From ca9c1aaec4187fc9922cfb6b283fffef89286943 Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Tue, 6 Jan 2009 20:11:51 +0000 Subject: ASoC: dapm: Allow explictly named mixer controls This patch allows you to define the mixer paths as having the same name as the paths they represent. This is required to support codecs such as the wm9705 neatly without extra controls in the alsa mixer. Signed-off-by: Ian Molton --- sound/soc/soc-dapm.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index ad0d801677c..6362c7641ce 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -54,14 +54,15 @@ static int dapm_up_seq[] = { snd_soc_dapm_pre, snd_soc_dapm_micbias, snd_soc_dapm_mic, snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_dac, - snd_soc_dapm_mixer, snd_soc_dapm_pga, snd_soc_dapm_adc, snd_soc_dapm_hp, - snd_soc_dapm_spk, snd_soc_dapm_post + snd_soc_dapm_mixer, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_pga, + snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, snd_soc_dapm_post }; + static int dapm_down_seq[] = { snd_soc_dapm_pre, snd_soc_dapm_adc, snd_soc_dapm_hp, snd_soc_dapm_spk, - snd_soc_dapm_pga, snd_soc_dapm_mixer, snd_soc_dapm_dac, snd_soc_dapm_mic, - snd_soc_dapm_micbias, snd_soc_dapm_mux, snd_soc_dapm_value_mux, - snd_soc_dapm_post + snd_soc_dapm_pga, snd_soc_dapm_mixer_named_ctl, snd_soc_dapm_mixer, + snd_soc_dapm_dac, snd_soc_dapm_mic, snd_soc_dapm_micbias, + snd_soc_dapm_mux, snd_soc_dapm_value_mux, snd_soc_dapm_post }; static int dapm_status = 1; @@ -101,7 +102,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, { switch (w->id) { case snd_soc_dapm_switch: - case snd_soc_dapm_mixer: { + case snd_soc_dapm_mixer: + case snd_soc_dapm_mixer_named_ctl: { int val; struct soc_mixer_control *mc = (struct soc_mixer_control *) w->kcontrols[i].private_value; @@ -347,15 +349,33 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, if (path->name != (char*)w->kcontrols[i].name) continue; - /* add dapm control with long name */ - name_len = 2 + strlen(w->name) - + strlen(w->kcontrols[i].name); + /* add dapm control with long name. + * for dapm_mixer this is the concatenation of the + * mixer and kcontrol name. + * for dapm_mixer_named_ctl this is simply the + * kcontrol name. + */ + name_len = strlen(w->kcontrols[i].name) + 1; + if (w->id == snd_soc_dapm_mixer) + name_len += 1 + strlen(w->name); + path->long_name = kmalloc(name_len, GFP_KERNEL); + if (path->long_name == NULL) return -ENOMEM; - snprintf(path->long_name, name_len, "%s %s", - w->name, w->kcontrols[i].name); + switch (w->id) { + case snd_soc_dapm_mixer: + default: + snprintf(path->long_name, name_len, "%s %s", + w->name, w->kcontrols[i].name); + break; + case snd_soc_dapm_mixer_named_ctl: + snprintf(path->long_name, name_len, "%s", + w->kcontrols[i].name); + break; + } + path->long_name[name_len - 1] = '\0'; path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w, @@ -711,6 +731,7 @@ static void dbg_dump_dapm(struct snd_soc_codec* codec, const char *action) case snd_soc_dapm_adc: case snd_soc_dapm_pga: case snd_soc_dapm_mixer: + case snd_soc_dapm_mixer_named_ctl: if (w->name) { in = is_connected_input_ep(w); dapm_clear_walk(w->codec); @@ -822,6 +843,7 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, int found = 0; if (widget->id != snd_soc_dapm_mixer && + widget->id != snd_soc_dapm_mixer_named_ctl && widget->id != snd_soc_dapm_switch) return -ENODEV; @@ -875,6 +897,7 @@ static ssize_t dapm_widget_show(struct device *dev, case snd_soc_dapm_adc: case snd_soc_dapm_pga: case snd_soc_dapm_mixer: + case snd_soc_dapm_mixer_named_ctl: if (w->name) count += sprintf(buf + count, "%s: %s\n", w->name, w->power ? "On":"Off"); @@ -1058,6 +1081,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_codec *codec, break; case snd_soc_dapm_switch: case snd_soc_dapm_mixer: + case snd_soc_dapm_mixer_named_ctl: ret = dapm_connect_mixer(codec, wsource, wsink, path, control); if (ret != 0) goto err; @@ -1135,6 +1159,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_codec *codec) switch(w->id) { case snd_soc_dapm_switch: case snd_soc_dapm_mixer: + case snd_soc_dapm_mixer_named_ctl: dapm_new_mixer(codec, w); break; case snd_soc_dapm_mux: -- cgit v1.2.3 From 1649923dd52ce914be98bff0ae352344ef04f305 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 7 Jan 2009 18:25:13 +0000 Subject: ASoC: Constify pin names for DAPM pin status APIs Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 6362c7641ce..a35ce69d9d7 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -961,7 +961,7 @@ static void dapm_free_widgets(struct snd_soc_codec *codec) } static int snd_soc_dapm_set_pin(struct snd_soc_codec *codec, - char *pin, int status) + const char *pin, int status) { struct snd_soc_dapm_widget *w; @@ -1643,7 +1643,7 @@ int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev, * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to * do any widget power switching. */ -int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, char *pin) +int snd_soc_dapm_enable_pin(struct snd_soc_codec *codec, const char *pin) { return snd_soc_dapm_set_pin(codec, pin, 1); } @@ -1658,7 +1658,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to * do any widget power switching. */ -int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, char *pin) +int snd_soc_dapm_disable_pin(struct snd_soc_codec *codec, const char *pin) { return snd_soc_dapm_set_pin(codec, pin, 0); } @@ -1678,7 +1678,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin); * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to * do any widget power switching. */ -int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, char *pin) +int snd_soc_dapm_nc_pin(struct snd_soc_codec *codec, const char *pin) { return snd_soc_dapm_set_pin(codec, pin, 0); } @@ -1693,7 +1693,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin); * * Returns 1 for connected otherwise 0. */ -int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, char *pin) +int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin) { struct snd_soc_dapm_widget *w; -- cgit v1.2.3 From 8a2cd6180f8fa00111843c2f4a4f4361995358e0 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 7 Jan 2009 17:31:10 +0000 Subject: ASoC: Add jack reporting interface This patch adds a jack reporting interface to ASoC. This wraps the ALSA core jack detection functionality and provides integration with DAPM to automatically update the power state of pins based on the jack state. Since embedded platforms can have multiple detecton methods used for a single jack (eg, separate microphone and headphone detection) the report function allows specification of which bits are being updated on a given report. The expected usage is that machine drivers will create jack objects and then configure jack detection methods to update that jack. Signed-off-by: Mark Brown --- sound/soc/Kconfig | 1 + sound/soc/Makefile | 2 +- sound/soc/soc-jack.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 sound/soc/soc-jack.c (limited to 'sound/soc') diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index ef025c66cc6..3d2bb6fc6dc 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -6,6 +6,7 @@ menuconfig SND_SOC tristate "ALSA for SoC audio support" select SND_PCM select AC97_BUS if SND_SOC_AC97_BUS + select SND_JACK if INPUT=y || INPUT=SND ---help--- If you want ASoC support, you should say Y here and also to the diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 86a9b1f5b0f..0237879fd41 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -1,4 +1,4 @@ -snd-soc-core-objs := soc-core.o soc-dapm.o +snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o obj-$(CONFIG_SND_SOC) += snd-soc-core.o obj-$(CONFIG_SND_SOC) += codecs/ diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c new file mode 100644 index 00000000000..8cc00c3cdf3 --- /dev/null +++ b/sound/soc/soc-jack.c @@ -0,0 +1,138 @@ +/* + * soc-jack.c -- ALSA SoC jack handling + * + * Copyright 2008 Wolfson Microelectronics PLC. + * + * Author: Mark Brown + * + * 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 +#include +#include + +/** + * snd_soc_jack_new - Create a new jack + * @card: ASoC card + * @id: an identifying string for this jack + * @type: a bitmask of enum snd_jack_type values that can be detected by + * this jack + * @jack: structure to use for the jack + * + * Creates a new jack object. + * + * Returns zero if successful, or a negative error code on failure. + * On success jack will be initialised. + */ +int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, + struct snd_soc_jack *jack) +{ + jack->card = card; + INIT_LIST_HEAD(&jack->pins); + + return snd_jack_new(card->socdev->codec->card, id, type, &jack->jack); +} +EXPORT_SYMBOL_GPL(snd_soc_jack_new); + +/** + * snd_soc_jack_report - Report the current status for a jack + * + * @jack: the jack + * @status: a bitmask of enum snd_jack_type values that are currently detected. + * @mask: a bitmask of enum snd_jack_type values that being reported. + * + * If configured using snd_soc_jack_add_pins() then the associated + * DAPM pins will be enabled or disabled as appropriate and DAPM + * synchronised. + * + * Note: This function uses mutexes and should be called from a + * context which can sleep (such as a workqueue). + */ +void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) +{ + struct snd_soc_codec *codec = jack->card->socdev->codec; + struct snd_soc_jack_pin *pin; + int enable; + int oldstatus; + + if (!jack) { + WARN_ON_ONCE(!jack); + return; + } + + mutex_lock(&codec->mutex); + + oldstatus = jack->status; + + jack->status &= ~mask; + jack->status |= status; + + /* The DAPM sync is expensive enough to be worth skipping */ + if (jack->status == oldstatus) + goto out; + + list_for_each_entry(pin, &jack->pins, list) { + enable = pin->mask & status; + + if (pin->invert) + enable = !enable; + + if (enable) + snd_soc_dapm_enable_pin(codec, pin->pin); + else + snd_soc_dapm_disable_pin(codec, pin->pin); + } + + snd_soc_dapm_sync(codec); + + snd_jack_report(jack->jack, status); + +out: + mutex_unlock(&codec->mutex); +} +EXPORT_SYMBOL_GPL(snd_soc_jack_report); + +/** + * snd_soc_jack_add_pins - Associate DAPM pins with an ASoC jack + * + * @jack: ASoC jack + * @count: Number of pins + * @pins: Array of pins + * + * After this function has been called the DAPM pins specified in the + * pins array will have their status updated to reflect the current + * state of the jack whenever the jack status is updated. + */ +int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, + struct snd_soc_jack_pin *pins) +{ + int i; + + for (i = 0; i < count; i++) { + if (!pins[i].pin) { + printk(KERN_ERR "No name for pin %d\n", i); + return -EINVAL; + } + if (!pins[i].mask) { + printk(KERN_ERR "No mask for pin %d (%s)\n", i, + pins[i].pin); + return -EINVAL; + } + + INIT_LIST_HEAD(&pins[i].list); + list_add(&(pins[i].list), &jack->pins); + } + + /* Update to reflect the last reported status; canned jack + * implementations are likely to set their state before the + * card has an opportunity to associate pins. + */ + snd_soc_jack_report(jack, 0, 0); + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins); -- cgit v1.2.3 From a6ba2b2dabb583e7820e567fb309d771b50cb9ff Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 8 Jan 2009 15:16:16 +0000 Subject: ASoC: Implement WM8350 headphone jack detection Signed-off-by: Mark Brown --- sound/soc/codecs/wm8350.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/wm8350.h | 8 ++++ 2 files changed, 124 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index e3989d406f5..47a9dabb523 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -51,10 +51,17 @@ struct wm8350_output { u16 mute; }; +struct wm8350_jack_data { + struct snd_soc_jack *jack; + int report; +}; + struct wm8350_data { struct snd_soc_codec codec; struct wm8350_output out1; struct wm8350_output out2; + struct wm8350_jack_data hpl; + struct wm8350_jack_data hpr; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; }; @@ -1328,6 +1335,95 @@ static int wm8350_resume(struct platform_device *pdev) return 0; } +static void wm8350_hp_jack_handler(struct wm8350 *wm8350, int irq, void *data) +{ + struct wm8350_data *priv = data; + u16 reg; + int report; + int mask; + struct wm8350_jack_data *jack = NULL; + + switch (irq) { + case WM8350_IRQ_CODEC_JCK_DET_L: + jack = &priv->hpl; + mask = WM8350_JACK_L_LVL; + break; + + case WM8350_IRQ_CODEC_JCK_DET_R: + jack = &priv->hpr; + mask = WM8350_JACK_R_LVL; + break; + + default: + BUG(); + } + + if (!jack->jack) { + dev_warn(wm8350->dev, "Jack interrupt called with no jack\n"); + return; + } + + /* Debounce */ + msleep(200); + + reg = wm8350_reg_read(wm8350, WM8350_JACK_PIN_STATUS); + if (reg & mask) + report = jack->report; + else + report = 0; + + snd_soc_jack_report(jack->jack, report, jack->report); +} + +/** + * wm8350_hp_jack_detect - Enable headphone jack detection. + * + * @codec: WM8350 codec + * @which: left or right jack detect signal + * @jack: jack to report detection events on + * @report: value to report + * + * Enables the headphone jack detection of the WM8350. + */ +int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, + struct snd_soc_jack *jack, int report) +{ + struct wm8350_data *priv = codec->private_data; + struct wm8350 *wm8350 = codec->control_data; + int irq; + int ena; + + switch (which) { + case WM8350_JDL: + priv->hpl.jack = jack; + priv->hpl.report = report; + irq = WM8350_IRQ_CODEC_JCK_DET_L; + ena = WM8350_JDL_ENA; + break; + + case WM8350_JDR: + priv->hpr.jack = jack; + priv->hpr.report = report; + irq = WM8350_IRQ_CODEC_JCK_DET_R; + ena = WM8350_JDR_ENA; + break; + + default: + return -EINVAL; + } + + wm8350_set_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); + wm8350_set_bits(wm8350, WM8350_JACK_DETECT, ena); + + /* Sync status */ + wm8350_hp_jack_handler(wm8350, irq, priv); + + wm8350_unmask_irq(wm8350, irq); + + return 0; +} +EXPORT_SYMBOL_GPL(wm8350_hp_jack_detect); + static struct snd_soc_codec *wm8350_codec; static int wm8350_probe(struct platform_device *pdev) @@ -1381,6 +1477,13 @@ static int wm8350_probe(struct platform_device *pdev) wm8350_set_bits(wm8350, WM8350_ROUT2_VOLUME, WM8350_OUT2_VU | WM8350_OUT2R_MUTE); + wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); + wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); + wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, + wm8350_hp_jack_handler, priv); + wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, + wm8350_hp_jack_handler, priv); + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { dev_err(&pdev->dev, "failed to create pcms\n"); @@ -1411,8 +1514,21 @@ static int wm8350_remove(struct platform_device *pdev) struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->codec; struct wm8350 *wm8350 = codec->control_data; + struct wm8350_data *priv = codec->private_data; int ret; + wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, + WM8350_JDL_ENA | WM8350_JDR_ENA); + wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_4, WM8350_TOCLK_ENA); + + wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); + wm8350_mask_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L); + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R); + + priv->hpl.jack = NULL; + priv->hpr.jack = NULL; + /* cancel any work waiting to be queued. */ ret = cancel_delayed_work(&codec->delayed_work); diff --git a/sound/soc/codecs/wm8350.h b/sound/soc/codecs/wm8350.h index cc2887aa6c3..d11bd9288cf 100644 --- a/sound/soc/codecs/wm8350.h +++ b/sound/soc/codecs/wm8350.h @@ -17,4 +17,12 @@ extern struct snd_soc_dai wm8350_dai; extern struct snd_soc_codec_device soc_codec_dev_wm8350; +enum wm8350_jack { + WM8350_JDL = 1, + WM8350_JDR = 2, +}; + +int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, + struct snd_soc_jack *jack, int report); + #endif -- cgit v1.2.3 From 3e8e1952e3a3dd59b11233a532ca68e6471742d9 Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Fri, 9 Jan 2009 00:23:21 +0000 Subject: ASoC: cleanup duplicated code. Many codec drivers were implementing cookie-cutter copies of the function that adds kcontrols to the codec. This patch moves this code to a common function snd_soc_add_controls() in soc-core.c and updates all drivers using copies of this function to use the new common version. [Edited to raise priority of error log message and document parameters. -- broonie] Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/codecs/ad1980.c | 17 ++------------ sound/soc/codecs/ak4535.c | 18 ++------------- sound/soc/codecs/ssm2602.c | 18 ++------------- sound/soc/codecs/tlv320aic23.c | 21 ++---------------- sound/soc/codecs/tlv320aic3x.c | 19 ++-------------- sound/soc/codecs/twl4030.c | 19 ++-------------- sound/soc/codecs/uda134x.c | 50 ++++++++++++++---------------------------- sound/soc/codecs/uda1380.c | 18 ++------------- sound/soc/codecs/wm8350.c | 18 ++------------- sound/soc/codecs/wm8510.c | 19 ++-------------- sound/soc/codecs/wm8580.c | 17 ++------------ sound/soc/codecs/wm8728.c | 18 ++------------- sound/soc/codecs/wm8731.c | 19 ++-------------- sound/soc/codecs/wm8750.c | 18 ++------------- sound/soc/codecs/wm8753.c | 18 ++------------- sound/soc/codecs/wm8900.c | 19 ++-------------- sound/soc/codecs/wm8903.c | 18 ++------------- sound/soc/codecs/wm8971.c | 18 ++------------- sound/soc/codecs/wm8990.c | 18 ++------------- sound/soc/codecs/wm9712.c | 18 ++------------- sound/soc/codecs/wm9713.c | 18 ++------------- sound/soc/soc-core.c | 31 ++++++++++++++++++++++++++ 22 files changed, 87 insertions(+), 360 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index 73fdbb4d4a3..c3c5d0eee37 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c @@ -93,20 +93,6 @@ SOC_ENUM("Capture Source", ad1980_cap_src), SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0), }; -/* add non dapm controls */ -static int ad1980_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(ad1980_snd_ac97_controls); i++) { - err = snd_ctl_add(codec->card, snd_soc_cnew( - &ad1980_snd_ac97_controls[i], codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - static unsigned int ac97_read(struct snd_soc_codec *codec, unsigned int reg) { @@ -269,7 +255,8 @@ static int ad1980_soc_probe(struct platform_device *pdev) ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); - ad1980_add_controls(codec); + snd_soc_add_controls(codec, ad1980_snd_ac97_controls, + ARRAY_SIZE(ad1980_snd_ac97_controls)); ret = snd_soc_init_card(socdev); if (ret < 0) { printk(KERN_ERR "ad1980: failed to register card\n"); diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index 81300d8d42c..f17c363cb1d 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -155,21 +155,6 @@ static const struct snd_kcontrol_new ak4535_snd_controls[] = { SOC_SINGLE("Mic Sidetone Volume", AK4535_VOL, 4, 7, 0), }; -/* add non dapm controls */ -static int ak4535_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(ak4535_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&ak4535_snd_controls[i], codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* Mono 1 Mixer */ static const struct snd_kcontrol_new ak4535_mono1_mixer_controls[] = { SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4535_SIG1, 4, 1, 0), @@ -510,7 +495,8 @@ static int ak4535_init(struct snd_soc_device *socdev) /* power on device */ ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - ak4535_add_controls(codec); + snd_soc_add_controls(codec, ak4535_snd_controls, + ARRAY_SIZE(ak4535_snd_controls)); ak4535_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index cac37361676..ec7fe3b7b0c 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -151,21 +151,6 @@ SOC_ENUM("Capture Source", ssm2602_enum[0]), SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]), }; -/* add non dapm controls */ -static int ssm2602_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(ssm2602_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&ssm2602_snd_controls[i], codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* Output Mixer */ static const struct snd_kcontrol_new ssm2602_output_mixer_controls[] = { SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0), @@ -622,7 +607,8 @@ static int ssm2602_init(struct snd_soc_device *socdev) APANA_ENABLE_MIC_BOOST); ssm2602_write(codec, SSM2602_PWR, 0); - ssm2602_add_controls(codec); + snd_soc_add_controls(codec, ssm2602_snd_controls, + ARRAY_SIZE(ssm2602_snd_controls)); ssm2602_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index cfdea007c4c..a0e47c1dcd6 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -183,24 +183,6 @@ static const struct snd_kcontrol_new tlv320aic23_snd_controls[] = { SOC_ENUM("Playback De-emphasis", tlv320aic23_deemph), }; -/* add non dapm controls */ -static int tlv320aic23_add_controls(struct snd_soc_codec *codec) -{ - - int err, i; - - for (i = 0; i < ARRAY_SIZE(tlv320aic23_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&tlv320aic23_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; - -} - /* PGA Mixer controls for Line and Mic switch */ static const struct snd_kcontrol_new tlv320aic23_output_mixer_controls[] = { SOC_DAPM_SINGLE("Line Bypass Switch", TLV320AIC23_ANLG, 3, 1, 0), @@ -718,7 +700,8 @@ static int tlv320aic23_init(struct snd_soc_device *socdev) tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x1); - tlv320aic23_add_controls(codec); + snd_soc_add_controls(codec, tlv320aic23_snd_controls, + ARRAY_SIZE(tlv320aic23_snd_controls)); tlv320aic23_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index b47a749c5ea..36ab0198ca3 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -311,22 +311,6 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), }; -/* add non dapm controls */ -static int aic3x_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(aic3x_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&aic3x_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* Left DAC Mux */ static const struct snd_kcontrol_new aic3x_left_dac_mux_controls = SOC_DAPM_ENUM("Route", aic3x_enum[LDAC_ENUM]); @@ -1224,7 +1208,8 @@ static int aic3x_init(struct snd_soc_device *socdev) aic3x_write(codec, AIC3X_GPIO1_REG, (setup->gpio_func[0] & 0xf) << 4); aic3x_write(codec, AIC3X_GPIO2_REG, (setup->gpio_func[1] & 0xf) << 4); - aic3x_add_controls(codec); + snd_soc_add_controls(codec, aic3x_snd_controls, + ARRAY_SIZE(aic3x_snd_controls)); aic3x_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index fd0f338374a..253063fd319 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -670,22 +670,6 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = { 0, 3, 5, 0, input_gain_tlv), }; -/* add non dapm controls */ -static int twl4030_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(twl4030_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&twl4030_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { /* Left channel inputs */ SND_SOC_DAPM_INPUT("MAINMIC"), @@ -1233,7 +1217,8 @@ static int twl4030_init(struct snd_soc_device *socdev) /* power on device */ twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - twl4030_add_controls(codec); + snd_soc_add_controls(codec, twl4030_snd_controls, + ARRAY_SIZE(twl4030_snd_controls)); twl4030_add_widgets(codec); ret = snd_soc_init_card(socdev); diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index a2c5064a774..277825d155a 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -431,39 +431,6 @@ SOC_ENUM("PCM Playback De-emphasis", uda134x_mixer_enum[1]), SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), }; -static int uda134x_add_controls(struct snd_soc_codec *codec) -{ - int err, i, n; - const struct snd_kcontrol_new *ctrls; - struct uda134x_platform_data *pd = codec->control_data; - - switch (pd->model) { - case UDA134X_UDA1340: - case UDA134X_UDA1344: - n = ARRAY_SIZE(uda1340_snd_controls); - ctrls = uda1340_snd_controls; - break; - case UDA134X_UDA1341: - n = ARRAY_SIZE(uda1341_snd_controls); - ctrls = uda1341_snd_controls; - break; - default: - printk(KERN_ERR "%s unkown codec type: %d", - __func__, pd->model); - return -EINVAL; - } - - for (i = 0; i < n; i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&ctrls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - struct snd_soc_dai uda134x_dai = { .name = "UDA134X", /* playback capabilities */ @@ -572,7 +539,22 @@ static int uda134x_soc_probe(struct platform_device *pdev) goto pcm_err; } - ret = uda134x_add_controls(codec); + switch (pd->model) { + case UDA134X_UDA1340: + case UDA134X_UDA1344: + ret = snd_soc_add_controls(codec, uda1340_snd_controls, + ARRAY_SIZE(uda1340_snd_controls)); + break; + case UDA134X_UDA1341: + ret = snd_soc_add_controls(codec, uda1341_snd_controls, + ARRAY_SIZE(uda1341_snd_controls)); + break; + default: + printk(KERN_ERR "%s unkown codec type: %d", + __func__, pd->model); + return -EINVAL; + } + if (ret < 0) { printk(KERN_ERR "UDA134X: failed to register controls\n"); goto pcm_err; diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index e6bf0844fbf..a957b4365b9 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -271,21 +271,6 @@ static const struct snd_kcontrol_new uda1380_snd_controls[] = { SOC_SINGLE("AGC Switch", UDA1380_AGC, 0, 1, 0), }; -/* add non dapm controls */ -static int uda1380_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(uda1380_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&uda1380_snd_controls[i], codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* Input mux */ static const struct snd_kcontrol_new uda1380_input_mux_control = SOC_DAPM_ENUM("Route", uda1380_input_sel_enum); @@ -675,7 +660,8 @@ static int uda1380_init(struct snd_soc_device *socdev, int dac_clk) } /* uda1380 init */ - uda1380_add_controls(codec); + snd_soc_add_controls(codec, uda1380_snd_controls, + ARRAY_SIZE(uda1380_snd_controls)); uda1380_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 47a9dabb523..2e0db29b499 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -782,21 +782,6 @@ static const struct snd_soc_dapm_route audio_map[] = { {"Beep", NULL, "IN3R PGA"}, }; -static int wm8350_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8350_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8350_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - static int wm8350_add_widgets(struct snd_soc_codec *codec) { int ret; @@ -1490,7 +1475,8 @@ static int wm8350_probe(struct platform_device *pdev) return ret; } - wm8350_add_controls(codec); + snd_soc_add_controls(codec, wm8350_snd_controls, + ARRAY_SIZE(wm8350_snd_controls)); wm8350_add_widgets(codec); wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 40f8238df71..abe7cce8771 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -171,22 +171,6 @@ SOC_SINGLE("Capture Boost(+20dB)", WM8510_ADCBOOST, 8, 1, 0), SOC_SINGLE("Mono Playback Switch", WM8510_MONOMIX, 6, 1, 1), }; -/* add non dapm controls */ -static int wm8510_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8510_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8510_snd_controls[i], codec, - NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* Speaker Output Mixer */ static const struct snd_kcontrol_new wm8510_speaker_mixer_controls[] = { SOC_DAPM_SINGLE("Line Bypass Switch", WM8510_SPKMIX, 1, 1, 0), @@ -656,7 +640,8 @@ static int wm8510_init(struct snd_soc_device *socdev) /* power on device */ codec->bias_level = SND_SOC_BIAS_OFF; wm8510_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - wm8510_add_controls(codec); + snd_soc_add_controls(codec, wm8510_snd_controls, + ARRAY_SIZE(wm8510_snd_controls)); wm8510_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index d004e584529..9b75a377453 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -330,20 +330,6 @@ SOC_DOUBLE("ADC Mute Switch", WM8580_ADC_CONTROL1, 0, 1, 1, 0), SOC_SINGLE("ADC High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0), }; -/* Add non-DAPM controls */ -static int wm8580_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8580_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8580_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - return 0; -} static const struct snd_soc_dapm_widget wm8580_dapm_widgets[] = { SND_SOC_DAPM_DAC("DAC1", "Playback", WM8580_PWRDN1, 2, 1), SND_SOC_DAPM_DAC("DAC2", "Playback", WM8580_PWRDN1, 3, 1), @@ -866,7 +852,8 @@ static int wm8580_init(struct snd_soc_device *socdev) goto pcm_err; } - wm8580_add_controls(codec); + snd_soc_add_controls(codec, wm8580_snd_controls, + ARRAY_SIZE(wm8580_snd_controls)); wm8580_add_widgets(codec); ret = snd_soc_init_card(socdev); diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index 80b11983e13..defa310bc7d 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -92,21 +92,6 @@ SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8728_DACLVOL, WM8728_DACRVOL, SOC_SINGLE("Deemphasis", WM8728_DACCTL, 1, 1, 0), }; -static int wm8728_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8728_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8728_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* * DAPM controls. */ @@ -330,7 +315,8 @@ static int wm8728_init(struct snd_soc_device *socdev) /* power on device */ wm8728_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - wm8728_add_controls(codec); + snd_soc_add_controls(codec, wm8728_snd_controls, + ARRAY_SIZE(wm8728_snd_controls)); wm8728_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index c444b9f2701..96d6e1aeaf4 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -129,22 +129,6 @@ SOC_SINGLE("Store DC Offset Switch", WM8731_APDIGI, 4, 1, 0), SOC_ENUM("Playback De-emphasis", wm8731_enum[1]), }; -/* add non dapm controls */ -static int wm8731_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8731_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - /* Output Mixer */ static const struct snd_kcontrol_new wm8731_output_mixer_controls[] = { SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0), @@ -543,7 +527,8 @@ static int wm8731_init(struct snd_soc_device *socdev) reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); - wm8731_add_controls(codec); + snd_soc_add_controls(codec, wm8731_snd_controls, + ARRAY_SIZE(wm8731_snd_controls)); wm8731_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 5997fa68e0d..1578569793a 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -231,21 +231,6 @@ SOC_SINGLE("Mono Playback Volume", WM8750_MOUTV, 0, 127, 0), }; -/* add non dapm controls */ -static int wm8750_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8750_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - /* * DAPM Controls */ @@ -816,7 +801,8 @@ static int wm8750_init(struct snd_soc_device *socdev) reg = wm8750_read_reg_cache(codec, WM8750_RINVOL); wm8750_write(codec, WM8750_RINVOL, reg | 0x0100); - wm8750_add_controls(codec); + snd_soc_add_controls(codec, wm8750_snd_controls, + ARRAY_SIZE(wm8750_snd_controls)); wm8750_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 6c21b50c937..7283178e0eb 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -339,21 +339,6 @@ SOC_ENUM("ADC Data Select", wm8753_enum[27]), SOC_ENUM("ROUT2 Phase", wm8753_enum[28]), }; -/* add non dapm controls */ -static int wm8753_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8753_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8753_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - /* * _DAPM_ Controls */ @@ -1603,7 +1588,8 @@ static int wm8753_init(struct snd_soc_device *socdev) reg = wm8753_read_reg_cache(codec, WM8753_RINVOL); wm8753_write(codec, WM8753_RINVOL, reg | 0x0100); - wm8753_add_controls(codec); + snd_soc_add_controls(codec, wm8753_snd_controls, + ARRAY_SIZE(wm8753_snd_controls)); wm8753_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 6767de10ded..1e08d4f065f 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -517,22 +517,6 @@ SOC_SINGLE("LINEOUT2 LP -12dB", WM8900_REG_LOUTMIXCTL1, }; -/* add non dapm controls */ -static int wm8900_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8900_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8900_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - static const struct snd_kcontrol_new wm8900_dapm_loutput2_control = SOC_DAPM_SINGLE("LINEOUT2L Switch", WM8900_REG_POWER3, 6, 1, 0); @@ -1439,7 +1423,8 @@ static int wm8900_probe(struct platform_device *pdev) goto pcm_err; } - wm8900_add_controls(codec); + snd_soc_add_controls(codec, wm8900_snd_controls, + ARRAY_SIZE(wm8900_snd_controls)); wm8900_add_widgets(codec); ret = snd_soc_init_card(socdev); diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index bde74546db4..6ff34b957dc 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -744,21 +744,6 @@ SOC_DOUBLE_R_TLV("Speaker Volume", 0, 63, 0, out_tlv), }; -static int wm8903_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8903_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8903_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - static const struct snd_kcontrol_new linput_mode_mux = SOC_DAPM_ENUM("Left Input Mode Mux", linput_mode_enum); @@ -1737,7 +1722,8 @@ static int wm8903_probe(struct platform_device *pdev) goto err; } - wm8903_add_controls(socdev->codec); + snd_soc_add_controls(socdev->codec, wm8903_snd_controls, + ARRAY_SIZE(wm8903_snd_controls)); wm8903_add_widgets(socdev->codec); ret = snd_soc_init_card(socdev); diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 88ead7f8dd9..c8bd9b06f33 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -195,21 +195,6 @@ static const struct snd_kcontrol_new wm8971_snd_controls[] = { SOC_DOUBLE_R("Mic Boost", WM8971_LADCIN, WM8971_RADCIN, 4, 3, 0), }; -/* add non-DAPM controls */ -static int wm8971_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8971_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8971_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - /* * DAPM Controls */ @@ -745,7 +730,8 @@ static int wm8971_init(struct snd_soc_device *socdev) reg = wm8971_read_reg_cache(codec, WM8971_RINVOL); wm8971_write(codec, WM8971_RINVOL, reg | 0x0100); - wm8971_add_controls(codec); + snd_soc_add_controls(codec, wm8971_snd_controls, + ARRAY_SIZE(wm8971_snd_controls)); wm8971_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 5b5afc14447..6b2778632d5 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -417,21 +417,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME, }; -/* add non dapm controls */ -static int wm8990_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8990_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8990_snd_controls[i], codec, - NULL)); - if (err < 0) - return err; - } - return 0; -} - /* * _DAPM_ Controls */ @@ -1460,7 +1445,8 @@ static int wm8990_init(struct snd_soc_device *socdev) wm8990_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); wm8990_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); - wm8990_add_controls(codec); + snd_soc_add_controls(codec, wm8990_snd_controls, + ARRAY_SIZE(wm8990_snd_controls)); wm8990_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index af83d629078..1b0ace0f4dc 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -154,21 +154,6 @@ SOC_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1), SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0), }; -/* add non dapm controls */ -static int wm9712_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm9712_snd_ac97_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - /* We have to create a fake left and right HP mixers because * the codec only has a single control that is shared by both channels. * This makes it impossible to determine the audio path. @@ -698,7 +683,8 @@ static int wm9712_soc_probe(struct platform_device *pdev) ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); wm9712_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - wm9712_add_controls(codec); + snd_soc_add_controls(codec, wm9712_snd_ac97_controls, + ARRAY_SIZE(wm9712_snd_ac97_controls)); wm9712_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index f3ca8aaf013..a45622620db 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -190,21 +190,6 @@ SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0), SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), }; -/* add non dapm controls */ -static int wm9713_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm9713_snd_ac97_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm9713_snd_ac97_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - /* We have to create a fake left and right HP mixers because * the codec only has a single control that is shared by both channels. * This makes it impossible to determine the audio path using the current @@ -1245,7 +1230,8 @@ static int wm9713_soc_probe(struct platform_device *pdev) reg = ac97_read(codec, AC97_CD) & 0x7fff; ac97_write(codec, AC97_CD, reg); - wm9713_add_controls(codec); + snd_soc_add_controls(codec, wm9713_snd_ac97_controls, + ARRAY_SIZE(wm9713_snd_ac97_controls)); wm9713_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6cbe7e82f23..d3b97a7542e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1494,6 +1494,37 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, } EXPORT_SYMBOL_GPL(snd_soc_cnew); +/** + * snd_soc_add_controls - add an array of controls to a codec. + * Convienience function to add a list of controls. Many codecs were + * duplicating this code. + * + * @codec: codec to add controls to + * @controls: array of controls to add + * @num_controls: number of elements in the array + * + * Return 0 for success, else error. + */ +int snd_soc_add_controls(struct snd_soc_codec *codec, + const struct snd_kcontrol_new *controls, int num_controls) +{ + struct snd_card *card = codec->card; + int err, i; + + for (i = 0; i < num_controls; i++) { + const struct snd_kcontrol_new *control = &controls[i]; + err = snd_ctl_add(card, snd_soc_cnew(control, codec, NULL)); + if (err < 0) { + dev_err(codec->dev, "%s: Failed to add %s\n", + codec->name, control->name); + return err; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_add_controls); + /** * snd_soc_info_enum_double - enumerated double mixer info callback * @kcontrol: mixer control -- cgit v1.2.3 From bd7dd77c2a05c530684eea2e3af16449ae9c5d52 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 28 Dec 2008 16:45:02 +0100 Subject: ALSA: Convert to snd_card_create() in other sound/* Convert from snd_card_new() to the new snd_card_create() function in other sound subdirectories. Signed-off-by: Takashi Iwai --- sound/soc/soc-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6cbe7e82f23..318dfdd54d7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1311,17 +1311,17 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) { struct snd_soc_codec *codec = socdev->codec; struct snd_soc_card *card = socdev->card; - int ret = 0, i; + int ret, i; mutex_lock(&codec->mutex); /* register a sound card */ - codec->card = snd_card_new(idx, xid, codec->owner, 0); - if (!codec->card) { + ret = snd_card_create(idx, xid, codec->owner, 0, &codec->card); + if (ret < 0) { printk(KERN_ERR "asoc: can't create sound card for codec %s\n", codec->name); mutex_unlock(&codec->mutex); - return -ENODEV; + return ret; } codec->card->dev = socdev->dev; -- cgit v1.2.3 From ac37373b6463d32955c6ac6b753d5e5b0946a791 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Thu, 15 Jan 2009 15:40:35 -0500 Subject: ASoC: DaVinci: Fix SFFSDR compilation error. Remove dependency on sffsdr_fpga_set_codec_fs() when the SFFSDR FPGA module is not selected. Signed-off-by: Hugo Villeneuve Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-sffsdr.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c index 4935d1bcbd8..50baef1fe5b 100644 --- a/sound/soc/davinci/davinci-sffsdr.c +++ b/sound/soc/davinci/davinci-sffsdr.c @@ -25,7 +25,9 @@ #include #include +#ifdef CONFIG_SFFSDR_FPGA #include +#endif #include #include @@ -43,6 +45,17 @@ static int sffsdr_hw_params(struct snd_pcm_substream *substream, int fs; int ret = 0; + /* Fsref can be 32000, 44100 or 48000. */ + fs = params_rate(params); + +#ifndef CONFIG_SFFSDR_FPGA + /* Without the FPGA module, the Fs is fixed at 44100 Hz */ + if (fs != 44100) { + pr_debug("warning: only 44.1 kHz is supported without SFFSDR FPGA module\n"); + return -EINVAL; + } +#endif + /* Set cpu DAI configuration: * CLKX and CLKR are the inputs for the Sample Rate Generator. * FSX and FSR are outputs, driven by the sample Rate Generator. */ @@ -53,12 +66,13 @@ static int sffsdr_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - /* Fsref can be 32000, 44100 or 48000. */ - fs = params_rate(params); - pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs); +#ifndef CONFIG_SFFSDR_FPGA + return 0; +#else return sffsdr_fpga_set_codec_fs(fs); +#endif } static struct snd_soc_ops sffsdr_ops = { -- cgit v1.2.3 From 2aceefefc891e85d336c1d95d9d89fd785f5d44c Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Fri, 16 Jan 2009 11:04:18 +0000 Subject: ASoC: Driver for the WM9705 AC97 codec. This driver adds support for the wm9705 ac97 codec. The driver supports audio input and output. Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 3 + sound/soc/codecs/wm9705.c | 410 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/wm9705.h | 14 ++ 4 files changed, 431 insertions(+) create mode 100644 sound/soc/codecs/wm9705.c create mode 100644 sound/soc/codecs/wm9705.h (limited to 'sound/soc') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index d0e0d691ae5..cb5fcd605ac 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -34,6 +34,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_WM8903 if I2C select SND_SOC_WM8971 if I2C select SND_SOC_WM8990 if I2C + select SND_SOC_WM9705 if SND_SOC_AC97_BUS select SND_SOC_WM9712 if SND_SOC_AC97_BUS select SND_SOC_WM9713 if SND_SOC_AC97_BUS help @@ -144,6 +145,9 @@ config SND_SOC_WM8971 config SND_SOC_WM8990 tristate +config SND_SOC_WM9705 + tristate + config SND_SOC_WM9712 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index c4ddc9aa2bb..3664cdc300b 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -23,6 +23,7 @@ snd-soc-wm8900-objs := wm8900.o snd-soc-wm8903-objs := wm8903.o snd-soc-wm8971-objs := wm8971.o snd-soc-wm8990-objs := wm8990.o +snd-soc-wm9705-objs := wm9705.o snd-soc-wm9712-objs := wm9712.o snd-soc-wm9713-objs := wm9713.o @@ -51,5 +52,7 @@ obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o obj-$(CONFIG_SND_SOC_WM8971) += snd-soc-wm8971.o obj-$(CONFIG_SND_SOC_WM8990) += snd-soc-wm8990.o +obj-$(CONFIG_SND_SOC_WM8991) += snd-soc-wm8991.o +obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c new file mode 100644 index 00000000000..cb26b6a77ff --- /dev/null +++ b/sound/soc/codecs/wm9705.c @@ -0,0 +1,410 @@ +/* + * wm9705.c -- ALSA Soc WM9705 codec support + * + * Copyright 2008 Ian Molton + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; Version 2 of the License only. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * WM9705 register cache + */ +static const u16 wm9705_reg[] = { + 0x6150, 0x8000, 0x8000, 0x8000, /* 0x0 */ + 0x0000, 0x8000, 0x8008, 0x8008, /* 0x8 */ + 0x8808, 0x8808, 0x8808, 0x8808, /* 0x10 */ + 0x8808, 0x0000, 0x8000, 0x0000, /* 0x18 */ + 0x0000, 0x0000, 0x0000, 0x000f, /* 0x20 */ + 0x0605, 0x0000, 0xbb80, 0x0000, /* 0x28 */ + 0x0000, 0xbb80, 0x0000, 0x0000, /* 0x30 */ + 0x0000, 0x2000, 0x0000, 0x0000, /* 0x38 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 0x40 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 0x48 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 0x50 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 0x58 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 0x60 */ + 0x0000, 0x0000, 0x0000, 0x0000, /* 0x68 */ + 0x0000, 0x0808, 0x0000, 0x0006, /* 0x70 */ + 0x0000, 0x0000, 0x574d, 0x4c05, /* 0x78 */ +}; + +static const struct snd_kcontrol_new wm9705_snd_ac97_controls[] = { + SOC_DOUBLE("Master Playback Volume", AC97_MASTER, 8, 0, 31, 1), + SOC_SINGLE("Master Playback Switch", AC97_MASTER, 15, 1, 1), + SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1), + SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 1, 1), + SOC_DOUBLE("PCM Playback Volume", AC97_PCM, 8, 0, 31, 1), + SOC_SINGLE("PCM Playback Switch", AC97_PCM, 15, 1, 1), + SOC_SINGLE("Mono Playback Volume", AC97_MASTER_MONO, 0, 31, 1), + SOC_SINGLE("Mono Playback Switch", AC97_MASTER_MONO, 15, 1, 1), + SOC_SINGLE("PCBeep Playback Volume", AC97_PC_BEEP, 1, 15, 1), + SOC_SINGLE("Phone Playback Volume", AC97_PHONE, 0, 31, 1), + SOC_DOUBLE("Line Playback Volume", AC97_LINE, 8, 0, 31, 1), + SOC_DOUBLE("CD Playback Volume", AC97_CD, 8, 0, 31, 1), + SOC_SINGLE("Mic Playback Volume", AC97_MIC, 0, 31, 1), + SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 6, 1, 0), + SOC_DOUBLE("PCM Capture Volume", AC97_REC_GAIN, 8, 0, 15, 0), + SOC_SINGLE("PCM Capture Switch", AC97_REC_GAIN, 15, 1, 1), +}; + +static const char *wm9705_mic[] = {"Mic 1", "Mic 2"}; +static const char *wm9705_rec_sel[] = {"Mic", "CD", "NC", "NC", + "Line", "Stereo Mix", "Mono Mix", "Phone"}; + +static const struct soc_enum wm9705_enum_mic = + SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 8, 2, wm9705_mic); +static const struct soc_enum wm9705_enum_rec_l = + SOC_ENUM_SINGLE(AC97_REC_SEL, 8, 8, wm9705_rec_sel); +static const struct soc_enum wm9705_enum_rec_r = + SOC_ENUM_SINGLE(AC97_REC_SEL, 0, 8, wm9705_rec_sel); + +/* Headphone Mixer */ +static const struct snd_kcontrol_new wm9705_hp_mixer_controls[] = { + SOC_DAPM_SINGLE("PCBeep Playback Switch", AC97_PC_BEEP, 15, 1, 1), + SOC_DAPM_SINGLE("CD Playback Switch", AC97_CD, 15, 1, 1), + SOC_DAPM_SINGLE("Mic Playback Switch", AC97_MIC, 15, 1, 1), + SOC_DAPM_SINGLE("Phone Playback Switch", AC97_PHONE, 15, 1, 1), + SOC_DAPM_SINGLE("Line Playback Switch", AC97_LINE, 15, 1, 1), +}; + +/* Mic source */ +static const struct snd_kcontrol_new wm9705_mic_src_controls = + SOC_DAPM_ENUM("Route", wm9705_enum_mic); + +/* Capture source */ +static const struct snd_kcontrol_new wm9705_capture_selectl_controls = + SOC_DAPM_ENUM("Route", wm9705_enum_rec_l); +static const struct snd_kcontrol_new wm9705_capture_selectr_controls = + SOC_DAPM_ENUM("Route", wm9705_enum_rec_r); + +/* DAPM widgets */ +static const struct snd_soc_dapm_widget wm9705_dapm_widgets[] = { + SND_SOC_DAPM_MUX("Mic Source", SND_SOC_NOPM, 0, 0, + &wm9705_mic_src_controls), + SND_SOC_DAPM_MUX("Left Capture Source", SND_SOC_NOPM, 0, 0, + &wm9705_capture_selectl_controls), + SND_SOC_DAPM_MUX("Right Capture Source", SND_SOC_NOPM, 0, 0, + &wm9705_capture_selectr_controls), + SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", + SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_MIXER_NAMED_CTL("HP Mixer", SND_SOC_NOPM, 0, 0, + &wm9705_hp_mixer_controls[0], + ARRAY_SIZE(wm9705_hp_mixer_controls)), + SND_SOC_DAPM_MIXER("Mono Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_PGA("Headphone PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Speaker PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Line PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Line out PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Mono PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Phone PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("Mic PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("PCBEEP PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("CD PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("ADC PGA", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_OUTPUT("HPOUTL"), + SND_SOC_DAPM_OUTPUT("HPOUTR"), + SND_SOC_DAPM_OUTPUT("LOUT"), + SND_SOC_DAPM_OUTPUT("ROUT"), + SND_SOC_DAPM_OUTPUT("MONOOUT"), + SND_SOC_DAPM_INPUT("PHONE"), + SND_SOC_DAPM_INPUT("LINEINL"), + SND_SOC_DAPM_INPUT("LINEINR"), + SND_SOC_DAPM_INPUT("CDINL"), + SND_SOC_DAPM_INPUT("CDINR"), + SND_SOC_DAPM_INPUT("PCBEEP"), + SND_SOC_DAPM_INPUT("MIC1"), + SND_SOC_DAPM_INPUT("MIC2"), +}; + +/* Audio map + * WM9705 has no switches to disable the route from the inputs to the HP mixer + * so in order to prevent active inputs from forcing the audio outputs to be + * constantly enabled, we use the mutes on those inputs to simulate such + * controls. + */ +static const struct snd_soc_dapm_route audio_map[] = { + /* HP mixer */ + {"HP Mixer", "PCBeep Playback Switch", "PCBEEP PGA"}, + {"HP Mixer", "CD Playback Switch", "CD PGA"}, + {"HP Mixer", "Mic Playback Switch", "Mic PGA"}, + {"HP Mixer", "Phone Playback Switch", "Phone PGA"}, + {"HP Mixer", "Line Playback Switch", "Line PGA"}, + {"HP Mixer", NULL, "Left DAC"}, + {"HP Mixer", NULL, "Right DAC"}, + + /* mono mixer */ + {"Mono Mixer", NULL, "HP Mixer"}, + + /* outputs */ + {"Headphone PGA", NULL, "HP Mixer"}, + {"HPOUTL", NULL, "Headphone PGA"}, + {"HPOUTR", NULL, "Headphone PGA"}, + {"Line out PGA", NULL, "HP Mixer"}, + {"LOUT", NULL, "Line out PGA"}, + {"ROUT", NULL, "Line out PGA"}, + {"Mono PGA", NULL, "Mono Mixer"}, + {"MONOOUT", NULL, "Mono PGA"}, + + /* inputs */ + {"CD PGA", NULL, "CDINL"}, + {"CD PGA", NULL, "CDINR"}, + {"Line PGA", NULL, "LINEINL"}, + {"Line PGA", NULL, "LINEINR"}, + {"Phone PGA", NULL, "PHONE"}, + {"Mic Source", "Mic 1", "MIC1"}, + {"Mic Source", "Mic 2", "MIC2"}, + {"Mic PGA", NULL, "Mic Source"}, + {"PCBEEP PGA", NULL, "PCBEEP"}, + + /* Left capture selector */ + {"Left Capture Source", "Mic", "Mic Source"}, + {"Left Capture Source", "CD", "CDINL"}, + {"Left Capture Source", "Line", "LINEINL"}, + {"Left Capture Source", "Stereo Mix", "HP Mixer"}, + {"Left Capture Source", "Mono Mix", "HP Mixer"}, + {"Left Capture Source", "Phone", "PHONE"}, + + /* Right capture source */ + {"Right Capture Source", "Mic", "Mic Source"}, + {"Right Capture Source", "CD", "CDINR"}, + {"Right Capture Source", "Line", "LINEINR"}, + {"Right Capture Source", "Stereo Mix", "HP Mixer"}, + {"Right Capture Source", "Mono Mix", "HP Mixer"}, + {"Right Capture Source", "Phone", "PHONE"}, + + {"ADC PGA", NULL, "Left Capture Source"}, + {"ADC PGA", NULL, "Right Capture Source"}, + + /* ADC's */ + {"Left ADC", NULL, "ADC PGA"}, + {"Right ADC", NULL, "ADC PGA"}, +}; + +static int wm9705_add_widgets(struct snd_soc_codec *codec) +{ + snd_soc_dapm_new_controls(codec, wm9705_dapm_widgets, + ARRAY_SIZE(wm9705_dapm_widgets)); + snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); + snd_soc_dapm_new_widgets(codec); + + return 0; +} + +/* We use a register cache to enhance read performance. */ +static unsigned int ac97_read(struct snd_soc_codec *codec, unsigned int reg) +{ + u16 *cache = codec->reg_cache; + + switch (reg) { + case AC97_RESET: + case AC97_VENDOR_ID1: + case AC97_VENDOR_ID2: + return soc_ac97_ops.read(codec->ac97, reg); + default: + reg = reg >> 1; + + if (reg >= (ARRAY_SIZE(wm9705_reg))) + return -EIO; + + return cache[reg]; + } +} + +static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int val) +{ + u16 *cache = codec->reg_cache; + + soc_ac97_ops.write(codec->ac97, reg, val); + reg = reg >> 1; + if (reg < (ARRAY_SIZE(wm9705_reg))) + cache[reg] = val; + + return 0; +} + +static int ac97_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->codec; + int reg; + u16 vra; + + vra = ac97_read(codec, AC97_EXTENDED_STATUS); + ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + reg = AC97_PCM_FRONT_DAC_RATE; + else + reg = AC97_PCM_LR_ADC_RATE; + + return ac97_write(codec, reg, runtime->rate); +} + +#define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \ + SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \ + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000) + +struct snd_soc_dai wm9705_dai[] = { + { + .name = "AC97 HiFi", + .ac97_control = 1, + .playback = { + .stream_name = "HiFi Playback", + .channels_min = 1, + .channels_max = 2, + .rates = WM9705_AC97_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "HiFi Capture", + .channels_min = 1, + .channels_max = 2, + .rates = WM9705_AC97_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .ops = { + .prepare = ac97_prepare, + }, + }, + { + .name = "AC97 Aux", + .playback = { + .stream_name = "Aux Playback", + .channels_min = 1, + .channels_max = 1, + .rates = WM9705_AC97_RATES, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + } +}; +EXPORT_SYMBOL_GPL(wm9705_dai); + +static int wm9705_reset(struct snd_soc_codec *codec) +{ + if (soc_ac97_ops.reset) { + soc_ac97_ops.reset(codec->ac97); + if (ac97_read(codec, 0) == wm9705_reg[0]) + return 0; /* Success */ + } + + return -EIO; +} + +static int wm9705_soc_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret = 0; + + printk(KERN_INFO "WM9705 SoC Audio Codec\n"); + + socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (socdev->codec == NULL) + return -ENOMEM; + codec = socdev->codec; + mutex_init(&codec->mutex); + + codec->reg_cache = kmemdup(wm9705_reg, sizeof(wm9705_reg), GFP_KERNEL); + if (codec->reg_cache == NULL) { + ret = -ENOMEM; + goto cache_err; + } + codec->reg_cache_size = sizeof(wm9705_reg); + codec->reg_cache_step = 2; + + codec->name = "WM9705"; + codec->owner = THIS_MODULE; + codec->dai = wm9705_dai; + codec->num_dai = ARRAY_SIZE(wm9705_dai); + codec->write = ac97_write; + codec->read = ac97_read; + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); + if (ret < 0) { + printk(KERN_ERR "wm9705: failed to register AC97 codec\n"); + goto codec_err; + } + + /* register pcms */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) + goto pcm_err; + + ret = wm9705_reset(codec); + if (ret) + goto reset_err; + + snd_soc_add_controls(codec, wm9705_snd_ac97_controls, + ARRAY_SIZE(wm9705_snd_ac97_controls)); + wm9705_add_widgets(codec); + + ret = snd_soc_init_card(socdev); + if (ret < 0) { + printk(KERN_ERR "wm9705: failed to register card\n"); + goto pcm_err; + } + + return 0; + +reset_err: + snd_soc_free_pcms(socdev); +pcm_err: + snd_soc_free_ac97_codec(codec); +codec_err: + kfree(codec->reg_cache); +cache_err: + kfree(socdev->codec); + socdev->codec = NULL; + return ret; +} + +static int wm9705_soc_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->codec; + + if (codec == NULL) + return 0; + + snd_soc_dapm_free(socdev); + snd_soc_free_pcms(socdev); + snd_soc_free_ac97_codec(codec); + kfree(codec->reg_cache); + kfree(codec); + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_wm9705 = { + .probe = wm9705_soc_probe, + .remove = wm9705_soc_remove, +}; +EXPORT_SYMBOL_GPL(soc_codec_dev_wm9705); + +MODULE_DESCRIPTION("ASoC WM9705 driver"); +MODULE_AUTHOR("Ian Molton"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/wm9705.h b/sound/soc/codecs/wm9705.h new file mode 100644 index 00000000000..d380f110f9e --- /dev/null +++ b/sound/soc/codecs/wm9705.h @@ -0,0 +1,14 @@ +/* + * wm9705.h -- WM9705 Soc Audio driver + */ + +#ifndef _WM9705_H +#define _WM9705_H + +#define WM9705_DAI_AC97_HIFI 0 +#define WM9705_DAI_AC97_AUX 1 + +extern struct snd_soc_dai wm9705_dai[2]; +extern struct snd_soc_codec_device soc_codec_dev_wm9705; + +#endif -- cgit v1.2.3 From a7e2e735dcf98717150d3c8eaa731de8038af05a Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Thu, 8 Jan 2009 21:03:55 +0000 Subject: ASoC: machine driver for Toshiba e750 This patch adds support for the wm9705 ac97 codec as used in the Toshiba e750 PDA. It includes support for powering up / down the external headphone and speaker amplifiers on this machine. Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/pxa/Kconfig | 9 +++ sound/soc/pxa/Makefile | 2 + sound/soc/pxa/e750_wm9705.c | 189 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 sound/soc/pxa/e750_wm9705.c (limited to 'sound/soc') diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index f82e1069947..b9b1a3f5d67 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig @@ -61,6 +61,15 @@ config SND_PXA2XX_SOC_TOSA Say Y if you want to add support for SoC audio on Sharp Zaurus SL-C6000x models (Tosa). +config SND_PXA2XX_SOC_E750 + tristate "SoC AC97 Audio support for e750" + depends on SND_PXA2XX_SOC && MACH_E750 + select SND_SOC_WM9705 + select SND_PXA2XX_SOC_AC97 + help + Say Y if you want to add support for SoC audio on the + toshiba e750 PDA + config SND_PXA2XX_SOC_E800 tristate "SoC AC97 Audio support for e800" depends on SND_PXA2XX_SOC && MACH_E800 diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 08a9f279772..c7d4cceeed9 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SND_PXA_SOC_SSP) += snd-soc-pxa-ssp.o snd-soc-corgi-objs := corgi.o snd-soc-poodle-objs := poodle.o snd-soc-tosa-objs := tosa.o +snd-soc-e750-objs := e750_wm9705.o snd-soc-e800-objs := e800_wm9712.o snd-soc-spitz-objs := spitz.o snd-soc-em-x270-objs := em-x270.o @@ -22,6 +23,7 @@ snd-soc-zylonite-objs := zylonite.o obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o +obj-$(CONFIG_SND_PXA2XX_SOC_E750) += snd-soc-e750.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 diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c new file mode 100644 index 00000000000..20fbdcfa9f7 --- /dev/null +++ b/sound/soc/pxa/e750_wm9705.c @@ -0,0 +1,189 @@ +/* + * e750-wm9705.c -- SoC audio for e750 + * + * Copyright 2007 (c) Ian Molton + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 ONLY. + * + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "../codecs/wm9705.h" +#include "pxa2xx-pcm.h" +#include "pxa2xx-ac97.h" + +static int e750_spk_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event & SND_SOC_DAPM_PRE_PMU) + gpio_set_value(GPIO_E750_SPK_AMP_OFF, 0); + else if (event & SND_SOC_DAPM_POST_PMD) + gpio_set_value(GPIO_E750_SPK_AMP_OFF, 1); + + return 0; +} + +static int e750_hp_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event & SND_SOC_DAPM_PRE_PMU) + gpio_set_value(GPIO_E750_HP_AMP_OFF, 0); + else if (event & SND_SOC_DAPM_POST_PMD) + gpio_set_value(GPIO_E750_HP_AMP_OFF, 1); + + return 0; +} + +static const struct snd_soc_dapm_widget e750_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_MIC("Mic (Internal)", NULL), + SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0, + e750_hp_amp_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0, + e750_spk_amp_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + {"Headphone Amp", NULL, "HPOUTL"}, + {"Headphone Amp", NULL, "HPOUTR"}, + {"Headphone Jack", NULL, "Headphone Amp"}, + + {"Speaker Amp", NULL, "MONOOUT"}, + {"Speaker", NULL, "Speaker Amp"}, + + {"MIC1", NULL, "Mic (Internal)"}, +}; + +static int e750_ac97_init(struct snd_soc_codec *codec) +{ + snd_soc_dapm_nc_pin(codec, "LOUT"); + snd_soc_dapm_nc_pin(codec, "ROUT"); + snd_soc_dapm_nc_pin(codec, "PHONE"); + snd_soc_dapm_nc_pin(codec, "LINEINL"); + snd_soc_dapm_nc_pin(codec, "LINEINR"); + snd_soc_dapm_nc_pin(codec, "CDINL"); + snd_soc_dapm_nc_pin(codec, "CDINR"); + snd_soc_dapm_nc_pin(codec, "PCBEEP"); + snd_soc_dapm_nc_pin(codec, "MIC2"); + + snd_soc_dapm_new_controls(codec, e750_dapm_widgets, + ARRAY_SIZE(e750_dapm_widgets)); + + 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 e750_dai[] = { + { + .name = "AC97", + .stream_name = "AC97 HiFi", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI], + .codec_dai = &wm9705_dai[WM9705_DAI_AC97_HIFI], + .init = e750_ac97_init, + /* use ops to check startup state */ + }, + { + .name = "AC97 Aux", + .stream_name = "AC97 Aux", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], + .codec_dai = &wm9705_dai[WM9705_DAI_AC97_AUX], + }, +}; + +static struct snd_soc_card e750 = { + .name = "Toshiba e750", + .platform = &pxa2xx_soc_platform, + .dai_link = e750_dai, + .num_links = ARRAY_SIZE(e750_dai), +}; + +static struct snd_soc_device e750_snd_devdata = { + .card = &e750, + .codec_dev = &soc_codec_dev_wm9705, +}; + +static struct platform_device *e750_snd_device; + +static int __init e750_init(void) +{ + int ret; + + if (!machine_is_e750()) + return -ENODEV; + + ret = gpio_request(GPIO_E750_HP_AMP_OFF, "Headphone amp"); + if (ret) + return ret; + + ret = gpio_request(GPIO_E750_SPK_AMP_OFF, "Speaker amp"); + if (ret) + goto free_hp_amp_gpio; + + ret = gpio_direction_output(GPIO_E750_HP_AMP_OFF, 1); + if (ret) + goto free_spk_amp_gpio; + + ret = gpio_direction_output(GPIO_E750_SPK_AMP_OFF, 1); + if (ret) + goto free_spk_amp_gpio; + + e750_snd_device = platform_device_alloc("soc-audio", -1); + if (!e750_snd_device) { + ret = -ENOMEM; + goto free_spk_amp_gpio; + } + + platform_set_drvdata(e750_snd_device, &e750_snd_devdata); + e750_snd_devdata.dev = &e750_snd_device->dev; + ret = platform_device_add(e750_snd_device); + + if (!ret) + return 0; + +/* Fail gracefully */ + platform_device_put(e750_snd_device); +free_spk_amp_gpio: + gpio_free(GPIO_E750_SPK_AMP_OFF); +free_hp_amp_gpio: + gpio_free(GPIO_E750_HP_AMP_OFF); + + return ret; +} + +static void __exit e750_exit(void) +{ + platform_device_unregister(e750_snd_device); + gpio_free(GPIO_E750_SPK_AMP_OFF); + gpio_free(GPIO_E750_HP_AMP_OFF); +} + +module_init(e750_init); +module_exit(e750_exit); + +/* Module information */ +MODULE_AUTHOR("Ian Molton "); +MODULE_DESCRIPTION("ALSA SoC driver for e750"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 0465c7aa6fbab89de820442aed449ceb8d9145a6 Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Thu, 8 Jan 2009 21:16:05 +0000 Subject: ASoC: machine driver for Toshiba e800 This patch adds support for the wm9712 ac97 codec as used in the Toshiba e800 PDA. It includes support for powering up / down the external headphone and speaker amplifiers on this machine. Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/pxa/e800_wm9712.c | 116 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 14 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/e800_wm9712.c b/sound/soc/pxa/e800_wm9712.c index 2e3386dfa0f..78a1770b986 100644 --- a/sound/soc/pxa/e800_wm9712.c +++ b/sound/soc/pxa/e800_wm9712.c @@ -1,8 +1,6 @@ /* * e800-wm9712.c -- SoC audio for e800 * - * Based on tosa.c - * * Copyright 2007 (c) Ian Molton * * This program is free software; you can redistribute it and/or modify it @@ -13,31 +11,96 @@ #include #include -#include +#include #include #include #include #include -#include #include #include #include +#include + +#include #include "../codecs/wm9712.h" #include "pxa2xx-pcm.h" #include "pxa2xx-ac97.h" -static struct snd_soc_card e800; +static int e800_spk_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event & SND_SOC_DAPM_PRE_PMU) + gpio_set_value(GPIO_E800_SPK_AMP_ON, 1); + else if (event & SND_SOC_DAPM_POST_PMD) + gpio_set_value(GPIO_E800_SPK_AMP_ON, 0); -static struct snd_soc_dai_link e800_dai[] = { + return 0; +} + +static int e800_hp_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) { - .name = "AC97 Aux", - .stream_name = "AC97 Aux", - .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], - .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX], -}, + if (event & SND_SOC_DAPM_PRE_PMU) + gpio_set_value(GPIO_E800_HP_AMP_OFF, 0); + else if (event & SND_SOC_DAPM_POST_PMD) + gpio_set_value(GPIO_E800_HP_AMP_OFF, 1); + + return 0; +} + +static const struct snd_soc_dapm_widget e800_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Mic (Internal1)", NULL), + SND_SOC_DAPM_MIC("Mic (Internal2)", NULL), + SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0, + e800_hp_amp_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0, + e800_spk_amp_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + {"Headphone Jack", NULL, "HPOUTL"}, + {"Headphone Jack", NULL, "HPOUTR"}, + {"Headphone Jack", NULL, "Headphone Amp"}, + + {"Speaker Amp", NULL, "MONOOUT"}, + {"Speaker", NULL, "Speaker Amp"}, + + {"MIC1", NULL, "Mic (Internal1)"}, + {"MIC2", NULL, "Mic (Internal2)"}, +}; + +static int e800_ac97_init(struct snd_soc_codec *codec) +{ + snd_soc_dapm_new_controls(codec, e800_dapm_widgets, + ARRAY_SIZE(e800_dapm_widgets)); + + 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 e800_dai[] = { + { + .name = "AC97", + .stream_name = "AC97 HiFi", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI], + .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI], + .init = e800_ac97_init, + }, + { + .name = "AC97 Aux", + .stream_name = "AC97 Aux", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], + .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX], + }, }; static struct snd_soc_card e800 = { @@ -61,6 +124,22 @@ static int __init e800_init(void) if (!machine_is_e800()) return -ENODEV; + ret = gpio_request(GPIO_E800_HP_AMP_OFF, "Headphone amp"); + if (ret) + return ret; + + ret = gpio_request(GPIO_E800_SPK_AMP_ON, "Speaker amp"); + if (ret) + goto free_hp_amp_gpio; + + ret = gpio_direction_output(GPIO_E800_HP_AMP_OFF, 1); + if (ret) + goto free_spk_amp_gpio; + + ret = gpio_direction_output(GPIO_E800_SPK_AMP_ON, 1); + if (ret) + goto free_spk_amp_gpio; + e800_snd_device = platform_device_alloc("soc-audio", -1); if (!e800_snd_device) return -ENOMEM; @@ -69,8 +148,15 @@ static int __init e800_init(void) e800_snd_devdata.dev = &e800_snd_device->dev; ret = platform_device_add(e800_snd_device); - if (ret) - platform_device_put(e800_snd_device); + if (!ret) + return 0; + +/* Fail gracefully */ + platform_device_put(e800_snd_device); +free_spk_amp_gpio: + gpio_free(GPIO_E800_SPK_AMP_ON); +free_hp_amp_gpio: + gpio_free(GPIO_E800_HP_AMP_OFF); return ret; } @@ -78,6 +164,8 @@ static int __init e800_init(void) static void __exit e800_exit(void) { platform_device_unregister(e800_snd_device); + gpio_free(GPIO_E800_SPK_AMP_ON); + gpio_free(GPIO_E800_HP_AMP_OFF); } module_init(e800_init); @@ -86,4 +174,4 @@ module_exit(e800_exit); /* Module information */ MODULE_AUTHOR("Ian Molton "); MODULE_DESCRIPTION("ALSA SoC driver for e800"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From c42f69bb064333624dcc1452ed109441c3c9e7b4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 16 Jan 2009 16:31:03 +0000 Subject: ASoC: Ignore output frequency for WM9713 PLL The WM9713 driver does not support configuring the PLL output frequency so the output frequency parameter is irrelevant. Allow users to set it to zero by ignoring it. Signed-off-by: Mark Brown --- sound/soc/codecs/wm9713.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index a45622620db..e636d8a18ed 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -32,7 +32,6 @@ struct wm9713_priv { u32 pll_in; /* PLL input frequency */ - u32 pll_out; /* PLL output frequency */ }; static unsigned int ac97_read(struct snd_soc_codec *codec, @@ -723,13 +722,13 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, struct _pll_div pll_div; /* turn PLL off ? */ - if (freq_in == 0 || freq_out == 0) { + if (freq_in == 0) { /* disable PLL power and select ext source */ reg = ac97_read(codec, AC97_HANDSET_RATE); ac97_write(codec, AC97_HANDSET_RATE, reg | 0x0080); reg = ac97_read(codec, AC97_EXTENDED_MID); ac97_write(codec, AC97_EXTENDED_MID, reg | 0x0200); - wm9713->pll_out = 0; + wm9713->pll_in = 0; return 0; } @@ -773,7 +772,6 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, ac97_write(codec, AC97_EXTENDED_MID, reg & 0xfdff); reg = ac97_read(codec, AC97_HANDSET_RATE); ac97_write(codec, AC97_HANDSET_RATE, reg & 0xff7f); - wm9713->pll_out = freq_out; wm9713->pll_in = freq_in; /* wait 10ms AC97 link frames for the link to stabilise */ @@ -1149,8 +1147,8 @@ static int wm9713_soc_resume(struct platform_device *pdev) wm9713_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* do we need to re-start the PLL ? */ - if (wm9713->pll_out) - wm9713_set_pll(codec, 0, wm9713->pll_in, wm9713->pll_out); + if (wm9713->pll_in) + wm9713_set_pll(codec, 0, wm9713->pll_in, 0); /* only synchronise the codec if warm reset failed */ if (ret == 0) { -- cgit v1.2.3 From 2c782f5981a022f7a238d550af5daa75c8acf382 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 16 Jan 2009 16:35:52 +0000 Subject: ASoC: Implement support for CLK_POUT as MCLK on Zylonite The Zylonite supports switching the MCLK for the WM9713 between the AC97CLK and CLK_POUT outputs of the PXA processor via switch SW15 on the board. This patch adds support for configuring the system to use CLK_POUT. Unfortunately it is not possible to read the state of SW15 from software so this feature is controlled by a module option 'clk_pout' which should be set to a non-zero value to enable the use of CLK_POUT. Signed-off-by: Mark Brown --- sound/soc/pxa/zylonite.c | 101 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 17 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c index f8e9ecd589d..8541b679f6e 100644 --- a/sound/soc/pxa/zylonite.c +++ b/sound/soc/pxa/zylonite.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,17 @@ #include "pxa2xx-ac97.h" #include "pxa-ssp.h" +/* + * There is a physical switch SW15 on the board which changes the MCLK + * for the WM9713 between the standard AC97 master clock and the + * output of the CLK_POUT signal from the PXA. + */ +static int clk_pout; +module_param(clk_pout, int, 0); +MODULE_PARM_DESC(clk_pout, "Use CLK_POUT as WM9713 MCLK (SW15 on board)."); + +static struct clk *pout; + static struct snd_soc_card zylonite; static const struct snd_soc_dapm_widget zylonite_dapm_widgets[] = { @@ -61,10 +73,8 @@ static const struct snd_soc_dapm_route audio_map[] = { static int zylonite_wm9713_init(struct snd_soc_codec *codec) { - /* Currently we only support use of the AC97 clock here. If - * CLK_POUT is selected by SW15 then the clock API will need - * to be used to request and enable it here. - */ + if (clk_pout) + snd_soc_dai_set_pll(&codec->dai[0], 0, clk_get_rate(pout), 0); snd_soc_dapm_new_controls(codec, zylonite_dapm_widgets, ARRAY_SIZE(zylonite_dapm_widgets)); @@ -85,7 +95,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; - unsigned int pll_out = 0; unsigned int acds = 0; unsigned int wm9713_div = 0; int ret = 0; @@ -93,16 +102,13 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, switch (params_rate(params)) { case 8000: wm9713_div = 12; - pll_out = 2048000; break; case 16000: wm9713_div = 6; - pll_out = 4096000; break; case 48000: default: wm9713_div = 2; - pll_out = 12288000; acds = 1; break; } @@ -123,10 +129,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, pll_out); - if (ret < 0) - return ret; - ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds); if (ret < 0) return ret; @@ -135,11 +137,12 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - /* Note that if the PLL is in use the WM9713_PCMCLK_PLL_DIV needs - * to be set instead. - */ - ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_DIV, - WM9713_PCMDIV(wm9713_div)); + if (clk_pout) + ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_PLL_DIV, + WM9713_PCMDIV(wm9713_div)); + else + ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_DIV, + WM9713_PCMDIV(wm9713_div)); if (ret < 0) return ret; @@ -173,8 +176,72 @@ static struct snd_soc_dai_link zylonite_dai[] = { }, }; +static int zylonite_probe(struct platform_device *pdev) +{ + int ret; + + if (clk_pout) { + pout = clk_get(NULL, "CLK_POUT"); + if (IS_ERR(pout)) { + dev_err(&pdev->dev, "Unable to obtain CLK_POUT: %ld\n", + PTR_ERR(pout)); + return PTR_ERR(pout); + } + + ret = clk_enable(pout); + if (ret != 0) { + dev_err(&pdev->dev, "Unable to enable CLK_POUT: %d\n", + ret); + clk_put(pout); + return ret; + } + + dev_dbg(&pdev->dev, "MCLK enabled at %luHz\n", + clk_get_rate(pout)); + } + + return 0; +} + +static int zylonite_remove(struct platform_device *pdev) +{ + if (clk_pout) { + clk_disable(pout); + clk_put(pout); + } + + return 0; +} + +static int zylonite_suspend_post(struct platform_device *pdev, + pm_message_t state) +{ + if (clk_pout) + clk_disable(pout); + + return 0; +} + +static int zylonite_resume_pre(struct platform_device *pdev) +{ + int ret = 0; + + if (clk_pout) { + ret = clk_enable(pout); + if (ret != 0) + dev_err(&pdev->dev, "Unable to enable CLK_POUT: %d\n", + ret); + } + + return ret; +} + static struct snd_soc_card zylonite = { .name = "Zylonite", + .probe = &zylonite_probe, + .remove = &zylonite_remove, + .suspend_post = &zylonite_suspend_post, + .resume_pre = &zylonite_resume_pre, .platform = &pxa2xx_soc_platform, .dai_link = zylonite_dai, .num_links = ARRAY_SIZE(zylonite_dai), -- cgit v1.2.3 From 28796eaf806502b9bd86cbacf8edbc14c80c14b0 Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Sat, 17 Jan 2009 15:11:06 +0000 Subject: ASoC: machine support for Toshiba e740 PDA This patch provides suupport for the wm9705 AC97 codec on the Toshiba e740. Note: The e740 has a hard headphone switch that turns the speaker off and is not software detectable or controlable. Also both headphone and speaker amps share a common output enable. Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/pxa/Kconfig | 9 ++ sound/soc/pxa/Makefile | 2 + sound/soc/pxa/e740_wm9705.c | 213 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) create mode 100644 sound/soc/pxa/e740_wm9705.c (limited to 'sound/soc') diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index b9b1a3f5d67..958ac3fe15d 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig @@ -61,6 +61,15 @@ config SND_PXA2XX_SOC_TOSA Say Y if you want to add support for SoC audio on Sharp Zaurus SL-C6000x models (Tosa). +config SND_PXA2XX_SOC_E740 + tristate "SoC AC97 Audio support for e740" + depends on SND_PXA2XX_SOC && MACH_E740 + select SND_SOC_WM9705 + select SND_PXA2XX_SOC_AC97 + help + Say Y if you want to add support for SoC audio on the + toshiba e740 PDA + config SND_PXA2XX_SOC_E750 tristate "SoC AC97 Audio support for e750" depends on SND_PXA2XX_SOC && MACH_E750 diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index c7d4cceeed9..97a51a8c936 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SND_PXA_SOC_SSP) += snd-soc-pxa-ssp.o snd-soc-corgi-objs := corgi.o snd-soc-poodle-objs := poodle.o snd-soc-tosa-objs := tosa.o +snd-soc-e740-objs := e740_wm9705.o snd-soc-e750-objs := e750_wm9705.o snd-soc-e800-objs := e800_wm9712.o snd-soc-spitz-objs := spitz.o @@ -23,6 +24,7 @@ snd-soc-zylonite-objs := zylonite.o obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o +obj-$(CONFIG_SND_PXA2XX_SOC_E740) += snd-soc-e740.o obj-$(CONFIG_SND_PXA2XX_SOC_E750) += snd-soc-e750.o obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c new file mode 100644 index 00000000000..ac361765173 --- /dev/null +++ b/sound/soc/pxa/e740_wm9705.c @@ -0,0 +1,213 @@ +/* + * e740-wm9705.c -- SoC audio for e740 + * + * Copyright 2007 (c) Ian Molton + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; version 2 ONLY. + * + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "../codecs/wm9705.h" +#include "pxa2xx-pcm.h" +#include "pxa2xx-ac97.h" + + +#define E740_AUDIO_OUT 1 +#define E740_AUDIO_IN 2 + +static int e740_audio_power; + +static void e740_sync_audio_power(int status) +{ + gpio_set_value(GPIO_E740_WM9705_nAVDD2, !status); + gpio_set_value(GPIO_E740_AMP_ON, (status & E740_AUDIO_OUT) ? 1 : 0); + gpio_set_value(GPIO_E740_MIC_ON, (status & E740_AUDIO_IN) ? 1 : 0); +} + +static int e740_mic_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event & SND_SOC_DAPM_PRE_PMU) + e740_audio_power |= E740_AUDIO_IN; + else if (event & SND_SOC_DAPM_POST_PMD) + e740_audio_power &= ~E740_AUDIO_IN; + + e740_sync_audio_power(e740_audio_power); + + return 0; +} + +static int e740_output_amp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + if (event & SND_SOC_DAPM_PRE_PMU) + e740_audio_power |= E740_AUDIO_OUT; + else if (event & SND_SOC_DAPM_POST_PMD) + e740_audio_power &= ~E740_AUDIO_OUT; + + e740_sync_audio_power(e740_audio_power); + + return 0; +} + +static const struct snd_soc_dapm_widget e740_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_MIC("Mic (Internal)", NULL), + SND_SOC_DAPM_PGA_E("Output Amp", SND_SOC_NOPM, 0, 0, NULL, 0, + e740_output_amp_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_PGA_E("Mic Amp", SND_SOC_NOPM, 0, 0, NULL, 0, + e740_mic_amp_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + {"Output Amp", NULL, "LOUT"}, + {"Output Amp", NULL, "ROUT"}, + {"Output Amp", NULL, "MONOOUT"}, + + {"Speaker", NULL, "Output Amp"}, + {"Headphone Jack", NULL, "Output Amp"}, + + {"MIC1", NULL, "Mic Amp"}, + {"Mic Amp", NULL, "Mic (Internal)"}, +}; + +static int e740_ac97_init(struct snd_soc_codec *codec) +{ + snd_soc_dapm_nc_pin(codec, "HPOUTL"); + snd_soc_dapm_nc_pin(codec, "HPOUTR"); + snd_soc_dapm_nc_pin(codec, "PHONE"); + snd_soc_dapm_nc_pin(codec, "LINEINL"); + snd_soc_dapm_nc_pin(codec, "LINEINR"); + snd_soc_dapm_nc_pin(codec, "CDINL"); + snd_soc_dapm_nc_pin(codec, "CDINR"); + snd_soc_dapm_nc_pin(codec, "PCBEEP"); + snd_soc_dapm_nc_pin(codec, "MIC2"); + + snd_soc_dapm_new_controls(codec, e740_dapm_widgets, + ARRAY_SIZE(e740_dapm_widgets)); + + 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 e740_dai[] = { + { + .name = "AC97", + .stream_name = "AC97 HiFi", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI], + .codec_dai = &wm9705_dai[WM9705_DAI_AC97_HIFI], + .init = e740_ac97_init, + }, + { + .name = "AC97 Aux", + .stream_name = "AC97 Aux", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], + .codec_dai = &wm9705_dai[WM9705_DAI_AC97_AUX], + }, +}; + +static struct snd_soc_card e740 = { + .name = "Toshiba e740", + .platform = &pxa2xx_soc_platform, + .dai_link = e740_dai, + .num_links = ARRAY_SIZE(e740_dai), +}; + +static struct snd_soc_device e740_snd_devdata = { + .card = &e740, + .codec_dev = &soc_codec_dev_wm9705, +}; + +static struct platform_device *e740_snd_device; + +static int __init e740_init(void) +{ + int ret; + + if (!machine_is_e740()) + return -ENODEV; + + ret = gpio_request(GPIO_E740_MIC_ON, "Mic amp"); + if (ret) + return ret; + + ret = gpio_request(GPIO_E740_AMP_ON, "Output amp"); + if (ret) + goto free_mic_amp_gpio; + + ret = gpio_request(GPIO_E740_WM9705_nAVDD2, "Audio power"); + if (ret) + goto free_op_amp_gpio; + + /* Disable audio */ + ret = gpio_direction_output(GPIO_E740_MIC_ON, 0); + if (ret) + goto free_apwr_gpio; + ret = gpio_direction_output(GPIO_E740_AMP_ON, 0); + if (ret) + goto free_apwr_gpio; + ret = gpio_direction_output(GPIO_E740_WM9705_nAVDD2, 1); + if (ret) + goto free_apwr_gpio; + + e740_snd_device = platform_device_alloc("soc-audio", -1); + if (!e740_snd_device) { + ret = -ENOMEM; + goto free_apwr_gpio; + } + + platform_set_drvdata(e740_snd_device, &e740_snd_devdata); + e740_snd_devdata.dev = &e740_snd_device->dev; + ret = platform_device_add(e740_snd_device); + + if (!ret) + return 0; + +/* Fail gracefully */ + platform_device_put(e740_snd_device); +free_apwr_gpio: + gpio_free(GPIO_E740_WM9705_nAVDD2); +free_op_amp_gpio: + gpio_free(GPIO_E740_AMP_ON); +free_mic_amp_gpio: + gpio_free(GPIO_E740_MIC_ON); + + return ret; +} + +static void __exit e740_exit(void) +{ + platform_device_unregister(e740_snd_device); +} + +module_init(e740_init); +module_exit(e740_exit); + +/* Module information */ +MODULE_AUTHOR("Ian Molton "); +MODULE_DESCRIPTION("ALSA SoC driver for e740"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 91432e976ff1323e5dd6f52498969602953c6ee9 Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Sat, 17 Jan 2009 17:44:23 +0000 Subject: ASoC: fixes to caching implementations This patch takes fixes a number of bugs in the caching code used by several ASoC codec drivers. Mostly off-by-one fixes. Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/codecs/ac97.c | 2 -- sound/soc/codecs/ad1980.c | 4 ++-- sound/soc/codecs/twl4030.c | 3 +++ sound/soc/codecs/wm8580.c | 4 ++-- sound/soc/codecs/wm8728.c | 4 ++-- sound/soc/codecs/wm8753.c | 4 ++-- sound/soc/codecs/wm8990.c | 4 ++-- sound/soc/codecs/wm9712.c | 4 ++-- sound/soc/codecs/wm9713.c | 4 ++-- 9 files changed, 17 insertions(+), 16 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index fb53e6511af..89d41277616 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -123,7 +123,6 @@ bus_err: snd_soc_free_pcms(socdev); err: - kfree(socdev->codec->reg_cache); kfree(socdev->codec); socdev->codec = NULL; return ret; @@ -138,7 +137,6 @@ static int ac97_soc_remove(struct platform_device *pdev) return 0; snd_soc_free_pcms(socdev); - kfree(socdev->codec->reg_cache); kfree(socdev->codec); return 0; diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index c3c5d0eee37..faf358758e1 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c @@ -109,7 +109,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, default: reg = reg >> 1; - if (reg >= (ARRAY_SIZE(ad1980_reg))) + if (reg >= ARRAY_SIZE(ad1980_reg)) return -EINVAL; return cache[reg]; @@ -123,7 +123,7 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, soc_ac97_ops.write(codec->ac97, reg, val); reg = reg >> 1; - if (reg < (ARRAY_SIZE(ad1980_reg))) + if (reg < ARRAY_SIZE(ad1980_reg)) cache[reg] = val; return 0; diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index ddc9f37d863..f530c1e6d9e 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -125,6 +125,9 @@ static inline unsigned int twl4030_read_reg_cache(struct snd_soc_codec *codec, { u8 *cache = codec->reg_cache; + if (reg >= TWL4030_CACHEREGNUM) + return -EIO; + return cache[reg]; } diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 9b75a377453..3faf0e70ce1 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -200,7 +200,7 @@ static inline unsigned int wm8580_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg) { u16 *cache = codec->reg_cache; - BUG_ON(reg > ARRAY_SIZE(wm8580_reg)); + BUG_ON(reg >= ARRAY_SIZE(wm8580_reg)); return cache[reg]; } @@ -223,7 +223,7 @@ static int wm8580_write(struct snd_soc_codec *codec, unsigned int reg, { u8 data[2]; - BUG_ON(reg > ARRAY_SIZE(wm8580_reg)); + BUG_ON(reg >= ARRAY_SIZE(wm8580_reg)); /* Registers are 9 bits wide */ value &= 0x1ff; diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index defa310bc7d..f90dc52e975 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -47,7 +47,7 @@ static inline unsigned int wm8728_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg) { u16 *cache = codec->reg_cache; - BUG_ON(reg > ARRAY_SIZE(wm8728_reg_defaults)); + BUG_ON(reg >= ARRAY_SIZE(wm8728_reg_defaults)); return cache[reg]; } @@ -55,7 +55,7 @@ static inline void wm8728_write_reg_cache(struct snd_soc_codec *codec, u16 reg, unsigned int value) { u16 *cache = codec->reg_cache; - BUG_ON(reg > ARRAY_SIZE(wm8728_reg_defaults)); + BUG_ON(reg >= ARRAY_SIZE(wm8728_reg_defaults)); cache[reg] = value; } diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 7283178e0eb..5a1c1fca120 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -97,7 +97,7 @@ static inline unsigned int wm8753_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg) { u16 *cache = codec->reg_cache; - if (reg < 1 || reg > (ARRAY_SIZE(wm8753_reg) + 1)) + if (reg < 1 || reg >= (ARRAY_SIZE(wm8753_reg) + 1)) return -1; return cache[reg - 1]; } @@ -109,7 +109,7 @@ static inline void wm8753_write_reg_cache(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { u16 *cache = codec->reg_cache; - if (reg < 1 || reg > 0x3f) + if (reg < 1 || reg >= (ARRAY_SIZE(wm8753_reg) + 1)) return; cache[reg - 1] = value; } diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 6b2778632d5..f93c0955ed9 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -116,7 +116,7 @@ static inline unsigned int wm8990_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg) { u16 *cache = codec->reg_cache; - BUG_ON(reg > (ARRAY_SIZE(wm8990_reg)) - 1); + BUG_ON(reg >= ARRAY_SIZE(wm8990_reg)); return cache[reg]; } @@ -129,7 +129,7 @@ static inline void wm8990_write_reg_cache(struct snd_soc_codec *codec, u16 *cache = codec->reg_cache; /* Reset register and reserved registers are uncached */ - if (reg == 0 || reg > ARRAY_SIZE(wm8990_reg) - 1) + if (reg == 0 || reg >= ARRAY_SIZE(wm8990_reg)) return; cache[reg] = value; diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 1b0ace0f4dc..4dc90d67530 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -452,7 +452,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, else { reg = reg >> 1; - if (reg > (ARRAY_SIZE(wm9712_reg))) + if (reg >= (ARRAY_SIZE(wm9712_reg))) return -EIO; return cache[reg]; @@ -466,7 +466,7 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, soc_ac97_ops.write(codec->ac97, reg, val); reg = reg >> 1; - if (reg <= (ARRAY_SIZE(wm9712_reg))) + if (reg < (ARRAY_SIZE(wm9712_reg))) cache[reg] = val; return 0; diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index e636d8a18ed..0e60e16973d 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -620,7 +620,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, else { reg = reg >> 1; - if (reg > (ARRAY_SIZE(wm9713_reg))) + if (reg >= (ARRAY_SIZE(wm9713_reg))) return -EIO; return cache[reg]; @@ -634,7 +634,7 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, if (reg < 0x7c) soc_ac97_ops.write(codec->ac97, reg, val); reg = reg >> 1; - if (reg <= (ARRAY_SIZE(wm9713_reg))) + if (reg < (ARRAY_SIZE(wm9713_reg))) cache[reg] = val; return 0; -- cgit v1.2.3 From b2a19d02396c92294abcddee5bd9bd49cc4e4d1c Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 17 Jan 2009 19:14:26 +0000 Subject: ASoC: Staticise PCM operations tables The PCM operations tables are not exported directly but are instead included in the platform structure so should be declared static. Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-pcm.c | 2 +- sound/soc/au1x/dbdma2.c | 2 +- sound/soc/blackfin/bf5xx-ac97-pcm.c | 2 +- sound/soc/blackfin/bf5xx-i2s-pcm.c | 2 +- sound/soc/davinci/davinci-pcm.c | 2 +- sound/soc/omap/omap-pcm.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c index 3dcdc4e3cfa..9ef6b96373f 100644 --- a/sound/soc/atmel/atmel-pcm.c +++ b/sound/soc/atmel/atmel-pcm.c @@ -347,7 +347,7 @@ static int atmel_pcm_mmap(struct snd_pcm_substream *substream, vma->vm_end - vma->vm_start, vma->vm_page_prot); } -struct snd_pcm_ops atmel_pcm_ops = { +static struct snd_pcm_ops atmel_pcm_ops = { .open = atmel_pcm_open, .close = atmel_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index bc8d654576c..30490a25914 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -305,7 +305,7 @@ static int au1xpsc_pcm_close(struct snd_pcm_substream *substream) return 0; } -struct snd_pcm_ops au1xpsc_pcm_ops = { +static struct snd_pcm_ops au1xpsc_pcm_ops = { .open = au1xpsc_pcm_open, .close = au1xpsc_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 8067cfafa3a..8cfed1a5dcb 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c @@ -297,7 +297,7 @@ static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, int channel, } #endif -struct snd_pcm_ops bf5xx_pcm_ac97_ops = { +static struct snd_pcm_ops bf5xx_pcm_ac97_ops = { .open = bf5xx_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = bf5xx_pcm_hw_params, diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 53d290b3ea4..1318c4f627b 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -184,7 +184,7 @@ static int bf5xx_pcm_mmap(struct snd_pcm_substream *substream, return 0 ; } -struct snd_pcm_ops bf5xx_pcm_i2s_ops = { +static struct snd_pcm_ops bf5xx_pcm_i2s_ops = { .open = bf5xx_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = bf5xx_pcm_hw_params, diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 366049d8578..7af3b5b3a53 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c @@ -286,7 +286,7 @@ static int davinci_pcm_mmap(struct snd_pcm_substream *substream, runtime->dma_bytes); } -struct snd_pcm_ops davinci_pcm_ops = { +static struct snd_pcm_ops davinci_pcm_ops = { .open = davinci_pcm_open, .close = davinci_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index b0362dfd5b7..607a38c7ae4 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -264,7 +264,7 @@ static int omap_pcm_mmap(struct snd_pcm_substream *substream, runtime->dma_bytes); } -struct snd_pcm_ops omap_pcm_ops = { +static struct snd_pcm_ops omap_pcm_ops = { .open = omap_pcm_open, .close = omap_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.2.3 From 75d91f9bc6d36b8d0ceef1cb75a4ac2b5c8a51d0 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Mon, 19 Jan 2009 11:57:46 -0600 Subject: ASoC: Allow Freescale MPC8610 audio drivers to be compiled as modules Change the Kconfig and Makefile options for Freescale MPC8610 audio drivers so that they can be compiled as modules, and simplify the Kconfig choices so that only the platform is selected. Also fix the naming of the driver files to conform to ALSA standards. [Removed extraneous SND_SOC dependency -- broonie] Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/fsl/Kconfig | 16 ++++++++-------- sound/soc/fsl/Makefile | 7 +++++-- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 95c12b26fe3..c7c78c39cfe 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,17 +1,17 @@ config SND_SOC_OF_SIMPLE tristate +# ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers +# for the SSI and the Elo DMA controller. You will still need to select +# a platform driver and a codec driver. config SND_SOC_MPC8610 - bool "ALSA SoC support for the MPC8610 SOC" - depends on MPC8610_HPCD - default y if MPC8610 - help - Say Y if you want to add support for codecs attached to the SSI - device on an MPC8610. + tristate + depends on MPC8610 config SND_SOC_MPC8610_HPCD - bool "ALSA SoC support for the Freescale MPC8610 HPCD board" - depends on SND_SOC_MPC8610 + tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" + depends on MPC8610_HPCD + select SND_SOC_MPC8610 select SND_SOC_CS4270 select SND_SOC_CS4270_VD33_ERRATA default y if MPC8610_HPCD diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 035da4afec3..f85134c8638 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -2,10 +2,13 @@ obj-$(CONFIG_SND_SOC_OF_SIMPLE) += soc-of-simple.o # MPC8610 HPCD Machine Support -obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += mpc8610_hpcd.o +snd-soc-mpc8610-hpcd-objs := mpc8610_hpcd.o +obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o # MPC8610 Platform Support -obj-$(CONFIG_SND_SOC_MPC8610) += fsl_ssi.o fsl_dma.o +snd-soc-fsl-ssi-objs := fsl_ssi.o +snd-soc-fsl-dma-objs := fsl_dma.o +obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o obj-$(CONFIG_SND_SOC_MPC5200_I2S) += mpc5200_psc_i2s.o -- cgit v1.2.3 From 927b0aea93bb324d743e575659e10d6d76818e4b Mon Sep 17 00:00:00 2001 From: Ian Molton Date: Mon, 19 Jan 2009 17:23:11 +0000 Subject: ASoC: Fix WM9705 capture switch name This patch fixes the acpture switch name so that it better reflects its purpose. Signed-off-by: Ian Molton Signed-off-by: Mark Brown --- sound/soc/codecs/wm9705.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index cb26b6a77ff..5e1937ac0b5 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -57,8 +57,8 @@ static const struct snd_kcontrol_new wm9705_snd_ac97_controls[] = { SOC_DOUBLE("CD Playback Volume", AC97_CD, 8, 0, 31, 1), SOC_SINGLE("Mic Playback Volume", AC97_MIC, 0, 31, 1), SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 6, 1, 0), - SOC_DOUBLE("PCM Capture Volume", AC97_REC_GAIN, 8, 0, 15, 0), - SOC_SINGLE("PCM Capture Switch", AC97_REC_GAIN, 15, 1, 1), + SOC_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 15, 0), + SOC_SINGLE("Capture Switch", AC97_REC_GAIN, 15, 1, 1), }; static const char *wm9705_mic[] = {"Mic 1", "Mic 2"}; -- cgit v1.2.3 From 80c509fdd74f3b158267374cc55156965c8bf930 Mon Sep 17 00:00:00 2001 From: Steve Sakoman Date: Tue, 20 Jan 2009 23:05:27 -0800 Subject: ASoC: Complete Beagleboard support Commit dc06102a0c8b5aa0dd7f9a40ce241e793c252a87 in the asoc tree did not include the necessary Kconfig and Makefile changes. This patch completes the support for Beagleboard Signed-off-by: Steve Sakoman Acked-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/omap/Kconfig | 10 ++++++++++ sound/soc/omap/Makefile | 2 ++ 2 files changed, 12 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 4f7f0401458..ccd8973683d 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -55,3 +55,13 @@ config SND_OMAP_SOC_OMAP3_PANDORA select SND_SOC_TWL4030 help Say Y if you want to add support for SoC audio on the OMAP3 Pandora. + +config SND_OMAP_SOC_OMAP3_BEAGLE + tristate "SoC Audio support for OMAP3 Beagle" + depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP3_BEAGLE + select SND_OMAP_SOC_MCBSP + select SND_SOC_TWL4030 + help + Say Y if you want to add support for SoC audio on the Beagleboard. + + diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 76fedd96e36..0c9e4ac3766 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile @@ -12,6 +12,7 @@ snd-soc-overo-objs := overo.o snd-soc-omap2evm-objs := omap2evm.o snd-soc-sdp3430-objs := sdp3430.o snd-soc-omap3pandora-objs := omap3pandora.o +snd-soc-omap3beagle-objs := omap3beagle.o obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o @@ -19,3 +20,4 @@ obj-$(CONFIG_SND_OMAP_SOC_OVERO) += snd-soc-overo.o obj-$(CONFIG_MACH_OMAP2EVM) += snd-soc-omap2evm.o obj-$(CONFIG_SND_OMAP_SOC_SDP3430) += snd-soc-sdp3430.o obj-$(CONFIG_SND_OMAP_SOC_OMAP3_PANDORA) += snd-soc-omap3pandora.o +obj-$(CONFIG_SND_OMAP_SOC_OMAP3_BEAGLE) += snd-soc-omap3beagle.o -- cgit v1.2.3 From ff637d38ea6b9c54f708a2b9edabc1b0c73c6d0a Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Thu, 22 Jan 2009 18:23:39 -0600 Subject: ASoC: remove stand-alone mode support from CS4270 codec driver The CS4270 supports stand-alone mode, where the codec is not connect to the I2C or SPI buses. Instead, input voltages configure the codec at power-on. The CS4270 ASoC device driver has partial support for this mode, but the code was never tested, and partial support doesn't help anyone. It also made the rest of the code more complicated than necessary. [Removed redundant CS4270 dependency on I2C -- broonie] Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 92 ++++++++++++++--------------------------------- sound/soc/fsl/Kconfig | 3 +- 2 files changed, 29 insertions(+), 66 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index f1aa0c34421..2e4ce04925e 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -12,11 +12,7 @@ * * Current features/limitations: * - * 1) Software mode is supported. Stand-alone mode is automatically - * selected if I2C is disabled or if a CS4270 is not found on the I2C - * bus. However, stand-alone mode is only partially implemented because - * there is no mechanism yet for this driver and the machine driver to - * communicate the values of the M0, M1, MCLK1, and MCLK2 pins. + * 1) Software mode is supported. Stand-alone mode is not supported. * 2) Only I2C is supported, not SPI * 3) Only Master mode is supported, not Slave. * 4) The machine driver's 'startup' function must call @@ -33,14 +29,6 @@ #include #include -#include "cs4270.h" - -/* If I2C is defined, then we support software mode. However, if we're - not compiled as module but I2C is, then we can't use I2C calls. */ -#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) -#define USE_I2C -#endif - /* Private data for the CS4270 */ struct cs4270_private { unsigned int mclk; /* Input frequency of the MCLK pin */ @@ -60,8 +48,6 @@ struct cs4270_private { SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE) -#ifdef USE_I2C - /* CS4270 registers addresses */ #define CS4270_CHIPID 0x01 /* Chip ID */ #define CS4270_PWRCTL 0x02 /* Power Control */ @@ -271,17 +257,6 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, return ret; } -/* - * A list of addresses on which this CS4270 could use. I2C addresses are - * 7 bits. For the CS4270, the upper four bits are always 1001, and the - * lower three bits are determined via the AD2, AD1, and AD0 pins - * (respectively). - */ -static const unsigned short normal_i2c[] = { - 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, I2C_CLIENT_END -}; -I2C_CLIENT_INSMOD; - /* * Pre-fill the CS4270 register cache. * @@ -476,7 +451,6 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, } #ifdef CONFIG_SND_SOC_CS4270_HWMUTE - /* * Set the CS4270 external mute * @@ -501,32 +475,16 @@ static int cs4270_mute(struct snd_soc_dai *dai, int mute) return snd_soc_write(codec, CS4270_MUTE, reg6); } - +#else +#define cs4270_mute NULL #endif -static int cs4270_i2c_probe(struct i2c_client *, const struct i2c_device_id *); - /* A list of non-DAPM controls that the CS4270 supports */ static const struct snd_kcontrol_new cs4270_snd_controls[] = { SOC_DOUBLE_R("Master Playback Volume", CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1) }; -static const struct i2c_device_id cs4270_id[] = { - {"cs4270", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs4270_id); - -static struct i2c_driver cs4270_i2c_driver = { - .driver = { - .name = "CS4270 I2C", - .owner = THIS_MODULE, - }, - .id_table = cs4270_id, - .probe = cs4270_i2c_probe, -}; - /* * Global variable to store socdev for i2c probe function. * @@ -633,7 +591,20 @@ error: return ret; } -#endif /* USE_I2C*/ +static const struct i2c_device_id cs4270_id[] = { + {"cs4270", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, cs4270_id); + +static struct i2c_driver cs4270_i2c_driver = { + .driver = { + .name = "cs4270", + .owner = THIS_MODULE, + }, + .id_table = cs4270_id, + .probe = cs4270_i2c_probe, +}; struct snd_soc_dai cs4270_dai = { .name = "CS4270", @@ -698,7 +669,6 @@ static int cs4270_probe(struct platform_device *pdev) goto error_free_codec; } -#ifdef USE_I2C cs4270_socdev = socdev; ret = i2c_add_driver(&cs4270_i2c_driver); @@ -708,20 +678,16 @@ static int cs4270_probe(struct platform_device *pdev) } /* Did we find a CS4270 on the I2C bus? */ - if (codec->control_data) { - /* Initialize codec ops */ - cs4270_dai.ops.hw_params = cs4270_hw_params; - cs4270_dai.ops.set_sysclk = cs4270_set_dai_sysclk; - cs4270_dai.ops.set_fmt = cs4270_set_dai_fmt; -#ifdef CONFIG_SND_SOC_CS4270_HWMUTE - cs4270_dai.ops.digital_mute = cs4270_mute; -#endif - } else - printk(KERN_INFO "cs4270: no I2C device found, " - "using stand-alone mode\n"); -#else - printk(KERN_INFO "cs4270: I2C disabled, using stand-alone mode\n"); -#endif + if (!codec->control_data) { + printk(KERN_ERR "cs4270: failed to attach driver"); + goto error_del_driver; + } + + /* Initialize codec ops */ + cs4270_dai.ops.hw_params = cs4270_hw_params; + cs4270_dai.ops.set_sysclk = cs4270_set_dai_sysclk; + cs4270_dai.ops.set_fmt = cs4270_set_dai_fmt; + cs4270_dai.ops.digital_mute = cs4270_mute; ret = snd_soc_init_card(socdev); if (ret < 0) { @@ -732,11 +698,9 @@ static int cs4270_probe(struct platform_device *pdev) return 0; error_del_driver: -#ifdef USE_I2C i2c_del_driver(&cs4270_i2c_driver); error_free_pcms: -#endif snd_soc_free_pcms(socdev); error_free_codec: @@ -752,9 +716,7 @@ static int cs4270_remove(struct platform_device *pdev) snd_soc_free_pcms(socdev); -#ifdef USE_I2C i2c_del_driver(&cs4270_i2c_driver); -#endif kfree(socdev->codec); socdev->codec = NULL; diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index c7c78c39cfe..9fc90828337 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -10,7 +10,8 @@ config SND_SOC_MPC8610 config SND_SOC_MPC8610_HPCD tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" - depends on MPC8610_HPCD + # I2C is necessary for the CS4270 driver + depends on MPC8610_HPCD && I2C select SND_SOC_MPC8610 select SND_SOC_CS4270 select SND_SOC_CS4270_VD33_ERRATA -- cgit v1.2.3 From c91cf25ebfbf3a5b336cbaa46646d37dd3d33127 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 11:23:32 +0000 Subject: ASoC: Fix merge with PXA tree Fix a merge issue caused by context overlap. Reported-by: Stephen Rothwell Signed-off-by: Mark Brown --- sound/soc/pxa/e800_wm9712.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/e800_wm9712.c b/sound/soc/pxa/e800_wm9712.c index 78a1770b986..bc019cdce42 100644 --- a/sound/soc/pxa/e800_wm9712.c +++ b/sound/soc/pxa/e800_wm9712.c @@ -18,13 +18,10 @@ #include #include -#include -#include +#include #include #include -#include - #include "../codecs/wm9712.h" #include "pxa2xx-pcm.h" #include "pxa2xx-ac97.h" -- cgit v1.2.3 From f6fca2e93c9ad3c704f02aaabe4359a8af16fbbb Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 11:40:26 +0000 Subject: ASoC: Remove unneeded e7x0 inclusion of pxa-regs.h and hardware.h pxa-regs.h and hardware.h are not intended for use directly in driver code and references to them have been removed in other code - remove them from the newly added e740 and e750 machine drivers. Signed-off-by: Mark Brown --- sound/soc/pxa/e740_wm9705.c | 2 -- sound/soc/pxa/e750_wm9705.c | 2 -- 2 files changed, 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c index ac361765173..7cd2f89d7b1 100644 --- a/sound/soc/pxa/e740_wm9705.c +++ b/sound/soc/pxa/e740_wm9705.c @@ -18,8 +18,6 @@ #include #include -#include -#include #include #include diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c index 20fbdcfa9f7..8dceccc5e05 100644 --- a/sound/soc/pxa/e750_wm9705.c +++ b/sound/soc/pxa/e750_wm9705.c @@ -18,8 +18,6 @@ #include #include -#include -#include #include #include -- cgit v1.2.3 From a435869cacbb581920df23411416bed533748bf1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 11:49:45 +0000 Subject: ASoC: Configure SSP port PLL for Zylonite Signed-off-by: Mark Brown --- sound/soc/pxa/zylonite.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c index 8541b679f6e..ec2fb764b24 100644 --- a/sound/soc/pxa/zylonite.c +++ b/sound/soc/pxa/zylonite.c @@ -95,6 +95,7 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + unsigned int pll_out = 0; unsigned int acds = 0; unsigned int wm9713_div = 0; int ret = 0; @@ -102,13 +103,16 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, switch (params_rate(params)) { case 8000: wm9713_div = 12; + pll_out = 2048000; break; case 16000: wm9713_div = 6; + pll_out = 4096000; break; case 48000: default: wm9713_div = 2; + pll_out = 12288000; acds = 1; break; } @@ -129,6 +133,10 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; + ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, pll_out); + if (ret < 0) + return ret; + ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds); if (ret < 0) return ret; -- cgit v1.2.3 From ef963dcf6879e500e6559b4327f6cbdc4439198e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 14:53:58 +0000 Subject: ASoC: Fix spurious codec driver dependencies Kbuild ignores dependency from things that are themselves selected so ASoC machine drivers need to ensure that the control bus is being built. This also avoids issues where multiple buses are supported by a given codec. Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 4 ---- sound/soc/omap/Kconfig | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index cb5fcd605ac..656f180b2c1 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -91,7 +91,6 @@ config SND_SOC_SSM2602 config SND_SOC_TLV320AIC23 tristate - depends on I2C config SND_SOC_TLV320AIC26 tristate "TI TLV320AIC26 Codec support" if SND_SOC_OF_SIMPLE @@ -99,15 +98,12 @@ config SND_SOC_TLV320AIC26 config SND_SOC_TLV320AIC3X tristate - depends on I2C config SND_SOC_TWL4030 tristate - depends on TWL4030_CORE config SND_SOC_UDA134X tristate - select SND_SOC_L3 config SND_SOC_UDA1380 tristate diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index ccd8973683d..675732e724d 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -8,7 +8,7 @@ config SND_OMAP_SOC_MCBSP config SND_OMAP_SOC_N810 tristate "SoC Audio support for Nokia N810" - depends on SND_OMAP_SOC && MACH_NOKIA_N810 + depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C select SND_OMAP_SOC_MCBSP select OMAP_MUX select SND_SOC_TLV320AIC3X @@ -17,7 +17,7 @@ config SND_OMAP_SOC_N810 config SND_OMAP_SOC_OSK5912 tristate "SoC Audio support for omap osk5912" - depends on SND_OMAP_SOC && MACH_OMAP_OSK + depends on SND_OMAP_SOC && MACH_OMAP_OSK && I2C select SND_OMAP_SOC_MCBSP select SND_SOC_TLV320AIC23 help -- cgit v1.2.3 From 01e097d6c409a6eb64758dce9fcde0c70073fe36 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 15:07:45 +0000 Subject: ASoC: Include header file in cs4270 and wm9705 Ensures that the DAI and socdev exported by the codec match up with their exported prototype. Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 2 ++ sound/soc/codecs/wm9705.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 2e4ce04925e..e2130d7b1e4 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -29,6 +29,8 @@ #include #include +#include "cs4270.h" + /* Private data for the CS4270 */ struct cs4270_private { unsigned int mclk; /* Input frequency of the MCLK pin */ diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index 5e1937ac0b5..d5c81bb3dec 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -20,6 +20,8 @@ #include #include +#include "wm9705.h" + /* * WM9705 register cache */ -- cgit v1.2.3 From 070504ade7a95a0f4395673717f3bb7d41793ca8 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 15:34:54 +0000 Subject: ASoC: Fix L3 bus handling in Kconfig It has no external dependencies but needs to be selected for L3 based codecs to work. Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 1 + sound/soc/s3c24xx/Kconfig | 1 + 2 files changed, 2 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 656f180b2c1..a195303603e 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -10,6 +10,7 @@ config SND_SOC_I2C_AND_SPI config SND_SOC_ALL_CODECS tristate "Build all ASoC CODEC drivers" + select SND_SOC_L3 select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS select SND_SOC_AD1980 if SND_SOC_AC97_BUS select SND_SOC_AD73311 if I2C diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index fcd03acf10f..e05a71084c3 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -48,4 +48,5 @@ config SND_S3C24XX_SOC_S3C24XX_UDA134X tristate "SoC I2S Audio support UDA134X wired to a S3C24XX" depends on SND_S3C24XX_SOC select SND_S3C24XX_SOC_I2S + select SND_SOC_L3 select SND_SOC_UDA134X -- cgit v1.2.3 From 0db4d0705260dd4bddf1e5a5441c58bdf08bdc9f Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Fri, 23 Jan 2009 16:31:19 -0600 Subject: ASoC: improve I2C initialization code in CS4270 driver Further improvements in the I2C initialization sequence of the CS4270 driver. All ASoC initialization is now done in the I2C probe function. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 252 +++++++++++++++++++++------------------------- 1 file changed, 113 insertions(+), 139 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index e2130d7b1e4..2aa12fdbd2c 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -31,12 +31,6 @@ #include "cs4270.h" -/* Private data for the CS4270 */ -struct cs4270_private { - unsigned int mclk; /* Input frequency of the MCLK pin */ - unsigned int mode; /* The mode (I2S or left-justified) */ -}; - /* * The codec isn't really big-endian or little-endian, since the I2S * interface requires data to be sent serially with the MSbit first. @@ -109,6 +103,14 @@ struct cs4270_private { #define CS4270_MUTE_DAC_A 0x01 #define CS4270_MUTE_DAC_B 0x02 +/* Private data for the CS4270 */ +struct cs4270_private { + struct snd_soc_codec codec; + u8 reg_cache[CS4270_NUMREGS]; + unsigned int mclk; /* Input frequency of the MCLK pin */ + unsigned int mode; /* The mode (I2S or left-justified) */ +}; + /* * Clock Ratio Selection for Master Mode with I2C enabled * @@ -504,6 +506,31 @@ static const struct snd_kcontrol_new cs4270_snd_controls[] = { */ static struct snd_soc_device *cs4270_socdev; +struct snd_soc_dai cs4270_dai = { + .name = "cs4270", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + .rates = 0, + .formats = CS4270_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + .rates = 0, + .formats = CS4270_FORMATS, + }, + .ops = { + .hw_params = cs4270_hw_params, + .set_sysclk = cs4270_set_dai_sysclk, + .set_fmt = cs4270_set_dai_fmt, + .digital_mute = cs4270_mute, + }, +}; +EXPORT_SYMBOL_GPL(cs4270_dai); + /* * Initialize the I2C interface of the CS4270 * @@ -517,47 +544,52 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { struct snd_soc_device *socdev = cs4270_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec; + struct cs4270_private *cs4270; int i; int ret = 0; - /* Probing all possible addresses has one drawback: if there are - multiple CS4270s on the bus, then you cannot specify which - socdev is matched with which CS4270. For now, we just reject - this I2C device if the socdev already has one attached. */ - if (codec->control_data) - return -ENODEV; - - /* Note: codec_dai->codec is NULL here */ - - codec->reg_cache = kzalloc(CS4270_NUMREGS, GFP_KERNEL); - if (!codec->reg_cache) { - printk(KERN_ERR "cs4270: could not allocate register cache\n"); - ret = -ENOMEM; - goto error; - } - /* Verify that we have a CS4270 */ ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); if (ret < 0) { printk(KERN_ERR "cs4270: failed to read I2C\n"); - goto error; + return ret; } /* The top four bits of the chip ID should be 1100. */ if ((ret & 0xF0) != 0xC0) { - /* The device at this address is not a CS4270 codec */ - ret = -ENODEV; - goto error; + printk(KERN_ERR "cs4270: device at addr %X is not a CS4270\n", + i2c_client->addr); + return -ENODEV; } printk(KERN_INFO "cs4270: found device at I2C address %X\n", i2c_client->addr); printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF); + /* Allocate enough space for the snd_soc_codec structure + and our private data together. */ + cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL); + if (!cs4270) { + printk(KERN_ERR "cs4270: Could not allocate codec structure\n"); + return -ENOMEM; + } + codec = &cs4270->codec; + socdev->codec = codec; + + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + codec->name = "CS4270"; + codec->owner = THIS_MODULE; + codec->dai = &cs4270_dai; + codec->num_dai = 1; + codec->private_data = cs4270; codec->control_data = i2c_client; codec->read = cs4270_read_reg_cache; codec->write = cs4270_i2c_write; + codec->reg_cache = cs4270->reg_cache; codec->reg_cache_size = CS4270_NUMREGS; /* The I2C interface is set up, so pre-fill our register cache */ @@ -565,35 +597,72 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ret = cs4270_fill_cache(codec); if (ret < 0) { printk(KERN_ERR "cs4270: failed to fill register cache\n"); - goto error; + goto error_free_codec; + } + + /* Register PCMs */ + + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + printk(KERN_ERR "cs4270: failed to create PCMs\n"); + goto error_free_codec; } /* Add the non-DAPM controls */ for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { - struct snd_kcontrol *kctrl = - snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); + struct snd_kcontrol *kctrl; + + kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); + if (!kctrl) { + printk(KERN_ERR "cs4270: error creating control '%s'\n", + cs4270_snd_controls[i].name); + ret = -ENOMEM; + goto error_free_pcms; + } ret = snd_ctl_add(codec->card, kctrl); - if (ret < 0) - goto error; + if (ret < 0) { + printk(KERN_ERR "cs4270: error adding control '%s'\n", + cs4270_snd_controls[i].name); + goto error_free_pcms; + } } - i2c_set_clientdata(i2c_client, codec); + /* Initialize the SOC device */ + + ret = snd_soc_init_card(socdev); + if (ret < 0) { + printk(KERN_ERR "cs4270: failed to register card\n"); + goto error_free_pcms;; + } + + i2c_set_clientdata(i2c_client, socdev); return 0; -error: - codec->control_data = NULL; +error_free_pcms: + snd_soc_free_pcms(socdev); - kfree(codec->reg_cache); - codec->reg_cache = NULL; - codec->reg_cache_size = 0; +error_free_codec: + kfree(cs4270); return ret; } -static const struct i2c_device_id cs4270_id[] = { +static int cs4270_i2c_remove(struct i2c_client *i2c_client) +{ + struct snd_soc_device *socdev = i2c_get_clientdata(i2c_client); + struct snd_soc_codec *codec = socdev->codec; + struct cs4270_private *cs4270 = codec->private_data; + + snd_soc_free_pcms(socdev); + kfree(cs4270); + + return 0; +} + +static struct i2c_device_id cs4270_id[] = { {"cs4270", 0}, {} }; @@ -606,27 +675,9 @@ static struct i2c_driver cs4270_i2c_driver = { }, .id_table = cs4270_id, .probe = cs4270_i2c_probe, + .remove = cs4270_i2c_remove, }; -struct snd_soc_dai cs4270_dai = { - .name = "CS4270", - .playback = { - .stream_name = "Playback", - .channels_min = 1, - .channels_max = 2, - .rates = 0, - .formats = CS4270_FORMATS, - }, - .capture = { - .stream_name = "Capture", - .channels_min = 1, - .channels_max = 2, - .rates = 0, - .formats = CS4270_FORMATS, - }, -}; -EXPORT_SYMBOL_GPL(cs4270_dai); - /* * ASoC probe function * @@ -635,94 +686,15 @@ EXPORT_SYMBOL_GPL(cs4270_dai); */ static int cs4270_probe(struct platform_device *pdev) { - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec; - int ret = 0; - - printk(KERN_INFO "CS4270 ALSA SoC Codec\n"); - - /* Allocate enough space for the snd_soc_codec structure - and our private data together. */ - codec = kzalloc(ALIGN(sizeof(struct snd_soc_codec), 4) + - sizeof(struct cs4270_private), GFP_KERNEL); - if (!codec) { - printk(KERN_ERR "cs4270: Could not allocate codec structure\n"); - return -ENOMEM; - } - - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - - codec->name = "CS4270"; - codec->owner = THIS_MODULE; - codec->dai = &cs4270_dai; - codec->num_dai = 1; - codec->private_data = (void *) codec + - ALIGN(sizeof(struct snd_soc_codec), 4); - - socdev->codec = codec; - - /* Register PCMs */ - - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); - if (ret < 0) { - printk(KERN_ERR "cs4270: failed to create PCMs\n"); - goto error_free_codec; - } - - cs4270_socdev = socdev; - - ret = i2c_add_driver(&cs4270_i2c_driver); - if (ret) { - printk(KERN_ERR "cs4270: failed to attach driver"); - goto error_free_pcms; - } - - /* Did we find a CS4270 on the I2C bus? */ - if (!codec->control_data) { - printk(KERN_ERR "cs4270: failed to attach driver"); - goto error_del_driver; - } + cs4270_socdev = platform_get_drvdata(pdev);; - /* Initialize codec ops */ - cs4270_dai.ops.hw_params = cs4270_hw_params; - cs4270_dai.ops.set_sysclk = cs4270_set_dai_sysclk; - cs4270_dai.ops.set_fmt = cs4270_set_dai_fmt; - cs4270_dai.ops.digital_mute = cs4270_mute; - - ret = snd_soc_init_card(socdev); - if (ret < 0) { - printk(KERN_ERR "cs4270: failed to register card\n"); - goto error_del_driver; - } - - return 0; - -error_del_driver: - i2c_del_driver(&cs4270_i2c_driver); - -error_free_pcms: - snd_soc_free_pcms(socdev); - -error_free_codec: - kfree(socdev->codec); - socdev->codec = NULL; - - return ret; + return i2c_add_driver(&cs4270_i2c_driver); } static int cs4270_remove(struct platform_device *pdev) { - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - - snd_soc_free_pcms(socdev); - i2c_del_driver(&cs4270_i2c_driver); - kfree(socdev->codec); - socdev->codec = NULL; - return 0; } @@ -740,6 +712,8 @@ EXPORT_SYMBOL_GPL(soc_codec_device_cs4270); static int __init cs4270_init(void) { + printk(KERN_INFO "Cirrus Logic CS4270 ALSA SoC Codec Driver\n"); + return snd_soc_register_dai(&cs4270_dai); } module_init(cs4270_init); -- cgit v1.2.3 From 6627a653bceb3a54e55e5cdc478ec5b8d5c9cc44 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 22:55:23 +0000 Subject: ASoC: Push the codec runtime storage into the card structure This is a further stage on the road to refactoring away the ASoC platform device. Signed-off-by: Mark Brown --- sound/soc/codecs/ac97.c | 20 ++++++++++---------- sound/soc/codecs/ad1980.c | 12 ++++++------ sound/soc/codecs/ad73311.c | 8 ++++---- sound/soc/codecs/ak4535.c | 14 +++++++------- sound/soc/codecs/cs4270.c | 6 +++--- sound/soc/codecs/pcm3008.c | 12 ++++++------ sound/soc/codecs/ssm2602.c | 20 ++++++++++---------- sound/soc/codecs/tlv320aic23.c | 18 +++++++++--------- sound/soc/codecs/tlv320aic26.c | 4 ++-- sound/soc/codecs/tlv320aic3x.c | 14 +++++++------- sound/soc/codecs/twl4030.c | 12 ++++++------ sound/soc/codecs/uda134x.c | 18 +++++++++--------- sound/soc/codecs/uda1380.c | 18 +++++++++--------- sound/soc/codecs/wm8350.c | 10 +++++----- sound/soc/codecs/wm8510.c | 16 ++++++++-------- sound/soc/codecs/wm8580.c | 10 +++++----- sound/soc/codecs/wm8728.c | 16 ++++++++-------- sound/soc/codecs/wm8731.c | 20 ++++++++++---------- sound/soc/codecs/wm8750.c | 16 ++++++++-------- sound/soc/codecs/wm8753.c | 18 +++++++++--------- sound/soc/codecs/wm8900.c | 8 ++++---- sound/soc/codecs/wm8903.c | 18 +++++++++--------- sound/soc/codecs/wm8971.c | 14 +++++++------- sound/soc/codecs/wm8990.c | 14 +++++++------- sound/soc/codecs/wm9705.c | 15 ++++++++------- sound/soc/codecs/wm9712.c | 21 +++++++++++---------- sound/soc/codecs/wm9713.c | 17 +++++++++-------- sound/soc/soc-core.c | 37 +++++++++++++++++-------------------- sound/soc/soc-dapm.c | 6 +++--- sound/soc/soc-jack.c | 4 ++-- 30 files changed, 218 insertions(+), 218 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index 89d41277616..11f84b6e5cb 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -30,7 +30,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; @@ -84,10 +84,10 @@ static int ac97_soc_probe(struct platform_device *pdev) printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION); - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (!socdev->codec) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (!socdev->card->codec) return -ENOMEM; - codec = socdev->codec; + codec = socdev->card->codec; mutex_init(&codec->mutex); codec->name = "AC97"; @@ -123,21 +123,21 @@ bus_err: snd_soc_free_pcms(socdev); err: - kfree(socdev->codec); - socdev->codec = NULL; + kfree(socdev->card->codec); + socdev->card->codec = NULL; return ret; } static int ac97_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (!codec) return 0; snd_soc_free_pcms(socdev); - kfree(socdev->codec); + kfree(socdev->card->codec); return 0; } @@ -147,7 +147,7 @@ static int ac97_soc_suspend(struct platform_device *pdev, pm_message_t msg) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - snd_ac97_suspend(socdev->codec->ac97); + snd_ac97_suspend(socdev->card->codec->ac97); return 0; } @@ -156,7 +156,7 @@ static int ac97_soc_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - snd_ac97_resume(socdev->codec->ac97); + snd_ac97_resume(socdev->card->codec->ac97); return 0; } diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index faf358758e1..ddb3b08ac23 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c @@ -186,10 +186,10 @@ static int ad1980_soc_probe(struct platform_device *pdev) printk(KERN_INFO "AD1980 SoC Audio Codec\n"); - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (socdev->codec == NULL) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (socdev->card->codec == NULL) return -ENOMEM; - codec = socdev->codec; + codec = socdev->card->codec; mutex_init(&codec->mutex); codec->reg_cache = @@ -275,15 +275,15 @@ codec_err: kfree(codec->reg_cache); cache_err: - kfree(socdev->codec); - socdev->codec = NULL; + kfree(socdev->card->codec); + socdev->card->codec = NULL; return ret; } static int ad1980_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec == NULL) return 0; diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c index b09289a1e55..e61dac5e7b8 100644 --- a/sound/soc/codecs/ad73311.c +++ b/sound/soc/codecs/ad73311.c @@ -53,7 +53,7 @@ static int ad73311_soc_probe(struct platform_device *pdev) codec->owner = THIS_MODULE; codec->dai = &ad73311_dai; codec->num_dai = 1; - socdev->codec = codec; + socdev->card->codec = codec; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -75,15 +75,15 @@ static int ad73311_soc_probe(struct platform_device *pdev) register_err: snd_soc_free_pcms(socdev); pcm_err: - kfree(socdev->codec); - socdev->codec = NULL; + kfree(socdev->card->codec); + socdev->card->codec = NULL; return ret; } static int ad73311_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec == NULL) return 0; diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index f17c363cb1d..d56e6bb1fed 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -329,7 +329,7 @@ static int ak4535_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; + struct snd_soc_codec *codec = socdev->card->codec; struct ak4535_priv *ak4535 = codec->private_data; u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5); int rate = params_rate(params), fs = 256; @@ -447,7 +447,7 @@ EXPORT_SYMBOL_GPL(ak4535_dai); static int ak4535_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -456,7 +456,7 @@ static int ak4535_suspend(struct platform_device *pdev, pm_message_t state) static int ak4535_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; ak4535_sync(codec); ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); ak4535_set_bias_level(codec, codec->suspend_bias_level); @@ -469,7 +469,7 @@ static int ak4535_resume(struct platform_device *pdev) */ static int ak4535_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "AK4535"; @@ -523,7 +523,7 @@ static int ak4535_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = ak4535_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -622,7 +622,7 @@ static int ak4535_probe(struct platform_device *pdev) } codec->private_data = ak4535; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -649,7 +649,7 @@ static int ak4535_probe(struct platform_device *pdev) static int ak4535_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) ak4535_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 2aa12fdbd2c..21253b48289 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -350,7 +350,7 @@ static int cs4270_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; + struct snd_soc_codec *codec = socdev->card->codec; struct cs4270_private *cs4270 = codec->private_data; int ret; unsigned int i; @@ -575,7 +575,7 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, return -ENOMEM; } codec = &cs4270->codec; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); @@ -653,7 +653,7 @@ error_free_codec: static int cs4270_i2c_remove(struct i2c_client *i2c_client) { struct snd_soc_device *socdev = i2c_get_clientdata(i2c_client); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct cs4270_private *cs4270 = codec->private_data; snd_soc_free_pcms(socdev); diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c index 9a3e67e5319..5cda9e6b5a7 100644 --- a/sound/soc/codecs/pcm3008.c +++ b/sound/soc/codecs/pcm3008.c @@ -67,11 +67,11 @@ static int pcm3008_soc_probe(struct platform_device *pdev) printk(KERN_INFO "PCM3008 SoC Audio Codec %s\n", PCM3008_VERSION); - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (!socdev->codec) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (!socdev->card->codec) return -ENOMEM; - codec = socdev->codec; + codec = socdev->card->codec; mutex_init(&codec->mutex); codec->name = "PCM3008"; @@ -139,7 +139,7 @@ gpio_err: card_err: snd_soc_free_pcms(socdev); pcm_err: - kfree(socdev->codec); + kfree(socdev->card->codec); return ret; } @@ -147,7 +147,7 @@ pcm_err: static int pcm3008_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct pcm3008_setup_data *setup = socdev->codec_data; if (!codec) @@ -155,7 +155,7 @@ static int pcm3008_soc_remove(struct platform_device *pdev) pcm3008_gpio_free(setup); snd_soc_free_pcms(socdev); - kfree(socdev->codec); + kfree(socdev->card->codec); return 0; } diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index ec7fe3b7b0c..58e225dadc7 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -276,7 +276,7 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, u16 srate; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct ssm2602_priv *ssm2602 = codec->private_data; struct i2c_client *i2c = codec->control_data; u16 iface = ssm2602_read_reg_cache(codec, SSM2602_IFACE) & 0xfff3; @@ -321,7 +321,7 @@ static int ssm2602_startup(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 snd_soc_codec *codec = socdev->card->codec; struct ssm2602_priv *ssm2602 = codec->private_data; struct i2c_client *i2c = codec->control_data; struct snd_pcm_runtime *master_runtime; @@ -358,7 +358,7 @@ static int ssm2602_pcm_prepare(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 snd_soc_codec *codec = socdev->card->codec; /* set active */ ssm2602_write(codec, SSM2602_ACTIVE, ACTIVE_ACTIVATE_CODEC); @@ -370,7 +370,7 @@ static void ssm2602_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 snd_soc_codec *codec = socdev->card->codec; struct ssm2602_priv *ssm2602 = codec->private_data; /* deactivate */ if (!codec->active) @@ -535,7 +535,7 @@ EXPORT_SYMBOL_GPL(ssm2602_dai); static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -544,7 +544,7 @@ static int ssm2602_suspend(struct platform_device *pdev, pm_message_t state) static int ssm2602_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -566,7 +566,7 @@ static int ssm2602_resume(struct platform_device *pdev) */ static int ssm2602_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg, ret = 0; codec->name = "SSM2602"; @@ -639,7 +639,7 @@ static int ssm2602_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = ssm2602_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -733,7 +733,7 @@ static int ssm2602_probe(struct platform_device *pdev) } codec->private_data = ssm2602; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -754,7 +754,7 @@ static int ssm2602_probe(struct platform_device *pdev) static int ssm2602_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) ssm2602_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index a0e47c1dcd6..8b20c360adf 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -405,7 +405,7 @@ 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; + struct snd_soc_codec *codec = socdev->card->codec; u16 iface_reg; int ret; struct aic23 *aic23 = container_of(codec, struct aic23, codec); @@ -453,7 +453,7 @@ static int tlv320aic23_pcm_prepare(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 snd_soc_codec *codec = socdev->card->codec; /* set active */ tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0001); @@ -466,7 +466,7 @@ 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 snd_soc_codec *codec = socdev->card->codec; struct aic23 *aic23 = container_of(codec, struct aic23, codec); /* deactivate */ @@ -609,7 +609,7 @@ static int tlv320aic23_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0); tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -620,7 +620,7 @@ static int tlv320aic23_suspend(struct platform_device *pdev, static int tlv320aic23_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u16 reg; @@ -642,7 +642,7 @@ static int tlv320aic23_resume(struct platform_device *pdev) */ static int tlv320aic23_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; u16 reg; @@ -729,7 +729,7 @@ static int tlv320aic23_codec_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct snd_soc_device *socdev = tlv320aic23_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) @@ -787,7 +787,7 @@ static int tlv320aic23_probe(struct platform_device *pdev) if (aic23 == NULL) return -ENOMEM; codec = &aic23->codec; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -806,7 +806,7 @@ static int tlv320aic23_probe(struct platform_device *pdev) 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 snd_soc_codec *codec = socdev->card->codec; struct aic23 *aic23 = container_of(codec, struct aic23, codec); if (codec->control_data) diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 29f2f1a017f..229e464cf71 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -130,7 +130,7 @@ static int aic26_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; + struct snd_soc_codec *codec = socdev->card->codec; struct aic26 *aic26 = codec->private_data; int fsref, divisor, wlen, pval, jval, dval, qval; u16 reg; @@ -338,7 +338,7 @@ static int aic26_probe(struct platform_device *pdev) return -ENODEV; } codec = &aic26->codec; - socdev->codec = codec; + socdev->card->codec = codec; dev_dbg(&pdev->dev, "Registering PCMs, dev=%p, socdev->dev=%p\n", &pdev->dev, socdev->dev); diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 36ab0198ca3..ba64b0c617e 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -727,7 +727,7 @@ static int aic3x_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; + struct snd_soc_codec *codec = socdev->card->codec; struct aic3x_priv *aic3x = codec->private_data; int codec_clk = 0, bypass_pll = 0, fsref, last_clk = 0; u8 data, r, p, pll_q, pll_p = 1, pll_r = 1, pll_j = 1; @@ -1079,7 +1079,7 @@ EXPORT_SYMBOL_GPL(aic3x_dai); static int aic3x_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -1089,7 +1089,7 @@ static int aic3x_suspend(struct platform_device *pdev, pm_message_t state) static int aic3x_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u8 *cache = codec->reg_cache; @@ -1112,7 +1112,7 @@ static int aic3x_resume(struct platform_device *pdev) */ static int aic3x_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct aic3x_setup_data *setup = socdev->codec_data; int reg, ret = 0; @@ -1243,7 +1243,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = aic3x_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -1348,7 +1348,7 @@ static int aic3x_probe(struct platform_device *pdev) } codec->private_data = aic3x; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -1374,7 +1374,7 @@ static int aic3x_probe(struct platform_device *pdev) static int aic3x_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; /* power down chip */ if (codec->control_data) diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index f530c1e6d9e..796f34cac85 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -981,7 +981,7 @@ static int twl4030_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; + struct snd_soc_codec *codec = socdev->card->codec; u8 mode, old_mode, format, old_format; @@ -1166,7 +1166,7 @@ EXPORT_SYMBOL_GPL(twl4030_dai); static int twl4030_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -1176,7 +1176,7 @@ static int twl4030_suspend(struct platform_device *pdev, pm_message_t state) static int twl4030_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY); twl4030_set_bias_level(codec, codec->suspend_bias_level); @@ -1190,7 +1190,7 @@ static int twl4030_resume(struct platform_device *pdev) static int twl4030_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; printk(KERN_INFO "TWL4030 Audio Codec init \n"); @@ -1251,7 +1251,7 @@ static int twl4030_probe(struct platform_device *pdev) if (codec == NULL) return -ENOMEM; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -1265,7 +1265,7 @@ static int twl4030_probe(struct platform_device *pdev) static int twl4030_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; printk(KERN_INFO "TWL4030 Audio Codec remove\n"); snd_soc_free_pcms(socdev); diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index 277825d155a..661599295ca 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -173,7 +173,7 @@ static int uda134x_startup(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 snd_soc_codec *codec = socdev->card->codec; struct uda134x_priv *uda134x = codec->private_data; struct snd_pcm_runtime *master_runtime; @@ -206,7 +206,7 @@ static void uda134x_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 snd_soc_codec *codec = socdev->card->codec; struct uda134x_priv *uda134x = codec->private_data; if (uda134x->master_substream == substream) @@ -221,7 +221,7 @@ static int uda134x_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; + struct snd_soc_codec *codec = socdev->card->codec; struct uda134x_priv *uda134x = codec->private_data; u8 hw_params; @@ -492,11 +492,11 @@ static int uda134x_soc_probe(struct platform_device *pdev) return -EINVAL; } - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (socdev->codec == NULL) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (socdev->card->codec == NULL) return ret; - codec = socdev->codec; + codec = socdev->card->codec; uda134x = kzalloc(sizeof(struct uda134x_priv), GFP_KERNEL); if (uda134x == NULL) @@ -584,7 +584,7 @@ priv_err: static int uda134x_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -604,7 +604,7 @@ static int uda134x_soc_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; uda134x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); uda134x_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -614,7 +614,7 @@ static int uda134x_soc_suspend(struct platform_device *pdev, static int uda134x_soc_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; uda134x_set_bias_level(codec, SND_SOC_BIAS_PREPARE); uda134x_set_bias_level(codec, SND_SOC_BIAS_ON); diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index a957b4365b9..98e4a6560f0 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -397,7 +397,7 @@ static int uda1380_pcm_prepare(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 snd_soc_codec *codec = socdev->card->codec; int reg, reg_start, reg_end, clk; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -430,7 +430,7 @@ static int uda1380_pcm_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; + struct snd_soc_codec *codec = socdev->card->codec; u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); /* set WSPLL power and divider if running from this clock */ @@ -469,7 +469,7 @@ static void uda1380_pcm_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 snd_soc_codec *codec = socdev->card->codec; u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); /* shut down WSPLL power if running from this clock */ @@ -591,7 +591,7 @@ EXPORT_SYMBOL_GPL(uda1380_dai); static int uda1380_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -600,7 +600,7 @@ static int uda1380_suspend(struct platform_device *pdev, pm_message_t state) static int uda1380_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -622,7 +622,7 @@ static int uda1380_resume(struct platform_device *pdev) */ static int uda1380_init(struct snd_soc_device *socdev, int dac_clk) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "UDA1380"; @@ -688,7 +688,7 @@ static int uda1380_i2c_probe(struct i2c_client *i2c, { struct snd_soc_device *socdev = uda1380_socdev; struct uda1380_setup_data *setup = socdev->codec_data; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -779,7 +779,7 @@ static int uda1380_probe(struct platform_device *pdev) if (codec == NULL) return -ENOMEM; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -803,7 +803,7 @@ static int uda1380_probe(struct platform_device *pdev) static int uda1380_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) uda1380_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 2e0db29b499..75d3438ccb8 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1301,7 +1301,7 @@ static int wm8350_set_bias_level(struct snd_soc_codec *codec, static int wm8350_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8350_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -1310,7 +1310,7 @@ static int wm8350_suspend(struct platform_device *pdev, pm_message_t state) static int wm8350_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); @@ -1423,8 +1423,8 @@ static int wm8350_probe(struct platform_device *pdev) BUG_ON(!wm8350_codec); - socdev->codec = wm8350_codec; - codec = socdev->codec; + socdev->card->codec = wm8350_codec; + codec = socdev->card->codec; wm8350 = codec->control_data; priv = codec->private_data; @@ -1498,7 +1498,7 @@ card_err: static int wm8350_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8350 *wm8350 = codec->control_data; struct wm8350_data *priv = codec->private_data; int ret; diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index abe7cce8771..f01078cfbd7 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -452,7 +452,7 @@ static int wm8510_pcm_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; + struct snd_soc_codec *codec = socdev->card->codec; u16 iface = wm8510_read_reg_cache(codec, WM8510_IFACE) & 0x19f; u16 adn = wm8510_read_reg_cache(codec, WM8510_ADD) & 0x1f1; @@ -581,7 +581,7 @@ EXPORT_SYMBOL_GPL(wm8510_dai); static int wm8510_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -590,7 +590,7 @@ static int wm8510_suspend(struct platform_device *pdev, pm_message_t state) static int wm8510_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -612,7 +612,7 @@ static int wm8510_resume(struct platform_device *pdev) */ static int wm8510_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "WM8510"; @@ -670,7 +670,7 @@ static int wm8510_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8510_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -751,7 +751,7 @@ err_driver: static int __devinit wm8510_spi_probe(struct spi_device *spi) { struct snd_soc_device *socdev = wm8510_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; codec->control_data = spi; @@ -817,7 +817,7 @@ static int wm8510_probe(struct platform_device *pdev) if (codec == NULL) return -ENOMEM; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -847,7 +847,7 @@ static int wm8510_probe(struct platform_device *pdev) static int wm8510_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 3faf0e70ce1..d3c51ba5e6f 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -539,7 +539,7 @@ static int wm8580_paif_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; + struct snd_soc_codec *codec = socdev->card->codec; u16 paifb = wm8580_read(codec, WM8580_PAIF3 + dai->id); paifb &= ~WM8580_AIF_LENGTH_MASK; @@ -816,7 +816,7 @@ EXPORT_SYMBOL_GPL(wm8580_dai); */ static int wm8580_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "WM8580"; @@ -888,7 +888,7 @@ static int wm8580_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8580_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -986,7 +986,7 @@ static int wm8580_probe(struct platform_device *pdev) } codec->private_data = wm8580; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -1007,7 +1007,7 @@ static int wm8580_probe(struct platform_device *pdev) static int wm8580_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index f90dc52e975..f8363b30889 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -137,7 +137,7 @@ static int wm8728_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; + struct snd_soc_codec *codec = socdev->card->codec; u16 dac = wm8728_read_reg_cache(codec, WM8728_DACCTL); dac &= ~0x18; @@ -264,7 +264,7 @@ EXPORT_SYMBOL_GPL(wm8728_dai); static int wm8728_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8728_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -274,7 +274,7 @@ static int wm8728_suspend(struct platform_device *pdev, pm_message_t state) static int wm8728_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8728_set_bias_level(codec, codec->suspend_bias_level); @@ -287,7 +287,7 @@ static int wm8728_resume(struct platform_device *pdev) */ static int wm8728_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; codec->name = "WM8728"; @@ -349,7 +349,7 @@ static int wm8728_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8728_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -430,7 +430,7 @@ err_driver: static int __devinit wm8728_spi_probe(struct spi_device *spi) { struct snd_soc_device *socdev = wm8728_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; codec->control_data = spi; @@ -494,7 +494,7 @@ static int wm8728_probe(struct platform_device *pdev) if (codec == NULL) return -ENOMEM; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -527,7 +527,7 @@ static int wm8728_probe(struct platform_device *pdev) static int wm8728_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8728_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 96d6e1aeaf4..0150fe53a65 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -253,7 +253,7 @@ static int wm8731_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; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8731_priv *wm8731 = codec->private_data; u16 iface = wm8731_read_reg_cache(codec, WM8731_IFACE) & 0xfff3; int i = get_coeff(wm8731->sysclk, params_rate(params)); @@ -283,7 +283,7 @@ static int wm8731_pcm_prepare(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 snd_soc_codec *codec = socdev->card->codec; /* set active */ wm8731_write(codec, WM8731_ACTIVE, 0x0001); @@ -296,7 +296,7 @@ static void wm8731_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 snd_soc_codec *codec = socdev->card->codec; /* deactivate */ if (!codec->active) { @@ -458,7 +458,7 @@ EXPORT_SYMBOL_GPL(wm8731_dai); static int wm8731_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8731_write(codec, WM8731_ACTIVE, 0x0); wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -468,7 +468,7 @@ static int wm8731_suspend(struct platform_device *pdev, pm_message_t state) static int wm8731_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -490,7 +490,7 @@ static int wm8731_resume(struct platform_device *pdev) */ static int wm8731_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg, ret = 0; codec->name = "WM8731"; @@ -561,7 +561,7 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -642,7 +642,7 @@ err_driver: static int __devinit wm8731_spi_probe(struct spi_device *spi) { struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; codec->control_data = spi; @@ -716,7 +716,7 @@ static int wm8731_probe(struct platform_device *pdev) } codec->private_data = wm8731; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -750,7 +750,7 @@ static int wm8731_probe(struct platform_device *pdev) static int wm8731_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 1578569793a..96afb86addc 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -604,7 +604,7 @@ static int wm8750_pcm_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; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8750_priv *wm8750 = codec->private_data; u16 iface = wm8750_read_reg_cache(codec, WM8750_IFACE) & 0x1f3; u16 srate = wm8750_read_reg_cache(codec, WM8750_SRATE) & 0x1c0; @@ -712,7 +712,7 @@ static void wm8750_work(struct work_struct *work) static int wm8750_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -721,7 +721,7 @@ static int wm8750_suspend(struct platform_device *pdev, pm_message_t state) static int wm8750_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -754,7 +754,7 @@ static int wm8750_resume(struct platform_device *pdev) */ static int wm8750_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg, ret = 0; codec->name = "WM8750"; @@ -836,7 +836,7 @@ static int wm8750_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8750_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -917,7 +917,7 @@ err_driver: static int __devinit wm8750_spi_probe(struct spi_device *spi) { struct snd_soc_device *socdev = wm8750_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; codec->control_data = spi; @@ -989,7 +989,7 @@ static int wm8750_probe(struct platform_device *pdev) } codec->private_data = wm8750; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -1043,7 +1043,7 @@ static int run_delayed_work(struct delayed_work *dwork) static int wm8750_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 5a1c1fca120..502766dce86 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -912,7 +912,7 @@ static int wm8753_pcm_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; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8753_priv *wm8753 = codec->private_data; u16 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x01f3; u16 srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x017f; @@ -1146,7 +1146,7 @@ static int wm8753_i2s_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; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8753_priv *wm8753 = codec->private_data; u16 srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x01c0; u16 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x01f3; @@ -1483,7 +1483,7 @@ static void wm8753_work(struct work_struct *work) static int wm8753_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; /* we only need to suspend if we are a valid card */ if (!codec->card) @@ -1496,7 +1496,7 @@ static int wm8753_suspend(struct platform_device *pdev, pm_message_t state) static int wm8753_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -1533,7 +1533,7 @@ static int wm8753_resume(struct platform_device *pdev) */ static int wm8753_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg, ret = 0; codec->name = "WM8753"; @@ -1624,7 +1624,7 @@ static int wm8753_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8753_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -1705,7 +1705,7 @@ err_driver: static int __devinit wm8753_spi_probe(struct spi_device *spi) { struct snd_soc_device *socdev = wm8753_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; codec->control_data = spi; @@ -1780,7 +1780,7 @@ static int wm8753_probe(struct platform_device *pdev) } codec->private_data = wm8753; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -1832,7 +1832,7 @@ static int run_delayed_work(struct delayed_work *dwork) static int wm8753_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 1e08d4f065f..85c0f1bc676 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -720,7 +720,7 @@ static int wm8900_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; + struct snd_soc_codec *codec = socdev->card->codec; u16 reg; reg = wm8900_read(codec, WM8900_REG_AUDIO1) & ~0x60; @@ -1210,7 +1210,7 @@ static int wm8900_set_bias_level(struct snd_soc_codec *codec, static int wm8900_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8900_priv *wm8900 = codec->private_data; int fll_out = wm8900->fll_out; int fll_in = wm8900->fll_in; @@ -1234,7 +1234,7 @@ static int wm8900_suspend(struct platform_device *pdev, pm_message_t state) static int wm8900_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8900_priv *wm8900 = codec->private_data; u16 *cache; int i, ret; @@ -1414,7 +1414,7 @@ static int wm8900_probe(struct platform_device *pdev) } codec = wm8900_codec; - socdev->codec = codec; + socdev->card->codec = codec; /* Register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 6ff34b957dc..d36b2b1edf1 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1261,7 +1261,7 @@ static int wm8903_startup(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 snd_soc_codec *codec = socdev->card->codec; struct wm8903_priv *wm8903 = codec->private_data; struct i2c_client *i2c = codec->control_data; struct snd_pcm_runtime *master_runtime; @@ -1303,7 +1303,7 @@ static void wm8903_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 snd_soc_codec *codec = socdev->card->codec; struct wm8903_priv *wm8903 = codec->private_data; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -1323,7 +1323,7 @@ static int wm8903_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; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8903_priv *wm8903 = codec->private_data; struct i2c_client *i2c = codec->control_data; int fs = params_rate(params); @@ -1527,7 +1527,7 @@ EXPORT_SYMBOL_GPL(wm8903_dai); static int wm8903_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -1537,7 +1537,7 @@ static int wm8903_suspend(struct platform_device *pdev, pm_message_t state) static int wm8903_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct i2c_client *i2c = codec->control_data; int i; u16 *reg_cache = codec->reg_cache; @@ -1713,7 +1713,7 @@ static int wm8903_probe(struct platform_device *pdev) goto err; } - socdev->codec = wm8903_codec; + socdev->card->codec = wm8903_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); @@ -1722,9 +1722,9 @@ static int wm8903_probe(struct platform_device *pdev) goto err; } - snd_soc_add_controls(socdev->codec, wm8903_snd_controls, + snd_soc_add_controls(socdev->card->codec, wm8903_snd_controls, ARRAY_SIZE(wm8903_snd_controls)); - wm8903_add_widgets(socdev->codec); + wm8903_add_widgets(socdev->card->codec); ret = snd_soc_init_card(socdev); if (ret < 0) { @@ -1745,7 +1745,7 @@ err: static int wm8903_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8903_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index c8bd9b06f33..24d4c905a01 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -531,7 +531,7 @@ static int wm8971_pcm_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; + struct snd_soc_codec *codec = socdev->card->codec; struct wm8971_priv *wm8971 = codec->private_data; u16 iface = wm8971_read_reg_cache(codec, WM8971_IFACE) & 0x1f3; u16 srate = wm8971_read_reg_cache(codec, WM8971_SRATE) & 0x1c0; @@ -637,7 +637,7 @@ static void wm8971_work(struct work_struct *work) static int wm8971_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -646,7 +646,7 @@ static int wm8971_suspend(struct platform_device *pdev, pm_message_t state) static int wm8971_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -677,7 +677,7 @@ static int wm8971_resume(struct platform_device *pdev) static int wm8971_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg, ret = 0; codec->name = "WM8971"; @@ -758,7 +758,7 @@ static int wm8971_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8971_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -859,7 +859,7 @@ static int wm8971_probe(struct platform_device *pdev) } codec->private_data = wm8971; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -894,7 +894,7 @@ static int wm8971_probe(struct platform_device *pdev) static int wm8971_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index f93c0955ed9..6af1d399b31 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -1162,7 +1162,7 @@ static int wm8990_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; + struct snd_soc_codec *codec = socdev->card->codec; u16 audio1 = wm8990_read_reg_cache(codec, WM8990_AUDIO_INTERFACE_1); audio1 &= ~WM8990_AIF_WL_MASK; @@ -1361,7 +1361,7 @@ EXPORT_SYMBOL_GPL(wm8990_dai); static int wm8990_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; /* we only need to suspend if we are a valid card */ if (!codec->card) @@ -1374,7 +1374,7 @@ static int wm8990_suspend(struct platform_device *pdev, pm_message_t state) static int wm8990_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i; u8 data[2]; u16 *cache = codec->reg_cache; @@ -1402,7 +1402,7 @@ static int wm8990_resume(struct platform_device *pdev) */ static int wm8990_init(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; u16 reg; int ret = 0; @@ -1480,7 +1480,7 @@ static int wm8990_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct snd_soc_device *socdev = wm8990_socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int ret; i2c_set_clientdata(i2c, codec); @@ -1579,7 +1579,7 @@ static int wm8990_probe(struct platform_device *pdev) } codec->private_data = wm8990; - socdev->codec = codec; + socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); @@ -1605,7 +1605,7 @@ static int wm8990_probe(struct platform_device *pdev) static int wm8990_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec->control_data) wm8990_set_bias_level(codec, SND_SOC_BIAS_OFF); diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index d5c81bb3dec..2e9e06b2daa 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -249,7 +249,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg; u16 vra; @@ -323,10 +323,11 @@ static int wm9705_soc_probe(struct platform_device *pdev) printk(KERN_INFO "WM9705 SoC Audio Codec\n"); - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (socdev->codec == NULL) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), + GFP_KERNEL); + if (socdev->card->codec == NULL) return -ENOMEM; - codec = socdev->codec; + codec = socdev->card->codec; mutex_init(&codec->mutex); codec->reg_cache = kmemdup(wm9705_reg, sizeof(wm9705_reg), GFP_KERNEL); @@ -380,15 +381,15 @@ pcm_err: codec_err: kfree(codec->reg_cache); cache_err: - kfree(socdev->codec); - socdev->codec = NULL; + kfree(socdev->card->codec); + socdev->card->codec = NULL; return ret; } static int wm9705_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec == NULL) return 0; diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 4dc90d67530..b3a8be77676 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -478,7 +478,7 @@ static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int reg; u16 vra; @@ -499,7 +499,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; u16 vra, xsle; vra = ac97_read(codec, AC97_EXTENDED_STATUS); @@ -592,7 +592,7 @@ static int wm9712_soc_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; wm9712_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; @@ -601,7 +601,7 @@ static int wm9712_soc_suspend(struct platform_device *pdev, static int wm9712_soc_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; int i, ret; u16 *cache = codec->reg_cache; @@ -637,10 +637,11 @@ static int wm9712_soc_probe(struct platform_device *pdev) printk(KERN_INFO "WM9711/WM9712 SoC Audio Codec %s\n", WM9712_VERSION); - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (socdev->codec == NULL) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), + GFP_KERNEL); + if (socdev->card->codec == NULL) return -ENOMEM; - codec = socdev->codec; + codec = socdev->card->codec; mutex_init(&codec->mutex); codec->reg_cache = kmemdup(wm9712_reg, sizeof(wm9712_reg), GFP_KERNEL); @@ -704,15 +705,15 @@ codec_err: kfree(codec->reg_cache); cache_err: - kfree(socdev->codec); - socdev->codec = NULL; + kfree(socdev->card->codec); + socdev->card->codec = NULL; return ret; } static int wm9712_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec == NULL) return 0; diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 0e60e16973d..54db9c52498 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -1115,7 +1115,7 @@ static int wm9713_soc_suspend(struct platform_device *pdev, pm_message_t state) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; u16 reg; /* Disable everything except touchpanel - that will be handled @@ -1133,7 +1133,7 @@ static int wm9713_soc_suspend(struct platform_device *pdev, static int wm9713_soc_resume(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; struct wm9713_priv *wm9713 = codec->private_data; int i, ret; u16 *cache = codec->reg_cache; @@ -1174,10 +1174,11 @@ static int wm9713_soc_probe(struct platform_device *pdev) printk(KERN_INFO "WM9713/WM9714 SoC Audio Codec %s\n", WM9713_VERSION); - socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (socdev->codec == NULL) + socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), + GFP_KERNEL); + if (socdev->card->codec == NULL) return -ENOMEM; - codec = socdev->codec; + codec = socdev->card->codec; mutex_init(&codec->mutex); codec->reg_cache = kmemdup(wm9713_reg, sizeof(wm9713_reg), GFP_KERNEL); @@ -1249,15 +1250,15 @@ priv_err: kfree(codec->reg_cache); cache_err: - kfree(socdev->codec); - socdev->codec = NULL; + kfree(socdev->card->codec); + socdev->card->codec = NULL; return ret; } static int wm9713_soc_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; if (codec == NULL) return 0; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 8313d52a6e8..f18c7a3e36d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -234,7 +234,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) cpu_dai->capture.active = codec_dai->capture.active = 1; cpu_dai->active = codec_dai->active = 1; cpu_dai->runtime = runtime; - socdev->codec->active++; + card->codec->active++; mutex_unlock(&pcm_mutex); return 0; @@ -264,7 +264,7 @@ static void close_delayed_work(struct work_struct *work) struct snd_soc_card *card = container_of(work, struct snd_soc_card, delayed_work.work); struct snd_soc_device *socdev = card->socdev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = card->codec; struct snd_soc_dai *codec_dai; int i; @@ -319,7 +319,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream) struct snd_soc_platform *platform = card->platform; struct snd_soc_dai *cpu_dai = machine->cpu_dai; struct snd_soc_dai *codec_dai = machine->codec_dai; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = card->codec; mutex_lock(&pcm_mutex); @@ -387,7 +387,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) struct snd_soc_platform *platform = card->platform; struct snd_soc_dai *cpu_dai = machine->cpu_dai; struct snd_soc_dai *codec_dai = machine->codec_dai; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = card->codec; int ret = 0; mutex_lock(&pcm_mutex); @@ -553,7 +553,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) struct snd_soc_platform *platform = card->platform; struct snd_soc_dai *cpu_dai = machine->cpu_dai; struct snd_soc_dai *codec_dai = machine->codec_dai; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = card->codec; mutex_lock(&pcm_mutex); @@ -629,7 +629,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state) struct snd_soc_card *card = socdev->card; struct snd_soc_platform *platform = card->platform; struct snd_soc_codec_device *codec_dev = socdev->codec_dev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = card->codec; int i; /* Due to the resume being scheduled into a workqueue we could @@ -705,7 +705,7 @@ static void soc_resume_deferred(struct work_struct *work) struct snd_soc_device *socdev = card->socdev; struct snd_soc_platform *platform = card->platform; struct snd_soc_codec_device *codec_dev = socdev->codec_dev; - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = card->codec; struct platform_device *pdev = to_platform_device(socdev->dev); int i; @@ -982,8 +982,8 @@ static struct platform_driver soc_driver = { static int soc_new_pcm(struct snd_soc_device *socdev, struct snd_soc_dai_link *dai_link, int num) { - struct snd_soc_codec *codec = socdev->codec; struct snd_soc_card *card = socdev->card; + struct snd_soc_codec *codec = card->codec; struct snd_soc_platform *platform = card->platform; struct snd_soc_dai *codec_dai = dai_link->codec_dai; struct snd_soc_dai *cpu_dai = dai_link->cpu_dai; @@ -998,7 +998,7 @@ static int soc_new_pcm(struct snd_soc_device *socdev, rtd->dai = dai_link; rtd->socdev = socdev; - codec_dai->codec = socdev->codec; + codec_dai->codec = card->codec; /* check client and interface hw capabilities */ sprintf(new_name, "%s %s-%d", dai_link->stream_name, codec_dai->name, @@ -1048,9 +1048,8 @@ static int soc_new_pcm(struct snd_soc_device *socdev, } /* codec register dump */ -static ssize_t soc_codec_reg_show(struct snd_soc_device *devdata, char *buf) +static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf) { - struct snd_soc_codec *codec = devdata->codec; int i, step = 1, count = 0; if (!codec->reg_cache_size) @@ -1090,7 +1089,7 @@ static ssize_t codec_reg_show(struct device *dev, struct device_attribute *attr, char *buf) { struct snd_soc_device *devdata = dev_get_drvdata(dev); - return soc_codec_reg_show(devdata, buf); + return soc_codec_reg_show(devdata->card->codec, buf); } static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); @@ -1107,12 +1106,10 @@ static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf, { ssize_t ret; struct snd_soc_codec *codec = file->private_data; - struct device *card_dev = codec->card->dev; - struct snd_soc_device *devdata = card_dev->driver_data; char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); if (!buf) return -ENOMEM; - ret = soc_codec_reg_show(devdata, buf); + ret = soc_codec_reg_show(codec, buf); if (ret >= 0) ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); kfree(buf); @@ -1309,8 +1306,8 @@ EXPORT_SYMBOL_GPL(snd_soc_test_bits); */ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) { - struct snd_soc_codec *codec = socdev->codec; struct snd_soc_card *card = socdev->card; + struct snd_soc_codec *codec = card->codec; int ret = 0, i; mutex_lock(&codec->mutex); @@ -1355,8 +1352,8 @@ EXPORT_SYMBOL_GPL(snd_soc_new_pcms); */ int snd_soc_init_card(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; struct snd_soc_card *card = socdev->card; + struct snd_soc_codec *codec = card->codec; int ret = 0, i, ac97 = 0, err = 0; for (i = 0; i < card->num_links; i++) { @@ -1404,7 +1401,7 @@ int snd_soc_init_card(struct snd_soc_device *socdev) if (err < 0) printk(KERN_WARNING "asoc: failed to add codec sysfs files\n"); - soc_init_codec_debugfs(socdev->codec); + soc_init_codec_debugfs(codec); mutex_unlock(&codec->mutex); out: @@ -1421,14 +1418,14 @@ EXPORT_SYMBOL_GPL(snd_soc_init_card); */ void snd_soc_free_pcms(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; #ifdef CONFIG_SND_SOC_AC97_BUS struct snd_soc_dai *codec_dai; int i; #endif mutex_lock(&codec->mutex); - soc_cleanup_codec_debugfs(socdev->codec); + soc_cleanup_codec_debugfs(codec); #ifdef CONFIG_SND_SOC_AC97_BUS for (i = 0; i < codec->num_dai; i++) { codec_dai = &codec->dai[i]; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 54b4564b82b..f4a8753c84c 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -817,7 +817,7 @@ static ssize_t dapm_widget_show(struct device *dev, struct device_attribute *attr, char *buf) { struct snd_soc_device *devdata = dev_get_drvdata(dev); - struct snd_soc_codec *codec = devdata->codec; + struct snd_soc_codec *codec = devdata->card->codec; struct snd_soc_dapm_widget *w; int count = 0; char *state = "not set"; @@ -1552,8 +1552,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_event); int snd_soc_dapm_set_bias_level(struct snd_soc_device *socdev, enum snd_soc_bias_level level) { - struct snd_soc_codec *codec = socdev->codec; struct snd_soc_card *card = socdev->card; + struct snd_soc_codec *codec = socdev->card->codec; int ret = 0; if (card->set_bias_level) @@ -1645,7 +1645,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status); */ void snd_soc_dapm_free(struct snd_soc_device *socdev) { - struct snd_soc_codec *codec = socdev->codec; + struct snd_soc_codec *codec = socdev->card->codec; snd_soc_dapm_sys_remove(socdev->dev); dapm_free_widgets(codec); diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 8cc00c3cdf3..ab64a30bedd 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -34,7 +34,7 @@ int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type, jack->card = card; INIT_LIST_HEAD(&jack->pins); - return snd_jack_new(card->socdev->codec->card, id, type, &jack->jack); + return snd_jack_new(card->codec->card, id, type, &jack->jack); } EXPORT_SYMBOL_GPL(snd_soc_jack_new); @@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new); */ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) { - struct snd_soc_codec *codec = jack->card->socdev->codec; + struct snd_soc_codec *codec = jack->card->codec; struct snd_soc_jack_pin *pin; int enable; int oldstatus; -- cgit v1.2.3 From 3fc93030e5a792fdd0da3321487f5cbfd1143c2b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 27 Jan 2009 11:29:39 +0200 Subject: ASoC: TWL4030: Syncronize the reg_cache for ANAMICL after the offset cancelation The offset cancelation bit in ANAMICL register is self cleanig. Make sure that the reg_cache holds the same value as the HW register. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 796f34cac85..24419afd319 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -913,6 +913,9 @@ static void twl4030_power_up(struct snd_soc_codec *codec) ((byte & TWL4030_CNCL_OFFSET_START) == TWL4030_CNCL_OFFSET_START)); + /* Make sure that the reg_cache has the same value as the HW */ + twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); + /* anti-pop when changing analog gain */ regmisc1 = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); twl4030_write(codec, TWL4030_REG_MISC_SET_1, -- cgit v1.2.3 From db04e2c58a65364218b89f1372b4b3b78d206423 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 27 Jan 2009 11:29:40 +0200 Subject: ASoC: TWL4030: Code clean up for codec power up and down Merge the codec up and down functions to a simple one. Codec is powered down by default (reg_cache change). Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 24419afd319..af7b433d4f5 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -42,7 +42,7 @@ */ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { 0x00, /* this register not used */ - 0x93, /* REG_CODEC_MODE (0x1) */ + 0x91, /* REG_CODEC_MODE (0x1) */ 0xc3, /* REG_OPTION (0x2) */ 0x00, /* REG_UNKNOWN (0x3) */ 0x00, /* REG_MICBIAS_CTL (0x4) */ @@ -154,26 +154,17 @@ static int twl4030_write(struct snd_soc_codec *codec, return twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg); } -static void twl4030_clear_codecpdz(struct snd_soc_codec *codec) +static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) { u8 mode; mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE); - twl4030_write(codec, TWL4030_REG_CODEC_MODE, - mode & ~TWL4030_CODECPDZ); + if (enable) + mode |= TWL4030_CODECPDZ; + else + mode &= ~TWL4030_CODECPDZ; - /* REVISIT: this delay is present in TI sample drivers */ - /* but there seems to be no TRM requirement for it */ - udelay(10); -} - -static void twl4030_set_codecpdz(struct snd_soc_codec *codec) -{ - u8 mode; - - mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE); - twl4030_write(codec, TWL4030_REG_CODEC_MODE, - mode | TWL4030_CODECPDZ); + twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); /* REVISIT: this delay is present in TI sample drivers */ /* but there seems to be no TRM requirement for it */ @@ -185,7 +176,7 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) int i; /* clear CODECPDZ prior to setting register defaults */ - twl4030_clear_codecpdz(codec); + twl4030_codec_enable(codec, 0); /* set all audio section registers to reasonable defaults */ for (i = TWL4030_REG_OPTION; i <= TWL4030_REG_MISC_SET_2; i++) @@ -895,7 +886,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec) int i = 0; /* set CODECPDZ to turn on codec */ - twl4030_set_codecpdz(codec); + twl4030_codec_enable(codec, 1); /* initiate offset cancellation */ anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); @@ -922,8 +913,8 @@ static void twl4030_power_up(struct snd_soc_codec *codec) regmisc1 | TWL4030_SMOOTH_ANAVOL_EN); /* toggle CODECPDZ as per TRM */ - twl4030_clear_codecpdz(codec); - twl4030_set_codecpdz(codec); + twl4030_codec_enable(codec, 0); + twl4030_codec_enable(codec, 1); /* program anti-pop with bias ramp delay */ popn = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); @@ -952,7 +943,7 @@ static void twl4030_power_down(struct snd_soc_codec *codec) twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn); /* power down */ - twl4030_clear_codecpdz(codec); + twl4030_codec_enable(codec, 0); } static int twl4030_set_bias_level(struct snd_soc_codec *codec, @@ -1030,7 +1021,7 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, if (mode != old_mode) { /* change rate and set CODECPDZ */ twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); - twl4030_set_codecpdz(codec); + twl4030_codec_enable(codec, 1); } /* sample size */ @@ -1053,13 +1044,13 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, if (format != old_format) { /* clear CODECPDZ before changing format (codec requirement) */ - twl4030_clear_codecpdz(codec); + twl4030_codec_enable(codec, 0); /* change format */ twl4030_write(codec, TWL4030_REG_AUDIO_IF, format); /* set CODECPDZ afterwards */ - twl4030_set_codecpdz(codec); + twl4030_codec_enable(codec, 1); } return 0; } @@ -1129,13 +1120,13 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, if (format != old_format) { /* clear CODECPDZ before changing format (codec requirement) */ - twl4030_clear_codecpdz(codec); + twl4030_codec_enable(codec, 0); /* change format */ twl4030_write(codec, TWL4030_REG_AUDIO_IF, format); /* set CODECPDZ afterwards */ - twl4030_set_codecpdz(codec); + twl4030_codec_enable(codec, 1); } return 0; -- cgit v1.2.3 From aad749e51a66d473f5cef4a050e3e36795261be3 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 27 Jan 2009 11:29:41 +0200 Subject: ASoC: TWL4030: Enable Headset Left anti-pop/bias ramp only if the Headset Left is in use The Headset Left anti-pop and bias ramp does not need to be enabled, if the headset is not in use. Move the code to DAPM event handler for HeadsetL. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 71 +++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 26 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index af7b433d4f5..900486ef633 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -414,6 +414,47 @@ static int handsfree_event(struct snd_soc_dapm_widget *w, return 0; } +static int headsetl_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + unsigned char hs_gain, hs_pop; + + /* Save the current volume */ + hs_gain = twl4030_read_reg_cache(w->codec, TWL4030_REG_HS_GAIN_SET); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + /* Do the anti-pop/bias ramp enable according to the TRM */ + hs_pop = TWL4030_RAMP_DELAY_645MS; + twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); + hs_pop |= TWL4030_VMID_EN; + twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); + /* Is this needed? Can we just use whatever gain here? */ + twl4030_write(w->codec, TWL4030_REG_HS_GAIN_SET, + (hs_gain & (~0x0f)) | 0x0a); + hs_pop |= TWL4030_RAMP_EN; + twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); + + /* Restore the original volume */ + twl4030_write(w->codec, TWL4030_REG_HS_GAIN_SET, hs_gain); + break; + case SND_SOC_DAPM_POST_PMD: + /* Do the anti-pop/bias ramp disable according to the TRM */ + hs_pop = twl4030_read_reg_cache(w->codec, + TWL4030_REG_HS_POPN_SET); + hs_pop &= ~TWL4030_RAMP_EN; + twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); + /* Bypass the reg_cache to mute the headset */ + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + hs_gain & (~0x0f), + TWL4030_REG_HS_GAIN_SET); + hs_pop &= ~TWL4030_VMID_EN; + twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); + break; + } + return 0; +} + /* * Some of the gain controls in TWL (mostly those which are associated with * the outputs) are implemented in an interesting way: @@ -720,8 +761,9 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0, &twl4030_dapm_predriver_control), /* HeadsetL/R */ - SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, - &twl4030_dapm_hsol_control), + SND_SOC_DAPM_MUX_E("HeadsetL Mux", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_hsol_control, headsetl_event, + SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MUX("HeadsetR Mux", SND_SOC_NOPM, 0, 0, &twl4030_dapm_hsor_control), /* CarkitL/R */ @@ -882,7 +924,7 @@ static int twl4030_add_widgets(struct snd_soc_codec *codec) static void twl4030_power_up(struct snd_soc_codec *codec) { - u8 anamicl, regmisc1, byte, popn; + u8 anamicl, regmisc1, byte; int i = 0; /* set CODECPDZ to turn on codec */ @@ -915,33 +957,10 @@ static void twl4030_power_up(struct snd_soc_codec *codec) /* toggle CODECPDZ as per TRM */ twl4030_codec_enable(codec, 0); twl4030_codec_enable(codec, 1); - - /* program anti-pop with bias ramp delay */ - popn = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); - popn &= TWL4030_RAMP_DELAY; - popn |= TWL4030_RAMP_DELAY_645MS; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn); - popn |= TWL4030_VMID_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn); - - /* enable anti-pop ramp */ - popn |= TWL4030_RAMP_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn); } static void twl4030_power_down(struct snd_soc_codec *codec) { - u8 popn; - - /* disable anti-pop ramp */ - popn = twl4030_read_reg_cache(codec, TWL4030_REG_HS_POPN_SET); - popn &= ~TWL4030_RAMP_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn); - - /* disable bias out */ - popn &= ~TWL4030_VMID_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, popn); - /* power down */ twl4030_codec_enable(codec, 0); } -- cgit v1.2.3 From fb2a2f84908460c18c3894963990518b224dd9ff Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 27 Jan 2009 11:29:42 +0200 Subject: ASoC: TWL4030: Physical ADC and amplifier power switch change Change the power switches for the physical ADC and for the amplifiers for the analog capture path to map more closely the actual path inside of the codec. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 900486ef633..8fe059e3e9a 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -802,16 +802,16 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| SND_SOC_DAPM_POST_REG), - /* Analog input muxes with power switch for the physical ADCL/R */ + /* Analog input muxes with switch for the capture amplifiers */ SND_SOC_DAPM_VALUE_MUX("Analog Left Capture Route", - TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control), + TWL4030_REG_ANAMICL, 4, 0, &twl4030_dapm_analoglmic_control), SND_SOC_DAPM_VALUE_MUX("Analog Right Capture Route", - TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control), + TWL4030_REG_ANAMICR, 4, 0, &twl4030_dapm_analogrmic_control), - SND_SOC_DAPM_PGA("Analog Left Amplifier", - TWL4030_REG_ANAMICL, 4, 0, NULL, 0), - SND_SOC_DAPM_PGA("Analog Right Amplifier", - TWL4030_REG_ANAMICR, 4, 0, NULL, 0), + SND_SOC_DAPM_PGA("ADC Physical Left", + TWL4030_REG_AVADC_CTL, 3, 0, NULL, 0), + SND_SOC_DAPM_PGA("ADC Physical Right", + TWL4030_REG_AVADC_CTL, 1, 0, NULL, 0), SND_SOC_DAPM_PGA("Digimic0 Enable", TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0), @@ -885,23 +885,23 @@ static const struct snd_soc_dapm_route intercon[] = { {"Analog Right Capture Route", "Sub mic", "SUBMIC"}, {"Analog Right Capture Route", "AUXR", "AUXR"}, - {"Analog Left Amplifier", NULL, "Analog Left Capture Route"}, - {"Analog Right Amplifier", NULL, "Analog Right Capture Route"}, + {"ADC Physical Left", NULL, "Analog Left Capture Route"}, + {"ADC Physical Right", NULL, "Analog Right Capture Route"}, {"Digimic0 Enable", NULL, "DIGIMIC0"}, {"Digimic1 Enable", NULL, "DIGIMIC1"}, /* TX1 Left capture path */ - {"TX1 Capture Route", "Analog", "Analog Left Amplifier"}, + {"TX1 Capture Route", "Analog", "ADC Physical Left"}, {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"}, /* TX1 Right capture path */ - {"TX1 Capture Route", "Analog", "Analog Right Amplifier"}, + {"TX1 Capture Route", "Analog", "ADC Physical Right"}, {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"}, /* TX2 Left capture path */ - {"TX2 Capture Route", "Analog", "Analog Left Amplifier"}, + {"TX2 Capture Route", "Analog", "ADC Physical Left"}, {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"}, /* TX2 Right capture path */ - {"TX2 Capture Route", "Analog", "Analog Right Amplifier"}, + {"TX2 Capture Route", "Analog", "ADC Physical Right"}, {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"}, {"ADC Virtual Left1", NULL, "TX1 Capture Route"}, -- cgit v1.2.3 From 006f367e38fb45e2f161c0f500c74449ae63e866 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 27 Jan 2009 11:29:43 +0200 Subject: ASoC: TWL4030: Move the twl4030_power_up and _power_down function Move the twl4030_power_up and twl4030_power_down function earlier to facilitate the analog bypass implementation. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 85 +++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 43 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 8fe059e3e9a..f985bef40a3 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -184,6 +184,48 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) } +static void twl4030_power_up(struct snd_soc_codec *codec) +{ + u8 anamicl, regmisc1, byte; + int i = 0; + + /* set CODECPDZ to turn on codec */ + twl4030_codec_enable(codec, 1); + + /* initiate offset cancellation */ + anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); + twl4030_write(codec, TWL4030_REG_ANAMICL, + anamicl | TWL4030_CNCL_OFFSET_START); + + /* wait for offset cancellation to complete */ + do { + /* this takes a little while, so don't slam i2c */ + udelay(2000); + twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, + TWL4030_REG_ANAMICL); + } while ((i++ < 100) && + ((byte & TWL4030_CNCL_OFFSET_START) == + TWL4030_CNCL_OFFSET_START)); + + /* Make sure that the reg_cache has the same value as the HW */ + twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); + + /* anti-pop when changing analog gain */ + regmisc1 = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); + twl4030_write(codec, TWL4030_REG_MISC_SET_1, + regmisc1 | TWL4030_SMOOTH_ANAVOL_EN); + + /* toggle CODECPDZ as per TRM */ + twl4030_codec_enable(codec, 0); + twl4030_codec_enable(codec, 1); +} + +static void twl4030_power_down(struct snd_soc_codec *codec) +{ + /* power down */ + twl4030_codec_enable(codec, 0); +} + /* Earpiece */ static const char *twl4030_earpiece_texts[] = {"Off", "DACL1", "DACL2", "DACR1"}; @@ -922,49 +964,6 @@ static int twl4030_add_widgets(struct snd_soc_codec *codec) return 0; } -static void twl4030_power_up(struct snd_soc_codec *codec) -{ - u8 anamicl, regmisc1, byte; - int i = 0; - - /* set CODECPDZ to turn on codec */ - twl4030_codec_enable(codec, 1); - - /* initiate offset cancellation */ - anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); - twl4030_write(codec, TWL4030_REG_ANAMICL, - anamicl | TWL4030_CNCL_OFFSET_START); - - - /* wait for offset cancellation to complete */ - do { - /* this takes a little while, so don't slam i2c */ - udelay(2000); - twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, - TWL4030_REG_ANAMICL); - } while ((i++ < 100) && - ((byte & TWL4030_CNCL_OFFSET_START) == - TWL4030_CNCL_OFFSET_START)); - - /* Make sure that the reg_cache has the same value as the HW */ - twl4030_write_reg_cache(codec, TWL4030_REG_ANAMICL, byte); - - /* anti-pop when changing analog gain */ - regmisc1 = twl4030_read_reg_cache(codec, TWL4030_REG_MISC_SET_1); - twl4030_write(codec, TWL4030_REG_MISC_SET_1, - regmisc1 | TWL4030_SMOOTH_ANAVOL_EN); - - /* toggle CODECPDZ as per TRM */ - twl4030_codec_enable(codec, 0); - twl4030_codec_enable(codec, 1); -} - -static void twl4030_power_down(struct snd_soc_codec *codec) -{ - /* power down */ - twl4030_codec_enable(codec, 0); -} - static int twl4030_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { -- cgit v1.2.3 From 7393958f630ac91e591e62058f2bdb61523ec60c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 29 Jan 2009 14:57:50 +0200 Subject: ASoC: TWL4030: Add analog loopback support This patch adds the analog loopback/bypass support for twl4030 codec. Details for the implementation: It seams that the analog loopback needs the DAC powered on on the channel, where the loopback is selected. The switch for the DACs has been moved from the DAPM_DAC to the "Analog XX Playback Mixer". In this way the DAC will be powered while the audio playback is used or/and the loopback is enabled for the channel. The twl4030 codec powering has been reworked. Now the codec will be powered as long as it does not receives the SND_SOC_BIAS_OFF event. The exceptions are when the given change in the registers needs the codec power down/up cycle in order to take effect. Otherwise the codec is on. When the codec enters to STANDBY state and none of the loopback paths are enabled, than the amplifiers, which are no in the DAPM path are forced to turn off and the PLL is disabled. When playback/capture starts the disabled gains are restored and the PLL is enabled. When one of the loopback enabled in STANDBY mode, the disabled gains are restored and the PLL is enabled also. In short: the codec always goes to the lowest power state based on the bias_level and the bypass_state. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 212 ++++++++++++++++++++++++++++++++++++++++++--- sound/soc/codecs/twl4030.h | 15 ++++ 2 files changed, 214 insertions(+), 13 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index f985bef40a3..c26854b398d 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -117,6 +117,13 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { 0x00, /* REG_MISC_SET_2 (0x49) */ }; +/* codec private data */ +struct twl4030_priv { + unsigned int bypass_state; + unsigned int codec_powered; + unsigned int codec_muted; +}; + /* * read twl4030 register cache */ @@ -156,8 +163,12 @@ static int twl4030_write(struct snd_soc_codec *codec, static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) { + struct twl4030_priv *twl4030 = codec->private_data; u8 mode; + if (enable == twl4030->codec_powered) + return; + mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE); if (enable) mode |= TWL4030_CODECPDZ; @@ -165,6 +176,7 @@ static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) mode &= ~TWL4030_CODECPDZ; twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); + twl4030->codec_powered = enable; /* REVISIT: this delay is present in TI sample drivers */ /* but there seems to be no TRM requirement for it */ @@ -184,11 +196,82 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) } +static void twl4030_codec_mute(struct snd_soc_codec *codec, int mute) +{ + struct twl4030_priv *twl4030 = codec->private_data; + u8 reg_val; + + if (mute == twl4030->codec_muted) + return; + + if (mute) { + /* Bypass the reg_cache and mute the volumes + * Headset mute is done in it's own event handler + * Things to mute: Earpiece, PreDrivL/R, CarkitL/R + */ + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_EAR_CTL); + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + reg_val & (~TWL4030_EAR_GAIN), + TWL4030_REG_EAR_CTL); + + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_PREDL_CTL); + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + reg_val & (~TWL4030_PREDL_GAIN), + TWL4030_REG_PREDL_CTL); + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_PREDR_CTL); + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + reg_val & (~TWL4030_PREDR_GAIN), + TWL4030_REG_PREDL_CTL); + + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_PRECKL_CTL); + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + reg_val & (~TWL4030_PRECKL_GAIN), + TWL4030_REG_PRECKL_CTL); + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_PRECKR_CTL); + twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + reg_val & (~TWL4030_PRECKL_GAIN), + TWL4030_REG_PRECKR_CTL); + + /* Disable PLL */ + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL); + reg_val &= ~TWL4030_APLL_EN; + twl4030_write(codec, TWL4030_REG_APLL_CTL, reg_val); + } else { + /* Restore the volumes + * Headset mute is done in it's own event handler + * Things to restore: Earpiece, PreDrivL/R, CarkitL/R + */ + twl4030_write(codec, TWL4030_REG_EAR_CTL, + twl4030_read_reg_cache(codec, TWL4030_REG_EAR_CTL)); + + twl4030_write(codec, TWL4030_REG_PREDL_CTL, + twl4030_read_reg_cache(codec, TWL4030_REG_PREDL_CTL)); + twl4030_write(codec, TWL4030_REG_PREDR_CTL, + twl4030_read_reg_cache(codec, TWL4030_REG_PREDR_CTL)); + + twl4030_write(codec, TWL4030_REG_PRECKL_CTL, + twl4030_read_reg_cache(codec, TWL4030_REG_PRECKL_CTL)); + twl4030_write(codec, TWL4030_REG_PRECKR_CTL, + twl4030_read_reg_cache(codec, TWL4030_REG_PRECKR_CTL)); + + /* Enable PLL */ + reg_val = twl4030_read_reg_cache(codec, TWL4030_REG_APLL_CTL); + reg_val |= TWL4030_APLL_EN; + twl4030_write(codec, TWL4030_REG_APLL_CTL, reg_val); + } + + twl4030->codec_muted = mute; +} + static void twl4030_power_up(struct snd_soc_codec *codec) { + struct twl4030_priv *twl4030 = codec->private_data; u8 anamicl, regmisc1, byte; int i = 0; + if (twl4030->codec_powered) + return; + /* set CODECPDZ to turn on codec */ twl4030_codec_enable(codec, 1); @@ -220,6 +303,9 @@ static void twl4030_power_up(struct snd_soc_codec *codec) twl4030_codec_enable(codec, 1); } +/* + * Unconditional power down + */ static void twl4030_power_down(struct snd_soc_codec *codec) { /* power down */ @@ -402,6 +488,22 @@ static const struct soc_enum twl4030_micpathtx2_enum = static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum); +/* Analog bypass for AudioR1 */ +static const struct snd_kcontrol_new twl4030_dapm_abypassr1_control = + SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXR1_APGA_CTL, 2, 1, 0); + +/* Analog bypass for AudioL1 */ +static const struct snd_kcontrol_new twl4030_dapm_abypassl1_control = + SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL1_APGA_CTL, 2, 1, 0); + +/* Analog bypass for AudioR2 */ +static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control = + SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXR2_APGA_CTL, 2, 1, 0); + +/* Analog bypass for AudioL2 */ +static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = + SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0); + static int micpath_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -497,6 +599,31 @@ static int headsetl_event(struct snd_soc_dapm_widget *w, return 0; } +static int bypass_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct soc_mixer_control *m = + (struct soc_mixer_control *)w->kcontrols->private_value; + struct twl4030_priv *twl4030 = w->codec->private_data; + unsigned char reg; + + reg = twl4030_read_reg_cache(w->codec, m->reg); + if (reg & (1 << m->shift)) + twl4030->bypass_state |= + (1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); + else + twl4030->bypass_state &= + ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); + + if (w->codec->bias_level == SND_SOC_BIAS_STANDBY) { + if (twl4030->bypass_state) + twl4030_codec_mute(w->codec, 0); + else + twl4030_codec_mute(w->codec, 1); + } + return 0; +} + /* * Some of the gain controls in TWL (mostly those which are associated with * the outputs) are implemented in an interesting way: @@ -775,13 +902,13 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { /* DACs */ SND_SOC_DAPM_DAC("DAC Right1", "Right Front Playback", - TWL4030_REG_AVDAC_CTL, 0, 0), + SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_DAC("DAC Left1", "Left Front Playback", - TWL4030_REG_AVDAC_CTL, 1, 0), + SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_DAC("DAC Right2", "Right Rear Playback", - TWL4030_REG_AVDAC_CTL, 2, 0), + SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_DAC("DAC Left2", "Left Rear Playback", - TWL4030_REG_AVDAC_CTL, 3, 0), + SND_SOC_NOPM, 0, 0), /* Analog PGAs */ SND_SOC_DAPM_PGA("ARXR1_APGA", TWL4030_REG_ARXR1_APGA_CTL, @@ -793,6 +920,29 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { SND_SOC_DAPM_PGA("ARXL2_APGA", TWL4030_REG_ARXL2_APGA_CTL, 0, 0, NULL, 0), + /* Analog bypasses */ + SND_SOC_DAPM_SWITCH_E("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_abypassr1_control, bypass_event, + SND_SOC_DAPM_POST_REG), + SND_SOC_DAPM_SWITCH_E("Left1 Analog Loopback", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_abypassl1_control, + bypass_event, SND_SOC_DAPM_POST_REG), + SND_SOC_DAPM_SWITCH_E("Right2 Analog Loopback", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_abypassr2_control, + bypass_event, SND_SOC_DAPM_POST_REG), + SND_SOC_DAPM_SWITCH_E("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_abypassl2_control, + bypass_event, SND_SOC_DAPM_POST_REG), + + SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer", TWL4030_REG_AVDAC_CTL, + 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer", TWL4030_REG_AVDAC_CTL, + 1, 0, NULL, 0), + SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer", TWL4030_REG_AVDAC_CTL, + 2, 0, NULL, 0), + SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer", TWL4030_REG_AVDAC_CTL, + 3, 0, NULL, 0), + /* Output MUX controls */ /* Earpiece */ SND_SOC_DAPM_VALUE_MUX("Earpiece Mux", SND_SOC_NOPM, 0, 0, @@ -863,13 +1013,19 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0), SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0), SND_SOC_DAPM_MICBIAS("Headset Mic Bias", TWL4030_REG_MICBIAS_CTL, 2, 0), + }; static const struct snd_soc_dapm_route intercon[] = { - {"ARXL1_APGA", NULL, "DAC Left1"}, - {"ARXR1_APGA", NULL, "DAC Right1"}, - {"ARXL2_APGA", NULL, "DAC Left2"}, - {"ARXR2_APGA", NULL, "DAC Right2"}, + {"Analog L1 Playback Mixer", NULL, "DAC Left1"}, + {"Analog R1 Playback Mixer", NULL, "DAC Right1"}, + {"Analog L2 Playback Mixer", NULL, "DAC Left2"}, + {"Analog R2 Playback Mixer", NULL, "DAC Right2"}, + + {"ARXL1_APGA", NULL, "Analog L1 Playback Mixer"}, + {"ARXR1_APGA", NULL, "Analog R1 Playback Mixer"}, + {"ARXL2_APGA", NULL, "Analog L2 Playback Mixer"}, + {"ARXR2_APGA", NULL, "Analog R2 Playback Mixer"}, /* Internal playback routings */ /* Earpiece */ @@ -951,6 +1107,17 @@ static const struct snd_soc_dapm_route intercon[] = { {"ADC Virtual Left2", NULL, "TX2 Capture Route"}, {"ADC Virtual Right2", NULL, "TX2 Capture Route"}, + /* Analog bypass routes */ + {"Right1 Analog Loopback", "Switch", "Analog Right Capture Route"}, + {"Left1 Analog Loopback", "Switch", "Analog Left Capture Route"}, + {"Right2 Analog Loopback", "Switch", "Analog Right Capture Route"}, + {"Left2 Analog Loopback", "Switch", "Analog Left Capture Route"}, + + {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"}, + {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"}, + {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"}, + {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"}, + }; static int twl4030_add_widgets(struct snd_soc_codec *codec) @@ -967,16 +1134,25 @@ static int twl4030_add_widgets(struct snd_soc_codec *codec) static int twl4030_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { + struct twl4030_priv *twl4030 = codec->private_data; + switch (level) { case SND_SOC_BIAS_ON: - twl4030_power_up(codec); + twl4030_codec_mute(codec, 0); break; case SND_SOC_BIAS_PREPARE: - /* TODO: develop a twl4030_prepare function */ + twl4030_power_up(codec); + if (twl4030->bypass_state) + twl4030_codec_mute(codec, 0); + else + twl4030_codec_mute(codec, 1); break; case SND_SOC_BIAS_STANDBY: - /* TODO: develop a twl4030_standby function */ - twl4030_power_down(codec); + twl4030_power_up(codec); + if (twl4030->bypass_state) + twl4030_codec_mute(codec, 0); + else + twl4030_codec_mute(codec, 1); break; case SND_SOC_BIAS_OFF: twl4030_power_down(codec); @@ -996,7 +1172,6 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, struct snd_soc_codec *codec = socdev->card->codec; u8 mode, old_mode, format, old_format; - /* bit rate */ old_mode = twl4030_read_reg_cache(codec, TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; @@ -1038,6 +1213,7 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, if (mode != old_mode) { /* change rate and set CODECPDZ */ + twl4030_codec_enable(codec, 0); twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); twl4030_codec_enable(codec, 1); } @@ -1258,11 +1434,19 @@ static int twl4030_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; + struct twl4030_priv *twl4030; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; + twl4030 = kzalloc(sizeof(struct twl4030_priv), GFP_KERNEL); + if (twl4030 == NULL) { + kfree(codec); + return -ENOMEM; + } + + codec->private_data = twl4030; socdev->card->codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); @@ -1280,8 +1464,10 @@ static int twl4030_remove(struct platform_device *pdev) struct snd_soc_codec *codec = socdev->card->codec; printk(KERN_INFO "TWL4030 Audio Codec remove\n"); + twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); + kfree(codec->private_data); kfree(codec); return 0; diff --git a/sound/soc/codecs/twl4030.h b/sound/soc/codecs/twl4030.h index 442e5a82861..33dbb144dad 100644 --- a/sound/soc/codecs/twl4030.h +++ b/sound/soc/codecs/twl4030.h @@ -170,6 +170,9 @@ #define TWL4030_CLK256FS_EN 0x02 #define TWL4030_AIF_EN 0x01 +/* EAR_CTL (0x21) */ +#define TWL4030_EAR_GAIN 0x30 + /* HS_GAIN_SET (0x23) Fields */ #define TWL4030_HSR_GAIN 0x0C @@ -198,6 +201,18 @@ #define TWL4030_RAMP_DELAY_2581MS 0x1C #define TWL4030_RAMP_EN 0x02 +/* PREDL_CTL (0x25) */ +#define TWL4030_PREDL_GAIN 0x30 + +/* PREDR_CTL (0x26) */ +#define TWL4030_PREDR_GAIN 0x30 + +/* PRECKL_CTL (0x27) */ +#define TWL4030_PRECKL_GAIN 0x30 + +/* PRECKR_CTL (0x28) */ +#define TWL4030_PRECKR_GAIN 0x30 + /* HFL_CTL (0x29, 0x2A) Fields */ #define TWL4030_HF_CTL_HB_EN 0x04 #define TWL4030_HF_CTL_LOOP_EN 0x08 -- cgit v1.2.3 From 04eb093c7c81d118efeb96228f69bc0179f71897 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Thu, 29 Jan 2009 14:28:37 -0600 Subject: ASoC: fix initialization order of the CS4270 codec driver ASoC codec drivers typically serve two masters: the I2C bus and ASoC itself. When a codec driver registers with ASoC, a probe function is called. Most codec drivers call ASoC first, and then register with the I2C bus in the ASoC probe function. However, in order to support multiple codecs on one board, it's easier if the codec driver is probed via the I2C bus first. This is because the call to i2c_add_driver() can result in the I2C probe function being called multiple times - once for each codec. In the current design, the driver registers once with ASoC, and in the ASoC probe function, it calls i2c_add_driver(). The results in the I2C probe function being called multiple times before the driver can register with ASoC again. The new design has the driver call i2c_add_driver() first. In the I2C probe function, the driver registers with ASoC. This allows the ASoC probe function to be called once per I2C device. Also add code to check if the I2C probe function is called more than once, since that is not supported with the current ASoC design. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 177 +++++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 80 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 21253b48289..adc1150ddb0 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -490,21 +490,17 @@ static const struct snd_kcontrol_new cs4270_snd_controls[] = { }; /* - * Global variable to store socdev for i2c probe function. + * Global variable to store codec for the ASoC probe function. * * If struct i2c_driver had a private_data field, we wouldn't need to use - * cs4270_socdec. This is the only way to pass the socdev structure to - * cs4270_i2c_probe(). - * - * The real solution to cs4270_socdev is to create a mechanism - * that maps I2C addresses to snd_soc_device structures. Perhaps the - * creation of the snd_soc_device object should be moved out of - * cs4270_probe() and into cs4270_i2c_probe(), but that would make this - * driver dependent on I2C. The CS4270 supports "stand-alone" mode, whereby - * the chip is *not* connected to the I2C bus, but is instead configured via - * input pins. + * cs4270_codec. This is the only way to pass the codec structure from + * cs4270_i2c_probe() to cs4270_probe(). Unfortunately, there is no good + * way to synchronize these two functions. cs4270_i2c_probe() can be called + * multiple times before cs4270_probe() is called even once. So for now, we + * also only allow cs4270_i2c_probe() to be run once. That means that we do + * not support more than one cs4270 device in the system, at least for now. */ -static struct snd_soc_device *cs4270_socdev; +static struct snd_soc_codec *cs4270_codec; struct snd_soc_dai cs4270_dai = { .name = "cs4270", @@ -531,6 +527,70 @@ struct snd_soc_dai cs4270_dai = { }; EXPORT_SYMBOL_GPL(cs4270_dai); +/* + * ASoC probe function + */ +static int cs4270_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = cs4270_codec; + unsigned int i; + int ret; + + /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ + socdev->card->codec = codec; + + /* Register PCMs */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + printk(KERN_ERR "cs4270: failed to create PCMs\n"); + return ret; + } + + /* Add the non-DAPM controls */ + for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { + struct snd_kcontrol *kctrl; + + kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); + if (!kctrl) { + printk(KERN_ERR "cs4270: error creating control '%s'\n", + cs4270_snd_controls[i].name); + ret = -ENOMEM; + goto error_free_pcms; + } + + ret = snd_ctl_add(codec->card, kctrl); + if (ret < 0) { + printk(KERN_ERR "cs4270: error adding control '%s'\n", + cs4270_snd_controls[i].name); + goto error_free_pcms; + } + } + + /* And finally, register the socdev */ + ret = snd_soc_init_card(socdev); + if (ret < 0) { + printk(KERN_ERR "cs4270: failed to register card\n"); + goto error_free_pcms; + } + + return 0; + +error_free_pcms: + snd_soc_free_pcms(socdev); + + return ret; +} + +static int cs4270_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + + snd_soc_free_pcms(socdev); + + return 0; +}; + /* * Initialize the I2C interface of the CS4270 * @@ -543,17 +603,27 @@ EXPORT_SYMBOL_GPL(cs4270_dai); static int cs4270_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) { - struct snd_soc_device *socdev = cs4270_socdev; struct snd_soc_codec *codec; struct cs4270_private *cs4270; - int i; - int ret = 0; + int ret; + + /* For now, we only support one cs4270 device in the system. See the + * comment for cs4270_codec. + */ + if (cs4270_codec) { + printk(KERN_ERR "cs4270: ignoring CS4270 at addr %X\n", + i2c_client->addr); + printk(KERN_ERR "cs4270: only one CS4270 per board allowed\n"); + /* Should we return something other than ENODEV here? */ + return -ENODEV; + } /* Verify that we have a CS4270 */ ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to read I2C\n"); + printk(KERN_ERR "cs4270: failed to read I2C at addr %X\n", + i2c_client->addr); return ret; } /* The top four bits of the chip ID should be 1100. */ @@ -575,7 +645,7 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, return -ENOMEM; } codec = &cs4270->codec; - socdev->card->codec = codec; + cs4270_codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); @@ -600,50 +670,20 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, goto error_free_codec; } - /* Register PCMs */ - - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + /* Register the DAI. If all the other ASoC driver have already + * registered, then this will call our probe function, so + * cs4270_codec needs to be ready. + */ + ret = snd_soc_register_dai(&cs4270_dai); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to create PCMs\n"); + printk(KERN_ERR "cs4270: failed to register DAIe\n"); goto error_free_codec; } - /* Add the non-DAPM controls */ - - for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { - struct snd_kcontrol *kctrl; - - kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); - if (!kctrl) { - printk(KERN_ERR "cs4270: error creating control '%s'\n", - cs4270_snd_controls[i].name); - ret = -ENOMEM; - goto error_free_pcms; - } - - ret = snd_ctl_add(codec->card, kctrl); - if (ret < 0) { - printk(KERN_ERR "cs4270: error adding control '%s'\n", - cs4270_snd_controls[i].name); - goto error_free_pcms; - } - } - - /* Initialize the SOC device */ - - ret = snd_soc_init_card(socdev); - if (ret < 0) { - printk(KERN_ERR "cs4270: failed to register card\n"); - goto error_free_pcms;; - } - - i2c_set_clientdata(i2c_client, socdev); + i2c_set_clientdata(i2c_client, cs4270); return 0; -error_free_pcms: - snd_soc_free_pcms(socdev); - error_free_codec: kfree(cs4270); @@ -652,11 +692,8 @@ error_free_codec: static int cs4270_i2c_remove(struct i2c_client *i2c_client) { - struct snd_soc_device *socdev = i2c_get_clientdata(i2c_client); - struct snd_soc_codec *codec = socdev->card->codec; - struct cs4270_private *cs4270 = codec->private_data; + struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client); - snd_soc_free_pcms(socdev); kfree(cs4270); return 0; @@ -678,26 +715,6 @@ static struct i2c_driver cs4270_i2c_driver = { .remove = cs4270_i2c_remove, }; -/* - * ASoC probe function - * - * This function is called when the machine driver calls - * platform_device_add(). - */ -static int cs4270_probe(struct platform_device *pdev) -{ - cs4270_socdev = platform_get_drvdata(pdev);; - - return i2c_add_driver(&cs4270_i2c_driver); -} - -static int cs4270_remove(struct platform_device *pdev) -{ - i2c_del_driver(&cs4270_i2c_driver); - - return 0; -} - /* * ASoC codec device structure * @@ -714,13 +731,13 @@ static int __init cs4270_init(void) { printk(KERN_INFO "Cirrus Logic CS4270 ALSA SoC Codec Driver\n"); - return snd_soc_register_dai(&cs4270_dai); + return i2c_add_driver(&cs4270_i2c_driver); } module_init(cs4270_init); static void __exit cs4270_exit(void) { - snd_soc_unregister_dai(&cs4270_dai); + i2c_del_driver(&cs4270_i2c_driver); } module_exit(cs4270_exit); -- cgit v1.2.3 From ff7bf02f630ae93cad4feda0f6a5a19b25a5019a Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Fri, 30 Jan 2009 11:14:49 -0600 Subject: ASoC: fix documentation in CS4270 codec driver Spruce up the documentation in the CS4270 codec. Use kerneldoc where appropriate. Fix incorrect comments. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 163 +++++++++++++++++++++++++++++----------------- 1 file changed, 105 insertions(+), 58 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index adc1150ddb0..e5f5afdd342 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -3,10 +3,10 @@ * * Author: Timur Tabi * - * Copyright 2007 Freescale Semiconductor, Inc. This file is licensed under - * the terms of the GNU General Public License version 2. This program - * is licensed "as is" without any warranty of any kind, whether express - * or implied. + * Copyright 2007-2009 Freescale Semiconductor, Inc. This file is licensed + * under the terms of the GNU General Public License version 2. This + * program is licensed "as is" without any warranty of any kind, whether + * express or implied. * * This is an ASoC device driver for the Cirrus Logic CS4270 codec. * @@ -111,8 +111,13 @@ struct cs4270_private { unsigned int mode; /* The mode (I2S or left-justified) */ }; -/* - * Clock Ratio Selection for Master Mode with I2C enabled +/** + * struct cs4270_mode_ratios - clock ratio tables + * @ratio: the ratio of MCLK to the sample rate + * @speed_mode: the Speed Mode bits to set in the Mode Control register for + * this ratio + * @mclk: the Ratio Select bits to set in the Mode Control register for this + * ratio * * The data for this chart is taken from Table 5 of the CS4270 reference * manual. @@ -121,31 +126,30 @@ struct cs4270_private { * It is also used by cs4270_set_dai_sysclk() to tell ALSA which sampling * rates the CS4270 currently supports. * - * Each element in this array corresponds to the ratios in mclk_ratios[]. - * These two arrays need to be in sync. - * - * 'speed_mode' is the corresponding bit pattern to be written to the + * @speed_mode is the corresponding bit pattern to be written to the * MODE bits of the Mode Control Register * - * 'mclk' is the corresponding bit pattern to be wirten to the MCLK bits of + * @mclk is the corresponding bit pattern to be wirten to the MCLK bits of * the Mode Control Register. * * In situations where a single ratio is represented by multiple speed * modes, we favor the slowest speed. E.g, for a ratio of 128, we pick * double-speed instead of quad-speed. However, the CS4270 errata states - * that Divide-By-1.5 can cause failures, so we avoid that mode where + * that divide-By-1.5 can cause failures, so we avoid that mode where * possible. * - * ERRATA: There is an errata for the CS4270 where divide-by-1.5 does not - * work if VD = 3.3V. If this effects you, select the + * Errata: There is an errata for the CS4270 where divide-by-1.5 does not + * work if Vd is 3.3V. If this effects you, select the * CONFIG_SND_SOC_CS4270_VD33_ERRATA Kconfig option, and the driver will * never select any sample rates that require divide-by-1.5. */ -static struct { +struct cs4270_mode_ratios { unsigned int ratio; u8 speed_mode; u8 mclk; -} cs4270_mode_ratios[] = { +}; + +static struct cs4270_mode_ratios[] = { {64, CS4270_MODE_4X, CS4270_MODE_DIV1}, #ifndef CONFIG_SND_SOC_CS4270_VD33_ERRATA {96, CS4270_MODE_4X, CS4270_MODE_DIV15}, @@ -162,34 +166,27 @@ static struct { /* The number of MCLK/LRCK ratios supported by the CS4270 */ #define NUM_MCLK_RATIOS ARRAY_SIZE(cs4270_mode_ratios) -/* - * Determine the CS4270 samples rates. +/** + * cs4270_set_dai_sysclk - determine the CS4270 samples rates. + * @codec_dai: the codec DAI + * @clk_id: the clock ID (ignored) + * @freq: the MCLK input frequency + * @dir: the clock direction (ignored) * - * 'freq' is the input frequency to MCLK. The other parameters are ignored. + * This function is used to tell the codec driver what the input MCLK + * frequency is. * * The value of MCLK is used to determine which sample rates are supported * by the CS4270. The ratio of MCLK / Fs must be equal to one of nine - * support values: 64, 96, 128, 192, 256, 384, 512, 768, and 1024. + * supported values - 64, 96, 128, 192, 256, 384, 512, 768, and 1024. * * This function calculates the nine ratios and determines which ones match * a standard sample rate. If there's a match, then it is added to the list - * of support sample rates. + * of supported sample rates. * * This function must be called by the machine driver's 'startup' function, * otherwise the list of supported sample rates will not be available in * time for ALSA. - * - * Note that in stand-alone mode, the sample rate is determined by input - * pins M0, M1, MDIV1, and MDIV2. Also in stand-alone mode, divide-by-3 - * is not a programmable option. However, divide-by-3 is not an available - * option in stand-alone mode. This cases two problems: a ratio of 768 is - * not available (it requires divide-by-3) and B) ratios 192 and 384 can - * only be selected with divide-by-1.5, but there is an errate that make - * this selection difficult. - * - * In addition, there is no mechanism for communicating with the machine - * driver what the input settings can be. This would need to be implemented - * for stand-alone mode to work. */ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) @@ -230,8 +227,10 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } -/* - * Configure the codec for the selected audio format +/** + * cs4270_set_dai_fmt - configure the codec for the selected audio format + * @codec_dai: the codec DAI + * @format: a SND_SOC_DAIFMT_x value indicating the data format * * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the * codec accordingly. @@ -261,8 +260,16 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, return ret; } -/* - * Pre-fill the CS4270 register cache. +/** + * cs4270_fill_cache - pre-fill the CS4270 register cache. + * @codec: the codec for this CS4270 + * + * This function fills in the CS4270 register cache by reading the register + * values from the hardware. + * + * This CS4270 registers are cached to avoid excessive I2C I/O operations. + * After the initial read to pre-fill the cache, the CS4270 never updates + * the register values, so we won't have a cache coherency problem. * * We use the auto-increment feature of the CS4270 to read all registers in * one shot. @@ -285,12 +292,17 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec) return 0; } -/* - * Read from the CS4270 register cache. +/** + * cs4270_read_reg_cache - read from the CS4270 register cache. + * @codec: the codec for this CS4270 + * @reg: the register to read + * + * This function returns the value for a given register. It reads only from + * the register cache, not the hardware itself. * * This CS4270 registers are cached to avoid excessive I2C I/O operations. * After the initial read to pre-fill the cache, the CS4270 never updates - * the register values, so we won't have a cache coherncy problem. + * the register values, so we won't have a cache coherency problem. */ static unsigned int cs4270_read_reg_cache(struct snd_soc_codec *codec, unsigned int reg) @@ -303,8 +315,11 @@ static unsigned int cs4270_read_reg_cache(struct snd_soc_codec *codec, return cache[reg - CS4270_FIRSTREG]; } -/* - * Write to a CS4270 register via the I2C bus. +/** + * cs4270_i2c_write - write to a CS4270 register via the I2C bus. + * @codec: the codec for this CS4270 + * @reg: the register to write + * @value: the value to write to the register * * This function writes the given value to the given CS4270 register, and * also updates the register cache. @@ -336,11 +351,17 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, return 0; } -/* - * Program the CS4270 with the given hardware parameters. +/** + * cs4270_hw_params - program the CS4270 with the given hardware parameters. + * @substream: the audio stream + * @params: the hardware parameters to set + * @dai: the SOC DAI (ignored) * - * The .ops functions are used to provide board-specific data, like - * input frequencies, to this driver. This function takes that information, + * This function programs the hardware with the values provided. + * Specifically, the sample rate and the data format. + * + * The .ops functions are used to provide board-specific data, like input + * frequencies, to this driver. This function takes that information, * combines it with the hardware parameters provided, and programs the * hardware accordingly. */ @@ -455,8 +476,10 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, } #ifdef CONFIG_SND_SOC_CS4270_HWMUTE -/* - * Set the CS4270 external mute +/** + * cs4270_mute - enable/disable the CS4270 external mute + * @dai: the SOC DAI + * @mute: 0 = disable mute, 1 = enable mute * * This function toggles the mute bits in the MUTE register. The CS4270's * mute capability is intended for external muting circuitry, so if the @@ -490,7 +513,7 @@ static const struct snd_kcontrol_new cs4270_snd_controls[] = { }; /* - * Global variable to store codec for the ASoC probe function. + * cs4270_codec - global variable to store codec for the ASoC probe function * * If struct i2c_driver had a private_data field, we wouldn't need to use * cs4270_codec. This is the only way to pass the codec structure from @@ -527,8 +550,12 @@ struct snd_soc_dai cs4270_dai = { }; EXPORT_SYMBOL_GPL(cs4270_dai); -/* - * ASoC probe function +/** + * cs4270_probe - ASoC probe function + * @pdev: platform device + * + * This function is called when ASoC has all the pieces it needs to + * instantiate a sound driver. */ static int cs4270_probe(struct platform_device *pdev) { @@ -582,6 +609,12 @@ error_free_pcms: return ret; } +/** + * cs4270_remove - ASoC remove function + * @pdev: platform device + * + * This function is the counterpart to cs4270_probe(). + */ static int cs4270_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); @@ -591,14 +624,13 @@ static int cs4270_remove(struct platform_device *pdev) return 0; }; -/* - * Initialize the I2C interface of the CS4270 - * - * This function is called for whenever the I2C subsystem finds a device - * at a particular address. +/** + * cs4270_i2c_probe - initialize the I2C interface of the CS4270 + * @i2c_client: the I2C client object + * @id: the I2C device ID (ignored) * - * Note: snd_soc_new_pcms() must be called before this function can be called, - * because of snd_ctl_add(). + * This function is called whenever the I2C subsystem finds a device that + * matches the device ID given via a prior call to i2c_add_driver(). */ static int cs4270_i2c_probe(struct i2c_client *i2c_client, const struct i2c_device_id *id) @@ -690,6 +722,12 @@ error_free_codec: return ret; } +/** + * cs4270_i2c_remove - remove an I2C device + * @i2c_client: the I2C client object + * + * This function is the counterpart to cs4270_i2c_probe(). + */ static int cs4270_i2c_remove(struct i2c_client *i2c_client) { struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client); @@ -699,12 +737,21 @@ static int cs4270_i2c_remove(struct i2c_client *i2c_client) return 0; } +/* + * cs4270_id - I2C device IDs supported by this driver + */ static struct i2c_device_id cs4270_id[] = { {"cs4270", 0}, {} }; MODULE_DEVICE_TABLE(i2c, cs4270_id); +/* + * cs4270_i2c_driver - I2C device identification + * + * This structure tells the I2C subsystem how to identify and support a + * given I2C device type. + */ static struct i2c_driver cs4270_i2c_driver = { .driver = { .name = "cs4270", -- cgit v1.2.3 From 8f008062943c8565e855dda8a6681f641d7e71f9 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sat, 31 Jan 2009 16:29:24 +0200 Subject: ASoC: Update OMAP3 pandora board file Update pandora board file for recent TWL4030 codec changes. Also move output related snd_soc_dapm_nc_pin() calls to omap3pandora_out_init(), where they belong. Signed-off-by: Grazvydas Ignotas Signed-off-by: Mark Brown --- sound/soc/omap/omap3pandora.c | 49 +++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index fcc2f5d9a87..fe282d4ef42 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -143,7 +143,7 @@ static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { }; static const struct snd_soc_dapm_widget omap3pandora_in_dapm_widgets[] = { - SND_SOC_DAPM_MIC("Mic (Internal)", NULL), + SND_SOC_DAPM_MIC("Mic (internal)", NULL), SND_SOC_DAPM_MIC("Mic (external)", NULL), SND_SOC_DAPM_LINE("Line In", NULL), }; @@ -155,16 +155,33 @@ static const struct snd_soc_dapm_route omap3pandora_out_map[] = { }; static const struct snd_soc_dapm_route omap3pandora_in_map[] = { - {"INL", NULL, "Line In"}, - {"INR", NULL, "Line In"}, - {"INL", NULL, "Mic (Internal)"}, - {"INR", NULL, "Mic (external)"}, + {"AUXL", NULL, "Line In"}, + {"AUXR", NULL, "Line In"}, + + {"MAINMIC", NULL, "Mic Bias 1"}, + {"Mic Bias 1", NULL, "Mic (internal)"}, + + {"SUBMIC", NULL, "Mic Bias 2"}, + {"Mic Bias 2", NULL, "Mic (external)"}, }; static int omap3pandora_out_init(struct snd_soc_codec *codec) { int ret; + /* All TWL4030 output pins are floating */ + snd_soc_dapm_nc_pin(codec, "OUTL"); + snd_soc_dapm_nc_pin(codec, "OUTR"); + snd_soc_dapm_nc_pin(codec, "EARPIECE"); + snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); + snd_soc_dapm_nc_pin(codec, "PREDRIVER"); + snd_soc_dapm_nc_pin(codec, "HSOL"); + snd_soc_dapm_nc_pin(codec, "HSOR"); + snd_soc_dapm_nc_pin(codec, "CARKITL"); + snd_soc_dapm_nc_pin(codec, "CARKITR"); + snd_soc_dapm_nc_pin(codec, "HFL"); + snd_soc_dapm_nc_pin(codec, "HFR"); + ret = snd_soc_dapm_new_controls(codec, omap3pandora_out_dapm_widgets, ARRAY_SIZE(omap3pandora_out_dapm_widgets)); if (ret < 0) @@ -180,18 +197,11 @@ static int omap3pandora_in_init(struct snd_soc_codec *codec) { int ret; - /* All TWL4030 output pins are floating */ - snd_soc_dapm_nc_pin(codec, "OUTL"), - snd_soc_dapm_nc_pin(codec, "OUTR"), - snd_soc_dapm_nc_pin(codec, "EARPIECE"), - snd_soc_dapm_nc_pin(codec, "PREDRIVEL"), - snd_soc_dapm_nc_pin(codec, "PREDRIVER"), - snd_soc_dapm_nc_pin(codec, "HSOL"), - snd_soc_dapm_nc_pin(codec, "HSOR"), - snd_soc_dapm_nc_pin(codec, "CARKITL"), - snd_soc_dapm_nc_pin(codec, "CARKITR"), - snd_soc_dapm_nc_pin(codec, "HFL"), - snd_soc_dapm_nc_pin(codec, "HFR"), + /* Not comnnected */ + snd_soc_dapm_nc_pin(codec, "HSMIC"); + snd_soc_dapm_nc_pin(codec, "CARKITMIC"); + snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); + snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); ret = snd_soc_dapm_new_controls(codec, omap3pandora_in_dapm_widgets, ARRAY_SIZE(omap3pandora_in_dapm_widgets)); @@ -251,10 +261,9 @@ static int __init omap3pandora_soc_init(void) { int ret; - if (!machine_is_omap3_pandora()) { - pr_debug(PREFIX "Not OMAP3 Pandora\n"); + if (!machine_is_omap3_pandora()) return -ENODEV; - } + pr_info("OMAP3 Pandora SoC init\n"); ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power"); -- cgit v1.2.3 From d9fb7fbddc9a14569aad517984c1a5b0b07002ea Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Mon, 2 Feb 2009 14:50:45 -0600 Subject: ASoC: fix build break in CS4270 codec driver Fix a oversight in the CS4270 codec driver that caused a build break. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index e5f5afdd342..7962874258f 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -149,7 +149,7 @@ struct cs4270_mode_ratios { u8 mclk; }; -static struct cs4270_mode_ratios[] = { +static struct cs4270_mode_ratios cs4270_mode_ratios[] = { {64, CS4270_MODE_4X, CS4270_MODE_DIV1}, #ifndef CONFIG_SND_SOC_CS4270_VD33_ERRATA {96, CS4270_MODE_4X, CS4270_MODE_DIV15}, -- cgit v1.2.3 From a6c255e0945160b76eabe983f59e2129e0c66246 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Mon, 2 Feb 2009 15:08:29 -0600 Subject: ASoC: fix message display in CS4270 codec driver Replace printk calls with dev_xxx calls. Set the 'dev' field of the codec and codec_dai structures so that these calls work. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 66 ++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 7962874258f..2c79a24186f 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -212,7 +212,7 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, rates &= ~SNDRV_PCM_RATE_KNOT; if (!rates) { - printk(KERN_ERR "cs4270: could not find a valid sample rate\n"); + dev_err(codec->dev, "could not find a valid sample rate\n"); return -EINVAL; } @@ -253,7 +253,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK; break; default: - printk(KERN_ERR "cs4270: invalid DAI format\n"); + dev_err(codec->dev, "invalid dai format\n"); ret = -EINVAL; } @@ -284,7 +284,7 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec) CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache); if (length != CS4270_NUMREGS) { - printk(KERN_ERR "cs4270: I2C read failure, addr=0x%x\n", + dev_err(codec->dev, "i2c read failure, addr=0x%x\n", i2c_client->addr); return -EIO; } @@ -340,7 +340,7 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg, if (cache[reg - CS4270_FIRSTREG] != value) { struct i2c_client *client = codec->control_data; if (i2c_smbus_write_byte_data(client, reg, value)) { - printk(KERN_ERR "cs4270: I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return -EIO; } @@ -391,7 +391,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, if (i == NUM_MCLK_RATIOS) { /* We did not find a matching ratio */ - printk(KERN_ERR "cs4270: could not find matching ratio\n"); + dev_err(codec->dev, "could not find matching ratio\n"); return -EINVAL; } @@ -401,7 +401,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | CS4270_PWRCTL_PDN); if (ret < 0) { - printk(KERN_ERR "cs4270: I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return ret; } @@ -413,7 +413,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_write(codec, CS4270_MODE, reg); if (ret < 0) { - printk(KERN_ERR "cs4270: I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return ret; } @@ -430,13 +430,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ; break; default: - printk(KERN_ERR "cs4270: unknown format\n"); + dev_err(codec->dev, "unknown dai format\n"); return -EINVAL; } ret = snd_soc_write(codec, CS4270_FORMAT, reg); if (ret < 0) { - printk(KERN_ERR "cs4270: I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return ret; } @@ -447,7 +447,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, reg &= ~CS4270_MUTE_AUTO; ret = snd_soc_write(codec, CS4270_MUTE, reg); if (ret < 0) { - printk(KERN_ERR "cs4270: I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return ret; } @@ -460,7 +460,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO); ret = cs4270_i2c_write(codec, CS4270_TRANS, reg); if (ret < 0) { - printk(KERN_ERR "I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return ret; } @@ -468,7 +468,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_write(codec, CS4270_PWRCTL, 0); if (ret < 0) { - printk(KERN_ERR "cs4270: I2C write failed\n"); + dev_err(codec->dev, "i2c write failed\n"); return ret; } @@ -570,7 +570,7 @@ static int cs4270_probe(struct platform_device *pdev) /* Register PCMs */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to create PCMs\n"); + dev_err(codec->dev, "failed to create pcms\n"); return ret; } @@ -580,7 +580,7 @@ static int cs4270_probe(struct platform_device *pdev) kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); if (!kctrl) { - printk(KERN_ERR "cs4270: error creating control '%s'\n", + dev_err(codec->dev, "error creating control '%s'\n", cs4270_snd_controls[i].name); ret = -ENOMEM; goto error_free_pcms; @@ -588,7 +588,7 @@ static int cs4270_probe(struct platform_device *pdev) ret = snd_ctl_add(codec->card, kctrl); if (ret < 0) { - printk(KERN_ERR "cs4270: error adding control '%s'\n", + dev_err(codec->dev, "error adding control '%s'\n", cs4270_snd_controls[i].name); goto error_free_pcms; } @@ -597,7 +597,7 @@ static int cs4270_probe(struct platform_device *pdev) /* And finally, register the socdev */ ret = snd_soc_init_card(socdev); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to register card\n"); + dev_err(codec->dev, "failed to register card\n"); goto error_free_pcms; } @@ -643,9 +643,9 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, * comment for cs4270_codec. */ if (cs4270_codec) { - printk(KERN_ERR "cs4270: ignoring CS4270 at addr %X\n", + dev_err(&i2c_client->dev, "ignoring CS4270 at addr %X\n", i2c_client->addr); - printk(KERN_ERR "cs4270: only one CS4270 per board allowed\n"); + dev_err(&i2c_client->dev, "only one per board allowed\n"); /* Should we return something other than ENODEV here? */ return -ENODEV; } @@ -654,35 +654,35 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to read I2C at addr %X\n", + dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n", i2c_client->addr); return ret; } /* The top four bits of the chip ID should be 1100. */ if ((ret & 0xF0) != 0xC0) { - printk(KERN_ERR "cs4270: device at addr %X is not a CS4270\n", + dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n", i2c_client->addr); return -ENODEV; } - printk(KERN_INFO "cs4270: found device at I2C address %X\n", + dev_info(&i2c_client->dev, "found device at i2c address %X\n", i2c_client->addr); - printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF); + dev_info(&i2c_client->dev, "hardware revision %X\n", ret & 0xF); /* Allocate enough space for the snd_soc_codec structure and our private data together. */ cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL); if (!cs4270) { - printk(KERN_ERR "cs4270: Could not allocate codec structure\n"); + dev_err(&i2c_client->dev, "could not allocate codec\n"); return -ENOMEM; } codec = &cs4270->codec; - cs4270_codec = codec; mutex_init(&codec->mutex); INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); + codec->dev = &i2c_client->dev; codec->name = "CS4270"; codec->owner = THIS_MODULE; codec->dai = &cs4270_dai; @@ -698,17 +698,25 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, ret = cs4270_fill_cache(codec); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to fill register cache\n"); + dev_err(&i2c_client->dev, "failed to fill register cache\n"); goto error_free_codec; } + /* Initialize the DAI. Normally, we'd prefer to have a kmalloc'd DAI + * structure for each CS4270 device, but the machine driver needs to + * have a pointer to the DAI structure, so for now it must be a global + * variable. + */ + cs4270_dai.dev = &i2c_client->dev; + /* Register the DAI. If all the other ASoC driver have already * registered, then this will call our probe function, so * cs4270_codec needs to be ready. */ + cs4270_codec = codec; ret = snd_soc_register_dai(&cs4270_dai); if (ret < 0) { - printk(KERN_ERR "cs4270: failed to register DAIe\n"); + dev_err(&i2c_client->dev, "failed to register DAIe\n"); goto error_free_codec; } @@ -718,6 +726,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, error_free_codec: kfree(cs4270); + cs4270_codec = NULL; + cs4270_dai.dev = NULL; return ret; } @@ -733,6 +743,8 @@ static int cs4270_i2c_remove(struct i2c_client *i2c_client) struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client); kfree(cs4270); + cs4270_codec = NULL; + cs4270_dai.dev = NULL; return 0; } @@ -776,7 +788,7 @@ EXPORT_SYMBOL_GPL(soc_codec_device_cs4270); static int __init cs4270_init(void) { - printk(KERN_INFO "Cirrus Logic CS4270 ALSA SoC Codec Driver\n"); + pr_info("Cirrus Logic CS4270 ALSA SoC Codec Driver\n"); return i2c_add_driver(&cs4270_i2c_driver); } -- cgit v1.2.3 From 111f6fbeb73fc350fe3a08c4ecd0ccdf3e13bef0 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Tue, 3 Feb 2009 15:52:56 +0200 Subject: ASoC: Don't unconditionally use the PLL in UDA1380 Without this fix driver switches to WSPLL in uda1380_pcm_prepare even if SYSCLK was chosen (uda1380_pcm_prepare modifies UDA1380_CLK register to disable R00_DAC_CLK before flushing reg cache) Signed-off-by: Vasily Khoruzhick Signed-off-by: Mark Brown --- sound/soc/codecs/uda1380.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 98e4a6560f0..6e4a1770ce8 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -418,8 +418,8 @@ static int uda1380_pcm_prepare(struct snd_pcm_substream *substream, uda1380_write(codec, reg, uda1380_read_reg_cache(codec, reg)); } - /* FIXME enable DAC_CLK */ - uda1380_write(codec, UDA1380_CLK, clk | R00_DAC_CLK); + /* FIXME restore DAC_CLK */ + uda1380_write(codec, UDA1380_CLK, clk); return 0; } -- cgit v1.2.3 From 5b2474425ed2a625b75dcd8d648701e473b7d764 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 3 Feb 2009 17:19:40 +0100 Subject: ASoC: uda1380: split set_dai_fmt into _both, _playback and _capture variants This patch splits set_dai_fmt into three variants (single interface, dual interface playback only, dual interface capture only) so that data input and output formats can be configured separately for dual interface setups. Signed-off-by: Philipp Zabel Tested-by: Vasily Khoruzhick Signed-off-by: Mark Brown --- sound/soc/codecs/uda1380.c | 68 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 7 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 6e4a1770ce8..5242b8156b3 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -356,7 +356,7 @@ static int uda1380_add_widgets(struct snd_soc_codec *codec) return 0; } -static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai, +static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, unsigned int fmt) { struct snd_soc_codec *codec = codec_dai->codec; @@ -366,16 +366,70 @@ static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai, iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK); - /* FIXME: how to select I2S for DATAO and MSB for DATAI correctly? */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: iface |= R01_SFORI_I2S | R01_SFORO_I2S; break; case SND_SOC_DAIFMT_LSB: - iface |= R01_SFORI_LSB16 | R01_SFORO_I2S; + iface |= R01_SFORI_LSB16 | R01_SFORO_LSB16; break; case SND_SOC_DAIFMT_MSB: - iface |= R01_SFORI_MSB | R01_SFORO_I2S; + iface |= R01_SFORI_MSB | R01_SFORO_MSB; + } + + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) + iface |= R01_SIM; + + uda1380_write(codec, UDA1380_IFACE, iface); + + return 0; +} + +static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + int iface; + + /* set up DAI based upon fmt */ + iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); + iface &= ~R01_SFORI_MASK; + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + iface |= R01_SFORI_I2S; + break; + case SND_SOC_DAIFMT_LSB: + iface |= R01_SFORI_LSB16; + break; + case SND_SOC_DAIFMT_MSB: + iface |= R01_SFORI_MSB; + } + + uda1380_write(codec, UDA1380_IFACE, iface); + + return 0; +} + +static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + int iface; + + /* set up DAI based upon fmt */ + iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); + iface &= ~(R01_SIM | R01_SFORO_MASK); + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + iface |= R01_SFORO_I2S; + break; + case SND_SOC_DAIFMT_LSB: + iface |= R01_SFORO_LSB16; + break; + case SND_SOC_DAIFMT_MSB: + iface |= R01_SFORO_MSB; } if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) @@ -549,7 +603,7 @@ struct snd_soc_dai uda1380_dai[] = { .shutdown = uda1380_pcm_shutdown, .prepare = uda1380_pcm_prepare, .digital_mute = uda1380_mute, - .set_fmt = uda1380_set_dai_fmt, + .set_fmt = uda1380_set_dai_fmt_both, }, }, { /* playback only - dual interface */ @@ -566,7 +620,7 @@ struct snd_soc_dai uda1380_dai[] = { .shutdown = uda1380_pcm_shutdown, .prepare = uda1380_pcm_prepare, .digital_mute = uda1380_mute, - .set_fmt = uda1380_set_dai_fmt, + .set_fmt = uda1380_set_dai_fmt_playback, }, }, { /* capture only - dual interface*/ @@ -582,7 +636,7 @@ struct snd_soc_dai uda1380_dai[] = { .hw_params = uda1380_pcm_hw_params, .shutdown = uda1380_pcm_shutdown, .prepare = uda1380_pcm_prepare, - .set_fmt = uda1380_set_dai_fmt, + .set_fmt = uda1380_set_dai_fmt_capture, }, }, }; -- cgit v1.2.3 From 0664678a84c653bde844c7d91646259a25c6188b Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 3 Feb 2009 21:18:26 +0100 Subject: ASoC: pxa-ssp: fix SSP port request PXA2xx/3xx SSP ports start from 1, not 0. Thus, the probe function requested the wrong SSP port. Correcting this unveiled another bug where ssp_init tries to request the already-requested SSP port again. So this patch replaces the ssp_init/exit calls with their internals from mach-pxa/ssp.c, leaving out the redundant ssp_request and the unneeded IRQ request. Effectively, that leaves us with not much more than enabling/disabling the SSP clock. Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 73cb6b4c2f2..4a973ab710b 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -21,6 +21,8 @@ #include #include +#include + #include #include #include @@ -221,9 +223,9 @@ static int pxa_ssp_startup(struct snd_pcm_substream *substream, int ret = 0; if (!cpu_dai->active) { - ret = ssp_init(&priv->dev, cpu_dai->id + 1, SSP_NO_IRQ); - if (ret < 0) - return ret; + priv->dev.port = cpu_dai->id + 1; + priv->dev.irq = NO_IRQ; + clk_enable(priv->dev.ssp->clk); ssp_disable(&priv->dev); } return ret; @@ -238,7 +240,7 @@ static void pxa_ssp_shutdown(struct snd_pcm_substream *substream, if (!cpu_dai->active) { ssp_disable(&priv->dev); - ssp_exit(&priv->dev); + clk_disable(priv->dev.ssp->clk); } } @@ -751,7 +753,7 @@ static int pxa_ssp_probe(struct platform_device *pdev, if (!priv) return -ENOMEM; - priv->dev.ssp = ssp_request(dai->id, "SoC audio"); + priv->dev.ssp = ssp_request(dai->id + 1, "SoC audio"); if (priv->dev.ssp == NULL) { ret = -ENODEV; goto err_priv; -- cgit v1.2.3 From 92a950ff2b7091a735c32a6e57b8136650bc7812 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 6 Feb 2009 18:12:34 +0800 Subject: ASoC: Blackfin: cleanup sport handling in ASoC Blackfin AC97 code - make sport number handling more dynamic as not all Blackfins have a linear sport map starting at 0 - indexes can be macroed away too Signed-off-by: Mike Frysinger Signed-off-by: Cliff Cai Signed-off-by: Bryan Wu Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-ac97.c | 92 +++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 59 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/blackfin/bf5xx-ac97.c b/sound/soc/blackfin/bf5xx-ac97.c index 3be2be60576..5885702c78f 100644 --- a/sound/soc/blackfin/bf5xx-ac97.c +++ b/sound/soc/blackfin/bf5xx-ac97.c @@ -31,72 +31,46 @@ #include "bf5xx-sport.h" #include "bf5xx-ac97.h" -#if defined(CONFIG_BF54x) -#define PIN_REQ_SPORT_0 {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, \ - P_SPORT0_RFS, P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0} - -#define PIN_REQ_SPORT_1 {P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, \ - P_SPORT1_RFS, P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0} - -#define PIN_REQ_SPORT_2 {P_SPORT2_TFS, P_SPORT2_DTPRI, P_SPORT2_TSCLK, \ - P_SPORT2_RFS, P_SPORT2_DRPRI, P_SPORT2_RSCLK, 0} - -#define PIN_REQ_SPORT_3 {P_SPORT3_TFS, P_SPORT3_DTPRI, P_SPORT3_TSCLK, \ - P_SPORT3_RFS, P_SPORT3_DRPRI, P_SPORT3_RSCLK, 0} -#else -#define PIN_REQ_SPORT_0 {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, \ - P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0} - -#define PIN_REQ_SPORT_1 {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, \ - P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0} -#endif - static int *cmd_count; static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; +#define SPORT_REQ(x) \ + [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \ + P_SPORT##x##_RFS, P_SPORT##x##_DRPRI, P_SPORT##x##_RSCLK, 0} static u16 sport_req[][7] = { - PIN_REQ_SPORT_0, -#ifdef PIN_REQ_SPORT_1 - PIN_REQ_SPORT_1, +#ifdef SPORT0_TCR1 + SPORT_REQ(0), #endif -#ifdef PIN_REQ_SPORT_2 - PIN_REQ_SPORT_2, +#ifdef SPORT1_TCR1 + SPORT_REQ(1), #endif -#ifdef PIN_REQ_SPORT_3 - PIN_REQ_SPORT_3, +#ifdef SPORT2_TCR1 + SPORT_REQ(2), #endif - }; +#ifdef SPORT3_TCR1 + SPORT_REQ(3), +#endif +}; +#define SPORT_PARAMS(x) \ + [x] = { \ + .dma_rx_chan = CH_SPORT##x##_RX, \ + .dma_tx_chan = CH_SPORT##x##_TX, \ + .err_irq = IRQ_SPORT##x##_ERROR, \ + .regs = (struct sport_register *)SPORT##x##_TCR1, \ + } static struct sport_param sport_params[4] = { - { - .dma_rx_chan = CH_SPORT0_RX, - .dma_tx_chan = CH_SPORT0_TX, - .err_irq = IRQ_SPORT0_ERROR, - .regs = (struct sport_register *)SPORT0_TCR1, - }, -#ifdef PIN_REQ_SPORT_1 - { - .dma_rx_chan = CH_SPORT1_RX, - .dma_tx_chan = CH_SPORT1_TX, - .err_irq = IRQ_SPORT1_ERROR, - .regs = (struct sport_register *)SPORT1_TCR1, - }, +#ifdef SPORT0_TCR1 + SPORT_PARAMS(0), #endif -#ifdef PIN_REQ_SPORT_2 - { - .dma_rx_chan = CH_SPORT2_RX, - .dma_tx_chan = CH_SPORT2_TX, - .err_irq = IRQ_SPORT2_ERROR, - .regs = (struct sport_register *)SPORT2_TCR1, - }, +#ifdef SPORT1_TCR1 + SPORT_PARAMS(1), #endif -#ifdef PIN_REQ_SPORT_3 - { - .dma_rx_chan = CH_SPORT3_RX, - .dma_tx_chan = CH_SPORT3_TX, - .err_irq = IRQ_SPORT3_ERROR, - .regs = (struct sport_register *)SPORT3_TCR1, - } +#ifdef SPORT2_TCR1 + SPORT_PARAMS(2), +#endif +#ifdef SPORT3_TCR1 + SPORT_PARAMS(3), #endif }; @@ -332,11 +306,11 @@ static int bf5xx_ac97_probe(struct platform_device *pdev, if (cmd_count == NULL) return -ENOMEM; - if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { + if (peripheral_request_list(sport_req[sport_num], "soc-audio")) { pr_err("Requesting Peripherals failed\n"); ret = -EFAULT; goto peripheral_err; - } + } #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ @@ -385,7 +359,7 @@ sport_err: gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); #endif gpio_err: - peripheral_free_list(&sport_req[sport_num][0]); + peripheral_free_list(sport_req[sport_num]); peripheral_err: free_page((unsigned long)cmd_count); cmd_count = NULL; @@ -398,7 +372,7 @@ static void bf5xx_ac97_remove(struct platform_device *pdev, { free_page((unsigned long)cmd_count); cmd_count = NULL; - peripheral_free_list(&sport_req[sport_num][0]); + peripheral_free_list(sport_req[sport_num]); #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); #endif -- cgit v1.2.3 From 8836c273e4d44d088157b7ccbd2c108cefe70565 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 6 Feb 2009 18:12:35 +0800 Subject: ASoC: Blackfin: drop unnecessary dma casts Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-sport.c | 104 ++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 61 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c index 3b99e484d55..b7953c8cf83 100644 --- a/sound/soc/blackfin/bf5xx-sport.c +++ b/sound/soc/blackfin/bf5xx-sport.c @@ -133,7 +133,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, int i; for (i = 0; i < fragcount; ++i) { - desc[i].next_desc_addr = (unsigned long)&(desc[i + 1]); + desc[i].next_desc_addr = &(desc[i + 1]); desc[i].start_addr = (unsigned long)buf + i*fragsize; desc[i].cfg = cfg; desc[i].x_count = x_count; @@ -143,12 +143,12 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, } /* make circular */ - desc[fragcount-1].next_desc_addr = (unsigned long)desc; + desc[fragcount-1].next_desc_addr = desc; - pr_debug("setup desc: desc0=%p, next0=%lx, desc1=%p," - "next1=%lx\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", - &(desc[0]), desc[0].next_desc_addr, - &(desc[1]), desc[1].next_desc_addr, + pr_debug("setup desc: desc0=%p, next0=%p, desc1=%p," + "next1=%p\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", + desc, desc[0].next_desc_addr, + desc+1, desc[1].next_desc_addr, desc[0].x_count, desc[0].y_count, desc[0].start_addr, desc[0].cfg); } @@ -184,22 +184,20 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); /* Maybe the dummy buffer descriptor ring is damaged */ - sport->dummy_rx_desc->next_desc_addr = \ - (unsigned long)(sport->dummy_rx_desc+1); + sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; local_irq_save(flags); - desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_rx_chan); + desc = get_dma_next_desc_ptr(sport->dma_rx_chan); /* Copy the descriptor which will be damaged to backup */ temp_desc = *desc; desc->x_count = 0xa; desc->y_count = 0; - desc->next_desc_addr = (unsigned long)(sport->dummy_rx_desc); + desc->next_desc_addr = sport->dummy_rx_desc; local_irq_restore(flags); /* Waiting for dummy buffer descriptor is already hooked*/ while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - - sizeof(struct dmasg)) != - (unsigned long)sport->dummy_rx_desc) - ; + sizeof(struct dmasg)) != sport->dummy_rx_desc) + continue; sport->curr_rx_desc = sport->dummy_rx_desc; /* Restore the damaged descriptor */ *desc = temp_desc; @@ -210,14 +208,12 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) { if (dummy) { - sport->dummy_rx_desc->next_desc_addr = \ - (unsigned long) sport->dummy_rx_desc; + sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc; sport->curr_rx_desc = sport->dummy_rx_desc; } else sport->curr_rx_desc = sport->dma_rx_desc; - set_dma_next_desc_addr(sport->dma_rx_chan, \ - (unsigned long)(sport->curr_rx_desc)); + set_dma_next_desc_addr(sport->dma_rx_chan, sport->curr_rx_desc); set_dma_x_count(sport->dma_rx_chan, 0); set_dma_x_modify(sport->dma_rx_chan, 0); set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ @@ -231,14 +227,12 @@ static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) { if (dummy) { - sport->dummy_tx_desc->next_desc_addr = \ - (unsigned long) sport->dummy_tx_desc; + sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc; sport->curr_tx_desc = sport->dummy_tx_desc; } else sport->curr_tx_desc = sport->dma_tx_desc; - set_dma_next_desc_addr(sport->dma_tx_chan, \ - (unsigned long)(sport->curr_tx_desc)); + set_dma_next_desc_addr(sport->dma_tx_chan, sport->curr_tx_desc); set_dma_x_count(sport->dma_tx_chan, 0); set_dma_x_modify(sport->dma_tx_chan, 0); set_dma_config(sport->dma_tx_chan, @@ -261,11 +255,9 @@ int sport_rx_start(struct sport_device *sport) BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); local_irq_save(flags); while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - - sizeof(struct dmasg)) != - (unsigned long)sport->dummy_rx_desc) - ; - sport->dummy_rx_desc->next_desc_addr = - (unsigned long)(sport->dma_rx_desc); + sizeof(struct dmasg)) != sport->dummy_rx_desc) + continue; + sport->dummy_rx_desc->next_desc_addr = sport->dma_rx_desc; local_irq_restore(flags); sport->curr_rx_desc = sport->dma_rx_desc; } else { @@ -310,23 +302,21 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) BUG_ON(sport->dummy_tx_desc == NULL); BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); - sport->dummy_tx_desc->next_desc_addr = \ - (unsigned long)(sport->dummy_tx_desc+1); + sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; /* Shorten the time on last normal descriptor */ local_irq_save(flags); - desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_tx_chan); + desc = get_dma_next_desc_ptr(sport->dma_tx_chan); /* Store the descriptor which will be damaged */ temp_desc = *desc; desc->x_count = 0xa; desc->y_count = 0; - desc->next_desc_addr = (unsigned long)(sport->dummy_tx_desc); + desc->next_desc_addr = sport->dummy_tx_desc; local_irq_restore(flags); /* Waiting for dummy buffer descriptor is already hooked*/ while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ - sizeof(struct dmasg)) != \ - (unsigned long)sport->dummy_tx_desc) - ; + sizeof(struct dmasg)) != sport->dummy_tx_desc) + continue; sport->curr_tx_desc = sport->dummy_tx_desc; /* Restore the damaged descriptor */ *desc = temp_desc; @@ -347,11 +337,9 @@ int sport_tx_start(struct sport_device *sport) /* Hook the normal buffer descriptor */ local_irq_save(flags); while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - - sizeof(struct dmasg)) != - (unsigned long)sport->dummy_tx_desc) - ; - sport->dummy_tx_desc->next_desc_addr = - (unsigned long)(sport->dma_tx_desc); + sizeof(struct dmasg)) != sport->dummy_tx_desc) + continue; + sport->dummy_tx_desc->next_desc_addr = sport->dma_tx_desc; local_irq_restore(flags); sport->curr_tx_desc = sport->dma_tx_desc; } else { @@ -536,19 +524,17 @@ static int sport_config_rx_dummy(struct sport_device *sport) unsigned config; pr_debug("%s entered\n", __func__); -#if L1_DATA_A_LENGTH != 0 - desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); -#else - { + if (L1_DATA_A_LENGTH) + desc = l1_data_sram_zalloc(2 * sizeof(*desc)); + else { dma_addr_t addr; desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); + memset(desc, 0, 2 * sizeof(*desc)); } -#endif if (desc == NULL) { pr_err("Failed to allocate memory for dummy rx desc\n"); return -ENOMEM; } - memset(desc, 0, 2 * sizeof(*desc)); sport->dummy_rx_desc = desc; desc->start_addr = (unsigned long)sport->dummy_buf; config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) @@ -559,8 +545,8 @@ static int sport_config_rx_dummy(struct sport_device *sport) desc->y_count = 0; desc->y_modify = 0; memcpy(desc+1, desc, sizeof(*desc)); - desc->next_desc_addr = (unsigned long)(desc+1); - desc[1].next_desc_addr = (unsigned long)desc; + desc->next_desc_addr = desc + 1; + desc[1].next_desc_addr = desc; return 0; } @@ -571,19 +557,17 @@ static int sport_config_tx_dummy(struct sport_device *sport) pr_debug("%s entered\n", __func__); -#if L1_DATA_A_LENGTH != 0 - desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); -#else - { + if (L1_DATA_A_LENGTH) + desc = l1_data_sram_zalloc(2 * sizeof(*desc)); + else { dma_addr_t addr; desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); + memset(desc, 0, 2 * sizeof(*desc)); } -#endif if (!desc) { pr_err("Failed to allocate memory for dummy tx desc\n"); return -ENOMEM; } - memset(desc, 0, 2 * sizeof(*desc)); sport->dummy_tx_desc = desc; desc->start_addr = (unsigned long)sport->dummy_buf + \ sport->dummy_count; @@ -595,8 +579,8 @@ static int sport_config_tx_dummy(struct sport_device *sport) desc->y_count = 0; desc->y_modify = 0; memcpy(desc+1, desc, sizeof(*desc)); - desc->next_desc_addr = (unsigned long)(desc+1); - desc[1].next_desc_addr = (unsigned long)desc; + desc->next_desc_addr = desc + 1; + desc[1].next_desc_addr = desc; return 0; } @@ -872,17 +856,15 @@ struct sport_device *sport_init(struct sport_param *param, unsigned wdsize, sport->wdsize = wdsize; sport->dummy_count = dummy_count; -#if L1_DATA_A_LENGTH != 0 - sport->dummy_buf = l1_data_sram_alloc(dummy_count * 2); -#else - sport->dummy_buf = kmalloc(dummy_count * 2, GFP_KERNEL); -#endif + if (L1_DATA_A_LENGTH) + sport->dummy_buf = l1_data_sram_zalloc(dummy_count * 2); + else + sport->dummy_buf = kzalloc(dummy_count * 2, GFP_KERNEL); if (sport->dummy_buf == NULL) { pr_err("Failed to allocate dummy buffer\n"); goto __error; } - memset(sport->dummy_buf, 0, dummy_count * 2); ret = sport_config_rx_dummy(sport); if (ret) { pr_err("Failed to config rx dummy ring\n"); @@ -939,6 +921,7 @@ void sport_done(struct sport_device *sport) sport = NULL; } EXPORT_SYMBOL(sport_done); + /* * It is only used to send several bytes when dma is not enabled * sport controller is configured but not enabled. @@ -1029,4 +1012,3 @@ EXPORT_SYMBOL(sport_send_and_recv); MODULE_AUTHOR("Roy Huang"); MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); MODULE_LICENSE("GPL"); - -- cgit v1.2.3 From 85ef2375ef2ebbb2bf660ad3a27c644d0ebf1b1a Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Thu, 5 Feb 2009 17:56:02 -0600 Subject: ASoC: optimize init sequence of Freescale MPC8610 sound drivers In the Freescale MPC8610 sound drivers, relocate all code from the _prepare functions into the corresponding _hw_params functions. These drivers assumed that the sample size is known in the _prepare function and not in the _hw_params function, but this is not true. Move the code in fsl_dma_prepare() into fsl_dma_hw_param(). Create fsl_ssi_hw_params() and move the code from fsl_ssi_prepare() into it. Turn off snooping for DMA operations to/from I/O registers, since that's not necessary. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 178 +++++++++++++++++++++++------------------------- sound/soc/fsl/fsl_ssi.c | 19 +++--- 2 files changed, 94 insertions(+), 103 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 64993eda567..58a3fa49750 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -464,11 +464,7 @@ static int fsl_dma_open(struct snd_pcm_substream *substream) sizeof(struct fsl_dma_link_descriptor); for (i = 0; i < NUM_DMA_LINKS; i++) { - struct fsl_dma_link_descriptor *link = &dma_private->link[i]; - - link->source_attr = cpu_to_be32(CCSR_DMA_ATR_SNOOP); - link->dest_attr = cpu_to_be32(CCSR_DMA_ATR_SNOOP); - link->next = cpu_to_be64(temp_link); + dma_private->link[i].next = cpu_to_be64(temp_link); temp_link += sizeof(struct fsl_dma_link_descriptor); } @@ -525,79 +521,9 @@ static int fsl_dma_open(struct snd_pcm_substream *substream) * This function obtains hardware parameters about the opened stream and * programs the DMA controller accordingly. * - * Note that due to a quirk of the SSI's STX register, the target address - * for the DMA operations depends on the sample size. So we don't program - * the dest_addr (for playback -- source_addr for capture) fields in the - * link descriptors here. We do that in fsl_dma_prepare() - */ -static int fsl_dma_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *hw_params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct fsl_dma_private *dma_private = runtime->private_data; - - dma_addr_t temp_addr; /* Pointer to next period */ - - unsigned int i; - - /* Get all the parameters we need */ - size_t buffer_size = params_buffer_bytes(hw_params); - size_t period_size = params_period_bytes(hw_params); - - /* Initialize our DMA tracking variables */ - dma_private->period_size = period_size; - dma_private->num_periods = params_periods(hw_params); - dma_private->dma_buf_end = dma_private->dma_buf_phys + buffer_size; - dma_private->dma_buf_next = dma_private->dma_buf_phys + - (NUM_DMA_LINKS * period_size); - if (dma_private->dma_buf_next >= dma_private->dma_buf_end) - dma_private->dma_buf_next = dma_private->dma_buf_phys; - - /* - * The actual address in STX0 (destination for playback, source for - * capture) is based on the sample size, but we don't know the sample - * size in this function, so we'll have to adjust that later. See - * comments in fsl_dma_prepare(). - * - * The DMA controller does not have a cache, so the CPU does not - * need to tell it to flush its cache. However, the DMA - * controller does need to tell the CPU to flush its cache. - * That's what the SNOOP bit does. - * - * Also, even though the DMA controller supports 36-bit addressing, for - * simplicity we currently support only 32-bit addresses for the audio - * buffer itself. - */ - temp_addr = substream->dma_buffer.addr; - - for (i = 0; i < NUM_DMA_LINKS; i++) { - struct fsl_dma_link_descriptor *link = &dma_private->link[i]; - - link->count = cpu_to_be32(period_size); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - link->source_addr = cpu_to_be32(temp_addr); - else - link->dest_addr = cpu_to_be32(temp_addr); - - temp_addr += period_size; - } - - return 0; -} - -/** - * fsl_dma_prepare - prepare the DMA registers for playback. - * - * This function is called after the specifics of the audio data are known, - * i.e. snd_pcm_runtime is initialized. - * - * In this function, we finish programming the registers of the DMA - * controller that are dependent on the sample size. - * - * One of the drawbacks with big-endian is that when copying integers of - * different sizes to a fixed-sized register, the address to which the - * integer must be copied is dependent on the size of the integer. + * One drawback of big-endian is that when copying integers of different + * sizes to a fixed-sized register, the address to which the integer must be + * copied is dependent on the size of the integer. * * For example, if P is the address of a 32-bit register, and X is a 32-bit * integer, then X should be copied to address P. However, if X is a 16-bit @@ -613,22 +539,58 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, * and 8 bytes at a time). So we do not support packed 24-bit samples. * 24-bit data must be padded to 32 bits. */ -static int fsl_dma_prepare(struct snd_pcm_substream *substream) +static int fsl_dma_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; + + /* Number of bits per sample */ + unsigned int sample_size = + snd_pcm_format_physical_width(params_format(hw_params)); + + /* Number of bytes per frame */ + unsigned int frame_size = 2 * (sample_size / 8); + + /* Bus address of SSI STX register */ + dma_addr_t ssi_sxx_phys = dma_private->ssi_sxx_phys; + + /* Size of the DMA buffer, in bytes */ + size_t buffer_size = params_buffer_bytes(hw_params); + + /* Number of bytes per period */ + size_t period_size = params_period_bytes(hw_params); + + /* Pointer to next period */ + dma_addr_t temp_addr = substream->dma_buffer.addr; + + /* Pointer to DMA controller */ struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; - u32 mr; + + u32 mr; /* DMA Mode Register */ + unsigned int i; - dma_addr_t ssi_sxx_phys; /* Bus address of SSI STX register */ - unsigned int frame_size; /* Number of bytes per frame */ - ssi_sxx_phys = dma_private->ssi_sxx_phys; + /* Initialize our DMA tracking variables */ + dma_private->period_size = period_size; + dma_private->num_periods = params_periods(hw_params); + dma_private->dma_buf_end = dma_private->dma_buf_phys + buffer_size; + dma_private->dma_buf_next = dma_private->dma_buf_phys + + (NUM_DMA_LINKS * period_size); + + if (dma_private->dma_buf_next >= dma_private->dma_buf_end) + /* This happens if the number of periods == NUM_DMA_LINKS */ + dma_private->dma_buf_next = dma_private->dma_buf_phys; mr = in_be32(&dma_channel->mr) & ~(CCSR_DMA_MR_BWC_MASK | CCSR_DMA_MR_SAHTS_MASK | CCSR_DMA_MR_DAHTS_MASK); - switch (runtime->sample_bits) { + /* Due to a quirk of the SSI's STX register, the target address + * for the DMA operations depends on the sample size. So we calculate + * that offset here. While we're at it, also tell the DMA controller + * how much data to transfer per sample. + */ + switch (sample_size) { case 8: mr |= CCSR_DMA_MR_DAHTS_1 | CCSR_DMA_MR_SAHTS_1; ssi_sxx_phys += 3; @@ -641,12 +603,12 @@ static int fsl_dma_prepare(struct snd_pcm_substream *substream) mr |= CCSR_DMA_MR_DAHTS_4 | CCSR_DMA_MR_SAHTS_4; break; default: + /* We should never get here */ dev_err(substream->pcm->card->dev, - "unsupported sample size %u\n", runtime->sample_bits); + "unsupported sample size %u\n", sample_size); return -EINVAL; } - frame_size = runtime->frame_bits / 8; /* * BWC should always be a multiple of the frame size. BWC determines * how many bytes are sent/received before the DMA controller checks the @@ -655,7 +617,6 @@ static int fsl_dma_prepare(struct snd_pcm_substream *substream) * capture, the receive FIFO is triggered when it contains one frame, so * we want to receive one frame at a time. */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) mr |= CCSR_DMA_MR_BWC(2 * frame_size); else @@ -663,16 +624,48 @@ static int fsl_dma_prepare(struct snd_pcm_substream *substream) out_be32(&dma_channel->mr, mr); - /* - * Program the address of the DMA transfer to/from the SSI. - */ for (i = 0; i < NUM_DMA_LINKS; i++) { struct fsl_dma_link_descriptor *link = &dma_private->link[i]; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + link->count = cpu_to_be32(period_size); + + /* Even though the DMA controller supports 36-bit addressing, + * for simplicity we allow only 32-bit addresses for the audio + * buffer itself. This was enforced in fsl_dma_new() with the + * DMA mask. + * + * The snoop bit tells the DMA controller whether it should tell + * the ECM to snoop during a read or write to an address. For + * audio, we use DMA to transfer data between memory and an I/O + * device (the SSI's STX0 or SRX0 register). Snooping is only + * needed if there is a cache, so we need to snoop memory + * addresses only. For playback, that means we snoop the source + * but not the destination. For capture, we snoop the + * destination but not the source. + * + * Note that failing to snoop properly is unlikely to cause + * cache incoherency if the period size is larger than the + * size of L1 cache. This is because filling in one period will + * flush out the data for the previous period. So if you + * increased period_bytes_min to a large enough size, you might + * get more performance by not snooping, and you'll still be + * okay. + */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + link->source_addr = cpu_to_be32(temp_addr); + link->source_attr = cpu_to_be32(CCSR_DMA_ATR_SNOOP); + link->dest_addr = cpu_to_be32(ssi_sxx_phys); - else + link->dest_attr = cpu_to_be32(CCSR_DMA_ATR_NOSNOOP); + } else { link->source_addr = cpu_to_be32(ssi_sxx_phys); + link->source_attr = cpu_to_be32(CCSR_DMA_ATR_NOSNOOP); + + link->dest_addr = cpu_to_be32(temp_addr); + link->dest_attr = cpu_to_be32(CCSR_DMA_ATR_SNOOP); + } + + temp_addr += period_size; } return 0; @@ -808,7 +801,6 @@ static struct snd_pcm_ops fsl_dma_ops = { .ioctl = snd_pcm_lib_ioctl, .hw_params = fsl_dma_hw_params, .hw_free = fsl_dma_hw_free, - .prepare = fsl_dma_prepare, .pointer = fsl_dma_pointer, }; diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index c6d6eb71dc1..6844009833d 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -400,7 +400,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, } /** - * fsl_ssi_prepare: prepare the SSI. + * fsl_ssi_hw_params - program the sample size * * Most of the SSI registers have been programmed in the startup function, * but the word length must be programmed here. Unfortunately, programming @@ -412,20 +412,19 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, * Note: The SxCCR.DC and SxCCR.PM bits are only used if the SSI is the * clock master. */ -static int fsl_ssi_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai) { - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct fsl_ssi_private *ssi_private = rtd->dai->cpu_dai->private_data; - - struct ccsr_ssi __iomem *ssi = ssi_private->ssi; + struct fsl_ssi_private *ssi_private = cpu_dai->private_data; if (substream == ssi_private->first_stream) { + struct ccsr_ssi __iomem *ssi = ssi_private->ssi; + unsigned int sample_size = + snd_pcm_format_width(params_format(hw_params)); u32 wl; /* The SSI should always be disabled at this points (SSIEN=0) */ - wl = CCSR_SSI_SxCCR_WL(snd_pcm_format_width(runtime->format)); + wl = CCSR_SSI_SxCCR_WL(sample_size); /* In synchronous mode, the SSI uses STCCR for capture */ clrsetbits_be32(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl); @@ -579,7 +578,7 @@ static struct snd_soc_dai fsl_ssi_dai_template = { }, .ops = { .startup = fsl_ssi_startup, - .prepare = fsl_ssi_prepare, + .hw_params = fsl_ssi_hw_params, .shutdown = fsl_ssi_shutdown, .trigger = fsl_ssi_trigger, .set_sysclk = fsl_ssi_set_sysclk, -- cgit v1.2.3 From 8f0dc655f9efa3fc81b8cdaf5aa1f2779f8db46d Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 7 Feb 2009 14:01:58 +0100 Subject: ASoC: Add initial support of Mitac mioa701 device SoC. This machine driver enables sound functions on Mitac mio a701 smartphone. Build upon ASoC v1, it handles : - rear speaker - front speaker - microphone - GSM A global "Mio Mode" switch is not yet provided to cope with audio path setup. As balance on audio chip line is no more assured, an incorrect setup can produce a lot of heat and even fry the battery behind the wm9713 and the speaker amplifier. It doesn't cope with : - headset jack - mio master mode - master volume control This driver is backported from ASoc v2, and amputated from scenario setups and master volume control. [Minor mods for terminology in comments -- broonie] Signed-off-by: Robert Jarzmik Signed-off-by: Mark Brown --- sound/soc/pxa/Kconfig | 9 ++ sound/soc/pxa/Makefile | 2 + sound/soc/pxa/mioa701_wm9713.c | 250 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 sound/soc/pxa/mioa701_wm9713.c (limited to 'sound/soc') diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index 958ac3fe15d..5998ab366e8 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig @@ -115,3 +115,12 @@ config SND_SOC_ZYLONITE help Say Y if you want to add support for SoC audio on the Marvell Zylonite reference platform. + +config SND_PXA2XX_SOC_MIOA701 + tristate "SoC Audio support for MIO A701" + depends on SND_PXA2XX_SOC && MACH_MIOA701 + select SND_PXA2XX_SOC_AC97 + select SND_SOC_WM9713 + help + Say Y if you want to add support for SoC audio on the + MIO A701. diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 97a51a8c936..8ed881c5e5c 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile @@ -20,6 +20,7 @@ snd-soc-spitz-objs := spitz.o snd-soc-em-x270-objs := em-x270.o snd-soc-palm27x-objs := palm27x.o snd-soc-zylonite-objs := zylonite.o +snd-soc-mioa701-objs := mioa701_wm9713.o obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o @@ -30,4 +31,5 @@ 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 +obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c new file mode 100644 index 00000000000..19eda8bbfda --- /dev/null +++ b/sound/soc/pxa/mioa701_wm9713.c @@ -0,0 +1,250 @@ +/* + * Handles the Mitac mioa701 SoC system + * + * Copyright (C) 2008 Robert Jarzmik + * + * 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 in version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * This is a little schema of the sound interconnections : + * + * Sagem X200 Wolfson WM9713 + * +--------+ +-------------------+ Rear Speaker + * | | | | /-+ + * | +--->----->---+MONOIN SPKL+--->----+-+ | + * | GSM | | | | | | + * | +--->----->---+PCBEEP SPKR+--->----+-+ | + * | CHIP | | | \-+ + * | +---<-----<---+MONO | + * | | | | Front Speaker + * +--------+ | | /-+ + * | HPL+--->----+-+ | + * | | | | | + * | OUT3+--->----+-+ | + * | | \-+ + * | | + * | | Front Micro + * | | + + * | MIC1+-----<--+o+ + * | | + + * +-------------------+ --- + */ + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "pxa2xx-pcm.h" +#include "pxa2xx-ac97.h" +#include "../codecs/wm9713.h" + +#define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) + +#define AC97_GPIO_PULL 0x58 + +/* Use GPIO8 for rear speaker amplifier */ +static int rear_amp_power(struct snd_soc_codec *codec, int power) +{ + unsigned short reg; + + if (power) { + reg = snd_soc_read(codec, AC97_GPIO_CFG); + snd_soc_write(codec, AC97_GPIO_CFG, reg | 0x0100); + reg = snd_soc_read(codec, AC97_GPIO_PULL); + snd_soc_write(codec, AC97_GPIO_PULL, reg | (1<<15)); + } else { + reg = snd_soc_read(codec, AC97_GPIO_CFG); + snd_soc_write(codec, AC97_GPIO_CFG, reg & ~0x0100); + reg = snd_soc_read(codec, AC97_GPIO_PULL); + snd_soc_write(codec, AC97_GPIO_PULL, reg & ~(1<<15)); + } + + return 0; +} + +static int rear_amp_event(struct snd_soc_dapm_widget *widget, + struct snd_kcontrol *kctl, int event) +{ + struct snd_soc_codec *codec = widget->codec; + + return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event)); +} + +/* mioa701 machine dapm widgets */ +static const struct snd_soc_dapm_widget mioa701_dapm_widgets[] = { + SND_SOC_DAPM_SPK("Front Speaker", NULL), + SND_SOC_DAPM_SPK("Rear Speaker", rear_amp_event), + SND_SOC_DAPM_MIC("Headset", NULL), + SND_SOC_DAPM_LINE("GSM Line Out", NULL), + SND_SOC_DAPM_LINE("GSM Line In", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Front Mic", NULL), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + /* Call Mic */ + {"Mic Bias", NULL, "Front Mic"}, + {"MIC1", NULL, "Mic Bias"}, + + /* Headset Mic */ + {"LINEL", NULL, "Headset Mic"}, + {"LINER", NULL, "Headset Mic"}, + + /* GSM Module */ + {"MONOIN", NULL, "GSM Line Out"}, + {"PCBEEP", NULL, "GSM Line Out"}, + {"GSM Line In", NULL, "MONO"}, + + /* headphone connected to HPL, HPR */ + {"Headset", NULL, "HPL"}, + {"Headset", NULL, "HPR"}, + + /* front speaker connected to HPL, OUT3 */ + {"Front Speaker", NULL, "HPL"}, + {"Front Speaker", NULL, "OUT3"}, + + /* rear speaker connected to SPKL, SPKR */ + {"Rear Speaker", NULL, "SPKL"}, + {"Rear Speaker", NULL, "SPKR"}, +}; + +static int mioa701_wm9713_init(struct snd_soc_codec *codec) +{ + unsigned short reg; + + /* Add mioa701 specific widgets */ + snd_soc_dapm_new_controls(codec, ARRAY_AND_SIZE(mioa701_dapm_widgets)); + + /* Set up mioa701 specific audio path audio_mapnects */ + snd_soc_dapm_add_routes(codec, ARRAY_AND_SIZE(audio_map)); + + /* Prepare GPIO8 for rear speaker amplifier */ + reg = codec->read(codec, AC97_GPIO_CFG); + codec->write(codec, AC97_GPIO_CFG, reg | 0x0100); + + /* Prepare MIC input */ + reg = codec->read(codec, AC97_3D_CONTROL); + codec->write(codec, AC97_3D_CONTROL, reg | 0xc000); + + snd_soc_dapm_enable_pin(codec, "Front Speaker"); + snd_soc_dapm_enable_pin(codec, "Rear Speaker"); + snd_soc_dapm_enable_pin(codec, "Front Mic"); + snd_soc_dapm_enable_pin(codec, "GSM Line In"); + snd_soc_dapm_enable_pin(codec, "GSM Line Out"); + snd_soc_dapm_sync(codec); + + return 0; +} + +static struct snd_soc_ops mioa701_ops; + +static struct snd_soc_dai_link mioa701_dai[] = { + { + .name = "AC97", + .stream_name = "AC97 HiFi", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI], + .codec_dai = &wm9713_dai[WM9713_DAI_AC97_HIFI], + .init = mioa701_wm9713_init, + .ops = &mioa701_ops, + }, + { + .name = "AC97 Aux", + .stream_name = "AC97 Aux", + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], + .codec_dai = &wm9713_dai[WM9713_DAI_AC97_AUX], + .ops = &mioa701_ops, + }, +}; + +static struct snd_soc_card mioa701 = { + .name = "MioA701", + .platform = &pxa2xx_soc_platform, + .dai_link = mioa701_dai, + .num_links = ARRAY_SIZE(mioa701_dai), +}; + +static struct snd_soc_device mioa701_snd_devdata = { + .card = &mioa701, + .codec_dev = &soc_codec_dev_wm9713, +}; + +static struct platform_device *mioa701_snd_device; + +static int mioa701_wm9713_probe(struct platform_device *pdev) +{ + int ret; + + if (!machine_is_mioa701()) + return -ENODEV; + + dev_warn(&pdev->dev, "Be warned that incorrect mixers/muxes setup will" + "lead to overheating and possible destruction of your device." + "Do not use without a good knowledge of mio's board design!\n"); + + mioa701_snd_device = platform_device_alloc("soc-audio", -1); + if (!mioa701_snd_device) + return -ENOMEM; + + platform_set_drvdata(mioa701_snd_device, &mioa701_snd_devdata); + mioa701_snd_devdata.dev = &mioa701_snd_device->dev; + + ret = platform_device_add(mioa701_snd_device); + if (!ret) + return 0; + + platform_device_put(mioa701_snd_device); + return ret; +} + +static int __devexit mioa701_wm9713_remove(struct platform_device *pdev) +{ + platform_device_unregister(mioa701_snd_device); + return 0; +} + +static struct platform_driver mioa701_wm9713_driver = { + .probe = mioa701_wm9713_probe, + .remove = __devexit_p(mioa701_wm9713_remove), + .driver = { + .name = "mioa701-wm9713", + .owner = THIS_MODULE, + }, +}; + +static int __init mioa701_asoc_init(void) +{ + return platform_driver_register(&mioa701_wm9713_driver); +} + +static void __exit mioa701_asoc_exit(void) +{ + platform_driver_unregister(&mioa701_wm9713_driver); +} + +module_init(mioa701_asoc_init); +module_exit(mioa701_asoc_exit); + +/* Module information */ +MODULE_AUTHOR("Robert Jarzmik (rjarzmik@free.fr)"); +MODULE_DESCRIPTION("ALSA SoC WM9713 MIO A701"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 67137a5d46d5a7c4cbdc66f03d1e2f397fe14b2b Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Sun, 8 Feb 2009 18:17:37 +0100 Subject: ASoC: count reaches 10001, not 10000. With a postfix increment count reaches 10001, not 10000. Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-ad73311.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/blackfin/bf5xx-ad73311.c b/sound/soc/blackfin/bf5xx-ad73311.c index 7f2a5e19907..edfbdc024e6 100644 --- a/sound/soc/blackfin/bf5xx-ad73311.c +++ b/sound/soc/blackfin/bf5xx-ad73311.c @@ -114,7 +114,7 @@ static int snd_ad73311_configure(void) SSYNC(); /* When TUVF is set, the data is already send out */ - while (!(status & TUVF) && count++ < 10000) { + while (!(status & TUVF) && ++count < 10000) { udelay(1); status = bfin_read_SPORT_STAT(); SSYNC(); @@ -123,7 +123,7 @@ static int snd_ad73311_configure(void) SSYNC(); local_irq_enable(); - if (count == 10000) { + if (count >= 10000) { printk(KERN_ERR "ad73311: failed to configure codec\n"); return -1; } -- cgit v1.2.3 From 44dd2b9168350b82a671ce71666b99208ab2d973 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 5 Feb 2009 17:48:21 +0100 Subject: ASoC: pxa2xx-i2s: remove I2S pin setup This removes the calls to pxa_gpio_mode from the pxa2xx-i2s driver. Pin setup should be done during board init via pxa2xx_mfp_config instead. Signed-off-by: Philipp Zabel Acked-by: Eric Miao Signed-off-by: Mark Brown --- sound/soc/pxa/pxa2xx-i2s.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index 517991fb109..83b59d7fe96 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -25,20 +25,11 @@ #include #include -#include #include #include "pxa2xx-pcm.h" #include "pxa2xx-i2s.h" -struct pxa2xx_gpio { - u32 sys; - u32 rx; - u32 tx; - u32 clk; - u32 frm; -}; - /* * I2S Controller Register and Bit Definitions */ @@ -106,21 +97,6 @@ static struct pxa2xx_pcm_dma_params pxa2xx_i2s_pcm_stereo_in = { DCMD_BURST32 | DCMD_WIDTH4, }; -static struct pxa2xx_gpio gpio_bus[] = { - { /* I2S SoC Slave */ - .rx = GPIO29_SDATA_IN_I2S_MD, - .tx = GPIO30_SDATA_OUT_I2S_MD, - .clk = GPIO28_BITCLK_IN_I2S_MD, - .frm = GPIO31_SYNC_I2S_MD, - }, - { /* I2S SoC Master */ - .rx = GPIO29_SDATA_IN_I2S_MD, - .tx = GPIO30_SDATA_OUT_I2S_MD, - .clk = GPIO28_BITCLK_OUT_I2S_MD, - .frm = GPIO31_SYNC_I2S_MD, - }, -}; - static int pxa2xx_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -181,9 +157,6 @@ static int pxa2xx_i2s_set_dai_sysclk(struct snd_soc_dai *cpu_dai, if (clk_id != PXA2XX_I2S_SYSCLK) return -ENODEV; - if (pxa_i2s.master && dir == SND_SOC_CLOCK_OUT) - pxa_gpio_mode(gpio_bus[pxa_i2s.master].sys); - return 0; } @@ -194,10 +167,6 @@ static int pxa2xx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; - pxa_gpio_mode(gpio_bus[pxa_i2s.master].rx); - pxa_gpio_mode(gpio_bus[pxa_i2s.master].tx); - pxa_gpio_mode(gpio_bus[pxa_i2s.master].frm); - pxa_gpio_mode(gpio_bus[pxa_i2s.master].clk); BUG_ON(IS_ERR(clk_i2s)); clk_enable(clk_i2s); pxa_i2s_wait(); @@ -398,11 +367,6 @@ static struct platform_driver pxa2xx_i2s_driver = { static int __init pxa2xx_i2s_init(void) { - if (cpu_is_pxa27x()) - gpio_bus[1].sys = GPIO113_I2S_SYSCLK_MD; - else - gpio_bus[1].sys = GPIO32_SYSCLK_I2S_MD; - clk_i2s = ERR_PTR(-ENOENT); return platform_driver_register(&pxa2xx_i2s_driver); } -- cgit v1.2.3 From b93f74f604c53b546fced33d11aee722560de249 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Mon, 9 Feb 2009 14:27:06 +0200 Subject: ASoC: TLV320AIC3X: Fix volume ranges This is a minor fix but helps to define dB ranges for volume controls. Only DAC digital volume has full register value range from 0 to 127 but ADC PGA gain and output stage volume controls don't. For ADC PGA, maximum value is 119 and then it saturates to the same gain value of 59.5 dB. For output stages, value 117 corresponds to -78.3 dB and is muted for values 118 and above. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index ac73e692a99..cdb6dec14e1 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -255,51 +255,51 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { SOC_DOUBLE_R("PCM Playback Volume", LDAC_VOL, RDAC_VOL, 0, 0x7f, 1), SOC_DOUBLE_R("Line DAC Playback Volume", DACL1_2_LLOPM_VOL, - DACR1_2_RLOPM_VOL, 0, 0x7f, 1), + DACR1_2_RLOPM_VOL, 0, 118, 1), SOC_SINGLE("LineL Playback Switch", LLOPM_CTRL, 3, 0x01, 0), SOC_SINGLE("LineR Playback Switch", RLOPM_CTRL, 3, 0x01, 0), SOC_DOUBLE_R("LineL DAC Playback Volume", DACL1_2_LLOPM_VOL, - DACR1_2_LLOPM_VOL, 0, 0x7f, 1), + DACR1_2_LLOPM_VOL, 0, 118, 1), SOC_SINGLE("LineL Left PGA Bypass Playback Volume", PGAL_2_LLOPM_VOL, - 0, 0x7f, 1), + 0, 118, 1), SOC_SINGLE("LineR Right PGA Bypass Playback Volume", PGAR_2_RLOPM_VOL, - 0, 0x7f, 1), + 0, 118, 1), SOC_DOUBLE_R("LineL Line2 Bypass Playback Volume", LINE2L_2_LLOPM_VOL, - LINE2R_2_LLOPM_VOL, 0, 0x7f, 1), + LINE2R_2_LLOPM_VOL, 0, 118, 1), SOC_DOUBLE_R("LineR Line2 Bypass Playback Volume", LINE2L_2_RLOPM_VOL, - LINE2R_2_RLOPM_VOL, 0, 0x7f, 1), + LINE2R_2_RLOPM_VOL, 0, 118, 1), SOC_DOUBLE_R("Mono DAC Playback Volume", DACL1_2_MONOLOPM_VOL, - DACR1_2_MONOLOPM_VOL, 0, 0x7f, 1), + DACR1_2_MONOLOPM_VOL, 0, 118, 1), SOC_SINGLE("Mono DAC Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0), SOC_DOUBLE_R("Mono PGA Bypass Playback Volume", PGAL_2_MONOLOPM_VOL, - PGAR_2_MONOLOPM_VOL, 0, 0x7f, 1), + PGAR_2_MONOLOPM_VOL, 0, 118, 1), SOC_DOUBLE_R("Mono Line2 Bypass Playback Volume", LINE2L_2_MONOLOPM_VOL, - LINE2R_2_MONOLOPM_VOL, 0, 0x7f, 1), + LINE2R_2_MONOLOPM_VOL, 0, 118, 1), SOC_DOUBLE_R("HP DAC Playback Volume", DACL1_2_HPLOUT_VOL, - DACR1_2_HPROUT_VOL, 0, 0x7f, 1), + DACR1_2_HPROUT_VOL, 0, 118, 1), SOC_DOUBLE_R("HP DAC Playback Switch", HPLOUT_CTRL, HPROUT_CTRL, 3, 0x01, 0), SOC_DOUBLE_R("HP Right PGA Bypass Playback Volume", PGAR_2_HPLOUT_VOL, - PGAR_2_HPROUT_VOL, 0, 0x7f, 1), + PGAR_2_HPROUT_VOL, 0, 118, 1), SOC_SINGLE("HPL PGA Bypass Playback Volume", PGAL_2_HPLOUT_VOL, - 0, 0x7f, 1), + 0, 118, 1), SOC_SINGLE("HPR PGA Bypass Playback Volume", PGAL_2_HPROUT_VOL, - 0, 0x7f, 1), + 0, 118, 1), SOC_DOUBLE_R("HP Line2 Bypass Playback Volume", LINE2L_2_HPLOUT_VOL, - LINE2R_2_HPROUT_VOL, 0, 0x7f, 1), + LINE2R_2_HPROUT_VOL, 0, 118, 1), SOC_DOUBLE_R("HPCOM DAC Playback Volume", DACL1_2_HPLCOM_VOL, - DACR1_2_HPRCOM_VOL, 0, 0x7f, 1), + DACR1_2_HPRCOM_VOL, 0, 118, 1), SOC_DOUBLE_R("HPCOM DAC Playback Switch", HPLCOM_CTRL, HPRCOM_CTRL, 3, 0x01, 0), SOC_SINGLE("HPLCOM PGA Bypass Playback Volume", PGAL_2_HPLCOM_VOL, - 0, 0x7f, 1), + 0, 118, 1), SOC_SINGLE("HPRCOM PGA Bypass Playback Volume", PGAL_2_HPRCOM_VOL, - 0, 0x7f, 1), + 0, 118, 1), SOC_DOUBLE_R("HPCOM Line2 Bypass Playback Volume", LINE2L_2_HPLCOM_VOL, - LINE2R_2_HPRCOM_VOL, 0, 0x7f, 1), + LINE2R_2_HPRCOM_VOL, 0, 118, 1), /* * Note: enable Automatic input Gain Controller with care. It can @@ -308,7 +308,7 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { SOC_DOUBLE_R("AGC Switch", LAGC_CTRL_A, RAGC_CTRL_A, 7, 0x01, 0), /* Input */ - SOC_DOUBLE_R("PGA Capture Volume", LADC_VOL, RADC_VOL, 0, 0x7f, 0), + SOC_DOUBLE_R("PGA Capture Volume", LADC_VOL, RADC_VOL, 0, 119, 0), SOC_DOUBLE_R("PGA Capture Switch", LADC_VOL, RADC_VOL, 7, 0x01, 1), SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), -- cgit v1.2.3 From 7565fc38cc8c3a2742d63e957199d70a82d2faf1 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Mon, 9 Feb 2009 14:27:07 +0200 Subject: ASoC: TLV320AIC3X: Add TLV information for volume controls TLV320AIC3X volume controls are logarithmic. Export their dB ranges. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 114 ++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 41 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index cdb6dec14e1..d638e3f0728 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "tlv320aic3x.h" @@ -250,56 +251,86 @@ static const struct soc_enum aic3x_enum[] = { SOC_ENUM_DOUBLE(AIC3X_CODEC_DFILT_CTRL, 6, 4, 4, aic3x_adc_hpf), }; +/* + * DAC digital volumes. From -63.5 to 0 dB in 0.5 dB steps + */ +static DECLARE_TLV_DB_SCALE(dac_tlv, -6350, 50, 0); +/* ADC PGA gain volumes. From 0 to 59.5 dB in 0.5 dB steps */ +static DECLARE_TLV_DB_SCALE(adc_tlv, 0, 50, 0); +/* + * Output stage volumes. From -78.3 to 0 dB. Muted below -78.3 dB. + * Step size is approximately 0.5 dB over most of the scale but increasing + * near the very low levels. + * Define dB scale so that it is mostly correct for range about -55 to 0 dB + * but having increasing dB difference below that (and where it doesn't count + * so much). This setting shows -50 dB (actual is -50.3 dB) for register + * value 100 and -58.5 dB (actual is -78.3 dB) for register value 117. + */ +static DECLARE_TLV_DB_SCALE(output_stage_tlv, -5900, 50, 1); + static const struct snd_kcontrol_new aic3x_snd_controls[] = { /* Output */ - SOC_DOUBLE_R("PCM Playback Volume", LDAC_VOL, RDAC_VOL, 0, 0x7f, 1), + SOC_DOUBLE_R_TLV("PCM Playback Volume", + LDAC_VOL, RDAC_VOL, 0, 0x7f, 1, dac_tlv), - SOC_DOUBLE_R("Line DAC Playback Volume", DACL1_2_LLOPM_VOL, - DACR1_2_RLOPM_VOL, 0, 118, 1), + SOC_DOUBLE_R_TLV("Line DAC Playback Volume", + DACL1_2_LLOPM_VOL, DACR1_2_RLOPM_VOL, + 0, 118, 1, output_stage_tlv), SOC_SINGLE("LineL Playback Switch", LLOPM_CTRL, 3, 0x01, 0), SOC_SINGLE("LineR Playback Switch", RLOPM_CTRL, 3, 0x01, 0), - SOC_DOUBLE_R("LineL DAC Playback Volume", DACL1_2_LLOPM_VOL, - DACR1_2_LLOPM_VOL, 0, 118, 1), - SOC_SINGLE("LineL Left PGA Bypass Playback Volume", PGAL_2_LLOPM_VOL, - 0, 118, 1), - SOC_SINGLE("LineR Right PGA Bypass Playback Volume", PGAR_2_RLOPM_VOL, - 0, 118, 1), - SOC_DOUBLE_R("LineL Line2 Bypass Playback Volume", LINE2L_2_LLOPM_VOL, - LINE2R_2_LLOPM_VOL, 0, 118, 1), - SOC_DOUBLE_R("LineR Line2 Bypass Playback Volume", LINE2L_2_RLOPM_VOL, - LINE2R_2_RLOPM_VOL, 0, 118, 1), - - SOC_DOUBLE_R("Mono DAC Playback Volume", DACL1_2_MONOLOPM_VOL, - DACR1_2_MONOLOPM_VOL, 0, 118, 1), + SOC_DOUBLE_R_TLV("LineL DAC Playback Volume", + DACL1_2_LLOPM_VOL, DACR1_2_LLOPM_VOL, + 0, 118, 1, output_stage_tlv), + SOC_SINGLE_TLV("LineL Left PGA Bypass Playback Volume", + PGAL_2_LLOPM_VOL, 0, 118, 1, output_stage_tlv), + SOC_SINGLE_TLV("LineR Right PGA Bypass Playback Volume", + PGAR_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv), + SOC_DOUBLE_R_TLV("LineL Line2 Bypass Playback Volume", + LINE2L_2_LLOPM_VOL, LINE2R_2_LLOPM_VOL, + 0, 118, 1, output_stage_tlv), + SOC_DOUBLE_R_TLV("LineR Line2 Bypass Playback Volume", + LINE2L_2_RLOPM_VOL, LINE2R_2_RLOPM_VOL, + 0, 118, 1, output_stage_tlv), + + SOC_DOUBLE_R_TLV("Mono DAC Playback Volume", + DACL1_2_MONOLOPM_VOL, DACR1_2_MONOLOPM_VOL, + 0, 118, 1, output_stage_tlv), SOC_SINGLE("Mono DAC Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0), - SOC_DOUBLE_R("Mono PGA Bypass Playback Volume", PGAL_2_MONOLOPM_VOL, - PGAR_2_MONOLOPM_VOL, 0, 118, 1), - SOC_DOUBLE_R("Mono Line2 Bypass Playback Volume", LINE2L_2_MONOLOPM_VOL, - LINE2R_2_MONOLOPM_VOL, 0, 118, 1), - - SOC_DOUBLE_R("HP DAC Playback Volume", DACL1_2_HPLOUT_VOL, - DACR1_2_HPROUT_VOL, 0, 118, 1), + SOC_DOUBLE_R_TLV("Mono PGA Bypass Playback Volume", + PGAL_2_MONOLOPM_VOL, PGAR_2_MONOLOPM_VOL, + 0, 118, 1, output_stage_tlv), + SOC_DOUBLE_R_TLV("Mono Line2 Bypass Playback Volume", + LINE2L_2_MONOLOPM_VOL, LINE2R_2_MONOLOPM_VOL, + 0, 118, 1, output_stage_tlv), + + SOC_DOUBLE_R_TLV("HP DAC Playback Volume", + DACL1_2_HPLOUT_VOL, DACR1_2_HPROUT_VOL, + 0, 118, 1, output_stage_tlv), SOC_DOUBLE_R("HP DAC Playback Switch", HPLOUT_CTRL, HPROUT_CTRL, 3, 0x01, 0), - SOC_DOUBLE_R("HP Right PGA Bypass Playback Volume", PGAR_2_HPLOUT_VOL, - PGAR_2_HPROUT_VOL, 0, 118, 1), - SOC_SINGLE("HPL PGA Bypass Playback Volume", PGAL_2_HPLOUT_VOL, - 0, 118, 1), - SOC_SINGLE("HPR PGA Bypass Playback Volume", PGAL_2_HPROUT_VOL, - 0, 118, 1), - SOC_DOUBLE_R("HP Line2 Bypass Playback Volume", LINE2L_2_HPLOUT_VOL, - LINE2R_2_HPROUT_VOL, 0, 118, 1), - - SOC_DOUBLE_R("HPCOM DAC Playback Volume", DACL1_2_HPLCOM_VOL, - DACR1_2_HPRCOM_VOL, 0, 118, 1), + SOC_DOUBLE_R_TLV("HP Right PGA Bypass Playback Volume", + PGAR_2_HPLOUT_VOL, PGAR_2_HPROUT_VOL, + 0, 118, 1, output_stage_tlv), + SOC_SINGLE_TLV("HPL PGA Bypass Playback Volume", + PGAL_2_HPLOUT_VOL, 0, 118, 1, output_stage_tlv), + SOC_SINGLE_TLV("HPR PGA Bypass Playback Volume", + PGAL_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv), + SOC_DOUBLE_R_TLV("HP Line2 Bypass Playback Volume", + LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL, + 0, 118, 1, output_stage_tlv), + + SOC_DOUBLE_R_TLV("HPCOM DAC Playback Volume", + DACL1_2_HPLCOM_VOL, DACR1_2_HPRCOM_VOL, + 0, 118, 1, output_stage_tlv), SOC_DOUBLE_R("HPCOM DAC Playback Switch", HPLCOM_CTRL, HPRCOM_CTRL, 3, 0x01, 0), - SOC_SINGLE("HPLCOM PGA Bypass Playback Volume", PGAL_2_HPLCOM_VOL, - 0, 118, 1), - SOC_SINGLE("HPRCOM PGA Bypass Playback Volume", PGAL_2_HPRCOM_VOL, - 0, 118, 1), - SOC_DOUBLE_R("HPCOM Line2 Bypass Playback Volume", LINE2L_2_HPLCOM_VOL, - LINE2R_2_HPRCOM_VOL, 0, 118, 1), + SOC_SINGLE_TLV("HPLCOM PGA Bypass Playback Volume", + PGAL_2_HPLCOM_VOL, 0, 118, 1, output_stage_tlv), + SOC_SINGLE_TLV("HPRCOM PGA Bypass Playback Volume", + PGAL_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv), + SOC_DOUBLE_R_TLV("HPCOM Line2 Bypass Playback Volume", + LINE2L_2_HPLCOM_VOL, LINE2R_2_HPRCOM_VOL, + 0, 118, 1, output_stage_tlv), /* * Note: enable Automatic input Gain Controller with care. It can @@ -308,7 +339,8 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { SOC_DOUBLE_R("AGC Switch", LAGC_CTRL_A, RAGC_CTRL_A, 7, 0x01, 0), /* Input */ - SOC_DOUBLE_R("PGA Capture Volume", LADC_VOL, RADC_VOL, 0, 119, 0), + SOC_DOUBLE_R_TLV("PGA Capture Volume", LADC_VOL, RADC_VOL, + 0, 119, 0, adc_tlv), SOC_DOUBLE_R("PGA Capture Switch", LADC_VOL, RADC_VOL, 7, 0x01, 1), SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), -- cgit v1.2.3 From 9e30d7718bb7402c7bdee631ad2aae2658c324f0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 11 Feb 2009 08:28:04 +0100 Subject: ASoC: Fix forgotten replacements of socdev->codec The snd_soc_codec was moved into socdev->card, but this change wasn't applied in some places. Fixed now. Signed-off-by: Takashi Iwai --- sound/soc/omap/n810.c | 2 +- sound/soc/pxa/corgi.c | 2 +- sound/soc/pxa/palm27x.c | 2 +- sound/soc/pxa/poodle.c | 2 +- sound/soc/pxa/spitz.c | 2 +- sound/soc/pxa/tosa.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 25593fee912..9f037cd0191 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -72,7 +72,7 @@ static int n810_startup(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; + struct snd_soc_codec *codec = rtd->socdev->card->codec; snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2); diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 1ba25a55952..0d41be33d57 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -100,7 +100,7 @@ static void corgi_ext_control(struct snd_soc_codec *codec) static int corgi_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; + struct snd_soc_codec *codec = rtd->socdev->card->codec; /* check the jack status at stream startup */ corgi_ext_control(codec); diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 4a9cf3083af..29958cd9dae 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -55,7 +55,7 @@ static void palm27x_ext_control(struct snd_soc_codec *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; + struct snd_soc_codec *codec = rtd->socdev->card->codec; /* check the jack status at stream startup */ palm27x_ext_control(codec); diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index 6e9827189ff..3a62d4354ef 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -77,7 +77,7 @@ static void poodle_ext_control(struct snd_soc_codec *codec) static int poodle_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; + struct snd_soc_codec *codec = rtd->socdev->card->codec; /* check the jack status at stream startup */ poodle_ext_control(codec); diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index a3b9e6bdf97..1aafd8c645a 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -109,7 +109,7 @@ static void spitz_ext_control(struct snd_soc_codec *codec) static int spitz_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; + struct snd_soc_codec *codec = rtd->socdev->card->codec; /* check the jack status at stream startup */ spitz_ext_control(codec); diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index c77194f74c9..09b5bada03b 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c @@ -82,7 +82,7 @@ static void tosa_ext_control(struct snd_soc_codec *codec) static int tosa_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; + struct snd_soc_codec *codec = rtd->socdev->card->codec; /* check the jack status at stream startup */ tosa_ext_control(codec); -- cgit v1.2.3 From d5e9ba1d58b6da1c58a91113fc350ece97ec5a0b Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Tue, 3 Feb 2009 11:09:32 -0600 Subject: ASoC: add additional controls to the CS4270 codec driver Update the CS4270 codec driver to allow applications to use the mixer to control Digital Loopback, Soft Ramp, Zero Cross, Popguard, and Auto-Mute. Soft Ramp, Zero Cross, and Auto-Mute are disabled by the driver when it first initializes the hardware, but these features either don't work or interfere with normal ALSA behavior. However, they can now be re-enabled by an application if desired. Remove CONFIG_SND_SOC_CS4270_HWMUTE and always allow ASoC to control the mute bits. The driver previously and erroneously assumed that these bits control only external muting circuitry, but they also control internal muting circuitry, so they should always be used. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 --- sound/soc/codecs/cs4270.c | 93 ++++++++++++++++++++--------------------------- 2 files changed, 40 insertions(+), 59 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index a195303603e..628a591c728 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -67,12 +67,6 @@ config SND_SOC_AK4535 config SND_SOC_CS4270 tristate -# Cirrus Logic CS4270 Codec Hardware Mute Support -# Select if you have external muting circuitry attached to your CS4270. -config SND_SOC_CS4270_HWMUTE - bool - depends on SND_SOC_CS4270 - # Cirrus Logic CS4270 Codec VD = 3.3V Errata # Select if you are affected by the errata where the part will not function # if MCLK divide-by-1.5 is selected and VD is set to 3.3V. The driver will diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 2c79a24186f..cd4a9ee38e4 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -395,17 +395,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - /* Freeze and power-down the codec */ - - ret = snd_soc_write(codec, CS4270_PWRCTL, CS4270_PWRCTL_FREEZE | - CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | - CS4270_PWRCTL_PDN); - if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); - return ret; - } - - /* Program the mode control register */ + /* Set the sample rate */ reg = snd_soc_read(codec, CS4270_MODE); reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK); @@ -417,7 +407,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, return ret; } - /* Program the format register */ + /* Set the DAI format */ reg = snd_soc_read(codec, CS4270_FORMAT); reg &= ~(CS4270_FORMAT_DAC_MASK | CS4270_FORMAT_ADC_MASK); @@ -440,42 +430,9 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, return ret; } - /* Disable auto-mute. This feature appears to be buggy, because in - some situations, auto-mute will not deactivate when it should. */ - - reg = snd_soc_read(codec, CS4270_MUTE); - reg &= ~CS4270_MUTE_AUTO; - ret = snd_soc_write(codec, CS4270_MUTE, reg); - if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); - return ret; - } - - /* Disable automatic volume control. It's enabled by default, and - * it causes volume change commands to be delayed, sometimes until - * after playback has started. - */ - - reg = cs4270_read_reg_cache(codec, CS4270_TRANS); - reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO); - ret = cs4270_i2c_write(codec, CS4270_TRANS, reg); - if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); - return ret; - } - - /* Thaw and power-up the codec */ - - ret = snd_soc_write(codec, CS4270_PWRCTL, 0); - if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); - return ret; - } - return ret; } -#ifdef CONFIG_SND_SOC_CS4270_HWMUTE /** * cs4270_mute - enable/disable the CS4270 external mute * @dai: the SOC DAI @@ -494,22 +451,23 @@ static int cs4270_mute(struct snd_soc_dai *dai, int mute) reg6 = snd_soc_read(codec, CS4270_MUTE); if (mute) - reg6 |= CS4270_MUTE_ADC_A | CS4270_MUTE_ADC_B | - CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B; + reg6 |= CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B; else - reg6 &= ~(CS4270_MUTE_ADC_A | CS4270_MUTE_ADC_B | - CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B); + reg6 &= ~(CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B); return snd_soc_write(codec, CS4270_MUTE, reg6); } -#else -#define cs4270_mute NULL -#endif /* A list of non-DAPM controls that the CS4270 supports */ static const struct snd_kcontrol_new cs4270_snd_controls[] = { SOC_DOUBLE_R("Master Playback Volume", - CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1) + CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1), + SOC_SINGLE("Digital Sidetone Switch", CS4270_FORMAT, 5, 1, 0), + SOC_SINGLE("Soft Ramp Switch", CS4270_TRANS, 6, 1, 0), + SOC_SINGLE("Zero Cross Switch", CS4270_TRANS, 5, 1, 0), + SOC_SINGLE("Popguard Switch", CS4270_MODE, 0, 1, 1), + SOC_SINGLE("Auto-Mute Switch", CS4270_MUTE, 5, 1, 0), + SOC_DOUBLE("Master Capture Switch", CS4270_MUTE, 3, 4, 1, 0) }; /* @@ -637,6 +595,7 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, { struct snd_soc_codec *codec; struct cs4270_private *cs4270; + unsigned int reg; int ret; /* For now, we only support one cs4270 device in the system. See the @@ -702,6 +661,34 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, goto error_free_codec; } + /* Disable auto-mute. This feature appears to be buggy. In some + * situations, auto-mute will not deactivate when it should, so we want + * this feature disabled by default. An application (e.g. alsactl) can + * re-enabled it by using the controls. + */ + + reg = cs4270_read_reg_cache(codec, CS4270_MUTE); + reg &= ~CS4270_MUTE_AUTO; + ret = cs4270_i2c_write(codec, CS4270_MUTE, reg); + if (ret < 0) { + dev_err(&i2c_client->dev, "i2c write failed\n"); + return ret; + } + + /* Disable automatic volume control. The hardware enables, and it + * causes volume change commands to be delayed, sometimes until after + * playback has started. An application (e.g. alsactl) can + * re-enabled it by using the controls. + */ + + reg = cs4270_read_reg_cache(codec, CS4270_TRANS); + reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO); + ret = cs4270_i2c_write(codec, CS4270_TRANS, reg); + if (ret < 0) { + dev_err(&i2c_client->dev, "i2c write failed\n"); + return ret; + } + /* Initialize the DAI. Normally, we'd prefer to have a kmalloc'd DAI * structure for each CS4270 device, but the machine driver needs to * have a pointer to the DAI structure, so for now it must be a global -- cgit v1.2.3 From bf3dbe5c8c4b85f98c36d35432efa6573b75e6d3 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Fri, 13 Feb 2009 11:36:37 -0800 Subject: ASoC: Fix DaVinci module unload error Fix for the error when the audio module is unloaded. On unregistering the platform_device, platform_device_release will free the platform data.If platform data is static the kernel panics when it is freed. Instead use the platform device helper function to add data. This change has been tested on DM644x EVM, DM644x SFFSDR and DM355 EVM. Signed-off-by: Chaithrika U S Signed-off-by: Kevin Hilman Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-evm.c | 3 ++- sound/soc/davinci/davinci-sffsdr.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 54851f31856..9b90b347007 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -186,7 +186,8 @@ static int __init evm_init(void) platform_set_drvdata(evm_snd_device, &evm_snd_devdata); evm_snd_devdata.dev = &evm_snd_device->dev; - evm_snd_device->dev.platform_data = &evm_snd_data; + platform_device_add_data(evm_snd_device, &evm_snd_data, + sizeof(evm_snd_data)); ret = platform_device_add_resources(evm_snd_device, evm_snd_resources, ARRAY_SIZE(evm_snd_resources)); diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c index 50baef1fe5b..0bf81abba8c 100644 --- a/sound/soc/davinci/davinci-sffsdr.c +++ b/sound/soc/davinci/davinci-sffsdr.c @@ -141,7 +141,8 @@ static int __init sffsdr_init(void) platform_set_drvdata(sffsdr_snd_device, &sffsdr_snd_devdata); sffsdr_snd_devdata.dev = &sffsdr_snd_device->dev; - sffsdr_snd_device->dev.platform_data = &sffsdr_snd_data; + platform_device_add_data(sffsdr_snd_device, &sffsdr_snd_data, + sizeof(sffsdr_snd_data)); ret = platform_device_add_resources(sffsdr_snd_device, sffsdr_snd_resources, -- cgit v1.2.3 From 31b59cf9cebb5bb675f49fe44814bbb7270374cc Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Mon, 16 Feb 2009 02:49:41 +0300 Subject: ASoC: Fix WM8753 DAIs unregistering WM8753 uses a tricky way to switch DAIs "on the fly", for that it registers 2 dummy DAIs and substitutes them depending on mixer control. List element of registered dummy DAIs should be preserved to allow unregistering of DAIs on module unload. Signed-off-by: Paul Fertser Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 6f9e6beabb1..dc6042c6424 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1451,30 +1451,35 @@ static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode) if (mode < 4) { int playback_active, capture_active, codec_active, pop_wait; void *private_data; + struct list_head list; playback_active = wm8753_dai[0].playback.active; capture_active = wm8753_dai[0].capture.active; codec_active = wm8753_dai[0].active; private_data = wm8753_dai[0].private_data; pop_wait = wm8753_dai[0].pop_wait; + list = wm8753_dai[0].list; wm8753_dai[0] = wm8753_all_dai[mode << 1]; wm8753_dai[0].playback.active = playback_active; wm8753_dai[0].capture.active = capture_active; wm8753_dai[0].active = codec_active; wm8753_dai[0].private_data = private_data; wm8753_dai[0].pop_wait = pop_wait; + wm8753_dai[0].list = list; playback_active = wm8753_dai[1].playback.active; capture_active = wm8753_dai[1].capture.active; codec_active = wm8753_dai[1].active; private_data = wm8753_dai[1].private_data; pop_wait = wm8753_dai[1].pop_wait; + list = wm8753_dai[1].list; wm8753_dai[1] = wm8753_all_dai[(mode << 1) + 1]; wm8753_dai[1].playback.active = playback_active; wm8753_dai[1].capture.active = capture_active; wm8753_dai[1].active = codec_active; wm8753_dai[1].private_data = private_data; wm8753_dai[1].pop_wait = pop_wait; + wm8753_dai[1].list = list; } wm8753_dai[0].codec = codec; wm8753_dai[1].codec = codec; -- cgit v1.2.3 From 7b317b692a03a870d7acda0a0bd4d211f1c064fe Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 14:08:22 +0000 Subject: ASoC: Remove version display from the WM8731 driver It makes boot a bit more noisy and I never remember to update it. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 0150fe53a65..816e5bf9edc 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -29,8 +29,6 @@ #include "wm8731.h" -#define WM8731_VERSION "0.13" - struct snd_soc_codec_device soc_codec_dev_wm8731; /* codec private data */ @@ -702,8 +700,6 @@ static int wm8731_probe(struct platform_device *pdev) struct wm8731_priv *wm8731; int ret = 0; - pr_info("WM8731 Audio Codec %s", WM8731_VERSION); - setup = socdev->codec_data; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) -- cgit v1.2.3 From 22d22ee5146ae823b1e93fe2887a7cba56015091 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 19:20:15 +0000 Subject: ASoC: Clean up WM8731 bias level configuration The WM8731 bias level configuration function was written slightly obscurely - streamline the code a little and refresh the comments. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 816e5bf9edc..c6db6779377 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -396,21 +396,19 @@ static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8731_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - u16 reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f; + u16 reg; switch (level) { case SND_SOC_BIAS_ON: - /* vref/mid, osc on, dac unmute */ - wm8731_write(codec, WM8731_PWR, reg); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - /* everything off except vref/vmid, */ + /* Clear PWROFF, gate CLKOUT, everything else as-is */ + reg = wm8731_read_reg_cache(codec, WM8731_PWR) & 0xff7f; wm8731_write(codec, WM8731_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: - /* everything off, dac mute, inactive */ wm8731_write(codec, WM8731_ACTIVE, 0x0); wm8731_write(codec, WM8731_PWR, 0xffff); break; -- cgit v1.2.3 From d6943541158985030108e4a0a483cdadc3c80ee1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 13:38:11 +0000 Subject: ASoC: Improve diagnostics for AT91SAM9G20-EK probe We should display an error by default if we fail to register. Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 6ea04be911d..be3f923d3c4 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -273,6 +273,7 @@ static int __init at91sam9g20ek_init(void) */ ssc = ssc_request(0); if (IS_ERR(ssc)) { + printk(KERN_ERR "ASoC: Failed to request SSC 0\n"); ret = PTR_ERR(ssc); ssc = NULL; goto err_ssc; @@ -281,8 +282,7 @@ static int __init at91sam9g20ek_init(void) at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); if (!at91sam9g20ek_snd_device) { - printk(KERN_DEBUG - "platform device allocation failed\n"); + printk(KERN_ERR "ASoC: Platform device allocation failed\n"); ret = -ENOMEM; } @@ -292,8 +292,7 @@ static int __init at91sam9g20ek_init(void) ret = platform_device_add(at91sam9g20ek_snd_device); if (ret) { - printk(KERN_DEBUG - "platform device allocation failed\n"); + printk(KERN_ERR "ASoC: Platform device allocation failed\n"); platform_device_put(at91sam9g20ek_snd_device); } -- cgit v1.2.3 From 40135ea07190316a789b2edfbf7c8131598bdf81 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 16:04:05 +0000 Subject: ASoC: Check machine type before loading on AT91SAM9G20-EK Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index be3f923d3c4..b7efdc8119d 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -268,6 +269,9 @@ static int __init at91sam9g20ek_init(void) struct ssc_device *ssc = NULL; int ret; + if (!machine_is_at91sam9g20ek()) + return -ENODEV; + /* * Request SSC device */ -- cgit v1.2.3 From 5de7f9b20069257aa5f0bb74723c8603adc5841a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 17:51:54 +0000 Subject: ASoC: Actively manage MCLK for AT91SAM9G20-EK We have software control of the MCLK for the WM8731 so save a bit of power by actively managing it within the machine driver, enabling it only while the codec is active. Once ASoC supports multiple boards and doesn't require the soc-audio device the initial clock setup should be pushed down into the arch/arm code but for now this reduces merge issues. Tested-by: Sedji Gaouaou Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 68 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index b7efdc8119d..ab32514a858 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -53,6 +53,9 @@ #include "atmel-pcm.h" #include "atmel_ssc_dai.h" +#define MCLK_RATE 12000000 + +static struct clk *mclk; static int at91sam9g20ek_startup(struct snd_pcm_substream *substream) { @@ -60,11 +63,12 @@ static int at91sam9g20ek_startup(struct snd_pcm_substream *substream) struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; int ret; - /* codec system clock is supplied by PCK0, set to 12MHz */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK, - 12000000, SND_SOC_CLOCK_IN); - if (ret < 0) + MCLK_RATE, SND_SOC_CLOCK_IN); + if (ret < 0) { + clk_disable(mclk); return ret; + } return 0; } @@ -190,6 +194,31 @@ static struct snd_soc_ops at91sam9g20ek_ops = { .shutdown = at91sam9g20ek_shutdown, }; +static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card, + enum snd_soc_bias_level level) +{ + static int mclk_on; + int ret = 0; + + switch (level) { + case SND_SOC_BIAS_ON: + case SND_SOC_BIAS_PREPARE: + if (!mclk_on) + ret = clk_enable(mclk); + if (ret == 0) + mclk_on = 1; + break; + + case SND_SOC_BIAS_OFF: + case SND_SOC_BIAS_STANDBY: + if (mclk_on) + clk_disable(mclk); + mclk_on = 0; + break; + } + + return ret; +} static const struct snd_soc_dapm_widget at91sam9g20ek_dapm_widgets[] = { SND_SOC_DAPM_MIC("Int Mic", NULL), @@ -248,6 +277,7 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = { .platform = &atmel_soc_platform, .dai_link = &at91sam9g20ek_dai, .num_links = 1, + .set_bias_level = at91sam9g20ek_set_bias_level, }; static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = { @@ -267,11 +297,37 @@ static int __init at91sam9g20ek_init(void) { struct atmel_ssc_info *ssc_p = at91sam9g20ek_dai.cpu_dai->private_data; struct ssc_device *ssc = NULL; + struct clk *pllb; int ret; if (!machine_is_at91sam9g20ek()) return -ENODEV; + /* + * Codec MCLK is supplied by PCK0 - set it up. + */ + mclk = clk_get(NULL, "pck0"); + if (IS_ERR(mclk)) { + printk(KERN_ERR "ASoC: Failed to get MCLK\n"); + ret = PTR_ERR(mclk); + goto err; + } + + pllb = clk_get(NULL, "pllb"); + if (IS_ERR(mclk)) { + printk(KERN_ERR "ASoC: Failed to get PLLB\n"); + ret = PTR_ERR(mclk); + goto err_mclk; + } + ret = clk_set_parent(mclk, pllb); + clk_put(pllb); + if (ret != 0) { + printk(KERN_ERR "ASoC: Failed to set MCLK parent\n"); + goto err_mclk; + } + + clk_set_rate(mclk, MCLK_RATE); + /* * Request SSC device */ @@ -303,6 +359,10 @@ static int __init at91sam9g20ek_init(void) return ret; err_ssc: +err_mclk: + clk_put(mclk); + mclk = NULL; +err: return ret; } @@ -320,6 +380,8 @@ static void __exit at91sam9g20ek_exit(void) platform_device_unregister(at91sam9g20ek_snd_device); at91sam9g20ek_snd_device = NULL; + clk_put(mclk); + mclk = NULL; } module_init(at91sam9g20ek_init); -- cgit v1.2.3 From 7ee753804185eb0a46ac964fd6a6564bd67290c9 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 18:00:58 +0000 Subject: ASoC: Rename AT91SAMG20-EK for applications This is a bit more idiomatic and makes identifying a configuration based on the board type work better. Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index ab32514a858..aa524235fd9 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -273,7 +273,7 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = { }; static struct snd_soc_card snd_soc_at91sam9g20ek = { - .name = "WM8731", + .name = "AT91SAMG20-EK", .platform = &atmel_soc_platform, .dai_link = &at91sam9g20ek_dai, .num_links = 1, -- cgit v1.2.3 From a8035c8f04477895207b92915b908344749be336 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 19:35:43 +0000 Subject: ASoC: Shuffle WM8731 SPI and I2C device registration This is a pure code motion patch intended to improve reviewability of a following patch moving WM8731 to use more standard device registration. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 215 ++++++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 103 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index c6db6779377..3ff971aeba2 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -36,6 +36,11 @@ struct wm8731_priv { unsigned int sysclk; }; +#ifdef CONFIG_SPI_MASTER +static int wm8731_spi_write(struct spi_device *spi, const char *data, int len); +static struct spi_driver wm8731_spi_driver; +#endif + /* * wm8731 register cache * We can't read the WM8731 register space when we are @@ -544,54 +549,9 @@ pcm_err: static struct snd_soc_device *wm8731_socdev; -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - -/* - * WM8731 2 wire address is determined by GPIO5 - * state during powerup. - * low = 0x1a - * high = 0x1b - */ - -static int wm8731_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; - - i2c_set_clientdata(i2c, codec); - codec->control_data = i2c; - - ret = wm8731_init(socdev); - if (ret < 0) - pr_err("failed to initialise WM8731\n"); - - return ret; -} -static int wm8731_i2c_remove(struct i2c_client *client) -{ - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); - return 0; -} - -static const struct i2c_device_id wm8731_i2c_id[] = { - { "wm8731", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id); - -static struct i2c_driver wm8731_i2c_driver = { - .driver = { - .name = "WM8731 I2C Codec", - .owner = THIS_MODULE, - }, - .probe = wm8731_i2c_probe, - .remove = wm8731_i2c_remove, - .id_table = wm8731_i2c_id, -}; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) +static struct i2c_driver wm8731_i2c_driver; static int wm8731_add_i2c_device(struct platform_device *pdev, const struct wm8731_setup_data *setup) @@ -634,62 +594,6 @@ err_driver: } #endif -#if defined(CONFIG_SPI_MASTER) -static int __devinit wm8731_spi_probe(struct spi_device *spi) -{ - struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; - - codec->control_data = spi; - - ret = wm8731_init(socdev); - if (ret < 0) - dev_err(&spi->dev, "failed to initialise WM8731\n"); - - return ret; -} - -static int __devexit wm8731_spi_remove(struct spi_device *spi) -{ - return 0; -} - -static struct spi_driver wm8731_spi_driver = { - .driver = { - .name = "wm8731", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = wm8731_spi_probe, - .remove = __devexit_p(wm8731_spi_remove), -}; - -static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) -{ - struct spi_transfer t; - struct spi_message m; - u8 msg[2]; - - if (len <= 0) - return 0; - - msg[0] = data[0]; - msg[1] = data[1]; - - spi_message_init(&m); - memset(&t, 0, (sizeof t)); - - t.tx_buf = &msg[0]; - t.len = len; - - spi_message_add_tail(&t, &m); - spi_sync(spi, &m); - - return len; -} -#endif /* CONFIG_SPI_MASTER */ - static int wm8731_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); @@ -772,6 +676,111 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); +#if defined(CONFIG_SPI_MASTER) +static int __devinit wm8731_spi_probe(struct spi_device *spi) +{ + struct snd_soc_device *socdev = wm8731_socdev; + struct snd_soc_codec *codec = socdev->card->codec; + int ret; + + codec->control_data = spi; + + ret = wm8731_init(socdev); + if (ret < 0) + dev_err(&spi->dev, "failed to initialise WM8731\n"); + + return ret; +} + +static int __devexit wm8731_spi_remove(struct spi_device *spi) +{ + return 0; +} + +static struct spi_driver wm8731_spi_driver = { + .driver = { + .name = "wm8731", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, + .probe = wm8731_spi_probe, + .remove = __devexit_p(wm8731_spi_remove), +}; + +static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) +{ + struct spi_transfer t; + struct spi_message m; + u8 msg[2]; + + if (len <= 0) + return 0; + + msg[0] = data[0]; + msg[1] = data[1]; + + spi_message_init(&m); + memset(&t, 0, (sizeof t)); + + t.tx_buf = &msg[0]; + t.len = len; + + spi_message_add_tail(&t, &m); + spi_sync(spi, &m); + + return len; +} +#endif /* CONFIG_SPI_MASTER */ + +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) +/* + * WM8731 2 wire address is determined by GPIO5 + * state during powerup. + * low = 0x1a + * high = 0x1b + */ + +static int wm8731_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct snd_soc_device *socdev = wm8731_socdev; + struct snd_soc_codec *codec = socdev->card->codec; + int ret; + + i2c_set_clientdata(i2c, codec); + codec->control_data = i2c; + + ret = wm8731_init(socdev); + if (ret < 0) + pr_err("failed to initialise WM8731\n"); + + return ret; +} + +static int wm8731_i2c_remove(struct i2c_client *client) +{ + struct snd_soc_codec *codec = i2c_get_clientdata(client); + kfree(codec->reg_cache); + return 0; +} + +static const struct i2c_device_id wm8731_i2c_id[] = { + { "wm8731", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id); + +static struct i2c_driver wm8731_i2c_driver = { + .driver = { + .name = "WM8731 I2C Codec", + .owner = THIS_MODULE, + }, + .probe = wm8731_i2c_probe, + .remove = wm8731_i2c_remove, + .id_table = wm8731_i2c_id, +}; +#endif + static int __init wm8731_modinit(void) { return snd_soc_register_dai(&wm8731_dai); -- cgit v1.2.3 From 5998102b9095fdb7c67755812038612afea315c5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 20:49:16 +0000 Subject: ASoC: Refactor WM8731 device registration Move the WM8731 driver to use a more standard device registration scheme where the device can be registered independantly of the ASoC probe. As a transition measure push the current manual code for registering the WM8731 into the individual machine driver probes. This allows separate patches to update the relevant architecture files with less risk of merge issues. Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 43 ++++- sound/soc/codecs/wm8731.c | 334 +++++++++++++++++---------------------- sound/soc/codecs/wm8731.h | 6 - sound/soc/pxa/corgi.c | 43 ++++- sound/soc/pxa/poodle.c | 41 ++++- 5 files changed, 256 insertions(+), 211 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index aa524235fd9..173a239a541 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -280,15 +281,41 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = { .set_bias_level = at91sam9g20ek_set_bias_level, }; -static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = { - .i2c_bus = 0, - .i2c_address = 0x1b, -}; +/* + * FIXME: This is a temporary bodge to avoid cross-tree merge issues. + * New drivers should register the wm8731 I2C device in the machine + * setup code (under arch/arm for ARM systems). + */ +static int wm8731_i2c_register(void) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x1b; + strlcpy(info.type, "wm8731", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(0); + if (!adapter) { + printk(KERN_ERR "can't get i2c adapter 0\n"); + return -ENODEV; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + printk(KERN_ERR "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + return -ENODEV; + } + + return 0; +} static struct snd_soc_device at91sam9g20ek_snd_devdata = { .card = &snd_soc_at91sam9g20ek, .codec_dev = &soc_codec_dev_wm8731, - .codec_data = &at91sam9g20ek_wm8731_setup, }; static struct platform_device *at91sam9g20ek_snd_device; @@ -340,6 +367,10 @@ static int __init at91sam9g20ek_init(void) } ssc_p->ssc = ssc; + ret = wm8731_i2c_register(); + if (ret != 0) + goto err_ssc; + at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); if (!at91sam9g20ek_snd_device) { printk(KERN_ERR "ASoC: Platform device allocation failed\n"); @@ -359,6 +390,8 @@ static int __init at91sam9g20ek_init(void) return ret; err_ssc: + ssc_free(ssc); + ssc_p->ssc = NULL; err_mclk: clk_put(mclk); mclk = NULL; diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 3ff971aeba2..a2c478e53d5 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -29,16 +29,18 @@ #include "wm8731.h" +static struct snd_soc_codec *wm8731_codec; struct snd_soc_codec_device soc_codec_dev_wm8731; /* codec private data */ struct wm8731_priv { + struct snd_soc_codec codec; + u16 reg_cache[WM8731_CACHEREGNUM]; unsigned int sysclk; }; #ifdef CONFIG_SPI_MASTER static int wm8731_spi_write(struct spi_device *spi, const char *data, int len); -static struct spi_driver wm8731_spi_driver; #endif /* @@ -485,55 +487,33 @@ static int wm8731_resume(struct platform_device *pdev) return 0; } -/* - * initialise the WM8731 driver - * register the mixer and dsp interfaces with the kernel - */ -static int wm8731_init(struct snd_soc_device *socdev) +static int wm8731_probe(struct platform_device *pdev) { - struct snd_soc_codec *codec = socdev->card->codec; - int reg, ret = 0; + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret = 0; - codec->name = "WM8731"; - codec->owner = THIS_MODULE; - codec->read = wm8731_read_reg_cache; - codec->write = wm8731_write; - codec->set_bias_level = wm8731_set_bias_level; - codec->dai = &wm8731_dai; - codec->num_dai = 1; - codec->reg_cache_size = ARRAY_SIZE(wm8731_reg); - codec->reg_cache = kmemdup(wm8731_reg, sizeof(wm8731_reg), GFP_KERNEL); - if (codec->reg_cache == NULL) - return -ENOMEM; + if (wm8731_codec == NULL) { + dev_err(&pdev->dev, "Codec device not registered\n"); + return -ENODEV; + } - wm8731_reset(codec); + socdev->card->codec = wm8731_codec; + codec = wm8731_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { - printk(KERN_ERR "wm8731: failed to create pcms\n"); + dev_err(codec->dev, "failed to create pcms: %d\n", ret); goto pcm_err; } - /* power on device */ - wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - - /* set the update bits */ - reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); - wm8731_write(codec, WM8731_LOUT1V, reg & ~0x0100); - reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V); - wm8731_write(codec, WM8731_ROUT1V, reg & ~0x0100); - reg = wm8731_read_reg_cache(codec, WM8731_LINVOL); - wm8731_write(codec, WM8731_LINVOL, reg & ~0x0100); - reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); - wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); - snd_soc_add_controls(codec, wm8731_snd_controls, - ARRAY_SIZE(wm8731_snd_controls)); + ARRAY_SIZE(wm8731_snd_controls)); wm8731_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { - printk(KERN_ERR "wm8731: failed to register card\n"); + dev_err(codec->dev, "failed to register card: %d\n", ret); goto card_err; } @@ -543,104 +523,6 @@ card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: - kfree(codec->reg_cache); - return ret; -} - -static struct snd_soc_device *wm8731_socdev; - - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -static struct i2c_driver wm8731_i2c_driver; - -static int wm8731_add_i2c_device(struct platform_device *pdev, - const struct wm8731_setup_data *setup) -{ - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; - int ret; - - ret = i2c_add_driver(&wm8731_i2c_driver); - if (ret != 0) { - dev_err(&pdev->dev, "can't add i2c driver\n"); - return ret; - } - - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = setup->i2c_address; - strlcpy(info.type, "wm8731", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(setup->i2c_bus); - if (!adapter) { - dev_err(&pdev->dev, "can't get i2c adapter %d\n", - setup->i2c_bus); - goto err_driver; - } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - goto err_driver; - } - - return 0; - -err_driver: - i2c_del_driver(&wm8731_i2c_driver); - return -ENODEV; -} -#endif - -static int wm8731_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct wm8731_setup_data *setup; - struct snd_soc_codec *codec; - struct wm8731_priv *wm8731; - int ret = 0; - - setup = socdev->codec_data; - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) - return -ENOMEM; - - wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); - if (wm8731 == NULL) { - kfree(codec); - return -ENOMEM; - } - - codec->private_data = wm8731; - socdev->card->codec = codec; - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - - wm8731_socdev = socdev; - ret = -ENODEV; - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - if (setup->i2c_address) { - codec->hw_write = (hw_write_t)i2c_master_send; - ret = wm8731_add_i2c_device(pdev, setup); - } -#endif -#if defined(CONFIG_SPI_MASTER) - if (setup->spi) { - codec->hw_write = (hw_write_t)wm8731_spi_write; - ret = spi_register_driver(&wm8731_spi_driver); - if (ret != 0) - printk(KERN_ERR "can't add spi driver"); - } -#endif - - if (ret != 0) { - kfree(codec->private_data); - kfree(codec); - } return ret; } @@ -648,22 +530,9 @@ static int wm8731_probe(struct platform_device *pdev) static int wm8731_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->card->codec; - - if (codec->control_data) - wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - i2c_unregister_device(codec->control_data); - i2c_del_driver(&wm8731_i2c_driver); -#endif -#if defined(CONFIG_SPI_MASTER) - spi_unregister_driver(&wm8731_spi_driver); -#endif - kfree(codec->private_data); - kfree(codec); return 0; } @@ -676,37 +545,78 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); -#if defined(CONFIG_SPI_MASTER) -static int __devinit wm8731_spi_probe(struct spi_device *spi) +static int wm8731_register(struct wm8731_priv *wm8731) { - struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->card->codec; int ret; + struct snd_soc_codec *codec = &wm8731->codec; + u16 reg; - codec->control_data = spi; + if (wm8731_codec) { + dev_err(codec->dev, "Another WM8731 is registered\n"); + return -EINVAL; + } - ret = wm8731_init(socdev); - if (ret < 0) - dev_err(&spi->dev, "failed to initialise WM8731\n"); + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); - return ret; -} + codec->private_data = wm8731; + codec->name = "WM8731"; + codec->owner = THIS_MODULE; + codec->read = wm8731_read_reg_cache; + codec->write = wm8731_write; + codec->bias_level = SND_SOC_BIAS_OFF; + codec->set_bias_level = wm8731_set_bias_level; + codec->dai = &wm8731_dai; + codec->num_dai = 1; + codec->reg_cache_size = WM8731_CACHEREGNUM; + codec->reg_cache = &wm8731->reg_cache; + + memcpy(codec->reg_cache, wm8731_reg, sizeof(wm8731_reg)); + + wm8731_dai.dev = codec->dev; + + wm8731_reset(codec); + wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + + /* Latch the update bits */ + reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); + wm8731_write(codec, WM8731_LOUT1V, reg & ~0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V); + wm8731_write(codec, WM8731_ROUT1V, reg & ~0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_LINVOL); + wm8731_write(codec, WM8731_LINVOL, reg & ~0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); + wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); + + wm8731_codec = codec; + + ret = snd_soc_register_codec(codec); + if (ret != 0) { + dev_err(codec->dev, "Failed to register codec: %d\n", ret); + return ret; + } + + ret = snd_soc_register_dai(&wm8731_dai); + if (ret != 0) { + dev_err(codec->dev, "Failed to register DAI: %d\n", ret); + snd_soc_unregister_codec(codec); + return ret; + } -static int __devexit wm8731_spi_remove(struct spi_device *spi) -{ return 0; } -static struct spi_driver wm8731_spi_driver = { - .driver = { - .name = "wm8731", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = wm8731_spi_probe, - .remove = __devexit_p(wm8731_spi_remove), -}; +static void wm8731_unregister(struct wm8731_priv *wm8731) +{ + wm8731_set_bias_level(&wm8731->codec, SND_SOC_BIAS_OFF); + snd_soc_unregister_dai(&wm8731_dai); + snd_soc_unregister_codec(&wm8731->codec); + kfree(wm8731); + wm8731_codec = NULL; +} +#if defined(CONFIG_SPI_MASTER) static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) { struct spi_transfer t; @@ -730,37 +640,67 @@ static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) return len; } + +static int __devinit wm8731_spi_probe(struct spi_device *spi) +{ + struct snd_soc_codec *codec; + struct wm8731_priv *wm8731; + + wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); + if (wm8731 == NULL) + return -ENOMEM; + + codec = &wm8731->codec; + codec->control_data = spi; + codec->hw_write = (hw_write_t)wm8731_spi_write; + codec->dev = &spi->dev; + + return wm8731_register(wm8731); +} + +static int __devexit wm8731_spi_remove(struct spi_device *spi) +{ + /* FIXME: This isn't actually implemented... */ + return 0; +} + +static struct spi_driver wm8731_spi_driver = { + .driver = { + .name = "wm8731", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, + .probe = wm8731_spi_probe, + .remove = __devexit_p(wm8731_spi_remove), +}; #endif /* CONFIG_SPI_MASTER */ #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -/* - * WM8731 2 wire address is determined by GPIO5 - * state during powerup. - * low = 0x1a - * high = 0x1b - */ - static int wm8731_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; + struct wm8731_priv *wm8731; + struct snd_soc_codec *codec; - i2c_set_clientdata(i2c, codec); + wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); + if (wm8731 == NULL) + return -ENOMEM; + + codec = &wm8731->codec; + codec->hw_write = (hw_write_t)i2c_master_send; + + i2c_set_clientdata(i2c, wm8731); codec->control_data = i2c; - ret = wm8731_init(socdev); - if (ret < 0) - pr_err("failed to initialise WM8731\n"); + codec->dev = &i2c->dev; - return ret; + return wm8731_register(wm8731); } static int wm8731_i2c_remove(struct i2c_client *client) { - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); + struct wm8731_priv *wm8731 = i2c_get_clientdata(client); + wm8731_unregister(wm8731); return 0; } @@ -783,13 +723,33 @@ static struct i2c_driver wm8731_i2c_driver = { static int __init wm8731_modinit(void) { - return snd_soc_register_dai(&wm8731_dai); + int ret; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + ret = i2c_add_driver(&wm8731_i2c_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register WM8731 I2C driver: %d\n", + ret); + } +#endif +#if defined(CONFIG_SPI_MASTER) + ret = spi_register_driver(&wm8731_spi_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register WM8731 SPI driver: %d\n", + ret); + } +#endif + return 0; } module_init(wm8731_modinit); static void __exit wm8731_exit(void) { - snd_soc_unregister_dai(&wm8731_dai); +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + i2c_del_driver(&wm8731_i2c_driver); +#endif +#if defined(CONFIG_SPI_MASTER) + spi_unregister_driver(&wm8731_spi_driver); +#endif } module_exit(wm8731_exit); diff --git a/sound/soc/codecs/wm8731.h b/sound/soc/codecs/wm8731.h index 95190e9c0c1..cd7b806e8ad 100644 --- a/sound/soc/codecs/wm8731.h +++ b/sound/soc/codecs/wm8731.h @@ -34,12 +34,6 @@ #define WM8731_SYSCLK 0 #define WM8731_DAI 0 -struct wm8731_setup_data { - int spi; - int i2c_bus; - unsigned short i2c_address; -}; - extern struct snd_soc_dai wm8731_dai; extern struct snd_soc_codec_device soc_codec_dev_wm8731; diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 0d41be33d57..eaa66915a32 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -317,19 +317,44 @@ static struct snd_soc_card snd_soc_corgi = { .num_links = 1, }; -/* corgi audio private data */ -static struct wm8731_setup_data corgi_wm8731_setup = { - .i2c_bus = 0, - .i2c_address = 0x1b, -}; - /* corgi audio subsystem */ static struct snd_soc_device corgi_snd_devdata = { .card = &snd_soc_corgi, .codec_dev = &soc_codec_dev_wm8731, - .codec_data = &corgi_wm8731_setup, }; +/* + * FIXME: This is a temporary bodge to avoid cross-tree merge issues. + * New drivers should register the wm8731 I2C device in the machine + * setup code (under arch/arm for ARM systems). + */ +static int wm8731_i2c_register(void) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x1b; + strlcpy(info.type, "wm8731", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(0); + if (!adapter) { + printk(KERN_ERR "can't get i2c adapter 0\n"); + return -ENODEV; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + printk(KERN_ERR "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + return -ENODEV; + } + + return 0; +} + static struct platform_device *corgi_snd_device; static int __init corgi_init(void) @@ -340,6 +365,10 @@ static int __init corgi_init(void) machine_is_husky())) return -ENODEV; + ret = wm8731_i2c_setup(); + if (ret != 0) + return ret; + corgi_snd_device = platform_device_alloc("soc-audio", -1); if (!corgi_snd_device) return -ENOMEM; diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index 3a62d4354ef..fd683a0b742 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -283,17 +283,42 @@ static struct snd_soc_card snd_soc_poodle = { .num_links = 1, }; -/* poodle audio private data */ -static struct wm8731_setup_data poodle_wm8731_setup = { - .i2c_bus = 0, - .i2c_address = 0x1b, -}; +/* + * FIXME: This is a temporary bodge to avoid cross-tree merge issues. + * New drivers should register the wm8731 I2C device in the machine + * setup code (under arch/arm for ARM systems). + */ +static int wm8731_i2c_register(void) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x1b; + strlcpy(info.type, "wm8731", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(0); + if (!adapter) { + printk(KERN_ERR "can't get i2c adapter 0\n"); + return -ENODEV; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + printk(KERN_ERR "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + return -ENODEV; + } + + return 0; +} /* poodle audio subsystem */ static struct snd_soc_device poodle_snd_devdata = { .card = &snd_soc_poodle, .codec_dev = &soc_codec_dev_wm8731, - .codec_data = &poodle_wm8731_setup, }; static struct platform_device *poodle_snd_device; @@ -305,6 +330,10 @@ static int __init poodle_init(void) if (!machine_is_poodle()) return -ENODEV; + ret = wm8731_i2c_setup(); + if (ret != 0) + return ret; + locomo_gpio_set_dir(&poodle_locomo_device.dev, POODLE_LOCOMO_GPIO_AMP_ON, 0); /* should we mute HP at startup - burning power ?*/ -- cgit v1.2.3 From 59544d33ff3118f22a484d8be06cdf5cfc2fdca5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Feb 2009 11:36:44 +0000 Subject: ASoC: Remove version display from the WM8753 driver Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index dc6042c6424..31ff337f822 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -51,8 +51,6 @@ #include "wm8753.h" -#define WM8753_VERSION "0.16" - static int caps_charge = 2000; module_param(caps_charge, int, 0); MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); @@ -1778,8 +1776,6 @@ static int wm8753_probe(struct platform_device *pdev) struct wm8753_priv *wm8753; int ret = 0; - pr_info("WM8753 Audio Codec %s", WM8753_VERSION); - setup = socdev->codec_data; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) -- cgit v1.2.3 From fc9967576829a01c98e5388410dc12c61006f79f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Feb 2009 12:34:53 +0000 Subject: ASoC: Fix build for corgi and poodle Signed-off-by: Mark Brown --- sound/soc/pxa/corgi.c | 3 ++- sound/soc/pxa/poodle.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index eaa66915a32..146973ae097 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -365,7 +366,7 @@ static int __init corgi_init(void) machine_is_husky())) return -ENODEV; - ret = wm8731_i2c_setup(); + ret = wm8731_i2c_register(); if (ret != 0) return ret; diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index fd683a0b742..fb17a0a5a09 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -330,7 +331,7 @@ static int __init poodle_init(void) if (!machine_is_poodle()) return -ENODEV; - ret = wm8731_i2c_setup(); + ret = wm8731_i2c_register(); if (ret != 0) return ret; -- cgit v1.2.3 From 93b760b7072ca6972c15c798e97af3f830d8bbba Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Feb 2009 12:44:40 +0000 Subject: ASoC: Implement SPI device unregistration for WM8731 Completely untested. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index a2c478e53d5..4191bdb803b 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -655,12 +655,17 @@ static int __devinit wm8731_spi_probe(struct spi_device *spi) codec->hw_write = (hw_write_t)wm8731_spi_write; codec->dev = &spi->dev; + spi->dev.driver_data = wm8731; + return wm8731_register(wm8731); } static int __devexit wm8731_spi_remove(struct spi_device *spi) { - /* FIXME: This isn't actually implemented... */ + struct wm8731_priv *wm8731 = spi->dev.driver_data; + + wm8731_unregister(wm8731); + return 0; } -- cgit v1.2.3 From 6bab83fd886564e96abcff62862732159535f600 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 18 Feb 2009 14:39:05 +0200 Subject: ASoC: TWL4030: Add digital loopback support This patch adds the digital loopback/bypass support for twl4030 codec. The digital loopback will let the digimic0 (routed in the TX1 capture path inside of TWL4030) data to be routed back to the RX2 playback path (I2S stereo). It can also route the analog capture date routed through the TX1 back to RX2. Effectively the digital loopback is routing the audio from the TX1 capture path to the RX2 playback path. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 56 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index c26854b398d..535d8ce2c32 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -504,6 +504,25 @@ static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control = static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0); +/* Digital bypass gain, 0 mutes the bypass */ +static const unsigned int twl4030_dapm_dbypass_tlv[] = { + TLV_DB_RANGE_HEAD(2), + 0, 3, TLV_DB_SCALE_ITEM(-2400, 0, 1), + 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0), +}; + +/* Digital bypass left (TX1L -> RX2L) */ +static const struct snd_kcontrol_new twl4030_dapm_dbypassl_control = + SOC_DAPM_SINGLE_TLV("Volume", + TWL4030_REG_ATX2ARXPGA, 3, 7, 0, + twl4030_dapm_dbypass_tlv); + +/* Digital bypass right (TX1R -> RX2R) */ +static const struct snd_kcontrol_new twl4030_dapm_dbypassr_control = + SOC_DAPM_SINGLE_TLV("Volume", + TWL4030_REG_ATX2ARXPGA, 0, 7, 0, + twl4030_dapm_dbypass_tlv); + static int micpath_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -608,12 +627,22 @@ static int bypass_event(struct snd_soc_dapm_widget *w, unsigned char reg; reg = twl4030_read_reg_cache(w->codec, m->reg); - if (reg & (1 << m->shift)) - twl4030->bypass_state |= - (1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); - else - twl4030->bypass_state &= - ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); + + if (m->reg <= TWL4030_REG_ARXR2_APGA_CTL) { + /* Analog bypass */ + if (reg & (1 << m->shift)) + twl4030->bypass_state |= + (1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); + else + twl4030->bypass_state &= + ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); + } else { + /* Digital bypass */ + if (reg & (0x7 << m->shift)) + twl4030->bypass_state |= (1 << (m->shift ? 5 : 4)); + else + twl4030->bypass_state &= ~(1 << (m->shift ? 5 : 4)); + } if (w->codec->bias_level == SND_SOC_BIAS_STANDBY) { if (twl4030->bypass_state) @@ -934,6 +963,14 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { &twl4030_dapm_abypassl2_control, bypass_event, SND_SOC_DAPM_POST_REG), + /* Digital bypasses */ + SND_SOC_DAPM_SWITCH_E("Left Digital Loopback", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_dbypassl_control, bypass_event, + SND_SOC_DAPM_POST_REG), + SND_SOC_DAPM_SWITCH_E("Right Digital Loopback", SND_SOC_NOPM, 0, 0, + &twl4030_dapm_dbypassr_control, bypass_event, + SND_SOC_DAPM_POST_REG), + SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer", TWL4030_REG_AVDAC_CTL, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer", TWL4030_REG_AVDAC_CTL, @@ -1118,6 +1155,13 @@ static const struct snd_soc_dapm_route intercon[] = { {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"}, {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"}, + /* Digital bypass routes */ + {"Right Digital Loopback", "Volume", "TX1 Capture Route"}, + {"Left Digital Loopback", "Volume", "TX1 Capture Route"}, + + {"Analog R2 Playback Mixer", NULL, "Right Digital Loopback"}, + {"Analog L2 Playback Mixer", NULL, "Left Digital Loopback"}, + }; static int twl4030_add_widgets(struct snd_soc_codec *codec) -- cgit v1.2.3 From 519cf2df5fb50c6d24412b2421ce2d1ff0346163 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Feb 2009 21:06:01 +0000 Subject: ASoC: Check for errors when writing WM8731 reset register Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 4191bdb803b..9c9fc3b5a6c 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -574,9 +574,14 @@ static int wm8731_register(struct wm8731_priv *wm8731) memcpy(codec->reg_cache, wm8731_reg, sizeof(wm8731_reg)); + ret = wm8731_reset(codec); + if (ret < 0) { + dev_err(codec->dev, "Failed to issue reset\n"); + return ret; + } + wm8731_dai.dev = codec->dev; - wm8731_reset(codec); wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Latch the update bits */ -- cgit v1.2.3 From c6f2981170272cce2c192087a16dd74dbde25ed2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Feb 2009 21:25:40 +0000 Subject: ASoC: Add device init/exit annotations to new-style Wolfson CODEC drivers Signed-off-by: Mark Brown --- sound/soc/codecs/wm8350.c | 2 +- sound/soc/codecs/wm8731.c | 8 ++++---- sound/soc/codecs/wm8900.c | 8 ++++---- sound/soc/codecs/wm8903.c | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index d3562788d42..359e5cc86f3 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1574,7 +1574,7 @@ struct snd_soc_codec_device soc_codec_dev_wm8350 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm8350); -static int wm8350_codec_probe(struct platform_device *pdev) +static __devinit int wm8350_codec_probe(struct platform_device *pdev) { struct wm8350 *wm8350 = platform_get_drvdata(pdev); struct wm8350_data *priv; diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 9c9fc3b5a6c..4cac3195bfa 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -686,8 +686,8 @@ static struct spi_driver wm8731_spi_driver = { #endif /* CONFIG_SPI_MASTER */ #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -static int wm8731_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static __devinit int wm8731_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) { struct wm8731_priv *wm8731; struct snd_soc_codec *codec; @@ -707,7 +707,7 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, return wm8731_register(wm8731); } -static int wm8731_i2c_remove(struct i2c_client *client) +static __devexit int wm8731_i2c_remove(struct i2c_client *client) { struct wm8731_priv *wm8731 = i2c_get_clientdata(client); wm8731_unregister(wm8731); @@ -726,7 +726,7 @@ static struct i2c_driver wm8731_i2c_driver = { .owner = THIS_MODULE, }, .probe = wm8731_i2c_probe, - .remove = wm8731_i2c_remove, + .remove = __devexit_p(wm8731_i2c_remove), .id_table = wm8731_i2c_id, }; #endif diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 85c0f1bc676..da5ca64f89b 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -1272,8 +1272,8 @@ static int wm8900_resume(struct platform_device *pdev) static struct snd_soc_codec *wm8900_codec; -static int wm8900_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static __devinit int wm8900_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) { struct wm8900_priv *wm8900; struct snd_soc_codec *codec; @@ -1372,7 +1372,7 @@ err: return ret; } -static int wm8900_i2c_remove(struct i2c_client *client) +static __devexit int wm8900_i2c_remove(struct i2c_client *client) { snd_soc_unregister_dai(&wm8900_dai); snd_soc_unregister_codec(wm8900_codec); @@ -1398,7 +1398,7 @@ static struct i2c_driver wm8900_i2c_driver = { .owner = THIS_MODULE, }, .probe = wm8900_i2c_probe, - .remove = wm8900_i2c_remove, + .remove = __devexit_p(wm8900_i2c_remove), .id_table = wm8900_i2c_id, }; diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index d36b2b1edf1..c6fa8a71b4d 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1562,8 +1562,8 @@ static int wm8903_resume(struct platform_device *pdev) static struct snd_soc_codec *wm8903_codec; -static int wm8903_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) +static __devinit int wm8903_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) { struct wm8903_priv *wm8903; struct snd_soc_codec *codec; @@ -1669,7 +1669,7 @@ err: return ret; } -static int wm8903_i2c_remove(struct i2c_client *client) +static __devexit int wm8903_i2c_remove(struct i2c_client *client) { struct snd_soc_codec *codec = i2c_get_clientdata(client); @@ -1699,7 +1699,7 @@ static struct i2c_driver wm8903_i2c_driver = { .owner = THIS_MODULE, }, .probe = wm8903_i2c_probe, - .remove = wm8903_i2c_remove, + .remove = __devexit_p(wm8903_i2c_remove), .id_table = wm8903_i2c_id, }; -- cgit v1.2.3 From ce3bdaa8710c10eec5a6dae67aaf73088d0ced4f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 19 Feb 2009 14:29:49 +0000 Subject: ASoC: Disable WM8731 line bypass by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids temporarily enabling the ouput stages during startup which can cause audible effets in the output stages. Reported-by: Fredrik Redgård Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 4cac3195bfa..9e7ebcc2c49 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -594,6 +594,10 @@ static int wm8731_register(struct wm8731_priv *wm8731) reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); + /* Disable bypass path by default */ + reg = wm8731_read_reg_cache(codec, WM8731_APANA); + wm8731_write(codec, WM8731_APANA, reg & ~0x4); + wm8731_codec = codec; ret = snd_soc_register_codec(codec); -- cgit v1.2.3 From eeb1080b29a0fa00e426ba77eb96f3a157b335ab Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 22 Feb 2009 14:19:23 +0000 Subject: ASoC: Report I/O errors from WM8753 reset Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 31ff337f822..180ec94ad8a 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1561,7 +1561,11 @@ static int wm8753_init(struct snd_soc_device *socdev) wm8753_set_dai_mode(codec, 0); - wm8753_reset(codec); + ret = wm8753_reset(codec); + if (ret < 0) { + printk(KERN_ERR "wm8753: failed to reset device\n"); + return ret; + } /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); -- cgit v1.2.3 From 93e051d2771e6bf70e86b8265bfbf296a457d044 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 22 Feb 2009 14:24:00 +0000 Subject: ASoC: Only unregister drivers we registered for WM8753 Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 180ec94ad8a..93c22c4f082 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1845,6 +1845,7 @@ static int wm8753_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; + struct wm8753_setup_data *setup = socdev->codec_data; if (codec->control_data) wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF); @@ -1852,11 +1853,14 @@ static int wm8753_remove(struct platform_device *pdev) snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - i2c_unregister_device(codec->control_data); - i2c_del_driver(&wm8753_i2c_driver); + if (setup->i2c_address) { + i2c_unregister_device(codec->control_data); + i2c_del_driver(&wm8753_i2c_driver); + } #endif #if defined(CONFIG_SPI_MASTER) - spi_unregister_driver(&wm8753_spi_driver); + if (setup->spi) + spi_unregister_driver(&wm8753_spi_driver); #endif kfree(codec->private_data); kfree(codec); -- cgit v1.2.3 From 8056d9bbb57207854462b6b0a3a75d172300cce5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 23 Jan 2009 14:44:54 +0000 Subject: ASoC: Improve WM9713 voice DAC shutdown procedure Signed-off-by: Mark Brown --- sound/soc/codecs/wm9713.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 54db9c52498..a93aea5c187 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -940,13 +940,14 @@ static void wm9713_voiceshutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; - u16 status; + u16 status, rate; /* Gracefully shut down the voice interface. */ status = ac97_read(codec, AC97_EXTENDED_STATUS) | 0x1000; - ac97_write(codec, AC97_HANDSET_RATE, 0x0280); + rate = ac97_read(codec, AC97_HANDSET_RATE) & 0xF0FF; + ac97_write(codec, AC97_HANDSET_RATE, rate | 0x0200); schedule_timeout_interruptible(msecs_to_jiffies(1)); - ac97_write(codec, AC97_HANDSET_RATE, 0x0F80); + ac97_write(codec, AC97_HANDSET_RATE, rate | 0x0F00); ac97_write(codec, AC97_EXTENDED_MID, status); } -- cgit v1.2.3 From d3b894218441ecb1c83e47c682e2d6589ee37a8d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 23 Feb 2009 18:45:19 +0000 Subject: ASoC: Fix Zylonite voice interface stereo configurations We always run in the first timeslot of one. Signed-off-by: Mark Brown --- sound/soc/pxa/zylonite.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c index ec2fb764b24..0140a250db2 100644 --- a/sound/soc/pxa/zylonite.c +++ b/sound/soc/pxa/zylonite.c @@ -127,9 +127,8 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - ret = snd_soc_dai_set_tdm_slot(cpu_dai, - params_channels(params), - params_channels(params)); + /* We're not really in network mode but the emulation wants this. */ + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1); if (ret < 0) return ret; -- cgit v1.2.3 From 69e169da5a69cc991d54bb4d54f236523145756c Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 22 Feb 2009 14:39:03 +0000 Subject: ASoC: Shuffle WM8753 device registration code This patch should be pure code motion, separating that out from the functional changes to move to new style device registration. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 209 +++++++++++++++++++++++----------------------- 1 file changed, 105 insertions(+), 104 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 93c22c4f082..4b426888f98 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -51,6 +51,11 @@ #include "wm8753.h" +#ifdef CONFIG_SPI_MASTER +static struct spi_driver wm8753_spi_driver; +static int wm8753_spi_write(struct spi_device *spi, const char *data, int len); +#endif + static int caps_charge = 2000; module_param(caps_charge, int, 0); MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); @@ -1626,53 +1631,7 @@ pcm_err: static struct snd_soc_device *wm8753_socdev; #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - -/* - * WM8753 2 wire address is determined by GPIO5 - * state during powerup. - * low = 0x1a - * high = 0x1b - */ - -static int wm8753_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct snd_soc_device *socdev = wm8753_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; - - i2c_set_clientdata(i2c, codec); - codec->control_data = i2c; - - ret = wm8753_init(socdev); - if (ret < 0) - pr_err("failed to initialise WM8753\n"); - - return ret; -} - -static int wm8753_i2c_remove(struct i2c_client *client) -{ - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); - return 0; -} - -static const struct i2c_device_id wm8753_i2c_id[] = { - { "wm8753", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id); - -static struct i2c_driver wm8753_i2c_driver = { - .driver = { - .name = "WM8753 I2C Codec", - .owner = THIS_MODULE, - }, - .probe = wm8753_i2c_probe, - .remove = wm8753_i2c_remove, - .id_table = wm8753_i2c_id, -}; +static struct i2c_driver wm8753_i2c_driver; static int wm8753_add_i2c_device(struct platform_device *pdev, const struct wm8753_setup_data *setup) @@ -1715,63 +1674,6 @@ err_driver: } #endif -#if defined(CONFIG_SPI_MASTER) -static int __devinit wm8753_spi_probe(struct spi_device *spi) -{ - struct snd_soc_device *socdev = wm8753_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; - - codec->control_data = spi; - - ret = wm8753_init(socdev); - if (ret < 0) - dev_err(&spi->dev, "failed to initialise WM8753\n"); - - return ret; -} - -static int __devexit wm8753_spi_remove(struct spi_device *spi) -{ - return 0; -} - -static struct spi_driver wm8753_spi_driver = { - .driver = { - .name = "wm8753", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = wm8753_spi_probe, - .remove = __devexit_p(wm8753_spi_remove), -}; - -static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) -{ - struct spi_transfer t; - struct spi_message m; - u8 msg[2]; - - if (len <= 0) - return 0; - - msg[0] = data[0]; - msg[1] = data[1]; - - spi_message_init(&m); - memset(&t, 0, (sizeof t)); - - t.tx_buf = &msg[0]; - t.len = len; - - spi_message_add_tail(&t, &m); - spi_sync(spi, &m); - - return len; -} -#endif - - static int wm8753_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); @@ -1876,6 +1778,105 @@ struct snd_soc_codec_device soc_codec_dev_wm8753 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753); +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + +static int wm8753_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct snd_soc_device *socdev = wm8753_socdev; + struct snd_soc_codec *codec = socdev->card->codec; + int ret; + + i2c_set_clientdata(i2c, codec); + codec->control_data = i2c; + + ret = wm8753_init(socdev); + if (ret < 0) + pr_err("failed to initialise WM8753\n"); + + return ret; +} + +static int wm8753_i2c_remove(struct i2c_client *client) +{ + struct snd_soc_codec *codec = i2c_get_clientdata(client); + kfree(codec->reg_cache); + return 0; +} + +static const struct i2c_device_id wm8753_i2c_id[] = { + { "wm8753", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id); + +static struct i2c_driver wm8753_i2c_driver = { + .driver = { + .name = "WM8753 I2C Codec", + .owner = THIS_MODULE, + }, + .probe = wm8753_i2c_probe, + .remove = wm8753_i2c_remove, + .id_table = wm8753_i2c_id, +}; +#endif + +#if defined(CONFIG_SPI_MASTER) +static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) +{ + struct spi_transfer t; + struct spi_message m; + u8 msg[2]; + + if (len <= 0) + return 0; + + msg[0] = data[0]; + msg[1] = data[1]; + + spi_message_init(&m); + memset(&t, 0, (sizeof t)); + + t.tx_buf = &msg[0]; + t.len = len; + + spi_message_add_tail(&t, &m); + spi_sync(spi, &m); + + return len; +} + +static int __devinit wm8753_spi_probe(struct spi_device *spi) +{ + struct snd_soc_device *socdev = wm8753_socdev; + struct snd_soc_codec *codec = socdev->card->codec; + int ret; + + codec->control_data = spi; + + ret = wm8753_init(socdev); + if (ret < 0) + dev_err(&spi->dev, "failed to initialise WM8753\n"); + + return ret; +} + +static int __devexit wm8753_spi_remove(struct spi_device *spi) +{ + return 0; +} + +static struct spi_driver wm8753_spi_driver = { + .driver = { + .name = "wm8753", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, + .probe = wm8753_spi_probe, + .remove = __devexit_p(wm8753_spi_remove), +}; +#endif + static int __init wm8753_modinit(void) { return snd_soc_register_dais(wm8753_dai, ARRAY_SIZE(wm8753_dai)); -- cgit v1.2.3 From c2bac1606a937d4700f8fdd8e051a4c49593c41b Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 24 Feb 2009 23:33:12 +0000 Subject: ASoC: Convert WM8753 to register via normal device probe The base support for the only in-tree user, the GTA01, is out of tree and will be updated separately. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 369 +++++++++++++++++-------------------- sound/soc/codecs/wm8753.h | 6 - sound/soc/s3c24xx/neo1973_wm8753.c | 6 - 3 files changed, 171 insertions(+), 210 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 4b426888f98..bc29558149e 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -63,12 +63,6 @@ MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode); -/* codec private data */ -struct wm8753_priv { - unsigned int sysclk; - unsigned int pcmclk; -}; - /* * wm8753 register cache * We can't read the WM8753 register space when we @@ -93,6 +87,14 @@ static const u16 wm8753_reg[] = { 0x0000, 0x0000 }; +/* codec private data */ +struct wm8753_priv { + unsigned int sysclk; + unsigned int pcmclk; + struct snd_soc_codec codec; + u16 reg_cache[ARRAY_SIZE(wm8753_reg)]; +}; + /* * read wm8753 register cache */ @@ -1542,36 +1544,24 @@ static int wm8753_resume(struct platform_device *pdev) return 0; } -/* - * initialise the WM8753 driver - * register the mixer and dsp interfaces with the kernel - */ -static int wm8753_init(struct snd_soc_device *socdev) +static struct snd_soc_codec *wm8753_codec; + +static int wm8753_probe(struct platform_device *pdev) { - struct snd_soc_codec *codec = socdev->card->codec; - int reg, ret = 0; + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret = 0; - codec->name = "WM8753"; - codec->owner = THIS_MODULE; - codec->read = wm8753_read_reg_cache; - codec->write = wm8753_write; - codec->set_bias_level = wm8753_set_bias_level; - codec->dai = wm8753_dai; - codec->num_dai = 2; - codec->reg_cache_size = ARRAY_SIZE(wm8753_reg); - codec->reg_cache = kmemdup(wm8753_reg, sizeof(wm8753_reg), GFP_KERNEL); + if (!wm8753_codec) { + dev_err(&pdev->dev, "WM8753 codec not yet registered\n"); + return -EINVAL; + } - if (codec->reg_cache == NULL) - return -ENOMEM; + socdev->card->codec = wm8753_codec; + codec = wm8753_codec; wm8753_set_dai_mode(codec, 0); - ret = wm8753_reset(codec); - if (ret < 0) { - printk(KERN_ERR "wm8753: failed to reset device\n"); - return ret; - } - /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { @@ -1579,36 +1569,7 @@ static int wm8753_init(struct snd_soc_device *socdev) goto pcm_err; } - /* charge output caps */ - wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE); - codec->bias_level = SND_SOC_BIAS_STANDBY; - schedule_delayed_work(&codec->delayed_work, - msecs_to_jiffies(caps_charge)); - - /* set the update bits */ - reg = wm8753_read_reg_cache(codec, WM8753_LDAC); - wm8753_write(codec, WM8753_LDAC, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_RDAC); - wm8753_write(codec, WM8753_RDAC, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_LADC); - wm8753_write(codec, WM8753_LADC, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_RADC); - wm8753_write(codec, WM8753_RADC, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_LOUT1V); - wm8753_write(codec, WM8753_LOUT1V, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_ROUT1V); - wm8753_write(codec, WM8753_ROUT1V, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_LOUT2V); - wm8753_write(codec, WM8753_LOUT2V, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_ROUT2V); - wm8753_write(codec, WM8753_ROUT2V, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_LINVOL); - wm8753_write(codec, WM8753_LINVOL, reg | 0x0100); - reg = wm8753_read_reg_cache(codec, WM8753_RINVOL); - wm8753_write(codec, WM8753_RINVOL, reg | 0x0100); - - snd_soc_add_controls(codec, wm8753_snd_controls, - ARRAY_SIZE(wm8753_snd_controls)); + wm8753_add_controls(codec); wm8753_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { @@ -1616,110 +1577,13 @@ static int wm8753_init(struct snd_soc_device *socdev) goto card_err; } - return ret; + return 0; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); -pcm_err: - kfree(codec->reg_cache); - return ret; -} - -/* If the i2c layer weren't so broken, we could pass this kind of data - around */ -static struct snd_soc_device *wm8753_socdev; - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -static struct i2c_driver wm8753_i2c_driver; - -static int wm8753_add_i2c_device(struct platform_device *pdev, - const struct wm8753_setup_data *setup) -{ - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; - int ret; - - ret = i2c_add_driver(&wm8753_i2c_driver); - if (ret != 0) { - dev_err(&pdev->dev, "can't add i2c driver\n"); - return ret; - } - - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = setup->i2c_address; - strlcpy(info.type, "wm8753", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(setup->i2c_bus); - if (!adapter) { - dev_err(&pdev->dev, "can't get i2c adapter %d\n", - setup->i2c_bus); - goto err_driver; - } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - goto err_driver; - } - - return 0; - -err_driver: - i2c_del_driver(&wm8753_i2c_driver); - return -ENODEV; -} -#endif - -static int wm8753_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct wm8753_setup_data *setup; - struct snd_soc_codec *codec; - struct wm8753_priv *wm8753; - int ret = 0; - - setup = socdev->codec_data; - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) - return -ENOMEM; - - wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL); - if (wm8753 == NULL) { - kfree(codec); - return -ENOMEM; - } - - codec->private_data = wm8753; - socdev->card->codec = codec; - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - wm8753_socdev = socdev; - INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work); - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - if (setup->i2c_address) { - codec->hw_write = (hw_write_t)i2c_master_send; - ret = wm8753_add_i2c_device(pdev, setup); - } -#endif -#if defined(CONFIG_SPI_MASTER) - if (setup->spi) { - codec->hw_write = (hw_write_t)wm8753_spi_write; - ret = spi_register_driver(&wm8753_spi_driver); - if (ret != 0) - printk(KERN_ERR "can't add spi driver"); - } -#endif - if (ret != 0) { - kfree(codec->private_data); - kfree(codec); - } +pcm_err: return ret; } @@ -1746,26 +1610,9 @@ static int run_delayed_work(struct delayed_work *dwork) static int wm8753_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->card->codec; - struct wm8753_setup_data *setup = socdev->codec_data; - if (codec->control_data) - wm8753_set_bias_level(codec, SND_SOC_BIAS_OFF); - run_delayed_work(&codec->delayed_work); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - if (setup->i2c_address) { - i2c_unregister_device(codec->control_data); - i2c_del_driver(&wm8753_i2c_driver); - } -#endif -#if defined(CONFIG_SPI_MASTER) - if (setup->spi) - spi_unregister_driver(&wm8753_spi_driver); -#endif - kfree(codec->private_data); - kfree(codec); return 0; } @@ -1778,30 +1625,134 @@ struct snd_soc_codec_device soc_codec_dev_wm8753 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753); +static int wm8753_register(struct wm8753_priv *wm8753) +{ + int ret, i; + struct snd_soc_codec *codec = &wm8753->codec; + u16 reg; + + if (wm8753_codec) { + dev_err(codec->dev, "Multiple WM8753 devices not supported\n"); + ret = -EINVAL; + goto err; + } + + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + codec->name = "WM8753"; + codec->owner = THIS_MODULE; + codec->read = wm8753_read_reg_cache; + codec->write = wm8753_write; + codec->bias_level = SND_SOC_BIAS_STANDBY; + codec->set_bias_level = wm8753_set_bias_level; + codec->dai = wm8753_dai; + codec->num_dai = 2; + codec->reg_cache_size = ARRAY_SIZE(wm8753->reg_cache); + codec->reg_cache = &wm8753->reg_cache; + codec->private_data = wm8753; + + memcpy(codec->reg_cache, wm8753_reg, sizeof(codec->reg_cache)); + INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work); + + ret = wm8753_reset(codec); + if (ret < 0) { + dev_err(codec->dev, "Failed to issue reset\n"); + goto err; + } + + /* charge output caps */ + wm8753_set_bias_level(codec, SND_SOC_BIAS_PREPARE); + schedule_delayed_work(&codec->delayed_work, + msecs_to_jiffies(caps_charge)); + + /* set the update bits */ + reg = wm8753_read_reg_cache(codec, WM8753_LDAC); + wm8753_write(codec, WM8753_LDAC, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_RDAC); + wm8753_write(codec, WM8753_RDAC, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_LADC); + wm8753_write(codec, WM8753_LADC, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_RADC); + wm8753_write(codec, WM8753_RADC, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_LOUT1V); + wm8753_write(codec, WM8753_LOUT1V, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_ROUT1V); + wm8753_write(codec, WM8753_ROUT1V, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_LOUT2V); + wm8753_write(codec, WM8753_LOUT2V, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_ROUT2V); + wm8753_write(codec, WM8753_ROUT2V, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_LINVOL); + wm8753_write(codec, WM8753_LINVOL, reg | 0x0100); + reg = wm8753_read_reg_cache(codec, WM8753_RINVOL); + wm8753_write(codec, WM8753_RINVOL, reg | 0x0100); + + wm8753_codec = codec; + + for (i = 0; i < ARRAY_SIZE(wm8753_dai); i++) + wm8753_dai[i].dev = codec->dev; + + ret = snd_soc_register_codec(codec); + if (ret != 0) { + dev_err(codec->dev, "Failed to register codec: %d\n", ret); + goto err; + } + + ret = snd_soc_register_dais(&wm8753_dai[0], ARRAY_SIZE(wm8753_dai)); + if (ret != 0) { + dev_err(codec->dev, "Failed to register DAIs: %d\n", ret); + goto err_codec; + } + + return 0; + +err_codec: + run_delayed_work(&codec->delayed_work); + snd_soc_unregister_codec(codec); +err: + kfree(wm8753); + return ret; +} + +static void wm8753_unregister(struct wm8753_priv *wm8753) +{ + wm8753_set_bias_level(&wm8753->codec, SND_SOC_BIAS_OFF); + run_delayed_work(&wm8753->codec.delayed_work); + snd_soc_unregister_dais(&wm8753_dai[0], ARRAY_SIZE(wm8753_dai)); + snd_soc_unregister_codec(&wm8753->codec); + kfree(wm8753); + wm8753_codec = NULL; +} + #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) static int wm8753_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct snd_soc_device *socdev = wm8753_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; + struct snd_soc_codec *codec; + struct wm8753_priv *wm8753; - i2c_set_clientdata(i2c, codec); - codec->control_data = i2c; + wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL); + if (wm8753 == NULL) + return -ENOMEM; - ret = wm8753_init(socdev); - if (ret < 0) - pr_err("failed to initialise WM8753\n"); + codec = &wm8753->codec; + codec->hw_write = (hw_write_t)i2c_master_send; + codec->control_data = i2c; + i2c_set_clientdata(i2c, wm8753); - return ret; + codec->dev = &i2c->dev; + + return wm8753_register(wm8753); } static int wm8753_i2c_remove(struct i2c_client *client) { - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); - return 0; + struct wm8753_priv *wm8753 = i2c_get_clientdata(client); + wm8753_unregister(wm8753); + return 0; } static const struct i2c_device_id wm8753_i2c_id[] = { @@ -1812,7 +1763,7 @@ MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id); static struct i2c_driver wm8753_i2c_driver = { .driver = { - .name = "WM8753 I2C Codec", + .name = "wm8753", .owner = THIS_MODULE, }, .probe = wm8753_i2c_probe, @@ -1848,21 +1799,27 @@ static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) static int __devinit wm8753_spi_probe(struct spi_device *spi) { - struct snd_soc_device *socdev = wm8753_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; + struct snd_soc_codec *codec; + struct wm8753_priv *wm8753; + + wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL); + if (wm8753 == NULL) + return -ENOMEM; + codec = &wm8753->codec; codec->control_data = spi; + codec->hw_write = (hw_write_t)wm8753_spi_write; + codec->dev = &spi->dev; - ret = wm8753_init(socdev); - if (ret < 0) - dev_err(&spi->dev, "failed to initialise WM8753\n"); + spi->dev.driver_data = wm8753; - return ret; + return wm8753_register(wm8753); } static int __devexit wm8753_spi_remove(struct spi_device *spi) { + struct wm8753_priv *wm8753 = spi->dev.driver_data; + wm8753_unregister(wm8753); return 0; } @@ -1879,13 +1836,29 @@ static struct spi_driver wm8753_spi_driver = { static int __init wm8753_modinit(void) { - return snd_soc_register_dais(wm8753_dai, ARRAY_SIZE(wm8753_dai)); + int ret; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + ret = i2c_add_driver(&wm8753_i2c_driver); + if (ret != 0) + pr_err("Failed to register WM8753 I2C driver: %d\n", ret); +#endif +#if defined(CONFIG_SPI_MASTER) + ret = spi_register_driver(&wm8753_spi_driver); + if (ret != 0) + pr_err("Failed to register WM8753 SPI driver: %d\n", ret); +#endif + return 0; } module_init(wm8753_modinit); static void __exit wm8753_exit(void) { - snd_soc_unregister_dais(wm8753_dai, ARRAY_SIZE(wm8753_dai)); +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + i2c_del_driver(&wm8753_i2c_driver); +#endif +#if defined(CONFIG_SPI_MASTER) + spi_unregister_driver(&wm8753_spi_driver); +#endif } module_exit(wm8753_exit); diff --git a/sound/soc/codecs/wm8753.h b/sound/soc/codecs/wm8753.h index f55704ce931..57b2ba24404 100644 --- a/sound/soc/codecs/wm8753.h +++ b/sound/soc/codecs/wm8753.h @@ -77,12 +77,6 @@ #define WM8753_BIASCTL 0x3d #define WM8753_ADCTL2 0x3f -struct wm8753_setup_data { - int spi; - int i2c_bus; - unsigned short i2c_address; -}; - #define WM8753_PLL1 0 #define WM8753_PLL2 1 diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 45bb12e8ea4..286e11ad50e 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -585,15 +585,9 @@ static struct snd_soc_card neo1973 = { .num_links = ARRAY_SIZE(neo1973_dai), }; -static struct wm8753_setup_data neo1973_wm8753_setup = { - .i2c_bus = 0, - .i2c_address = 0x1a, -}; - static struct snd_soc_device neo1973_snd_devdata = { .card = &neo1973, .codec_dev = &soc_codec_dev_wm8753, - .codec_data = &neo1973_wm8753_setup, }; static int lm4857_i2c_probe(struct i2c_client *client, -- cgit v1.2.3 From e611bd82441130991d7f4600dfd4632cebd417c5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 22 Feb 2009 20:04:41 +0000 Subject: ASoC: Only write back non-default registers when resuming WM8753 This will reduce the number of writes done on resume, allowing that to complete faster (especially on systems with very slow I2C like the current Samsung driver). Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index bc29558149e..2241204b515 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1526,6 +1526,11 @@ static int wm8753_resume(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(wm8753_reg); i++) { if (i + 1 == WM8753_RESET) continue; + + /* No point in writing hardware default values back */ + if (cache[i] == wm8753_reg[i]) + continue; + data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001); data[1] = cache[i] & 0x00ff; codec->hw_write(codec->control_data, data, 2); -- cgit v1.2.3 From 6d5643455ced9ee45a4aa7403fe8056d826bde85 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 26 Feb 2009 11:29:58 +0100 Subject: ASoC: wm8753 - Fix build error sound/soc/codecs/wm8753.c: In function 'wm8753_probe': sound/soc/codecs/wm8753.c:1577: error: implicit declaration of function 'wm8753_add_controls' Acked-by: Mark Brown Signed-off-by: Takashi Iwai --- sound/soc/codecs/wm8753.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 2241204b515..7f353e935d7 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1574,7 +1574,8 @@ static int wm8753_probe(struct platform_device *pdev) goto pcm_err; } - wm8753_add_controls(codec); + snd_soc_add_controls(codec, wm8753_snd_controls, + ARRAY_SIZE(wm8753_snd_controls)); wm8753_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { -- cgit v1.2.3 From c8efef1745d168b80c800e98cce48a59630dbbfc Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Sat, 28 Feb 2009 17:09:57 +0000 Subject: ASoC: Fix copyright statements on Simtec files Fix the copyright statements in two of the S3C24XX ASoC files that have (c) when we require the full word. Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/s3c24xx-i2s.c | 2 +- sound/soc/s3c24xx/s3c24xx-pcm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 6f4d439b57a..1c2b0549710 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -4,7 +4,7 @@ * (c) 2006 Wolfson Microelectronics PLC. * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com * - * (c) 2004-2005 Simtec Electronics + * Copyright 2004-2005 Simtec Electronics * http://armlinux.simtec.co.uk/ * Ben Dooks * diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c index 7c64d31d067..ba1ae09dfae 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.c +++ b/sound/soc/s3c24xx/s3c24xx-pcm.c @@ -4,7 +4,7 @@ * (c) 2006 Wolfson Microelectronics PLC. * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com * - * (c) 2004-2005 Simtec Electronics + * Copyright 2004-2005 Simtec Electronics * http://armlinux.simtec.co.uk/ * Ben Dooks * -- cgit v1.2.3 From 4eae080dda3a563160be2f642cfbda27ffc42178 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 25 Feb 2009 14:37:21 +0100 Subject: ASoC: Add cs4270 support for slave mode configurations Added support for scenarios where the Cirrus CS4270 audio codec is slave to the bitclk and lrclk. Mixed setups are unsupported. Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index cd4a9ee38e4..339e0f6b0fe 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -109,6 +109,7 @@ struct cs4270_private { u8 reg_cache[CS4270_NUMREGS]; unsigned int mclk; /* Input frequency of the MCLK pin */ unsigned int mode; /* The mode (I2S or left-justified) */ + unsigned int slave_mode; }; /** @@ -247,6 +248,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, struct cs4270_private *cs4270 = codec->private_data; int ret = 0; + /* set DAI format */ switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_LEFT_J: @@ -257,6 +259,21 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, ret = -EINVAL; } + /* set master/slave audio interface */ + switch (format & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + cs4270->slave_mode = 1; + break; + case SND_SOC_DAIFMT_CBM_CFM: + cs4270->slave_mode = 0; + break; + case SND_SOC_DAIFMT_CBM_CFS: + /* unsupported - cs4270 can eigther be slave or master to + * both the bitclk and the lrclk. */ + default: + ret = -EINVAL; + } + return ret; } @@ -399,7 +416,12 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, reg = snd_soc_read(codec, CS4270_MODE); reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK); - reg |= cs4270_mode_ratios[i].speed_mode | cs4270_mode_ratios[i].mclk; + reg |= cs4270_mode_ratios[i].mclk; + + if (cs4270->slave_mode) + reg |= CS4270_MODE_SLAVE; + else + reg |= cs4270_mode_ratios[i].speed_mode; ret = snd_soc_write(codec, CS4270_MODE, reg); if (ret < 0) { -- cgit v1.2.3 From 8b37dbd2a180667e51db0552383df18743239c25 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 28 Feb 2009 21:14:20 +0000 Subject: ASoC: Add SND_SOC_DAPM_PIN_SWITCH controls for exposing DAPM pins On some systems it is desirable for control for DAPM pins to be provided to user space. This is the case with things like GSM modems which are controlled primarily from user space, for example. Provide a helper which exposes the state of a DAPM pin to user space for use in cases like this. Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index f4a8753c84c..4b8dbbfe2ef 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1420,6 +1420,76 @@ out: } EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double); +/** + * snd_soc_dapm_info_pin_switch - Info for a pin switch + * + * @kcontrol: mixer control + * @uinfo: control element information + * + * Callback to provide information about a pin switch control. + */ +int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_info_pin_switch); + +/** + * snd_soc_dapm_get_pin_switch - Get information for a pin switch + * + * @kcontrol: mixer control + * @ucontrol: Value + */ +int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + const char *pin = (const char *)kcontrol->private_value; + + mutex_lock(&codec->mutex); + + ucontrol->value.integer.value[0] = + snd_soc_dapm_get_pin_status(codec, pin); + + mutex_unlock(&codec->mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_switch); + +/** + * snd_soc_dapm_put_pin_switch - Set information for a pin switch + * + * @kcontrol: mixer control + * @ucontrol: Value + */ +int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + const char *pin = (const char *)kcontrol->private_value; + + mutex_lock(&codec->mutex); + + if (ucontrol->value.integer.value[0]) + snd_soc_dapm_enable_pin(codec, pin); + else + snd_soc_dapm_disable_pin(codec, pin); + + snd_soc_dapm_sync(codec); + + mutex_unlock(&codec->mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch); + /** * snd_soc_dapm_new_control - create new dapm control * @codec: audio codec -- cgit v1.2.3 From ff09d49ad0176a5f52a398c137a7ff5f669d6be4 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Sat, 28 Feb 2009 13:21:03 +0100 Subject: ASoC: fix typo and removed unneeded switch case for cs4270 This removes a misspelled comment and got rid of superfluous switch case. Signed-off-by: Daniel Mack Acked-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 339e0f6b0fe..f86f33cc179 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -267,10 +267,8 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBM_CFM: cs4270->slave_mode = 0; break; - case SND_SOC_DAIFMT_CBM_CFS: - /* unsupported - cs4270 can eigther be slave or master to - * both the bitclk and the lrclk. */ default: + /* all other modes are unsupported by the hardware */ ret = -EINVAL; } -- cgit v1.2.3 From a3c7729e6c5d41bbeb3e13befbcf8e4ef76e55dc Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 3 Mar 2009 16:10:53 +0100 Subject: ASoC: Remove version display from the UDA1380 driver Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/codecs/uda1380.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 5242b8156b3..8686a554536 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -35,8 +35,6 @@ #include "uda1380.h" -#define UDA1380_VERSION "0.6" - /* * uda1380 register cache */ @@ -826,8 +824,6 @@ static int uda1380_probe(struct platform_device *pdev) struct snd_soc_codec *codec; int ret; - pr_info("UDA1380 Audio Codec %s", UDA1380_VERSION); - setup = socdev->codec_data; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) -- cgit v1.2.3 From ef9e5e5c31cb2c6254760611289ac13e4e41b964 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 3 Mar 2009 16:10:54 +0100 Subject: ASoC: UDA1380: change decimator/interpolator register handling If the UDA1380's interpolator or decimator are set to be clocked from the WSPLL (which syncs to the WSI signal), the DAI link must be running to change the interpolator/decimator registers (which include volume controls and digital mute setting). * Queue work in the alsa PCM_START .trigger to flush registers as soon as the link is running. This replaces the .prepare and .digital_mute callbacks. * Use the SILENCE override instead of MTM for muting and remove its alsa control to avoid confusion. Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/codecs/uda1380.c | 102 +++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 54 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 8686a554536..1c9d2a75add 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,9 @@ #include "uda1380.h" +static struct work_struct uda1380_work; +static struct snd_soc_codec *uda1380_codec; + /* * uda1380 register cache */ @@ -50,6 +54,8 @@ static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = { 0x0000, 0x8000, 0x0002, 0x0000, }; +static unsigned long uda1380_cache_dirty; + /* * read uda1380 register cache */ @@ -71,8 +77,11 @@ static inline void uda1380_write_reg_cache(struct snd_soc_codec *codec, u16 reg, unsigned int value) { u16 *cache = codec->reg_cache; + if (reg >= UDA1380_CACHEREGNUM) return; + if ((reg >= 0x10) && (cache[reg] != value)) + set_bit(reg - 0x10, &uda1380_cache_dirty); cache[reg] = value; } @@ -111,6 +120,8 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg, (data[0]<<8) | data[1]); return -EIO; } + if (reg >= 0x10) + clear_bit(reg - 0x10, &uda1380_cache_dirty); return 0; } else return -EIO; @@ -118,6 +129,20 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg, #define uda1380_reset(c) uda1380_write(c, UDA1380_RESET, 0) +static void uda1380_flush_work(struct work_struct *work) +{ + int bit, reg; + + for_each_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { + reg = 0x10 + bit; + pr_debug("uda1380: flush reg %x val %x:\n", reg, + uda1380_read_reg_cache(uda1380_codec, reg)); + uda1380_write(uda1380_codec, reg, + uda1380_read_reg_cache(uda1380_codec, reg)); + clear_bit(bit, &uda1380_cache_dirty); + } +} + /* declarations of ALSA reg_elem_REAL controls */ static const char *uda1380_deemp[] = { "None", @@ -252,7 +277,6 @@ static const struct snd_kcontrol_new uda1380_snd_controls[] = { SOC_SINGLE("DAC Polarity inverting Switch", UDA1380_MIXER, 15, 1, 0), /* DA_POL_INV */ SOC_ENUM("Noise Shaper", uda1380_sel_ns_enum), /* SEL_NS */ SOC_ENUM("Digital Mixer Signal Control", uda1380_mix_enum), /* MIX_POS, MIX */ - SOC_SINGLE("Silence Switch", UDA1380_MIXER, 7, 1, 0), /* SILENCE, force DAC output to silence */ SOC_SINGLE("Silence Detector Switch", UDA1380_MIXER, 6, 1, 0), /* SDET_ON */ SOC_ENUM("Silence Detector Setting", uda1380_sdet_enum), /* SD_VALUE */ SOC_ENUM("Oversampling Input", uda1380_os_enum), /* OS */ @@ -438,41 +462,28 @@ static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai, return 0; } -/* - * Flush reg cache - * We can only write the interpolator and decimator registers - * when the DAI is being clocked by the CPU DAI. It's up to the - * machine and cpu DAI driver to do this before we are called. - */ -static int uda1380_pcm_prepare(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static int uda1380_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_device *socdev = rtd->socdev; struct snd_soc_codec *codec = socdev->card->codec; - int reg, reg_start, reg_end, clk; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - reg_start = UDA1380_MVOL; - reg_end = UDA1380_MIXER; - } else { - reg_start = UDA1380_DEC; - reg_end = UDA1380_AGC; - } - - /* FIXME disable DAC_CLK */ - clk = uda1380_read_reg_cache(codec, UDA1380_CLK); - uda1380_write(codec, UDA1380_CLK, clk & ~R00_DAC_CLK); - - for (reg = reg_start; reg <= reg_end; reg++) { - pr_debug("uda1380: flush reg %x val %x:", reg, - uda1380_read_reg_cache(codec, reg)); - uda1380_write(codec, reg, uda1380_read_reg_cache(codec, reg)); + int mixer = uda1380_read_reg_cache(codec, UDA1380_MIXER); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + uda1380_write_reg_cache(codec, UDA1380_MIXER, + mixer & ~R14_SILENCE); + schedule_work(&uda1380_work); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + uda1380_write_reg_cache(codec, UDA1380_MIXER, + mixer | R14_SILENCE); + schedule_work(&uda1380_work); + break; } - - /* FIXME restore DAC_CLK */ - uda1380_write(codec, UDA1380_CLK, clk); - return 0; } @@ -538,24 +549,6 @@ static void uda1380_pcm_shutdown(struct snd_pcm_substream *substream, uda1380_write(codec, UDA1380_CLK, clk); } -static int uda1380_mute(struct snd_soc_dai *codec_dai, int mute) -{ - struct snd_soc_codec *codec = codec_dai->codec; - u16 mute_reg = uda1380_read_reg_cache(codec, UDA1380_DEEMP) & ~R13_MTM; - - /* FIXME: mute(codec,0) is called when the magician clock is already - * set to WSPLL, but for some unknown reason writing to interpolator - * registers works only when clocked by SYSCLK */ - u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); - uda1380_write(codec, UDA1380_CLK, ~R00_DAC_CLK & clk); - if (mute) - uda1380_write(codec, UDA1380_DEEMP, mute_reg | R13_MTM); - else - uda1380_write(codec, UDA1380_DEEMP, mute_reg); - uda1380_write(codec, UDA1380_CLK, clk); - return 0; -} - static int uda1380_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { @@ -597,10 +590,9 @@ struct snd_soc_dai uda1380_dai[] = { .rates = UDA1380_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, .ops = { + .trigger = uda1380_trigger, .hw_params = uda1380_pcm_hw_params, .shutdown = uda1380_pcm_shutdown, - .prepare = uda1380_pcm_prepare, - .digital_mute = uda1380_mute, .set_fmt = uda1380_set_dai_fmt_both, }, }, @@ -614,10 +606,9 @@ struct snd_soc_dai uda1380_dai[] = { .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = { + .trigger = uda1380_trigger, .hw_params = uda1380_pcm_hw_params, .shutdown = uda1380_pcm_shutdown, - .prepare = uda1380_pcm_prepare, - .digital_mute = uda1380_mute, .set_fmt = uda1380_set_dai_fmt_playback, }, }, @@ -631,9 +622,9 @@ struct snd_soc_dai uda1380_dai[] = { .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .ops = { + .trigger = uda1380_trigger, .hw_params = uda1380_pcm_hw_params, .shutdown = uda1380_pcm_shutdown, - .prepare = uda1380_pcm_prepare, .set_fmt = uda1380_set_dai_fmt_capture, }, }, @@ -692,6 +683,9 @@ static int uda1380_init(struct snd_soc_device *socdev, int dac_clk) codec->reg_cache_step = 1; uda1380_reset(codec); + uda1380_codec = codec; + INIT_WORK(&uda1380_work, uda1380_flush_work); + /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { -- cgit v1.2.3 From aa4ef01de5f2e7ed948b88f9f1cfc93c8e0c3f25 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 3 Mar 2009 16:10:51 +0100 Subject: ASoC: Use network mode with 2 slots for 16-bit stereo in pxa-ssp/Zylonite For consistency with 24-bit and 32-bit modes, don't send 16-bit stereo in one 32-bit transfer. Use 2 slots instead on Zylonite. It should result in exactly the same behaviour. Now it is possible to use 16-bit single slot transfers in pxa-ssp, which are needed for Magician to get two frame clock pulses per sample (one for each channel). Signed-off-by: Philipp Zabel Tested-by: Mark Brown Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 3 +-- sound/soc/pxa/zylonite.c | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 4a973ab710b..c49bb12b0a6 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -644,8 +644,7 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, sscr0 |= SSCR0_FPCKE; #endif sscr0 |= SSCR0_DataSize(16); - if (params_channels(params) > 1) - sscr0 |= SSCR0_EDSS; + /* use network mode (2 slots) for 16 bit stereo */ break; case SNDRV_PCM_FORMAT_S24_LE: sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8)); diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c index 0140a250db2..9f6116edbb8 100644 --- a/sound/soc/pxa/zylonite.c +++ b/sound/soc/pxa/zylonite.c @@ -127,8 +127,11 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - /* We're not really in network mode but the emulation wants this. */ - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1); + /* Use network mode for stereo, one slot per channel. */ + if (params_channels(params) > 1) + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 2); + else + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1); if (ret < 0) return ret; -- cgit v1.2.3 From 5f2a9384a9291d898b4bf85c4fbf497eef582977 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 3 Mar 2009 16:10:52 +0100 Subject: ASoC: UDA1380: DATAI is slave only Only allow SND_SOC_DAIFMT_CBS_CFS for the playback DAI. Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/codecs/uda1380.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 1c9d2a75add..1b10f488328 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -399,8 +399,9 @@ static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, iface |= R01_SFORI_MSB | R01_SFORO_MSB; } - if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) - iface |= R01_SIM; + /* DATAI is slave only, so in single-link mode, this has to be slave */ + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) + return -EINVAL; uda1380_write(codec, UDA1380_IFACE, iface); @@ -428,6 +429,10 @@ static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai, iface |= R01_SFORI_MSB; } + /* DATAI is slave only, so this has to be slave */ + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) + return -EINVAL; + uda1380_write(codec, UDA1380_IFACE, iface); return 0; -- cgit v1.2.3 From ec67624d33d5639bcc6ee6918cb1fc0bd1bac3a8 Mon Sep 17 00:00:00 2001 From: "Lopez Cruz, Misael" Date: Tue, 3 Mar 2009 15:25:04 -0600 Subject: ASoC: Add GPIO support for jack reporting interface Add GPIO support to jack reporting framework in ASoC using gpiolib calls. The gpio support exports two new functions: snd_soc_jack_add_gpios and snd_soc_jack_free_gpios. Client drivers using gpio feature must pass an array of jack_gpio pins belonging to a specific jack to the snd_soc_jack_add_gpios function. The framework will request the gpios, set the data direction and request irq. The framework will update power status of related jack_pins when an event on the gpio pins comes according to the reporting bits defined for each gpio. All gpio resources allocated when adding jack_gpio pins can be released using snd_soc_jack_free_gpios function. Signed-off-by: Misael Lopez Cruz Signed-off-by: Mark Brown --- sound/soc/soc-jack.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index ab64a30bedd..bdf2484c222 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -14,6 +14,10 @@ #include #include #include +#include +#include +#include +#include /** * snd_soc_jack_new - Create a new jack @@ -136,3 +140,128 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, return 0; } EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins); + +#ifdef CONFIG_GPIOLIB +/* gpio detect */ +void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) +{ + struct snd_soc_jack *jack = gpio->jack; + int enable; + int report; + + if (gpio->debounce_time > 0) + mdelay(gpio->debounce_time); + + enable = gpio_get_value(gpio->gpio); + if (gpio->invert) + enable = !enable; + + if (enable) + report = gpio->report; + else + report = 0; + + snd_soc_jack_report(jack, report, gpio->report); +} + +/* irq handler for gpio pin */ +static irqreturn_t gpio_handler(int irq, void *data) +{ + struct snd_soc_jack_gpio *gpio = data; + + schedule_work(&gpio->work); + + return IRQ_HANDLED; +} + +/* gpio work */ +static void gpio_work(struct work_struct *work) +{ + struct snd_soc_jack_gpio *gpio; + + gpio = container_of(work, struct snd_soc_jack_gpio, work); + snd_soc_jack_gpio_detect(gpio); +} + +/** + * snd_soc_jack_add_gpios - Associate GPIO pins with an ASoC jack + * + * @jack: ASoC jack + * @count: number of pins + * @gpios: array of gpio pins + * + * This function will request gpio, set data direction and request irq + * for each gpio in the array. + */ +int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, + struct snd_soc_jack_gpio *gpios) +{ + int i, ret; + + for (i = 0; i < count; i++) { + if (!gpio_is_valid(gpios[i].gpio)) { + printk(KERN_ERR "Invalid gpio %d\n", + gpios[i].gpio); + ret = -EINVAL; + goto undo; + } + if (!gpios[i].name) { + printk(KERN_ERR "No name for gpio %d\n", + gpios[i].gpio); + ret = -EINVAL; + goto undo; + } + + ret = gpio_request(gpios[i].gpio, gpios[i].name); + if (ret) + goto undo; + + ret = gpio_direction_input(gpios[i].gpio); + if (ret) + goto err; + + ret = request_irq(gpio_to_irq(gpios[i].gpio), + gpio_handler, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, + jack->card->dev->driver->name, + &gpios[i]); + if (ret) + goto err; + + INIT_WORK(&gpios[i].work, gpio_work); + gpios[i].jack = jack; + } + + return 0; + +err: + gpio_free(gpios[i].gpio); +undo: + snd_soc_jack_free_gpios(jack, i, gpios); + + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpios); + +/** + * snd_soc_jack_free_gpios - Release GPIO pins' resources of an ASoC jack + * + * @jack: ASoC jack + * @count: number of pins + * @gpios: array of gpio pins + * + * Release gpio and irq resources for gpio pins associated with an ASoC jack. + */ +void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, + struct snd_soc_jack_gpio *gpios) +{ + int i; + + for (i = 0; i < count; i++) { + free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]); + gpio_free(gpios[i].gpio); + gpios[i].jack = NULL; + } +} +EXPORT_SYMBOL_GPL(snd_soc_jack_free_gpios); +#endif /* CONFIG_GPIOLIB */ -- cgit v1.2.3 From 86027ae78c9294bb450b76eec28cfb431a8fb3ee Mon Sep 17 00:00:00 2001 From: Jonas Andersson Date: Wed, 4 Mar 2009 08:24:26 +0100 Subject: ASoC: wm8510 pll settings When setting WM8510_MCLKDIV the pll was turned off. When setting pll frequency you got twice the expected freq, because the code calculated with postscaler of 8, but the hardware divide by 4. Signed-off-by: Jonas Andersson Signed-off-by: Mark Brown --- sound/soc/atmel/playpaq_wm8510.c | 24 ++++++++++++------------ sound/soc/codecs/wm8510.c | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/playpaq_wm8510.c b/sound/soc/atmel/playpaq_wm8510.c index 43dd8cee83c..70657534e6b 100644 --- a/sound/soc/atmel/playpaq_wm8510.c +++ b/sound/soc/atmel/playpaq_wm8510.c @@ -164,38 +164,38 @@ static int playpaq_wm8510_hw_params(struct snd_pcm_substream *substream, */ switch (params_rate(params)) { case 48000: - pll_out = 12288000; - mclk_div = WM8510_MCLKDIV_1; + pll_out = 24576000; + mclk_div = WM8510_MCLKDIV_2; bclk = WM8510_BCLKDIV_8; break; case 44100: - pll_out = 11289600; - mclk_div = WM8510_MCLKDIV_1; + pll_out = 22579200; + mclk_div = WM8510_MCLKDIV_2; bclk = WM8510_BCLKDIV_8; break; case 22050: - pll_out = 11289600; - mclk_div = WM8510_MCLKDIV_2; + pll_out = 22579200; + mclk_div = WM8510_MCLKDIV_4; bclk = WM8510_BCLKDIV_8; break; case 16000: - pll_out = 12288000; - mclk_div = WM8510_MCLKDIV_3; + pll_out = 24576000; + mclk_div = WM8510_MCLKDIV_6; bclk = WM8510_BCLKDIV_8; break; case 11025: - pll_out = 11289600; - mclk_div = WM8510_MCLKDIV_4; + pll_out = 22579200; + mclk_div = WM8510_MCLKDIV_8; bclk = WM8510_BCLKDIV_8; break; case 8000: - pll_out = 12288000; - mclk_div = WM8510_MCLKDIV_6; + pll_out = 24576000; + mclk_div = WM8510_MCLKDIV_12; bclk = WM8510_BCLKDIV_8; break; diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index f01078cfbd7..6d4ef71e919 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -336,7 +336,7 @@ static int wm8510_set_dai_pll(struct snd_soc_dai *codec_dai, return 0; } - pll_factors(freq_out*8, freq_in); + pll_factors(freq_out*4, freq_in); wm8510_write(codec, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n); wm8510_write(codec, WM8510_PLLK1, pll_div.k >> 18); @@ -367,7 +367,7 @@ static int wm8510_set_dai_clkdiv(struct snd_soc_dai *codec_dai, wm8510_write(codec, WM8510_GPIO, reg | div); break; case WM8510_MCLKDIV: - reg = wm8510_read_reg_cache(codec, WM8510_CLOCK) & 0x1f; + reg = wm8510_read_reg_cache(codec, WM8510_CLOCK) & 0x11f; wm8510_write(codec, WM8510_CLOCK, reg | div); break; case WM8510_ADCCLK: -- cgit v1.2.3 From 6335d05548eece40092000aa91b64a50310d69d5 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Tue, 3 Mar 2009 09:41:00 +0800 Subject: ASoC: make ops a pointer in 'struct snd_soc_dai' Considering the fact that most cpu_dai or codec_dai are using a same 'snd_soc_dai_ops' for several similar interfaces, 'ops' would be better made a pointer instead, to make sharing easier and code a bit cleaner. The patch below is rather preliminary since the asoc tree is being actively developed, and this touches almost every piece of code, (and possibly many others in development need to be changed as well). Building of all codecs are OK, yet to every SoC, I didn't test that. Signed-off-by: Eric Miao Acked-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/atmel/atmel_ssc_dai.c | 33 +++++-------- sound/soc/au1x/psc-ac97.c | 10 ++-- sound/soc/au1x/psc-i2s.c | 12 +++-- sound/soc/blackfin/bf5xx-i2s.c | 14 +++--- sound/soc/codecs/ac97.c | 7 ++- sound/soc/codecs/ak4535.c | 14 +++--- sound/soc/codecs/cs4270.c | 14 +++--- sound/soc/codecs/ssm2602.c | 20 ++++---- sound/soc/codecs/tlv320aic23.c | 18 ++++--- sound/soc/codecs/tlv320aic26.c | 14 +++--- sound/soc/codecs/tlv320aic3x.c | 14 +++--- sound/soc/codecs/uda134x.c | 18 ++++--- sound/soc/codecs/uda1380.c | 46 ++++++++++-------- sound/soc/codecs/wm8350.c | 20 ++++---- sound/soc/codecs/wm8510.c | 16 +++--- sound/soc/codecs/wm8580.c | 30 +++++++----- sound/soc/codecs/wm8728.c | 12 +++-- sound/soc/codecs/wm8731.c | 18 ++++--- sound/soc/codecs/wm8750.c | 14 +++--- sound/soc/codecs/wm8753.c | 90 +++++++++++++++++++--------------- sound/soc/codecs/wm8900.c | 16 +++--- sound/soc/codecs/wm8903.c | 18 ++++--- sound/soc/codecs/wm8971.c | 14 +++--- sound/soc/codecs/wm8990.c | 18 ++++--- sound/soc/codecs/wm9705.c | 8 +-- sound/soc/codecs/wm9712.c | 14 ++++-- sound/soc/codecs/wm9713.c | 40 +++++++++------ sound/soc/davinci/davinci-i2s.c | 14 +++--- sound/soc/fsl/fsl_ssi.c | 18 ++++--- sound/soc/fsl/mpc5200_psc_i2s.c | 20 ++++---- sound/soc/omap/omap-mcbsp.c | 20 ++++---- sound/soc/pxa/pxa-ssp.c | 65 +++++++------------------ sound/soc/pxa/pxa2xx-ac97.c | 13 ++--- sound/soc/pxa/pxa2xx-i2s.c | 18 ++++--- sound/soc/s3c24xx/s3c2412-i2s.c | 16 +++--- sound/soc/s3c24xx/s3c2443-ac97.c | 13 ++--- sound/soc/s3c24xx/s3c24xx-i2s.c | 16 +++--- sound/soc/sh/ssi.c | 30 +++++------- sound/soc/soc-core.c | 102 +++++++++++++++++++++------------------ 39 files changed, 480 insertions(+), 427 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index ff0054b7650..e588e63f18d 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -697,6 +697,15 @@ static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai) #define ATMEL_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops atmel_ssc_dai_ops = { + .startup = atmel_ssc_startup, + .shutdown = atmel_ssc_shutdown, + .prepare = atmel_ssc_prepare, + .hw_params = atmel_ssc_hw_params, + .set_fmt = atmel_ssc_set_dai_fmt, + .set_clkdiv = atmel_ssc_set_dai_clkdiv, +}; + struct snd_soc_dai atmel_ssc_dai[NUM_SSC_DEVICES] = { { .name = "atmel-ssc0", .id = 0, @@ -712,13 +721,7 @@ struct snd_soc_dai atmel_ssc_dai[NUM_SSC_DEVICES] = { .channels_max = 2, .rates = ATMEL_SSC_RATES, .formats = ATMEL_SSC_FORMATS,}, - .ops = { - .startup = atmel_ssc_startup, - .shutdown = atmel_ssc_shutdown, - .prepare = atmel_ssc_prepare, - .hw_params = atmel_ssc_hw_params, - .set_fmt = atmel_ssc_set_dai_fmt, - .set_clkdiv = atmel_ssc_set_dai_clkdiv,}, + .ops = &atmel_ssc_dai_ops, .private_data = &ssc_info[0], }, #if NUM_SSC_DEVICES == 3 @@ -736,13 +739,7 @@ struct snd_soc_dai atmel_ssc_dai[NUM_SSC_DEVICES] = { .channels_max = 2, .rates = ATMEL_SSC_RATES, .formats = ATMEL_SSC_FORMATS,}, - .ops = { - .startup = atmel_ssc_startup, - .shutdown = atmel_ssc_shutdown, - .prepare = atmel_ssc_prepare, - .hw_params = atmel_ssc_hw_params, - .set_fmt = atmel_ssc_set_dai_fmt, - .set_clkdiv = atmel_ssc_set_dai_clkdiv,}, + .ops = &atmel_ssc_dai_ops, .private_data = &ssc_info[1], }, { .name = "atmel-ssc2", @@ -759,13 +756,7 @@ struct snd_soc_dai atmel_ssc_dai[NUM_SSC_DEVICES] = { .channels_max = 2, .rates = ATMEL_SSC_RATES, .formats = ATMEL_SSC_FORMATS,}, - .ops = { - .startup = atmel_ssc_startup, - .shutdown = atmel_ssc_shutdown, - .prepare = atmel_ssc_prepare, - .hw_params = atmel_ssc_hw_params, - .set_fmt = atmel_ssc_set_dai_fmt, - .set_clkdiv = atmel_ssc_set_dai_clkdiv,}, + .ops = &atmel_ssc_dai_ops, .private_data = &ssc_info[2], }, #endif diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c index f0e30aec7f2..479d7bdf186 100644 --- a/sound/soc/au1x/psc-ac97.c +++ b/sound/soc/au1x/psc-ac97.c @@ -342,6 +342,11 @@ static int au1xpsc_ac97_resume(struct snd_soc_dai *dai) return 0; } +static struct snd_soc_dai_ops au1xpsc_ac97_dai_ops = { + .trigger = au1xpsc_ac97_trigger, + .hw_params = au1xpsc_ac97_hw_params, +}; + struct snd_soc_dai au1xpsc_ac97_dai = { .name = "au1xpsc_ac97", .ac97_control = 1, @@ -361,10 +366,7 @@ struct snd_soc_dai au1xpsc_ac97_dai = { .channels_min = 2, .channels_max = 2, }, - .ops = { - .trigger = au1xpsc_ac97_trigger, - .hw_params = au1xpsc_ac97_hw_params, - }, + .ops = &au1xpsc_ac97_dai_ops, }; EXPORT_SYMBOL_GPL(au1xpsc_ac97_dai); diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c index f916de4400e..bb589327ee3 100644 --- a/sound/soc/au1x/psc-i2s.c +++ b/sound/soc/au1x/psc-i2s.c @@ -367,6 +367,12 @@ static int au1xpsc_i2s_resume(struct snd_soc_dai *cpu_dai) return 0; } +static struct snd_soc_dai_ops au1xpsc_i2s_dai_ops = { + .trigger = au1xpsc_i2s_trigger, + .hw_params = au1xpsc_i2s_hw_params, + .set_fmt = au1xpsc_i2s_set_fmt, +}; + struct snd_soc_dai au1xpsc_i2s_dai = { .name = "au1xpsc_i2s", .probe = au1xpsc_i2s_probe, @@ -385,11 +391,7 @@ struct snd_soc_dai au1xpsc_i2s_dai = { .channels_min = 2, .channels_max = 8, /* 2 without external help */ }, - .ops = { - .trigger = au1xpsc_i2s_trigger, - .hw_params = au1xpsc_i2s_hw_params, - .set_fmt = au1xpsc_i2s_set_fmt, - }, + .ops = &au1xpsc_i2s_dai_ops, }; EXPORT_SYMBOL(au1xpsc_i2s_dai); diff --git a/sound/soc/blackfin/bf5xx-i2s.c b/sound/soc/blackfin/bf5xx-i2s.c index d1d95d2393f..96482441967 100644 --- a/sound/soc/blackfin/bf5xx-i2s.c +++ b/sound/soc/blackfin/bf5xx-i2s.c @@ -287,6 +287,13 @@ static int bf5xx_i2s_resume(struct platform_device *pdev, #define BF5XX_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |\ SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops bf5xx_i2s_dai_ops = { + .startup = bf5xx_i2s_startup, + .shutdown = bf5xx_i2s_shutdown, + .hw_params = bf5xx_i2s_hw_params, + .set_fmt = bf5xx_i2s_set_dai_fmt, +}; + struct snd_soc_dai bf5xx_i2s_dai = { .name = "bf5xx-i2s", .id = 0, @@ -304,12 +311,7 @@ struct snd_soc_dai bf5xx_i2s_dai = { .channels_max = 2, .rates = BF5XX_I2S_RATES, .formats = BF5XX_I2S_FORMATS,}, - .ops = { - .startup = bf5xx_i2s_startup, - .shutdown = bf5xx_i2s_shutdown, - .hw_params = bf5xx_i2s_hw_params, - .set_fmt = bf5xx_i2s_set_dai_fmt, - }, + .ops = &bf5xx_i2s_dai_ops, }; EXPORT_SYMBOL_GPL(bf5xx_i2s_dai); diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index 11f84b6e5cb..b0d4af145b8 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -41,6 +41,10 @@ static int ac97_prepare(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\ SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops ac97_dai_ops = { + .prepare = ac97_prepare, +}; + struct snd_soc_dai ac97_dai = { .name = "AC97 HiFi", .ac97_control = 1, @@ -56,8 +60,7 @@ struct snd_soc_dai ac97_dai = { .channels_max = 2, .rates = STD_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .prepare = ac97_prepare,}, + .ops = &ac97_dai_ops, }; EXPORT_SYMBOL_GPL(ac97_dai); diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index d56e6bb1fed..1f63d387a2f 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -421,6 +421,13 @@ static int ak4535_set_bias_level(struct snd_soc_codec *codec, SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops ak4535_dai_ops = { + .hw_params = ak4535_hw_params, + .set_fmt = ak4535_set_dai_fmt, + .digital_mute = ak4535_mute, + .set_sysclk = ak4535_set_dai_sysclk, +}; + struct snd_soc_dai ak4535_dai = { .name = "AK4535", .playback = { @@ -435,12 +442,7 @@ struct snd_soc_dai ak4535_dai = { .channels_max = 2, .rates = AK4535_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = ak4535_hw_params, - .set_fmt = ak4535_set_dai_fmt, - .digital_mute = ak4535_mute, - .set_sysclk = ak4535_set_dai_sysclk, - }, + .ops = &ak4535_dai_ops, }; EXPORT_SYMBOL_GPL(ak4535_dai); diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index f86f33cc179..7ae3d6520e3 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -503,6 +503,13 @@ static const struct snd_kcontrol_new cs4270_snd_controls[] = { */ static struct snd_soc_codec *cs4270_codec; +static struct snd_soc_dai_ops cs4270_dai_ops = { + .hw_params = cs4270_hw_params, + .set_sysclk = cs4270_set_dai_sysclk, + .set_fmt = cs4270_set_dai_fmt, + .digital_mute = cs4270_mute, +}; + struct snd_soc_dai cs4270_dai = { .name = "cs4270", .playback = { @@ -519,12 +526,7 @@ struct snd_soc_dai cs4270_dai = { .rates = 0, .formats = CS4270_FORMATS, }, - .ops = { - .hw_params = cs4270_hw_params, - .set_sysclk = cs4270_set_dai_sysclk, - .set_fmt = cs4270_set_dai_fmt, - .digital_mute = cs4270_mute, - }, + .ops = &cs4270_dai_ops, }; EXPORT_SYMBOL_GPL(cs4270_dai); diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 58e225dadc7..87f606c7682 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -506,6 +506,16 @@ static int ssm2602_set_bias_level(struct snd_soc_codec *codec, #define SSM2602_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops ssm2602_dai_ops = { + .startup = ssm2602_startup, + .prepare = ssm2602_pcm_prepare, + .hw_params = ssm2602_hw_params, + .shutdown = ssm2602_shutdown, + .digital_mute = ssm2602_mute, + .set_sysclk = ssm2602_set_dai_sysclk, + .set_fmt = ssm2602_set_dai_fmt, +}; + struct snd_soc_dai ssm2602_dai = { .name = "SSM2602", .playback = { @@ -520,15 +530,7 @@ struct snd_soc_dai ssm2602_dai = { .channels_max = 2, .rates = SSM2602_RATES, .formats = SSM2602_FORMATS,}, - .ops = { - .startup = ssm2602_startup, - .prepare = ssm2602_pcm_prepare, - .hw_params = ssm2602_hw_params, - .shutdown = ssm2602_shutdown, - .digital_mute = ssm2602_mute, - .set_sysclk = ssm2602_set_dai_sysclk, - .set_fmt = ssm2602_set_dai_fmt, - } + .ops = &ssm2602_dai_ops, }; EXPORT_SYMBOL_GPL(ssm2602_dai); diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 8b20c360adf..c3f4afb5d01 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -580,6 +580,15 @@ static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec, #define AIC23_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops tlv320aic23_dai_ops = { + .prepare = tlv320aic23_pcm_prepare, + .hw_params = tlv320aic23_hw_params, + .shutdown = tlv320aic23_shutdown, + .digital_mute = tlv320aic23_mute, + .set_fmt = tlv320aic23_set_dai_fmt, + .set_sysclk = tlv320aic23_set_dai_sysclk, +}; + struct snd_soc_dai tlv320aic23_dai = { .name = "tlv320aic23", .playback = { @@ -594,14 +603,7 @@ struct snd_soc_dai tlv320aic23_dai = { .channels_max = 2, .rates = AIC23_RATES, .formats = AIC23_FORMATS,}, - .ops = { - .prepare = tlv320aic23_pcm_prepare, - .hw_params = tlv320aic23_hw_params, - .shutdown = tlv320aic23_shutdown, - .digital_mute = tlv320aic23_mute, - .set_fmt = tlv320aic23_set_dai_fmt, - .set_sysclk = tlv320aic23_set_dai_sysclk, - } + .ops = &tlv320aic23_dai_ops, }; EXPORT_SYMBOL_GPL(tlv320aic23_dai); diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 229e464cf71..a7f333fc579 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -270,6 +270,13 @@ static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) #define AIC26_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE |\ SNDRV_PCM_FMTBIT_S24_BE | SNDRV_PCM_FMTBIT_S32_BE) +static struct snd_soc_dai_ops aic26_dai_ops = { + .hw_params = aic26_hw_params, + .digital_mute = aic26_mute, + .set_sysclk = aic26_set_sysclk, + .set_fmt = aic26_set_fmt, +}; + struct snd_soc_dai aic26_dai = { .name = "tlv320aic26", .playback = { @@ -286,12 +293,7 @@ struct snd_soc_dai aic26_dai = { .rates = AIC26_RATES, .formats = AIC26_FORMATS, }, - .ops = { - .hw_params = aic26_hw_params, - .digital_mute = aic26_mute, - .set_sysclk = aic26_set_sysclk, - .set_fmt = aic26_set_fmt, - }, + .ops = &aic26_dai_ops, }; EXPORT_SYMBOL_GPL(aic26_dai); diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index d638e3f0728..ab099f48248 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -1088,6 +1088,13 @@ EXPORT_SYMBOL_GPL(aic3x_button_pressed); #define AIC3X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops aic3x_dai_ops = { + .hw_params = aic3x_hw_params, + .digital_mute = aic3x_mute, + .set_sysclk = aic3x_set_dai_sysclk, + .set_fmt = aic3x_set_dai_fmt, +}; + struct snd_soc_dai aic3x_dai = { .name = "tlv320aic3x", .playback = { @@ -1102,12 +1109,7 @@ struct snd_soc_dai aic3x_dai = { .channels_max = 2, .rates = AIC3X_RATES, .formats = AIC3X_FORMATS,}, - .ops = { - .hw_params = aic3x_hw_params, - .digital_mute = aic3x_mute, - .set_sysclk = aic3x_set_dai_sysclk, - .set_fmt = aic3x_set_dai_fmt, - } + .ops = &aic3x_dai_ops, }; EXPORT_SYMBOL_GPL(aic3x_dai); diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index 661599295ca..ddefb8f8014 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -431,6 +431,15 @@ SOC_ENUM("PCM Playback De-emphasis", uda134x_mixer_enum[1]), SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), }; +static struct snd_soc_dai_ops uda134x_dai_ops = { + .startup = uda134x_startup, + .shutdown = uda134x_shutdown, + .hw_params = uda134x_hw_params, + .digital_mute = uda134x_mute, + .set_sysclk = uda134x_set_dai_sysclk, + .set_fmt = uda134x_set_dai_fmt, +}; + struct snd_soc_dai uda134x_dai = { .name = "UDA134X", /* playback capabilities */ @@ -450,14 +459,7 @@ struct snd_soc_dai uda134x_dai = { .formats = UDA134X_FORMATS, }, /* pcm operations */ - .ops = { - .startup = uda134x_startup, - .shutdown = uda134x_shutdown, - .hw_params = uda134x_hw_params, - .digital_mute = uda134x_mute, - .set_sysclk = uda134x_set_dai_sysclk, - .set_fmt = uda134x_set_dai_fmt, - } + .ops = &uda134x_dai_ops, }; EXPORT_SYMBOL(uda134x_dai); diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 5242b8156b3..cafa7684c0e 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -583,6 +583,29 @@ static int uda1380_set_bias_level(struct snd_soc_codec *codec, SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops uda1380_dai_ops = { + .hw_params = uda1380_pcm_hw_params, + .shutdown = uda1380_pcm_shutdown, + .prepare = uda1380_pcm_prepare, + .digital_mute = uda1380_mute, + .set_fmt = uda1380_set_dai_fmt_both, +}; + +static struct snd_soc_dai_ops uda1380_dai_ops_playback = { + .hw_params = uda1380_pcm_hw_params, + .shutdown = uda1380_pcm_shutdown, + .prepare = uda1380_pcm_prepare, + .digital_mute = uda1380_mute, + .set_fmt = uda1380_set_dai_fmt_playback, +}; + +static struct snd_soc_dai_ops uda1380_dai_ops_capture = { + .hw_params = uda1380_pcm_hw_params, + .shutdown = uda1380_pcm_shutdown, + .prepare = uda1380_pcm_prepare, + .set_fmt = uda1380_set_dai_fmt_capture, +}; + struct snd_soc_dai uda1380_dai[] = { { .name = "UDA1380", @@ -598,13 +621,7 @@ struct snd_soc_dai uda1380_dai[] = { .channels_max = 2, .rates = UDA1380_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = uda1380_pcm_hw_params, - .shutdown = uda1380_pcm_shutdown, - .prepare = uda1380_pcm_prepare, - .digital_mute = uda1380_mute, - .set_fmt = uda1380_set_dai_fmt_both, - }, + .ops = &uda1380_dai_ops, }, { /* playback only - dual interface */ .name = "UDA1380", @@ -615,13 +632,7 @@ struct snd_soc_dai uda1380_dai[] = { .rates = UDA1380_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = { - .hw_params = uda1380_pcm_hw_params, - .shutdown = uda1380_pcm_shutdown, - .prepare = uda1380_pcm_prepare, - .digital_mute = uda1380_mute, - .set_fmt = uda1380_set_dai_fmt_playback, - }, + .ops = &uda1380_dai_ops_playback, }, { /* capture only - dual interface*/ .name = "UDA1380", @@ -632,12 +643,7 @@ struct snd_soc_dai uda1380_dai[] = { .rates = UDA1380_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = { - .hw_params = uda1380_pcm_hw_params, - .shutdown = uda1380_pcm_shutdown, - .prepare = uda1380_pcm_prepare, - .set_fmt = uda1380_set_dai_fmt_capture, - }, + .ops = &uda1380_dai_ops_capture, }, }; EXPORT_SYMBOL_GPL(uda1380_dai); diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 359e5cc86f3..3b1d0993bed 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1538,6 +1538,16 @@ static int wm8350_remove(struct platform_device *pdev) SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static struct snd_soc_dai_ops wm8350_dai_ops = { + .hw_params = wm8350_pcm_hw_params, + .digital_mute = wm8350_mute, + .trigger = wm8350_pcm_trigger, + .set_fmt = wm8350_set_dai_fmt, + .set_sysclk = wm8350_set_dai_sysclk, + .set_pll = wm8350_set_fll, + .set_clkdiv = wm8350_set_clkdiv, +}; + struct snd_soc_dai wm8350_dai = { .name = "WM8350", .playback = { @@ -1554,15 +1564,7 @@ struct snd_soc_dai wm8350_dai = { .rates = WM8350_RATES, .formats = WM8350_FORMATS, }, - .ops = { - .hw_params = wm8350_pcm_hw_params, - .digital_mute = wm8350_mute, - .trigger = wm8350_pcm_trigger, - .set_fmt = wm8350_set_dai_fmt, - .set_sysclk = wm8350_set_dai_sysclk, - .set_pll = wm8350_set_fll, - .set_clkdiv = wm8350_set_clkdiv, - }, + .ops = &wm8350_dai_ops, }; EXPORT_SYMBOL_GPL(wm8350_dai); diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index f01078cfbd7..cc975a62fa5 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -554,6 +554,14 @@ static int wm8510_set_bias_level(struct snd_soc_codec *codec, #define WM8510_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops wm8510_dai_ops = { + .hw_params = wm8510_pcm_hw_params, + .digital_mute = wm8510_mute, + .set_fmt = wm8510_set_dai_fmt, + .set_clkdiv = wm8510_set_dai_clkdiv, + .set_pll = wm8510_set_dai_pll, +}; + struct snd_soc_dai wm8510_dai = { .name = "WM8510 HiFi", .playback = { @@ -568,13 +576,7 @@ struct snd_soc_dai wm8510_dai = { .channels_max = 2, .rates = WM8510_RATES, .formats = WM8510_FORMATS,}, - .ops = { - .hw_params = wm8510_pcm_hw_params, - .digital_mute = wm8510_mute, - .set_fmt = wm8510_set_dai_fmt, - .set_clkdiv = wm8510_set_dai_clkdiv, - .set_pll = wm8510_set_dai_pll, - }, + .ops = &wm8510_dai_ops, }; EXPORT_SYMBOL_GPL(wm8510_dai); diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index d3c51ba5e6f..ee0af23a1ac 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -771,6 +771,21 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec, #define WM8580_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops wm8580_dai_ops_playback = { + .hw_params = wm8580_paif_hw_params, + .set_fmt = wm8580_set_paif_dai_fmt, + .set_clkdiv = wm8580_set_dai_clkdiv, + .set_pll = wm8580_set_dai_pll, + .digital_mute = wm8580_digital_mute, +}; + +static struct snd_soc_dai_ops wm8580_dai_ops_capture = { + .hw_params = wm8580_paif_hw_params, + .set_fmt = wm8580_set_paif_dai_fmt, + .set_clkdiv = wm8580_set_dai_clkdiv, + .set_pll = wm8580_set_dai_pll, +}; + struct snd_soc_dai wm8580_dai[] = { { .name = "WM8580 PAIFRX", @@ -782,13 +797,7 @@ struct snd_soc_dai wm8580_dai[] = { .rates = SNDRV_PCM_RATE_8000_192000, .formats = WM8580_FORMATS, }, - .ops = { - .hw_params = wm8580_paif_hw_params, - .set_fmt = wm8580_set_paif_dai_fmt, - .set_clkdiv = wm8580_set_dai_clkdiv, - .set_pll = wm8580_set_dai_pll, - .digital_mute = wm8580_digital_mute, - }, + .ops = &wm8580_dai_ops_playback, }, { .name = "WM8580 PAIFTX", @@ -800,12 +809,7 @@ struct snd_soc_dai wm8580_dai[] = { .rates = SNDRV_PCM_RATE_8000_192000, .formats = WM8580_FORMATS, }, - .ops = { - .hw_params = wm8580_paif_hw_params, - .set_fmt = wm8580_set_paif_dai_fmt, - .set_clkdiv = wm8580_set_dai_clkdiv, - .set_pll = wm8580_set_dai_pll, - }, + .ops = &wm8580_dai_ops_capture, }, }; EXPORT_SYMBOL_GPL(wm8580_dai); diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index f8363b30889..e7ff2121ede 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -244,6 +244,12 @@ static int wm8728_set_bias_level(struct snd_soc_codec *codec, #define WM8728_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static struct snd_soc_dai_ops wm8728_dai_ops = { + .hw_params = wm8728_hw_params, + .digital_mute = wm8728_mute, + .set_fmt = wm8728_set_dai_fmt, +}; + struct snd_soc_dai wm8728_dai = { .name = "WM8728", .playback = { @@ -253,11 +259,7 @@ struct snd_soc_dai wm8728_dai = { .rates = WM8728_RATES, .formats = WM8728_FORMATS, }, - .ops = { - .hw_params = wm8728_hw_params, - .digital_mute = wm8728_mute, - .set_fmt = wm8728_set_dai_fmt, - } + .ops = &wm8728_dai_ops, }; EXPORT_SYMBOL_GPL(wm8728_dai); diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 9e7ebcc2c49..e043e3f6000 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -433,6 +433,15 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, #define WM8731_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static struct snd_soc_dai_ops wm8731_dai_ops = { + .prepare = wm8731_pcm_prepare, + .hw_params = wm8731_hw_params, + .shutdown = wm8731_shutdown, + .digital_mute = wm8731_mute, + .set_sysclk = wm8731_set_dai_sysclk, + .set_fmt = wm8731_set_dai_fmt, +}; + struct snd_soc_dai wm8731_dai = { .name = "WM8731", .playback = { @@ -447,14 +456,7 @@ struct snd_soc_dai wm8731_dai = { .channels_max = 2, .rates = WM8731_RATES, .formats = WM8731_FORMATS,}, - .ops = { - .prepare = wm8731_pcm_prepare, - .hw_params = wm8731_hw_params, - .shutdown = wm8731_shutdown, - .digital_mute = wm8731_mute, - .set_sysclk = wm8731_set_dai_sysclk, - .set_fmt = wm8731_set_dai_fmt, - } + .ops = &wm8731_dai_ops, }; EXPORT_SYMBOL_GPL(wm8731_dai); diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 96afb86addc..b64509b01a4 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -679,6 +679,13 @@ static int wm8750_set_bias_level(struct snd_soc_codec *codec, #define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static struct snd_soc_dai_ops wm8750_dai_ops = { + .hw_params = wm8750_pcm_hw_params, + .digital_mute = wm8750_mute, + .set_fmt = wm8750_set_dai_fmt, + .set_sysclk = wm8750_set_dai_sysclk, +}; + struct snd_soc_dai wm8750_dai = { .name = "WM8750", .playback = { @@ -693,12 +700,7 @@ struct snd_soc_dai wm8750_dai = { .channels_max = 2, .rates = WM8750_RATES, .formats = WM8750_FORMATS,}, - .ops = { - .hw_params = wm8750_pcm_hw_params, - .digital_mute = wm8750_mute, - .set_fmt = wm8750_set_dai_fmt, - .set_sysclk = wm8750_set_dai_sysclk, - }, + .ops = &wm8750_dai_ops, }; EXPORT_SYMBOL_GPL(wm8750_dai); diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 7f353e935d7..cc6e57f9acf 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1306,6 +1306,51 @@ static int wm8753_set_bias_level(struct snd_soc_codec *codec, * 3. Voice disabled - HIFI over HIFI * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture */ +static struct snd_soc_dai_ops wm8753_dai_ops_hifi_mode1 = { + .hw_params = wm8753_i2s_hw_params, + .digital_mute = wm8753_mute, + .set_fmt = wm8753_mode1h_set_dai_fmt, + .set_clkdiv = wm8753_set_dai_clkdiv, + .set_pll = wm8753_set_dai_pll, + .set_sysclk = wm8753_set_dai_sysclk, +}; + +static struct snd_soc_dai_ops wm8753_dai_ops_voice_mode1 = { + .hw_params = wm8753_pcm_hw_params, + .digital_mute = wm8753_mute, + .set_fmt = wm8753_mode1v_set_dai_fmt, + .set_clkdiv = wm8753_set_dai_clkdiv, + .set_pll = wm8753_set_dai_pll, + .set_sysclk = wm8753_set_dai_sysclk, +}; + +static struct snd_soc_dai_ops wm8753_dai_ops_voice_mode2 = { + .hw_params = wm8753_pcm_hw_params, + .digital_mute = wm8753_mute, + .set_fmt = wm8753_mode2_set_dai_fmt, + .set_clkdiv = wm8753_set_dai_clkdiv, + .set_pll = wm8753_set_dai_pll, + .set_sysclk = wm8753_set_dai_sysclk, +}; + +static struct snd_soc_dai_ops wm8753_dai_ops_hifi_mode3 = { + .hw_params = wm8753_i2s_hw_params, + .digital_mute = wm8753_mute, + .set_fmt = wm8753_mode3_4_set_dai_fmt, + .set_clkdiv = wm8753_set_dai_clkdiv, + .set_pll = wm8753_set_dai_pll, + .set_sysclk = wm8753_set_dai_sysclk, +}; + +static struct snd_soc_dai_ops wm8753_dai_ops_hifi_mode4 = { + .hw_params = wm8753_i2s_hw_params, + .digital_mute = wm8753_mute, + .set_fmt = wm8753_mode3_4_set_dai_fmt, + .set_clkdiv = wm8753_set_dai_clkdiv, + .set_pll = wm8753_set_dai_pll, + .set_sysclk = wm8753_set_dai_sysclk, +}; + static const struct snd_soc_dai wm8753_all_dai[] = { /* DAI HiFi mode 1 */ { .name = "WM8753 HiFi", @@ -1322,14 +1367,7 @@ static const struct snd_soc_dai wm8753_all_dai[] = { .channels_max = 2, .rates = WM8753_RATES, .formats = WM8753_FORMATS}, - .ops = { - .hw_params = wm8753_i2s_hw_params, - .digital_mute = wm8753_mute, - .set_fmt = wm8753_mode1h_set_dai_fmt, - .set_clkdiv = wm8753_set_dai_clkdiv, - .set_pll = wm8753_set_dai_pll, - .set_sysclk = wm8753_set_dai_sysclk, - }, + .ops = &wm8753_dai_ops_hifi_mode1, }, /* DAI Voice mode 1 */ { .name = "WM8753 Voice", @@ -1346,14 +1384,7 @@ static const struct snd_soc_dai wm8753_all_dai[] = { .channels_max = 2, .rates = WM8753_RATES, .formats = WM8753_FORMATS,}, - .ops = { - .hw_params = wm8753_pcm_hw_params, - .digital_mute = wm8753_mute, - .set_fmt = wm8753_mode1v_set_dai_fmt, - .set_clkdiv = wm8753_set_dai_clkdiv, - .set_pll = wm8753_set_dai_pll, - .set_sysclk = wm8753_set_dai_sysclk, - }, + .ops = &wm8753_dai_ops_voice_mode1, }, /* DAI HiFi mode 2 - dummy */ { .name = "WM8753 HiFi", @@ -1374,14 +1405,7 @@ static const struct snd_soc_dai wm8753_all_dai[] = { .channels_max = 2, .rates = WM8753_RATES, .formats = WM8753_FORMATS,}, - .ops = { - .hw_params = wm8753_pcm_hw_params, - .digital_mute = wm8753_mute, - .set_fmt = wm8753_mode2_set_dai_fmt, - .set_clkdiv = wm8753_set_dai_clkdiv, - .set_pll = wm8753_set_dai_pll, - .set_sysclk = wm8753_set_dai_sysclk, - }, + .ops = &wm8753_dai_ops_voice_mode2, }, /* DAI HiFi mode 3 */ { .name = "WM8753 HiFi", @@ -1398,14 +1422,7 @@ static const struct snd_soc_dai wm8753_all_dai[] = { .channels_max = 2, .rates = WM8753_RATES, .formats = WM8753_FORMATS,}, - .ops = { - .hw_params = wm8753_i2s_hw_params, - .digital_mute = wm8753_mute, - .set_fmt = wm8753_mode3_4_set_dai_fmt, - .set_clkdiv = wm8753_set_dai_clkdiv, - .set_pll = wm8753_set_dai_pll, - .set_sysclk = wm8753_set_dai_sysclk, - }, + .ops = &wm8753_dai_ops_hifi_mode3, }, /* DAI Voice mode 3 - dummy */ { .name = "WM8753 Voice", @@ -1426,14 +1443,7 @@ static const struct snd_soc_dai wm8753_all_dai[] = { .channels_max = 2, .rates = WM8753_RATES, .formats = WM8753_FORMATS,}, - .ops = { - .hw_params = wm8753_i2s_hw_params, - .digital_mute = wm8753_mute, - .set_fmt = wm8753_mode3_4_set_dai_fmt, - .set_clkdiv = wm8753_set_dai_clkdiv, - .set_pll = wm8753_set_dai_pll, - .set_sysclk = wm8753_set_dai_sysclk, - }, + .ops = &wm8753_dai_ops_hifi_mode4, }, /* DAI Voice mode 4 - dummy */ { .name = "WM8753 Voice", diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index da5ca64f89b..46c5ea1ff92 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -1088,6 +1088,14 @@ static int wm8900_digital_mute(struct snd_soc_dai *codec_dai, int mute) (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \ SNDRV_PCM_FORMAT_S24_LE) +static struct snd_soc_dai_ops wm8900_dai_ops = { + .hw_params = wm8900_hw_params, + .set_clkdiv = wm8900_set_dai_clkdiv, + .set_pll = wm8900_set_dai_pll, + .set_fmt = wm8900_set_dai_fmt, + .digital_mute = wm8900_digital_mute, +}; + struct snd_soc_dai wm8900_dai = { .name = "WM8900 HiFi", .playback = { @@ -1104,13 +1112,7 @@ struct snd_soc_dai wm8900_dai = { .rates = WM8900_RATES, .formats = WM8900_PCM_FORMATS, }, - .ops = { - .hw_params = wm8900_hw_params, - .set_clkdiv = wm8900_set_dai_clkdiv, - .set_pll = wm8900_set_dai_pll, - .set_fmt = wm8900_set_dai_fmt, - .digital_mute = wm8900_digital_mute, - }, + .ops = &wm8900_dai_ops, }; EXPORT_SYMBOL_GPL(wm8900_dai); diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index c6fa8a71b4d..8cf571f1a80 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -1497,6 +1497,15 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static struct snd_soc_dai_ops wm8903_dai_ops = { + .startup = wm8903_startup, + .shutdown = wm8903_shutdown, + .hw_params = wm8903_hw_params, + .digital_mute = wm8903_digital_mute, + .set_fmt = wm8903_set_dai_fmt, + .set_sysclk = wm8903_set_dai_sysclk, +}; + struct snd_soc_dai wm8903_dai = { .name = "WM8903", .playback = { @@ -1513,14 +1522,7 @@ struct snd_soc_dai wm8903_dai = { .rates = WM8903_CAPTURE_RATES, .formats = WM8903_FORMATS, }, - .ops = { - .startup = wm8903_startup, - .shutdown = wm8903_shutdown, - .hw_params = wm8903_hw_params, - .digital_mute = wm8903_digital_mute, - .set_fmt = wm8903_set_dai_fmt, - .set_sysclk = wm8903_set_dai_sysclk - } + .ops = &wm8903_dai_ops, }; EXPORT_SYMBOL_GPL(wm8903_dai); diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 24d4c905a01..032dca22dbd 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -604,6 +604,13 @@ static int wm8971_set_bias_level(struct snd_soc_codec *codec, #define WM8971_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static struct snd_soc_dai_ops wm8971_dai_ops = { + .hw_params = wm8971_pcm_hw_params, + .digital_mute = wm8971_mute, + .set_fmt = wm8971_set_dai_fmt, + .set_sysclk = wm8971_set_dai_sysclk, +}; + struct snd_soc_dai wm8971_dai = { .name = "WM8971", .playback = { @@ -618,12 +625,7 @@ struct snd_soc_dai wm8971_dai = { .channels_max = 2, .rates = WM8971_RATES, .formats = WM8971_FORMATS,}, - .ops = { - .hw_params = wm8971_pcm_hw_params, - .digital_mute = wm8971_mute, - .set_fmt = wm8971_set_dai_fmt, - .set_sysclk = wm8971_set_dai_sysclk, - }, + .ops = &wm8971_dai_ops, }; EXPORT_SYMBOL_GPL(wm8971_dai); diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 1a38421f759..c518c3e5aa3 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -1332,6 +1332,15 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, * 1. ADC/DAC on Primary Interface * 2. ADC on Primary Interface/DAC on secondary */ +static struct snd_soc_dai_ops wm8990_dai_ops = { + .hw_params = wm8990_hw_params, + .digital_mute = wm8990_mute, + .set_fmt = wm8990_set_dai_fmt, + .set_clkdiv = wm8990_set_dai_clkdiv, + .set_pll = wm8990_set_dai_pll, + .set_sysclk = wm8990_set_dai_sysclk, +}; + struct snd_soc_dai wm8990_dai = { /* ADC/DAC on primary */ .name = "WM8990 ADC/DAC Primary", @@ -1348,14 +1357,7 @@ struct snd_soc_dai wm8990_dai = { .channels_max = 2, .rates = WM8990_RATES, .formats = WM8990_FORMATS,}, - .ops = { - .hw_params = wm8990_hw_params, - .digital_mute = wm8990_mute, - .set_fmt = wm8990_set_dai_fmt, - .set_clkdiv = wm8990_set_dai_clkdiv, - .set_pll = wm8990_set_dai_pll, - .set_sysclk = wm8990_set_dai_sysclk, - }, + .ops = &wm8990_dai_ops, }; EXPORT_SYMBOL_GPL(wm8990_dai); diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index 2e9e06b2daa..3265817c5c2 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -269,6 +269,10 @@ static int ac97_prepare(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops wm9705_dai_ops = { + .prepare = ac97_prepare, +}; + struct snd_soc_dai wm9705_dai[] = { { .name = "AC97 HiFi", @@ -287,9 +291,7 @@ struct snd_soc_dai wm9705_dai[] = { .rates = WM9705_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = { - .prepare = ac97_prepare, - }, + .ops = &wm9705_dai_ops, }, { .name = "AC97 Aux", diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index b3a8be77676..765cf1e7369 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -517,6 +517,14 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\ SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops wm9712_dai_ops_hifi = { + .prepare = ac97_prepare, +}; + +static struct snd_soc_dai_ops wm9712_dai_ops_aux = { + .prepare = ac97_aux_prepare, +}; + struct snd_soc_dai wm9712_dai[] = { { .name = "AC97 HiFi", @@ -533,8 +541,7 @@ struct snd_soc_dai wm9712_dai[] = { .channels_max = 2, .rates = WM9712_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .prepare = ac97_prepare,}, + .ops = &wm9712_dai_ops_hifi, }, { .name = "AC97 Aux", @@ -544,8 +551,7 @@ struct snd_soc_dai wm9712_dai[] = { .channels_max = 1, .rates = WM9712_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .prepare = ac97_aux_prepare,}, + .ops = &wm9712_dai_ops_aux, } }; EXPORT_SYMBOL_GPL(wm9712_dai); diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index a93aea5c187..523bad077fa 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -1005,6 +1005,27 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream, (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \ SNDRV_PCM_FORMAT_S24_LE) +static struct snd_soc_dai_ops wm9713_dai_ops_hifi = { + .prepare = ac97_hifi_prepare, + .set_clkdiv = wm9713_set_dai_clkdiv, + .set_pll = wm9713_set_dai_pll, +}; + +static struct snd_soc_dai_ops wm9713_dai_ops_aux = { + .prepare = ac97_aux_prepare, + .set_clkdiv = wm9713_set_dai_clkdiv, + .set_pll = wm9713_set_dai_pll, +}; + +static struct snd_soc_dai_ops wm9713_dai_ops_voice = { + .hw_params = wm9713_pcm_hw_params, + .shutdown = wm9713_voiceshutdown, + .set_clkdiv = wm9713_set_dai_clkdiv, + .set_pll = wm9713_set_dai_pll, + .set_fmt = wm9713_set_dai_fmt, + .set_tristate = wm9713_set_dai_tristate, +}; + struct snd_soc_dai wm9713_dai[] = { { .name = "AC97 HiFi", @@ -1021,10 +1042,7 @@ struct snd_soc_dai wm9713_dai[] = { .channels_max = 2, .rates = WM9713_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .prepare = ac97_hifi_prepare, - .set_clkdiv = wm9713_set_dai_clkdiv, - .set_pll = wm9713_set_dai_pll,}, + .ops = &wm9713_dai_ops_hifi, }, { .name = "AC97 Aux", @@ -1034,10 +1052,7 @@ struct snd_soc_dai wm9713_dai[] = { .channels_max = 1, .rates = WM9713_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .prepare = ac97_aux_prepare, - .set_clkdiv = wm9713_set_dai_clkdiv, - .set_pll = wm9713_set_dai_pll,}, + .ops = &wm9713_dai_ops_aux, }, { .name = "WM9713 Voice", @@ -1053,14 +1068,7 @@ struct snd_soc_dai wm9713_dai[] = { .channels_max = 2, .rates = WM9713_PCM_RATES, .formats = WM9713_PCM_FORMATS,}, - .ops = { - .hw_params = wm9713_pcm_hw_params, - .shutdown = wm9713_voiceshutdown, - .set_clkdiv = wm9713_set_dai_clkdiv, - .set_pll = wm9713_set_dai_pll, - .set_fmt = wm9713_set_dai_fmt, - .set_tristate = wm9713_set_dai_tristate, - }, + .ops = &wm9713_dai_ops_voice, }, }; EXPORT_SYMBOL_GPL(wm9713_dai); diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 0fee779e3c7..ffdb9439d3d 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -499,6 +499,13 @@ static void davinci_i2s_remove(struct platform_device *pdev, #define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 +static struct snd_soc_dai_ops davinci_i2s_dai_ops = { + .startup = davinci_i2s_startup, + .trigger = davinci_i2s_trigger, + .hw_params = davinci_i2s_hw_params, + .set_fmt = davinci_i2s_set_dai_fmt, +}; + struct snd_soc_dai davinci_i2s_dai = { .name = "davinci-i2s", .id = 0, @@ -514,12 +521,7 @@ struct snd_soc_dai davinci_i2s_dai = { .channels_max = 2, .rates = DAVINCI_I2S_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .startup = davinci_i2s_startup, - .trigger = davinci_i2s_trigger, - .hw_params = davinci_i2s_hw_params, - .set_fmt = davinci_i2s_set_dai_fmt, - }, + .ops = &davinci_i2s_dai_ops, }; EXPORT_SYMBOL_GPL(davinci_i2s_dai); diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 6844009833d..0fddd437a7c 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -562,6 +562,15 @@ static int fsl_ssi_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) /** * fsl_ssi_dai_template: template CPU DAI for the SSI */ +static struct snd_soc_dai_ops fsl_ssi_dai_ops = { + .startup = fsl_ssi_startup, + .hw_params = fsl_ssi_hw_params, + .shutdown = fsl_ssi_shutdown, + .trigger = fsl_ssi_trigger, + .set_sysclk = fsl_ssi_set_sysclk, + .set_fmt = fsl_ssi_set_fmt, +}; + static struct snd_soc_dai fsl_ssi_dai_template = { .playback = { /* The SSI does not support monaural audio. */ @@ -576,14 +585,7 @@ static struct snd_soc_dai fsl_ssi_dai_template = { .rates = FSLSSI_I2S_RATES, .formats = FSLSSI_I2S_FORMATS, }, - .ops = { - .startup = fsl_ssi_startup, - .hw_params = fsl_ssi_hw_params, - .shutdown = fsl_ssi_shutdown, - .trigger = fsl_ssi_trigger, - .set_sysclk = fsl_ssi_set_sysclk, - .set_fmt = fsl_ssi_set_fmt, - }, + .ops = &fsl_ssi_dai_ops, }; /** diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c index 9eb1ce185bd..3aa729df27b 100644 --- a/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/sound/soc/fsl/mpc5200_psc_i2s.c @@ -468,6 +468,16 @@ static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) /** * psc_i2s_dai_template: template CPU Digital Audio Interface */ +static struct snd_soc_dai_ops psc_i2s_dai_ops = { + .startup = psc_i2s_startup, + .hw_params = psc_i2s_hw_params, + .hw_free = psc_i2s_hw_free, + .shutdown = psc_i2s_shutdown, + .trigger = psc_i2s_trigger, + .set_sysclk = psc_i2s_set_sysclk, + .set_fmt = psc_i2s_set_fmt, +}; + static struct snd_soc_dai psc_i2s_dai_template = { .playback = { .channels_min = 2, @@ -481,15 +491,7 @@ static struct snd_soc_dai psc_i2s_dai_template = { .rates = PSC_I2S_RATES, .formats = PSC_I2S_FORMATS, }, - .ops = { - .startup = psc_i2s_startup, - .hw_params = psc_i2s_hw_params, - .hw_free = psc_i2s_hw_free, - .shutdown = psc_i2s_shutdown, - .trigger = psc_i2s_trigger, - .set_sysclk = psc_i2s_set_sysclk, - .set_fmt = psc_i2s_set_fmt, - }, + .ops = &psc_i2s_dai_ops, }; /* --------------------------------------------------------------------- diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 05dd5abcddf..d6882be3345 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -461,6 +461,16 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, return err; } +static struct snd_soc_dai_ops omap_mcbsp_dai_ops = { + .startup = omap_mcbsp_dai_startup, + .shutdown = omap_mcbsp_dai_shutdown, + .trigger = omap_mcbsp_dai_trigger, + .hw_params = omap_mcbsp_dai_hw_params, + .set_fmt = omap_mcbsp_dai_set_dai_fmt, + .set_clkdiv = omap_mcbsp_dai_set_clkdiv, + .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, +}; + #define OMAP_MCBSP_DAI_BUILDER(link_id) \ { \ .name = "omap-mcbsp-dai-"#link_id, \ @@ -477,15 +487,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai, .rates = OMAP_MCBSP_RATES, \ .formats = SNDRV_PCM_FMTBIT_S16_LE, \ }, \ - .ops = { \ - .startup = omap_mcbsp_dai_startup, \ - .shutdown = omap_mcbsp_dai_shutdown, \ - .trigger = omap_mcbsp_dai_trigger, \ - .hw_params = omap_mcbsp_dai_hw_params, \ - .set_fmt = omap_mcbsp_dai_set_dai_fmt, \ - .set_clkdiv = omap_mcbsp_dai_set_clkdiv, \ - .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, \ - }, \ + .ops = &omap_mcbsp_dai_ops, \ .private_data = &mcbsp_data[(link_id)].bus_id, \ } diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 4a973ab710b..3e18064e86b 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -784,6 +784,19 @@ static void pxa_ssp_remove(struct platform_device *pdev, SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) +static struct snd_soc_dai_ops pxa_ssp_dai_ops = { + .startup = pxa_ssp_startup, + .shutdown = pxa_ssp_shutdown, + .trigger = pxa_ssp_trigger, + .hw_params = pxa_ssp_hw_params, + .set_sysclk = pxa_ssp_set_dai_sysclk, + .set_clkdiv = pxa_ssp_set_dai_clkdiv, + .set_pll = pxa_ssp_set_dai_pll, + .set_fmt = pxa_ssp_set_dai_fmt, + .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, + .set_tristate = pxa_ssp_set_dai_tristate, +}; + struct snd_soc_dai pxa_ssp_dai[] = { { .name = "pxa2xx-ssp1", @@ -804,18 +817,7 @@ struct snd_soc_dai pxa_ssp_dai[] = { .rates = PXA_SSP_RATES, .formats = PXA_SSP_FORMATS, }, - .ops = { - .startup = pxa_ssp_startup, - .shutdown = pxa_ssp_shutdown, - .trigger = pxa_ssp_trigger, - .hw_params = pxa_ssp_hw_params, - .set_sysclk = pxa_ssp_set_dai_sysclk, - .set_clkdiv = pxa_ssp_set_dai_clkdiv, - .set_pll = pxa_ssp_set_dai_pll, - .set_fmt = pxa_ssp_set_dai_fmt, - .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, - .set_tristate = pxa_ssp_set_dai_tristate, - }, + .ops = &pxa_ssp_dai_ops, }, { .name = "pxa2xx-ssp2", .id = 1, @@ -835,18 +837,7 @@ struct snd_soc_dai pxa_ssp_dai[] = { .rates = PXA_SSP_RATES, .formats = PXA_SSP_FORMATS, }, - .ops = { - .startup = pxa_ssp_startup, - .shutdown = pxa_ssp_shutdown, - .trigger = pxa_ssp_trigger, - .hw_params = pxa_ssp_hw_params, - .set_sysclk = pxa_ssp_set_dai_sysclk, - .set_clkdiv = pxa_ssp_set_dai_clkdiv, - .set_pll = pxa_ssp_set_dai_pll, - .set_fmt = pxa_ssp_set_dai_fmt, - .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, - .set_tristate = pxa_ssp_set_dai_tristate, - }, + .ops = &pxa_ssp_dai_ops, }, { .name = "pxa2xx-ssp3", @@ -867,18 +858,7 @@ struct snd_soc_dai pxa_ssp_dai[] = { .rates = PXA_SSP_RATES, .formats = PXA_SSP_FORMATS, }, - .ops = { - .startup = pxa_ssp_startup, - .shutdown = pxa_ssp_shutdown, - .trigger = pxa_ssp_trigger, - .hw_params = pxa_ssp_hw_params, - .set_sysclk = pxa_ssp_set_dai_sysclk, - .set_clkdiv = pxa_ssp_set_dai_clkdiv, - .set_pll = pxa_ssp_set_dai_pll, - .set_fmt = pxa_ssp_set_dai_fmt, - .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, - .set_tristate = pxa_ssp_set_dai_tristate, - }, + .ops = &pxa_ssp_dai_ops, }, { .name = "pxa2xx-ssp4", @@ -899,18 +879,7 @@ struct snd_soc_dai pxa_ssp_dai[] = { .rates = PXA_SSP_RATES, .formats = PXA_SSP_FORMATS, }, - .ops = { - .startup = pxa_ssp_startup, - .shutdown = pxa_ssp_shutdown, - .trigger = pxa_ssp_trigger, - .hw_params = pxa_ssp_hw_params, - .set_sysclk = pxa_ssp_set_dai_sysclk, - .set_clkdiv = pxa_ssp_set_dai_clkdiv, - .set_pll = pxa_ssp_set_dai_pll, - .set_fmt = pxa_ssp_set_dai_fmt, - .set_tdm_slot = pxa_ssp_set_dai_tdm_slot, - .set_tristate = pxa_ssp_set_dai_tristate, - }, + .ops = &pxa_ssp_dai_ops, }, }; EXPORT_SYMBOL_GPL(pxa_ssp_dai); diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 812c2b4d3e0..11cd0f289c1 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -164,6 +164,10 @@ static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops pxa_ac97_dai_ops = { + .hw_params = pxa2xx_ac97_hw_params, +}; + /* * There is only 1 physical AC97 interface for pxa2xx, but it * has extra fifo's that can be used for aux DACs and ADCs. @@ -189,8 +193,7 @@ struct snd_soc_dai pxa_ac97_dai[] = { .channels_max = 2, .rates = PXA2XX_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = pxa2xx_ac97_hw_params,}, + .ops = &pxa_ac97_dai_ops, }, { .name = "pxa2xx-ac97-aux", @@ -208,8 +211,7 @@ struct snd_soc_dai pxa_ac97_dai[] = { .channels_max = 1, .rates = PXA2XX_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = pxa2xx_ac97_hw_aux_params,}, + .ops = &pxa_ac97_dai_ops, }, { .name = "pxa2xx-ac97-mic", @@ -221,8 +223,7 @@ struct snd_soc_dai pxa_ac97_dai[] = { .channels_max = 1, .rates = PXA2XX_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = pxa2xx_ac97_hw_mic_params,}, + .ops = &pxa_ac97_dai_ops, }, }; diff --git a/sound/soc/pxa/pxa2xx-i2s.c b/sound/soc/pxa/pxa2xx-i2s.c index 83b59d7fe96..e6c24408c5f 100644 --- a/sound/soc/pxa/pxa2xx-i2s.c +++ b/sound/soc/pxa/pxa2xx-i2s.c @@ -304,6 +304,15 @@ static int pxa2xx_i2s_resume(struct snd_soc_dai *dai) SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000) +static struct snd_soc_dai_ops pxa_i2s_dai_ops = { + .startup = pxa2xx_i2s_startup, + .shutdown = pxa2xx_i2s_shutdown, + .trigger = pxa2xx_i2s_trigger, + .hw_params = pxa2xx_i2s_hw_params, + .set_fmt = pxa2xx_i2s_set_dai_fmt, + .set_sysclk = pxa2xx_i2s_set_dai_sysclk, +}; + struct snd_soc_dai pxa_i2s_dai = { .name = "pxa2xx-i2s", .id = 0, @@ -319,14 +328,7 @@ struct snd_soc_dai pxa_i2s_dai = { .channels_max = 2, .rates = PXA2XX_I2S_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .startup = pxa2xx_i2s_startup, - .shutdown = pxa2xx_i2s_shutdown, - .trigger = pxa2xx_i2s_trigger, - .hw_params = pxa2xx_i2s_hw_params, - .set_fmt = pxa2xx_i2s_set_dai_fmt, - .set_sysclk = pxa2xx_i2s_set_dai_sysclk, - }, + .ops = &pxa_i2s_dai_ops, }; EXPORT_SYMBOL_GPL(pxa_i2s_dai); diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index f3fc0aba0aa..382d7eee53e 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c @@ -708,6 +708,14 @@ static int s3c2412_i2s_resume(struct snd_soc_dai *dai) SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) +static struct snd_soc_dai_ops s3c2412_i2s_dai_ops = { + .trigger = s3c2412_i2s_trigger, + .hw_params = s3c2412_i2s_hw_params, + .set_fmt = s3c2412_i2s_set_fmt, + .set_clkdiv = s3c2412_i2s_set_clkdiv, + .set_sysclk = s3c2412_i2s_set_sysclk, +}; + struct snd_soc_dai s3c2412_i2s_dai = { .name = "s3c2412-i2s", .id = 0, @@ -726,13 +734,7 @@ struct snd_soc_dai s3c2412_i2s_dai = { .rates = S3C2412_I2S_RATES, .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = { - .trigger = s3c2412_i2s_trigger, - .hw_params = s3c2412_i2s_hw_params, - .set_fmt = s3c2412_i2s_set_fmt, - .set_clkdiv = s3c2412_i2s_set_clkdiv, - .set_sysclk = s3c2412_i2s_set_sysclk, - }, + .ops = &s3c2412_i2s_dai_ops, }; EXPORT_SYMBOL_GPL(s3c2412_i2s_dai); diff --git a/sound/soc/s3c24xx/s3c2443-ac97.c b/sound/soc/s3c24xx/s3c2443-ac97.c index 5822d2dd49b..83ea623234e 100644 --- a/sound/soc/s3c24xx/s3c2443-ac97.c +++ b/sound/soc/s3c24xx/s3c2443-ac97.c @@ -355,6 +355,11 @@ static int s3c2443_ac97_mic_trigger(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \ SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +static struct snd_soc_dai_ops s3c2443_ac97_dai_ops = { + .hw_params = s3c2443_ac97_hw_params, + .trigger = s3c2443_ac97_trigger, +}; + struct snd_soc_dai s3c2443_ac97_dai[] = { { .name = "s3c2443-ac97", @@ -374,9 +379,7 @@ struct snd_soc_dai s3c2443_ac97_dai[] = { .channels_max = 2, .rates = s3c2443_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = s3c2443_ac97_hw_params, - .trigger = s3c2443_ac97_trigger}, + .ops = &s3c2443_ac97_dai_ops, }, { .name = "pxa2xx-ac97-mic", @@ -388,9 +391,7 @@ struct snd_soc_dai s3c2443_ac97_dai[] = { .channels_max = 1, .rates = s3c2443_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .hw_params = s3c2443_ac97_hw_mic_params, - .trigger = s3c2443_ac97_mic_trigger,}, + .ops = &s3c2443_ac97_dai_ops, }, }; EXPORT_SYMBOL_GPL(s3c2443_ac97_dai); diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 1c2b0549710..4473fb584c4 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -456,6 +456,14 @@ static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) +static struct snd_soc_dai_ops s3c24xx_i2s_dai_ops = { + .trigger = s3c24xx_i2s_trigger, + .hw_params = s3c24xx_i2s_hw_params, + .set_fmt = s3c24xx_i2s_set_fmt, + .set_clkdiv = s3c24xx_i2s_set_clkdiv, + .set_sysclk = s3c24xx_i2s_set_sysclk, +}; + struct snd_soc_dai s3c24xx_i2s_dai = { .name = "s3c24xx-i2s", .id = 0, @@ -472,13 +480,7 @@ struct snd_soc_dai s3c24xx_i2s_dai = { .channels_max = 2, .rates = S3C24XX_I2S_RATES, .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = { - .trigger = s3c24xx_i2s_trigger, - .hw_params = s3c24xx_i2s_hw_params, - .set_fmt = s3c24xx_i2s_set_fmt, - .set_clkdiv = s3c24xx_i2s_set_clkdiv, - .set_sysclk = s3c24xx_i2s_set_sysclk, - }, + .ops = &s3c24xx_i2s_dai_ops, }; EXPORT_SYMBOL_GPL(s3c24xx_i2s_dai); diff --git a/sound/soc/sh/ssi.c b/sound/soc/sh/ssi.c index d1e5390fdde..56fa0872abb 100644 --- a/sound/soc/sh/ssi.c +++ b/sound/soc/sh/ssi.c @@ -336,6 +336,16 @@ static int ssi_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3LE | \ SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_U32_LE) +static struct snd_soc_dai_ops ssi_dai_ops = { + .startup = ssi_startup, + .shutdown = ssi_shutdown, + .trigger = ssi_trigger, + .hw_params = ssi_hw_params, + .set_sysclk = ssi_set_sysclk, + .set_clkdiv = ssi_set_clkdiv, + .set_fmt = ssi_set_fmt, +}; + struct snd_soc_dai sh4_ssi_dai[] = { { .name = "SSI0", @@ -352,15 +362,7 @@ struct snd_soc_dai sh4_ssi_dai[] = { .channels_min = 2, .channels_max = 8, }, - .ops = { - .startup = ssi_startup, - .shutdown = ssi_shutdown, - .trigger = ssi_trigger, - .hw_params = ssi_hw_params, - .set_sysclk = ssi_set_sysclk, - .set_clkdiv = ssi_set_clkdiv, - .set_fmt = ssi_set_fmt, - }, + .ops = &ssi_dai_ops, }, #ifdef CONFIG_CPU_SUBTYPE_SH7760 { @@ -378,15 +380,7 @@ struct snd_soc_dai sh4_ssi_dai[] = { .channels_min = 2, .channels_max = 8, }, - .ops = { - .startup = ssi_startup, - .shutdown = ssi_shutdown, - .trigger = ssi_trigger, - .hw_params = ssi_hw_params, - .set_sysclk = ssi_set_sysclk, - .set_clkdiv = ssi_set_clkdiv, - .set_fmt = ssi_set_fmt, - }, + .ops = &ssi_dai_ops, }, #endif }; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d4b90d82a09..16518329f6b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -133,8 +133,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) mutex_lock(&pcm_mutex); /* startup the audio subsystem */ - if (cpu_dai->ops.startup) { - ret = cpu_dai->ops.startup(substream, cpu_dai); + if (cpu_dai->ops->startup) { + ret = cpu_dai->ops->startup(substream, cpu_dai); if (ret < 0) { printk(KERN_ERR "asoc: can't open interface %s\n", cpu_dai->name); @@ -150,8 +150,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) } } - if (codec_dai->ops.startup) { - ret = codec_dai->ops.startup(substream, codec_dai); + if (codec_dai->ops->startup) { + ret = codec_dai->ops->startup(substream, codec_dai); if (ret < 0) { printk(KERN_ERR "asoc: can't open codec %s\n", codec_dai->name); @@ -247,8 +247,8 @@ codec_dai_err: platform->pcm_ops->close(substream); platform_err: - if (cpu_dai->ops.shutdown) - cpu_dai->ops.shutdown(substream, cpu_dai); + if (cpu_dai->ops->shutdown) + cpu_dai->ops->shutdown(substream, cpu_dai); out: mutex_unlock(&pcm_mutex); return ret; @@ -340,11 +340,11 @@ static int soc_codec_close(struct snd_pcm_substream *substream) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) snd_soc_dai_digital_mute(codec_dai, 1); - if (cpu_dai->ops.shutdown) - cpu_dai->ops.shutdown(substream, cpu_dai); + if (cpu_dai->ops->shutdown) + cpu_dai->ops->shutdown(substream, cpu_dai); - if (codec_dai->ops.shutdown) - codec_dai->ops.shutdown(substream, codec_dai); + if (codec_dai->ops->shutdown) + codec_dai->ops->shutdown(substream, codec_dai); if (machine->ops && machine->ops->shutdown) machine->ops->shutdown(substream); @@ -408,16 +408,16 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) } } - if (codec_dai->ops.prepare) { - ret = codec_dai->ops.prepare(substream, codec_dai); + if (codec_dai->ops->prepare) { + ret = codec_dai->ops->prepare(substream, codec_dai); if (ret < 0) { printk(KERN_ERR "asoc: codec DAI prepare error\n"); goto out; } } - if (cpu_dai->ops.prepare) { - ret = cpu_dai->ops.prepare(substream, cpu_dai); + if (cpu_dai->ops->prepare) { + ret = cpu_dai->ops->prepare(substream, cpu_dai); if (ret < 0) { printk(KERN_ERR "asoc: cpu DAI prepare error\n"); goto out; @@ -494,8 +494,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, } } - if (codec_dai->ops.hw_params) { - ret = codec_dai->ops.hw_params(substream, params, codec_dai); + if (codec_dai->ops->hw_params) { + ret = codec_dai->ops->hw_params(substream, params, codec_dai); if (ret < 0) { printk(KERN_ERR "asoc: can't set codec %s hw params\n", codec_dai->name); @@ -503,8 +503,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, } } - if (cpu_dai->ops.hw_params) { - ret = cpu_dai->ops.hw_params(substream, params, cpu_dai); + if (cpu_dai->ops->hw_params) { + ret = cpu_dai->ops->hw_params(substream, params, cpu_dai); if (ret < 0) { printk(KERN_ERR "asoc: interface %s hw params failed\n", cpu_dai->name); @@ -526,12 +526,12 @@ out: return ret; platform_err: - if (cpu_dai->ops.hw_free) - cpu_dai->ops.hw_free(substream, cpu_dai); + if (cpu_dai->ops->hw_free) + cpu_dai->ops->hw_free(substream, cpu_dai); interface_err: - if (codec_dai->ops.hw_free) - codec_dai->ops.hw_free(substream, codec_dai); + if (codec_dai->ops->hw_free) + codec_dai->ops->hw_free(substream, codec_dai); codec_err: if (machine->ops && machine->ops->hw_free) @@ -570,11 +570,11 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) platform->pcm_ops->hw_free(substream); /* now free hw params for the DAI's */ - if (codec_dai->ops.hw_free) - codec_dai->ops.hw_free(substream, codec_dai); + if (codec_dai->ops->hw_free) + codec_dai->ops->hw_free(substream, codec_dai); - if (cpu_dai->ops.hw_free) - cpu_dai->ops.hw_free(substream, cpu_dai); + if (cpu_dai->ops->hw_free) + cpu_dai->ops->hw_free(substream, cpu_dai); mutex_unlock(&pcm_mutex); return 0; @@ -591,8 +591,8 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_soc_dai *codec_dai = machine->codec_dai; int ret; - if (codec_dai->ops.trigger) { - ret = codec_dai->ops.trigger(substream, cmd, codec_dai); + if (codec_dai->ops->trigger) { + ret = codec_dai->ops->trigger(substream, cmd, codec_dai); if (ret < 0) return ret; } @@ -603,8 +603,8 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) return ret; } - if (cpu_dai->ops.trigger) { - ret = cpu_dai->ops.trigger(substream, cmd, cpu_dai); + if (cpu_dai->ops->trigger) { + ret = cpu_dai->ops->trigger(substream, cmd, cpu_dai); if (ret < 0) return ret; } @@ -645,8 +645,8 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state) /* mute any active DAC's */ for (i = 0; i < card->num_links; i++) { struct snd_soc_dai *dai = card->dai_link[i].codec_dai; - if (dai->ops.digital_mute && dai->playback.active) - dai->ops.digital_mute(dai, 1); + if (dai->ops->digital_mute && dai->playback.active) + dai->ops->digital_mute(dai, 1); } /* suspend all pcms */ @@ -741,8 +741,8 @@ static void soc_resume_deferred(struct work_struct *work) /* unmute any active DACs */ for (i = 0; i < card->num_links; i++) { struct snd_soc_dai *dai = card->dai_link[i].codec_dai; - if (dai->ops.digital_mute && dai->playback.active) - dai->ops.digital_mute(dai, 0); + if (dai->ops->digital_mute && dai->playback.active) + dai->ops->digital_mute(dai, 0); } for (i = 0; i < card->num_links; i++) { @@ -2051,8 +2051,8 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - if (dai->ops.set_sysclk) - return dai->ops.set_sysclk(dai, clk_id, freq, dir); + if (dai->ops->set_sysclk) + return dai->ops->set_sysclk(dai, clk_id, freq, dir); else return -EINVAL; } @@ -2071,8 +2071,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { - if (dai->ops.set_clkdiv) - return dai->ops.set_clkdiv(dai, div_id, div); + if (dai->ops->set_clkdiv) + return dai->ops->set_clkdiv(dai, div_id, div); else return -EINVAL; } @@ -2090,8 +2090,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv); int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, unsigned int freq_in, unsigned int freq_out) { - if (dai->ops.set_pll) - return dai->ops.set_pll(dai, pll_id, freq_in, freq_out); + if (dai->ops->set_pll) + return dai->ops->set_pll(dai, pll_id, freq_in, freq_out); else return -EINVAL; } @@ -2106,8 +2106,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); */ int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - if (dai->ops.set_fmt) - return dai->ops.set_fmt(dai, fmt); + if (dai->ops->set_fmt) + return dai->ops->set_fmt(dai, fmt); else return -EINVAL; } @@ -2125,8 +2125,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt); int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int mask, int slots) { - if (dai->ops.set_sysclk) - return dai->ops.set_tdm_slot(dai, mask, slots); + if (dai->ops->set_sysclk) + return dai->ops->set_tdm_slot(dai, mask, slots); else return -EINVAL; } @@ -2141,8 +2141,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot); */ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) { - if (dai->ops.set_sysclk) - return dai->ops.set_tristate(dai, tristate); + if (dai->ops->set_sysclk) + return dai->ops->set_tristate(dai, tristate); else return -EINVAL; } @@ -2157,8 +2157,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate); */ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute) { - if (dai->ops.digital_mute) - return dai->ops.digital_mute(dai, mute); + if (dai->ops->digital_mute) + return dai->ops->digital_mute(dai, mute); else return -EINVAL; } @@ -2211,6 +2211,9 @@ static int snd_soc_unregister_card(struct snd_soc_card *card) return 0; } +static struct snd_soc_dai_ops null_dai_ops = { +}; + /** * snd_soc_register_dai - Register a DAI with the ASoC core * @@ -2225,6 +2228,9 @@ int snd_soc_register_dai(struct snd_soc_dai *dai) if (!dai->dev) printk(KERN_WARNING "No device for DAI %s\n", dai->name); + if (!dai->ops) + dai->ops = &null_dai_ops; + INIT_LIST_HEAD(&dai->list); mutex_lock(&client_mutex); -- cgit v1.2.3 From 8150bc886be5ce3cc301a2baca1fcf2cf7bd7f39 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 4 Mar 2009 00:49:26 +0000 Subject: S3C24XX: Move and update IIS headers Move the IIS headers to their correct place. Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/neo1973_wm8753.c | 2 +- sound/soc/s3c24xx/s3c2412-i2s.c | 6 ++---- sound/soc/s3c24xx/s3c24xx-i2s.c | 2 +- sound/soc/s3c24xx/s3c24xx_uda134x.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 45bb12e8ea4..286ff4497fd 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include "../codecs/wm8753.h" #include "lm4857.h" diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index f3fc0aba0aa..36b927d3f54 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -30,10 +31,7 @@ #include #include -#include -#include - -#include +#include #include #include diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 6f4d439b57a..2569b910b9b 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include "s3c24xx-pcm.h" #include "s3c24xx-i2s.h" diff --git a/sound/soc/s3c24xx/s3c24xx_uda134x.c b/sound/soc/s3c24xx/s3c24xx_uda134x.c index a0a4d1832a1..8e79a416db5 100644 --- a/sound/soc/s3c24xx/s3c24xx_uda134x.c +++ b/sound/soc/s3c24xx/s3c24xx_uda134x.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include "s3c24xx-pcm.h" #include "s3c24xx-i2s.h" -- cgit v1.2.3 From 899e6cf5e6d83a91d2e257f7a4e8ca98db3831cc Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 4 Mar 2009 00:49:28 +0000 Subject: S3C: Move to The file needs to be common to both ARCH_S3C2410 and ARCH_S3C64XX as they share common driver code, so move it to . Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/neo1973_wm8753.c | 2 +- sound/soc/s3c24xx/s3c2412-i2s.c | 2 +- sound/soc/s3c24xx/s3c2443-ac97.c | 2 +- sound/soc/s3c24xx/s3c24xx-i2s.c | 2 +- sound/soc/s3c24xx/s3c24xx-pcm.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 286ff4497fd..40530fc7fba 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index 36b927d3f54..3297698ff29 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include "s3c24xx-pcm.h" diff --git a/sound/soc/s3c24xx/s3c2443-ac97.c b/sound/soc/s3c24xx/s3c2443-ac97.c index 5822d2dd49b..5c7f18a2264 100644 --- a/sound/soc/s3c24xx/s3c2443-ac97.c +++ b/sound/soc/s3c24xx/s3c2443-ac97.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 2569b910b9b..a7312e4fe4a 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c index 7c64d31d067..bfea13f3ba7 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.c +++ b/sound/soc/s3c24xx/s3c24xx-pcm.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "s3c24xx-pcm.h" -- cgit v1.2.3 From 979c036e090332cd3a090ce8b4eb50c3aa28dea0 Mon Sep 17 00:00:00 2001 From: "Lopez Cruz, Misael" Date: Wed, 4 Mar 2009 11:39:07 -0600 Subject: ASoC: Add DAPM machine widgets to SDP3430 driver Add DAPM machine domain widgets to SDP3430 machine driver. Interconnection: * Ext Mic: MAINMIC, SUBMIC * Ext Spk: HFL, HFR * Headset Jack: HSMIC, HSOL, HSOR Signed-off-by: Misael Lopez Cruz Signed-off-by: Mark Brown --- sound/soc/omap/sdp3430.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index e226fa75669..4eab4b491de 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -81,12 +81,76 @@ static struct snd_soc_ops sdp3430_ops = { .hw_params = sdp3430_hw_params, }; +/* SDP3430 machine DAPM */ +static const struct snd_soc_dapm_widget sdp3430_twl4030_dapm_widgets[] = { + SND_SOC_DAPM_MIC("Ext Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), + SND_SOC_DAPM_HP("Headset Jack", NULL), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + /* External Mics: MAINMIC, SUBMIC with bias*/ + {"MAINMIC", NULL, "Mic Bias 1"}, + {"SUBMIC", NULL, "Mic Bias 2"}, + {"Mic Bias 1", NULL, "Ext Mic"}, + {"Mic Bias 2", NULL, "Ext Mic"}, + + /* External Speakers: HFL, HFR */ + {"Ext Spk", NULL, "HFL"}, + {"Ext Spk", NULL, "HFR"}, + + /* Headset: HSMIC (with bias), HSOL, HSOR */ + {"Headset Jack", NULL, "HSOL"}, + {"Headset Jack", NULL, "HSOR"}, + {"HSMIC", NULL, "Headset Mic Bias"}, + {"Headset Mic Bias", NULL, "Headset Jack"}, +}; + +static int sdp3430_twl4030_init(struct snd_soc_codec *codec) +{ + int ret; + + /* Add SDP3430 specific widgets */ + ret = snd_soc_dapm_new_controls(codec, sdp3430_twl4030_dapm_widgets, + ARRAY_SIZE(sdp3430_twl4030_dapm_widgets)); + if (ret) + return ret; + + /* Set up SDP3430 specific audio path audio_map */ + snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); + + /* SDP3430 connected pins */ + snd_soc_dapm_enable_pin(codec, "Ext Mic"); + snd_soc_dapm_enable_pin(codec, "Ext Spk"); + snd_soc_dapm_enable_pin(codec, "Headset Jack"); + + /* TWL4030 not connected pins */ + snd_soc_dapm_nc_pin(codec, "AUXL"); + snd_soc_dapm_nc_pin(codec, "AUXR"); + snd_soc_dapm_nc_pin(codec, "CARKITMIC"); + snd_soc_dapm_nc_pin(codec, "DIGIMIC0"); + snd_soc_dapm_nc_pin(codec, "DIGIMIC1"); + + snd_soc_dapm_nc_pin(codec, "OUTL"); + snd_soc_dapm_nc_pin(codec, "OUTR"); + snd_soc_dapm_nc_pin(codec, "EARPIECE"); + snd_soc_dapm_nc_pin(codec, "PREDRIVEL"); + snd_soc_dapm_nc_pin(codec, "PREDRIVER"); + snd_soc_dapm_nc_pin(codec, "CARKITL"); + snd_soc_dapm_nc_pin(codec, "CARKITR"); + + ret = snd_soc_dapm_sync(codec); + + return ret; +} + /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link sdp3430_dai = { .name = "TWL4030", .stream_name = "TWL4030", .cpu_dai = &omap_mcbsp_dai[0], .codec_dai = &twl4030_dai, + .init = sdp3430_twl4030_init, .ops = &sdp3430_ops, }; -- cgit v1.2.3 From 3093e48c48b69ccc06a1f78ffe7ece7ee2ee09ef Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 4 Mar 2009 00:49:27 +0000 Subject: ASoC: Add JIVE audio support Add support for the Jive's WM8750 codec attached via the S3C2412 IIS. Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/Kconfig | 9 ++ sound/soc/s3c24xx/Makefile | 2 + sound/soc/s3c24xx/jive_wm8750.c | 216 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 sound/soc/s3c24xx/jive_wm8750.c (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index e05a71084c3..7803218d190 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -26,6 +26,15 @@ config SND_S3C24XX_SOC_NEO1973_WM8753 Say Y if you want to add support for SoC audio on smdk2440 with the WM8753. +config SND_S3C24XX_SOC_JIVE_WM8750 + tristate "SoC I2S Audio support for Jive" + depends on SND_S3C24XX_SOC && MACH_JIVE + select SND_SOC_WM8750 + select SND_SOC_WM8750_SPI + select SND_S3C2412_SOC_I2S + help + Sat Y if you want to add support for SoC audio on the Jive. + config SND_S3C24XX_SOC_SMDK2443_WM9710 tristate "SoC AC97 Audio support for SMDK2443 - WM9710" depends on SND_S3C24XX_SOC && MACH_SMDK2443 diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile index 96b3f3f617d..bc11976e269 100644 --- a/sound/soc/s3c24xx/Makefile +++ b/sound/soc/s3c24xx/Makefile @@ -10,11 +10,13 @@ obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o # S3C24XX Machine Support +snd-soc-jive-wm8750-objs := jive_wm8750.o snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o snd-soc-ln2440sbc-alc650-objs := ln2440sbc_alc650.o snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o +obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o obj-$(CONFIG_SND_S3C24XX_SOC_LN2440SBC_ALC650) += snd-soc-ln2440sbc-alc650.o diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c new file mode 100644 index 00000000000..fe466c1f71e --- /dev/null +++ b/sound/soc/s3c24xx/jive_wm8750.c @@ -0,0 +1,216 @@ +/* sound/soc/s3c24xx/jive_wm8750.c + * + * Copyright 2007,2008 Simtec Electronics + * + * Based on sound/soc/pxa/spitz.c + * Copyright 2005 Wolfson Microelectronics PLC. + * Copyright 2005 Openedhand Ltd. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include "s3c24xx-pcm.h" +#include "s3c2412-i2s.h" + +#include "../codecs/wm8750.h" + +static const struct snd_soc_dapm_route audio_map[] = { + { "Headphone Jack", NULL, "LOUT1" }, + { "Headphone Jack", NULL, "ROUT1" }, + { "Internal Speaker", NULL, "LOUT2" }, + { "Internal Speaker", NULL, "ROUT2" }, + { "LINPUT1", NULL, "Line Input" }, + { "RINPUT1", NULL, "Line Input" }, +}; + +static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_SPK("Internal Speaker", NULL), + SND_SOC_DAPM_LINE("Line In", NULL), +}; + +static int jive_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_codec *codec = rtd->socdev->codec; + + snd_soc_dapm_enable_pin(codec, "Headphone Jack"); + snd_soc_dapm_enable_pin(codec, "Internal Speaker"); + snd_soc_dapm_enable_pin(codec, "Line In"); + + snd_soc_dapm_sync(codec); + + return 0; +} + +static int jive_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + struct s3c2412_rate_calc div; + unsigned int clk = 0; + int ret = 0; + + switch (params_rate(params)) { + case 8000: + case 16000: + case 48000: + case 96000: + clk = 12288000; + break; + case 11025: + case 22050: + case 44100: + clk = 11289600; + break; + } + + s3c2412_iis_calc_rate(&div, NULL, params_rate(params), + s3c2412_get_iisclk()); + + /* 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; + + /* set the codec system clock for DAC and ADC */ + ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk, + SND_SOC_CLOCK_IN); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER, + div.clk_div - 1); + if (ret < 0) + return ret; + + return 0; +} + +static struct snd_soc_ops jive_ops = { + .startup = jive_startup, + .hw_params = jive_hw_params, +}; + +static int jive_wm8750_init(struct snd_soc_codec *codec) +{ + int err; + + /* These endpoints are not being used. */ + snd_soc_dapm_disable_pin(codec, "LINPUT2"); + snd_soc_dapm_disable_pin(codec, "RINPUT2"); + snd_soc_dapm_disable_pin(codec, "LINPUT3"); + snd_soc_dapm_disable_pin(codec, "RINPUT3"); + snd_soc_dapm_disable_pin(codec, "OUT3"); + snd_soc_dapm_disable_pin(codec, "MONO"); + + /* Add jive specific widgets */ + err = snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, + ARRAY_SIZE(wm8750_dapm_widgets)); + if (err) { + printk(KERN_ERR "%s: failed to add widgets (%d)\n", + __func__, err); + return err; + } + + 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 jive_dai = { + .name = "wm8750", + .stream_name = "WM8750", + .cpu_dai = &s3c2412_i2s_dai, + .codec_dai = &wm8750_dai, + .init = jive_wm8750_init, + .ops = &jive_ops, +}; + +/* jive audio machine driver */ +static struct snd_soc_machine snd_soc_machine_jive = { + .name = "Jive", + .dai_link = &jive_dai, + .num_links = 1, +}; + +/* jive audio private data */ +static struct wm8750_setup_data jive_wm8750_setup = { +}; + +/* jive audio subsystem */ +static struct snd_soc_device jive_snd_devdata = { + .machine = &snd_soc_machine_jive, + .platform = &s3c24xx_soc_platform, + .codec_dev = &soc_codec_dev_wm8750_spi, + .codec_data = &jive_wm8750_setup, +}; + +static struct platform_device *jive_snd_device; + +static int __init jive_init(void) +{ + int ret; + + if (!machine_is_jive()) + return 0; + + printk("JIVE WM8750 Audio support\n"); + + jive_snd_device = platform_device_alloc("soc-audio", -1); + if (!jive_snd_device) + return -ENOMEM; + + platform_set_drvdata(jive_snd_device, &jive_snd_devdata); + jive_snd_devdata.dev = &jive_snd_device->dev; + ret = platform_device_add(jive_snd_device); + + if (ret) + platform_device_put(jive_snd_device); + + return ret; +} + +static void __exit jive_exit(void) +{ + platform_device_unregister(jive_snd_device); +} + +module_init(jive_init); +module_exit(jive_exit); + +MODULE_AUTHOR("Ben Dooks "); +MODULE_DESCRIPTION("ALSA SoC Jive Audio support"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From dc85447b196a683784eb85654c436fd58c3e2ed1 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 4 Mar 2009 00:49:30 +0000 Subject: ASoC: Split s3c2412-i2s.c into core and SoC specific parts The S3C2412 I2S (IIS) interface is replicated on further Samsung SoC parts in a broadly compatible way, so split the common code out into a core called s3c-i2s-v2.[ch] so that the newer SoCs such as the S3C6410 can make use of it. As such, all the original s3c2412 functions are currently being left with their original names, and will be renamed later in the series. Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/Kconfig | 4 + sound/soc/s3c24xx/Makefile | 2 + sound/soc/s3c24xx/jive_wm8750.c | 6 +- sound/soc/s3c24xx/s3c-i2s-v2.c | 645 ++++++++++++++++++++++++++++++++++++++++ sound/soc/s3c24xx/s3c-i2s-v2.h | 90 ++++++ sound/soc/s3c24xx/s3c2412-i2s.c | 596 ++----------------------------------- sound/soc/s3c24xx/s3c2412-i2s.h | 17 +- 7 files changed, 767 insertions(+), 593 deletions(-) create mode 100644 sound/soc/s3c24xx/s3c-i2s-v2.c create mode 100644 sound/soc/s3c24xx/s3c-i2s-v2.h (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index 7803218d190..bd98adaa5b0 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -9,8 +9,12 @@ config SND_S3C24XX_SOC config SND_S3C24XX_SOC_I2S tristate +config SND_S3C_I2SV2_SOC + tristate + config SND_S3C2412_SOC_I2S tristate + select SND_S3C_I2SV2_SOC config SND_S3C2443_SOC_AC97 tristate diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile index bc11976e269..848981e18ac 100644 --- a/sound/soc/s3c24xx/Makefile +++ b/sound/soc/s3c24xx/Makefile @@ -3,11 +3,13 @@ snd-soc-s3c24xx-objs := s3c24xx-pcm.o snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o snd-soc-s3c2443-ac97-objs := s3c2443-ac97.o +snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o +obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o # S3C24XX Machine Support snd-soc-jive-wm8750-objs := jive_wm8750.o diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c index fe466c1f71e..7dfe26ea8f4 100644 --- a/sound/soc/s3c24xx/jive_wm8750.c +++ b/sound/soc/s3c24xx/jive_wm8750.c @@ -65,7 +65,7 @@ static int jive_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; - struct s3c2412_rate_calc div; + struct s3c_i2sv2_rate_calc div; unsigned int clk = 0; int ret = 0; @@ -83,8 +83,8 @@ static int jive_hw_params(struct snd_pcm_substream *substream, break; } - s3c2412_iis_calc_rate(&div, NULL, params_rate(params), - s3c2412_get_iisclk()); + s3c_i2sv2_calc_rate(&div, NULL, params_rate(params), + s3c2412_get_iisclk()); /* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c new file mode 100644 index 00000000000..43262e1e8f9 --- /dev/null +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c @@ -0,0 +1,645 @@ +/* sound/soc/s3c24xx/s3c-i2c-v2.c + * + * ALSA Soc Audio Layer - I2S core for newer Samsung SoCs. + * + * Copyright (c) 2006 Wolfson Microelectronics PLC. + * Graeme Gregory graeme.gregory@wolfsonmicro.com + * linux@wolfsonmicro.com + * + * Copyright (c) 2008, 2007, 2004-2005 Simtec Electronics + * http://armlinux.simtec.co.uk/ + * Ben Dooks + * + * 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "s3c-i2s-v2.h" + +#define S3C2412_I2S_DEBUG_CON 0 +#define S3C2412_I2S_DEBUG 0 + +#if S3C2412_I2S_DEBUG +#define DBG(x...) printk(KERN_INFO x) +#else +#define DBG(x...) do { } while (0) +#endif + +static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) +{ + return cpu_dai->private_data; +} + +#define bit_set(v, b) (((v) & (b)) ? 1 : 0) + +#if S3C2412_I2S_DEBUG_CON +static void dbg_showcon(const char *fn, u32 con) +{ + printk(KERN_DEBUG "%s: LRI=%d, TXFEMPT=%d, RXFEMPT=%d, TXFFULL=%d, RXFFULL=%d\n", fn, + bit_set(con, S3C2412_IISCON_LRINDEX), + bit_set(con, S3C2412_IISCON_TXFIFO_EMPTY), + bit_set(con, S3C2412_IISCON_RXFIFO_EMPTY), + bit_set(con, S3C2412_IISCON_TXFIFO_FULL), + bit_set(con, S3C2412_IISCON_RXFIFO_FULL)); + + printk(KERN_DEBUG "%s: PAUSE: TXDMA=%d, RXDMA=%d, TXCH=%d, RXCH=%d\n", + fn, + bit_set(con, S3C2412_IISCON_TXDMA_PAUSE), + bit_set(con, S3C2412_IISCON_RXDMA_PAUSE), + bit_set(con, S3C2412_IISCON_TXCH_PAUSE), + bit_set(con, S3C2412_IISCON_RXCH_PAUSE)); + printk(KERN_DEBUG "%s: ACTIVE: TXDMA=%d, RXDMA=%d, IIS=%d\n", fn, + bit_set(con, S3C2412_IISCON_TXDMA_ACTIVE), + bit_set(con, S3C2412_IISCON_RXDMA_ACTIVE), + bit_set(con, S3C2412_IISCON_IIS_ACTIVE)); +} +#else +static inline void dbg_showcon(const char *fn, u32 con) +{ +} +#endif + + +/* Turn on or off the transmission path. */ +void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) +{ + void __iomem *regs = i2s->regs; + u32 fic, con, mod; + + DBG("%s(%d)\n", __func__, on); + + fic = readl(regs + S3C2412_IISFIC); + con = readl(regs + S3C2412_IISCON); + mod = readl(regs + S3C2412_IISMOD); + + DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); + + if (on) { + con |= S3C2412_IISCON_TXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; + con &= ~S3C2412_IISCON_TXDMA_PAUSE; + con &= ~S3C2412_IISCON_TXCH_PAUSE; + + switch (mod & S3C2412_IISMOD_MODE_MASK) { + case S3C2412_IISMOD_MODE_TXONLY: + case S3C2412_IISMOD_MODE_TXRX: + /* do nothing, we are in the right mode */ + break; + + case S3C2412_IISMOD_MODE_RXONLY: + mod &= ~S3C2412_IISMOD_MODE_MASK; + mod |= S3C2412_IISMOD_MODE_TXRX; + break; + + default: + dev_err(i2s->dev, "TXEN: Invalid MODE in IISMOD\n"); + } + + writel(con, regs + S3C2412_IISCON); + writel(mod, regs + S3C2412_IISMOD); + } else { + /* Note, we do not have any indication that the FIFO problems + * tha the S3C2410/2440 had apply here, so we should be able + * to disable the DMA and TX without resetting the FIFOS. + */ + + con |= S3C2412_IISCON_TXDMA_PAUSE; + con |= S3C2412_IISCON_TXCH_PAUSE; + con &= ~S3C2412_IISCON_TXDMA_ACTIVE; + + switch (mod & S3C2412_IISMOD_MODE_MASK) { + case S3C2412_IISMOD_MODE_TXRX: + mod &= ~S3C2412_IISMOD_MODE_MASK; + mod |= S3C2412_IISMOD_MODE_RXONLY; + break; + + case S3C2412_IISMOD_MODE_TXONLY: + mod &= ~S3C2412_IISMOD_MODE_MASK; + con &= ~S3C2412_IISCON_IIS_ACTIVE; + break; + + default: + dev_err(i2s->dev, "TXDIS: Invalid MODE in IISMOD\n"); + } + + writel(mod, regs + S3C2412_IISMOD); + writel(con, regs + S3C2412_IISCON); + } + + fic = readl(regs + S3C2412_IISFIC); + dbg_showcon(__func__, con); + DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); +} +EXPORT_SYMBOL_GPL(s3c2412_snd_txctrl); + +void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) +{ + void __iomem *regs = i2s->regs; + u32 fic, con, mod; + + DBG("%s(%d)\n", __func__, on); + + fic = readl(regs + S3C2412_IISFIC); + con = readl(regs + S3C2412_IISCON); + mod = readl(regs + S3C2412_IISMOD); + + DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); + + if (on) { + con |= S3C2412_IISCON_RXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; + con &= ~S3C2412_IISCON_RXDMA_PAUSE; + con &= ~S3C2412_IISCON_RXCH_PAUSE; + + switch (mod & S3C2412_IISMOD_MODE_MASK) { + case S3C2412_IISMOD_MODE_TXRX: + case S3C2412_IISMOD_MODE_RXONLY: + /* do nothing, we are in the right mode */ + break; + + case S3C2412_IISMOD_MODE_TXONLY: + mod &= ~S3C2412_IISMOD_MODE_MASK; + mod |= S3C2412_IISMOD_MODE_TXRX; + break; + + default: + dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n"); + } + + writel(mod, regs + S3C2412_IISMOD); + writel(con, regs + S3C2412_IISCON); + } else { + /* See txctrl notes on FIFOs. */ + + con &= ~S3C2412_IISCON_RXDMA_ACTIVE; + con |= S3C2412_IISCON_RXDMA_PAUSE; + con |= S3C2412_IISCON_RXCH_PAUSE; + + switch (mod & S3C2412_IISMOD_MODE_MASK) { + case S3C2412_IISMOD_MODE_RXONLY: + con &= ~S3C2412_IISCON_IIS_ACTIVE; + mod &= ~S3C2412_IISMOD_MODE_MASK; + break; + + case S3C2412_IISMOD_MODE_TXRX: + mod &= ~S3C2412_IISMOD_MODE_MASK; + mod |= S3C2412_IISMOD_MODE_TXONLY; + break; + + default: + dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n"); + } + + writel(con, regs + S3C2412_IISCON); + writel(mod, regs + S3C2412_IISMOD); + } + + fic = readl(regs + S3C2412_IISFIC); + DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); +} +EXPORT_SYMBOL_GPL(s3c2412_snd_rxctrl); + +/* + * Wait for the LR signal to allow synchronisation to the L/R clock + * from the codec. May only be needed for slave mode. + */ +static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s) +{ + u32 iiscon; + unsigned long timeout = jiffies + msecs_to_jiffies(5); + + DBG("Entered %s\n", __func__); + + while (1) { + iiscon = readl(i2s->regs + S3C2412_IISCON); + if (iiscon & S3C2412_IISCON_LRINDEX) + break; + + if (timeout < jiffies) { + printk(KERN_ERR "%s: timeout\n", __func__); + return -ETIMEDOUT; + } + } + + return 0; +} + +/* + * Set S3C2412 I2S DAI format + */ +static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, + unsigned int fmt) +{ + struct s3c_i2sv2_info *i2s = to_info(cpu_dai); + u32 iismod; + + DBG("Entered %s\n", __func__); + + iismod = readl(i2s->regs + S3C2412_IISMOD); + DBG("hw_params r: IISMOD: %x \n", iismod); + +#if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) +#define IISMOD_MASTER_MASK S3C2412_IISMOD_MASTER_MASK +#define IISMOD_SLAVE S3C2412_IISMOD_SLAVE +#define IISMOD_MASTER S3C2412_IISMOD_MASTER_INTERNAL +#endif + +#if defined(CONFIG_PLAT_S3C64XX) +/* From Rev1.1 datasheet, we have two master and two slave modes: + * IMS[11:10]: + * 00 = master mode, fed from PCLK + * 01 = master mode, fed from CLKAUDIO + * 10 = slave mode, using PCLK + * 11 = slave mode, using I2SCLK + */ +#define IISMOD_MASTER_MASK (1 << 11) +#define IISMOD_SLAVE (1 << 11) +#define IISMOD_MASTER (0x0) +#endif + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + i2s->master = 0; + iismod &= ~IISMOD_MASTER_MASK; + iismod |= IISMOD_SLAVE; + break; + case SND_SOC_DAIFMT_CBS_CFS: + i2s->master = 1; + iismod &= ~IISMOD_MASTER_MASK; + iismod |= IISMOD_MASTER; + break; + default: + DBG("unknwon master/slave format\n"); + return -EINVAL; + } + + iismod &= ~S3C2412_IISMOD_SDF_MASK; + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_RIGHT_J: + iismod |= S3C2412_IISMOD_SDF_MSB; + break; + case SND_SOC_DAIFMT_LEFT_J: + iismod |= S3C2412_IISMOD_SDF_LSB; + break; + case SND_SOC_DAIFMT_I2S: + iismod |= S3C2412_IISMOD_SDF_IIS; + break; + default: + DBG("Unknown data format\n"); + return -EINVAL; + } + + writel(iismod, i2s->regs + S3C2412_IISMOD); + DBG("hw_params w: IISMOD: %x \n", iismod); + return 0; +} + +static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *socdai) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai_link *dai = rtd->dai; + struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai); + u32 iismod; + + DBG("Entered %s\n", __func__); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + dai->cpu_dai->dma_data = i2s->dma_playback; + else + dai->cpu_dai->dma_data = i2s->dma_capture; + + /* Working copies of register */ + iismod = readl(i2s->regs + S3C2412_IISMOD); + DBG("%s: r: IISMOD: %x\n", __func__, iismod); + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S8: + iismod |= S3C2412_IISMOD_8BIT; + break; + case SNDRV_PCM_FORMAT_S16_LE: + iismod &= ~S3C2412_IISMOD_8BIT; + break; + } + + writel(iismod, i2s->regs + S3C2412_IISMOD); + DBG("%s: w: IISMOD: %x\n", __func__, iismod); + return 0; +} + +static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct s3c_i2sv2_info *i2s = to_info(rtd->dai->cpu_dai); + int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); + unsigned long irqs; + int ret = 0; + + DBG("Entered %s\n", __func__); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + /* On start, ensure that the FIFOs are cleared and reset. */ + + writel(capture ? S3C2412_IISFIC_RXFLUSH : S3C2412_IISFIC_TXFLUSH, + i2s->regs + S3C2412_IISFIC); + + /* clear again, just in case */ + writel(0x0, i2s->regs + S3C2412_IISFIC); + + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + if (!i2s->master) { + ret = s3c2412_snd_lrsync(i2s); + if (ret) + goto exit_err; + } + + local_irq_save(irqs); + + if (capture) + s3c2412_snd_rxctrl(i2s, 1); + else + s3c2412_snd_txctrl(i2s, 1); + + local_irq_restore(irqs); + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + local_irq_save(irqs); + + if (capture) + s3c2412_snd_rxctrl(i2s, 0); + else + s3c2412_snd_txctrl(i2s, 0); + + local_irq_restore(irqs); + break; + default: + ret = -EINVAL; + break; + } + +exit_err: + return ret; +} + +/* + * Set S3C2412 Clock dividers + */ +static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, + int div_id, int div) +{ + struct s3c_i2sv2_info *i2s = to_info(cpu_dai); + u32 reg; + + DBG("%s(%p, %d, %d)\n", __func__, cpu_dai, div_id, div); + + switch (div_id) { + case S3C_I2SV2_DIV_BCLK: + reg = readl(i2s->regs + S3C2412_IISMOD); + reg &= ~S3C2412_IISMOD_BCLK_MASK; + writel(reg | div, i2s->regs + S3C2412_IISMOD); + + DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); + break; + + case S3C_I2SV2_DIV_RCLK: + if (div > 3) { + /* convert value to bit field */ + + switch (div) { + case 256: + div = S3C2412_IISMOD_RCLK_256FS; + break; + + case 384: + div = S3C2412_IISMOD_RCLK_384FS; + break; + + case 512: + div = S3C2412_IISMOD_RCLK_512FS; + break; + + case 768: + div = S3C2412_IISMOD_RCLK_768FS; + break; + + default: + return -EINVAL; + } + } + + reg = readl(i2s->regs + S3C2412_IISMOD); + reg &= ~S3C2412_IISMOD_RCLK_MASK; + writel(reg | div, i2s->regs + S3C2412_IISMOD); + DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); + break; + + case S3C_I2SV2_DIV_PRESCALER: + if (div >= 0) { + writel((div << 8) | S3C2412_IISPSR_PSREN, + i2s->regs + S3C2412_IISPSR); + } else { + writel(0x0, i2s->regs + S3C2412_IISPSR); + } + DBG("%s: PSR=%08x\n", __func__, readl(i2s->regs + S3C2412_IISPSR)); + break; + + default: + return -EINVAL; + } + + return 0; +} + +/* default table of all avaialable root fs divisors */ +static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 }; + +int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, + unsigned int *fstab, + unsigned int rate, struct clk *clk) +{ + unsigned long clkrate = clk_get_rate(clk); + unsigned int div; + unsigned int fsclk; + unsigned int actual; + unsigned int fs; + unsigned int fsdiv; + signed int deviation = 0; + unsigned int best_fs = 0; + unsigned int best_div = 0; + unsigned int best_rate = 0; + unsigned int best_deviation = INT_MAX; + + if (fstab == NULL) + fstab = iis_fs_tab; + + for (fs = 0; fs < ARRAY_SIZE(iis_fs_tab); fs++) { + fsdiv = iis_fs_tab[fs]; + + fsclk = clkrate / fsdiv; + div = fsclk / rate; + + if ((fsclk % rate) > (rate / 2)) + div++; + + if (div <= 1) + continue; + + actual = clkrate / (fsdiv * div); + deviation = actual - rate; + + printk(KERN_DEBUG "%dfs: div %d => result %d, deviation %d\n", + fsdiv, div, actual, deviation); + + deviation = abs(deviation); + + if (deviation < best_deviation) { + best_fs = fsdiv; + best_div = div; + best_rate = actual; + best_deviation = deviation; + } + + if (deviation == 0) + break; + } + + printk(KERN_DEBUG "best: fs=%d, div=%d, rate=%d\n", + best_fs, best_div, best_rate); + + info->fs_div = best_fs; + info->clk_div = best_div; + + return 0; +} +EXPORT_SYMBOL_GPL(s3c2412_iis_calc_rate); + +int s3c_i2sv2_probe(struct platform_device *pdev, + struct snd_soc_dai *dai, + struct s3c_i2sv2_info *i2s, + unsigned long base) +{ + struct device *dev = &pdev->dev; + + i2s->dev = dev; + + /* record our i2s structure for later use in the callbacks */ + dai->private_data = i2s; + + i2s->regs = ioremap(base, 0x100); + if (i2s->regs == NULL) { + dev_err(dev, "cannot ioremap registers\n"); + return -ENXIO; + } + + i2s->iis_pclk = clk_get(dev, "iis"); + if (i2s->iis_pclk == NULL) { + DBG("failed to get iis_clock\n"); + iounmap(i2s->regs); + return -ENOENT; + } + + clk_enable(i2s->iis_pclk); + + s3c2412_snd_txctrl(i2s, 0); + s3c2412_snd_rxctrl(i2s, 0); + + return 0; +} + +EXPORT_SYMBOL_GPL(s3c_i2sv2_probe); + +#ifdef CONFIG_PM +static int s3c2412_i2s_suspend(struct snd_soc_dai *dai) +{ + struct s3c_i2sv2_info *i2s = to_info(dai); + u32 iismod; + + if (dai->active) { + i2s->suspend_iismod = readl(i2s->regs + S3C2412_IISMOD); + i2s->suspend_iiscon = readl(i2s->regs + S3C2412_IISCON); + i2s->suspend_iispsr = readl(i2s->regs + S3C2412_IISPSR); + + /* some basic suspend checks */ + + iismod = readl(i2s->regs + S3C2412_IISMOD); + + if (iismod & S3C2412_IISCON_RXDMA_ACTIVE) + pr_warning("%s: RXDMA active?\n", __func__); + + if (iismod & S3C2412_IISCON_TXDMA_ACTIVE) + pr_warning("%s: TXDMA active?\n", __func__); + + if (iismod & S3C2412_IISCON_IIS_ACTIVE) + pr_warning("%s: IIS active\n", __func__); + } + + return 0; +} + +static int s3c2412_i2s_resume(struct snd_soc_dai *dai) +{ + struct s3c_i2sv2_info *i2s = to_info(dai); + + pr_info("dai_active %d, IISMOD %08x, IISCON %08x\n", + dai->active, i2s->suspend_iismod, i2s->suspend_iiscon); + + if (dai->active) { + writel(i2s->suspend_iiscon, i2s->regs + S3C2412_IISCON); + writel(i2s->suspend_iismod, i2s->regs + S3C2412_IISMOD); + writel(i2s->suspend_iispsr, i2s->regs + S3C2412_IISPSR); + + writel(S3C2412_IISFIC_RXFLUSH | S3C2412_IISFIC_TXFLUSH, + i2s->regs + S3C2412_IISFIC); + + ndelay(250); + writel(0x0, i2s->regs + S3C2412_IISFIC); + } + + return 0; +} +#else +#define s3c2412_i2s_suspend NULL +#define s3c2412_i2s_resume NULL +#endif + +int s3c_i2sv2_register_dai(struct snd_soc_dai *dai) +{ + dai->ops.trigger = s3c2412_i2s_trigger; + dai->ops.hw_params = s3c2412_i2s_hw_params; + dai->ops.set_fmt = s3c2412_i2s_set_fmt; + dai->ops.set_clkdiv = s3c2412_i2s_set_clkdiv; + + dai->suspend = s3c2412_i2s_suspend; + dai->resume = s3c2412_i2s_resume; + + return snd_soc_register_dai(dai); +} + +EXPORT_SYMBOL_GPL(s3c_i2sv2_register_dai); diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.h b/sound/soc/s3c24xx/s3c-i2s-v2.h new file mode 100644 index 00000000000..f66854a77fb --- /dev/null +++ b/sound/soc/s3c24xx/s3c-i2s-v2.h @@ -0,0 +1,90 @@ +/* sound/soc/s3c24xx/s3c-i2s-v2.h + * + * ALSA Soc Audio Layer - S3C_I2SV2 I2S driver + * + * Copyright (c) 2007 Simtec Electronics + * http://armlinux.simtec.co.uk/ + * Ben Dooks + * + * 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 code is the core support for the I2S block found in a number of + * Samsung SoC devices which is unofficially named I2S-V2. Currently the + * S3C2412 and the S3C64XX series use this block to provide 1 or 2 I2S + * channels via configurable GPIO. + */ + +#ifndef __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H +#define __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H __FILE__ + +#define S3C_I2SV2_DIV_BCLK (1) +#define S3C_I2SV2_DIV_RCLK (2) +#define S3C_I2SV2_DIV_PRESCALER (3) + +/** + * struct s3c_i2sv2_info - S3C I2S-V2 information + * @dev: The parent device passed to use from the probe. + * @regs: The pointer to the device registe block. + * @master: True if the I2S core is the I2S bit clock master. + * @dma_playback: DMA information for playback channel. + * @dma_capture: DMA information for capture channel. + * @suspend_iismod: PM save for the IISMOD register. + * @suspend_iiscon: PM save for the IISCON register. + * @suspend_iispsr: PM save for the IISPSR register. + * + * This is the private codec state for the hardware associated with an + * I2S channel such as the register mappings and clock sources. + */ +struct s3c_i2sv2_info { + struct device *dev; + void __iomem *regs; + + struct clk *iis_pclk; + struct clk *iis_cclk; + struct clk *iis_clk; + + unsigned char master; + + struct s3c24xx_pcm_dma_params *dma_playback; + struct s3c24xx_pcm_dma_params *dma_capture; + + u32 suspend_iismod; + u32 suspend_iiscon; + u32 suspend_iispsr; +}; + +struct s3c_i2sv2_rate_calc { + unsigned int clk_div; /* for prescaler */ + unsigned int fs_div; /* for root frame clock */ +}; + +extern int s3c_i2sv2_iis_calc_rate(struct s3c_i2sv2_rate_calc *info, + unsigned int *fstab, + unsigned int rate, struct clk *clk); + +/** + * s3c_i2sv2_probe - probe for i2s device helper + * @pdev: The platform device supplied to the original probe. + * @dai: The ASoC DAI structure supplied to the original probe. + * @i2s: Our local i2s structure to fill in. + * @base: The base address for the registers. + */ +extern int s3c_i2sv2_probe(struct platform_device *pdev, + struct snd_soc_dai *dai, + struct s3c_i2sv2_info *i2s, + unsigned long base); + +/** + * s3c_i2sv2_register_dai - register dai with soc core + * @dai: The snd_soc_dai structure to register + * + * Fill in any missing fields and then register the given dai with the + * soc core. + */ +extern int s3c_i2sv2_register_dai(struct snd_soc_dai *dai); + +#endif /* __SND_SOC_S3C24XX_S3C_I2SV2_I2S_H */ diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index 3297698ff29..5099d939667 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c @@ -33,7 +33,7 @@ #include -#include +#include #include #include @@ -41,7 +41,6 @@ #include "s3c2412-i2s.h" #define S3C2412_I2S_DEBUG 0 -#define S3C2412_I2S_DEBUG_CON 0 #if S3C2412_I2S_DEBUG #define DBG(x...) printk(KERN_INFO x) @@ -71,431 +70,7 @@ static struct s3c24xx_pcm_dma_params s3c2412_i2s_pcm_stereo_in = { .dma_size = 4, }; -struct s3c2412_i2s_info { - struct device *dev; - void __iomem *regs; - struct clk *iis_clk; - struct clk *iis_pclk; - struct clk *iis_cclk; - - u32 suspend_iismod; - u32 suspend_iiscon; - u32 suspend_iispsr; -}; - -static struct s3c2412_i2s_info s3c2412_i2s; - -#define bit_set(v, b) (((v) & (b)) ? 1 : 0) - -#if S3C2412_I2S_DEBUG_CON -static void dbg_showcon(const char *fn, u32 con) -{ - printk(KERN_DEBUG "%s: LRI=%d, TXFEMPT=%d, RXFEMPT=%d, TXFFULL=%d, RXFFULL=%d\n", fn, - bit_set(con, S3C2412_IISCON_LRINDEX), - bit_set(con, S3C2412_IISCON_TXFIFO_EMPTY), - bit_set(con, S3C2412_IISCON_RXFIFO_EMPTY), - bit_set(con, S3C2412_IISCON_TXFIFO_FULL), - bit_set(con, S3C2412_IISCON_RXFIFO_FULL)); - - printk(KERN_DEBUG "%s: PAUSE: TXDMA=%d, RXDMA=%d, TXCH=%d, RXCH=%d\n", - fn, - bit_set(con, S3C2412_IISCON_TXDMA_PAUSE), - bit_set(con, S3C2412_IISCON_RXDMA_PAUSE), - bit_set(con, S3C2412_IISCON_TXCH_PAUSE), - bit_set(con, S3C2412_IISCON_RXCH_PAUSE)); - printk(KERN_DEBUG "%s: ACTIVE: TXDMA=%d, RXDMA=%d, IIS=%d\n", fn, - bit_set(con, S3C2412_IISCON_TXDMA_ACTIVE), - bit_set(con, S3C2412_IISCON_RXDMA_ACTIVE), - bit_set(con, S3C2412_IISCON_IIS_ACTIVE)); -} -#else -static inline void dbg_showcon(const char *fn, u32 con) -{ -} -#endif - -/* Turn on or off the transmission path. */ -static void s3c2412_snd_txctrl(int on) -{ - struct s3c2412_i2s_info *i2s = &s3c2412_i2s; - void __iomem *regs = i2s->regs; - u32 fic, con, mod; - - DBG("%s(%d)\n", __func__, on); - - fic = readl(regs + S3C2412_IISFIC); - con = readl(regs + S3C2412_IISCON); - mod = readl(regs + S3C2412_IISMOD); - - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); - - if (on) { - con |= S3C2412_IISCON_TXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; - con &= ~S3C2412_IISCON_TXDMA_PAUSE; - con &= ~S3C2412_IISCON_TXCH_PAUSE; - - switch (mod & S3C2412_IISMOD_MODE_MASK) { - case S3C2412_IISMOD_MODE_TXONLY: - case S3C2412_IISMOD_MODE_TXRX: - /* do nothing, we are in the right mode */ - break; - - case S3C2412_IISMOD_MODE_RXONLY: - mod &= ~S3C2412_IISMOD_MODE_MASK; - mod |= S3C2412_IISMOD_MODE_TXRX; - break; - - default: - dev_err(i2s->dev, "TXEN: Invalid MODE in IISMOD\n"); - } - - writel(con, regs + S3C2412_IISCON); - writel(mod, regs + S3C2412_IISMOD); - } else { - /* Note, we do not have any indication that the FIFO problems - * tha the S3C2410/2440 had apply here, so we should be able - * to disable the DMA and TX without resetting the FIFOS. - */ - - con |= S3C2412_IISCON_TXDMA_PAUSE; - con |= S3C2412_IISCON_TXCH_PAUSE; - con &= ~S3C2412_IISCON_TXDMA_ACTIVE; - - switch (mod & S3C2412_IISMOD_MODE_MASK) { - case S3C2412_IISMOD_MODE_TXRX: - mod &= ~S3C2412_IISMOD_MODE_MASK; - mod |= S3C2412_IISMOD_MODE_RXONLY; - break; - - case S3C2412_IISMOD_MODE_TXONLY: - mod &= ~S3C2412_IISMOD_MODE_MASK; - con &= ~S3C2412_IISCON_IIS_ACTIVE; - break; - - default: - dev_err(i2s->dev, "TXDIS: Invalid MODE in IISMOD\n"); - } - - writel(mod, regs + S3C2412_IISMOD); - writel(con, regs + S3C2412_IISCON); - } - - fic = readl(regs + S3C2412_IISFIC); - dbg_showcon(__func__, con); - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); -} - -static void s3c2412_snd_rxctrl(int on) -{ - struct s3c2412_i2s_info *i2s = &s3c2412_i2s; - void __iomem *regs = i2s->regs; - u32 fic, con, mod; - - DBG("%s(%d)\n", __func__, on); - - fic = readl(regs + S3C2412_IISFIC); - con = readl(regs + S3C2412_IISCON); - mod = readl(regs + S3C2412_IISMOD); - - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); - - if (on) { - con |= S3C2412_IISCON_RXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; - con &= ~S3C2412_IISCON_RXDMA_PAUSE; - con &= ~S3C2412_IISCON_RXCH_PAUSE; - - switch (mod & S3C2412_IISMOD_MODE_MASK) { - case S3C2412_IISMOD_MODE_TXRX: - case S3C2412_IISMOD_MODE_RXONLY: - /* do nothing, we are in the right mode */ - break; - - case S3C2412_IISMOD_MODE_TXONLY: - mod &= ~S3C2412_IISMOD_MODE_MASK; - mod |= S3C2412_IISMOD_MODE_TXRX; - break; - - default: - dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n"); - } - - writel(mod, regs + S3C2412_IISMOD); - writel(con, regs + S3C2412_IISCON); - } else { - /* See txctrl notes on FIFOs. */ - - con &= ~S3C2412_IISCON_RXDMA_ACTIVE; - con |= S3C2412_IISCON_RXDMA_PAUSE; - con |= S3C2412_IISCON_RXCH_PAUSE; - - switch (mod & S3C2412_IISMOD_MODE_MASK) { - case S3C2412_IISMOD_MODE_RXONLY: - con &= ~S3C2412_IISCON_IIS_ACTIVE; - mod &= ~S3C2412_IISMOD_MODE_MASK; - break; - - case S3C2412_IISMOD_MODE_TXRX: - mod &= ~S3C2412_IISMOD_MODE_MASK; - mod |= S3C2412_IISMOD_MODE_TXONLY; - break; - - default: - dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n"); - } - - writel(con, regs + S3C2412_IISCON); - writel(mod, regs + S3C2412_IISMOD); - } - - fic = readl(regs + S3C2412_IISFIC); - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); -} - - -/* - * Wait for the LR signal to allow synchronisation to the L/R clock - * from the codec. May only be needed for slave mode. - */ -static int s3c2412_snd_lrsync(void) -{ - u32 iiscon; - unsigned long timeout = jiffies + msecs_to_jiffies(5); - - DBG("Entered %s\n", __func__); - - while (1) { - iiscon = readl(s3c2412_i2s.regs + S3C2412_IISCON); - if (iiscon & S3C2412_IISCON_LRINDEX) - break; - - if (timeout < jiffies) { - printk(KERN_ERR "%s: timeout\n", __func__); - return -ETIMEDOUT; - } - } - - return 0; -} - -/* - * Check whether CPU is the master or slave - */ -static inline int s3c2412_snd_is_clkmaster(void) -{ - u32 iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD); - - DBG("Entered %s\n", __func__); - - iismod &= S3C2412_IISMOD_MASTER_MASK; - return !(iismod == S3C2412_IISMOD_SLAVE); -} - -/* - * Set S3C2412 I2S DAI format - */ -static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, - unsigned int fmt) -{ - u32 iismod; - - - DBG("Entered %s\n", __func__); - - iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD); - DBG("hw_params r: IISMOD: %x \n", iismod); - - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFM: - iismod &= ~S3C2412_IISMOD_MASTER_MASK; - iismod |= S3C2412_IISMOD_SLAVE; - break; - case SND_SOC_DAIFMT_CBS_CFS: - iismod &= ~S3C2412_IISMOD_MASTER_MASK; - iismod |= S3C2412_IISMOD_MASTER_INTERNAL; - break; - default: - DBG("unknwon master/slave format\n"); - return -EINVAL; - } - - iismod &= ~S3C2412_IISMOD_SDF_MASK; - - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_RIGHT_J: - iismod |= S3C2412_IISMOD_SDF_MSB; - break; - case SND_SOC_DAIFMT_LEFT_J: - iismod |= S3C2412_IISMOD_SDF_LSB; - break; - case SND_SOC_DAIFMT_I2S: - iismod |= S3C2412_IISMOD_SDF_IIS; - break; - default: - DBG("Unknown data format\n"); - return -EINVAL; - } - - writel(iismod, s3c2412_i2s.regs + S3C2412_IISMOD); - DBG("hw_params w: IISMOD: %x \n", iismod); - return 0; -} - -static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - u32 iismod; - - DBG("Entered %s\n", __func__); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - rtd->dai->cpu_dai->dma_data = &s3c2412_i2s_pcm_stereo_out; - else - rtd->dai->cpu_dai->dma_data = &s3c2412_i2s_pcm_stereo_in; - - /* Working copies of register */ - iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD); - DBG("%s: r: IISMOD: %x\n", __func__, iismod); - - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S8: - iismod |= S3C2412_IISMOD_8BIT; - break; - case SNDRV_PCM_FORMAT_S16_LE: - iismod &= ~S3C2412_IISMOD_8BIT; - break; - } - - writel(iismod, s3c2412_i2s.regs + S3C2412_IISMOD); - DBG("%s: w: IISMOD: %x\n", __func__, iismod); - return 0; -} - -static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); - unsigned long irqs; - int ret = 0; - - DBG("Entered %s\n", __func__); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - /* On start, ensure that the FIFOs are cleared and reset. */ - - writel(capture ? S3C2412_IISFIC_RXFLUSH : S3C2412_IISFIC_TXFLUSH, - s3c2412_i2s.regs + S3C2412_IISFIC); - - /* clear again, just in case */ - writel(0x0, s3c2412_i2s.regs + S3C2412_IISFIC); - - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (!s3c2412_snd_is_clkmaster()) { - ret = s3c2412_snd_lrsync(); - if (ret) - goto exit_err; - } - - local_irq_save(irqs); - - if (capture) - s3c2412_snd_rxctrl(1); - else - s3c2412_snd_txctrl(1); - - local_irq_restore(irqs); - break; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - local_irq_save(irqs); - - if (capture) - s3c2412_snd_rxctrl(0); - else - s3c2412_snd_txctrl(0); - - local_irq_restore(irqs); - break; - default: - ret = -EINVAL; - break; - } - -exit_err: - return ret; -} - -/* default table of all avaialable root fs divisors */ -static unsigned int s3c2412_iis_fs[] = { 256, 512, 384, 768, 0 }; - -int s3c2412_iis_calc_rate(struct s3c2412_rate_calc *info, - unsigned int *fstab, - unsigned int rate, struct clk *clk) -{ - unsigned long clkrate = clk_get_rate(clk); - unsigned int div; - unsigned int fsclk; - unsigned int actual; - unsigned int fs; - unsigned int fsdiv; - signed int deviation = 0; - unsigned int best_fs = 0; - unsigned int best_div = 0; - unsigned int best_rate = 0; - unsigned int best_deviation = INT_MAX; - - - if (fstab == NULL) - fstab = s3c2412_iis_fs; - - for (fs = 0;; fs++) { - fsdiv = s3c2412_iis_fs[fs]; - - if (fsdiv == 0) - break; - - fsclk = clkrate / fsdiv; - div = fsclk / rate; - - if ((fsclk % rate) > (rate / 2)) - div++; - - if (div <= 1) - continue; - - actual = clkrate / (fsdiv * div); - deviation = actual - rate; - - printk(KERN_DEBUG "%dfs: div %d => result %d, deviation %d\n", - fsdiv, div, actual, deviation); - - deviation = abs(deviation); - - if (deviation < best_deviation) { - best_fs = fsdiv; - best_div = div; - best_rate = actual; - best_deviation = deviation; - } - - if (deviation == 0) - break; - } - - printk(KERN_DEBUG "best: fs=%d, div=%d, rate=%d\n", - best_fs, best_div, best_rate); - - info->fs_div = best_fs; - info->clk_div = best_div; - - return 0; -} -EXPORT_SYMBOL_GPL(s3c2412_iis_calc_rate); +static struct s3c_i2sv2_info s3c2412_i2s; /* * Set S3C2412 Clock source @@ -510,10 +85,12 @@ static int s3c2412_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, switch (clk_id) { case S3C2412_CLKSRC_PCLK: + s3c2412_i2s.master = 1; iismod &= ~S3C2412_IISMOD_MASTER_MASK; iismod |= S3C2412_IISMOD_MASTER_INTERNAL; break; case S3C2412_CLKSRC_I2SCLK: + s3c2412_i2s.master = 0; iismod &= ~S3C2412_IISMOD_MASTER_MASK; iismod |= S3C2412_IISMOD_MASTER_EXTERNAL; break; @@ -525,74 +102,6 @@ static int s3c2412_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, return 0; } -/* - * Set S3C2412 Clock dividers - */ -static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, - int div_id, int div) -{ - struct s3c2412_i2s_info *i2s = &s3c2412_i2s; - u32 reg; - - DBG("%s(%p, %d, %d)\n", __func__, cpu_dai, div_id, div); - - switch (div_id) { - case S3C2412_DIV_BCLK: - reg = readl(i2s->regs + S3C2412_IISMOD); - reg &= ~S3C2412_IISMOD_BCLK_MASK; - writel(reg | div, i2s->regs + S3C2412_IISMOD); - - DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); - break; - - case S3C2412_DIV_RCLK: - if (div > 3) { - /* convert value to bit field */ - - switch (div) { - case 256: - div = S3C2412_IISMOD_RCLK_256FS; - break; - - case 384: - div = S3C2412_IISMOD_RCLK_384FS; - break; - - case 512: - div = S3C2412_IISMOD_RCLK_512FS; - break; - - case 768: - div = S3C2412_IISMOD_RCLK_768FS; - break; - - default: - return -EINVAL; - } - } - - reg = readl(s3c2412_i2s.regs + S3C2412_IISMOD); - reg &= ~S3C2412_IISMOD_RCLK_MASK; - writel(reg | div, i2s->regs + S3C2412_IISMOD); - DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); - break; - - case S3C2412_DIV_PRESCALER: - if (div >= 0) { - writel((div << 8) | S3C2412_IISPSR_PSREN, - i2s->regs + S3C2412_IISPSR); - } else { - writel(0x0, i2s->regs + S3C2412_IISPSR); - } - DBG("%s: PSR=%08x\n", __func__, readl(i2s->regs + S3C2412_IISPSR)); - break; - - default: - return -EINVAL; - } - - return 0; -} struct clk *s3c2412_get_iisclk(void) { @@ -604,20 +113,16 @@ EXPORT_SYMBOL_GPL(s3c2412_get_iisclk); static int s3c2412_i2s_probe(struct platform_device *pdev, struct snd_soc_dai *dai) { - DBG("Entered %s\n", __func__); + int ret; - s3c2412_i2s.dev = &pdev->dev; + DBG("Entered %s\n", __func__); - s3c2412_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); - if (s3c2412_i2s.regs == NULL) - return -ENXIO; + ret = s3c_i2sv2_probe(pdev, dai, &s3c2412_i2s, S3C2410_PA_IIS); + if (ret) + return ret; - s3c2412_i2s.iis_pclk = clk_get(&pdev->dev, "iis"); - if (s3c2412_i2s.iis_pclk == NULL) { - DBG("failed to get iis_clock\n"); - iounmap(s3c2412_i2s.regs); - return -ENODEV; - } + s3c2412_i2s.dma_capture = &s3c2412_i2s_pcm_stereo_in; + s3c2412_i2s.dma_playback = &s3c2412_i2s_pcm_stereo_out; s3c2412_i2s.iis_cclk = clk_get(&pdev->dev, "i2sclk"); if (s3c2412_i2s.iis_cclk == NULL) { @@ -626,12 +131,12 @@ static int s3c2412_i2s_probe(struct platform_device *pdev, return -ENODEV; } - clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); + /* Set MPLL as the source for IIS CLK */ - clk_enable(s3c2412_i2s.iis_pclk); + clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); clk_enable(s3c2412_i2s.iis_cclk); - s3c2412_i2s.iis_clk = s3c2412_i2s.iis_pclk; + s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk; /* Configure the I2S pins in correct mode */ s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK); @@ -640,78 +145,18 @@ static int s3c2412_i2s_probe(struct platform_device *pdev, s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI); s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO); - s3c2412_snd_txctrl(0); - s3c2412_snd_rxctrl(0); - - return 0; -} - -#ifdef CONFIG_PM -static int s3c2412_i2s_suspend(struct snd_soc_dai *dai) -{ - struct s3c2412_i2s_info *i2s = &s3c2412_i2s; - u32 iismod; - - if (dai->active) { - i2s->suspend_iismod = readl(i2s->regs + S3C2412_IISMOD); - i2s->suspend_iiscon = readl(i2s->regs + S3C2412_IISCON); - i2s->suspend_iispsr = readl(i2s->regs + S3C2412_IISPSR); - - /* some basic suspend checks */ - - iismod = readl(i2s->regs + S3C2412_IISMOD); - - if (iismod & S3C2412_IISCON_RXDMA_ACTIVE) - pr_warning("%s: RXDMA active?\n", __func__); - - if (iismod & S3C2412_IISCON_TXDMA_ACTIVE) - pr_warning("%s: TXDMA active?\n", __func__); - - if (iismod & S3C2412_IISCON_IIS_ACTIVE) - pr_warning("%s: IIS active\n", __func__); - } - return 0; } -static int s3c2412_i2s_resume(struct snd_soc_dai *dai) -{ - struct s3c2412_i2s_info *i2s = &s3c2412_i2s; - - pr_info("dai_active %d, IISMOD %08x, IISCON %08x\n", - dai->active, i2s->suspend_iismod, i2s->suspend_iiscon); - - if (dai->active) { - writel(i2s->suspend_iiscon, i2s->regs + S3C2412_IISCON); - writel(i2s->suspend_iismod, i2s->regs + S3C2412_IISMOD); - writel(i2s->suspend_iispsr, i2s->regs + S3C2412_IISPSR); - - writel(S3C2412_IISFIC_RXFLUSH | S3C2412_IISFIC_TXFLUSH, - i2s->regs + S3C2412_IISFIC); - - ndelay(250); - writel(0x0, i2s->regs + S3C2412_IISFIC); - - } - - return 0; -} -#else -#define s3c2412_i2s_suspend NULL -#define s3c2412_i2s_resume NULL -#endif /* CONFIG_PM */ - #define S3C2412_I2S_RATES \ (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) struct snd_soc_dai s3c2412_i2s_dai = { - .name = "s3c2412-i2s", - .id = 0, - .probe = s3c2412_i2s_probe, - .suspend = s3c2412_i2s_suspend, - .resume = s3c2412_i2s_resume, + .name = "s3c2412-i2s", + .id = 0, + .probe = s3c2412_i2s_probe, .playback = { .channels_min = 2, .channels_max = 2, @@ -725,10 +170,6 @@ struct snd_soc_dai s3c2412_i2s_dai = { .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE, }, .ops = { - .trigger = s3c2412_i2s_trigger, - .hw_params = s3c2412_i2s_hw_params, - .set_fmt = s3c2412_i2s_set_fmt, - .set_clkdiv = s3c2412_i2s_set_clkdiv, .set_sysclk = s3c2412_i2s_set_sysclk, }, }; @@ -736,7 +177,7 @@ EXPORT_SYMBOL_GPL(s3c2412_i2s_dai); static int __init s3c2412_i2s_init(void) { - return snd_soc_register_dai(&s3c2412_i2s_dai); + return s3c_i2sv2_register_dai(&s3c2412_i2s_dai); } module_init(s3c2412_i2s_init); @@ -746,7 +187,6 @@ static void __exit s3c2412_i2s_exit(void) } module_exit(s3c2412_i2s_exit); - /* Module information */ MODULE_AUTHOR("Ben Dooks, "); MODULE_DESCRIPTION("S3C2412 I2S SoC Interface"); diff --git a/sound/soc/s3c24xx/s3c2412-i2s.h b/sound/soc/s3c24xx/s3c2412-i2s.h index aac08a25e54..92848e54be1 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.h +++ b/sound/soc/s3c24xx/s3c2412-i2s.h @@ -15,9 +15,11 @@ #ifndef __SND_SOC_S3C24XX_S3C2412_I2S_H #define __SND_SOC_S3C24XX_S3C2412_I2S_H __FILE__ -#define S3C2412_DIV_BCLK (1) -#define S3C2412_DIV_RCLK (2) -#define S3C2412_DIV_PRESCALER (3) +#include "s3c-i2s-v2.h" + +#define S3C2412_DIV_BCLK S3C_I2SV2_DIV_BCLK +#define S3C2412_DIV_RCLK S3C_I2SV2_DIV_RCLK +#define S3C2412_DIV_PRESCALER S3C_I2SV2_DIV_PRESCALER #define S3C2412_CLKSRC_PCLK (0) #define S3C2412_CLKSRC_I2SCLK (1) @@ -26,13 +28,4 @@ extern struct clk *s3c2412_get_iisclk(void); extern struct snd_soc_dai s3c2412_i2s_dai; -struct s3c2412_rate_calc { - unsigned int clk_div; /* for prescaler */ - unsigned int fs_div; /* for root frame clock */ -}; - -extern int s3c2412_iis_calc_rate(struct s3c2412_rate_calc *info, - unsigned int *fstab, - unsigned int rate, struct clk *clk); - #endif /* __SND_SOC_S3C24XX_S3C2412_I2S_H */ -- cgit v1.2.3 From f8cf8176c7fc2c790e900595755b93e30633754d Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 4 Mar 2009 00:49:31 +0000 Subject: ASoC: Add s3c64xx-i2s support Add the initial code to support the S3C64XX I2S hardware using the s3c-i2s-v2 core code. Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/Kconfig | 6 +- sound/soc/s3c24xx/Makefile | 2 + sound/soc/s3c24xx/s3c64xx-i2s.c | 220 ++++++++++++++++++++++++++++++++++++++++ sound/soc/s3c24xx/s3c64xx-i2s.h | 31 ++++++ 4 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 sound/soc/s3c24xx/s3c64xx-i2s.c create mode 100644 sound/soc/s3c24xx/s3c64xx-i2s.h (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index bd98adaa5b0..036a4965c95 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -1,6 +1,6 @@ config SND_S3C24XX_SOC tristate "SoC Audio for the Samsung S3C24XX chips" - depends on ARCH_S3C2410 + depends on ARCH_S3C2410 || ARCH_S3C64XX help Say Y or M if you want to add support for codecs attached to the S3C24XX AC97, I2S or SSP interface. You will also need @@ -16,6 +16,10 @@ config SND_S3C2412_SOC_I2S tristate select SND_S3C_I2SV2_SOC +config SND_S3C64XX_SOC_I2S + tristate + select SND_S3C_I2SV2_SOC + config SND_S3C2443_SOC_AC97 tristate select AC97_BUS diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile index 848981e18ac..07a93a2ebe5 100644 --- a/sound/soc/s3c24xx/Makefile +++ b/sound/soc/s3c24xx/Makefile @@ -2,6 +2,7 @@ snd-soc-s3c24xx-objs := s3c24xx-pcm.o snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o +snd-soc-s3c64xx-i2s-objs := s3c64xx-i2s.o snd-soc-s3c2443-ac97-objs := s3c2443-ac97.o snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o @@ -9,6 +10,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o obj-$(CONFIG_SND_S3C2443_SOC_AC97) += snd-soc-s3c2443-ac97.o obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o +obj-$(CONFIG_SND_S3C64XX_SOC_I2S) += snd-soc-s3c64xx-i2s.o obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o # S3C24XX Machine Support diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c new file mode 100644 index 00000000000..6e1e85dc1ff --- /dev/null +++ b/sound/soc/s3c24xx/s3c64xx-i2s.c @@ -0,0 +1,220 @@ +/* sound/soc/s3c24xx/s3c64xx-i2s.c + * + * ALSA SoC Audio Layer - S3C64XX I2S driver + * + * Copyright 2008 Openmoko, Inc. + * Copyright 2008 Simtec Electronics + * Ben Dooks + * http://armlinux.simtec.co.uk/ + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "s3c24xx-pcm.h" +#include "s3c64xx-i2s.h" + +static struct s3c2410_dma_client s3c64xx_dma_client_out = { + .name = "I2S PCM Stereo out" +}; + +static struct s3c2410_dma_client s3c64xx_dma_client_in = { + .name = "I2S PCM Stereo in" +}; + +static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_out[2] = { + [0] = { + .channel = DMACH_I2S0_OUT, + .client = &s3c64xx_dma_client_out, + .dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISTXD, + .dma_size = 4, + }, + [1] = { + .channel = DMACH_I2S1_OUT, + .client = &s3c64xx_dma_client_out, + .dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISTXD, + .dma_size = 4, + }, +}; + +static struct s3c24xx_pcm_dma_params s3c64xx_i2s_pcm_stereo_in[2] = { + [0] = { + .channel = DMACH_I2S0_IN, + .client = &s3c64xx_dma_client_in, + .dma_addr = S3C64XX_PA_IIS0 + S3C2412_IISRXD, + .dma_size = 4, + }, + [1] = { + .channel = DMACH_I2S1_IN, + .client = &s3c64xx_dma_client_in, + .dma_addr = S3C64XX_PA_IIS1 + S3C2412_IISRXD, + .dma_size = 4, + }, +}; + +static struct s3c_i2sv2_info s3c64xx_i2s[2]; + +static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) +{ + return cpu_dai->private_data; +} + +static int s3c64xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, + int clk_id, unsigned int freq, int dir) +{ + struct s3c_i2sv2_info *i2s = to_info(cpu_dai); + u32 iismod = readl(i2s->regs + S3C2412_IISMOD); + + switch (clk_id) { + case S3C64XX_CLKSRC_PCLK: + iismod &= ~S3C64XX_IISMOD_IMS_SYSMUX; + break; + + case S3C64XX_CLKSRC_MUX: + iismod |= S3C64XX_IISMOD_IMS_SYSMUX; + break; + + default: + return -EINVAL; + } + + writel(iismod, i2s->regs + S3C2412_IISMOD); + + return 0; +} + + +unsigned long s3c64xx_i2s_get_clockrate(struct snd_soc_dai *dai) +{ + struct s3c_i2sv2_info *i2s = to_info(dai); + + return clk_get_rate(i2s->iis_cclk); +} +EXPORT_SYMBOL_GPL(s3c64xx_i2s_get_clockrate); + +static int s3c64xx_i2s_probe(struct platform_device *pdev, + struct snd_soc_dai *dai) +{ + struct device *dev = &pdev->dev; + struct s3c_i2sv2_info *i2s; + int ret; + + dev_dbg(dev, "%s: probing dai %d\n", __func__, pdev->id); + + if (pdev->id < 0 || pdev->id > ARRAY_SIZE(s3c64xx_i2s)) { + dev_err(dev, "id %d out of range\n", pdev->id); + return -EINVAL; + } + + i2s = &s3c64xx_i2s[pdev->id]; + + ret = s3c_i2sv2_probe(pdev, dai, i2s, + pdev->id ? S3C64XX_PA_IIS1 : S3C64XX_PA_IIS0); + if (ret) + return ret; + + i2s->dma_capture = &s3c64xx_i2s_pcm_stereo_in[pdev->id]; + i2s->dma_playback = &s3c64xx_i2s_pcm_stereo_out[pdev->id]; + + i2s->iis_cclk = clk_get(dev, "audio-bus"); + if (IS_ERR(i2s->iis_cclk)) { + dev_err(dev, "failed to get audio-bus"); + iounmap(i2s->regs); + return -ENODEV; + } + + /* configure GPIO for i2s port */ + switch (pdev->id) { + case 0: + s3c_gpio_cfgpin(S3C64XX_GPD(0), S3C64XX_GPD0_I2S0_CLK); + s3c_gpio_cfgpin(S3C64XX_GPD(1), S3C64XX_GPD1_I2S0_CDCLK); + s3c_gpio_cfgpin(S3C64XX_GPD(2), S3C64XX_GPD2_I2S0_LRCLK); + s3c_gpio_cfgpin(S3C64XX_GPD(3), S3C64XX_GPD3_I2S0_DI); + s3c_gpio_cfgpin(S3C64XX_GPD(4), S3C64XX_GPD4_I2S0_D0); + break; + case 1: + s3c_gpio_cfgpin(S3C64XX_GPE(0), S3C64XX_GPE0_I2S1_CLK); + s3c_gpio_cfgpin(S3C64XX_GPE(1), S3C64XX_GPE1_I2S1_CDCLK); + s3c_gpio_cfgpin(S3C64XX_GPE(2), S3C64XX_GPE2_I2S1_LRCLK); + s3c_gpio_cfgpin(S3C64XX_GPE(3), S3C64XX_GPE3_I2S1_DI); + s3c_gpio_cfgpin(S3C64XX_GPE(4), S3C64XX_GPE4_I2S1_D0); + } + + return 0; +} + + +#define S3C64XX_I2S_RATES \ + (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \ + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) + +#define S3C64XX_I2S_FMTS \ + (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE) + +struct snd_soc_dai s3c64xx_i2s_dai = { + .name = "s3c64xx-i2s", + .id = 0, + .probe = s3c64xx_i2s_probe, + .playback = { + .channels_min = 2, + .channels_max = 2, + .rates = S3C64XX_I2S_RATES, + .formats = S3C64XX_I2S_FMTS, + }, + .capture = { + .channels_min = 2, + .channels_max = 2, + .rates = S3C64XX_I2S_RATES, + .formats = S3C64XX_I2S_FMTS, + }, + .ops = { + .set_sysclk = s3c64xx_i2s_set_sysclk, + }, +}; +EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai); + +static int __init s3c64xx_i2s_init(void) +{ + return s3c_i2sv2_register_dai(&s3c64xx_i2s_dai); +} +module_init(s3c64xx_i2s_init); + +static void __exit s3c64xx_i2s_exit(void) +{ + snd_soc_unregister_dai(&s3c64xx_i2s_dai); +} +module_exit(s3c64xx_i2s_exit); + +/* Module information */ +MODULE_AUTHOR("Ben Dooks, "); +MODULE_DESCRIPTION("S3C64XX I2S SoC Interface"); +MODULE_LICENSE("GPL"); + + + diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.h b/sound/soc/s3c24xx/s3c64xx-i2s.h new file mode 100644 index 00000000000..b7ffe3c38b6 --- /dev/null +++ b/sound/soc/s3c24xx/s3c64xx-i2s.h @@ -0,0 +1,31 @@ +/* sound/soc/s3c24xx/s3c64xx-i2s.h + * + * ALSA SoC Audio Layer - S3C64XX I2S driver + * + * Copyright 2008 Openmoko, Inc. + * Copyright 2008 Simtec Electronics + * Ben Dooks + * http://armlinux.simtec.co.uk/ + * + * 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. + */ + +#ifndef __SND_SOC_S3C24XX_S3C64XX_I2S_H +#define __SND_SOC_S3C24XX_S3C64XX_I2S_H __FILE__ + +#include "s3c-i2s-v2.h" + +#define S3C64XX_DIV_BCLK S3C_I2SV2_DIV_BCLK +#define S3C64XX_DIV_RCLK S3C_I2SV2_DIV_RCLK +#define S3C64XX_DIV_PRESCALER S3C_I2SV2_DIV_PRESCALER + +#define S3C64XX_CLKSRC_PCLK (0) +#define S3C64XX_CLKSRC_MUX (1) + +extern struct snd_soc_dai s3c64xx_i2s_dai; + +extern unsigned long s3c64xx_i2s_get_clockrate(struct snd_soc_dai *cpu_dai); + +#endif /* __SND_SOC_S3C24XX_S3C64XX_I2S_H */ -- cgit v1.2.3 From c36623a7543e7a23ceeafbeb7b34a9e020100898 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 4 Mar 2009 00:49:34 +0000 Subject: ASoC: Select DMA if I2S is configured Select the relevant DMA implementation when the sound driver is selected. Signed-off-by: Ben Dooks Signed-off-by: Mark Brown --- sound/soc/s3c24xx/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index 036a4965c95..f22dbeec48a 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -8,6 +8,7 @@ config SND_S3C24XX_SOC config SND_S3C24XX_SOC_I2S tristate + select S3C2410_DMA config SND_S3C_I2SV2_SOC tristate @@ -15,13 +16,16 @@ config SND_S3C_I2SV2_SOC config SND_S3C2412_SOC_I2S tristate select SND_S3C_I2SV2_SOC + select S3C2410_DMA config SND_S3C64XX_SOC_I2S tristate select SND_S3C_I2SV2_SOC + select S3C64XX_DMA config SND_S3C2443_SOC_AC97 tristate + select S3C2410_DMA select AC97_BUS select SND_SOC_AC97_BUS -- cgit v1.2.3 From a1b3eaeb146937e954cdb6dcb67f8761b73e2eef Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 4 Mar 2009 20:17:48 +0000 Subject: ASoC: Refresh JIVE driver Remove uneeded startup callback and use snd_soc_dapm_nc_pin() Signed-off-by: Mark Brown --- sound/soc/s3c24xx/jive_wm8750.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/jive_wm8750.c b/sound/soc/s3c24xx/jive_wm8750.c index 7dfe26ea8f4..32063790d95 100644 --- a/sound/soc/s3c24xx/jive_wm8750.c +++ b/sound/soc/s3c24xx/jive_wm8750.c @@ -45,20 +45,6 @@ static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = { SND_SOC_DAPM_LINE("Line In", NULL), }; -static int jive_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; - - snd_soc_dapm_enable_pin(codec, "Headphone Jack"); - snd_soc_dapm_enable_pin(codec, "Internal Speaker"); - snd_soc_dapm_enable_pin(codec, "Line In"); - - snd_soc_dapm_sync(codec); - - return 0; -} - static int jive_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -119,7 +105,6 @@ static int jive_hw_params(struct snd_pcm_substream *substream, } static struct snd_soc_ops jive_ops = { - .startup = jive_startup, .hw_params = jive_hw_params, }; @@ -128,12 +113,12 @@ static int jive_wm8750_init(struct snd_soc_codec *codec) int err; /* These endpoints are not being used. */ - snd_soc_dapm_disable_pin(codec, "LINPUT2"); - snd_soc_dapm_disable_pin(codec, "RINPUT2"); - snd_soc_dapm_disable_pin(codec, "LINPUT3"); - snd_soc_dapm_disable_pin(codec, "RINPUT3"); - snd_soc_dapm_disable_pin(codec, "OUT3"); - snd_soc_dapm_disable_pin(codec, "MONO"); + snd_soc_dapm_nc_pin(codec, "LINPUT2"); + snd_soc_dapm_nc_pin(codec, "RINPUT2"); + snd_soc_dapm_nc_pin(codec, "LINPUT3"); + snd_soc_dapm_nc_pin(codec, "RINPUT3"); + snd_soc_dapm_nc_pin(codec, "OUT3"); + snd_soc_dapm_nc_pin(codec, "MONO"); /* Add jive specific widgets */ err = snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, -- cgit v1.2.3 From 89492be88616aa20b3a6c3eb512f83c0c7d0c8a3 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 5 Mar 2009 12:48:49 +0200 Subject: ASoC: TWL4030: Make the HS ramp delay configurable Enum type for selecting the desired ramp delay for the headset output. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 535d8ce2c32..86bb15cc82c 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -584,12 +584,11 @@ static int headsetl_event(struct snd_soc_dapm_widget *w, /* Save the current volume */ hs_gain = twl4030_read_reg_cache(w->codec, TWL4030_REG_HS_GAIN_SET); + hs_pop = twl4030_read_reg_cache(w->codec, TWL4030_REG_HS_POPN_SET); switch (event) { case SND_SOC_DAPM_POST_PMU: /* Do the anti-pop/bias ramp enable according to the TRM */ - hs_pop = TWL4030_RAMP_DELAY_645MS; - twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); hs_pop |= TWL4030_VMID_EN; twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); /* Is this needed? Can we just use whatever gain here? */ @@ -603,8 +602,6 @@ static int headsetl_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: /* Do the anti-pop/bias ramp disable according to the TRM */ - hs_pop = twl4030_read_reg_cache(w->codec, - TWL4030_REG_HS_POPN_SET); hs_pop &= ~TWL4030_RAMP_EN; twl4030_write(w->codec, TWL4030_REG_HS_POPN_SET, hs_pop); /* Bypass the reg_cache to mute the headset */ @@ -847,6 +844,17 @@ static DECLARE_TLV_DB_SCALE(digital_capture_tlv, 0, 100, 0); */ static DECLARE_TLV_DB_SCALE(input_gain_tlv, 0, 600, 0); +static const char *twl4030_rampdelay_texts[] = { + "27/20/14 ms", "55/40/27 ms", "109/81/55 ms", "218/161/109 ms", + "437/323/218 ms", "874/645/437 ms", "1748/1291/874 ms", + "3495/2581/1748 ms" +}; + +static const struct soc_enum twl4030_rampdelay_enum = + SOC_ENUM_SINGLE(TWL4030_REG_HS_POPN_SET, 2, + ARRAY_SIZE(twl4030_rampdelay_texts), + twl4030_rampdelay_texts); + static const struct snd_kcontrol_new twl4030_snd_controls[] = { /* Common playback gain controls */ SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume", @@ -901,6 +909,8 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = { SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN, 0, 3, 5, 0, input_gain_tlv), + + SOC_ENUM("HS ramp delay", twl4030_rampdelay_enum), }; static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { -- cgit v1.2.3 From 20a41eac4fbaa22d051d0fbaeaf3315d2d8c4860 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 4 Mar 2009 21:16:57 +0100 Subject: ASoC: Fix name of register bit in pxa-ssp A bit in PXA's SSCR0 register was erroneously named ADC but its name is in fact ACS (audio clock select). Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index c49bb12b0a6..7fc13f03d1d 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -300,7 +300,7 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai, int val; u32 sscr0 = ssp_read_reg(ssp, SSCR0) & - ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ADC); + ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); dev_dbg(&ssp->pdev->dev, "pxa_ssp_set_dai_sysclk id: %d, clk_id %d, freq %d\n", @@ -328,7 +328,7 @@ static int pxa_ssp_set_dai_sysclk(struct snd_soc_dai *cpu_dai, case PXA_SSP_CLK_AUDIO: priv->sysclk = 0; ssp_set_scr(&priv->dev, 1); - sscr0 |= SSCR0_ADC; + sscr0 |= SSCR0_ACS; break; default: return -ENODEV; @@ -524,7 +524,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, /* reset port settings */ sscr0 = ssp_read_reg(ssp, SSCR0) & - (SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ADC); + (SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); sscr1 = SSCR1_RxTresh(8) | SSCR1_TxTresh(7); sspsp = 0; -- cgit v1.2.3 From 42aa3418ebd7b79be0e1ee7515e365c1574114f9 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 1 Mar 2009 19:21:10 +0000 Subject: ASoC: Factor out DAPM widget power check into separate function Essentially simple code motion to facilitate refactoring of the power decisions. Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 258 +++++++++++++++++++++++++++------------------------ 1 file changed, 137 insertions(+), 121 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 4b8dbbfe2ef..7da6d0db40f 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -522,6 +522,137 @@ int dapm_reg_event(struct snd_soc_dapm_widget *w, } EXPORT_SYMBOL_GPL(dapm_reg_event); +/* + * Scan a single DAPM widget for a complete audio path and update the + * power status appropriately. + */ +static int dapm_power_widget(struct snd_soc_codec *codec, int event, + struct snd_soc_dapm_widget *w) +{ + int in, out, power_change, power, ret; + + /* vmid - no action */ + if (w->id == snd_soc_dapm_vmid) + return 0; + + /* active ADC */ + if (w->id == snd_soc_dapm_adc && w->active) { + in = is_connected_input_ep(w); + dapm_clear_walk(w->codec); + w->power = (in != 0) ? 1 : 0; + dapm_update_bits(w); + return 0; + } + + /* active DAC */ + if (w->id == snd_soc_dapm_dac && w->active) { + out = is_connected_output_ep(w); + dapm_clear_walk(w->codec); + w->power = (out != 0) ? 1 : 0; + dapm_update_bits(w); + return 0; + } + + /* pre and post event widgets */ + if (w->id == snd_soc_dapm_pre) { + if (!w->event) + return 0; + + if (event == SND_SOC_DAPM_STREAM_START) { + ret = w->event(w, + NULL, SND_SOC_DAPM_PRE_PMU); + if (ret < 0) + return ret; + } else if (event == SND_SOC_DAPM_STREAM_STOP) { + ret = w->event(w, + NULL, SND_SOC_DAPM_PRE_PMD); + if (ret < 0) + return ret; + } + return 0; + } + if (w->id == snd_soc_dapm_post) { + if (!w->event) + return 0; + + if (event == SND_SOC_DAPM_STREAM_START) { + ret = w->event(w, + NULL, SND_SOC_DAPM_POST_PMU); + if (ret < 0) + return ret; + } else if (event == SND_SOC_DAPM_STREAM_STOP) { + ret = w->event(w, + NULL, SND_SOC_DAPM_POST_PMD); + if (ret < 0) + return ret; + } + return 0; + } + + /* all other widgets */ + in = is_connected_input_ep(w); + dapm_clear_walk(w->codec); + out = is_connected_output_ep(w); + dapm_clear_walk(w->codec); + power = (out != 0 && in != 0) ? 1 : 0; + power_change = (w->power == power) ? 0 : 1; + w->power = power; + + if (!power_change) + return 0; + + /* call any power change event handlers */ + if (w->event) + pr_debug("power %s event for %s flags %x\n", + w->power ? "on" : "off", + w->name, w->event_flags); + + /* power up pre event */ + if (power && w->event && + (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { + ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU); + if (ret < 0) + return ret; + } + + /* power down pre event */ + if (!power && w->event && + (w->event_flags & SND_SOC_DAPM_PRE_PMD)) { + ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD); + if (ret < 0) + return ret; + } + + /* Lower PGA volume to reduce pops */ + if (w->id == snd_soc_dapm_pga && !power) + dapm_set_pga(w, power); + + dapm_update_bits(w); + + /* Raise PGA volume to reduce pops */ + if (w->id == snd_soc_dapm_pga && power) + dapm_set_pga(w, power); + + /* power up post event */ + if (power && w->event && + (w->event_flags & SND_SOC_DAPM_POST_PMU)) { + ret = w->event(w, + NULL, SND_SOC_DAPM_POST_PMU); + if (ret < 0) + return ret; + } + + /* power down post event */ + if (!power && w->event && + (w->event_flags & SND_SOC_DAPM_POST_PMD)) { + ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD); + if (ret < 0) + return ret; + } + + return 0; +} + /* * Scan each dapm widget for complete audio path. * A complete path is a route that has valid endpoints i.e.:- @@ -534,7 +665,7 @@ EXPORT_SYMBOL_GPL(dapm_reg_event); static int dapm_power_widgets(struct snd_soc_codec *codec, int event) { struct snd_soc_dapm_widget *w; - int in, out, i, c = 1, *seq = NULL, ret = 0, power_change, power; + int i, c = 1, *seq = NULL, ret = 0; /* do we have a sequenced stream event */ if (event == SND_SOC_DAPM_STREAM_START) { @@ -545,135 +676,20 @@ static int dapm_power_widgets(struct snd_soc_codec *codec, int event) seq = dapm_down_seq; } - for(i = 0; i < c; i++) { + for (i = 0; i < c; i++) { list_for_each_entry(w, &codec->dapm_widgets, list) { /* is widget in stream order */ if (seq && seq[i] && w->id != seq[i]) continue; - /* vmid - no action */ - if (w->id == snd_soc_dapm_vmid) - continue; - - /* active ADC */ - if (w->id == snd_soc_dapm_adc && w->active) { - in = is_connected_input_ep(w); - dapm_clear_walk(w->codec); - w->power = (in != 0) ? 1 : 0; - dapm_update_bits(w); - continue; - } - - /* active DAC */ - if (w->id == snd_soc_dapm_dac && w->active) { - out = is_connected_output_ep(w); - dapm_clear_walk(w->codec); - w->power = (out != 0) ? 1 : 0; - dapm_update_bits(w); - continue; - } - - /* pre and post event widgets */ - if (w->id == snd_soc_dapm_pre) { - if (!w->event) - continue; - - if (event == SND_SOC_DAPM_STREAM_START) { - ret = w->event(w, - NULL, SND_SOC_DAPM_PRE_PMU); - if (ret < 0) - return ret; - } else if (event == SND_SOC_DAPM_STREAM_STOP) { - ret = w->event(w, - NULL, SND_SOC_DAPM_PRE_PMD); - if (ret < 0) - return ret; - } - continue; - } - if (w->id == snd_soc_dapm_post) { - if (!w->event) - continue; - - if (event == SND_SOC_DAPM_STREAM_START) { - ret = w->event(w, - NULL, SND_SOC_DAPM_POST_PMU); - if (ret < 0) - return ret; - } else if (event == SND_SOC_DAPM_STREAM_STOP) { - ret = w->event(w, - NULL, SND_SOC_DAPM_POST_PMD); - if (ret < 0) - return ret; - } - continue; - } - - /* all other widgets */ - in = is_connected_input_ep(w); - dapm_clear_walk(w->codec); - out = is_connected_output_ep(w); - dapm_clear_walk(w->codec); - power = (out != 0 && in != 0) ? 1 : 0; - power_change = (w->power == power) ? 0: 1; - w->power = power; - - if (!power_change) - continue; - - /* call any power change event handlers */ - if (w->event) - pr_debug("power %s event for %s flags %x\n", - w->power ? "on" : "off", - w->name, w->event_flags); - - /* power up pre event */ - if (power && w->event && - (w->event_flags & SND_SOC_DAPM_PRE_PMU)) { - ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMU); - if (ret < 0) - return ret; - } - - /* power down pre event */ - if (!power && w->event && - (w->event_flags & SND_SOC_DAPM_PRE_PMD)) { - ret = w->event(w, NULL, SND_SOC_DAPM_PRE_PMD); - if (ret < 0) - return ret; - } - - /* Lower PGA volume to reduce pops */ - if (w->id == snd_soc_dapm_pga && !power) - dapm_set_pga(w, power); - - dapm_update_bits(w); - - /* Raise PGA volume to reduce pops */ - if (w->id == snd_soc_dapm_pga && power) - dapm_set_pga(w, power); - - /* power up post event */ - if (power && w->event && - (w->event_flags & SND_SOC_DAPM_POST_PMU)) { - ret = w->event(w, - NULL, SND_SOC_DAPM_POST_PMU); - if (ret < 0) - return ret; - } - - /* power down post event */ - if (!power && w->event && - (w->event_flags & SND_SOC_DAPM_POST_PMD)) { - ret = w->event(w, NULL, SND_SOC_DAPM_POST_PMD); - if (ret < 0) - return ret; - } + ret = dapm_power_widget(codec, event, w); + if (ret != 0) + return ret; } } - return ret; + return 0; } #ifdef DEBUG -- cgit v1.2.3 From 07495f3e5af3a472f0f49957692cac15168fa528 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 5 Mar 2009 17:06:23 +0000 Subject: ASoC: Fix memory allocation for snd_soc_dapm_switch names snd_soc_dapm_switch ends up ends up in dapm_new_mixer() (since a switch is a special case of a mixer with only one input) but this wasn't correctly handled in the code. Also fix the coding style for the switch below while we're here. Reported-by: Joonyoung Shim Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 7da6d0db40f..735903a7467 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -332,7 +332,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, * kcontrol name. */ name_len = strlen(w->kcontrols[i].name) + 1; - if (w->id == snd_soc_dapm_mixer) + if (w->id != snd_soc_dapm_mixer_named_ctl) name_len += 1 + strlen(w->name); path->long_name = kmalloc(name_len, GFP_KERNEL); @@ -341,15 +341,14 @@ static int dapm_new_mixer(struct snd_soc_codec *codec, return -ENOMEM; switch (w->id) { - case snd_soc_dapm_mixer: default: snprintf(path->long_name, name_len, "%s %s", w->name, w->kcontrols[i].name); - break; + break; case snd_soc_dapm_mixer_named_ctl: snprintf(path->long_name, name_len, "%s", w->kcontrols[i].name); - break; + break; } path->long_name[name_len - 1] = '\0'; -- cgit v1.2.3 From 499d8f4a528f1ebd0c19d89174fdc67130090c89 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 5 Mar 2009 17:26:15 +0000 Subject: ASoC: Update Kconfig for Samsung CPUs to reflect S3C64xx support We now support the 64xx series as well as the 24xx series - make sure people using Kconfig know this. Signed-off-by: Mark Brown --- sound/soc/s3c24xx/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index f22dbeec48a..78d01ff487c 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -1,10 +1,10 @@ config SND_S3C24XX_SOC - tristate "SoC Audio for the Samsung S3C24XX chips" + tristate "SoC Audio for the Samsung S3CXXXX chips" depends on ARCH_S3C2410 || ARCH_S3C64XX help Say Y or M if you want to add support for codecs attached to - the S3C24XX AC97, I2S or SSP interface. You will also need - to select the audio interfaces to support below. + the S3C24XX and S3C64XX AC97, I2S or SSP interface. You will + also need to select the audio interfaces to support below. config SND_S3C24XX_SOC_I2S tristate -- cgit v1.2.3 From a454dad19e78388d9f140ad0dfa6a849c57d385d Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Thu, 5 Mar 2009 17:23:37 -0600 Subject: ASoC: add support for SSI asynchronous mode to the Freescale SSI drivers Add a new device tree property for the SSI node: "fsl,ssi-asynchronous". If defined, the SSI is programmed into asynchronous mode, otherwise it is programmed into synchronous mode. In asynchronous mode, pin SRCK must be connected to the same clock source as STFS, and pin SRFS must be connected to the same signal as STFS. Asynchronous mode allows playback and capture to use different sample sizes. It also technically allows different sample rates, but the driver does not support that. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 42 ++++++++++++++++++++++++++++++++---------- sound/soc/fsl/fsl_ssi.h | 2 ++ sound/soc/fsl/mpc8610_hpcd.c | 5 +++++ 3 files changed, 39 insertions(+), 10 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 6844009833d..8cb6bcf2c00 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -72,6 +72,7 @@ * @dev: struct device pointer * @playback: the number of playback streams opened * @capture: the number of capture streams opened + * @asynchronous: 0=synchronous mode, 1=asynchronous mode * @cpu_dai: the CPU DAI for this device * @dev_attr: the sysfs device attribute structure * @stats: SSI statistics @@ -86,6 +87,7 @@ struct fsl_ssi_private { struct device *dev; unsigned int playback; unsigned int capture; + int asynchronous; struct snd_soc_dai cpu_dai; struct device_attribute dev_attr; @@ -301,9 +303,10 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, * * FIXME: Little-endian samples require a different shift dir */ - clrsetbits_be32(&ssi->scr, CCSR_SSI_SCR_I2S_MODE_MASK, - CCSR_SSI_SCR_TFR_CLK_DIS | - CCSR_SSI_SCR_I2S_MODE_SLAVE | CCSR_SSI_SCR_SYN); + clrsetbits_be32(&ssi->scr, + CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, + CCSR_SSI_SCR_TFR_CLK_DIS | CCSR_SSI_SCR_I2S_MODE_SLAVE + | (ssi_private->asynchronous ? 0 : CCSR_SSI_SCR_SYN)); out_be32(&ssi->stcr, CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 | @@ -382,10 +385,15 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, SNDRV_PCM_HW_PARAM_RATE, first_runtime->rate, first_runtime->rate); - snd_pcm_hw_constraint_minmax(substream->runtime, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - first_runtime->sample_bits, - first_runtime->sample_bits); + /* If we're in synchronous mode, then we need to constrain + * the sample size as well. We don't support independent sample + * rates in asynchronous mode. + */ + if (!ssi_private->asynchronous) + snd_pcm_hw_constraint_minmax(substream->runtime, + SNDRV_PCM_HW_PARAM_SAMPLE_BITS, + first_runtime->sample_bits, + first_runtime->sample_bits); ssi_private->second_stream = substream; } @@ -421,13 +429,18 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, struct ccsr_ssi __iomem *ssi = ssi_private->ssi; unsigned int sample_size = snd_pcm_format_width(params_format(hw_params)); - u32 wl; + u32 wl = CCSR_SSI_SxCCR_WL(sample_size); /* The SSI should always be disabled at this points (SSIEN=0) */ - wl = CCSR_SSI_SxCCR_WL(sample_size); /* In synchronous mode, the SSI uses STCCR for capture */ - clrsetbits_be32(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl); + if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) || + !ssi_private->asynchronous) + clrsetbits_be32(&ssi->stccr, + CCSR_SSI_SxCCR_WL_MASK, wl); + else + clrsetbits_be32(&ssi->srccr, + CCSR_SSI_SxCCR_WL_MASK, wl); } return 0; @@ -653,6 +666,7 @@ struct snd_soc_dai *fsl_ssi_create_dai(struct fsl_ssi_info *ssi_info) ssi_private->ssi_phys = ssi_info->ssi_phys; ssi_private->irq = ssi_info->irq; ssi_private->dev = ssi_info->dev; + ssi_private->asynchronous = ssi_info->asynchronous; ssi_private->dev->driver_data = fsl_ssi_dai; @@ -703,6 +717,14 @@ void fsl_ssi_destroy_dai(struct snd_soc_dai *fsl_ssi_dai) } EXPORT_SYMBOL_GPL(fsl_ssi_destroy_dai); +static int __init fsl_ssi_init(void) +{ + printk(KERN_INFO "Freescale Synchronous Serial Interface (SSI) ASoC Driver\n"); + + return 0; +} +module_init(fsl_ssi_init); + MODULE_AUTHOR("Timur Tabi "); MODULE_DESCRIPTION("Freescale Synchronous Serial Interface (SSI) ASoC Driver"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h index 83b44d700e3..eade01feaab 100644 --- a/sound/soc/fsl/fsl_ssi.h +++ b/sound/soc/fsl/fsl_ssi.h @@ -208,6 +208,7 @@ struct ccsr_ssi { * ssi_phys: physical address of the SSI registers * irq: IRQ of this SSI * dev: struct device, used to create the sysfs statistics file + * asynchronous: 0=synchronous mode, 1=asynchronous mode */ struct fsl_ssi_info { unsigned int id; @@ -215,6 +216,7 @@ struct fsl_ssi_info { dma_addr_t ssi_phys; unsigned int irq; struct device *dev; + int asynchronous; }; struct snd_soc_dai *fsl_ssi_create_dai(struct fsl_ssi_info *ssi_info); diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index acf39a646b2..ef67d1cdffe 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -353,6 +353,11 @@ static int mpc8610_hpcd_probe(struct of_device *ofdev, } ssi_info.irq = machine_data->ssi_irq; + /* Do we want to use asynchronous mode? */ + ssi_info.asynchronous = + of_find_property(np, "fsl,ssi-asynchronous", NULL) ? 1 : 0; + if (ssi_info.asynchronous) + dev_info(&ofdev->dev, "using asynchronous mode\n"); /* Map the global utilities registers. */ guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts"); -- cgit v1.2.3 From de0b988828a45f4fefc96ff2fbed3ba2184319b9 Mon Sep 17 00:00:00 2001 From: "Lopez Cruz, Misael" Date: Thu, 5 Mar 2009 11:32:31 -0600 Subject: ASoC: Add headset jack detection for SDP3430 machine driver Add headset jack detection for SDP3430 boards using SoC jack reporting interface. Headset detection on SDP3430 board is achieved through TWL4030 GPIO_2 pin. Signed-off-by: Misael Lopez Cruz Signed-off-by: Mark Brown --- sound/soc/omap/sdp3430.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 4eab4b491de..715c648203a 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -122,7 +123,7 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) /* SDP3430 connected pins */ snd_soc_dapm_enable_pin(codec, "Ext Mic"); snd_soc_dapm_enable_pin(codec, "Ext Spk"); - snd_soc_dapm_enable_pin(codec, "Headset Jack"); + snd_soc_dapm_disable_pin(codec, "Headset Jack"); /* TWL4030 not connected pins */ snd_soc_dapm_nc_pin(codec, "AUXL"); @@ -144,6 +145,27 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) return ret; } +/* Headset jack */ +static struct snd_soc_jack hs_jack; + +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin hs_jack_pins[] = { + { + .pin = "Headset Jack", + .mask = SND_JACK_HEADSET, + }, +}; + +/* Headset jack detection gpios */ +static struct snd_soc_jack_gpio hs_jack_gpios[] = { + { + .gpio = (OMAP_MAX_GPIO_LINES + 2), + .name = "hsdet-gpio", + .report = SND_JACK_HEADSET, + .debounce_time = 200, + }, +}; + /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link sdp3430_dai = { .name = "TWL4030", @@ -194,7 +216,21 @@ static int __init sdp3430_soc_init(void) if (ret) goto err1; - return 0; + /* Headset jack detection */ + ret = snd_soc_jack_new(&snd_soc_sdp3430, "SDP3430 headset jack", + SND_JACK_HEADSET, &hs_jack); + if (ret) + return ret; + + ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), + hs_jack_pins); + if (ret) + return ret; + + ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), + hs_jack_gpios); + + return ret; err1: printk(KERN_ERR "Unable to add platform device\n"); @@ -206,6 +242,9 @@ module_init(sdp3430_soc_init); static void __exit sdp3430_soc_exit(void) { + snd_soc_jack_free_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), + hs_jack_gpios); + platform_device_unregister(sdp3430_snd_device); } module_exit(sdp3430_soc_exit); -- cgit v1.2.3 From 3465d93a128acce836249e3de40932d2ed25cac6 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 6 Mar 2009 15:53:28 +0800 Subject: ASoC: Blackfin: move gpio_err behind the define that is only user of it Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-ac97.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/blackfin/bf5xx-ac97.c b/sound/soc/blackfin/bf5xx-ac97.c index 5885702c78f..8a935f2d176 100644 --- a/sound/soc/blackfin/bf5xx-ac97.c +++ b/sound/soc/blackfin/bf5xx-ac97.c @@ -357,8 +357,8 @@ sport_config_err: sport_err: #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); -#endif gpio_err: +#endif peripheral_free_list(sport_req[sport_num]); peripheral_err: free_page((unsigned long)cmd_count); -- cgit v1.2.3 From 67a9c573b5bf39bc6b40c322c58640687c1b79fe Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 6 Mar 2009 15:53:30 +0800 Subject: ASoC: Blackfin: fix typo in MUTE definition Reported-by: Rob Maris Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu Signed-off-by: Mark Brown --- sound/soc/codecs/ad73311.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/ad73311.h b/sound/soc/codecs/ad73311.h index 507ce0c30ed..569573d2d4d 100644 --- a/sound/soc/codecs/ad73311.h +++ b/sound/soc/codecs/ad73311.h @@ -70,7 +70,7 @@ #define REGD_IGS(x) (x & 0x7) #define REGD_RMOD (1 << 3) #define REGD_OGS(x) ((x & 0x7) << 4) -#define REGD_MUTE (x << 7) +#define REGD_MUTE (1 << 7) /* Control register E */ #define CTRL_REG_E (4 << 8) -- cgit v1.2.3 From 26bd7b496cabc232fcff9ae0249828420c52b5af Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 6 Mar 2009 11:32:17 +0000 Subject: ASoC: Staticise workqueue function for GPIO jack detection Signed-off-by: Mark Brown --- sound/soc/soc-jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index bdf2484c222..28346fb2e70 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -143,7 +143,7 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins); #ifdef CONFIG_GPIOLIB /* gpio detect */ -void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) +static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) { struct snd_soc_jack *jack = gpio->jack; int enable; -- cgit v1.2.3 From ee7d476714464206317d4420d67e3bfa0308448d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 6 Mar 2009 18:04:34 +0000 Subject: ASoC: Re-remove hand-rolled pr_debug() macros The recent set of S3C64xx patches re-added a lot of uses of DBG() that had previously been removed - revert this so the standard pr_debug() macro is used. Signed-off-by: Mark Brown --- sound/soc/s3c24xx/neo1973_wm8753.c | 44 ++++++++++++++-------------------- sound/soc/s3c24xx/s3c-i2s-v2.c | 49 ++++++++++++++++---------------------- sound/soc/s3c24xx/s3c2412-i2s.c | 12 +++------- sound/soc/s3c24xx/s3c24xx-i2s.c | 49 ++++++++++++++++---------------------- sound/soc/s3c24xx/s3c24xx-pcm.c | 45 +++++++++++++++------------------- 5 files changed, 82 insertions(+), 117 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 74573352718..5f6aeec0437 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -40,14 +40,6 @@ #include "s3c24xx-pcm.h" #include "s3c24xx-i2s.h" -/* Debugging stuff */ -#define S3C24XX_SOC_NEO1973_WM8753_DEBUG 0 -#if S3C24XX_SOC_NEO1973_WM8753_DEBUG -#define DBG(x...) printk(KERN_DEBUG "s3c24xx-soc-neo1973-wm8753: " x) -#else -#define DBG(x...) -#endif - /* define the scenarios */ #define NEO_AUDIO_OFF 0 #define NEO_GSM_CALL_AUDIO_HANDSET 1 @@ -72,7 +64,7 @@ static int neo1973_hifi_hw_params(struct snd_pcm_substream *substream, int ret = 0; unsigned long iis_clkrate; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iis_clkrate = s3c24xx_i2s_get_clockrate(); @@ -158,7 +150,7 @@ static int neo1973_hifi_hw_free(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); /* disable the PLL */ return snd_soc_dai_set_pll(codec_dai, WM8753_PLL1, 0, 0); @@ -181,7 +173,7 @@ static int neo1973_voice_hw_params(struct snd_pcm_substream *substream, int ret = 0; unsigned long iis_clkrate; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iis_clkrate = s3c24xx_i2s_get_clockrate(); @@ -224,7 +216,7 @@ static int neo1973_voice_hw_free(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); /* disable the PLL */ return snd_soc_dai_set_pll(codec_dai, WM8753_PLL2, 0, 0); @@ -246,7 +238,7 @@ static int neo1973_get_scenario(struct snd_kcontrol *kcontrol, static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); switch (neo1973_scenario) { case NEO_AUDIO_OFF: @@ -330,7 +322,7 @@ static int neo1973_set_scenario(struct snd_kcontrol *kcontrol, { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (neo1973_scenario == ucontrol->value.integer.value[0]) return 0; @@ -344,7 +336,7 @@ static u8 lm4857_regs[4] = {0x00, 0x40, 0x80, 0xC0}; static void lm4857_write_regs(void) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (i2c_master_send(i2c, lm4857_regs, 4) != 4) printk(KERN_ERR "lm4857: i2c write failed\n"); @@ -357,7 +349,7 @@ static int lm4857_get_reg(struct snd_kcontrol *kcontrol, int shift = (kcontrol->private_value >> 8) & 0x0F; int mask = (kcontrol->private_value >> 16) & 0xFF; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); ucontrol->value.integer.value[0] = (lm4857_regs[reg] >> shift) & mask; return 0; @@ -385,7 +377,7 @@ static int lm4857_get_mode(struct snd_kcontrol *kcontrol, { u8 value = lm4857_regs[LM4857_CTRL] & 0x0F; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (value) value -= 5; @@ -399,7 +391,7 @@ static int lm4857_set_mode(struct snd_kcontrol *kcontrol, { u8 value = ucontrol->value.integer.value[0]; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (value) value += 5; @@ -508,7 +500,7 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec) { int i, err; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); /* set up NC codec pins */ snd_soc_dapm_nc_pin(codec, "LOUT2"); @@ -593,7 +585,7 @@ static struct snd_soc_device neo1973_snd_devdata = { static int lm4857_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); i2c = client; @@ -603,7 +595,7 @@ static int lm4857_i2c_probe(struct i2c_client *client, static int lm4857_i2c_remove(struct i2c_client *client) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); i2c = NULL; @@ -614,7 +606,7 @@ static u8 lm4857_state; static int lm4857_suspend(struct i2c_client *dev, pm_message_t state) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); dev_dbg(&dev->dev, "lm4857_suspend\n"); lm4857_state = lm4857_regs[LM4857_CTRL] & 0xf; @@ -627,7 +619,7 @@ static int lm4857_suspend(struct i2c_client *dev, pm_message_t state) static int lm4857_resume(struct i2c_client *dev) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (lm4857_state) { lm4857_regs[LM4857_CTRL] |= (lm4857_state & 0x0f); @@ -638,7 +630,7 @@ static int lm4857_resume(struct i2c_client *dev) static void lm4857_shutdown(struct i2c_client *dev) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); dev_dbg(&dev->dev, "lm4857_shutdown\n"); lm4857_regs[LM4857_CTRL] &= 0xf0; @@ -669,7 +661,7 @@ static int __init neo1973_init(void) { int ret; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (!machine_is_neo1973_gta01()) { printk(KERN_INFO @@ -700,7 +692,7 @@ static int __init neo1973_init(void) static void __exit neo1973_exit(void) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); i2c_del_driver(&lm4857_i2c_driver); platform_device_unregister(neo1973_snd_device); diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c index 43262e1e8f9..b7b8e47ae36 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.c +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c @@ -38,13 +38,6 @@ #include "s3c-i2s-v2.h" #define S3C2412_I2S_DEBUG_CON 0 -#define S3C2412_I2S_DEBUG 0 - -#if S3C2412_I2S_DEBUG -#define DBG(x...) printk(KERN_INFO x) -#else -#define DBG(x...) do { } while (0) -#endif static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai) { @@ -87,13 +80,13 @@ void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) void __iomem *regs = i2s->regs; u32 fic, con, mod; - DBG("%s(%d)\n", __func__, on); + pr_debug("%s(%d)\n", __func__, on); fic = readl(regs + S3C2412_IISFIC); con = readl(regs + S3C2412_IISCON); mod = readl(regs + S3C2412_IISMOD); - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); + pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); if (on) { con |= S3C2412_IISCON_TXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; @@ -148,7 +141,7 @@ void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on) fic = readl(regs + S3C2412_IISFIC); dbg_showcon(__func__, con); - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); + pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); } EXPORT_SYMBOL_GPL(s3c2412_snd_txctrl); @@ -157,13 +150,13 @@ void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) void __iomem *regs = i2s->regs; u32 fic, con, mod; - DBG("%s(%d)\n", __func__, on); + pr_debug("%s(%d)\n", __func__, on); fic = readl(regs + S3C2412_IISFIC); con = readl(regs + S3C2412_IISCON); mod = readl(regs + S3C2412_IISMOD); - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); + pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); if (on) { con |= S3C2412_IISCON_RXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE; @@ -214,7 +207,7 @@ void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on) } fic = readl(regs + S3C2412_IISFIC); - DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); + pr_debug("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic); } EXPORT_SYMBOL_GPL(s3c2412_snd_rxctrl); @@ -227,7 +220,7 @@ static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s) u32 iiscon; unsigned long timeout = jiffies + msecs_to_jiffies(5); - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); while (1) { iiscon = readl(i2s->regs + S3C2412_IISCON); @@ -252,10 +245,10 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, struct s3c_i2sv2_info *i2s = to_info(cpu_dai); u32 iismod; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iismod = readl(i2s->regs + S3C2412_IISMOD); - DBG("hw_params r: IISMOD: %x \n", iismod); + pr_debug("hw_params r: IISMOD: %x \n", iismod); #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) #define IISMOD_MASTER_MASK S3C2412_IISMOD_MASTER_MASK @@ -288,7 +281,7 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, iismod |= IISMOD_MASTER; break; default: - DBG("unknwon master/slave format\n"); + pr_debug("unknwon master/slave format\n"); return -EINVAL; } @@ -305,12 +298,12 @@ static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai, iismod |= S3C2412_IISMOD_SDF_IIS; break; default: - DBG("Unknown data format\n"); + pr_debug("Unknown data format\n"); return -EINVAL; } writel(iismod, i2s->regs + S3C2412_IISMOD); - DBG("hw_params w: IISMOD: %x \n", iismod); + pr_debug("hw_params w: IISMOD: %x \n", iismod); return 0; } @@ -323,7 +316,7 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai); u32 iismod; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) dai->cpu_dai->dma_data = i2s->dma_playback; @@ -332,7 +325,7 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, /* Working copies of register */ iismod = readl(i2s->regs + S3C2412_IISMOD); - DBG("%s: r: IISMOD: %x\n", __func__, iismod); + pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: @@ -344,7 +337,7 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, } writel(iismod, i2s->regs + S3C2412_IISMOD); - DBG("%s: w: IISMOD: %x\n", __func__, iismod); + pr_debug("%s: w: IISMOD: %x\n", __func__, iismod); return 0; } @@ -357,7 +350,7 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, unsigned long irqs; int ret = 0; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -417,7 +410,7 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, struct s3c_i2sv2_info *i2s = to_info(cpu_dai); u32 reg; - DBG("%s(%p, %d, %d)\n", __func__, cpu_dai, div_id, div); + pr_debug("%s(%p, %d, %d)\n", __func__, cpu_dai, div_id, div); switch (div_id) { case S3C_I2SV2_DIV_BCLK: @@ -425,7 +418,7 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, reg &= ~S3C2412_IISMOD_BCLK_MASK; writel(reg | div, i2s->regs + S3C2412_IISMOD); - DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); + pr_debug("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); break; case S3C_I2SV2_DIV_RCLK: @@ -457,7 +450,7 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, reg = readl(i2s->regs + S3C2412_IISMOD); reg &= ~S3C2412_IISMOD_RCLK_MASK; writel(reg | div, i2s->regs + S3C2412_IISMOD); - DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); + pr_debug("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD)); break; case S3C_I2SV2_DIV_PRESCALER: @@ -467,7 +460,7 @@ static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, } else { writel(0x0, i2s->regs + S3C2412_IISPSR); } - DBG("%s: PSR=%08x\n", __func__, readl(i2s->regs + S3C2412_IISPSR)); + pr_debug("%s: PSR=%08x\n", __func__, readl(i2s->regs + S3C2412_IISPSR)); break; default: @@ -560,7 +553,7 @@ int s3c_i2sv2_probe(struct platform_device *pdev, i2s->iis_pclk = clk_get(dev, "iis"); if (i2s->iis_pclk == NULL) { - DBG("failed to get iis_clock\n"); + pr_debug("failed to get iis_clock\n"); iounmap(i2s->regs); return -ENOENT; } diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index 5099d939667..1ceae690d01 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c @@ -42,12 +42,6 @@ #define S3C2412_I2S_DEBUG 0 -#if S3C2412_I2S_DEBUG -#define DBG(x...) printk(KERN_INFO x) -#else -#define DBG(x...) do { } while (0) -#endif - static struct s3c2410_dma_client s3c2412_dma_client_out = { .name = "I2S PCM Stereo out" }; @@ -80,7 +74,7 @@ static int s3c2412_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, { u32 iismod = readl(s3c2412_i2s.regs + S3C2412_IISMOD); - DBG("%s(%p, %d, %u, %d)\n", __func__, cpu_dai, clk_id, + pr_debug("%s(%p, %d, %u, %d)\n", __func__, cpu_dai, clk_id, freq, dir); switch (clk_id) { @@ -115,7 +109,7 @@ static int s3c2412_i2s_probe(struct platform_device *pdev, { int ret; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); ret = s3c_i2sv2_probe(pdev, dai, &s3c2412_i2s, S3C2410_PA_IIS); if (ret) @@ -126,7 +120,7 @@ static int s3c2412_i2s_probe(struct platform_device *pdev, s3c2412_i2s.iis_cclk = clk_get(&pdev->dev, "i2sclk"); if (s3c2412_i2s.iis_cclk == NULL) { - DBG("failed to get i2sclk clock\n"); + pr_debug("failed to get i2sclk clock\n"); iounmap(s3c2412_i2s.regs); return -ENODEV; } diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index c0c6ec1536b..2fbead33b7c 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -39,13 +39,6 @@ #include "s3c24xx-pcm.h" #include "s3c24xx-i2s.h" -#define S3C24XX_I2S_DEBUG 0 -#if S3C24XX_I2S_DEBUG -#define DBG(x...) printk(KERN_DEBUG "s3c24xx-i2s: " x) -#else -#define DBG(x...) -#endif - static struct s3c2410_dma_client s3c24xx_dma_client_out = { .name = "I2S PCM Stereo out" }; @@ -84,13 +77,13 @@ static void s3c24xx_snd_txctrl(int on) u32 iiscon; u32 iismod; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); if (on) { iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE; @@ -120,7 +113,7 @@ static void s3c24xx_snd_txctrl(int on) writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); } - DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); } static void s3c24xx_snd_rxctrl(int on) @@ -129,13 +122,13 @@ static void s3c24xx_snd_rxctrl(int on) u32 iiscon; u32 iismod; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); if (on) { iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE; @@ -165,7 +158,7 @@ static void s3c24xx_snd_rxctrl(int on) writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); } - DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); } /* @@ -177,7 +170,7 @@ static int s3c24xx_snd_lrsync(void) u32 iiscon; int timeout = 50; /* 5ms */ - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); while (1) { iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); @@ -197,7 +190,7 @@ static int s3c24xx_snd_lrsync(void) */ static inline int s3c24xx_snd_is_clkmaster(void) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1; } @@ -210,10 +203,10 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, { u32 iismod; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("hw_params r: IISMOD: %lx \n", iismod); + pr_debug("hw_params r: IISMOD: %lx \n", iismod); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -238,7 +231,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, } writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("hw_params w: IISMOD: %lx \n", iismod); + pr_debug("hw_params w: IISMOD: %lx \n", iismod); return 0; } @@ -249,7 +242,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; u32 iismod; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out; @@ -258,7 +251,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, /* Working copies of register */ iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("hw_params r: IISMOD: %lx\n", iismod); + pr_debug("hw_params r: IISMOD: %lx\n", iismod); switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: @@ -276,7 +269,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, } writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("hw_params w: IISMOD: %lx\n", iismod); + pr_debug("hw_params w: IISMOD: %lx\n", iismod); return 0; } @@ -285,7 +278,7 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, { int ret = 0; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -327,7 +320,7 @@ static int s3c24xx_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, { u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); iismod &= ~S3C2440_IISMOD_MPLL; @@ -353,7 +346,7 @@ static int s3c24xx_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai, { u32 reg; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); switch (div_id) { case S3C24XX_DIV_BCLK: @@ -389,7 +382,7 @@ EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate); static int s3c24xx_i2s_probe(struct platform_device *pdev, struct snd_soc_dai *dai) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); if (s3c24xx_i2s.regs == NULL) @@ -397,7 +390,7 @@ static int s3c24xx_i2s_probe(struct platform_device *pdev, s3c24xx_i2s.iis_clk = clk_get(&pdev->dev, "iis"); if (s3c24xx_i2s.iis_clk == NULL) { - DBG("failed to get iis_clock\n"); + pr_debug("failed to get iis_clock\n"); iounmap(s3c24xx_i2s.regs); return -ENODEV; } @@ -421,7 +414,7 @@ static int s3c24xx_i2s_probe(struct platform_device *pdev, #ifdef CONFIG_PM static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); s3c24xx_i2s.iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); s3c24xx_i2s.iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); @@ -435,7 +428,7 @@ static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) { - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); clk_enable(s3c24xx_i2s.iis_clk); writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c index 5c96c1ed629..269f5c8e7ca 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.c +++ b/sound/soc/s3c24xx/s3c24xx-pcm.c @@ -33,13 +33,6 @@ #include "s3c24xx-pcm.h" -#define S3C24XX_PCM_DEBUG 0 -#if S3C24XX_PCM_DEBUG -#define DBG(x...) printk(KERN_DEBUG "s3c24xx-pcm: " x) -#else -#define DBG(x...) -#endif - static const struct snd_pcm_hardware s3c24xx_pcm_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -84,16 +77,16 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream) dma_addr_t pos = prtd->dma_pos; int ret; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); while (prtd->dma_loaded < prtd->dma_limit) { unsigned long len = prtd->dma_period; - DBG("dma_loaded: %d\n", prtd->dma_loaded); + pr_debug("dma_loaded: %d\n", prtd->dma_loaded); if ((pos + len) > prtd->dma_end) { len = prtd->dma_end - pos; - DBG(KERN_DEBUG "%s: corrected dma len %ld\n", + pr_debug(KERN_DEBUG "%s: corrected dma len %ld\n", __func__, len); } @@ -119,7 +112,7 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel, struct snd_pcm_substream *substream = dev_id; struct s3c24xx_runtime_data *prtd; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR) return; @@ -148,7 +141,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, unsigned long totbytes = params_buffer_bytes(params); int ret = 0; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); /* return if this is a bufferless transfer e.g. * codec <--> BT codec or GSM modem -- lg FIXME */ @@ -161,14 +154,14 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, /* prepare DMA */ prtd->params = dma; - DBG("params %p, client %p, channel %d\n", prtd->params, + pr_debug("params %p, client %p, channel %d\n", prtd->params, prtd->params->client, prtd->params->channel); ret = s3c2410_dma_request(prtd->params->channel, prtd->params->client, NULL); if (ret < 0) { - DBG(KERN_ERR "failed to get dma channel\n"); + pr_debug(KERN_ERR "failed to get dma channel\n"); return ret; } } @@ -196,7 +189,7 @@ static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream) { struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); /* TODO - do we need to ensure DMA flushed */ snd_pcm_set_runtime_buffer(substream, NULL); @@ -214,7 +207,7 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream) struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; int ret = 0; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); /* return if this is a bufferless transfer e.g. * codec <--> BT codec or GSM modem -- lg FIXME */ @@ -259,7 +252,7 @@ static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct s3c24xx_runtime_data *prtd = substream->runtime->private_data; int ret = 0; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); spin_lock(&prtd->lock); @@ -297,7 +290,7 @@ s3c24xx_pcm_pointer(struct snd_pcm_substream *substream) unsigned long res; dma_addr_t src, dst; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); spin_lock(&prtd->lock); s3c2410_dma_getposition(prtd->params->channel, &src, &dst); @@ -309,7 +302,7 @@ s3c24xx_pcm_pointer(struct snd_pcm_substream *substream) spin_unlock(&prtd->lock); - DBG("Pointer %x %x\n", src, dst); + pr_debug("Pointer %x %x\n", src, dst); /* we seem to be getting the odd error from the pcm library due * to out-of-bounds pointers. this is maybe due to the dma engine @@ -330,7 +323,7 @@ static int s3c24xx_pcm_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct s3c24xx_runtime_data *prtd; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware); @@ -349,10 +342,10 @@ static int s3c24xx_pcm_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct s3c24xx_runtime_data *prtd = runtime->private_data; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (!prtd) - DBG("s3c24xx_pcm_close called with prtd == NULL\n"); + pr_debug("s3c24xx_pcm_close called with prtd == NULL\n"); kfree(prtd); @@ -364,7 +357,7 @@ static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream, { struct snd_pcm_runtime *runtime = substream->runtime; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); return dma_mmap_writecombine(substream->pcm->card->dev, vma, runtime->dma_area, @@ -390,7 +383,7 @@ static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) struct snd_dma_buffer *buf = &substream->dma_buffer; size_t size = s3c24xx_pcm_hardware.buffer_bytes_max; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); buf->dev.type = SNDRV_DMA_TYPE_DEV; buf->dev.dev = pcm->card->dev; @@ -409,7 +402,7 @@ static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm) struct snd_dma_buffer *buf; int stream; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); for (stream = 0; stream < 2; stream++) { substream = pcm->streams[stream].substream; @@ -433,7 +426,7 @@ static int s3c24xx_pcm_new(struct snd_card *card, { int ret = 0; - DBG("Entered %s\n", __func__); + pr_debug("Entered %s\n", __func__); if (!card->dev->dma_mask) card->dev->dma_mask = &s3c24xx_pcm_dmamask; -- cgit v1.2.3 From b52a5195efd6173c06107ca5beb44389130596dc Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 6 Mar 2009 18:13:43 +0000 Subject: ASoC: Fix logging severity for some S3C error messages Upgrade the severity of some failure messages from debug level so they're displayed by default. Signed-off-by: Mark Brown --- sound/soc/s3c24xx/s3c-i2s-v2.c | 2 +- sound/soc/s3c24xx/s3c24xx-i2s.c | 2 +- sound/soc/s3c24xx/s3c24xx-pcm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c index b7b8e47ae36..295a4c91026 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.c +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c @@ -553,7 +553,7 @@ int s3c_i2sv2_probe(struct platform_device *pdev, i2s->iis_pclk = clk_get(dev, "iis"); if (i2s->iis_pclk == NULL) { - pr_debug("failed to get iis_clock\n"); + dev_err(dev, "failed to get iis_clock\n"); iounmap(i2s->regs); return -ENOENT; } diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 2fbead33b7c..580cfed71cc 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -390,7 +390,7 @@ static int s3c24xx_i2s_probe(struct platform_device *pdev, s3c24xx_i2s.iis_clk = clk_get(&pdev->dev, "iis"); if (s3c24xx_i2s.iis_clk == NULL) { - pr_debug("failed to get iis_clock\n"); + pr_err("failed to get iis_clock\n"); iounmap(s3c24xx_i2s.regs); return -ENODEV; } diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c index 269f5c8e7ca..a9d68fa2b34 100644 --- a/sound/soc/s3c24xx/s3c24xx-pcm.c +++ b/sound/soc/s3c24xx/s3c24xx-pcm.c @@ -161,7 +161,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream, prtd->params->client, NULL); if (ret < 0) { - pr_debug(KERN_ERR "failed to get dma channel\n"); + printk(KERN_ERR "failed to get dma channel\n"); return ret; } } -- cgit v1.2.3 From 96deff6baf55da68b4b9b4dfe8ef572c6f1835fd Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Fri, 6 Mar 2009 15:56:53 -0500 Subject: ASoC: Davinci: Fix incorrect machine type for SFFSDR board Signed-off-by: Hugo Villeneuve Signed-off-by: Mark Brown --- sound/soc/davinci/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index b502741692d..bd7392c9657 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig @@ -20,7 +20,7 @@ config SND_DAVINCI_SOC_EVM config SND_DAVINCI_SOC_SFFSDR tristate "SoC Audio support for SFFSDR" - depends on SND_DAVINCI_SOC && MACH_DAVINCI_SFFSDR + depends on SND_DAVINCI_SOC && MACH_SFFSDR select SND_DAVINCI_SOC_I2S select SND_SOC_PCM3008 select SFFSDR_FPGA -- cgit v1.2.3 From 3a638ff272744247aad4a75b1fac174ac5746114 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Fri, 6 Mar 2009 18:39:34 -0600 Subject: ASoC: Improve pause/unpause performance in Freescale 8610 drivers Add support for true pause and unpause. Without this, mplayer will drop some audio (less than one second, but still noticeable) when pausing playback. Remove support for PM suspend and resume from the trigger function, since the driver doesn't support PM anyway. Optimize the delay after starting capture. Instead of delaying 1ms, the driver now polls the hardware. The new delay is shorter by over 90% yet still effective. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 3 ++- sound/soc/fsl/fsl_ssi.c | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 58a3fa49750..b3eb8570cd7 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -142,7 +142,8 @@ static const struct snd_pcm_hardware fsl_dma_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_JOINT_DUPLEX, + SNDRV_PCM_INFO_JOINT_DUPLEX | + SNDRV_PCM_INFO_PAUSE, .formats = FSLDMA_PCM_FORMATS, .rates = FSLDMA_PCM_RATES, .rate_min = 5512, diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 8cb6bcf2c00..b7733e6be19 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -464,28 +464,33 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, switch (cmd) { case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: + clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); setbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE); } else { - clrbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN); + long timeout = jiffies + 10; + setbits32(&ssi->scr, CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE); - /* - * I think we need this delay to allow time for the SSI - * to put data into its FIFO. Without it, ALSA starts - * to complain about overruns. + /* Wait until the SSI has filled its FIFO. Without this + * delay, ALSA complains about overruns. When the FIFO + * is full, the DMA controller initiates its first + * transfer. Until then, however, the DMA's DAR + * register is zero, which translates to an + * out-of-bounds pointer. This makes ALSA think an + * overrun has occurred. */ - mdelay(1); + while (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0) && + (jiffies < timeout)); + if (!(in_be32(&ssi->sisr) & CCSR_SSI_SISR_RFF0)) + return -EIO; } break; case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) clrbits32(&ssi->scr, CCSR_SSI_SCR_TE); -- cgit v1.2.3 From b191f63c4fe9fbcfe583180228080d02b8dcdebc Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Sun, 8 Mar 2009 17:51:52 +0100 Subject: ASoC: bring cs4270 feature/limitations list in sync Removes numbers from the list of features/limitations and makes it reflect recent changes to the code. Signed-off-by: Daniel Mack Acked-by: Timur Tabi Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index f86f33cc179..0e0c23ee6af 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -12,14 +12,13 @@ * * Current features/limitations: * - * 1) Software mode is supported. Stand-alone mode is not supported. - * 2) Only I2C is supported, not SPI - * 3) Only Master mode is supported, not Slave. - * 4) The machine driver's 'startup' function must call - * cs4270_set_dai_sysclk() with the value of MCLK. - * 5) Only I2S and left-justified modes are supported - * 6) Power management is not supported - * 7) The only supported control is volume and hardware mute (if enabled) + * - Software mode is supported. Stand-alone mode is not supported. + * - Only I2C is supported, not SPI + * - Support for master and slave mode + * - The machine driver's 'startup' function must call + * cs4270_set_dai_sysclk() with the value of MCLK. + * - Only I2S and left-justified modes are supported + * - Power management is not supported */ #include -- cgit v1.2.3 From 055a49b0c92c6282e7db22e9e6ebcae6cb74ebb4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 8 Mar 2009 18:57:34 +0000 Subject: ASoC: Remove unneeded forward reference to WM8753 SPI implementation Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 7f353e935d7..1d5eca89de6 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -51,11 +51,6 @@ #include "wm8753.h" -#ifdef CONFIG_SPI_MASTER -static struct spi_driver wm8753_spi_driver; -static int wm8753_spi_write(struct spi_device *spi, const char *data, int len); -#endif - static int caps_charge = 2000; module_param(caps_charge, int, 0); MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); -- cgit v1.2.3 From f271fa28fbaf947d9c79f188dd149176da727dd5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Mar 2009 00:52:17 +0100 Subject: ASoC: Fix Kconfig dependency of CONFIG_SND_S3C24XX_SOC_JIVE_WM8750 Remove a non-existing Kconfig CONFIG_SND_SOC_WM8750_SPI. Signed-off-by: Takashi Iwai --- sound/soc/s3c24xx/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index 78d01ff487c..2f3a21eee05 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -42,7 +42,6 @@ config SND_S3C24XX_SOC_JIVE_WM8750 tristate "SoC I2S Audio support for Jive" depends on SND_S3C24XX_SOC && MACH_JIVE select SND_SOC_WM8750 - select SND_SOC_WM8750_SPI select SND_S3C2412_SOC_I2S help Sat Y if you want to add support for SoC audio on the Jive. -- cgit v1.2.3 From a381934e5f9c0c3c292d780d61f5be9c22b2ef54 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 9 Mar 2009 02:13:17 +0100 Subject: ASoC: Add a driver for AK4104 S/PDIF transmitter This adds a driver for the SPI connected AK4104 S/PDIF transmitter device. Its features are fairly simple, but as there is need to set up certain bits in the IEC958 information, this better goes into a real driver. Signed-off-by: Daniel Mack Cc: Mark Brown Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ak4104.c | 363 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ak4104.h | 7 + 4 files changed, 376 insertions(+) create mode 100644 sound/soc/codecs/ak4104.c create mode 100644 sound/soc/codecs/ak4104.h (limited to 'sound/soc') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 628a591c728..a1af311e7f0 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -14,6 +14,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS select SND_SOC_AD1980 if SND_SOC_AC97_BUS select SND_SOC_AD73311 if I2C + select SND_SOC_AK4104 if SPI_MASTER select SND_SOC_AK4535 if I2C select SND_SOC_CS4270 if I2C select SND_SOC_PCM3008 @@ -60,6 +61,9 @@ config SND_SOC_AD1980 config SND_SOC_AD73311 tristate +config SND_SOC_AK4104 + tristate + config SND_SOC_AK4535 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 3664cdc300b..4717c3c9904 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -1,6 +1,7 @@ snd-soc-ac97-objs := ac97.o snd-soc-ad1980-objs := ad1980.o snd-soc-ad73311-objs := ad73311.o +snd-soc-ak4104-objs := ak4104.o snd-soc-ak4535-objs := ak4535.o snd-soc-cs4270-objs := cs4270.o snd-soc-l3-objs := l3.o @@ -30,6 +31,7 @@ snd-soc-wm9713-objs := wm9713.o obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o +obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c new file mode 100644 index 00000000000..338381f4fe1 --- /dev/null +++ b/sound/soc/codecs/ak4104.c @@ -0,0 +1,363 @@ +/* + * AK4104 ALSA SoC (ASoC) driver + * + * Copyright (c) 2009 Daniel Mack + * + * 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 +#include +#include +#include +#include +#include + +#include "ak4104.h" + +/* AK4104 registers addresses */ +#define AK4104_REG_CONTROL1 0x00 +#define AK4104_REG_RESERVED 0x01 +#define AK4104_REG_CONTROL2 0x02 +#define AK4104_REG_TX 0x03 +#define AK4104_REG_CHN_STATUS(x) ((x) + 0x04) +#define AK4104_NUM_REGS 10 + +#define AK4104_REG_MASK 0x1f +#define AK4104_READ 0xc0 +#define AK4104_WRITE 0xe0 +#define AK4104_RESERVED_VAL 0x5b + +/* Bit masks for AK4104 registers */ +#define AK4104_CONTROL1_RSTN (1 << 0) +#define AK4104_CONTROL1_PW (1 << 1) +#define AK4104_CONTROL1_DIF0 (1 << 2) +#define AK4104_CONTROL1_DIF1 (1 << 3) + +#define AK4104_CONTROL2_SEL0 (1 << 0) +#define AK4104_CONTROL2_SEL1 (1 << 1) +#define AK4104_CONTROL2_MODE (1 << 2) + +#define AK4104_TX_TXE (1 << 0) +#define AK4104_TX_V (1 << 1) + +#define DRV_NAME "ak4104" + +struct ak4104_private { + struct snd_soc_codec codec; + u8 reg_cache[AK4104_NUM_REGS]; +}; + +static int ak4104_fill_cache(struct snd_soc_codec *codec) +{ + int i; + u8 *reg_cache = codec->reg_cache; + struct spi_device *spi = codec->control_data; + + for (i = 0; i < codec->reg_cache_size; i++) { + int ret = spi_w8r8(spi, i | AK4104_READ); + if (ret < 0) { + dev_err(&spi->dev, "SPI write failure\n"); + return ret; + } + + reg_cache[i] = ret; + } + + return 0; +} + +static unsigned int ak4104_read_reg_cache(struct snd_soc_codec *codec, + unsigned int reg) +{ + u8 *reg_cache = codec->reg_cache; + + if (reg >= codec->reg_cache_size) + return -EINVAL; + + return reg_cache[reg]; +} + +static int ak4104_spi_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + u8 *cache = codec->reg_cache; + struct spi_device *spi = codec->control_data; + + if (reg >= codec->reg_cache_size) + return -EINVAL; + + reg &= AK4104_REG_MASK; + reg |= AK4104_WRITE; + + /* only write to the hardware if value has changed */ + if (cache[reg] != value) { + u8 tmp[2] = { reg, value }; + if (spi_write(spi, tmp, sizeof(tmp))) { + dev_err(&spi->dev, "SPI write failed\n"); + return -EIO; + } + + cache[reg] = value; + } + + return 0; +} + +static int ak4104_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int format) +{ + struct snd_soc_codec *codec = codec_dai->codec; + int val = 0; + + val = ak4104_read_reg_cache(codec, AK4104_REG_CONTROL1); + if (val < 0) + return val; + + val &= ~(AK4104_CONTROL1_DIF0 | AK4104_CONTROL1_DIF1); + + /* set DAI format */ + switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_RIGHT_J: + break; + case SND_SOC_DAIFMT_LEFT_J: + val |= AK4104_CONTROL1_DIF0; + break; + case SND_SOC_DAIFMT_I2S: + val |= AK4104_CONTROL1_DIF0 | AK4104_CONTROL1_DIF1; + break; + default: + dev_err(codec->dev, "invalid dai format\n"); + return -EINVAL; + } + + /* This device can only be slave */ + if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) + return -EINVAL; + + return ak4104_spi_write(codec, AK4104_REG_CONTROL1, val); +} + +static int ak4104_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->card->codec; + int val = 0; + + /* set the IEC958 bits: consumer mode, no copyright bit */ + val |= IEC958_AES0_CON_NOT_COPYRIGHT; + ak4104_spi_write(codec, AK4104_REG_CHN_STATUS(0), val); + + val = 0; + + switch (params_rate(params)) { + case 44100: + val |= IEC958_AES3_CON_FS_44100; + break; + case 48000: + val |= IEC958_AES3_CON_FS_48000; + break; + case 32000: + val |= IEC958_AES3_CON_FS_32000; + break; + default: + dev_err(codec->dev, "unsupported sampling rate\n"); + return -EINVAL; + } + + return ak4104_spi_write(codec, AK4104_REG_CHN_STATUS(3), val); +} + +struct snd_soc_dai ak4104_dai = { + .name = DRV_NAME, + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_32000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_3LE | + SNDRV_PCM_FMTBIT_S24_LE + }, + .ops = { + .hw_params = ak4104_hw_params, + .set_fmt = ak4104_set_dai_fmt, + } +}; + +static struct snd_soc_codec *ak4104_codec; + +static int ak4104_spi_probe(struct spi_device *spi) +{ + struct snd_soc_codec *codec; + struct ak4104_private *ak4104; + int ret, val; + + spi->bits_per_word = 8; + spi->mode = SPI_MODE_0; + ret = spi_setup(spi); + if (ret < 0) + return ret; + + ak4104 = kzalloc(sizeof(struct ak4104_private), GFP_KERNEL); + if (!ak4104) { + dev_err(&spi->dev, "could not allocate codec\n"); + return -ENOMEM; + } + + codec = &ak4104->codec; + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + codec->dev = &spi->dev; + codec->name = DRV_NAME; + codec->owner = THIS_MODULE; + codec->dai = &ak4104_dai; + codec->num_dai = 1; + codec->private_data = ak4104; + codec->control_data = spi; + codec->reg_cache = ak4104->reg_cache; + codec->reg_cache_size = AK4104_NUM_REGS; + + /* read all regs and fill the cache */ + ret = ak4104_fill_cache(codec); + if (ret < 0) { + dev_err(&spi->dev, "failed to fill register cache\n"); + return ret; + } + + /* read the 'reserved' register - according to the datasheet, it + * should contain 0x5b. Not a good way to verify the presence of + * the device, but there is no hardware ID register. */ + if (ak4104_read_reg_cache(codec, AK4104_REG_RESERVED) != + AK4104_RESERVED_VAL) { + ret = -ENODEV; + goto error_free_codec; + } + + /* set power-up and non-reset bits */ + val = ak4104_read_reg_cache(codec, AK4104_REG_CONTROL1); + val |= AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN; + ret = ak4104_spi_write(codec, AK4104_REG_CONTROL1, val); + if (ret < 0) + goto error_free_codec; + + /* enable transmitter */ + val = ak4104_read_reg_cache(codec, AK4104_REG_TX); + val |= AK4104_TX_TXE; + ret = ak4104_spi_write(codec, AK4104_REG_TX, val); + if (ret < 0) + goto error_free_codec; + + ak4104_codec = codec; + ret = snd_soc_register_dai(&ak4104_dai); + if (ret < 0) { + dev_err(&spi->dev, "failed to register DAI\n"); + goto error_free_codec; + } + + spi_set_drvdata(spi, ak4104); + dev_info(&spi->dev, "SPI device initialized\n"); + return 0; + +error_free_codec: + kfree(ak4104); + ak4104_dai.dev = NULL; + return ret; +} + +static int __devexit ak4104_spi_remove(struct spi_device *spi) +{ + int ret, val; + struct ak4104_private *ak4104 = spi_get_drvdata(spi); + + val = ak4104_read_reg_cache(&ak4104->codec, AK4104_REG_CONTROL1); + if (val < 0) + return val; + + /* clear power-up and non-reset bits */ + val &= ~(AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN); + ret = ak4104_spi_write(&ak4104->codec, AK4104_REG_CONTROL1, val); + if (ret < 0) + return ret; + + ak4104_codec = NULL; + kfree(ak4104); + return 0; +} + +static int ak4104_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = ak4104_codec; + int ret; + + /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ + socdev->card->codec = codec; + + /* Register PCMs */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + dev_err(codec->dev, "failed to create pcms\n"); + return ret; + } + + /* Register the socdev */ + ret = snd_soc_init_card(socdev); + if (ret < 0) { + dev_err(codec->dev, "failed to register card\n"); + snd_soc_free_pcms(socdev); + return ret; + } + + return 0; +} + +static int ak4104_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + snd_soc_free_pcms(socdev); + return 0; +}; + +struct snd_soc_codec_device soc_codec_device_ak4104 = { + .probe = ak4104_probe, + .remove = ak4104_remove +}; +EXPORT_SYMBOL_GPL(soc_codec_device_ak4104); + +static struct spi_driver ak4104_spi_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = ak4104_spi_probe, + .remove = __devexit_p(ak4104_spi_remove), +}; + +static int __init ak4104_init(void) +{ + pr_info("Asahi Kasei AK4104 ALSA SoC Codec Driver\n"); + return spi_register_driver(&ak4104_spi_driver); +} +module_init(ak4104_init); + +static void __exit ak4104_exit(void) +{ + spi_unregister_driver(&ak4104_spi_driver); +} +module_exit(ak4104_exit); + +MODULE_AUTHOR("Daniel Mack "); +MODULE_DESCRIPTION("Asahi Kasei AK4104 ALSA SoC driver"); +MODULE_LICENSE("GPL"); + diff --git a/sound/soc/codecs/ak4104.h b/sound/soc/codecs/ak4104.h new file mode 100644 index 00000000000..eb88fe7e4de --- /dev/null +++ b/sound/soc/codecs/ak4104.h @@ -0,0 +1,7 @@ +#ifndef _AK4104_H +#define _AK4104_H + +extern struct snd_soc_dai ak4104_dai; +extern struct snd_soc_codec_device soc_codec_device_ak4104; + +#endif -- cgit v1.2.3 From 6b849bcff0004aa5dd216b4d3eb56f51c9df8a72 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 9 Mar 2009 18:18:33 +0000 Subject: ASoC: Convert PXA AC97 driver to probe with the platform device This will break any boards that don't register the AC97 controller device due to using ASoC. Signed-off-by: Mark Brown --- sound/soc/pxa/pxa2xx-ac97.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index 812c2b4d3e0..49a2810ca58 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -106,13 +106,13 @@ static int pxa2xx_ac97_resume(struct snd_soc_dai *dai) static int pxa2xx_ac97_probe(struct platform_device *pdev, struct snd_soc_dai *dai) { - return pxa2xx_ac97_hw_probe(pdev); + return pxa2xx_ac97_hw_probe(to_platform_device(dai->dev)); } static void pxa2xx_ac97_remove(struct platform_device *pdev, struct snd_soc_dai *dai) { - pxa2xx_ac97_hw_remove(pdev); + pxa2xx_ac97_hw_remove(to_platform_device(dai->dev)); } static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, @@ -229,15 +229,45 @@ struct snd_soc_dai pxa_ac97_dai[] = { EXPORT_SYMBOL_GPL(pxa_ac97_dai); EXPORT_SYMBOL_GPL(soc_ac97_ops); -static int __init pxa_ac97_init(void) +static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev) { + int i; + + for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) + pxa_ac97_dai[i].dev = &pdev->dev; + + /* Punt most of the init to the SoC probe; we may need the machine + * driver to do interesting things with the clocking to get us up + * and running. + */ return snd_soc_register_dais(pxa_ac97_dai, ARRAY_SIZE(pxa_ac97_dai)); } + +static int __devexit pxa2xx_ac97_dev_remove(struct platform_device *pdev) +{ + snd_soc_unregister_dais(pxa_ac97_dai, ARRAY_SIZE(pxa_ac97_dai)); + + return 0; +} + +static struct platform_driver pxa2xx_ac97_driver = { + .probe = pxa2xx_ac97_dev_probe, + .remove = __devexit_p(pxa2xx_ac97_dev_remove), + .driver = { + .name = "pxa2xx-ac97", + .owner = THIS_MODULE, + }, +}; + +static int __init pxa_ac97_init(void) +{ + return platform_driver_register(&pxa2xx_ac97_driver); +} module_init(pxa_ac97_init); static void __exit pxa_ac97_exit(void) { - snd_soc_unregister_dais(pxa_ac97_dai, ARRAY_SIZE(pxa_ac97_dai)); + platform_driver_unregister(&pxa2xx_ac97_driver); } module_exit(pxa_ac97_exit); -- cgit v1.2.3 From 14cbba89ae967d2e9106a80b270b078d7699109a Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Mon, 9 Mar 2009 23:32:07 -0400 Subject: ALSA: ASoC: Davinci: Replaced DAI format RIGHT_J by DSP_B for SFFSDR Signed-off-by: Hugo Villeneuve Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-sffsdr.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c index 0bf81abba8c..a1ae3736a5d 100644 --- a/sound/soc/davinci/davinci-sffsdr.c +++ b/sound/soc/davinci/davinci-sffsdr.c @@ -36,6 +36,14 @@ #include "davinci-pcm.h" #include "davinci-i2s.h" +/* + * CLKX and CLKR are the inputs for the Sample Rate Generator. + * FSX and FSR are outputs, driven by the sample Rate Generator. + */ +#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ + SND_SOC_DAIFMT_CBM_CFS | \ + SND_SOC_DAIFMT_IB_NF) + static int sffsdr_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -56,13 +64,8 @@ static int sffsdr_hw_params(struct snd_pcm_substream *substream, } #endif - /* Set cpu DAI configuration: - * CLKX and CLKR are the inputs for the Sample Rate Generator. - * FSX and FSR are outputs, driven by the sample Rate Generator. */ - ret = snd_soc_dai_set_fmt(cpu_dai, - SND_SOC_DAIFMT_RIGHT_J | - SND_SOC_DAIFMT_CBM_CFS | - SND_SOC_DAIFMT_IB_NF); + /* set cpu DAI configuration */ + ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT); if (ret < 0) return ret; -- cgit v1.2.3 From 090cec81ae9b4ff0c1d301b722f0e6c5fb72d8f9 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Mon, 9 Mar 2009 23:32:08 -0400 Subject: ALSA: ASoC: Davinci: Updated sffsdr_hw_params() function to new format Signed-off-by: Hugo Villeneuve Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-sffsdr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c index a1ae3736a5d..40eccfe9e35 100644 --- a/sound/soc/davinci/davinci-sffsdr.c +++ b/sound/soc/davinci/davinci-sffsdr.c @@ -45,8 +45,7 @@ SND_SOC_DAIFMT_IB_NF) static int sffsdr_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) + struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; -- cgit v1.2.3 From cbf1146d5ee113152c5cdeb54ff9d4b2f0c91736 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 10 Mar 2009 16:41:00 +0100 Subject: ASoC: don't touch pxa-ssp registers when stream is running In pxa_ssp_set_dai_fmt(), check whether there is anything to do at all. If there would be but the SSP port is in use already, bail out. Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 7fc13f03d1d..52d97c4b82b 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -522,6 +522,17 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, u32 sscr1; u32 sspsp; + /* check if we need to change anything at all */ + if (priv->dai_fmt == fmt) + return 0; + + /* we can only change the settings if the port is not in use */ + if (ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) { + dev_err(&ssp->pdev->dev, + "can't change hardware dai format: stream is in use"); + return -EINVAL; + } + /* reset port settings */ sscr0 = ssp_read_reg(ssp, SSCR0) & (SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); -- cgit v1.2.3 From 5706d5013212c8afcb9fe5332ee6442488280c66 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 11 Mar 2009 02:37:25 -0800 Subject: ASoC: buildfix for OSK Buildfix: CC sound/soc/omap/osk5912.o sound/soc/omap/osk5912.c: In function 'osk_soc_init': sound/soc/omap/osk5912.c:189: error: implicit declaration of function 'clk_get_usecount' make[3]: *** [sound/soc/omap/osk5912.o] Error 1 There's no such (standard) clock interface. Signed-off-by: David Brownell Signed-off-by: Mark Brown --- sound/soc/omap/osk5912.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/osk5912.c b/sound/soc/omap/osk5912.c index cd41a948df7..a952a4eb336 100644 --- a/sound/soc/omap/osk5912.c +++ b/sound/soc/omap/osk5912.c @@ -186,13 +186,6 @@ static int __init osk_soc_init(void) return -ENODEV; } - if (clk_get_usecount(tlv320aic23_mclk) > 0) { - /* MCLK is already in use */ - printk(KERN_WARNING - "MCLK in use at %d Hz. We change it to %d Hz\n", - (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK); - } - /* * Configure 12 MHz output on MCLK. */ @@ -205,9 +198,8 @@ static int __init osk_soc_init(void) } } - printk(KERN_INFO "MCLK = %d [%d], usecount = %d\n", - (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK, - clk_get_usecount(tlv320aic23_mclk)); + printk(KERN_INFO "MCLK = %d [%d]\n", + (uint) clk_get_rate(tlv320aic23_mclk), CODEC_CLOCK); return 0; err1: -- cgit v1.2.3 From aaf1e176fa9a96fe1eea33b710684bba066aedc1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 10 Mar 2009 10:55:15 +0000 Subject: ASoC: Add initial driver for the WM8400 CODEC The WM8400 is a highly integrated audio CODEC and power management unit intended for mobile multimedia application. This driver supports the primary audio CODEC features, including: - 1W speaker driver - Fully differential headphone output - Up to 4 differential microphone inputs Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wm8400.c | 1479 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/wm8400.h | 62 ++ 4 files changed, 1547 insertions(+) create mode 100644 sound/soc/codecs/wm8400.c create mode 100644 sound/soc/codecs/wm8400.h (limited to 'sound/soc') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index a1af311e7f0..b6c7f7a01cb 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -26,6 +26,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_UDA134X select SND_SOC_UDA1380 if I2C select SND_SOC_WM8350 if MFD_WM8350 + select SND_SOC_WM8400 if MFD_WM8400 select SND_SOC_WM8510 if SND_SOC_I2C_AND_SPI select SND_SOC_WM8580 if I2C select SND_SOC_WM8728 if SND_SOC_I2C_AND_SPI @@ -110,6 +111,9 @@ config SND_SOC_UDA1380 config SND_SOC_WM8350 tristate +config SND_SOC_WM8400 + tristate + config SND_SOC_WM8510 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 4717c3c9904..030d2454725 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -14,6 +14,7 @@ snd-soc-twl4030-objs := twl4030.o snd-soc-uda134x-objs := uda134x.o snd-soc-uda1380-objs := uda1380.o snd-soc-wm8350-objs := wm8350.o +snd-soc-wm8400-objs := wm8400.o snd-soc-wm8510-objs := wm8510.o snd-soc-wm8580-objs := wm8580.o snd-soc-wm8728-objs := wm8728.o @@ -44,6 +45,7 @@ obj-$(CONFIG_SND_SOC_TWL4030) += snd-soc-twl4030.o obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o obj-$(CONFIG_SND_SOC_WM8350) += snd-soc-wm8350.o +obj-$(CONFIG_SND_SOC_WM8400) += snd-soc-wm8400.o obj-$(CONFIG_SND_SOC_WM8510) += snd-soc-wm8510.o obj-$(CONFIG_SND_SOC_WM8580) += snd-soc-wm8580.o obj-$(CONFIG_SND_SOC_WM8728) += snd-soc-wm8728.o diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c new file mode 100644 index 00000000000..9cb73d9d023 --- /dev/null +++ b/sound/soc/codecs/wm8400.c @@ -0,0 +1,1479 @@ +/* + * wm8400.c -- WM8400 ALSA Soc Audio driver + * + * Copyright 2008, 2009 Wolfson Microelectronics PLC. + * Author: Mark Brown + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wm8400.h" + +/* Fake register for internal state */ +#define WM8400_INTDRIVBITS (WM8400_REGISTER_COUNT + 1) +#define WM8400_INMIXL_PWR 0 +#define WM8400_AINLMUX_PWR 1 +#define WM8400_INMIXR_PWR 2 +#define WM8400_AINRMUX_PWR 3 + +static struct regulator_bulk_data power[] = { + { + .supply = "I2S1VDD", + }, + { + .supply = "I2S2VDD", + }, + { + .supply = "DCVDD", + }, + { + .supply = "FLLVDD", + }, + { + .supply = "HPVDD", + }, + { + .supply = "SPKVDD", + }, +}; + +/* codec private data */ +struct wm8400_priv { + struct snd_soc_codec codec; + struct wm8400 *wm8400; + u16 fake_register; + unsigned int sysclk; + unsigned int pcmclk; + struct work_struct work; +}; + +static inline unsigned int wm8400_read(struct snd_soc_codec *codec, + unsigned int reg) +{ + struct wm8400_priv *wm8400 = codec->private_data; + + if (reg == WM8400_INTDRIVBITS) + return wm8400->fake_register; + else + return wm8400_reg_read(wm8400->wm8400, reg); +} + +/* + * write to the wm8400 register space + */ +static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, + unsigned int value) +{ + struct wm8400_priv *wm8400 = codec->private_data; + + if (reg == WM8400_INTDRIVBITS) { + wm8400->fake_register = value; + return 0; + } else + return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); +} + +static void wm8400_codec_reset(struct snd_soc_codec *codec) +{ + struct wm8400_priv *wm8400 = codec->private_data; + + wm8400_reset_codec_reg_cache(wm8400->wm8400); +} + +static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600); + +static const DECLARE_TLV_DB_LINEAR(in_pga_tlv, -1650, 3000); + +static const DECLARE_TLV_DB_LINEAR(out_mix_tlv, -2100, 0); + +static const DECLARE_TLV_DB_LINEAR(out_pga_tlv, -7300, 600); + +static const DECLARE_TLV_DB_LINEAR(out_omix_tlv, -600, 0); + +static const DECLARE_TLV_DB_LINEAR(out_dac_tlv, -7163, 0); + +static const DECLARE_TLV_DB_LINEAR(in_adc_tlv, -7163, 1763); + +static const DECLARE_TLV_DB_LINEAR(out_sidetone_tlv, -3600, 0); + +static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + int reg = mc->reg; + int ret; + u16 val; + + ret = snd_soc_put_volsw(kcontrol, ucontrol); + if (ret < 0) + return ret; + + /* now hit the volume update bits (always bit 8) */ + val = wm8400_read(codec, reg); + return wm8400_write(codec, reg, val | 0x0100); +} + +#define WM8400_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert, tlv_array) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ + SNDRV_CTL_ELEM_ACCESS_READWRITE,\ + .tlv.p = (tlv_array), \ + .info = snd_soc_info_volsw, \ + .get = snd_soc_get_volsw, .put = wm8400_outpga_put_volsw_vu, \ + .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } + + +static const char *wm8400_digital_sidetone[] = + {"None", "Left ADC", "Right ADC", "Reserved"}; + +static const struct soc_enum wm8400_left_digital_sidetone_enum = +SOC_ENUM_SINGLE(WM8400_DIGITAL_SIDE_TONE, + WM8400_ADC_TO_DACL_SHIFT, 2, wm8400_digital_sidetone); + +static const struct soc_enum wm8400_right_digital_sidetone_enum = +SOC_ENUM_SINGLE(WM8400_DIGITAL_SIDE_TONE, + WM8400_ADC_TO_DACR_SHIFT, 2, wm8400_digital_sidetone); + +static const char *wm8400_adcmode[] = + {"Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"}; + +static const struct soc_enum wm8400_right_adcmode_enum = +SOC_ENUM_SINGLE(WM8400_ADC_CTRL, WM8400_ADC_HPF_CUT_SHIFT, 3, wm8400_adcmode); + +static const struct snd_kcontrol_new wm8400_snd_controls[] = { +/* INMIXL */ +SOC_SINGLE("LIN12 PGA Boost", WM8400_INPUT_MIXER3, WM8400_L12MNBST_SHIFT, + 1, 0), +SOC_SINGLE("LIN34 PGA Boost", WM8400_INPUT_MIXER3, WM8400_L34MNBST_SHIFT, + 1, 0), +/* INMIXR */ +SOC_SINGLE("RIN12 PGA Boost", WM8400_INPUT_MIXER3, WM8400_R12MNBST_SHIFT, + 1, 0), +SOC_SINGLE("RIN34 PGA Boost", WM8400_INPUT_MIXER3, WM8400_R34MNBST_SHIFT, + 1, 0), + +/* LOMIX */ +SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8400_OUTPUT_MIXER3, + WM8400_LLI3LOVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("LOMIX RIN12 PGA Bypass Volume", WM8400_OUTPUT_MIXER3, + WM8400_LR12LOVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("LOMIX LIN12 PGA Bypass Volume", WM8400_OUTPUT_MIXER3, + WM8400_LL12LOVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8400_OUTPUT_MIXER5, + WM8400_LRI3LOVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("LOMIX AINRMUX Bypass Volume", WM8400_OUTPUT_MIXER5, + WM8400_LRBLOVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("LOMIX AINLMUX Bypass Volume", WM8400_OUTPUT_MIXER5, + WM8400_LRBLOVOL_SHIFT, 7, 0, out_mix_tlv), + +/* ROMIX */ +SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8400_OUTPUT_MIXER4, + WM8400_RRI3ROVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("ROMIX LIN12 PGA Bypass Volume", WM8400_OUTPUT_MIXER4, + WM8400_RL12ROVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("ROMIX RIN12 PGA Bypass Volume", WM8400_OUTPUT_MIXER4, + WM8400_RR12ROVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("ROMIX LIN3 Bypass Volume", WM8400_OUTPUT_MIXER6, + WM8400_RLI3ROVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("ROMIX AINLMUX Bypass Volume", WM8400_OUTPUT_MIXER6, + WM8400_RLBROVOL_SHIFT, 7, 0, out_mix_tlv), +SOC_SINGLE_TLV("ROMIX AINRMUX Bypass Volume", WM8400_OUTPUT_MIXER6, + WM8400_RRBROVOL_SHIFT, 7, 0, out_mix_tlv), + +/* LOUT */ +WM8400_OUTPGA_SINGLE_R_TLV("LOUT Volume", WM8400_LEFT_OUTPUT_VOLUME, + WM8400_LOUTVOL_SHIFT, WM8400_LOUTVOL_MASK, 0, out_pga_tlv), +SOC_SINGLE("LOUT ZC", WM8400_LEFT_OUTPUT_VOLUME, WM8400_LOZC_SHIFT, 1, 0), + +/* ROUT */ +WM8400_OUTPGA_SINGLE_R_TLV("ROUT Volume", WM8400_RIGHT_OUTPUT_VOLUME, + WM8400_ROUTVOL_SHIFT, WM8400_ROUTVOL_MASK, 0, out_pga_tlv), +SOC_SINGLE("ROUT ZC", WM8400_RIGHT_OUTPUT_VOLUME, WM8400_ROZC_SHIFT, 1, 0), + +/* LOPGA */ +WM8400_OUTPGA_SINGLE_R_TLV("LOPGA Volume", WM8400_LEFT_OPGA_VOLUME, + WM8400_LOPGAVOL_SHIFT, WM8400_LOPGAVOL_MASK, 0, out_pga_tlv), +SOC_SINGLE("LOPGA ZC Switch", WM8400_LEFT_OPGA_VOLUME, + WM8400_LOPGAZC_SHIFT, 1, 0), + +/* ROPGA */ +WM8400_OUTPGA_SINGLE_R_TLV("ROPGA Volume", WM8400_RIGHT_OPGA_VOLUME, + WM8400_ROPGAVOL_SHIFT, WM8400_ROPGAVOL_MASK, 0, out_pga_tlv), +SOC_SINGLE("ROPGA ZC Switch", WM8400_RIGHT_OPGA_VOLUME, + WM8400_ROPGAZC_SHIFT, 1, 0), + +SOC_SINGLE("LON Mute Switch", WM8400_LINE_OUTPUTS_VOLUME, + WM8400_LONMUTE_SHIFT, 1, 0), +SOC_SINGLE("LOP Mute Switch", WM8400_LINE_OUTPUTS_VOLUME, + WM8400_LOPMUTE_SHIFT, 1, 0), +SOC_SINGLE("LOP Attenuation Switch", WM8400_LINE_OUTPUTS_VOLUME, + WM8400_LOATTN_SHIFT, 1, 0), +SOC_SINGLE("RON Mute Switch", WM8400_LINE_OUTPUTS_VOLUME, + WM8400_RONMUTE_SHIFT, 1, 0), +SOC_SINGLE("ROP Mute Switch", WM8400_LINE_OUTPUTS_VOLUME, + WM8400_ROPMUTE_SHIFT, 1, 0), +SOC_SINGLE("ROP Attenuation Switch", WM8400_LINE_OUTPUTS_VOLUME, + WM8400_ROATTN_SHIFT, 1, 0), + +SOC_SINGLE("OUT3 Mute Switch", WM8400_OUT3_4_VOLUME, + WM8400_OUT3MUTE_SHIFT, 1, 0), +SOC_SINGLE("OUT3 Attenuation Switch", WM8400_OUT3_4_VOLUME, + WM8400_OUT3ATTN_SHIFT, 1, 0), + +SOC_SINGLE("OUT4 Mute Switch", WM8400_OUT3_4_VOLUME, + WM8400_OUT4MUTE_SHIFT, 1, 0), +SOC_SINGLE("OUT4 Attenuation Switch", WM8400_OUT3_4_VOLUME, + WM8400_OUT4ATTN_SHIFT, 1, 0), + +SOC_SINGLE("Speaker Mode Switch", WM8400_CLASSD1, + WM8400_CDMODE_SHIFT, 1, 0), + +SOC_SINGLE("Speaker Output Attenuation Volume", WM8400_SPEAKER_VOLUME, + WM8400_SPKATTN_SHIFT, WM8400_SPKATTN_MASK, 0), +SOC_SINGLE("Speaker DC Boost Volume", WM8400_CLASSD3, + WM8400_DCGAIN_SHIFT, 6, 0), +SOC_SINGLE("Speaker AC Boost Volume", WM8400_CLASSD3, + WM8400_ACGAIN_SHIFT, 6, 0), + +WM8400_OUTPGA_SINGLE_R_TLV("Left DAC Digital Volume", + WM8400_LEFT_DAC_DIGITAL_VOLUME, WM8400_DACL_VOL_SHIFT, + 127, 0, out_dac_tlv), + +WM8400_OUTPGA_SINGLE_R_TLV("Right DAC Digital Volume", + WM8400_RIGHT_DAC_DIGITAL_VOLUME, WM8400_DACR_VOL_SHIFT, + 127, 0, out_dac_tlv), + +SOC_ENUM("Left Digital Sidetone", wm8400_left_digital_sidetone_enum), +SOC_ENUM("Right Digital Sidetone", wm8400_right_digital_sidetone_enum), + +SOC_SINGLE_TLV("Left Digital Sidetone Volume", WM8400_DIGITAL_SIDE_TONE, + WM8400_ADCL_DAC_SVOL_SHIFT, 15, 0, out_sidetone_tlv), +SOC_SINGLE_TLV("Right Digital Sidetone Volume", WM8400_DIGITAL_SIDE_TONE, + WM8400_ADCR_DAC_SVOL_SHIFT, 15, 0, out_sidetone_tlv), + +SOC_SINGLE("ADC Digital High Pass Filter Switch", WM8400_ADC_CTRL, + WM8400_ADC_HPF_ENA_SHIFT, 1, 0), + +SOC_ENUM("ADC HPF Mode", wm8400_right_adcmode_enum), + +WM8400_OUTPGA_SINGLE_R_TLV("Left ADC Digital Volume", + WM8400_LEFT_ADC_DIGITAL_VOLUME, + WM8400_ADCL_VOL_SHIFT, + WM8400_ADCL_VOL_MASK, + 0, + in_adc_tlv), + +WM8400_OUTPGA_SINGLE_R_TLV("Right ADC Digital Volume", + WM8400_RIGHT_ADC_DIGITAL_VOLUME, + WM8400_ADCR_VOL_SHIFT, + WM8400_ADCR_VOL_MASK, + 0, + in_adc_tlv), + +WM8400_OUTPGA_SINGLE_R_TLV("LIN12 Volume", + WM8400_LEFT_LINE_INPUT_1_2_VOLUME, + WM8400_LIN12VOL_SHIFT, + WM8400_LIN12VOL_MASK, + 0, + in_pga_tlv), + +SOC_SINGLE("LIN12 ZC Switch", WM8400_LEFT_LINE_INPUT_1_2_VOLUME, + WM8400_LI12ZC_SHIFT, 1, 0), + +SOC_SINGLE("LIN12 Mute Switch", WM8400_LEFT_LINE_INPUT_1_2_VOLUME, + WM8400_LI12MUTE_SHIFT, 1, 0), + +WM8400_OUTPGA_SINGLE_R_TLV("LIN34 Volume", + WM8400_LEFT_LINE_INPUT_3_4_VOLUME, + WM8400_LIN34VOL_SHIFT, + WM8400_LIN34VOL_MASK, + 0, + in_pga_tlv), + +SOC_SINGLE("LIN34 ZC Switch", WM8400_LEFT_LINE_INPUT_3_4_VOLUME, + WM8400_LI34ZC_SHIFT, 1, 0), + +SOC_SINGLE("LIN34 Mute Switch", WM8400_LEFT_LINE_INPUT_3_4_VOLUME, + WM8400_LI34MUTE_SHIFT, 1, 0), + +WM8400_OUTPGA_SINGLE_R_TLV("RIN12 Volume", + WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, + WM8400_RIN12VOL_SHIFT, + WM8400_RIN12VOL_MASK, + 0, + in_pga_tlv), + +SOC_SINGLE("RIN12 ZC Switch", WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, + WM8400_RI12ZC_SHIFT, 1, 0), + +SOC_SINGLE("RIN12 Mute Switch", WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, + WM8400_RI12MUTE_SHIFT, 1, 0), + +WM8400_OUTPGA_SINGLE_R_TLV("RIN34 Volume", + WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, + WM8400_RIN34VOL_SHIFT, + WM8400_RIN34VOL_MASK, + 0, + in_pga_tlv), + +SOC_SINGLE("RIN34 ZC Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, + WM8400_RI34ZC_SHIFT, 1, 0), + +SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, + WM8400_RI34MUTE_SHIFT, 1, 0), + +}; + +/* add non dapm controls */ +static int wm8400_add_controls(struct snd_soc_codec *codec) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(wm8400_snd_controls); i++) { + err = snd_ctl_add(codec->card, + snd_soc_cnew(&wm8400_snd_controls[i],codec, + NULL)); + if (err < 0) + return err; + } + return 0; +} + +/* + * _DAPM_ Controls + */ + +static int inmixer_event (struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + u16 reg, fakepower; + + reg = wm8400_read(w->codec, WM8400_POWER_MANAGEMENT_2); + fakepower = wm8400_read(w->codec, WM8400_INTDRIVBITS); + + if (fakepower & ((1 << WM8400_INMIXL_PWR) | + (1 << WM8400_AINLMUX_PWR))) { + reg |= WM8400_AINL_ENA; + } else { + reg &= ~WM8400_AINL_ENA; + } + + if (fakepower & ((1 << WM8400_INMIXR_PWR) | + (1 << WM8400_AINRMUX_PWR))) { + reg |= WM8400_AINR_ENA; + } else { + reg &= ~WM8400_AINL_ENA; + } + wm8400_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg); + + return 0; +} + +static int outmixer_event (struct snd_soc_dapm_widget *w, + struct snd_kcontrol * kcontrol, int event) +{ + struct soc_mixer_control *mc = + (struct soc_mixer_control *)kcontrol->private_value; + u32 reg_shift = mc->shift; + int ret = 0; + u16 reg; + + switch (reg_shift) { + case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : + reg = wm8400_read(w->codec, WM8400_OUTPUT_MIXER1); + if (reg & WM8400_LDLO) { + printk(KERN_WARNING + "Cannot set as Output Mixer 1 LDLO Set\n"); + ret = -1; + } + break; + case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): + reg = wm8400_read(w->codec, WM8400_OUTPUT_MIXER2); + if (reg & WM8400_RDRO) { + printk(KERN_WARNING + "Cannot set as Output Mixer 2 RDRO Set\n"); + ret = -1; + } + break; + case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): + reg = wm8400_read(w->codec, WM8400_SPEAKER_MIXER); + if (reg & WM8400_LDSPK) { + printk(KERN_WARNING + "Cannot set as Speaker Mixer LDSPK Set\n"); + ret = -1; + } + break; + case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): + reg = wm8400_read(w->codec, WM8400_SPEAKER_MIXER); + if (reg & WM8400_RDSPK) { + printk(KERN_WARNING + "Cannot set as Speaker Mixer RDSPK Set\n"); + ret = -1; + } + break; + } + + return ret; +} + +/* INMIX dB values */ +static const unsigned int in_mix_tlv[] = { + TLV_DB_RANGE_HEAD(1), + 0,7, TLV_DB_LINEAR_ITEM(-1200, 600), +}; + +/* Left In PGA Connections */ +static const struct snd_kcontrol_new wm8400_dapm_lin12_pga_controls[] = { +SOC_DAPM_SINGLE("LIN1 Switch", WM8400_INPUT_MIXER2, WM8400_LMN1_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LIN2 Switch", WM8400_INPUT_MIXER2, WM8400_LMP2_SHIFT, 1, 0), +}; + +static const struct snd_kcontrol_new wm8400_dapm_lin34_pga_controls[] = { +SOC_DAPM_SINGLE("LIN3 Switch", WM8400_INPUT_MIXER2, WM8400_LMN3_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LIN4 Switch", WM8400_INPUT_MIXER2, WM8400_LMP4_SHIFT, 1, 0), +}; + +/* Right In PGA Connections */ +static const struct snd_kcontrol_new wm8400_dapm_rin12_pga_controls[] = { +SOC_DAPM_SINGLE("RIN1 Switch", WM8400_INPUT_MIXER2, WM8400_RMN1_SHIFT, 1, 0), +SOC_DAPM_SINGLE("RIN2 Switch", WM8400_INPUT_MIXER2, WM8400_RMP2_SHIFT, 1, 0), +}; + +static const struct snd_kcontrol_new wm8400_dapm_rin34_pga_controls[] = { +SOC_DAPM_SINGLE("RIN3 Switch", WM8400_INPUT_MIXER2, WM8400_RMN3_SHIFT, 1, 0), +SOC_DAPM_SINGLE("RIN4 Switch", WM8400_INPUT_MIXER2, WM8400_RMP4_SHIFT, 1, 0), +}; + +/* INMIXL */ +static const struct snd_kcontrol_new wm8400_dapm_inmixl_controls[] = { +SOC_DAPM_SINGLE_TLV("Record Left Volume", WM8400_INPUT_MIXER3, + WM8400_LDBVOL_SHIFT, WM8400_LDBVOL_MASK, 0, in_mix_tlv), +SOC_DAPM_SINGLE_TLV("LIN2 Volume", WM8400_INPUT_MIXER5, WM8400_LI2BVOL_SHIFT, + 7, 0, in_mix_tlv), +SOC_DAPM_SINGLE("LINPGA12 Switch", WM8400_INPUT_MIXER3, WM8400_L12MNB_SHIFT, + 1, 0), +SOC_DAPM_SINGLE("LINPGA34 Switch", WM8400_INPUT_MIXER3, WM8400_L34MNB_SHIFT, + 1, 0), +}; + +/* INMIXR */ +static const struct snd_kcontrol_new wm8400_dapm_inmixr_controls[] = { +SOC_DAPM_SINGLE_TLV("Record Right Volume", WM8400_INPUT_MIXER4, + WM8400_RDBVOL_SHIFT, WM8400_RDBVOL_MASK, 0, in_mix_tlv), +SOC_DAPM_SINGLE_TLV("RIN2 Volume", WM8400_INPUT_MIXER6, WM8400_RI2BVOL_SHIFT, + 7, 0, in_mix_tlv), +SOC_DAPM_SINGLE("RINPGA12 Switch", WM8400_INPUT_MIXER3, WM8400_L12MNB_SHIFT, + 1, 0), +SOC_DAPM_SINGLE("RINPGA34 Switch", WM8400_INPUT_MIXER3, WM8400_L34MNB_SHIFT, + 1, 0), +}; + +/* AINLMUX */ +static const char *wm8400_ainlmux[] = + {"INMIXL Mix", "RXVOICE Mix", "DIFFINL Mix"}; + +static const struct soc_enum wm8400_ainlmux_enum = +SOC_ENUM_SINGLE( WM8400_INPUT_MIXER1, WM8400_AINLMODE_SHIFT, + ARRAY_SIZE(wm8400_ainlmux), wm8400_ainlmux); + +static const struct snd_kcontrol_new wm8400_dapm_ainlmux_controls = +SOC_DAPM_ENUM("Route", wm8400_ainlmux_enum); + +/* DIFFINL */ + +/* AINRMUX */ +static const char *wm8400_ainrmux[] = + {"INMIXR Mix", "RXVOICE Mix", "DIFFINR Mix"}; + +static const struct soc_enum wm8400_ainrmux_enum = +SOC_ENUM_SINGLE( WM8400_INPUT_MIXER1, WM8400_AINRMODE_SHIFT, + ARRAY_SIZE(wm8400_ainrmux), wm8400_ainrmux); + +static const struct snd_kcontrol_new wm8400_dapm_ainrmux_controls = +SOC_DAPM_ENUM("Route", wm8400_ainrmux_enum); + +/* RXVOICE */ +static const struct snd_kcontrol_new wm8400_dapm_rxvoice_controls[] = { +SOC_DAPM_SINGLE_TLV("LIN4/RXN", WM8400_INPUT_MIXER5, WM8400_LR4BVOL_SHIFT, + WM8400_LR4BVOL_MASK, 0, in_mix_tlv), +SOC_DAPM_SINGLE_TLV("RIN4/RXP", WM8400_INPUT_MIXER6, WM8400_RL4BVOL_SHIFT, + WM8400_RL4BVOL_MASK, 0, in_mix_tlv), +}; + +/* LOMIX */ +static const struct snd_kcontrol_new wm8400_dapm_lomix_controls[] = { +SOC_DAPM_SINGLE("LOMIX Right ADC Bypass Switch", WM8400_OUTPUT_MIXER1, + WM8400_LRBLO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOMIX Left ADC Bypass Switch", WM8400_OUTPUT_MIXER1, + WM8400_LLBLO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOMIX RIN3 Bypass Switch", WM8400_OUTPUT_MIXER1, + WM8400_LRI3LO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOMIX LIN3 Bypass Switch", WM8400_OUTPUT_MIXER1, + WM8400_LLI3LO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOMIX RIN12 PGA Bypass Switch", WM8400_OUTPUT_MIXER1, + WM8400_LR12LO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOMIX LIN12 PGA Bypass Switch", WM8400_OUTPUT_MIXER1, + WM8400_LL12LO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOMIX Left DAC Switch", WM8400_OUTPUT_MIXER1, + WM8400_LDLO_SHIFT, 1, 0), +}; + +/* ROMIX */ +static const struct snd_kcontrol_new wm8400_dapm_romix_controls[] = { +SOC_DAPM_SINGLE("ROMIX Left ADC Bypass Switch", WM8400_OUTPUT_MIXER2, + WM8400_RLBRO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROMIX Right ADC Bypass Switch", WM8400_OUTPUT_MIXER2, + WM8400_RRBRO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROMIX LIN3 Bypass Switch", WM8400_OUTPUT_MIXER2, + WM8400_RLI3RO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROMIX RIN3 Bypass Switch", WM8400_OUTPUT_MIXER2, + WM8400_RRI3RO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROMIX LIN12 PGA Bypass Switch", WM8400_OUTPUT_MIXER2, + WM8400_RL12RO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROMIX RIN12 PGA Bypass Switch", WM8400_OUTPUT_MIXER2, + WM8400_RR12RO_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROMIX Right DAC Switch", WM8400_OUTPUT_MIXER2, + WM8400_RDRO_SHIFT, 1, 0), +}; + +/* LONMIX */ +static const struct snd_kcontrol_new wm8400_dapm_lonmix_controls[] = { +SOC_DAPM_SINGLE("LONMIX Left Mixer PGA Switch", WM8400_LINE_MIXER1, + WM8400_LLOPGALON_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LONMIX Right Mixer PGA Switch", WM8400_LINE_MIXER1, + WM8400_LROPGALON_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LONMIX Inverted LOP Switch", WM8400_LINE_MIXER1, + WM8400_LOPLON_SHIFT, 1, 0), +}; + +/* LOPMIX */ +static const struct snd_kcontrol_new wm8400_dapm_lopmix_controls[] = { +SOC_DAPM_SINGLE("LOPMIX Right Mic Bypass Switch", WM8400_LINE_MIXER1, + WM8400_LR12LOP_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOPMIX Left Mic Bypass Switch", WM8400_LINE_MIXER1, + WM8400_LL12LOP_SHIFT, 1, 0), +SOC_DAPM_SINGLE("LOPMIX Left Mixer PGA Switch", WM8400_LINE_MIXER1, + WM8400_LLOPGALOP_SHIFT, 1, 0), +}; + +/* RONMIX */ +static const struct snd_kcontrol_new wm8400_dapm_ronmix_controls[] = { +SOC_DAPM_SINGLE("RONMIX Right Mixer PGA Switch", WM8400_LINE_MIXER2, + WM8400_RROPGARON_SHIFT, 1, 0), +SOC_DAPM_SINGLE("RONMIX Left Mixer PGA Switch", WM8400_LINE_MIXER2, + WM8400_RLOPGARON_SHIFT, 1, 0), +SOC_DAPM_SINGLE("RONMIX Inverted ROP Switch", WM8400_LINE_MIXER2, + WM8400_ROPRON_SHIFT, 1, 0), +}; + +/* ROPMIX */ +static const struct snd_kcontrol_new wm8400_dapm_ropmix_controls[] = { +SOC_DAPM_SINGLE("ROPMIX Left Mic Bypass Switch", WM8400_LINE_MIXER2, + WM8400_RL12ROP_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROPMIX Right Mic Bypass Switch", WM8400_LINE_MIXER2, + WM8400_RR12ROP_SHIFT, 1, 0), +SOC_DAPM_SINGLE("ROPMIX Right Mixer PGA Switch", WM8400_LINE_MIXER2, + WM8400_RROPGAROP_SHIFT, 1, 0), +}; + +/* OUT3MIX */ +static const struct snd_kcontrol_new wm8400_dapm_out3mix_controls[] = { +SOC_DAPM_SINGLE("OUT3MIX LIN4/RXP Bypass Switch", WM8400_OUT3_4_MIXER, + WM8400_LI4O3_SHIFT, 1, 0), +SOC_DAPM_SINGLE("OUT3MIX Left Out PGA Switch", WM8400_OUT3_4_MIXER, + WM8400_LPGAO3_SHIFT, 1, 0), +}; + +/* OUT4MIX */ +static const struct snd_kcontrol_new wm8400_dapm_out4mix_controls[] = { +SOC_DAPM_SINGLE("OUT4MIX Right Out PGA Switch", WM8400_OUT3_4_MIXER, + WM8400_RPGAO4_SHIFT, 1, 0), +SOC_DAPM_SINGLE("OUT4MIX RIN4/RXP Bypass Switch", WM8400_OUT3_4_MIXER, + WM8400_RI4O4_SHIFT, 1, 0), +}; + +/* SPKMIX */ +static const struct snd_kcontrol_new wm8400_dapm_spkmix_controls[] = { +SOC_DAPM_SINGLE("SPKMIX LIN2 Bypass Switch", WM8400_SPEAKER_MIXER, + WM8400_LI2SPK_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX LADC Bypass Switch", WM8400_SPEAKER_MIXER, + WM8400_LB2SPK_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX Left Mixer PGA Switch", WM8400_SPEAKER_MIXER, + WM8400_LOPGASPK_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX Left DAC Switch", WM8400_SPEAKER_MIXER, + WM8400_LDSPK_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX Right DAC Switch", WM8400_SPEAKER_MIXER, + WM8400_RDSPK_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX Right Mixer PGA Switch", WM8400_SPEAKER_MIXER, + WM8400_ROPGASPK_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX RADC Bypass Switch", WM8400_SPEAKER_MIXER, + WM8400_RL12ROP_SHIFT, 1, 0), +SOC_DAPM_SINGLE("SPKMIX RIN2 Bypass Switch", WM8400_SPEAKER_MIXER, + WM8400_RI2SPK_SHIFT, 1, 0), +}; + +static const struct snd_soc_dapm_widget wm8400_dapm_widgets[] = { +/* Input Side */ +/* Input Lines */ +SND_SOC_DAPM_INPUT("LIN1"), +SND_SOC_DAPM_INPUT("LIN2"), +SND_SOC_DAPM_INPUT("LIN3"), +SND_SOC_DAPM_INPUT("LIN4/RXN"), +SND_SOC_DAPM_INPUT("RIN3"), +SND_SOC_DAPM_INPUT("RIN4/RXP"), +SND_SOC_DAPM_INPUT("RIN1"), +SND_SOC_DAPM_INPUT("RIN2"), +SND_SOC_DAPM_INPUT("Internal ADC Source"), + +/* DACs */ +SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8400_POWER_MANAGEMENT_2, + WM8400_ADCL_ENA_SHIFT, 0), +SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8400_POWER_MANAGEMENT_2, + WM8400_ADCR_ENA_SHIFT, 0), + +/* Input PGAs */ +SND_SOC_DAPM_MIXER("LIN12 PGA", WM8400_POWER_MANAGEMENT_2, + WM8400_LIN12_ENA_SHIFT, + 0, &wm8400_dapm_lin12_pga_controls[0], + ARRAY_SIZE(wm8400_dapm_lin12_pga_controls)), +SND_SOC_DAPM_MIXER("LIN34 PGA", WM8400_POWER_MANAGEMENT_2, + WM8400_LIN34_ENA_SHIFT, + 0, &wm8400_dapm_lin34_pga_controls[0], + ARRAY_SIZE(wm8400_dapm_lin34_pga_controls)), +SND_SOC_DAPM_MIXER("RIN12 PGA", WM8400_POWER_MANAGEMENT_2, + WM8400_RIN12_ENA_SHIFT, + 0, &wm8400_dapm_rin12_pga_controls[0], + ARRAY_SIZE(wm8400_dapm_rin12_pga_controls)), +SND_SOC_DAPM_MIXER("RIN34 PGA", WM8400_POWER_MANAGEMENT_2, + WM8400_RIN34_ENA_SHIFT, + 0, &wm8400_dapm_rin34_pga_controls[0], + ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), + +/* INMIXL */ +SND_SOC_DAPM_MIXER_E("INMIXL", WM8400_INTDRIVBITS, WM8400_INMIXL_PWR, 0, + &wm8400_dapm_inmixl_controls[0], + ARRAY_SIZE(wm8400_dapm_inmixl_controls), + inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + +/* AINLMUX */ +SND_SOC_DAPM_MUX_E("AILNMUX", WM8400_INTDRIVBITS, WM8400_AINLMUX_PWR, 0, + &wm8400_dapm_ainlmux_controls, inmixer_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + +/* INMIXR */ +SND_SOC_DAPM_MIXER_E("INMIXR", WM8400_INTDRIVBITS, WM8400_INMIXR_PWR, 0, + &wm8400_dapm_inmixr_controls[0], + ARRAY_SIZE(wm8400_dapm_inmixr_controls), + inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + +/* AINRMUX */ +SND_SOC_DAPM_MUX_E("AIRNMUX", WM8400_INTDRIVBITS, WM8400_AINRMUX_PWR, 0, + &wm8400_dapm_ainrmux_controls, inmixer_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), + +/* Output Side */ +/* DACs */ +SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8400_POWER_MANAGEMENT_3, + WM8400_DACL_ENA_SHIFT, 0), +SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8400_POWER_MANAGEMENT_3, + WM8400_DACR_ENA_SHIFT, 0), + +/* LOMIX */ +SND_SOC_DAPM_MIXER_E("LOMIX", WM8400_POWER_MANAGEMENT_3, + WM8400_LOMIX_ENA_SHIFT, + 0, &wm8400_dapm_lomix_controls[0], + ARRAY_SIZE(wm8400_dapm_lomix_controls), + outmixer_event, SND_SOC_DAPM_PRE_REG), + +/* LONMIX */ +SND_SOC_DAPM_MIXER("LONMIX", WM8400_POWER_MANAGEMENT_3, WM8400_LON_ENA_SHIFT, + 0, &wm8400_dapm_lonmix_controls[0], + ARRAY_SIZE(wm8400_dapm_lonmix_controls)), + +/* LOPMIX */ +SND_SOC_DAPM_MIXER("LOPMIX", WM8400_POWER_MANAGEMENT_3, WM8400_LOP_ENA_SHIFT, + 0, &wm8400_dapm_lopmix_controls[0], + ARRAY_SIZE(wm8400_dapm_lopmix_controls)), + +/* OUT3MIX */ +SND_SOC_DAPM_MIXER("OUT3MIX", WM8400_POWER_MANAGEMENT_1, WM8400_OUT3_ENA_SHIFT, + 0, &wm8400_dapm_out3mix_controls[0], + ARRAY_SIZE(wm8400_dapm_out3mix_controls)), + +/* SPKMIX */ +SND_SOC_DAPM_MIXER_E("SPKMIX", WM8400_POWER_MANAGEMENT_1, WM8400_SPK_ENA_SHIFT, + 0, &wm8400_dapm_spkmix_controls[0], + ARRAY_SIZE(wm8400_dapm_spkmix_controls), outmixer_event, + SND_SOC_DAPM_PRE_REG), + +/* OUT4MIX */ +SND_SOC_DAPM_MIXER("OUT4MIX", WM8400_POWER_MANAGEMENT_1, WM8400_OUT4_ENA_SHIFT, + 0, &wm8400_dapm_out4mix_controls[0], + ARRAY_SIZE(wm8400_dapm_out4mix_controls)), + +/* ROPMIX */ +SND_SOC_DAPM_MIXER("ROPMIX", WM8400_POWER_MANAGEMENT_3, WM8400_ROP_ENA_SHIFT, + 0, &wm8400_dapm_ropmix_controls[0], + ARRAY_SIZE(wm8400_dapm_ropmix_controls)), + +/* RONMIX */ +SND_SOC_DAPM_MIXER("RONMIX", WM8400_POWER_MANAGEMENT_3, WM8400_RON_ENA_SHIFT, + 0, &wm8400_dapm_ronmix_controls[0], + ARRAY_SIZE(wm8400_dapm_ronmix_controls)), + +/* ROMIX */ +SND_SOC_DAPM_MIXER_E("ROMIX", WM8400_POWER_MANAGEMENT_3, + WM8400_ROMIX_ENA_SHIFT, + 0, &wm8400_dapm_romix_controls[0], + ARRAY_SIZE(wm8400_dapm_romix_controls), + outmixer_event, SND_SOC_DAPM_PRE_REG), + +/* LOUT PGA */ +SND_SOC_DAPM_PGA("LOUT PGA", WM8400_POWER_MANAGEMENT_1, WM8400_LOUT_ENA_SHIFT, + 0, NULL, 0), + +/* ROUT PGA */ +SND_SOC_DAPM_PGA("ROUT PGA", WM8400_POWER_MANAGEMENT_1, WM8400_ROUT_ENA_SHIFT, + 0, NULL, 0), + +/* LOPGA */ +SND_SOC_DAPM_PGA("LOPGA", WM8400_POWER_MANAGEMENT_3, WM8400_LOPGA_ENA_SHIFT, 0, + NULL, 0), + +/* ROPGA */ +SND_SOC_DAPM_PGA("ROPGA", WM8400_POWER_MANAGEMENT_3, WM8400_ROPGA_ENA_SHIFT, 0, + NULL, 0), + +/* MICBIAS */ +SND_SOC_DAPM_MICBIAS("MICBIAS", WM8400_POWER_MANAGEMENT_1, + WM8400_MIC1BIAS_ENA_SHIFT, 0), + +SND_SOC_DAPM_OUTPUT("LON"), +SND_SOC_DAPM_OUTPUT("LOP"), +SND_SOC_DAPM_OUTPUT("OUT3"), +SND_SOC_DAPM_OUTPUT("LOUT"), +SND_SOC_DAPM_OUTPUT("SPKN"), +SND_SOC_DAPM_OUTPUT("SPKP"), +SND_SOC_DAPM_OUTPUT("ROUT"), +SND_SOC_DAPM_OUTPUT("OUT4"), +SND_SOC_DAPM_OUTPUT("ROP"), +SND_SOC_DAPM_OUTPUT("RON"), + +SND_SOC_DAPM_OUTPUT("Internal DAC Sink"), +}; + +static const struct snd_soc_dapm_route audio_map[] = { + /* Make DACs turn on when playing even if not mixed into any outputs */ + {"Internal DAC Sink", NULL, "Left DAC"}, + {"Internal DAC Sink", NULL, "Right DAC"}, + + /* Make ADCs turn on when recording + * even if not mixed from any inputs */ + {"Left ADC", NULL, "Internal ADC Source"}, + {"Right ADC", NULL, "Internal ADC Source"}, + + /* Input Side */ + /* LIN12 PGA */ + {"LIN12 PGA", "LIN1 Switch", "LIN1"}, + {"LIN12 PGA", "LIN2 Switch", "LIN2"}, + /* LIN34 PGA */ + {"LIN34 PGA", "LIN3 Switch", "LIN3"}, + {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, + /* INMIXL */ + {"INMIXL", "Record Left Volume", "LOMIX"}, + {"INMIXL", "LIN2 Volume", "LIN2"}, + {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, + {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, + /* AILNMUX */ + {"AILNMUX", "INMIXL Mix", "INMIXL"}, + {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, + {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, + {"AILNMUX", "RXVOICE Mix", "LIN4/RXN"}, + {"AILNMUX", "RXVOICE Mix", "RIN4/RXP"}, + /* ADC */ + {"Left ADC", NULL, "AILNMUX"}, + + /* RIN12 PGA */ + {"RIN12 PGA", "RIN1 Switch", "RIN1"}, + {"RIN12 PGA", "RIN2 Switch", "RIN2"}, + /* RIN34 PGA */ + {"RIN34 PGA", "RIN3 Switch", "RIN3"}, + {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, + /* INMIXL */ + {"INMIXR", "Record Right Volume", "ROMIX"}, + {"INMIXR", "RIN2 Volume", "RIN2"}, + {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, + {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, + /* AIRNMUX */ + {"AIRNMUX", "INMIXR Mix", "INMIXR"}, + {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, + {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, + {"AIRNMUX", "RXVOICE Mix", "LIN4/RXN"}, + {"AIRNMUX", "RXVOICE Mix", "RIN4/RXP"}, + /* ADC */ + {"Right ADC", NULL, "AIRNMUX"}, + + /* LOMIX */ + {"LOMIX", "LOMIX RIN3 Bypass Switch", "RIN3"}, + {"LOMIX", "LOMIX LIN3 Bypass Switch", "LIN3"}, + {"LOMIX", "LOMIX LIN12 PGA Bypass Switch", "LIN12 PGA"}, + {"LOMIX", "LOMIX RIN12 PGA Bypass Switch", "RIN12 PGA"}, + {"LOMIX", "LOMIX Right ADC Bypass Switch", "AIRNMUX"}, + {"LOMIX", "LOMIX Left ADC Bypass Switch", "AILNMUX"}, + {"LOMIX", "LOMIX Left DAC Switch", "Left DAC"}, + + /* ROMIX */ + {"ROMIX", "ROMIX RIN3 Bypass Switch", "RIN3"}, + {"ROMIX", "ROMIX LIN3 Bypass Switch", "LIN3"}, + {"ROMIX", "ROMIX LIN12 PGA Bypass Switch", "LIN12 PGA"}, + {"ROMIX", "ROMIX RIN12 PGA Bypass Switch", "RIN12 PGA"}, + {"ROMIX", "ROMIX Right ADC Bypass Switch", "AIRNMUX"}, + {"ROMIX", "ROMIX Left ADC Bypass Switch", "AILNMUX"}, + {"ROMIX", "ROMIX Right DAC Switch", "Right DAC"}, + + /* SPKMIX */ + {"SPKMIX", "SPKMIX LIN2 Bypass Switch", "LIN2"}, + {"SPKMIX", "SPKMIX RIN2 Bypass Switch", "RIN2"}, + {"SPKMIX", "SPKMIX LADC Bypass Switch", "AILNMUX"}, + {"SPKMIX", "SPKMIX RADC Bypass Switch", "AIRNMUX"}, + {"SPKMIX", "SPKMIX Left Mixer PGA Switch", "LOPGA"}, + {"SPKMIX", "SPKMIX Right Mixer PGA Switch", "ROPGA"}, + {"SPKMIX", "SPKMIX Right DAC Switch", "Right DAC"}, + {"SPKMIX", "SPKMIX Left DAC Switch", "Right DAC"}, + + /* LONMIX */ + {"LONMIX", "LONMIX Left Mixer PGA Switch", "LOPGA"}, + {"LONMIX", "LONMIX Right Mixer PGA Switch", "ROPGA"}, + {"LONMIX", "LONMIX Inverted LOP Switch", "LOPMIX"}, + + /* LOPMIX */ + {"LOPMIX", "LOPMIX Right Mic Bypass Switch", "RIN12 PGA"}, + {"LOPMIX", "LOPMIX Left Mic Bypass Switch", "LIN12 PGA"}, + {"LOPMIX", "LOPMIX Left Mixer PGA Switch", "LOPGA"}, + + /* OUT3MIX */ + {"OUT3MIX", "OUT3MIX LIN4/RXP Bypass Switch", "LIN4/RXN"}, + {"OUT3MIX", "OUT3MIX Left Out PGA Switch", "LOPGA"}, + + /* OUT4MIX */ + {"OUT4MIX", "OUT4MIX Right Out PGA Switch", "ROPGA"}, + {"OUT4MIX", "OUT4MIX RIN4/RXP Bypass Switch", "RIN4/RXP"}, + + /* RONMIX */ + {"RONMIX", "RONMIX Right Mixer PGA Switch", "ROPGA"}, + {"RONMIX", "RONMIX Left Mixer PGA Switch", "LOPGA"}, + {"RONMIX", "RONMIX Inverted ROP Switch", "ROPMIX"}, + + /* ROPMIX */ + {"ROPMIX", "ROPMIX Left Mic Bypass Switch", "LIN12 PGA"}, + {"ROPMIX", "ROPMIX Right Mic Bypass Switch", "RIN12 PGA"}, + {"ROPMIX", "ROPMIX Right Mixer PGA Switch", "ROPGA"}, + + /* Out Mixer PGAs */ + {"LOPGA", NULL, "LOMIX"}, + {"ROPGA", NULL, "ROMIX"}, + + {"LOUT PGA", NULL, "LOMIX"}, + {"ROUT PGA", NULL, "ROMIX"}, + + /* Output Pins */ + {"LON", NULL, "LONMIX"}, + {"LOP", NULL, "LOPMIX"}, + {"OUT3", NULL, "OUT3MIX"}, + {"LOUT", NULL, "LOUT PGA"}, + {"SPKN", NULL, "SPKMIX"}, + {"ROUT", NULL, "ROUT PGA"}, + {"OUT4", NULL, "OUT4MIX"}, + {"ROP", NULL, "ROPMIX"}, + {"RON", NULL, "RONMIX"}, +}; + +static int wm8400_add_widgets(struct snd_soc_codec *codec) +{ + snd_soc_dapm_new_controls(codec, wm8400_dapm_widgets, + ARRAY_SIZE(wm8400_dapm_widgets)); + + snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); + + snd_soc_dapm_new_widgets(codec); + return 0; +} + +/* + * Clock after FLL and dividers + */ +static int wm8400_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; + struct wm8400_priv *wm8400 = codec->private_data; + + wm8400->sysclk = freq; + return 0; +} + +/* + * Sets ADC and Voice DAC format. + */ +static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + u16 audio1, audio3; + + audio1 = wm8400_read(codec, WM8400_AUDIO_INTERFACE_1); + audio3 = wm8400_read(codec, WM8400_AUDIO_INTERFACE_3); + + /* set master/slave audio interface */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + audio3 &= ~WM8400_AIF_MSTR1; + break; + case SND_SOC_DAIFMT_CBM_CFM: + audio3 |= WM8400_AIF_MSTR1; + break; + default: + return -EINVAL; + } + + audio1 &= ~WM8400_AIF_FMT_MASK; + + /* interface format */ + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + audio1 |= WM8400_AIF_FMT_I2S; + audio1 &= ~WM8400_AIF_LRCLK_INV; + break; + case SND_SOC_DAIFMT_RIGHT_J: + audio1 |= WM8400_AIF_FMT_RIGHTJ; + audio1 &= ~WM8400_AIF_LRCLK_INV; + break; + case SND_SOC_DAIFMT_LEFT_J: + audio1 |= WM8400_AIF_FMT_LEFTJ; + audio1 &= ~WM8400_AIF_LRCLK_INV; + break; + case SND_SOC_DAIFMT_DSP_A: + audio1 |= WM8400_AIF_FMT_DSP; + audio1 &= ~WM8400_AIF_LRCLK_INV; + break; + case SND_SOC_DAIFMT_DSP_B: + audio1 |= WM8400_AIF_FMT_DSP | WM8400_AIF_LRCLK_INV; + break; + default: + return -EINVAL; + } + + wm8400_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); + wm8400_write(codec, WM8400_AUDIO_INTERFACE_3, audio3); + return 0; +} + +static int wm8400_set_dai_clkdiv(struct snd_soc_dai *codec_dai, + int div_id, int div) +{ + struct snd_soc_codec *codec = codec_dai->codec; + u16 reg; + + switch (div_id) { + case WM8400_MCLK_DIV: + reg = wm8400_read(codec, WM8400_CLOCKING_2) & + ~WM8400_MCLK_DIV_MASK; + wm8400_write(codec, WM8400_CLOCKING_2, reg | div); + break; + case WM8400_DACCLK_DIV: + reg = wm8400_read(codec, WM8400_CLOCKING_2) & + ~WM8400_DAC_CLKDIV_MASK; + wm8400_write(codec, WM8400_CLOCKING_2, reg | div); + break; + case WM8400_ADCCLK_DIV: + reg = wm8400_read(codec, WM8400_CLOCKING_2) & + ~WM8400_ADC_CLKDIV_MASK; + wm8400_write(codec, WM8400_CLOCKING_2, reg | div); + break; + case WM8400_BCLK_DIV: + reg = wm8400_read(codec, WM8400_CLOCKING_1) & + ~WM8400_BCLK_DIV_MASK; + wm8400_write(codec, WM8400_CLOCKING_1, reg | div); + break; + default: + return -EINVAL; + } + + return 0; +} + +/* + * Set PCM DAI bit size and sample rate. + */ +static int wm8400_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->card->codec; + u16 audio1 = wm8400_read(codec, WM8400_AUDIO_INTERFACE_1); + + audio1 &= ~WM8400_AIF_WL_MASK; + /* bit size */ + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S16_LE: + break; + case SNDRV_PCM_FORMAT_S20_3LE: + audio1 |= WM8400_AIF_WL_20BITS; + break; + case SNDRV_PCM_FORMAT_S24_LE: + audio1 |= WM8400_AIF_WL_24BITS; + break; + case SNDRV_PCM_FORMAT_S32_LE: + audio1 |= WM8400_AIF_WL_32BITS; + break; + } + + wm8400_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); + return 0; +} + +static int wm8400_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + u16 val = wm8400_read(codec, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE; + + if (mute) + wm8400_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); + else + wm8400_write(codec, WM8400_DAC_CTRL, val); + + return 0; +} + +/* TODO: set bias for best performance at standby */ +static int wm8400_set_bias_level(struct snd_soc_codec *codec, + enum snd_soc_bias_level level) +{ + struct wm8400_priv *wm8400 = codec->private_data; + u16 val; + int ret; + + switch (level) { + case SND_SOC_BIAS_ON: + break; + + case SND_SOC_BIAS_PREPARE: + /* VMID=2*50k */ + val = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1) & + ~WM8400_VMID_MODE_MASK; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x2); + break; + + case SND_SOC_BIAS_STANDBY: + if (codec->bias_level == SND_SOC_BIAS_OFF) { + ret = regulator_bulk_enable(ARRAY_SIZE(power), + &power[0]); + if (ret != 0) { + dev_err(wm8400->wm8400->dev, + "Failed to enable regulators: %d\n", + ret); + return ret; + } + + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, + WM8400_CODEC_ENA | WM8400_SYSCLK_ENA); + + /* Enable all output discharge bits */ + wm8400_write(codec, WM8400_ANTIPOP1, WM8400_DIS_LLINE | + WM8400_DIS_RLINE | WM8400_DIS_OUT3 | + WM8400_DIS_OUT4 | WM8400_DIS_LOUT | + WM8400_DIS_ROUT); + + /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ + wm8400_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + WM8400_BUFDCOPEN | WM8400_POBCTRL); + + msleep(500); + + /* Enable outputs */ + val = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1); + val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | + WM8400_OUT4_ENA | WM8400_LOUT_ENA | + WM8400_ROUT_ENA; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); + + /* disable all output discharge bits */ + wm8400_write(codec, WM8400_ANTIPOP1, 0); + + /* Enable VREF & VMID at 2x50k */ + val |= 0x2 | WM8400_VREF_ENA; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); + + msleep(600); + + /* Enable BUFIOEN */ + wm8400_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + WM8400_BUFDCOPEN | WM8400_POBCTRL | + WM8400_BUFIOEN); + + /* Disable outputs */ + val &= ~(WM8400_SPK_ENA | WM8400_OUT3_ENA | + WM8400_OUT4_ENA | WM8400_LOUT_ENA | + WM8400_ROUT_ENA); + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); + + /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ + wm8400_write(codec, WM8400_ANTIPOP2, WM8400_BUFIOEN); + } + + /* VMID=2*300k */ + val = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1) & + ~WM8400_VMID_MODE_MASK; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x4); + break; + + case SND_SOC_BIAS_OFF: + /* Enable POBCTRL and SOFT_ST */ + wm8400_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + WM8400_POBCTRL | WM8400_BUFIOEN); + + /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ + wm8400_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + WM8400_BUFDCOPEN | WM8400_POBCTRL | + WM8400_BUFIOEN); + + /* mute DAC */ + val = wm8400_read(codec, WM8400_DAC_CTRL); + wm8400_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); + + /* Enable any disabled outputs */ + val = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1); + val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | + WM8400_OUT4_ENA | WM8400_LOUT_ENA | + WM8400_ROUT_ENA; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); + + /* Disable VMID */ + val &= ~WM8400_VMID_MODE_MASK; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); + + msleep(300); + + /* Enable all output discharge bits */ + wm8400_write(codec, WM8400_ANTIPOP1, WM8400_DIS_LLINE | + WM8400_DIS_RLINE | WM8400_DIS_OUT3 | + WM8400_DIS_OUT4 | WM8400_DIS_LOUT | + WM8400_DIS_ROUT); + + /* Disable VREF */ + val &= ~WM8400_VREF_ENA; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); + + /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ + wm8400_write(codec, WM8400_ANTIPOP2, 0x0); + + ret = regulator_bulk_disable(ARRAY_SIZE(power), + &power[0]); + if (ret != 0) + return ret; + + break; + } + + codec->bias_level = level; + return 0; +} + +#define WM8400_RATES SNDRV_PCM_RATE_8000_96000 + +#define WM8400_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ + SNDRV_PCM_FMTBIT_S24_LE) + +/* + * The WM8400 supports 2 different and mutually exclusive DAI + * configurations. + * + * 1. ADC/DAC on Primary Interface + * 2. ADC on Primary Interface/DAC on secondary + */ +struct snd_soc_dai wm8400_dai = { +/* ADC/DAC on primary */ + .name = "WM8400 ADC/DAC Primary", + .id = 1, + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + .rates = WM8400_RATES, + .formats = WM8400_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + .rates = WM8400_RATES, + .formats = WM8400_FORMATS, + }, + .ops = { + .hw_params = wm8400_hw_params, + .digital_mute = wm8400_mute, + .set_fmt = wm8400_set_dai_fmt, + .set_clkdiv = wm8400_set_dai_clkdiv, + .set_sysclk = wm8400_set_dai_sysclk, + }, +}; +EXPORT_SYMBOL_GPL(wm8400_dai); + +static int wm8400_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->card->codec; + + wm8400_set_bias_level(codec, SND_SOC_BIAS_OFF); + + return 0; +} + +static int wm8400_resume(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = socdev->card->codec; + + wm8400_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + + return 0; +} + +static struct snd_soc_codec *wm8400_codec; + +static int wm8400_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret; + + if (!wm8400_codec) { + dev_err(&pdev->dev, "wm8400 not yet discovered\n"); + return -ENODEV; + } + codec = wm8400_codec; + + socdev->card->codec = codec; + + /* register pcms */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + dev_err(&pdev->dev, "failed to create pcms\n"); + goto pcm_err; + } + + wm8400_add_controls(codec); + wm8400_add_widgets(codec); + + ret = snd_soc_init_card(socdev); + if (ret < 0) { + dev_err(&pdev->dev, "failed to register card\n"); + goto card_err; + } + + return ret; + +card_err: + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); +pcm_err: + return ret; +} + +/* power down chip */ +static int wm8400_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); + + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_wm8400 = { + .probe = wm8400_probe, + .remove = wm8400_remove, + .suspend = wm8400_suspend, + .resume = wm8400_resume, +}; + +static void wm8400_probe_deferred(struct work_struct *work) +{ + struct wm8400_priv *priv = container_of(work, struct wm8400_priv, + work); + struct snd_soc_codec *codec = &priv->codec; + int ret; + + /* charge output caps */ + wm8400_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + + /* We're done, tell the subsystem. */ + ret = snd_soc_register_codec(codec); + if (ret != 0) { + dev_err(priv->wm8400->dev, + "Failed to register codec: %d\n", ret); + goto err; + } + + ret = snd_soc_register_dai(&wm8400_dai); + if (ret != 0) { + dev_err(priv->wm8400->dev, + "Failed to register DAI: %d\n", ret); + goto err_codec; + } + + return; + +err_codec: + snd_soc_unregister_codec(codec); +err: + wm8400_set_bias_level(codec, SND_SOC_BIAS_OFF); +} + +static int wm8400_codec_probe(struct platform_device *dev) +{ + struct wm8400_priv *priv; + int ret; + u16 reg; + struct snd_soc_codec *codec; + + priv = kzalloc(sizeof(struct wm8400_priv), GFP_KERNEL); + if (priv == NULL) + return -ENOMEM; + + codec = &priv->codec; + codec->private_data = priv; + codec->control_data = dev->dev.driver_data; + priv->wm8400 = dev->dev.driver_data; + + ret = regulator_bulk_get(priv->wm8400->dev, + ARRAY_SIZE(power), &power[0]); + if (ret != 0) { + dev_err(&dev->dev, "Failed to get regulators: %d\n", ret); + goto err; + } + + codec->dev = &dev->dev; + wm8400_dai.dev = &dev->dev; + + codec->name = "WM8400"; + codec->owner = THIS_MODULE; + codec->read = wm8400_read; + codec->write = wm8400_write; + codec->bias_level = SND_SOC_BIAS_OFF; + codec->set_bias_level = wm8400_set_bias_level; + codec->dai = &wm8400_dai; + codec->num_dai = 1; + codec->reg_cache_size = WM8400_REGISTER_COUNT; + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + INIT_WORK(&priv->work, wm8400_probe_deferred); + + wm8400_codec_reset(codec); + + reg = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1); + wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA); + + /* Latch volume update bits */ + reg = wm8400_read(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); + wm8400_write(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, + reg & WM8400_IPVU); + reg = wm8400_read(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); + wm8400_write(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, + reg & WM8400_IPVU); + + wm8400_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); + wm8400_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); + + wm8400_codec = codec; + + if (!schedule_work(&priv->work)) { + ret = -EINVAL; + goto err_regulator; + } + + return 0; + +err_regulator: + wm8400_codec = NULL; + regulator_bulk_free(ARRAY_SIZE(power), power); +err: + kfree(priv); + return ret; +} + +static int __exit wm8400_codec_remove(struct platform_device *dev) +{ + struct wm8400_priv *priv = wm8400_codec->private_data; + u16 reg; + + snd_soc_unregister_dai(&wm8400_dai); + snd_soc_unregister_codec(wm8400_codec); + + reg = wm8400_read(wm8400_codec, WM8400_POWER_MANAGEMENT_1); + wm8400_write(wm8400_codec, WM8400_POWER_MANAGEMENT_1, + reg & (~WM8400_CODEC_ENA)); + + regulator_bulk_free(ARRAY_SIZE(power), power); + kfree(priv); + + wm8400_codec = NULL; + + return 0; +} + +static struct platform_driver wm8400_codec_driver = { + .driver = { + .name = "wm8400-codec", + .owner = THIS_MODULE, + }, + .probe = wm8400_codec_probe, + .remove = __exit_p(wm8400_codec_remove), +}; + +static int __init wm8400_codec_init(void) +{ + return platform_driver_register(&wm8400_codec_driver); +} +module_init(wm8400_codec_init); + +static void __exit wm8400_codec_exit(void) +{ + platform_driver_unregister(&wm8400_codec_driver); +} +module_exit(wm8400_codec_exit); + +EXPORT_SYMBOL_GPL(soc_codec_dev_wm8400); + +MODULE_DESCRIPTION("ASoC WM8400 driver"); +MODULE_AUTHOR("Mark Brown"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:wm8400-codec"); diff --git a/sound/soc/codecs/wm8400.h b/sound/soc/codecs/wm8400.h new file mode 100644 index 00000000000..79c5934d477 --- /dev/null +++ b/sound/soc/codecs/wm8400.h @@ -0,0 +1,62 @@ +/* + * wm8400.h -- audio driver for WM8400 + * + * Copyright 2008 Wolfson Microelectronics PLC. + * Author: Mark Brown + * + * 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. + * + */ + +#ifndef _WM8400_CODEC_H +#define _WM8400_CODEC_H + +#define WM8400_MCLK_DIV 0 +#define WM8400_DACCLK_DIV 1 +#define WM8400_ADCCLK_DIV 2 +#define WM8400_BCLK_DIV 3 + +#define WM8400_MCLK_DIV_1 0x400 +#define WM8400_MCLK_DIV_2 0x800 + +#define WM8400_DAC_CLKDIV_1 0x00 +#define WM8400_DAC_CLKDIV_1_5 0x04 +#define WM8400_DAC_CLKDIV_2 0x08 +#define WM8400_DAC_CLKDIV_3 0x0c +#define WM8400_DAC_CLKDIV_4 0x10 +#define WM8400_DAC_CLKDIV_5_5 0x14 +#define WM8400_DAC_CLKDIV_6 0x18 + +#define WM8400_ADC_CLKDIV_1 0x00 +#define WM8400_ADC_CLKDIV_1_5 0x20 +#define WM8400_ADC_CLKDIV_2 0x40 +#define WM8400_ADC_CLKDIV_3 0x60 +#define WM8400_ADC_CLKDIV_4 0x80 +#define WM8400_ADC_CLKDIV_5_5 0xa0 +#define WM8400_ADC_CLKDIV_6 0xc0 + + +#define WM8400_BCLK_DIV_1 (0x0 << 1) +#define WM8400_BCLK_DIV_1_5 (0x1 << 1) +#define WM8400_BCLK_DIV_2 (0x2 << 1) +#define WM8400_BCLK_DIV_3 (0x3 << 1) +#define WM8400_BCLK_DIV_4 (0x4 << 1) +#define WM8400_BCLK_DIV_5_5 (0x5 << 1) +#define WM8400_BCLK_DIV_6 (0x6 << 1) +#define WM8400_BCLK_DIV_8 (0x7 << 1) +#define WM8400_BCLK_DIV_11 (0x8 << 1) +#define WM8400_BCLK_DIV_12 (0x9 << 1) +#define WM8400_BCLK_DIV_16 (0xA << 1) +#define WM8400_BCLK_DIV_22 (0xB << 1) +#define WM8400_BCLK_DIV_24 (0xC << 1) +#define WM8400_BCLK_DIV_32 (0xD << 1) +#define WM8400_BCLK_DIV_44 (0xE << 1) +#define WM8400_BCLK_DIV_48 (0xF << 1) + +extern struct snd_soc_dai wm8400_dai; +extern struct snd_soc_codec_device soc_codec_dev_wm8400; + +#endif -- cgit v1.2.3 From 02b7cbc3994622900e8fc201f5f229b591c43628 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 Mar 2009 14:12:28 +0000 Subject: ASoC: Remove version display from WM8580 driver Signed-off-by: Mark Brown --- sound/soc/codecs/wm8580.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index d3c51ba5e6f..6cab82a9c9d 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -35,8 +35,6 @@ #include "wm8580.h" -#define WM8580_VERSION "0.1" - struct pll_state { unsigned int in; unsigned int out; @@ -972,8 +970,6 @@ static int wm8580_probe(struct platform_device *pdev) struct wm8580_priv *wm8580; int ret = 0; - pr_info("WM8580 Audio Codec %s\n", WM8580_VERSION); - setup = socdev->codec_data; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) -- cgit v1.2.3 From 5314adc3612d893c7cc526b3312d124805e45bc3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 Mar 2009 16:28:29 +0000 Subject: ASoC: Fix formats for s3c24xx-i2s register prints The register values are all u32 so don't need the long format. Signed-off-by: Mark Brown --- sound/soc/s3c24xx/s3c24xx-i2s.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 580cfed71cc..407ccd7180f 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c @@ -83,7 +83,7 @@ static void s3c24xx_snd_txctrl(int on) iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - pr_debug("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("r: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); if (on) { iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE; @@ -113,7 +113,7 @@ static void s3c24xx_snd_txctrl(int on) writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); } - pr_debug("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("w: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); } static void s3c24xx_snd_rxctrl(int on) @@ -128,7 +128,7 @@ static void s3c24xx_snd_rxctrl(int on) iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON); iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - pr_debug("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("r: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); if (on) { iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE; @@ -158,7 +158,7 @@ static void s3c24xx_snd_rxctrl(int on) writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); } - pr_debug("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon); + pr_debug("w: IISCON: %x IISMOD: %x IISFCON: %x\n", iiscon, iismod, iisfcon); } /* @@ -206,7 +206,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, pr_debug("Entered %s\n", __func__); iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - pr_debug("hw_params r: IISMOD: %lx \n", iismod); + pr_debug("hw_params r: IISMOD: %x \n", iismod); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -231,7 +231,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, } writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); - pr_debug("hw_params w: IISMOD: %lx \n", iismod); + pr_debug("hw_params w: IISMOD: %x \n", iismod); return 0; } @@ -251,7 +251,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, /* Working copies of register */ iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); - pr_debug("hw_params r: IISMOD: %lx\n", iismod); + pr_debug("hw_params r: IISMOD: %x\n", iismod); switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: @@ -269,7 +269,7 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, } writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); - pr_debug("hw_params w: IISMOD: %lx\n", iismod); + pr_debug("hw_params w: IISMOD: %x\n", iismod); return 0; } -- cgit v1.2.3 From 6f7cb44ba1a5195bf719f9ba1d57bd79e13262c1 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 11 Mar 2009 18:31:08 +0000 Subject: ASoC: Move WM8580 to normal I2C device probe Refactor the WM8580 device registration to probe via standard I2C device registration, registering the DAIs once the device has probed via I2C. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8580.c | 326 ++++++++++++++++++++++------------------------ sound/soc/codecs/wm8580.h | 5 - 2 files changed, 158 insertions(+), 173 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 27f9e231bf6..442ea6f160f 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -1,7 +1,7 @@ /* * wm8580.c -- WM8580 ALSA Soc Audio driver * - * Copyright 2008 Wolfson Microelectronics PLC. + * Copyright 2008, 2009 Wolfson Microelectronics PLC. * * 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 @@ -35,17 +35,6 @@ #include "wm8580.h" -struct pll_state { - unsigned int in; - unsigned int out; -}; - -/* codec private data */ -struct wm8580_priv { - struct pll_state a; - struct pll_state b; -}; - /* WM8580 register space */ #define WM8580_PLLA1 0x00 #define WM8580_PLLA2 0x01 @@ -100,6 +89,8 @@ struct wm8580_priv { #define WM8580_READBACK 0x34 #define WM8580_RESET 0x35 +#define WM8580_MAX_REGISTER 0x35 + /* PLLB4 (register 7h) */ #define WM8580_PLLB4_MCLKOUTSRC_MASK 0x60 #define WM8580_PLLB4_MCLKOUTSRC_PLLA 0x20 @@ -191,6 +182,20 @@ static const u16 wm8580_reg[] = { 0x0000, 0x0000 /*R53*/ }; +struct pll_state { + unsigned int in; + unsigned int out; +}; + +/* codec private data */ +struct wm8580_priv { + struct snd_soc_codec codec; + u16 reg_cache[WM8580_MAX_REGISTER + 1]; + struct pll_state a; + struct pll_state b; +}; + + /* * read wm8580 register cache */ @@ -755,8 +760,22 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: + break; + case SND_SOC_BIAS_STANDBY: + if (codec->bias_level == SND_SOC_BIAS_OFF) { + /* Power up and get individual control of the DACs */ + reg = wm8580_read(codec, WM8580_PWRDN1); + reg &= ~(WM8580_PWRDN1_PWDN | WM8580_PWRDN1_ALLDACPD); + wm8580_write(codec, WM8580_PWRDN1, reg); + + /* Make VMID high impedence */ + reg = wm8580_read(codec, WM8580_ADC_CONTROL1); + reg &= ~0x100; + wm8580_write(codec, WM8580_ADC_CONTROL1, reg); + } break; + case SND_SOC_BIAS_OFF: reg = wm8580_read(codec, WM8580_PWRDN1); wm8580_write(codec, WM8580_PWRDN1, reg | WM8580_PWRDN1_PWDN); @@ -812,100 +831,163 @@ struct snd_soc_dai wm8580_dai[] = { }; EXPORT_SYMBOL_GPL(wm8580_dai); -/* - * initialise the WM8580 driver - * register the mixer and dsp interfaces with the kernel - */ -static int wm8580_init(struct snd_soc_device *socdev) +static struct snd_soc_codec *wm8580_codec; + +static int wm8580_probe(struct platform_device *pdev) { - struct snd_soc_codec *codec = socdev->card->codec; + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; int ret = 0; - codec->name = "WM8580"; - codec->owner = THIS_MODULE; - codec->read = wm8580_read_reg_cache; - codec->write = wm8580_write; - codec->set_bias_level = wm8580_set_bias_level; - codec->dai = wm8580_dai; - codec->num_dai = ARRAY_SIZE(wm8580_dai); - codec->reg_cache_size = ARRAY_SIZE(wm8580_reg); - codec->reg_cache = kmemdup(wm8580_reg, sizeof(wm8580_reg), - GFP_KERNEL); - - if (codec->reg_cache == NULL) - return -ENOMEM; - - /* Get the codec into a known state */ - wm8580_write(codec, WM8580_RESET, 0); - - /* Power up and get individual control of the DACs */ - wm8580_write(codec, WM8580_PWRDN1, wm8580_read(codec, WM8580_PWRDN1) & - ~(WM8580_PWRDN1_PWDN | WM8580_PWRDN1_ALLDACPD)); + if (wm8580_codec == NULL) { + dev_err(&pdev->dev, "Codec device not registered\n"); + return -ENODEV; + } - /* Make VMID high impedence */ - wm8580_write(codec, WM8580_ADC_CONTROL1, - wm8580_read(codec, WM8580_ADC_CONTROL1) & ~0x100); + socdev->card->codec = wm8580_codec; + codec = wm8580_codec; /* register pcms */ - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, - SNDRV_DEFAULT_STR1); + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { - printk(KERN_ERR "wm8580: failed to create pcms\n"); + dev_err(codec->dev, "failed to create pcms: %d\n", ret); goto pcm_err; } snd_soc_add_controls(codec, wm8580_snd_controls, - ARRAY_SIZE(wm8580_snd_controls)); + ARRAY_SIZE(wm8580_snd_controls)); wm8580_add_widgets(codec); - ret = snd_soc_init_card(socdev); if (ret < 0) { - printk(KERN_ERR "wm8580: failed to register card\n"); + dev_err(codec->dev, "failed to register card: %d\n", ret); goto card_err; } + return ret; card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: - kfree(codec->reg_cache); return ret; } -/* If the i2c layer weren't so broken, we could pass this kind of data - around */ -static struct snd_soc_device *wm8580_socdev; +/* power down chip */ +static int wm8580_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + snd_soc_free_pcms(socdev); + snd_soc_dapm_free(socdev); -/* - * WM8580 2 wire address is determined by GPIO5 - * state during powerup. - * low = 0x1a - * high = 0x1b - */ + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_wm8580 = { + .probe = wm8580_probe, + .remove = wm8580_remove, +}; +EXPORT_SYMBOL_GPL(soc_codec_dev_wm8580); + +static int wm8580_register(struct wm8580_priv *wm8580) +{ + int ret, i; + struct snd_soc_codec *codec = &wm8580->codec; + + if (wm8580_codec) { + dev_err(codec->dev, "Another WM8580 is registered\n"); + ret = -EINVAL; + goto err; + } + + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + codec->private_data = wm8580; + codec->name = "WM8580"; + codec->owner = THIS_MODULE; + codec->read = wm8580_read_reg_cache; + codec->write = wm8580_write; + codec->bias_level = SND_SOC_BIAS_OFF; + codec->set_bias_level = wm8580_set_bias_level; + codec->dai = wm8580_dai; + codec->num_dai = ARRAY_SIZE(wm8580_dai); + codec->reg_cache_size = ARRAY_SIZE(wm8580->reg_cache); + codec->reg_cache = &wm8580->reg_cache; + + memcpy(codec->reg_cache, wm8580_reg, sizeof(wm8580_reg)); + + /* Get the codec into a known state */ + ret = wm8580_write(codec, WM8580_RESET, 0); + if (ret != 0) { + dev_err(codec->dev, "Failed to reset codec: %d\n", ret); + goto err; + } + + for (i = 0; i < ARRAY_SIZE(wm8580_dai); i++) + wm8580_dai[i].dev = codec->dev; + + wm8580_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + wm8580_codec = codec; + + ret = snd_soc_register_codec(codec); + if (ret != 0) { + dev_err(codec->dev, "Failed to register codec: %d\n", ret); + goto err; + } + + ret = snd_soc_register_dais(wm8580_dai, ARRAY_SIZE(wm8580_dai)); + if (ret != 0) { + dev_err(codec->dev, "Failed to register DAI: %d\n", ret); + goto err_codec; + } + + return 0; + +err_codec: + snd_soc_unregister_codec(codec); +err: + kfree(wm8580); + return ret; +} + +static void wm8580_unregister(struct wm8580_priv *wm8580) +{ + wm8580_set_bias_level(&wm8580->codec, SND_SOC_BIAS_OFF); + snd_soc_unregister_dais(wm8580_dai, ARRAY_SIZE(wm8580_dai)); + snd_soc_unregister_codec(&wm8580->codec); + kfree(wm8580); + wm8580_codec = NULL; +} + +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) static int wm8580_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct snd_soc_device *socdev = wm8580_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; + struct wm8580_priv *wm8580; + struct snd_soc_codec *codec; + + wm8580 = kzalloc(sizeof(struct wm8580_priv), GFP_KERNEL); + if (wm8580 == NULL) + return -ENOMEM; + + codec = &wm8580->codec; + codec->hw_write = (hw_write_t)i2c_master_send; - i2c_set_clientdata(i2c, codec); + i2c_set_clientdata(i2c, wm8580); codec->control_data = i2c; - ret = wm8580_init(socdev); - if (ret < 0) - dev_err(&i2c->dev, "failed to initialise WM8580\n"); - return ret; + codec->dev = &i2c->dev; + + return wm8580_register(wm8580); } static int wm8580_i2c_remove(struct i2c_client *client) { - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); + struct wm8580_priv *wm8580 = i2c_get_clientdata(client); + wm8580_unregister(wm8580); return 0; } @@ -917,127 +999,35 @@ MODULE_DEVICE_TABLE(i2c, wm8580_i2c_id); static struct i2c_driver wm8580_i2c_driver = { .driver = { - .name = "WM8580 I2C Codec", + .name = "wm8580", .owner = THIS_MODULE, }, .probe = wm8580_i2c_probe, .remove = wm8580_i2c_remove, .id_table = wm8580_i2c_id, }; +#endif -static int wm8580_add_i2c_device(struct platform_device *pdev, - const struct wm8580_setup_data *setup) +static int __init wm8580_modinit(void) { - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; int ret; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) ret = i2c_add_driver(&wm8580_i2c_driver); if (ret != 0) { - dev_err(&pdev->dev, "can't add i2c driver\n"); - return ret; - } - - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = setup->i2c_address; - strlcpy(info.type, "wm8580", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(setup->i2c_bus); - if (!adapter) { - dev_err(&pdev->dev, "can't get i2c adapter %d\n", - setup->i2c_bus); - goto err_driver; - } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - goto err_driver; - } - - return 0; - -err_driver: - i2c_del_driver(&wm8580_i2c_driver); - return -ENODEV; -} -#endif - -static int wm8580_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct wm8580_setup_data *setup; - struct snd_soc_codec *codec; - struct wm8580_priv *wm8580; - int ret = 0; - - setup = socdev->codec_data; - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) - return -ENOMEM; - - wm8580 = kzalloc(sizeof(struct wm8580_priv), GFP_KERNEL); - if (wm8580 == NULL) { - kfree(codec); - return -ENOMEM; + pr_err("Failed to register WM8580 I2C driver: %d\n", ret); } - - codec->private_data = wm8580; - socdev->card->codec = codec; - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - wm8580_socdev = socdev; - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - if (setup->i2c_address) { - codec->hw_write = (hw_write_t)i2c_master_send; - ret = wm8580_add_i2c_device(pdev, setup); - } -#else - /* Add other interfaces here */ -#endif - return ret; -} - -/* power down chip */ -static int wm8580_remove(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->card->codec; - - if (codec->control_data) - wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF); - snd_soc_free_pcms(socdev); - snd_soc_dapm_free(socdev); -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - i2c_unregister_device(codec->control_data); - i2c_del_driver(&wm8580_i2c_driver); #endif - kfree(codec->private_data); - kfree(codec); return 0; } - -struct snd_soc_codec_device soc_codec_dev_wm8580 = { - .probe = wm8580_probe, - .remove = wm8580_remove, -}; -EXPORT_SYMBOL_GPL(soc_codec_dev_wm8580); - -static int __init wm8580_modinit(void) -{ - return snd_soc_register_dais(wm8580_dai, ARRAY_SIZE(wm8580_dai)); -} module_init(wm8580_modinit); static void __exit wm8580_exit(void) { - snd_soc_unregister_dais(wm8580_dai, ARRAY_SIZE(wm8580_dai)); +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + i2c_del_driver(&wm8580_i2c_driver); +#endif } module_exit(wm8580_exit); diff --git a/sound/soc/codecs/wm8580.h b/sound/soc/codecs/wm8580.h index 09e4422f6f2..0dfb5ddde6a 100644 --- a/sound/soc/codecs/wm8580.h +++ b/sound/soc/codecs/wm8580.h @@ -28,11 +28,6 @@ #define WM8580_CLKSRC_OSC 4 #define WM8580_CLKSRC_NONE 5 -struct wm8580_setup_data { - int i2c_bus; - unsigned short i2c_address; -}; - #define WM8580_DAI_PAIFRX 0 #define WM8580_DAI_PAIFTX 1 -- cgit v1.2.3 From eb5f6d753e337834c7ceb07824ee472e43d9a7a2 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 12 Mar 2009 11:07:54 +0100 Subject: ASoC: Replace remaining uses of snd_soc_cnew with snd_soc_add_controls. The drivers are basically duplicating the same code over and over. As snd_soc_cnew is going to be made static some time after the next merge window, we might as well convert them now. Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 23 +++++------------------ sound/soc/codecs/tlv320aic26.c | 11 ++++------- sound/soc/codecs/wm8400.c | 12 ++---------- sound/soc/omap/n810.c | 12 +++++------- sound/soc/pxa/corgi.c | 12 +++++------- sound/soc/pxa/palm27x.c | 13 +++++-------- sound/soc/pxa/poodle.c | 12 +++++------- sound/soc/pxa/spitz.c | 12 +++++------- sound/soc/pxa/tosa.c | 12 +++++------- sound/soc/s3c24xx/neo1973_wm8753.c | 13 +++++-------- 10 files changed, 46 insertions(+), 86 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 2137670c9b7..7fa09a38762 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -540,7 +540,6 @@ static int cs4270_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = cs4270_codec; - unsigned int i; int ret; /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ @@ -554,23 +553,11 @@ static int cs4270_probe(struct platform_device *pdev) } /* Add the non-DAPM controls */ - for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { - struct snd_kcontrol *kctrl; - - kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); - if (!kctrl) { - dev_err(codec->dev, "error creating control '%s'\n", - cs4270_snd_controls[i].name); - ret = -ENOMEM; - goto error_free_pcms; - } - - ret = snd_ctl_add(codec->card, kctrl); - if (ret < 0) { - dev_err(codec->dev, "error adding control '%s'\n", - cs4270_snd_controls[i].name); - goto error_free_pcms; - } + ret = snd_soc_add_controls(codec, cs4270_snd_controls, + ARRAY_SIZE(cs4270_snd_controls)); + if (ret < 0) { + dev_err(codec->dev, "failed to add controls\n"); + goto error_free_pcms; } /* And finally, register the socdev */ diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index a7f333fc579..3387d9e736e 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -324,9 +324,8 @@ static int aic26_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; - struct snd_kcontrol *kcontrol; struct aic26 *aic26; - int i, ret, err; + int ret, err; dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n"); dev_dbg(&pdev->dev, "socdev=%p\n", socdev); @@ -353,11 +352,9 @@ static int aic26_probe(struct platform_device *pdev) /* register controls */ dev_dbg(&pdev->dev, "Registering controls\n"); - for (i = 0; i < ARRAY_SIZE(aic26_snd_controls); i++) { - kcontrol = snd_soc_cnew(&aic26_snd_controls[i], codec, NULL); - err = snd_ctl_add(codec->card, kcontrol); - WARN_ON(err < 0); - } + err = snd_soc_add_controls(codec, aic26_snd_controls, + ARRAY_SIZE(aic26_snd_controls)); + WARN_ON(err < 0); /* CODEC is setup, we can register the card now */ dev_dbg(&pdev->dev, "Registering card\n"); diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 4e1cefff848..744e0dc73be 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, /* add non dapm controls */ static int wm8400_add_controls(struct snd_soc_codec *codec) { - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8400_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8400_snd_controls[i],codec, - NULL)); - if (err < 0) - return err; - } - return 0; + return snd_soc_add_controls(codec, wm8400_snd_controls, + ARRAY_SIZE(wm8400_snd_controls)); } /* diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 9f037cd0191..86471fd6340 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = { static int n810_aic33_init(struct snd_soc_codec *codec) { - int i, err; + int err; /* Not connected */ snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); @@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec) snd_soc_dapm_nc_pin(codec, "HPRCOM"); /* Add N810 specific controls */ - for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&aic33_n810_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, aic33_n810_controls, + ARRAY_SIZE(aic33_n810_controls)); + if (err < 0) + return err; /* Add N810 specific widgets */ snd_soc_dapm_new_controls(codec, aic33_dapm_widgets, diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 146973ae097..02263e5d8f0 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = { */ static int corgi_wm8731_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN"); /* Add corgi specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8731_corgi_controls, + ARRAY_SIZE(wm8731_corgi_controls)); + if (err < 0) + return err; /* Add corgi specific widgets */ snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 29958cd9dae..48a73f64500 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -146,19 +146,16 @@ static const struct snd_kcontrol_new palm27x_controls[] = { static int palm27x_ac97_init(struct snd_soc_codec *codec) { - int i, err; + int 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; - } + err = snd_soc_add_controls(codec, palm27x_controls, + ARRAY_SIZE(palm27x_controls)); + if (err < 0) + return err; /* add palm27x specific widgets */ snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets, diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index fb17a0a5a09..ef7c6c8dc8f 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -241,19 +241,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = { */ static int poodle_wm8731_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN"); snd_soc_dapm_enable_pin(codec, "MICIN"); /* Add poodle specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8731_poodle_controls, + ARRAY_SIZE(wm8731_poodle_controls)); + if (err < 0) + return err; /* Add poodle specific widgets */ snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index 1aafd8c645a..6ca9f53080c 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -278,7 +278,7 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = { */ static int spitz_wm8750_init(struct snd_soc_codec *codec) { - int i, err; + int err; /* NC codec pins */ snd_soc_dapm_nc_pin(codec, "RINPUT1"); @@ -290,12 +290,10 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec) snd_soc_dapm_nc_pin(codec, "MONO1"); /* Add spitz specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8750_spitz_controls, + ARRAY_SIZE(wm8750_spitz_controls)); + if (err < 0) + return err; /* Add spitz specific widgets */ snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index 09b5bada03b..fc781374b1b 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c @@ -188,18 +188,16 @@ static const struct snd_kcontrol_new tosa_controls[] = { static int tosa_ac97_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "OUT3"); snd_soc_dapm_nc_pin(codec, "MONOOUT"); /* add tosa specific controls */ - for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&tosa_controls[i],codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, tosa_controls, + ARRAY_SIZE(tosa_controls)); + if (err < 0) + return err; /* add tosa specific widgets */ snd_soc_dapm_new_controls(codec, tosa_dapm_widgets, diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 5f6aeec0437..289fadf60b1 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -498,7 +498,7 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { */ static int neo1973_wm8753_init(struct snd_soc_codec *codec) { - int i, err; + int err; pr_debug("Entered %s\n", __func__); @@ -518,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec) set_scenario_endpoints(codec, NEO_AUDIO_OFF); /* add neo1973 specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8753_neo1973_controls[i], - codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8753_neo1973_controls, + ARRAY_SIZE(8753_neo1973_controls)); + if (err < 0) + return err; /* set up neo1973 specific audio routes */ err = snd_soc_dapm_add_routes(codec, dapm_routes, -- cgit v1.2.3 From 77dd7e17b86bd81b3638e01d784a72652071508b Mon Sep 17 00:00:00 2001 From: "Lopez Cruz, Misael" Date: Thu, 12 Mar 2009 21:45:27 -0500 Subject: ASoC: Move headset jack registration to device initialization for SDP3430 Move headset jack registration to the codec/machine specific initialization. Having the jack registration in machine init causes that the jack device gets initialized but not registered since the sound card is registered before the jack. Moving jack registration to device initialization will register the jack device along with all other devices associated to the card when the card is registed. As a consequence of jack device registered properly, the jack is detected as an input device. Signed-off-by: Misael Lopez Cruz Signed-off-by: Mark Brown --- sound/soc/omap/sdp3430.c | 74 +++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 35 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 715c648203a..0a41de677e7 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -39,6 +39,8 @@ #include "omap-pcm.h" #include "../codecs/twl4030.h" +static struct snd_soc_card snd_soc_sdp3430; + static int sdp3430_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -82,6 +84,27 @@ static struct snd_soc_ops sdp3430_ops = { .hw_params = sdp3430_hw_params, }; +/* Headset jack */ +static struct snd_soc_jack hs_jack; + +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin hs_jack_pins[] = { + { + .pin = "Headset Jack", + .mask = SND_JACK_HEADSET, + }, +}; + +/* Headset jack detection gpios */ +static struct snd_soc_jack_gpio hs_jack_gpios[] = { + { + .gpio = (OMAP_MAX_GPIO_LINES + 2), + .name = "hsdet-gpio", + .report = SND_JACK_HEADSET, + .debounce_time = 200, + }, +}; + /* SDP3430 machine DAPM */ static const struct snd_soc_dapm_widget sdp3430_twl4030_dapm_widgets[] = { SND_SOC_DAPM_MIC("Ext Mic", NULL), @@ -141,30 +164,25 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) snd_soc_dapm_nc_pin(codec, "CARKITR"); ret = snd_soc_dapm_sync(codec); + if (ret) + return ret; - return ret; -} + /* Headset jack detection */ + ret = snd_soc_jack_new(&snd_soc_sdp3430, "Headset Jack", + SND_JACK_HEADSET, &hs_jack); + if (ret) + return ret; -/* Headset jack */ -static struct snd_soc_jack hs_jack; + ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), + hs_jack_pins); + if (ret) + return ret; -/* Headset jack detection DAPM pins */ -static struct snd_soc_jack_pin hs_jack_pins[] = { - { - .pin = "Headset Jack", - .mask = SND_JACK_HEADSET, - }, -}; + ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), + hs_jack_gpios); -/* Headset jack detection gpios */ -static struct snd_soc_jack_gpio hs_jack_gpios[] = { - { - .gpio = (OMAP_MAX_GPIO_LINES + 2), - .name = "hsdet-gpio", - .report = SND_JACK_HEADSET, - .debounce_time = 200, - }, -}; + return ret; +} /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link sdp3430_dai = { @@ -216,21 +234,7 @@ static int __init sdp3430_soc_init(void) if (ret) goto err1; - /* Headset jack detection */ - ret = snd_soc_jack_new(&snd_soc_sdp3430, "SDP3430 headset jack", - SND_JACK_HEADSET, &hs_jack); - if (ret) - return ret; - - ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), - hs_jack_pins); - if (ret) - return ret; - - ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), - hs_jack_gpios); - - return ret; + return 0; err1: printk(KERN_ERR "Unable to add platform device\n"); -- cgit v1.2.3 From 72d7466468b471f99cefae3c5f4a414bbbaa0bdd Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Thu, 12 Mar 2009 11:27:49 +0100 Subject: ASoC: switch PXA SSP driver from network mode to PSP This switches the pxa ssp port usage from network mode to PSP mode. Removed some comments and checks for configured TDM channels. A special case is added to support configuration where BCLK = 64fs. We need to do some black magic in this case which doesn't look nice but there is unfortunately no other option than that. Diagnosed-by: Tim Ruetz Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index d3fa6357a9f..4dd0d7c5722 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -558,18 +558,17 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - sscr0 |= SSCR0_MOD | SSCR0_PSP; + sscr0 |= SSCR0_PSP; sscr1 |= SSCR1_RWOT | SSCR1_TRAIL; switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: - sspsp |= SSPSP_FSRT; break; case SND_SOC_DAIFMT_NB_IF: - sspsp |= SSPSP_SFRMP | SSPSP_FSRT; + sspsp |= SSPSP_SFRMP; break; case SND_SOC_DAIFMT_IB_IF: - sspsp |= SSPSP_SFRMP; + sspsp |= SSPSP_SFRMP | SSPSP_SCMODE(3); break; default: return -EINVAL; @@ -655,33 +654,56 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, sscr0 |= SSCR0_FPCKE; #endif sscr0 |= SSCR0_DataSize(16); - /* use network mode (2 slots) for 16 bit stereo */ break; case SNDRV_PCM_FORMAT_S24_LE: sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(8)); - /* we must be in network mode (2 slots) for 24 bit stereo */ break; case SNDRV_PCM_FORMAT_S32_LE: sscr0 |= (SSCR0_EDSS | SSCR0_DataSize(16)); - /* we must be in network mode (2 slots) for 32 bit stereo */ break; } ssp_write_reg(ssp, SSCR0, sscr0); switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - /* Cleared when the DAI format is set */ - sspsp = ssp_read_reg(ssp, SSPSP) | SSPSP_SFRMWDTH(width); + sspsp = ssp_read_reg(ssp, SSPSP); + + if (((sscr0 & SSCR0_SCR) == SSCR0_SerClkDiv(4)) && + (width == 16)) { + /* This is a special case where the bitclk is 64fs + * and we're not dealing with 2*32 bits of audio + * samples. + * + * The SSP values used for that are all found out by + * trying and failing a lot; some of the registers + * needed for that mode are only available on PXA3xx. + */ + +#ifdef CONFIG_PXA3xx + if (!cpu_is_pxa3xx()) + return -EINVAL; + + sspsp |= SSPSP_SFRMWDTH(width * 2); + sspsp |= SSPSP_SFRMDLY(width * 4); + sspsp |= SSPSP_EDMYSTOP(3); + sspsp |= SSPSP_DMYSTOP(3); + sspsp |= SSPSP_DMYSTRT(1); +#else + return -EINVAL; +#endif + } else + sspsp |= SSPSP_SFRMWDTH(width); + ssp_write_reg(ssp, SSPSP, sspsp); break; default: break; } - /* We always use a network mode so we always require TDM slots + /* When we use a network mode, we always require TDM slots * - complain loudly and fail if they've not been set up yet. */ - if (!(ssp_read_reg(ssp, SSTSA) & 0xf)) { + if ((sscr0 & SSCR0_MOD) && !(ssp_read_reg(ssp, SSTSA) & 0xf)) { dev_err(&ssp->pdev->dev, "No TDM timeslot configured\n"); return -EINVAL; } -- cgit v1.2.3 From 0ce36c5f7f87632f26c8fbefe68b5116eda152d2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 13 Mar 2009 14:26:08 +0000 Subject: ASoC: Fix non-networked I2S mode for PXA SSP Two issues are fixed here: - I2S transmits the left frame with the clock low but I don't seem to get LRCLK out without SFRMDLY being set so invert SFRMP and set a delay. - I2S has a clock cycle prior to the first data byte in each channel so we need to delay the data by one cycle. Tested-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 4dd0d7c5722..b0bf40973d5 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -1,4 +1,3 @@ -#define DEBUG /* * pxa-ssp.c -- ALSA Soc Audio Layer * @@ -561,14 +560,15 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, sscr0 |= SSCR0_PSP; sscr1 |= SSCR1_RWOT | SSCR1_TRAIL; + /* See hw_params() */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: + sspsp |= SSPSP_SFRMP; break; case SND_SOC_DAIFMT_NB_IF: - sspsp |= SSPSP_SFRMP; break; case SND_SOC_DAIFMT_IB_IF: - sspsp |= SSPSP_SFRMP | SSPSP_SCMODE(3); + sspsp |= SSPSP_SCMODE(3); break; default: return -EINVAL; @@ -691,8 +691,17 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, #else return -EINVAL; #endif - } else - sspsp |= SSPSP_SFRMWDTH(width); + } else { + /* The frame width is the width the LRCLK is + * asserted for; the delay is expressed in + * half cycle units. We need the extra cycle + * because the data starts clocking out one BCLK + * after LRCLK changes polarity. + */ + sspsp |= SSPSP_SFRMWDTH(width + 1); + sspsp |= SSPSP_SFRMDLY((width + 1) * 2); + sspsp |= SSPSP_DMYSTRT(1); + } ssp_write_reg(ssp, SSPSP, sspsp); break; -- cgit v1.2.3 From 85fab7802a4bc00cc752f430e22a0d9fc41fe199 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 13 Mar 2009 14:27:08 +0000 Subject: ASoC: Fix Zylonite for non-networked SSP mode This also simplifies the code a bit. Signed-off-by: Mark Brown --- sound/soc/pxa/zylonite.c | 55 ++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/zylonite.c b/sound/soc/pxa/zylonite.c index 9f6116edbb8..9a386b4c4ed 100644 --- a/sound/soc/pxa/zylonite.c +++ b/sound/soc/pxa/zylonite.c @@ -96,42 +96,35 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; unsigned int pll_out = 0; - unsigned int acds = 0; unsigned int wm9713_div = 0; int ret = 0; - - switch (params_rate(params)) { + int rate = params_rate(params); + int width = snd_pcm_format_physical_width(params_format(params)); + + /* Only support ratios that we can generate neatly from the AC97 + * based master clock - in particular, this excludes 44.1kHz. + * In most applications the voice DAC will be used for telephony + * data so multiples of 8kHz will be the common case. + */ + switch (rate) { case 8000: wm9713_div = 12; - pll_out = 2048000; break; case 16000: wm9713_div = 6; - pll_out = 4096000; break; case 48000: - default: wm9713_div = 2; - pll_out = 12288000; - acds = 1; break; + default: + /* Don't support OSS emulation */ + return -EINVAL; } - 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; - - 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; + /* Add 1 to the width for the leading clock cycle */ + pll_out = rate * (width + 1) * 8; - /* Use network mode for stereo, one slot per channel. */ - if (params_channels(params) > 1) - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 2); - else - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1); + ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0, 1); if (ret < 0) return ret; @@ -139,14 +132,6 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0, 1); - if (ret < 0) - return ret; - if (clk_pout) ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_PLL_DIV, WM9713_PCMDIV(wm9713_div)); @@ -156,6 +141,16 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; + 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; + + 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; + return 0; } -- cgit v1.2.3 From 10d9e3d99ee8332bb73a3d7f12a8cd8ffab8b136 Mon Sep 17 00:00:00 2001 From: Joonyoung Shim Date: Mon, 16 Mar 2009 21:23:35 +0900 Subject: ASoC: twl4030 - Fix build error CC sound/soc/codecs/twl4030.o sound/soc/codecs/twl4030.c:1400: warning: braces around scalar initializer sound/soc/codecs/twl4030.c:1400: warning: (near initialization for 'twl4030_dai.ops') sound/soc/codecs/twl4030.c:1401: error: field name not in record or union initializer sound/soc/codecs/twl4030.c:1401: error: (near initialization for 'twl4030_dai.ops') sound/soc/codecs/twl4030.c:1401: warning: initialization from incompatible pointer type sound/soc/codecs/twl4030.c:1402: error: field name not in record or union initializer sound/soc/codecs/twl4030.c:1402: error: (near initialization for 'twl4030_dai.ops') sound/soc/codecs/twl4030.c:1402: warning: excess elements in scalar initializer sound/soc/codecs/twl4030.c:1402: warning: (near initialization for 'twl4030_dai.ops') sound/soc/codecs/twl4030.c:1403: error: field name not in record or union initializer sound/soc/codecs/twl4030.c:1403: error: (near initialization for 'twl4030_dai.ops') sound/soc/codecs/twl4030.c:1403: warning: excess elements in scalar initializer sound/soc/codecs/twl4030.c:1403: warning: (near initialization for 'twl4030_dai.ops') Signed-off-by: Joonyoung Shim Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 86bb15cc82c..97738e2ece0 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -1383,6 +1383,12 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, #define TWL4030_RATES (SNDRV_PCM_RATE_8000_48000) #define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE) +static struct snd_soc_dai_ops twl4030_dai_ops = { + .hw_params = twl4030_hw_params, + .set_sysclk = twl4030_set_dai_sysclk, + .set_fmt = twl4030_set_dai_fmt, +}; + struct snd_soc_dai twl4030_dai = { .name = "twl4030", .playback = { @@ -1397,11 +1403,7 @@ struct snd_soc_dai twl4030_dai = { .channels_max = 2, .rates = TWL4030_RATES, .formats = TWL4030_FORMATS,}, - .ops = { - .hw_params = twl4030_hw_params, - .set_sysclk = twl4030_set_dai_sysclk, - .set_fmt = twl4030_set_dai_fmt, - } + .ops = &twl4030_dai_ops, }; EXPORT_SYMBOL_GPL(twl4030_dai); -- cgit v1.2.3 From f2a5d6a2ea2fa24573a8ce7ea7a7a2cce42e3588 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Mar 2009 14:02:07 +0000 Subject: ASoC: Fix some missing dai_ops conversions Signed-off-by: Mark Brown --- sound/soc/s3c24xx/s3c64xx-i2s.c | 8 +++++--- sound/soc/sh/hac.c | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/s3c24xx/s3c64xx-i2s.c b/sound/soc/s3c24xx/s3c64xx-i2s.c index 6e1e85dc1ff..33c5de7e255 100644 --- a/sound/soc/s3c24xx/s3c64xx-i2s.c +++ b/sound/soc/s3c24xx/s3c64xx-i2s.c @@ -177,6 +177,10 @@ static int s3c64xx_i2s_probe(struct platform_device *pdev, #define S3C64XX_I2S_FMTS \ (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE) +static struct snd_soc_dai_ops s3c64xx_i2s_dai_ops = { + .set_sysclk = s3c64xx_i2s_set_sysclk, +}; + struct snd_soc_dai s3c64xx_i2s_dai = { .name = "s3c64xx-i2s", .id = 0, @@ -193,9 +197,7 @@ struct snd_soc_dai s3c64xx_i2s_dai = { .rates = S3C64XX_I2S_RATES, .formats = S3C64XX_I2S_FMTS, }, - .ops = { - .set_sysclk = s3c64xx_i2s_set_sysclk, - }, + .ops = &s3c64xx_i2s_dai_ops, }; EXPORT_SYMBOL_GPL(s3c64xx_i2s_dai); diff --git a/sound/soc/sh/hac.c b/sound/soc/sh/hac.c index eab31838bad..41db75af3c6 100644 --- a/sound/soc/sh/hac.c +++ b/sound/soc/sh/hac.c @@ -267,6 +267,10 @@ static int hac_hw_params(struct snd_pcm_substream *substream, #define AC97_FMTS \ SNDRV_PCM_FMTBIT_S16_LE +static struct snd_soc_dai_ops hac_dai_ops = { + .hw_params = hac_hw_params, +}; + struct snd_soc_dai sh4_hac_dai[] = { { .name = "HAC0", @@ -284,9 +288,7 @@ struct snd_soc_dai sh4_hac_dai[] = { .channels_min = 2, .channels_max = 2, }, - .ops = { - .hw_params = hac_hw_params, - }, + .ops = &hac_dai_ops, }, #ifdef CONFIG_CPU_SUBTYPE_SH7760 { @@ -305,9 +307,7 @@ struct snd_soc_dai sh4_hac_dai[] = { .channels_min = 2, .channels_max = 2, }, - .ops = { - .hw_params = hac_hw_params, - }, + .ops = &hac_dai_ops, }, #endif -- cgit v1.2.3 From 852fd9e50f62b4ea7afe26eee0710464de4801b8 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Mar 2009 14:13:12 +0000 Subject: ASoC: Each PXA AC97 DAI needs a separate ops Signed-off-by: Mark Brown --- sound/soc/pxa/pxa2xx-ac97.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index cf809049272..01c21c6cdbb 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c @@ -164,10 +164,18 @@ static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream, SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000) -static struct snd_soc_dai_ops pxa_ac97_dai_ops = { +static struct snd_soc_dai_ops pxa_ac97_hifi_dai_ops = { .hw_params = pxa2xx_ac97_hw_params, }; +static struct snd_soc_dai_ops pxa_ac97_aux_dai_ops = { + .hw_params = pxa2xx_ac97_hw_aux_params, +}; + +static struct snd_soc_dai_ops pxa_ac97_mic_dai_ops = { + .hw_params = pxa2xx_ac97_hw_mic_params, +}; + /* * There is only 1 physical AC97 interface for pxa2xx, but it * has extra fifo's that can be used for aux DACs and ADCs. @@ -193,7 +201,7 @@ struct snd_soc_dai pxa_ac97_dai[] = { .channels_max = 2, .rates = PXA2XX_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = &pxa_ac97_dai_ops, + .ops = &pxa_ac97_hifi_dai_ops, }, { .name = "pxa2xx-ac97-aux", @@ -211,7 +219,7 @@ struct snd_soc_dai pxa_ac97_dai[] = { .channels_max = 1, .rates = PXA2XX_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = &pxa_ac97_dai_ops, + .ops = &pxa_ac97_aux_dai_ops, }, { .name = "pxa2xx-ac97-mic", @@ -223,7 +231,7 @@ struct snd_soc_dai pxa_ac97_dai[] = { .channels_max = 1, .rates = PXA2XX_AC97_RATES, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, - .ops = &pxa_ac97_dai_ops, + .ops = &pxa_ac97_mic_dai_ops, }, }; -- cgit v1.2.3 From d2314e0e27566f8830ebed3587cc049e07e6a4ee Mon Sep 17 00:00:00 2001 From: Atsushi Nemoto Date: Mon, 16 Mar 2009 23:26:20 +0900 Subject: ASoC: Only deregister AC97 dev if it's name was not "AC97" The commit 14fa43f53ff3a9c3d8b9662574b7369812a31a97 ("ASoC: Only register AC97 bus if it's not done already") added a condition for calling of soc_ac97_dev_register() but not added for calling of soc_ac97_dev_unregister(). This patch adds same condition for soc_ac97_dev_unregister(). Without this fix, kernel crashes when unloading an asoc driver. Signed-off-by: Atsushi Nemoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 16518329f6b..6e710f705a7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1432,7 +1432,8 @@ void snd_soc_free_pcms(struct snd_soc_device *socdev) #ifdef CONFIG_SND_SOC_AC97_BUS for (i = 0; i < codec->num_dai; i++) { codec_dai = &codec->dai[i]; - if (codec_dai->ac97_control && codec->ac97) { + if (codec_dai->ac97_control && codec->ac97 && + strcmp(codec->name, "AC97") != 0) { soc_ac97_dev_unregister(codec); goto free_card; } -- cgit v1.2.3 From e3598f6e4218d1aad3369c97217266b2375e6aca Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Mar 2009 15:19:10 +0000 Subject: ASoC: Further optimise WM8400 bias configuration sequence The active discharge does not bring sufficient benefit to justify the lengthy times involved so don't do that. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 744e0dc73be..462f8b0d9ac 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -1096,45 +1096,22 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, WM8400_CODEC_ENA | WM8400_SYSCLK_ENA); - /* Enable all output discharge bits */ - wm8400_write(codec, WM8400_ANTIPOP1, WM8400_DIS_LLINE | - WM8400_DIS_RLINE | WM8400_DIS_OUT3 | - WM8400_DIS_OUT4 | WM8400_DIS_LOUT | - WM8400_DIS_ROUT); - /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ wm8400_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL); - msleep(500); - - /* Enable outputs */ - val = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1); - val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | - WM8400_OUT4_ENA | WM8400_LOUT_ENA | - WM8400_ROUT_ENA; - wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); - - /* disable all output discharge bits */ - wm8400_write(codec, WM8400_ANTIPOP1, 0); + msleep(50); /* Enable VREF & VMID at 2x50k */ + val = wm8400_read(codec, WM8400_POWER_MANAGEMENT_1); val |= 0x2 | WM8400_VREF_ENA; wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); - msleep(600); - /* Enable BUFIOEN */ wm8400_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL | WM8400_BUFIOEN); - /* Disable outputs */ - val &= ~(WM8400_SPK_ENA | WM8400_OUT3_ENA | - WM8400_OUT4_ENA | WM8400_LOUT_ENA | - WM8400_ROUT_ENA); - wm8400_write(codec, WM8400_POWER_MANAGEMENT_1, val); - /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ wm8400_write(codec, WM8400_ANTIPOP2, WM8400_BUFIOEN); } -- cgit v1.2.3 From 24a51029fc3055f33684e650b5e3a59f77c9b05c Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Mar 2009 15:19:48 +0000 Subject: ASoC: Add separate AVDD for WM8400 There is an AVDD supply as well, normally one or more of the other upplies would be tied to it. Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 462f8b0d9ac..b7350c25b61 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -48,6 +48,9 @@ static struct regulator_bulk_data power[] = { { .supply = "DCVDD", }, + { + .supply = "AVDD", + }, { .supply = "FLLVDD", }, -- cgit v1.2.3 From e8523b641cddedec754ae5e44ec579dbceea5ef4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Mar 2009 18:28:01 +0000 Subject: ASoC: Add FLL support for WM8400 Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index b7350c25b61..510efa60400 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -70,6 +70,7 @@ struct wm8400_priv { unsigned int sysclk; unsigned int pcmclk; struct work_struct work; + int fll_in, fll_out; }; static inline unsigned int wm8400_read(struct snd_soc_codec *codec, @@ -931,6 +932,133 @@ static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } +struct fll_factors { + u16 n; + u16 k; + u16 outdiv; + u16 fratio; + u16 freq_ref; +}; + +#define FIXED_FLL_SIZE ((1 << 16) * 10) + +static int fll_factors(struct wm8400_priv *wm8400, struct fll_factors *factors, + unsigned int Fref, unsigned int Fout) +{ + u64 Kpart; + unsigned int K, Nmod, target; + + factors->outdiv = 2; + while (Fout * factors->outdiv < 90000000 || + Fout * factors->outdiv > 100000000) { + factors->outdiv *= 2; + if (factors->outdiv > 32) { + dev_err(wm8400->wm8400->dev, + "Unsupported FLL output frequency %dHz\n", + Fout); + return -EINVAL; + } + } + target = Fout * factors->outdiv; + factors->outdiv = factors->outdiv >> 2; + + if (Fref < 48000) + factors->freq_ref = 1; + else + factors->freq_ref = 0; + + if (Fref < 1000000) + factors->fratio = 9; + else + factors->fratio = 0; + + /* Ensure we have a fractional part */ + do { + if (Fref < 1000000) + factors->fratio--; + else + factors->fratio++; + + if (factors->fratio < 1 || factors->fratio > 8) { + dev_err(wm8400->wm8400->dev, + "Unable to calculate FRATIO\n"); + return -EINVAL; + } + + factors->n = target / (Fref * factors->fratio); + Nmod = target % (Fref * factors->fratio); + } while (Nmod == 0); + + /* Calculate fractional part - scale up so we can round. */ + Kpart = FIXED_FLL_SIZE * (long long)Nmod; + + do_div(Kpart, (Fref * factors->fratio)); + + K = Kpart & 0xFFFFFFFF; + + if ((K % 10) >= 5) + K += 5; + + /* Move down to proper range now rounding is done */ + factors->k = K / 10; + + dev_dbg(wm8400->wm8400->dev, + "FLL: Fref=%d Fout=%d N=%x K=%x, FRATIO=%x OUTDIV=%x\n", + Fref, Fout, + factors->n, factors->k, factors->fratio, factors->outdiv); + + return 0; +} + +static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, + unsigned int freq_in, unsigned int freq_out) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct wm8400_priv *wm8400 = codec->private_data; + struct fll_factors factors; + int ret; + u16 reg; + + if (freq_in == wm8400->fll_in && freq_out == wm8400->fll_out) + return 0; + + if (freq_out != 0) { + ret = fll_factors(wm8400, &factors, freq_in, freq_out); + if (ret != 0) + return ret; + } + + wm8400->fll_out = freq_out; + wm8400->fll_in = freq_in; + + /* We *must* disable the FLL before any changes */ + reg = wm8400_read(codec, WM8400_POWER_MANAGEMENT_2); + reg &= ~WM8400_FLL_ENA; + wm8400_write(codec, WM8400_POWER_MANAGEMENT_2, reg); + + reg = wm8400_read(codec, WM8400_FLL_CONTROL_1); + reg &= ~WM8400_FLL_OSC_ENA; + wm8400_write(codec, WM8400_FLL_CONTROL_1, reg); + + if (freq_out == 0) + return 0; + + reg &= ~(WM8400_FLL_REF_FREQ | WM8400_FLL_FRATIO_MASK); + reg |= WM8400_FLL_FRAC | factors.fratio; + reg |= factors.freq_ref << WM8400_FLL_REF_FREQ_SHIFT; + wm8400_write(codec, WM8400_FLL_CONTROL_1, reg); + + wm8400_write(codec, WM8400_FLL_CONTROL_2, factors.k); + wm8400_write(codec, WM8400_FLL_CONTROL_3, factors.n); + + reg = wm8400_read(codec, WM8400_FLL_CONTROL_4); + reg &= WM8400_FLL_OUTDIV_MASK; + reg |= factors.outdiv; + wm8400_write(codec, WM8400_FLL_CONTROL_4, reg); + + return 0; +} + /* * Sets ADC and Voice DAC format. */ @@ -1188,6 +1316,7 @@ static struct snd_soc_dai_ops wm8400_dai_ops = { .set_fmt = wm8400_set_dai_fmt, .set_clkdiv = wm8400_set_dai_clkdiv, .set_sysclk = wm8400_set_dai_sysclk, + .set_pll = wm8400_set_dai_pll, }; /* -- cgit v1.2.3 From 13b9d2ab5921d77df5217a2104b687a1c729d521 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Wed, 18 Mar 2009 16:46:53 +0200 Subject: ASoC: OMAP: N810: Mark not connected input pins Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/omap/n810.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 86471fd6340..f203221d9cb 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -254,6 +254,11 @@ static int n810_aic33_init(struct snd_soc_codec *codec) snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); snd_soc_dapm_nc_pin(codec, "HPLCOM"); snd_soc_dapm_nc_pin(codec, "HPRCOM"); + snd_soc_dapm_nc_pin(codec, "MIC3L"); + snd_soc_dapm_nc_pin(codec, "MIC3R"); + snd_soc_dapm_nc_pin(codec, "LINE1R"); + snd_soc_dapm_nc_pin(codec, "LINE2L"); + snd_soc_dapm_nc_pin(codec, "LINE2R"); /* Add N810 specific controls */ err = snd_soc_add_controls(codec, aic33_n810_controls, -- cgit v1.2.3 From f8d5fc924b1bec95f47b0a9e8f9a6e22fa1c7b05 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Wed, 18 Mar 2009 16:46:54 +0200 Subject: ASoC: OMAP: N810: Add more jack functions Add functions "Headset" and "Mic" to the control "Jack Function" for activating and de-activating codec input pin LINE1L which is connected to the mic pin of 4-pole Nokia AV connecter. Note there is no mic bias voltage management here since bias is coming from Nokia ASIC and driver for it is not in mainline. Signed-off-by: Jarkko Nikula Signed-off-by: Mark Brown --- sound/soc/omap/n810.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index f203221d9cb..a6d1178ce12 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -40,6 +40,13 @@ #define N810_HEADSET_AMP_GPIO 10 #define N810_SPEAKER_AMP_GPIO 101 +enum { + N810_JACK_DISABLED, + N810_JACK_HP, + N810_JACK_HS, + N810_JACK_MIC, +}; + static struct clk *sys_clkout2; static struct clk *sys_clkout2_src; static struct clk *func96m_clk; @@ -50,15 +57,32 @@ static int n810_dmic_func; static void n810_ext_control(struct snd_soc_codec *codec) { + int hp = 0, line1l = 0; + + switch (n810_jack_func) { + case N810_JACK_HS: + line1l = 1; + case N810_JACK_HP: + hp = 1; + break; + case N810_JACK_MIC: + line1l = 1; + break; + } + if (n810_spk_func) snd_soc_dapm_enable_pin(codec, "Ext Spk"); else snd_soc_dapm_disable_pin(codec, "Ext Spk"); - if (n810_jack_func) + if (hp) snd_soc_dapm_enable_pin(codec, "Headphone Jack"); else snd_soc_dapm_disable_pin(codec, "Headphone Jack"); + if (line1l) + snd_soc_dapm_enable_pin(codec, "LINE1L"); + else + snd_soc_dapm_disable_pin(codec, "LINE1L"); if (n810_dmic_func) snd_soc_dapm_enable_pin(codec, "DMic"); @@ -229,7 +253,7 @@ static const struct snd_soc_dapm_route audio_map[] = { }; static const char *spk_function[] = {"Off", "On"}; -static const char *jack_function[] = {"Off", "Headphone"}; +static const char *jack_function[] = {"Off", "Headphone", "Headset", "Mic"}; static const char *input_function[] = {"ADC", "Digital Mic"}; static const struct soc_enum n810_enum[] = { SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function), -- cgit v1.2.3 From 632087748c3795a54d5631e640df65592774e045 Mon Sep 17 00:00:00 2001 From: "Lopez Cruz, Misael" Date: Thu, 19 Mar 2009 01:07:34 -0500 Subject: ASoC: Declare Headset as Mic and Headphone widgets for SDP3430 Headset was declared previously as a Headphone widget connecting HSMIC and HSOL/HSOR pins of TWL4030 codec in SDP430 machine driver. The capture path becomes invalid as the Headphone widget is not a valid input endpoint. Instead of that, the Headset is declared as separate Microphone and Headphone widgets. Current patch modifies audio map: - Headset Mic: HSMIC with bias - Headset Stereophone: HSOL, HSOR Signed-off-by: Misael Lopez Cruz Signed-off-by: Mark Brown --- sound/soc/omap/sdp3430.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 0a41de677e7..10f1c867f11 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -90,8 +90,12 @@ static struct snd_soc_jack hs_jack; /* Headset jack detection DAPM pins */ static struct snd_soc_jack_pin hs_jack_pins[] = { { - .pin = "Headset Jack", - .mask = SND_JACK_HEADSET, + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, + { + .pin = "Headset Stereophone", + .mask = SND_JACK_HEADPHONE, }, }; @@ -109,7 +113,8 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = { static const struct snd_soc_dapm_widget sdp3430_twl4030_dapm_widgets[] = { SND_SOC_DAPM_MIC("Ext Mic", NULL), SND_SOC_DAPM_SPK("Ext Spk", NULL), - SND_SOC_DAPM_HP("Headset Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_HP("Headset Stereophone", NULL), }; static const struct snd_soc_dapm_route audio_map[] = { @@ -123,11 +128,13 @@ static const struct snd_soc_dapm_route audio_map[] = { {"Ext Spk", NULL, "HFL"}, {"Ext Spk", NULL, "HFR"}, - /* Headset: HSMIC (with bias), HSOL, HSOR */ - {"Headset Jack", NULL, "HSOL"}, - {"Headset Jack", NULL, "HSOR"}, + /* Headset Mic: HSMIC with bias */ {"HSMIC", NULL, "Headset Mic Bias"}, - {"Headset Mic Bias", NULL, "Headset Jack"}, + {"Headset Mic Bias", NULL, "Headset Mic"}, + + /* Headset Stereophone (Headphone): HSOL, HSOR */ + {"Headset Stereophone", NULL, "HSOL"}, + {"Headset Stereophone", NULL, "HSOR"}, }; static int sdp3430_twl4030_init(struct snd_soc_codec *codec) @@ -146,7 +153,8 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) /* SDP3430 connected pins */ snd_soc_dapm_enable_pin(codec, "Ext Mic"); snd_soc_dapm_enable_pin(codec, "Ext Spk"); - snd_soc_dapm_disable_pin(codec, "Headset Jack"); + snd_soc_dapm_disable_pin(codec, "Headset Mic"); + snd_soc_dapm_disable_pin(codec, "Headset Stereophone"); /* TWL4030 not connected pins */ snd_soc_dapm_nc_pin(codec, "AUXL"); -- cgit v1.2.3