From 6d4baf084f4d8dc43cf5d5a3c182018604afa80c Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 20 Sep 2011 15:44:21 +0100 Subject: ASoC: Add WM5100 driver The WM5100 is a highly integrated low power audio subsystem with advanced digital signal processing capabilities including effects, speech clarity enhancement and active noise cancellation. This initial driver provides support for basic audio paths, further patches will provide more complete functionality. Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- include/sound/wm5100.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/sound/wm5100.h (limited to 'include/sound') diff --git a/include/sound/wm5100.h b/include/sound/wm5100.h new file mode 100644 index 0000000..617d0c4 --- /dev/null +++ b/include/sound/wm5100.h @@ -0,0 +1,59 @@ +/* + * linux/sound/wm5100.h -- Platform data for WM5100 + * + * Copyright 2011 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_WM5100_H +#define __LINUX_SND_WM5100_H + +enum wm5100_in_mode { + WM5100_IN_SE = 0, + WM5100_IN_DIFF = 1, + WM5100_IN_DMIC = 2, +}; + +enum wm5100_dmic_sup { + WM5100_DMIC_SUP_MICVDD = 0, + WM5100_DMIC_SUP_MICBIAS1 = 1, + WM5100_DMIC_SUP_MICBIAS2 = 2, + WM5100_DMIC_SUP_MICBIAS3 = 3, +}; + +enum wm5100_micdet_bias { + WM5100_MICDET_MICBIAS1 = 0, + WM5100_MICDET_MICBIAS2 = 1, + WM5100_MICDET_MICBIAS3 = 2, +}; + +struct wm5100_jack_mode { + enum wm5100_micdet_bias bias; + int hp_pol; + int micd_src; +}; + +#define WM5100_GPIO_SET 0x10000 + +struct wm5100_pdata { + int reset; /** GPIO controlling /RESET, if any */ + int ldo_ena; /** GPIO controlling LODENA, if any */ + int hp_pol; /** GPIO controlling headset polarity, if any */ + int irq_flags; + int gpio_base; + + struct wm5100_jack_mode jack_modes[2]; + + /* Input pin mode selection */ + enum wm5100_in_mode in_mode[4]; + + /* DMIC supply selection */ + enum wm5100_dmic_sup dmic_sup[4]; + + int gpio_defaults[6]; +}; + +#endif -- cgit v1.1 From de02d0786d4075091f5b1860474cd21d85ff5862 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 20 Sep 2011 21:43:24 +0100 Subject: ASoC: Trace and collect statistics for DAPM graph walking One of the longest standing areas for improvement in ASoC has been the DAPM algorithm - it repeats the same checks many times whenever it is run and makes no effort to limit the areas of the graph it checks meaning we do an awful lot of walks over the full graph. This has never mattered too much as the size of the graph has generally been small in relation to the size of the devices supported and the speed of CPUs but it is annoying. In preparation for work on improving this insert a trace point after the graph walk has been done. This gives us specific timing information for the walk, and in order to give quantifiable (non-benchmark) numbers also count every time we check a link or check the power for a widget and report those numbers. Substantial changes in the algorithm may require tweaks to the stats but they should be useful for simpler things. Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 5 +++++ include/sound/soc.h | 1 + 2 files changed, 6 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 350b1b3..0e2d017 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -537,4 +537,9 @@ struct snd_soc_dapm_widget_list { struct snd_soc_dapm_widget *widgets[0]; }; +struct snd_soc_dapm_stats { + int power_checks; + int path_checks; +}; + #endif diff --git a/include/sound/soc.h b/include/sound/soc.h index 24e17be..006f4f6 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -828,6 +828,7 @@ struct snd_soc_card { /* Generic DAPM context for the card */ struct snd_soc_dapm_context dapm; + struct snd_soc_dapm_stats dapm_stats; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_card_root; -- cgit v1.1 From 17841020e9d3dbd4e8114c2142c2bc6d45c01da1 Mon Sep 17 00:00:00 2001 From: Dong Aisheng Date: Mon, 29 Aug 2011 17:15:14 +0800 Subject: ASoC: soc-core: symmetry checking for each DAIs separately The orginal code does not cover the case that one DAI such as codec may be shared between other two DAIs(CPU). When do symmetry checking, altough the codec DAI requires symmetry, the two CPU DAIs may still be configured to run on different rates. We change to check each DAI's state separately instead of only checking the dai link to prevent this issue. Signed-off-by: Dong Aisheng Tested-by: Wolfram Sang Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- include/sound/soc-dai.h | 3 +++ include/sound/soc.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 5ad5f3a..12d98b43 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -242,6 +242,9 @@ struct snd_soc_dai { void *playback_dma_data; void *capture_dma_data; + /* Symmetry data - only valid if symmetry is being enforced */ + unsigned int rate; + /* parent platform/codec */ union { struct snd_soc_platform *platform; diff --git a/include/sound/soc.h b/include/sound/soc.h index 006f4f6..b499b37 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -851,8 +851,6 @@ struct snd_soc_pcm_runtime { unsigned int complete:1; unsigned int dev_registered:1; - /* Symmetry data - only valid if symmetry is being enforced */ - unsigned int rate; long pmdown_time; /* runtime devices */ -- cgit v1.1 From 0722d055ac2236da4e319d22a99c9f7e82dbdd5d Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 30 Aug 2011 14:39:54 +0300 Subject: ASoC: tpa6130a2: Remove model_id from platform data The model_id is no longer needed within the platform_data for the TPA driver since the model of TPA specified with the device name (tpa6130a2/tpa6140a2). Also update rx51 (the only affected user) to use the device name rather than platform data. Signed-off-by: Peter Ujfalusi Tested-by: Jarkko Nikula Acked-by: Liam Girdwood Acked-by: Tony Lindgren Signed-off-by: Mark Brown --- include/sound/tpa6130a2-plat.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include/sound') diff --git a/include/sound/tpa6130a2-plat.h b/include/sound/tpa6130a2-plat.h index 89beccb5..4cc1093 100644 --- a/include/sound/tpa6130a2-plat.h +++ b/include/sound/tpa6130a2-plat.h @@ -23,13 +23,7 @@ #ifndef TPA6130A2_PLAT_H #define TPA6130A2_PLAT_H -enum tpa_model { - TPA6130A2, - TPA6140A2, -}; - struct tpa6130a2_platform_data { - enum tpa_model id; int power_gpio; }; -- cgit v1.1 From e56235e099d7290a2331b984a79f75bbe0865fe8 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 21 Sep 2011 18:19:14 +0100 Subject: ASoC: Add another DAPM stat for neighbour checks The number of times we look at a potentially connected neighbour is just as important as the number of times we actually recurse into looking at that neighbour so also collect that statistic. Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 0e2d017..bb59532 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -540,6 +540,7 @@ struct snd_soc_dapm_widget_list { struct snd_soc_dapm_stats { int power_checks; int path_checks; + int neighbour_checks; }; #endif -- cgit v1.1 From 213eb0fb1e8e4ddfb8ffdb239c45ba2a1eef3dc2 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 21 Sep 2011 20:54:47 +0100 Subject: ASoC: Add platform data for WM1250 EV1 GPIOs The WM1250 EV1 has some GPIOs which can be used to control the behaviour at runtime. Request them all if supplied and add a set_bias_level() function to start and stop the clocks. Signed-off-by: Mark Brown --- include/sound/wm1250-ev1.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 include/sound/wm1250-ev1.h (limited to 'include/sound') diff --git a/include/sound/wm1250-ev1.h b/include/sound/wm1250-ev1.h new file mode 100644 index 0000000..7dff828 --- /dev/null +++ b/include/sound/wm1250-ev1.h @@ -0,0 +1,27 @@ +/* + * linux/sound/wm1250-ev1.h - Platform data for WM1250-EV1 + * + * Copyright 2011 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_WM1250_EV1_H +#define __LINUX_SND_WM1250_EV1_H + +#define WM1250_EV1_NUM_GPIOS 5 + +#define WM1250_EV1_GPIO_CLK_ENA 0 +#define WM1250_EV1_GPIO_CLK_SEL0 1 +#define WM1250_EV1_GPIO_CLK_SEL1 2 +#define WM1250_EV1_GPIO_OSR 3 +#define WM1250_EV1_GPIO_MASTER 4 + + +struct wm1250_ev1_pdata { + int gpios[WM1250_EV1_NUM_GPIOS]; +}; + +#endif -- cgit v1.1 From 75d9ac46b99280f5f381927ae75a9eaf21844d20 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 27 Sep 2011 16:41:01 +0100 Subject: ASoC: Allow DAI formats to be specified in the dai_link For almost all machines the DAI format is a constant, always set to the same thing. This means that not only should we normally set it on init rather than in hw_params() (where it has been for historical reasons) we should also allow users to configure this by setting a variable in the dai_link structure. The combination of these two will make many machine drivers even more data driven. Implement a new dai_fmt field in the dai_link doing just that. Since 0 is a valid value for many format flags and we need to be able to tell if the field is actually set also add one to all the values used to configure formats. Signed-off-by: Mark Brown --- include/sound/soc-dai.h | 34 +++++++++++++++++----------------- include/sound/soc.h | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 12d98b43..2413acc 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -24,13 +24,13 @@ struct snd_pcm_substream; * Describes the physical PCM data formating and clocking. Add new formats * to the end. */ -#define SND_SOC_DAIFMT_I2S 0 /* I2S mode */ -#define SND_SOC_DAIFMT_RIGHT_J 1 /* Right Justified mode */ -#define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */ -#define SND_SOC_DAIFMT_DSP_A 3 /* L data MSB after FRM LRC */ -#define SND_SOC_DAIFMT_DSP_B 4 /* L data MSB during FRM LRC */ -#define SND_SOC_DAIFMT_AC97 5 /* AC97 */ -#define SND_SOC_DAIFMT_PDM 6 /* Pulse density modulation */ +#define SND_SOC_DAIFMT_I2S 1 /* I2S mode */ +#define SND_SOC_DAIFMT_RIGHT_J 2 /* Right Justified mode */ +#define SND_SOC_DAIFMT_LEFT_J 3 /* Left Justified mode */ +#define SND_SOC_DAIFMT_DSP_A 4 /* L data MSB after FRM LRC */ +#define SND_SOC_DAIFMT_DSP_B 5 /* L data MSB during FRM LRC */ +#define SND_SOC_DAIFMT_AC97 6 /* AC97 */ +#define SND_SOC_DAIFMT_PDM 7 /* Pulse density modulation */ /* left and right justified also known as MSB and LSB respectively */ #define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J @@ -42,8 +42,8 @@ struct snd_pcm_substream; * DAI bit clocks can be be gated (disabled) when the DAI is not * sending or receiving PCM data in a frame. This can be used to save power. */ -#define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */ -#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated */ +#define SND_SOC_DAIFMT_CONT (1 << 4) /* continuous clock */ +#define SND_SOC_DAIFMT_GATED (2 << 4) /* clock is gated */ /* * DAI hardware signal inversions. @@ -51,10 +51,10 @@ struct snd_pcm_substream; * Specifies whether the DAI can also support inverted clocks for the specified * format. */ -#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */ -#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal BCLK + inv FRM */ -#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert BCLK + nor FRM */ -#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert BCLK + FRM */ +#define SND_SOC_DAIFMT_NB_NF (1 << 8) /* normal bit clock + frame */ +#define SND_SOC_DAIFMT_NB_IF (2 << 8) /* normal BCLK + inv FRM */ +#define SND_SOC_DAIFMT_IB_NF (3 << 8) /* invert BCLK + nor FRM */ +#define SND_SOC_DAIFMT_IB_IF (4 << 8) /* invert BCLK + FRM */ /* * DAI hardware clock masters. @@ -63,10 +63,10 @@ struct snd_pcm_substream; * i.e. if the codec is clk and FRM master then the interface is * clk and frame slave. */ -#define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & FRM master */ -#define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & FRM master */ -#define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */ -#define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & FRM slave */ +#define SND_SOC_DAIFMT_CBM_CFM (1 << 12) /* codec clk & FRM master */ +#define SND_SOC_DAIFMT_CBS_CFM (2 << 12) /* codec clk slave & FRM master */ +#define SND_SOC_DAIFMT_CBM_CFS (3 << 12) /* codec clk master & frame slave */ +#define SND_SOC_DAIFMT_CBS_CFS (4 << 12) /* codec clk & FRM slave */ #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0 diff --git a/include/sound/soc.h b/include/sound/soc.h index b499b37..a4dc699 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -713,6 +713,8 @@ struct snd_soc_dai_link { const char *cpu_dai_name; const char *codec_dai_name; + unsigned int dai_fmt; /* format to set on init */ + /* Keep DAI active over suspend */ unsigned int ignore_suspend:1; -- cgit v1.1 From 460acbec1e7ba727519689902f51a6257279bbae Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 4 Oct 2011 14:39:38 +0300 Subject: ASoC: core: Introduce SOC_DOUBLE_VALUE macro With the new macro we can remove duplicated code for the SOC_DOUBLE type of controls. We can also remap the SOC_SINGLE_VALUE macro to SOC_DOUBLE_VALUE Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index a4dc699..3d7c7f7 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -28,10 +28,12 @@ /* * Convenience kcontrol builders */ -#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ +#define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert) \ ((unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \ - .platform_max = xmax, .invert = xinvert}) + {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ + .max = xmax, .platform_max = xmax, .invert = xinvert}) +#define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ + SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert) #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ ((unsigned long)&(struct soc_mixer_control) \ {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert}) @@ -48,13 +50,12 @@ .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ .put = snd_soc_put_volsw, \ .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } -#define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \ +#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ .put = snd_soc_put_volsw, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ + max, invert) } #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .info = snd_soc_info_volsw_2r, \ @@ -62,16 +63,15 @@ .private_value = (unsigned long)&(struct soc_mixer_control) \ {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ .max = xmax, .platform_max = xmax, .invert = xinvert} } -#define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \ +#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, 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 = snd_soc_put_volsw, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right,\ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \ + max, invert) } #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ @@ -121,14 +121,13 @@ .info = snd_soc_info_volsw, \ .get = xhandler_get, .put = xhandler_put, \ .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) } -#define SOC_DOUBLE_EXT(xname, xreg, shift_left, shift_right, xmax, xinvert,\ +#define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\ xhandler_get, xhandler_put) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ .info = snd_soc_info_volsw, \ .get = xhandler_get, .put = xhandler_put, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = \ + SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert) } #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ xhandler_get, xhandler_put, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ @@ -146,9 +145,8 @@ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw, \ .get = xhandler_get, .put = xhandler_put, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \ + xmax, xinvert) } #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\ xhandler_get, xhandler_put, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ -- cgit v1.1 From cdffa775e72de3a3d3ddccd04eb4eb94d58e84e6 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 4 Oct 2011 14:39:39 +0300 Subject: ASoC: core: Introduce SOC_DOUBLE_R_VALUE macro With the new macro we can remove duplicated code for the SOC_DOUBLE_R type of controls. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 3d7c7f7..9d0524a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -37,6 +37,10 @@ #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ ((unsigned long)&(struct soc_mixer_control) \ {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert}) +#define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \ + ((unsigned long)&(struct soc_mixer_control) \ + {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \ + .max = xmax, .platform_max = xmax, .invert = xinvert}) #define SOC_SINGLE(xname, reg, shift, max, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ @@ -60,9 +64,8 @@ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .info = snd_soc_info_volsw_2r, \ .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ + xmax, xinvert) } #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ @@ -79,9 +82,8 @@ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw_2r, \ .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ + xmax, xinvert) } #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ @@ -155,9 +157,8 @@ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw_2r, \ .get = xhandler_get, .put = xhandler_put, \ - .private_value = (unsigned long)&(struct soc_mixer_control) \ - {.reg = reg_left, .rreg = reg_right, .shift = xshift, \ - .max = xmax, .platform_max = xmax, .invert = xinvert} } + .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ + xmax, xinvert) } #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ .info = snd_soc_info_bool_ext, \ -- cgit v1.1 From db432b414e20b7218bbd91654d7be9c524a4337a Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 3 Oct 2011 21:06:40 +0100 Subject: ASoC: Do DAPM power checks only for widgets changed since last run In order to reduce the number of DAPM power checks we run keep a list of widgets which have been changed since the last DAPM run and iterate over that rather than the full widget list. Whenever we change the power state for a widget we add all the source and sink widgets it has to the dirty list, ensuring that all widgets in the path are checked. This covers more widgets than we need to as some of the neighbour widgets won't be connected but it's simpler as a first step. On one system I tried this gave: Power Path Neighbour Before: 207 1939 2461 After: 114 1066 1327 which seems useful. Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 1 + include/sound/soc.h | 1 + 2 files changed, 2 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index bb59532..c080635 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -492,6 +492,7 @@ struct snd_soc_dapm_widget { /* used during DAPM updates */ struct list_head power_list; + struct list_head dirty; }; struct snd_soc_dapm_update { diff --git a/include/sound/soc.h b/include/sound/soc.h index 9d0524a..8ab1cfe 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -826,6 +826,7 @@ struct snd_soc_card { struct list_head widgets; struct list_head paths; struct list_head dapm_list; + struct list_head dapm_dirty; /* Generic DAPM context for the card */ struct snd_soc_dapm_context dapm; -- cgit v1.1 From 9b8a83b205bd07b06784028effd94515fe9278c3 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 4 Oct 2011 22:15:59 +0100 Subject: ASoC: Only run power_check() on a widget once per run Some widgets will get power_check() run on them more than once during a DAPM run, most commonly due to supply widgets checking to see if their consumers are powered up. It's wasteful to do this so cache the result of power_check() during a run. For one system I tested this on I got an improvement of: Power Path Neighbour Before: 106 970 1186 After: 69 727 905 from this. Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index c080635..e2853da 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -473,6 +473,8 @@ struct snd_soc_dapm_widget { unsigned char ext:1; /* has external widgets */ unsigned char force:1; /* force state */ unsigned char ignore_suspend:1; /* kept enabled over suspend */ + unsigned char new_power:1; /* power from this run */ + unsigned char power_checked:1; /* power checked this run */ int subseq; /* sort within widget type */ int (*power_check)(struct snd_soc_dapm_widget *w); -- cgit v1.1 From 30d86ba47f79d566fffe9ba577caf247d06a3796 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 5 Oct 2011 10:29:22 +0300 Subject: ASoC: core: Change SOC_SINGLE/DOUBLE_VALUE representation SOC_SINGLE/DOUBLE_VALUE is used for mixer controls, where the bits are within one register. Assign .rreg to be the same as .reg for these types. With this change we can tell if the mixer in question: is mono: mc->reg == mc->rreg && mc->shift == mc->rshift is stereo, within single register: mc->reg == mc->rreg && mc->shift != mc->rshift is stereo, in two registers: mc->reg != mc->rreg The patch provide a small inline function to query, if the mixer is stereo, or mono. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 8ab1cfe..88ff2d8 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -30,8 +30,9 @@ */ #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert) \ ((unsigned long)&(struct soc_mixer_control) \ - {.reg = xreg, .shift = shift_left, .rshift = shift_right, \ - .max = xmax, .platform_max = xmax, .invert = xinvert}) + {.reg = xreg, .rreg = xreg, .shift = shift_left, \ + .rshift = shift_right, .max = xmax, .platform_max = xmax, \ + .invert = xinvert}) #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \ SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert) #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \ @@ -947,6 +948,18 @@ static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) INIT_LIST_HEAD(&card->dapm_list); } +static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc) +{ + if (mc->reg == mc->rreg && mc->shift == mc->rshift) + return 0; + /* + * mc->reg == mc->rreg && mc->shift != mc->rshift, or + * mc->reg != mc->rreg means that the control is + * stereo (bits in one register or in two registers) + */ + return 1; +} + int snd_soc_util_init(void); void snd_soc_util_exit(void); -- cgit v1.1 From e8f5a10307f7d224df91776033a0b8559a559844 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 5 Oct 2011 10:29:23 +0300 Subject: ASoC: core: Combine snd_soc_info_volsw/info_volsw_2r functions Handle the info_volsw/info_volsw_2r in one function. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 88ff2d8..2d0c1d2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -63,7 +63,7 @@ max, invert) } #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ - .info = snd_soc_info_volsw_2r, \ + .info = snd_soc_info_volsw, \ .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } @@ -81,7 +81,7 @@ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ SNDRV_CTL_ELEM_ACCESS_READWRITE,\ .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ + .info = snd_soc_info_volsw, \ .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } @@ -156,7 +156,7 @@ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ SNDRV_CTL_ELEM_ACCESS_READWRITE, \ .tlv.p = (tlv_array), \ - .info = snd_soc_info_volsw_2r, \ + .info = snd_soc_info_volsw, \ .get = xhandler_get, .put = xhandler_put, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } @@ -393,8 +393,6 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo); int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, -- cgit v1.1 From f7915d997554d4e2ce123c7a4ddd28e12c2e034c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 5 Oct 2011 10:29:24 +0300 Subject: ASoC: core: Combine snd_soc_get_volsw/get_volsw_2r functions Handle the get_volsw/get_volsw_2r in one function. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 2d0c1d2..e5e424e 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -64,7 +64,7 @@ #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \ @@ -82,7 +82,7 @@ SNDRV_CTL_ELEM_ACCESS_READWRITE,\ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ @@ -393,8 +393,6 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, -- cgit v1.1 From 974815ba4f88f3f12f6f01384e822b23be058323 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 5 Oct 2011 10:29:25 +0300 Subject: ASoC: core: Combine snd_soc_put_volsw/put_volsw_2r functions Handle the put_volsw/put_volsw_2r in one function. To avoid build breakage in twl6040 keep the snd_soc_put_volsw_2r as define, and map it snd_soc_put_volsw. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index e5e424e..1738c2b 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -64,7 +64,7 @@ #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \ @@ -82,7 +82,7 @@ SNDRV_CTL_ELEM_ACCESS_READWRITE,\ .tlv.p = (tlv_array), \ .info = snd_soc_info_volsw, \ - .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_2r, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ xmax, xinvert) } #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \ @@ -393,8 +393,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); +#define snd_soc_put_volsw_2r snd_soc_put_volsw int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, -- cgit v1.1 From 1576a5ff4929a4082307be0c69bb36826aafaad6 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 5 Oct 2011 10:29:27 +0300 Subject: ASoC: core: Remove snd_soc_put_volsw_2r definition We do not have users for snd_soc_put_volsw_2r anymore. It can be removed. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/sound') diff --git a/include/sound/soc.h b/include/sound/soc.h index 1738c2b..88ba85a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -393,7 +393,6 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -#define snd_soc_put_volsw_2r snd_soc_put_volsw int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, -- cgit v1.1 From a92f1394a184191d904872e0d3b8ef0c158e5021 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 6 Oct 2011 07:43:21 +0300 Subject: ASoC: fix codec breakage caused by the volsw/volsw_2r merger By accident few places still uses the _2r calls from the core. This is a quick fix, the drivers using the old callbacks going to be changed. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- 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 88ba85a..858291d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -393,6 +393,8 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +#define snd_soc_get_volsw_2r snd_soc_get_volsw +#define snd_soc_put_volsw_2r snd_soc_put_volsw int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol, -- cgit v1.1 From 024dc078558e64e4cebc62c096285430a61dd10e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sun, 9 Oct 2011 11:52:05 +0100 Subject: ASoC: Cache connected input and output recursions The number of connected input and output endpoints for a given widgets can't change during a DAPM run so there is no need to redo the recursion through branches of the tree we've already visited. Doing this on one of my test systems gives an improvement of: Power Path Neighbour Before: 63 607 731 After: 63 141 181 which scales up well as more widgets are involved in paths. Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index e2853da..bfefc16 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -495,6 +495,8 @@ struct snd_soc_dapm_widget { /* used during DAPM updates */ struct list_head power_list; struct list_head dirty; + int inputs; + int outputs; }; struct snd_soc_dapm_update { -- cgit v1.1 From 25c77c5fae5e0ef43ab6381f89fc41e26d2ca0f4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 8 Oct 2011 13:36:03 +0100 Subject: ASoC: Fix DAPM sync for TLV320AIC3x custom DAPM widget We really should be doing this in the core, not in a driver... Signed-off-by: Mark Brown Tested-by: Jarkko Nikula --- include/sound/soc-dapm.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/sound') diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index bfefc16..17a4c17 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -381,6 +381,9 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, const char *pin); +/* Mostly internal - should not normally be used */ +void dapm_mark_dirty(struct snd_soc_dapm_widget *w, const char *reason); + /* dapm widget types */ enum snd_soc_dapm_type { snd_soc_dapm_input = 0, /* input pin */ -- cgit v1.1 From 1d69c5c5de32c355667c105a5fac85c8043128e6 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 14 Oct 2011 14:43:33 +0300 Subject: ASoC: core: Add flag to ignore pmdown_time at pcm_close With this flag codec drivers can indicate that it is desired to ignore the pmdown_time for DAPM shutdown sequence when playback stream is stopped. The DAPM sequence will be executed without delay in this case. Signed-off-by: Peter Ujfalusi 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 858291d..11cfb59 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -578,6 +578,7 @@ struct snd_soc_codec { /* dapm */ struct snd_soc_dapm_context dapm; + unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_codec_root; -- cgit v1.1