From 58ba9b25454fe9b6ded804f69cb7ed4500b685fc Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Jan 2012 18:38:51 +0000 Subject: ASoC: Allow drivers to specify how many bits are significant on a DAI Most devices accept data in formats that don't correspond directly to their internal format. ALSA allows us to set a msbits constraint which tells userspace about this in case it finds it useful (for example, in order to avoid wasting effort dithering bits that will be ignored when raising the sample size of data) so provide a mechanism for drivers to specify the number of bits that are actually significant on a DAI and add the appropriate constraints along with all the others. This is done slightly awkwardly as the constraint is specified per sample size - we loop over every possible sample size, including ones that the device doesn't support and including ones that have fewer bits than are actually used, but this is harmless as the upper layers do the right thing in these cases. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 0992dff..55381fc 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -505,6 +505,7 @@ struct snd_soc_pcm_stream { unsigned int rate_max; /* max rate */ unsigned int channels_min; /* min channels */ unsigned int channels_max; /* max channels */ + unsigned int sig_bits; /* number of bits of content */ }; /* SoC audio ops */ -- cgit v1.1 From 8a713da8d1ce9ceaf738b32e2b24f22d4432f886 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 3 Dec 2011 12:33:55 +0000 Subject: ASoC: Use regmap update bits operation for drivers using regmap If a driver is using regmap directly ensure that we're coherent with non-ASoC register updates by using the regmap API directly to do our read/modify/write cycles. This will bypass the ASoC cache but drivers using regmap directly should not be using the ASoC cache. Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 55381fc..2f687ed 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -560,6 +560,7 @@ struct snd_soc_codec { unsigned int ac97_created:1; /* Codec has been created by SoC */ unsigned int sysfs_registered:1; /* codec has been sysfs registered */ unsigned int cache_init:1; /* codec cache has been initialized */ + unsigned int using_regmap:1; /* using regmap access */ u32 cache_only; /* Suppress writes to hardware */ u32 cache_sync; /* Cache needs to be synced to hardware */ -- cgit v1.1 From 182c51ce7944a214dd77a0b5c0462241e49dd418 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 24 Jan 2012 21:07:55 +0000 Subject: ASoC: wm8962: Optimise power consumption for IN4 DC measurement usage When the hardware is configured with one or both of the IN4 inputs used for DC measurement (with no DC blocking capacitor connected) then we can improve power consumption slightly in idle modes by applying a register write sequence. Provide platform data to enable this, implemented using a regmap patch. Signed-off-by: Mark Brown --- include/sound/wm8962.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/sound') diff --git a/include/sound/wm8962.h b/include/sound/wm8962.h index 1750bed7..79e6d42 100644 --- a/include/sound/wm8962.h +++ b/include/sound/wm8962.h @@ -49,6 +49,12 @@ struct wm8962_pdata { bool irq_active_low; bool spk_mono; /* Speaker outputs tied together as mono */ + + /** + * This flag should be set if one or both IN4 inputs is wired + * in a DC measurement configuration. + */ + bool in4_dc_measure; }; #endif -- cgit v1.1 From 62ea874abc11f02dbeb05314eb82f7d38e82e894 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 21 Jan 2012 21:14:48 +0000 Subject: ASoC: Provide REGULATOR_SUPPLY widget type Modern devices allow systems to enable and disable individual supplies on the device, allowing additional power saving by switching off regulators which power portions of the device which are not currently in use. Add a new SND_SOC_DAPM_REGULATOR_SUPPLY widget type factoring out the code for managing such widgets from individual drivers. The widget name will be used as the supply name when requesting the regulator from the regulator API. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dapm.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index d26a9b7..bfa0d3c 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -243,6 +243,10 @@ { .id = snd_soc_dapm_supply, .name = wname, .reg = wreg, \ .shift = wshift, .invert = winvert, .event = wevent, \ .event_flags = wflags} +#define SND_SOC_DAPM_REGULATOR_SUPPLY(wname, wdelay) \ +{ .id = snd_soc_dapm_regulator_supply, .name = wname, \ + .reg = SND_SOC_NOPM, .shift = wdelay, .event = dapm_regulator_event, \ + .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD } /* dapm kcontrol types */ #define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \ @@ -322,6 +326,8 @@ struct snd_soc_dapm_context; int dapm_reg_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); +int dapm_regulator_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event); /* dapm controls */ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, @@ -411,6 +417,7 @@ enum snd_soc_dapm_type { snd_soc_dapm_pre, /* machine specific pre widget - exec first */ snd_soc_dapm_post, /* machine specific post widget - exec last */ snd_soc_dapm_supply, /* power/clock supply */ + snd_soc_dapm_regulator_supply, /* external regulator */ snd_soc_dapm_aif_in, /* audio interface input */ snd_soc_dapm_aif_out, /* audio interface output */ snd_soc_dapm_siggen, /* signal generator */ @@ -465,6 +472,8 @@ struct snd_soc_dapm_widget { struct list_head list; struct snd_soc_dapm_context *dapm; + void *priv; /* widget specific data */ + /* dapm control */ short reg; /* negative reg = no direct dapm */ unsigned char shift; /* bits to shift */ -- cgit v1.1 From d5315a23ccdf921c838d26df6360b439c8d7ac83 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 25 Jan 2012 19:29:41 +0000 Subject: ASoC: wm2200: Add WM2200 CODEC driver The WM2200 is a low power mobile CODEC with enhanced Wolfson myZone Ambient Noise Cancellation (ANC) intended for mobile telephony applications. Signed-off-by: Mark Brown --- include/sound/wm2200.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/sound/wm2200.h (limited to 'include/sound') diff --git a/include/sound/wm2200.h b/include/sound/wm2200.h new file mode 100644 index 0000000..79bf55b --- /dev/null +++ b/include/sound/wm2200.h @@ -0,0 +1,41 @@ +/* + * linux/sound/wm2200.h -- Platform data for WM2200 + * + * Copyright 2012 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 version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __LINUX_SND_WM2200_H +#define __LINUX_SND_WM2200_H + +#define WM2200_GPIO_SET 0x10000 + +enum wm2200_in_mode { + WM2200_IN_SE = 0, + WM2200_IN_DIFF = 1, + WM2200_IN_DMIC = 2, +}; + +enum wm2200_dmic_sup { + WM2200_DMIC_SUP_MICVDD = 0, + WM2200_DMIC_SUP_MICBIAS1 = 1, + WM2200_DMIC_SUP_MICBIAS2 = 2, +}; + +struct wm2200_pdata { + int reset; /** GPIO controlling /RESET, if any */ + int ldo_ena; /** GPIO controlling LODENA, if any */ + int irq_flags; + + int gpio_defaults[4]; + + enum wm2200_in_mode in_mode[3]; + enum wm2200_dmic_sup dmic_sup[3]; + + int micbias_cfg[2]; /** Register value to configure MICBIAS */ +}; + +#endif -- cgit v1.1 From 394d2bbae3dbde0972b90415fc4b5628bbfd700f Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 27 Jan 2012 16:10:23 +0100 Subject: ASoC: max9768: add driver for max9768 amplifier Add a driver supporting the volume control and the mute pin. Shdn pin and DAPM are not taken care of yet. Signed-off-by: Wolfram Sang Signed-off-by: Mark Brown --- include/sound/max9768.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 include/sound/max9768.h (limited to 'include/sound') diff --git a/include/sound/max9768.h b/include/sound/max9768.h new file mode 100644 index 0000000..0f78b41 --- /dev/null +++ b/include/sound/max9768.h @@ -0,0 +1,24 @@ +/* + * Platform data for MAX9768 + * Copyright (C) 2011, 2012 by Wolfram Sang, Pengutronix e.K. + * same licence as the driver + */ + +#ifndef __SOUND_MAX9768_PDATA_H__ +#define __SOUND_MAX9768_PDATA_H__ + +/** + * struct max9768_pdata - optional platform specific MAX9768 configuration + * @shdn_gpio: GPIO to SHDN pin. If not valid, pin must be hardwired HIGH + * @mute_gpio: GPIO to MUTE pin. If not valid, control for mute won't be added + * @flags: configuration flags, e.g. set classic PWM mode (check datasheet + * regarding "filterless modulation" which is default). + */ +struct max9768_pdata { + int shdn_gpio; + int mute_gpio; + unsigned flags; +#define MAX9768_FLAG_CLASSIC_PWM (1 << 0) +}; + +#endif /* __SOUND_MAX9768_PDATA_H__*/ -- cgit v1.1 From fec691e73bf20e1c8e6ecd8e3725e4745bec4e21 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 3 Feb 2012 00:58:48 -0800 Subject: ASoC: fsi: PortA/B information was controlled by sh_fsi_port_info Current FSI got each PortA/B parameter by porta_flags/portb_flags from platform. And .set_rate function was shared for PortA/B. This structure was not readable and not flexible. This patch adds sh_fsi_port_info, and its own settings was added on each platform. it is preparation for DMAEngine support Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- include/sound/sh_fsi.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include/sound') diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h index 9b1aaca..78cd77a 100644 --- a/include/sound/sh_fsi.h +++ b/include/sound/sh_fsi.h @@ -72,10 +72,14 @@ #define SH_FSI_BPFMD_32 (5 << 4) #define SH_FSI_BPFMD_16 (6 << 4) +struct sh_fsi_port_info { + unsigned long flags; + int (*set_rate)(struct device *dev, int rate, int enable); +}; + struct sh_fsi_platform_info { - unsigned long porta_flags; - unsigned long portb_flags; - int (*set_rate)(struct device *dev, int is_porta, int rate, int enable); + struct sh_fsi_port_info port_a; + struct sh_fsi_port_info port_b; }; /* -- cgit v1.1 From 022658beab5581ecc1d325d60857f2fc464da22f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 3 Feb 2012 17:43:09 +0000 Subject: ASoC: core: Add support for DAI and machine kcontrols. Currently ASoC can only add kcontrols using codec and platform component device handles. It's also desirable to add kcontrols for DAIs (i.e. McBSP) and for SoC card machine drivers too. This allows the kcontrol to have a direct handle to the parent ASoC component DAI/SoC Card/Platform/Codec device and hence easily get it's private data. This change makes snd_soc_add_controls() static and wraps it in the folowing calls (card and dai are new) :- snd_soc_add_card_controls() snd_soc_add_codec_controls() snd_soc_add_dai_controls() snd_soc_add_platform_controls() This patch also does a lot of small mechanical changes in individual codec drivers to replace snd_soc_add_controls() with snd_soc_add_codec_controls(). It also updates the McBSP DAI driver to use snd_soc_add_dai_controls(). Finally, it updates the existing machine drivers that register controls to either :- 1) Use snd_soc_add_card_controls() where no direct codec control is required. 2) Use snd_soc_add_codec_controls() where there is direct codec control. In the case of 1) above we also update the machine drivers to get the correct component data pointers from the kcontrol (rather than getting the machine pointer via the codec pointer). Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- include/sound/soc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 2f687ed..9348bed 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -368,10 +368,14 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, void *data, char *long_name, const char *prefix); -int snd_soc_add_controls(struct snd_soc_codec *codec, +int snd_soc_add_codec_controls(struct snd_soc_codec *codec, const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_add_platform_controls(struct snd_soc_platform *platform, const struct snd_kcontrol_new *controls, int num_controls); +int snd_soc_add_card_controls(struct snd_soc_card *soc_card, + const struct snd_kcontrol_new *controls, int num_controls); +int snd_soc_add_dai_controls(struct snd_soc_dai *dai, + const struct snd_kcontrol_new *controls, int num_controls); int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol, -- cgit v1.1 From 40f02cd9f21dc2bd2c65713eb986139bb1ea0363 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 6 Feb 2012 16:05:14 +0000 Subject: ASoC: dapm: Export mixer|mux_update_power() to public API. Allow for the operation of custom mixer and mux DAPM widgets that can call snd_soc_dapm_mixer_update_power() and snd_soc_dapm_mux_update_power() directly after updating their status. This is useful with complex DAPM Mixer operations where we need to do additional work in addition to setting a few mixer register bits. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index bfa0d3c..db8435a 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -371,6 +371,12 @@ int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, const char *stream, int event); void snd_soc_dapm_shutdown(struct snd_soc_card *card); +/* external DAPM widget events */ +int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, + struct snd_kcontrol *kcontrol, int connect); +int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_widget *widget, + struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e); + /* dapm sys fs - used by the core */ int snd_soc_dapm_sys_add(struct device *dev); void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, -- cgit v1.1 From 945e5038455fef18e73914c149717878d78cb4c0 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 8 Feb 2012 20:33:31 +0000 Subject: ALSA: PCM - Add PCM creation API for internal PCMs. The new ASoC dynamic PCM core needs to create PCMs and substreams that are for use by internal ASoC drivers only and not visible to userspace for direct IO. These new PCMs are similar to regular PCMs expect they have no device nodes or procfs entries. The ASoC component drivers use them in exactly the same way as regular PCMs for PCM and DAI operations. The intention is that a dynamic PCM based driver will register both regular PCMs and internal PCMs. The regular PCMs will be used for all IO with userspace however the internal PCMs will be used by the driver to route digital audio through numerous back end DAI links (with potentially a DSP providing different hw_params, DAI formats based on the regular front end PCM params) to devices like CODECs, MODEMs, Bluetooth, FM, DMICs, etc This patch adds a new snd_pcm_new_internal() API call to create the internal PCM without device nodes or procfs. It also adds adds a new internal flag to snd_pcm. [fixed minor coding-style issues by tiwai] Signed-off-by: Liam Girdwood Signed-off-by: Takashi Iwai --- include/sound/pcm.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/sound') diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 0cf91b2..1d58d79 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -454,6 +454,7 @@ struct snd_pcm { void *private_data; void (*private_free) (struct snd_pcm *pcm); struct device *dev; /* actual hw device this belongs to */ + bool internal; /* pcm is for internal use only */ #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) struct snd_pcm_oss oss; #endif @@ -475,6 +476,9 @@ extern const struct file_operations snd_pcm_f_ops[2]; int snd_pcm_new(struct snd_card *card, const char *id, int device, int playback_count, int capture_count, struct snd_pcm **rpcm); +int snd_pcm_new_internal(struct snd_card *card, const char *id, int device, + int playback_count, int capture_count, + struct snd_pcm **rpcm); int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count); int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree); -- cgit v1.1 From 5124e69e2b31f4ded7ed9ac47b18804b7847f677 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 8 Feb 2012 13:20:50 +0000 Subject: ASoC: core: Allow CODECs to set ignore_pmdown_time in the driver struct This is usually not a use case dependant flag anyway. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 9348bed..4f67e01 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -643,6 +643,8 @@ struct snd_soc_codec_driver { /* codec stream completion event */ int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); + bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ + /* probe ordering - for components with runtime dependencies */ int probe_order; int remove_order; -- cgit v1.1 From 731f1ab290ca1e59430ab222290d379222eb38a5 Mon Sep 17 00:00:00 2001 From: Sebastien Guiriec Date: Wed, 15 Feb 2012 15:25:31 +0000 Subject: ASoC: core: add platform DAPM debugfs support Allow platform widgets to be visible in debugfs like codec widgets. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- include/sound/soc.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 4f67e01..8fa4dca 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -706,6 +706,11 @@ struct snd_soc_platform { struct list_head card_list; struct snd_soc_dapm_context dapm; + +#ifdef CONFIG_DEBUG_FS + struct dentry *debugfs_platform_root; + struct dentry *debugfs_dapm; +#endif }; struct snd_soc_dai_link { -- cgit v1.1 From 5ac2ba9452b0a59df6cec10e8d27c52cf0b41a43 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 16 Feb 2012 17:08:13 -0800 Subject: ALSA: core: Constify the name in new kcontrols We never modify it and this lets us use a const string as the name without warnings. Signed-off-by: Mark Brown Reviewed-by: Takashi Iwai Acked-by: Liam Girdwood --- include/sound/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/sound') diff --git a/include/sound/control.h b/include/sound/control.h index b2796e8..57815f6 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -40,7 +40,7 @@ struct snd_kcontrol_new { snd_ctl_elem_iface_t iface; /* interface identifier */ unsigned int device; /* device/client number */ unsigned int subdevice; /* subdevice (substream) number */ - unsigned char *name; /* ASCII name of item */ + const unsigned char *name; /* ASCII name of item */ unsigned int index; /* index of item */ unsigned int access; /* access rights */ unsigned int count; /* count of same elements */ -- cgit v1.1 From ce0e9f0ede349097c849db9c3aa7e947fc443552 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 16 Feb 2012 11:02:11 -0800 Subject: ASoC: dapm: Unexport snd_soc_dapm_new_control() Everything now uses snd_soc_dapm_new_controls() instead so we don't need to make it part of the external API. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dapm.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index db8435a..c28d20b 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -352,8 +352,6 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uncontrol); int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uncontrol); -int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, - const struct snd_soc_dapm_widget *widget); int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget, int num); -- cgit v1.1 From 7bd3a6f34cdd4b1776ca34d0b6fab216e9323759 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 16 Feb 2012 15:03:27 -0800 Subject: ASoC: dapm: Supply the DAI and substream when calling stream events In order to allow us to do something smarter than iterate through widgets doing strcmp() to work out what to power up for stream events change the interface used to generate them to be based on the combination of a DAI and a stream direction rather than just a simple string identifying the stream. At some point we'll probably want a set of channels too. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dapm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index c28d20b..c32c521 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -365,8 +365,8 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_route *route, int num); /* dapm events */ -int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, - const char *stream, int event); +int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, + struct snd_soc_dai *dai, int event); void snd_soc_dapm_shutdown(struct snd_soc_card *card); /* external DAPM widget events */ -- cgit v1.1 From 3056557f3b2387d4ac99ca8af14956cd2bf003c2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 16 Feb 2012 17:07:42 -0800 Subject: ASoC: dapm: Constify lots of names that are never modified Neater and avoids warnings when used in other places where const strings are desired. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dapm.h | 8 ++++---- include/sound/soc.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index c32c521..91eb812 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -445,8 +445,8 @@ struct snd_soc_dapm_route { /* dapm audio path between two widgets */ struct snd_soc_dapm_path { - char *name; - char *long_name; + const char *name; + const char *long_name; /* source (input) and sink (output) widgets */ struct snd_soc_dapm_widget *source; @@ -469,8 +469,8 @@ struct snd_soc_dapm_path { /* dapm widget */ struct snd_soc_dapm_widget { enum snd_soc_dapm_type id; - char *name; /* widget name */ - char *sname; /* stream name */ + const char *name; /* widget name */ + const char *sname; /* stream name */ struct snd_soc_codec *codec; struct snd_soc_platform *platform; struct list_head list; diff --git a/include/sound/soc.h b/include/sound/soc.h index 8fa4dca..1e16d6e 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -366,7 +366,7 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); *Controls */ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, - void *data, char *long_name, + void *data, const char *long_name, const char *prefix); int snd_soc_add_codec_controls(struct snd_soc_codec *codec, const struct snd_kcontrol_new *controls, int num_controls); -- cgit v1.1 From 888df395ebc5c88cde45478660197ca46665efe2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 16 Feb 2012 19:37:51 -0800 Subject: ASoC: dapm: Implement and instantiate DAI widgets In order to allow us to do smarter things with DAI links create DAPM widgets which directly represent the DAIs in the DAPM graph. These are automatically created from the DAIs as we probe the card with references held in both directions between the widget and the DAI. The widgets are not made available for direct instantiation by drivers, they are created automatically from the DAIs. Drivers should be updated to create stream routes using DAPM maps rather than by annotating AIF and DAC widgets with streams. In order to ease transition to this model from existing drivers we automatically create DAPM routes between the DAI widgets and the existing stream widgets which are started and stopped by the DAI widgets, though the old stream handling mechanism is still in place. This also has the nice effect of removing non-DAPM devices as any device with a DAI acquires a widget automatically which will allow future simplifications to the core DAPM logic. The intention is that in future the AIF and DAI widgets will gain the ability to interact such that we are able to manage activity on individual channels independantly rather than powering up and down the entire AIF as we do currently. Currently we only generate these for CODECs, mostly as I have no systems with non-CODEC DAPM to integrate with. It should be a simple matter of programming to add the additional hookup for these. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dai.h | 4 ++++ include/sound/soc-dapm.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 2413acc..adb07fc 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -17,6 +17,7 @@ #include struct snd_pcm_substream; +struct snd_soc_dapm_widget; /* * DAI hardware audio formats. @@ -238,6 +239,9 @@ struct snd_soc_dai { unsigned char pop_wait:1; unsigned char probed:1; + struct snd_soc_dapm_widget *playback_widget; + struct snd_soc_dapm_widget *capture_widget; + /* DAI DMA data */ void *playback_dma_data; void *capture_dma_data; diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 91eb812..e46107f 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -355,6 +355,9 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget, int num); +int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, + struct snd_soc_dai *dai); +int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card); /* dapm path setup */ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm); @@ -425,6 +428,7 @@ enum snd_soc_dapm_type { snd_soc_dapm_aif_in, /* audio interface input */ snd_soc_dapm_aif_out, /* audio interface output */ snd_soc_dapm_siggen, /* signal generator */ + snd_soc_dapm_dai, /* link to DAI structure */ }; /* -- cgit v1.1 From 7da9ced6066c654a22836c24bae509ef323e10a8 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 3 Feb 2012 00:59:33 -0800 Subject: ASoC: fsi: Add DMAEngine support This patch supports DMAEngine to FSI driver. It supports only Tx case at this point. If platform/cpu doesn't support DMAEngine, FSI driver will use PIO transfer. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- include/sound/sh_fsi.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/sound') diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h index 78cd77a..b457e87 100644 --- a/include/sound/sh_fsi.h +++ b/include/sound/sh_fsi.h @@ -74,6 +74,8 @@ struct sh_fsi_port_info { unsigned long flags; + int tx_id; + int rx_id; int (*set_rate)(struct device *dev, int rate, int enable); }; -- cgit v1.1 From 71d08516b80638a69d5efea4e8cb832c053f9dd9 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 10 Oct 2011 18:31:26 +0100 Subject: ASoC: core: Add SND_SOC_BYTES control for coefficient blocks Allow devices to export blocks of registers to the application layer, intended for use for reading and writing coefficient data which can't usefully be worked with by the kernel at runtime (for example, due to requiring complex and expensive calculations or being the results of callibration procedures). Currently drivers are using platform data to provide configurations for coefficient blocks which isn't at all convenient for runtime management or configuration development. Currently only devices using regmap are supported, an error will be generated for any attempt to work with a byte control on a non-regmap device. There's no fundamental block to other devices so support could be added if required. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 1e16d6e..3e9cae0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -185,6 +185,12 @@ .rreg = xreg_right, .shift = xshift, \ .min = xmin, .max = xmax} } +#define SND_SOC_BYTES(xname, xbase, xregs) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ + .put = snd_soc_bytes_put, .private_value = \ + ((unsigned long)&(struct soc_bytes) \ + {.base = xbase, .num_regs = xregs }) } /* * Simplified versions of above macros, declaring a struct and calculating @@ -413,6 +419,13 @@ int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_soc_bytes_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo); +int snd_soc_bytes_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); +int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol); + /** * struct snd_soc_reg_access - Describes whether a given register is @@ -888,6 +901,11 @@ struct soc_mixer_control { unsigned int reg, rreg, shift, rshift, invert; }; +struct soc_bytes { + int base; + int num_regs; +}; + /* enumerated kcontrol */ struct soc_enum { unsigned short reg; -- cgit v1.1 From f831b055ececb3172f7fe498db5ca1fb43ff644d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 17 Feb 2012 16:20:33 -0800 Subject: ASoC: core: Add support for masking out parts of coefficient blocks Chip designers frequently include things like the enable and disable controls for algorithms in the register blocks which also hold the coefficients. Since it's desirable to split out the enable/disable control from userspace the plain SND_SOC_BYTES() isn't optimal for these devices. Add a SND_SOC_BYTES_MASK() which allows a bitmask from the first word of the block to be excluded from the control. This supports the needs of devices I've looked at and lets us have a reasonably simple API. Further controls can be added in future if that's needed. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 3e9cae0..82bd773 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -192,6 +192,14 @@ ((unsigned long)&(struct soc_bytes) \ {.base = xbase, .num_regs = xregs }) } +#define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \ + .put = snd_soc_bytes_put, .private_value = \ + ((unsigned long)&(struct soc_bytes) \ + {.base = xbase, .num_regs = xregs, \ + .mask = xmask }) } + /* * Simplified versions of above macros, declaring a struct and calculating * ARRAY_SIZE internally @@ -904,6 +912,7 @@ struct soc_mixer_control { struct soc_bytes { int base; int num_regs; + u32 mask; }; /* enumerated kcontrol */ -- cgit v1.1 From e7f73a1613567ac82314f33956c0f3810bf1efb2 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 22 Feb 2012 10:49:08 +0100 Subject: ASoC: Add dmaengine PCM helper functions This patch adds a set of functions which are intended to be used when implementing a dmaengine based sound PCM driver. Signed-off-by: Lars-Peter Clausen Tested-by: Shawn Guo Acked-by: Vinod Koul Signed-off-by: Mark Brown --- include/sound/dmaengine_pcm.h | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 include/sound/dmaengine_pcm.h (limited to 'include/sound') diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h new file mode 100644 index 0000000..a8fcaa6 --- /dev/null +++ b/include/sound/dmaengine_pcm.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012, Analog Devices Inc. + * Author: Lars-Peter Clausen + * + * 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. + * + * 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., + * 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +#ifndef __SOUND_DMAENGINE_PCM_H__ +#define __SOUND_DMAENGINE_PCM_H__ + +#include +#include + +/** + * snd_pcm_substream_to_dma_direction - Get dma_transfer_direction for a PCM + * substream + * @substream: PCM substream + */ +static inline enum dma_transfer_direction +snd_pcm_substream_to_dma_direction(const struct snd_pcm_substream *substream) +{ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + return DMA_MEM_TO_DEV; + else + return DMA_DEV_TO_MEM; +} + +void snd_dmaengine_pcm_set_data(struct snd_pcm_substream *substream, void *data); +void *snd_dmaengine_pcm_get_data(struct snd_pcm_substream *substream); + +int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, + const struct snd_pcm_hw_params *params, struct dma_slave_config *slave_config); +int snd_dmaengine_pcm_trigger(struct snd_pcm_substream *substream, int cmd); +snd_pcm_uframes_t snd_dmaengine_pcm_pointer(struct snd_pcm_substream *substream); + +int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream, + dma_filter_fn filter_fn, void *filter_data); +int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream); + +struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream); + +#endif -- cgit v1.1 From 2466ab9709bf7375ef8b8ad16f39008ce6e6bc8a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 2 Mar 2012 16:18:30 +0000 Subject: ASoC: core: Split the union for CODEC/platform in the DAI There's now core code which falls back to global CODEC operations for DAI calls that needs to be able to tell if it's dealing with a CPU or CODEC DAI and given the small number of DAIs in a typical system and overall memory usage pattern saving a pointer per DAI is really not worth the effort. Reported-by: Ian Lartey Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/soc-dai.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index adb07fc..c429f24 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -250,10 +250,9 @@ struct snd_soc_dai { unsigned int rate; /* parent platform/codec */ - union { - struct snd_soc_platform *platform; - struct snd_soc_codec *codec; - }; + struct snd_soc_platform *platform; + struct snd_soc_codec *codec; + struct snd_soc_card *card; struct list_head list; -- cgit v1.1 From cc22d37e7f5e1745658760660f03793913f43e49 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 6 Mar 2012 18:16:18 +0000 Subject: ASoC: core: Add platform component mutex Add mutex support for platform IO operations. e.g. can be used for platform DAPM widget IO ops. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 82bd773..2ebf787 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -718,6 +718,7 @@ struct snd_soc_platform { int id; struct device *dev; struct snd_soc_platform_driver *driver; + struct mutex mutex; unsigned int suspended:1; /* platform is suspended */ unsigned int probed:1; -- cgit v1.1