From eb2535f542b4279b42518d6a312c6f7290434e55 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Apr 2015 08:49:25 +0000 Subject: ASoC: rsnd: add rsnd_dai_to_priv() macro Using standardized function/macro name is useful in driver Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 9f48d75fa992..a2a0b5768c44 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -272,9 +272,10 @@ struct rsnd_dai *rsnd_rdai_get(struct rsnd_priv *priv, int id) return priv->rdai + id; } +#define rsnd_dai_to_priv(dai) snd_soc_dai_get_drvdata(dai) static struct rsnd_dai *rsnd_dai_to_rdai(struct snd_soc_dai *dai) { - struct rsnd_priv *priv = snd_soc_dai_get_drvdata(dai); + struct rsnd_priv *priv = rsnd_dai_to_priv(dai); return rsnd_rdai_get(priv, dai->id); } @@ -351,7 +352,7 @@ struct rsnd_dai_stream *rsnd_rdai_to_io(struct rsnd_dai *rdai, static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct rsnd_priv *priv = snd_soc_dai_get_drvdata(dai); + struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); int ssi_id = rsnd_mod_id(rsnd_io_to_mod_ssi(io)); -- cgit v1.2.3 From e9c390df671fadc829550935ffb6b23549f26ded Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Apr 2015 08:49:49 +0000 Subject: ASoC: rsnd: make sure it uses lock when it calls rsnd_dai_call rsnd_dai_call() should be called under rsnd_lock Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index a2a0b5768c44..164653c0bc10 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -731,10 +731,15 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_dai *dai = rsnd_substream_to_dai(substream); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); + struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); + unsigned long flags; int ret; + rsnd_lock(priv, flags); ret = rsnd_dai_call(hw_params, io, substream, hw_params); + rsnd_unlock(priv, flags); + if (ret) return ret; @@ -919,14 +924,16 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod, static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->cpu_dai; + struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); - int ret; + unsigned long flags; + int ret = 0; - ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd); - if (ret) - return ret; + rsnd_lock(priv, flags); + ret |= rsnd_dai_call(pcm_new, &rdai->playback, rtd); + ret |= rsnd_dai_call(pcm_new, &rdai->capture, rtd); + rsnd_unlock(priv, flags); - ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd); if (ret) return ret; @@ -949,8 +956,11 @@ static const struct snd_soc_component_driver rsnd_soc_component = { static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, struct rsnd_dai_stream *io) { + unsigned long flags; int ret; + rsnd_lock(priv, flags); + ret = rsnd_dai_call(probe, io, priv); if (ret == -EAGAIN) { /* @@ -983,6 +993,7 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, */ ret = rsnd_dai_call(probe, io, priv); } + rsnd_unlock(priv, flags); return ret; } @@ -998,6 +1009,7 @@ static int rsnd_probe(struct platform_device *pdev) struct rsnd_dai *rdai; const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev); const struct rsnd_of_data *of_data; + unsigned long flags; int (*probe_func[])(struct platform_device *pdev, const struct rsnd_of_data *of_data, struct rsnd_priv *priv) = { @@ -1084,10 +1096,12 @@ static int rsnd_probe(struct platform_device *pdev) exit_snd_soc: snd_soc_unregister_platform(dev); exit_snd_probe: + rsnd_lock(priv, flags); for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); rsnd_dai_call(remove, &rdai->capture, priv); } + rsnd_unlock(priv, flags); return ret; } @@ -1096,6 +1110,7 @@ static int rsnd_remove(struct platform_device *pdev) { struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev); struct rsnd_dai *rdai; + unsigned long flags; void (*remove_func[])(struct platform_device *pdev, struct rsnd_priv *priv) = { rsnd_ssi_remove, @@ -1106,10 +1121,12 @@ static int rsnd_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); + rsnd_lock(priv, flags); for_each_rsnd_dai(rdai, priv, i) { ret |= rsnd_dai_call(remove, &rdai->playback, priv); ret |= rsnd_dai_call(remove, &rdai->capture, priv); } + rsnd_unlock(priv, flags); for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](pdev, priv); -- cgit v1.2.3 From 8c5c79a1cd51ce1b4fec8bbaecd17d599478bd27 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Apr 2015 08:50:12 +0000 Subject: ASoC: rsnd: tidyup SSI parent related function/macro names Current rsnd driver is using SSI parent related function/macro as "clock" related. but it is not only clock related. tidyup function/macro naming. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 7bb9c087f3dc..2ef48a44c4ab 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -80,7 +80,7 @@ struct rsnd_ssi { #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) #define rsnd_dma_to_ssi(dma) rsnd_mod_to_ssi(rsnd_dma_to_mod(dma)) #define rsnd_ssi_pio_available(ssi) ((ssi)->info->irq > 0) -#define rsnd_ssi_clk_from_parent(ssi) ((ssi)->parent) +#define rsnd_ssi_parent(ssi) ((ssi)->parent) #define rsnd_ssi_mode_flags(p) ((p)->info->flags) #define rsnd_ssi_dai_id(ssi) ((ssi)->info->dai_id) #define rsnd_ssi_of_node(priv) \ @@ -189,8 +189,10 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, rsnd_mod_hw_start(&ssi->mod); if (rsnd_rdai_is_clk_master(rdai)) { - if (rsnd_ssi_clk_from_parent(ssi)) - rsnd_ssi_hw_start(ssi->parent, io); + struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); + + if (ssi_parent) + rsnd_ssi_hw_start(ssi_parent, io); else rsnd_ssi_master_clk_start(ssi, io); } @@ -253,8 +255,10 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi) rsnd_ssi_status_check(&ssi->mod, IIRQ); if (rsnd_rdai_is_clk_master(rdai)) { - if (rsnd_ssi_clk_from_parent(ssi)) - rsnd_ssi_hw_stop(ssi->parent); + struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); + + if (ssi_parent) + rsnd_ssi_hw_stop(ssi_parent); else rsnd_ssi_master_clk_stop(ssi); } @@ -598,7 +602,7 @@ int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod) return !!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_CLK_PIN_SHARE); } -static void rsnd_ssi_parent_clk_setup(struct rsnd_priv *priv, struct rsnd_ssi *ssi) +static void rsnd_ssi_parent_setup(struct rsnd_priv *priv, struct rsnd_ssi *ssi) { if (!rsnd_ssi_is_pin_sharing(&ssi->mod)) return; @@ -732,7 +736,7 @@ int rsnd_ssi_probe(struct platform_device *pdev, if (ret) return ret; - rsnd_ssi_parent_clk_setup(priv, ssi); + rsnd_ssi_parent_setup(priv, ssi); } return 0; -- cgit v1.2.3 From 919567d914b3c134e60c01db72a03a0adc5f41b9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Apr 2015 08:50:30 +0000 Subject: ASoC: rsnd: make sure SSI parent/child uses same number of sound channel. SSI parent/child need to use same number of sound data channel if these are sharing clock/ws pin. this patch makes it sure. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 2ef48a44c4ab..5b89723c3206 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -66,6 +66,7 @@ struct rsnd_ssi { u32 cr_own; u32 cr_clk; + int chan; int err; unsigned int usrcnt; }; @@ -264,6 +265,8 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi) } rsnd_mod_hw_stop(&ssi->mod); + + ssi->chan = 0; } dev_dbg(dev, "%s[%d] hw stopped\n", @@ -340,6 +343,35 @@ static int rsnd_ssi_quit(struct rsnd_mod *mod, return 0; } +static int rsnd_ssi_hw_params(struct rsnd_mod *mod, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); + struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); + int chan = params_channels(params); + + /* + * Already working. + * It will happen if SSI has parent/child connection. + */ + if (ssi->usrcnt) { + /* + * it is error if child <-> parent SSI uses + * different channels. + */ + if (ssi->chan != chan) + return -EIO; + } + + /* It will be removed on rsnd_ssi_hw_stop */ + ssi->chan = chan; + if (ssi_parent) + return rsnd_ssi_hw_params(&ssi_parent->mod, substream, params); + + return 0; +} + static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status) { /* under/over flow error */ @@ -460,6 +492,7 @@ static struct rsnd_mod_ops rsnd_ssi_pio_ops = { .quit = rsnd_ssi_quit, .start = rsnd_ssi_start, .stop = rsnd_ssi_stop, + .hw_params = rsnd_ssi_hw_params, }; static int rsnd_ssi_dma_probe(struct rsnd_mod *mod, @@ -569,6 +602,7 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = { .start = rsnd_ssi_dma_start, .stop = rsnd_ssi_dma_stop, .fallback = rsnd_ssi_fallback, + .hw_params = rsnd_ssi_hw_params, }; int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod) -- cgit v1.2.3 From da620d722a7b7b16bf8571150acd7fd9e155809f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 10 Apr 2015 08:50:50 +0000 Subject: ASoC: rsnd: care snd_kcontrol's index rsnd might be used in multi-codec sound card. Then, same name kcontrol will be registered many times, and it will be error. This patch fixes this issue by using .index Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 164653c0bc10..99eb1093c569 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -839,12 +839,14 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod, struct rsnd_kctrl_cfg *cfg, void (*update)(struct rsnd_mod *mod)) { + struct snd_soc_card *soc_card = rtd->card; struct snd_card *card = rtd->card->snd_card; struct snd_kcontrol *kctrl; struct snd_kcontrol_new knew = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = name, .info = rsnd_kctrl_info, + .index = rtd - soc_card->rtd, .get = rsnd_kctrl_get, .put = rsnd_kctrl_put, .private_value = (unsigned long)cfg, -- cgit v1.2.3 From 596f74ec275b0ec608e9450c937c6a29ba91b352 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 27 Apr 2015 14:49:09 +0200 Subject: ASoC: rsnd: Use generic names for device nodes rcar_sound -> sound Signed-off-by: Geert Uytterhoeven Acked-by: Simon Horman Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/renesas,rsnd.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt index f316ce1f214a..62ece4c59da7 100644 --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt @@ -47,7 +47,7 @@ DAI subnode properties: Example: -rcar_sound: rcar_sound@ec500000 { +rcar_sound: sound@ec500000 { #sound-dai-cells = <1>; compatible = "renesas,rcar_sound-r8a7791", "renesas,rcar_sound-gen2"; reg = <0 0xec500000 0 0x1000>, /* SCU */ -- cgit v1.2.3 From ce883ccfef043257a3d679d389444ea805006587 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 30 Apr 2015 18:16:35 +0100 Subject: ASoC: qcom: Remove redundant error check. This patch remove redundant check after request_resource as ioremap would do the check anyway. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-cpu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c index 6698d058de29..1e284c667aa9 100644 --- a/sound/soc/qcom/lpass-cpu.c +++ b/sound/soc/qcom/lpass-cpu.c @@ -380,10 +380,6 @@ static int lpass_cpu_platform_probe(struct platform_device *pdev) platform_set_drvdata(pdev, drvdata); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpass-lpaif"); - if (!res) { - dev_err(&pdev->dev, "%s() error getting resource\n", __func__); - return -ENODEV; - } drvdata->lpaif = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR((void const __force *)drvdata->lpaif)) { -- cgit v1.2.3 From 3c803da266e1a960e0569a154acafb5703ae8b60 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 30 Apr 2015 18:16:44 +0100 Subject: ASoC: qcom: remove unnecessary header files This patch removes unnecessary header files in lpass cpu and platform code. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-cpu.c | 6 +----- sound/soc/qcom/lpass-platform.c | 6 ------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c index 1e284c667aa9..40842958f423 100644 --- a/sound/soc/qcom/lpass-cpu.c +++ b/sound/soc/qcom/lpass-cpu.c @@ -14,12 +14,7 @@ */ #include -#include -#include -#include -#include #include -#include #include #include #include @@ -28,6 +23,7 @@ #include #include #include + #include "lpass-lpaif-ipq806x.h" #include "lpass.h" diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index 2fa6280dfb23..ffc09287af7c 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -13,17 +13,11 @@ * lpass-platform.c -- ALSA SoC platform driver for QTi LPASS */ -#include -#include #include -#include #include #include #include -#include #include -#include -#include #include #include #include -- cgit v1.2.3 From a9843112b49af71f98c3953625555517f4a748bd Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 27 Apr 2015 12:15:02 +0200 Subject: ASoC: omap-twl4030: Use card DAPM context to access widgets Use the card DAPM context instead of the CODEC DAPM context since only card level widgets are accessed here. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/omap-twl4030.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index 3673ada43bfb..743131473056 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c @@ -159,9 +159,8 @@ static inline void twl4030_disconnect_pin(struct snd_soc_dapm_context *dapm, static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; struct snd_soc_card *card = rtd->card; - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_dapm_context *dapm = &card->dapm; struct omap_tw4030_pdata *pdata = dev_get_platdata(card->dev); struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card); int ret = 0; -- cgit v1.2.3 From 6b9aa50cd239ff78f6680d070315608a49218159 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 7 May 2015 21:27:46 +0200 Subject: ASoC: brownstone: Automatically disconnect non-connected pins Most DAPM input and output pins of the wm8994 are either used in the card's DAPM routing table or are marked as not connected. The only exception is DMIC2DAT input. Given that DMIC1DAT is explicitly mentioned in the DAPM routes lets assume that DMIC2DAT simply has been overlooked and should be marked as not connected. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/brownstone.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/sound/soc/pxa/brownstone.c b/sound/soc/pxa/brownstone.c index 79936e3e80e7..2b26318bc200 100644 --- a/sound/soc/pxa/brownstone.c +++ b/sound/soc/pxa/brownstone.c @@ -45,29 +45,6 @@ static const struct snd_soc_dapm_route brownstone_audio_map[] = { {"MICBIAS1", NULL, "Main Mic"}, }; -static int brownstone_wm8994_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - /* set endpoints to not connected */ - snd_soc_dapm_nc_pin(dapm, "HPOUT2P"); - snd_soc_dapm_nc_pin(dapm, "HPOUT2N"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT1N"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT1P"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT2N"); - snd_soc_dapm_nc_pin(dapm, "LINEOUT2P"); - snd_soc_dapm_nc_pin(dapm, "IN1LN"); - snd_soc_dapm_nc_pin(dapm, "IN1LP"); - snd_soc_dapm_nc_pin(dapm, "IN1RP"); - snd_soc_dapm_nc_pin(dapm, "IN2LP:VXRN"); - snd_soc_dapm_nc_pin(dapm, "IN2RN"); - snd_soc_dapm_nc_pin(dapm, "IN2RP:VXRP"); - snd_soc_dapm_nc_pin(dapm, "IN2LN"); - - return 0; -} - static int brownstone_wm8994_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -115,7 +92,6 @@ static struct snd_soc_dai_link brownstone_wm8994_dai[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &brownstone_ops, - .init = brownstone_wm8994_init, }, }; @@ -132,6 +108,7 @@ static struct snd_soc_card brownstone = { .num_dapm_widgets = ARRAY_SIZE(brownstone_dapm_widgets), .dapm_routes = brownstone_audio_map, .num_dapm_routes = ARRAY_SIZE(brownstone_audio_map), + .fully_routed = true, }; static int brownstone_probe(struct platform_device *pdev) -- cgit v1.2.3 From 9b44bacd584220e721fb477cfd6de457f34a4f11 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 7 May 2015 21:27:47 +0200 Subject: ASoC: poodle: Automatically disconnect non-connected pins The Zaurus SL-5600 seems to have a microphone input. Otherwise all DAPM input and output pins of the wm8731 are either used in the card's DAPM routing table or are marked as not connected. So add the microphone to the DAPM tables and set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/poodle.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index 0fce8c420e96..80b457ac522a 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -192,6 +192,7 @@ static int poodle_amp_event(struct snd_soc_dapm_widget *w, static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_SPK("Ext Spk", poodle_amp_event), +SND_SOC_DAPM_MIC("Microphone", NULL), }; /* Corgi machine connections to the codec pins */ @@ -204,6 +205,8 @@ static const struct snd_soc_dapm_route poodle_audio_map[] = { /* speaker connected to LOUT, ROUT */ {"Ext Spk", NULL, "ROUT"}, {"Ext Spk", NULL, "LOUT"}, + + {"MICIN", NULL, "Microphone"}, }; static const char *jack_function[] = {"Off", "Headphone"}; @@ -220,20 +223,6 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = { poodle_set_spk), }; -/* - * Logic for a wm8731 as connected on a Sharp SL-C7x0 Device - */ -static int poodle_wm8731_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - snd_soc_dapm_nc_pin(dapm, "LLINEIN"); - snd_soc_dapm_nc_pin(dapm, "RLINEIN"); - - return 0; -} - /* poodle digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link poodle_dai = { .name = "WM8731", @@ -242,7 +231,6 @@ static struct snd_soc_dai_link poodle_dai = { .codec_dai_name = "wm8731-hifi", .platform_name = "pxa-pcm-audio", .codec_name = "wm8731.0-001b", - .init = poodle_wm8731_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ops = &poodle_ops, @@ -261,6 +249,7 @@ static struct snd_soc_card poodle = { .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), .dapm_routes = poodle_audio_map, .num_dapm_routes = ARRAY_SIZE(poodle_audio_map), + .fully_routed = true, }; static int poodle_probe(struct platform_device *pdev) -- cgit v1.2.3 From c02e723f3e27f3bd32f24de473af69f0e39e8f79 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 7 May 2015 21:27:48 +0200 Subject: ASoC: tosa: Automatically disconnect non-connected pins Most DAPM input and output pins of the wm9712 are either used in the card's DAPM routing table or are marked as not connected. The only two exception are "PHONE" and "PCBEEP" input, lets assume that those were simply overlooked and that the routing table is complete. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/tosa.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index cb49284e853a..f59f566551ef 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c @@ -185,17 +185,6 @@ static const struct snd_kcontrol_new tosa_controls[] = { tosa_set_spk), }; -static int tosa_ac97_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; - - snd_soc_dapm_nc_pin(dapm, "OUT3"); - snd_soc_dapm_nc_pin(dapm, "MONOOUT"); - - return 0; -} - static struct snd_soc_dai_link tosa_dai[] = { { .name = "AC97", @@ -204,7 +193,6 @@ static struct snd_soc_dai_link tosa_dai[] = { .codec_dai_name = "wm9712-hifi", .platform_name = "pxa-pcm-audio", .codec_name = "wm9712-codec", - .init = tosa_ac97_init, .ops = &tosa_ops, }, { @@ -230,6 +218,7 @@ static struct snd_soc_card tosa = { .num_dapm_widgets = ARRAY_SIZE(tosa_dapm_widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), + .fully_routed = true, }; static int tosa_probe(struct platform_device *pdev) -- cgit v1.2.3 From 92ac4c5012a6505858c28be2dd5bf1c6f0dd26cf Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 7 May 2015 21:27:49 +0200 Subject: ASoC: z2: Automatically disconnect non-connected pins Most DAPM input and output pins of the wm8750 are either used in the card's DAPM routing table or are marked as not connected. The only exceptions are the LINPUT1, RINPUT1, LINPUT2 input pins. Lets assume that those were simply overlooked and that the routing table is complete. Set the fully_routed flag of the card instead of manually marking the unused inputs and outputs as not connected. This makes the code a bit shorter and cleaner. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/pxa/z2.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sound/soc/pxa/z2.c b/sound/soc/pxa/z2.c index bcbfbe8303f7..990b1aa6d7f6 100644 --- a/sound/soc/pxa/z2.c +++ b/sound/soc/pxa/z2.c @@ -132,16 +132,8 @@ static const struct snd_soc_dapm_route z2_audio_map[] = { */ static int z2_wm8750_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; int ret; - /* NC codec pins */ - snd_soc_dapm_disable_pin(dapm, "LINPUT3"); - snd_soc_dapm_disable_pin(dapm, "RINPUT3"); - snd_soc_dapm_disable_pin(dapm, "OUT3"); - snd_soc_dapm_disable_pin(dapm, "MONO1"); - /* Jack detection API stuff */ ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET, &hs_jack, hs_jack_pins, @@ -189,6 +181,7 @@ static struct snd_soc_card snd_soc_z2 = { .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), .dapm_routes = z2_audio_map, .num_dapm_routes = ARRAY_SIZE(z2_audio_map), + .fully_routed = true, }; static struct platform_device *z2_snd_device; -- cgit v1.2.3 From ae11a9be5a9bfc085ab3e0b7d2ea7cd01bc1d477 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 12 May 2015 01:57:50 +0000 Subject: ASoC: rsnd: revert lock for calls to rsnd_dai_call This reverts commit 'e9c390df671f ("ASoC: rsnd: make sure it uses lock when it calls rsnd_dai_call)' The additional locks make 1") lock issue when boot 2) lock issue when unbind/rmmod. And there is no problem without these locks. This patch revert it. Reported-by: Geert Uytterhoeven Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 99eb1093c569..405cacdbedfb 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -731,15 +731,10 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_dai *dai = rsnd_substream_to_dai(substream); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); - struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); - unsigned long flags; int ret; - rsnd_lock(priv, flags); ret = rsnd_dai_call(hw_params, io, substream, hw_params); - rsnd_unlock(priv, flags); - if (ret) return ret; @@ -926,16 +921,14 @@ int rsnd_kctrl_new_e(struct rsnd_mod *mod, static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->cpu_dai; - struct rsnd_priv *priv = rsnd_dai_to_priv(dai); struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); - unsigned long flags; - int ret = 0; + int ret; - rsnd_lock(priv, flags); - ret |= rsnd_dai_call(pcm_new, &rdai->playback, rtd); - ret |= rsnd_dai_call(pcm_new, &rdai->capture, rtd); - rsnd_unlock(priv, flags); + ret = rsnd_dai_call(pcm_new, &rdai->playback, rtd); + if (ret) + return ret; + ret = rsnd_dai_call(pcm_new, &rdai->capture, rtd); if (ret) return ret; @@ -958,11 +951,8 @@ static const struct snd_soc_component_driver rsnd_soc_component = { static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, struct rsnd_dai_stream *io) { - unsigned long flags; int ret; - rsnd_lock(priv, flags); - ret = rsnd_dai_call(probe, io, priv); if (ret == -EAGAIN) { /* @@ -995,7 +985,6 @@ static int rsnd_rdai_continuance_probe(struct rsnd_priv *priv, */ ret = rsnd_dai_call(probe, io, priv); } - rsnd_unlock(priv, flags); return ret; } @@ -1011,7 +1000,6 @@ static int rsnd_probe(struct platform_device *pdev) struct rsnd_dai *rdai; const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev); const struct rsnd_of_data *of_data; - unsigned long flags; int (*probe_func[])(struct platform_device *pdev, const struct rsnd_of_data *of_data, struct rsnd_priv *priv) = { @@ -1098,12 +1086,10 @@ static int rsnd_probe(struct platform_device *pdev) exit_snd_soc: snd_soc_unregister_platform(dev); exit_snd_probe: - rsnd_lock(priv, flags); for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); rsnd_dai_call(remove, &rdai->capture, priv); } - rsnd_unlock(priv, flags); return ret; } @@ -1112,7 +1098,6 @@ static int rsnd_remove(struct platform_device *pdev) { struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev); struct rsnd_dai *rdai; - unsigned long flags; void (*remove_func[])(struct platform_device *pdev, struct rsnd_priv *priv) = { rsnd_ssi_remove, @@ -1123,12 +1108,10 @@ static int rsnd_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); - rsnd_lock(priv, flags); for_each_rsnd_dai(rdai, priv, i) { ret |= rsnd_dai_call(remove, &rdai->playback, priv); ret |= rsnd_dai_call(remove, &rdai->capture, priv); } - rsnd_unlock(priv, flags); for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](pdev, priv); -- cgit v1.2.3 From 16f0acd0ca5dd6103df5b789553da86ff3d5c505 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 12 May 2015 01:23:00 -0300 Subject: ASoC: max98095: Pass the IRQF_ONESHOT flag Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail. So pass the IRQF_ONESHOT flag in this case. The semantic patch that makes this change is available in scripts/coccinelle/misc/irqf_oneshot.cocci. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/max98095.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 8fba0c3db798..e451d1f6d4a9 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -2301,8 +2301,8 @@ static int max98095_probe(struct snd_soc_codec *codec) /* register an audio interrupt */ ret = request_threaded_irq(client->irq, NULL, max98095_report_jack, - IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, - "max98095", codec); + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | + IRQF_ONESHOT, "max98095", codec); if (ret) { dev_err(codec->dev, "Failed to request IRQ: %d\n", ret); goto err_access; -- cgit v1.2.3 From 0574eab363ace70ef275d4caad6eadc458d33728 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 19 May 2015 14:47:32 +0200 Subject: ASoC: omap: fix up SND_OMAP_SOC_OMAP_ABE_TWL6040 dependency, again I tried to fix this before and submitted a working patch, but after some discussion we came up with what seemed to be a nicer solution, resulting in commit 3d4cf65e2d ("ASoC: omap: fix up SND_OMAP_SOC_OMAP_ABE_TWL6040 dependency"). Unfortunately, that version was incomplete, and we still get this build error: drivers/clk/clk-palmas.c:46:16: error: field 'hw' has incomplete type drivers/clk/clk-palmas.c: In function 'to_palmas_clks_info': drivers/clk/clk-palmas.c:54:74: warning: initialization from incompatible pointer type [-Winc This happens only in randconfig builds that turn on MFD_PALMAS on a platform other than OMAP2+ when COMPILE_TEST is set but COMMON_CLK is not. The new approach is only 'select COMMON_CLK_PALMAS' if we know that we are on an OMAP5 platform and MFD_PALMAS is already set. This patch has survived thousands of randconfig builds and I don't see a remaining hole in the logic. Fixes: 3d4cf65e2d ("ASoC: omap: fix up SND_OMAP_SOC_OMAP_ABE_TWL6040 dependency") Signed-off-by: Arnd Bergmann Acked-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 6768e4f7d7d0..30d0109703a9 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig @@ -100,12 +100,13 @@ config SND_OMAP_SOC_OMAP_TWL4030 config SND_OMAP_SOC_OMAP_ABE_TWL6040 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" - depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || SOC_OMAP5 || COMPILE_TEST) + depends on TWL6040_CORE && SND_OMAP_SOC + depends on ARCH_OMAP4 || (SOC_OMAP5 && MFD_PALMAS) || COMPILE_TEST select SND_OMAP_SOC_DMIC select SND_OMAP_SOC_MCPDM select SND_SOC_TWL6040 select SND_SOC_DMIC - select COMMON_CLK_PALMAS if MFD_PALMAS + select COMMON_CLK_PALMAS if (SOC_OMAP5 && MFD_PALMAS) help Say Y if you want to add support for SoC audio on OMAP boards using ABE and twl6040 codec. This driver currently supports: -- cgit v1.2.3 From b847357979048f718aa7e218050982ec9c306285 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 21 May 2015 03:49:13 +0000 Subject: ASoC: rsnd: indicate unknown HW start rsnd_ssi_hw_stop() should be called after rsnd_ssi_hw_start(). This patch indicates unknown hw_stop as error Signed-off-by: Kuninori Morimoto Tested-by: Keita Kobayashi Tested by: Cao Minh Hiep Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 5b89723c3206..927ac52a6d1e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -232,8 +232,10 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi) struct device *dev = rsnd_priv_to_dev(priv); u32 cr; - if (0 == ssi->usrcnt) /* stop might be called without start */ + if (0 == ssi->usrcnt) { + dev_err(dev, "%s called without starting\n", __func__); return; + } ssi->usrcnt--; -- cgit v1.2.3 From 5626ad0866657c4758958040589b395d2a58816d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 21 May 2015 03:49:54 +0000 Subject: ASoC: rsnd: add rsnd_dai_stream_quit() Current Renesas R-Car sound driver calls rsnd_dai_stream_init() when start, but it didn't call paired function. This patch adds rsnd_dai_stream_quit() for it. This is prepare for interrupt error status check feature support. Signed-off-by: Kuninori Morimoto Tested-by: Keita Kobayashi Tested by: Cao Minh Hiep Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 405cacdbedfb..2b7323c92994 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -315,7 +315,7 @@ void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int byte) } } -static int rsnd_dai_stream_init(struct rsnd_dai_stream *io, +static void rsnd_dai_stream_init(struct rsnd_dai_stream *io, struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -327,8 +327,11 @@ static int rsnd_dai_stream_init(struct rsnd_dai_stream *io, runtime->channels * samples_to_bytes(runtime, 1); io->next_period_byte = io->byte_per_period; +} - return 0; +static void rsnd_dai_stream_quit(struct rsnd_dai_stream *io) +{ + io->substream = NULL; } static @@ -363,9 +366,7 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd, switch (cmd) { case SNDRV_PCM_TRIGGER_START: - ret = rsnd_dai_stream_init(io, substream); - if (ret < 0) - goto dai_trigger_end; + rsnd_dai_stream_init(io, substream); ret = rsnd_platform_call(priv, dai, start, ssi_id); if (ret < 0) @@ -391,6 +392,8 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd, ret = rsnd_platform_call(priv, dai, stop, ssi_id); if (ret < 0) goto dai_trigger_end; + + rsnd_dai_stream_quit(io); break; default: ret = -EINVAL; -- cgit v1.2.3 From a7310c496f376b945e7e61f64d69c9c0a93ee1ee Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 21 May 2015 11:07:08 +0200 Subject: ASoC: qcom: remove incorrect dependencies Compile-tests show a warning for the newly added SND_SOC_STORM symbol: warning: (SND_SOC_STORM) selects SND_SOC_LPASS_CPU which has unmet direct dependencies (SOUND && !M68K && !UML && SND && SND_SOC && SND_SOC_QCOM) The problem is that it can be selected for COMPILE_TEST on non-QCOM builds, but the symbols it selects have a dependency. Dropping the dependencies makes it work without warnings and no other side-effects, because these are not user-visible. Signed-off-by: Arnd Bergmann Fixes: f380dd3f3cd ("ASoC: qcom: Add ability to build QCOM drivers") Signed-off-by: Mark Brown --- sound/soc/qcom/Kconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 5f58e4f1bca9..b07f183fc47f 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -6,12 +6,10 @@ config SND_SOC_QCOM config SND_SOC_LPASS_CPU tristate - depends on SND_SOC_QCOM select REGMAP_MMIO config SND_SOC_LPASS_PLATFORM tristate - depends on SND_SOC_QCOM select REGMAP_MMIO config SND_SOC_STORM -- cgit v1.2.3 From 9bae4880acee1cd7340d0566b55b927f92de89fb Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Sat, 16 May 2015 13:32:17 +0100 Subject: ASoC: qcom: move ipq806x specific bits out of lpass driver. This patch tries to make the lpass driver more generic by moving the ipq806x specific bits out of the cpu and platform driver, also allows the SOC specific drivers to add the correct register offsets. This patch also renames the register definition header file into more generic header file. Signed-off-by: Srinivas Kandagatla Tested-by: Kenneth Westfield Acked-by: Kenneth Westfield Signed-off-by: Mark Brown --- sound/soc/qcom/Kconfig | 9 +- sound/soc/qcom/Makefile | 2 + sound/soc/qcom/lpass-cpu.c | 157 ++++++++++++++++---------------- sound/soc/qcom/lpass-ipq806x.c | 96 +++++++++++++++++++ sound/soc/qcom/lpass-lpaif-ipq806x.h | 172 ----------------------------------- sound/soc/qcom/lpass-lpaif-reg.h | 126 +++++++++++++++++++++++++ sound/soc/qcom/lpass-platform.c | 49 ++++++---- sound/soc/qcom/lpass.h | 28 ++++++ 8 files changed, 364 insertions(+), 275 deletions(-) create mode 100644 sound/soc/qcom/lpass-ipq806x.c delete mode 100644 sound/soc/qcom/lpass-lpaif-ipq806x.h create mode 100644 sound/soc/qcom/lpass-lpaif-reg.h diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index b07f183fc47f..b30c2baa7501 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -12,11 +12,16 @@ config SND_SOC_LPASS_PLATFORM tristate select REGMAP_MMIO +config SND_SOC_LPASS_IPQ806X + tristate + depends on SND_SOC_QCOM + select SND_SOC_LPASS_CPU + select SND_SOC_LPASS_PLATFORM + config SND_SOC_STORM tristate "ASoC I2S support for Storm boards" depends on (ARCH_QCOM && SND_SOC_QCOM) || COMPILE_TEST - select SND_SOC_LPASS_CPU - select SND_SOC_LPASS_PLATFORM + select SND_SOC_LPASS_IPQ806X select SND_SOC_MAX98357A help Say Y or M if you want add support for SoC audio on the diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index c5ce96c761c4..f8aab91c9117 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -1,9 +1,11 @@ # Platform snd-soc-lpass-cpu-objs := lpass-cpu.o snd-soc-lpass-platform-objs := lpass-platform.o +snd-soc-lpass-ipq806x-objs := lpass-ipq806x.o obj-$(CONFIG_SND_SOC_LPASS_CPU) += snd-soc-lpass-cpu.o obj-$(CONFIG_SND_SOC_LPASS_PLATFORM) += snd-soc-lpass-platform.o +obj-$(CONFIG_SND_SOC_LPASS_IPQ806X) += snd-soc-lpass-ipq806x.o # Machine snd-soc-storm-objs := storm.o diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c index 40842958f423..5544bfc57357 100644 --- a/sound/soc/qcom/lpass-cpu.c +++ b/sound/soc/qcom/lpass-cpu.c @@ -17,14 +17,14 @@ #include #include #include +#include #include #include #include #include #include #include - -#include "lpass-lpaif-ipq806x.h" +#include "lpass-lpaif-reg.h" #include "lpass.h" static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id, @@ -138,7 +138,9 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, } ret = regmap_write(drvdata->lpaif_map, - LPAIF_I2SCTL_REG(LPAIF_I2S_PORT_MI2S), regval); + LPAIF_I2SCTL_REG(drvdata->variant, + LPAIF_I2S_PORT_MI2S), + regval); if (ret) { dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", __func__, ret); @@ -162,7 +164,8 @@ static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream, int ret; ret = regmap_write(drvdata->lpaif_map, - LPAIF_I2SCTL_REG(LPAIF_I2S_PORT_MI2S), 0); + LPAIF_I2SCTL_REG(drvdata->variant, + LPAIF_I2S_PORT_MI2S), 0); if (ret) dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", __func__, ret); @@ -177,7 +180,7 @@ static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream, int ret; ret = regmap_update_bits(drvdata->lpaif_map, - LPAIF_I2SCTL_REG(LPAIF_I2S_PORT_MI2S), + LPAIF_I2SCTL_REG(drvdata->variant, LPAIF_I2S_PORT_MI2S), LPAIF_I2SCTL_SPKEN_MASK, LPAIF_I2SCTL_SPKEN_ENABLE); if (ret) dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", @@ -197,7 +200,8 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: ret = regmap_update_bits(drvdata->lpaif_map, - LPAIF_I2SCTL_REG(LPAIF_I2S_PORT_MI2S), + LPAIF_I2SCTL_REG(drvdata->variant, + LPAIF_I2S_PORT_MI2S), LPAIF_I2SCTL_SPKEN_MASK, LPAIF_I2SCTL_SPKEN_ENABLE); if (ret) @@ -208,7 +212,8 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: ret = regmap_update_bits(drvdata->lpaif_map, - LPAIF_I2SCTL_REG(LPAIF_I2S_PORT_MI2S), + LPAIF_I2SCTL_REG(drvdata->variant, + LPAIF_I2S_PORT_MI2S), LPAIF_I2SCTL_SPKEN_MASK, LPAIF_I2SCTL_SPKEN_DISABLE); if (ret) @@ -220,7 +225,7 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, return ret; } -static struct snd_soc_dai_ops lpass_cpu_dai_ops = { +struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { .set_sysclk = lpass_cpu_daiops_set_sysclk, .startup = lpass_cpu_daiops_startup, .shutdown = lpass_cpu_daiops_shutdown, @@ -229,41 +234,24 @@ static struct snd_soc_dai_ops lpass_cpu_dai_ops = { .prepare = lpass_cpu_daiops_prepare, .trigger = lpass_cpu_daiops_trigger, }; +EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops); -static int lpass_cpu_dai_probe(struct snd_soc_dai *dai) +int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai) { struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); int ret; /* ensure audio hardware is disabled */ ret = regmap_write(drvdata->lpaif_map, - LPAIF_I2SCTL_REG(LPAIF_I2S_PORT_MI2S), 0); + LPAIF_I2SCTL_REG(drvdata->variant, + LPAIF_I2S_PORT_MI2S), 0); if (ret) dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", __func__, ret); return ret; } - -static struct snd_soc_dai_driver lpass_cpu_dai_driver = { - .playback = { - .stream_name = "lpass-cpu-playback", - .formats = SNDRV_PCM_FMTBIT_S16 | - SNDRV_PCM_FMTBIT_S24 | - SNDRV_PCM_FMTBIT_S32, - .rates = SNDRV_PCM_RATE_8000 | - SNDRV_PCM_RATE_16000 | - SNDRV_PCM_RATE_32000 | - SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_96000, - .rate_min = 8000, - .rate_max = 96000, - .channels_min = 1, - .channels_max = 8, - }, - .probe = &lpass_cpu_dai_probe, - .ops = &lpass_cpu_dai_ops, -}; +EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_probe); static const struct snd_soc_component_driver lpass_cpu_comp_driver = { .name = "lpass-cpu", @@ -271,27 +259,29 @@ static const struct snd_soc_component_driver lpass_cpu_comp_driver = { static bool lpass_cpu_regmap_writeable(struct device *dev, unsigned int reg) { + struct lpass_data *drvdata = dev_get_drvdata(dev); + struct lpass_variant *v = drvdata->variant; int i; - for (i = 0; i < LPAIF_I2S_PORT_NUM; ++i) - if (reg == LPAIF_I2SCTL_REG(i)) + for (i = 0; i < v->i2s_ports; ++i) + if (reg == LPAIF_I2SCTL_REG(v, i)) return true; - for (i = 0; i < LPAIF_IRQ_PORT_NUM; ++i) { - if (reg == LPAIF_IRQEN_REG(i)) + for (i = 0; i < v->irq_ports; ++i) { + if (reg == LPAIF_IRQEN_REG(v, i)) return true; - if (reg == LPAIF_IRQCLEAR_REG(i)) + if (reg == LPAIF_IRQCLEAR_REG(v, i)) return true; } - for (i = 0; i < LPAIF_RDMA_CHAN_NUM; ++i) { - if (reg == LPAIF_RDMACTL_REG(i)) + for (i = 0; i < v->rdma_channels; ++i) { + if (reg == LPAIF_RDMACTL_REG(v, i)) return true; - if (reg == LPAIF_RDMABASE_REG(i)) + if (reg == LPAIF_RDMABASE_REG(v, i)) return true; - if (reg == LPAIF_RDMABUFF_REG(i)) + if (reg == LPAIF_RDMABUFF_REG(v, i)) return true; - if (reg == LPAIF_RDMAPER_REG(i)) + if (reg == LPAIF_RDMAPER_REG(v, i)) return true; } @@ -300,29 +290,31 @@ static bool lpass_cpu_regmap_writeable(struct device *dev, unsigned int reg) static bool lpass_cpu_regmap_readable(struct device *dev, unsigned int reg) { + struct lpass_data *drvdata = dev_get_drvdata(dev); + struct lpass_variant *v = drvdata->variant; int i; - for (i = 0; i < LPAIF_I2S_PORT_NUM; ++i) - if (reg == LPAIF_I2SCTL_REG(i)) + for (i = 0; i < v->i2s_ports; ++i) + if (reg == LPAIF_I2SCTL_REG(v, i)) return true; - for (i = 0; i < LPAIF_IRQ_PORT_NUM; ++i) { - if (reg == LPAIF_IRQEN_REG(i)) + for (i = 0; i < v->irq_ports; ++i) { + if (reg == LPAIF_IRQEN_REG(v, i)) return true; - if (reg == LPAIF_IRQSTAT_REG(i)) + if (reg == LPAIF_IRQSTAT_REG(v, i)) return true; } - for (i = 0; i < LPAIF_RDMA_CHAN_NUM; ++i) { - if (reg == LPAIF_RDMACTL_REG(i)) + for (i = 0; i < v->rdma_channels; ++i) { + if (reg == LPAIF_RDMACTL_REG(v, i)) return true; - if (reg == LPAIF_RDMABASE_REG(i)) + if (reg == LPAIF_RDMABASE_REG(v, i)) return true; - if (reg == LPAIF_RDMABUFF_REG(i)) + if (reg == LPAIF_RDMABUFF_REG(v, i)) return true; - if (reg == LPAIF_RDMACURR_REG(i)) + if (reg == LPAIF_RDMACURR_REG(v, i)) return true; - if (reg == LPAIF_RDMAPER_REG(i)) + if (reg == LPAIF_RDMAPER_REG(v, i)) return true; } @@ -331,35 +323,39 @@ static bool lpass_cpu_regmap_readable(struct device *dev, unsigned int reg) static bool lpass_cpu_regmap_volatile(struct device *dev, unsigned int reg) { + struct lpass_data *drvdata = dev_get_drvdata(dev); + struct lpass_variant *v = drvdata->variant; int i; - for (i = 0; i < LPAIF_IRQ_PORT_NUM; ++i) - if (reg == LPAIF_IRQSTAT_REG(i)) + for (i = 0; i < v->irq_ports; ++i) + if (reg == LPAIF_IRQSTAT_REG(v, i)) return true; - for (i = 0; i < LPAIF_RDMA_CHAN_NUM; ++i) - if (reg == LPAIF_RDMACURR_REG(i)) + for (i = 0; i < v->rdma_channels; ++i) + if (reg == LPAIF_RDMACURR_REG(v, i)) return true; return false; } -static const struct regmap_config lpass_cpu_regmap_config = { +static struct regmap_config lpass_cpu_regmap_config = { .reg_bits = 32, .reg_stride = 4, .val_bits = 32, - .max_register = LPAIF_RDMAPER_REG(LPAIF_RDMA_CHAN_MAX), .writeable_reg = lpass_cpu_regmap_writeable, .readable_reg = lpass_cpu_regmap_readable, .volatile_reg = lpass_cpu_regmap_volatile, .cache_type = REGCACHE_FLAT, }; -static int lpass_cpu_platform_probe(struct platform_device *pdev) +int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) { struct lpass_data *drvdata; struct device_node *dsp_of_node; struct resource *res; + struct lpass_variant *variant; + struct device *dev = &pdev->dev; + const struct of_device_id *match; int ret; dsp_of_node = of_parse_phandle(pdev->dev.of_node, "qcom,adsp", 0); @@ -375,6 +371,13 @@ static int lpass_cpu_platform_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, drvdata); + match = of_match_device(dev->driver->of_match_table, dev); + if (!match || !match->data) + return -EINVAL; + + drvdata->variant = (struct lpass_variant *)match->data; + variant = drvdata->variant; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpass-lpaif"); drvdata->lpaif = devm_ioremap_resource(&pdev->dev, res); @@ -385,6 +388,9 @@ static int lpass_cpu_platform_probe(struct platform_device *pdev) return PTR_ERR((void const __force *)drvdata->lpaif); } + lpass_cpu_regmap_config.max_register = LPAIF_RDMAPER_REG(variant, + variant->rdma_channels); + drvdata->lpaif_map = devm_regmap_init_mmio(&pdev->dev, drvdata->lpaif, &lpass_cpu_regmap_config); if (IS_ERR(drvdata->lpaif_map)) { @@ -393,6 +399,9 @@ static int lpass_cpu_platform_probe(struct platform_device *pdev) return PTR_ERR(drvdata->lpaif_map); } + if (variant->init) + variant->init(pdev); + drvdata->mi2s_osr_clk = devm_clk_get(&pdev->dev, "mi2s-osr-clk"); if (IS_ERR(drvdata->mi2s_osr_clk)) { dev_err(&pdev->dev, "%s() error getting mi2s-osr-clk: %ld\n", @@ -431,7 +440,9 @@ static int lpass_cpu_platform_probe(struct platform_device *pdev) } ret = devm_snd_soc_register_component(&pdev->dev, - &lpass_cpu_comp_driver, &lpass_cpu_dai_driver, 1); + &lpass_cpu_comp_driver, + variant->dai_driver, + variant->num_dai); if (ret) { dev_err(&pdev->dev, "%s() error registering cpu driver: %d\n", __func__, ret); @@ -451,33 +462,17 @@ err_clk: clk_disable_unprepare(drvdata->ahbix_clk); return ret; } +EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_platform_probe); -static int lpass_cpu_platform_remove(struct platform_device *pdev) +int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev) { struct lpass_data *drvdata = platform_get_drvdata(pdev); + if (drvdata->variant->exit) + drvdata->variant->exit(pdev); + clk_disable_unprepare(drvdata->ahbix_clk); return 0; } - -#ifdef CONFIG_OF -static const struct of_device_id lpass_cpu_device_id[] = { - { .compatible = "qcom,lpass-cpu" }, - {} -}; -MODULE_DEVICE_TABLE(of, lpass_cpu_device_id); -#endif - -static struct platform_driver lpass_cpu_platform_driver = { - .driver = { - .name = "lpass-cpu", - .of_match_table = of_match_ptr(lpass_cpu_device_id), - }, - .probe = lpass_cpu_platform_probe, - .remove = lpass_cpu_platform_remove, -}; -module_platform_driver(lpass_cpu_platform_driver); - -MODULE_DESCRIPTION("QTi LPASS CPU Driver"); -MODULE_LICENSE("GPL v2"); +EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_platform_remove); diff --git a/sound/soc/qcom/lpass-ipq806x.c b/sound/soc/qcom/lpass-ipq806x.c new file mode 100644 index 000000000000..4a0e3fbb384b --- /dev/null +++ b/sound/soc/qcom/lpass-ipq806x.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * 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. + * + * lpass-ipq806x.c -- ALSA SoC CPU DAI driver for QTi LPASS + * Splited out the IPQ8064 soc specific from lpass-cpu.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lpass-lpaif-reg.h" +#include "lpass.h" + +enum lpaif_i2s_ports { + IPQ806X_LPAIF_I2S_PORT_CODEC_SPK, + IPQ806X_LPAIF_I2S_PORT_CODEC_MIC, + IPQ806X_LPAIF_I2S_PORT_SEC_SPK, + IPQ806X_LPAIF_I2S_PORT_SEC_MIC, + IPQ806X_LPAIF_I2S_PORT_MI2S, +}; + +enum lpaif_dma_channels { + IPQ806X_LPAIF_RDMA_CHAN_MI2S, + IPQ806X_LPAIF_RDMA_CHAN_PCM0, + IPQ806X_LPAIF_RDMA_CHAN_PCM1, +}; + +static struct snd_soc_dai_driver ipq806x_lpass_cpu_dai_driver = { + .playback = { + .stream_name = "lpass-cpu-playback", + .formats = SNDRV_PCM_FMTBIT_S16 | + SNDRV_PCM_FMTBIT_S24 | + SNDRV_PCM_FMTBIT_S32, + .rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000, + .rate_min = 8000, + .rate_max = 96000, + .channels_min = 1, + .channels_max = 8, + }, + .probe = &asoc_qcom_lpass_cpu_dai_probe, + .ops = &asoc_qcom_lpass_cpu_dai_ops, +}; + +struct lpass_variant ipq806x_data = { + .i2sctrl_reg_base = 0x0010, + .i2sctrl_reg_stride = 0x04, + .i2s_ports = 5, + .irq_reg_base = 0x3000, + .irq_reg_stride = 0x1000, + .irq_ports = 3, + .rdma_reg_base = 0x6000, + .rdma_reg_stride = 0x1000, + .rdma_channels = 4, + .dai_driver = &ipq806x_lpass_cpu_dai_driver, + .num_dai = 1, +}; + +static const struct of_device_id ipq806x_lpass_cpu_device_id[] = { + { .compatible = "qcom,lpass-cpu", .data = &ipq806x_data }, + {} +}; +MODULE_DEVICE_TABLE(of, ipq806x_lpass_cpu_device_id); + +static struct platform_driver ipq806x_lpass_cpu_platform_driver = { + .driver = { + .name = "lpass-cpu", + .of_match_table = of_match_ptr(ipq806x_lpass_cpu_device_id), + }, + .probe = asoc_qcom_lpass_cpu_platform_probe, + .remove = asoc_qcom_lpass_cpu_platform_remove, +}; +module_platform_driver(ipq806x_lpass_cpu_platform_driver); + +MODULE_DESCRIPTION("QTi LPASS CPU Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/qcom/lpass-lpaif-ipq806x.h b/sound/soc/qcom/lpass-lpaif-ipq806x.h deleted file mode 100644 index dc423b888842..000000000000 --- a/sound/soc/qcom/lpass-lpaif-ipq806x.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * 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. - * - * lpass-lpaif-ipq806x.h -- Definitions for the QTi LPAIF in the ipq806x LPASS - */ - -#ifndef __LPASS_LPAIF_H__ -#define __LPASS_LPAIF_H__ - -#define LPAIF_BANK_OFFSET 0x1000 - -/* LPAIF I2S */ - -#define LPAIF_I2SCTL_REG_BASE 0x0010 -#define LPAIF_I2SCTL_REG_STRIDE 0x4 -#define LPAIF_I2SCTL_REG_ADDR(addr, port) \ - (LPAIF_I2SCTL_REG_BASE + (addr) + (LPAIF_I2SCTL_REG_STRIDE * (port))) - -enum lpaif_i2s_ports { - LPAIF_I2S_PORT_MIN = 0, - - LPAIF_I2S_PORT_CODEC_SPK = 0, - LPAIF_I2S_PORT_CODEC_MIC = 1, - LPAIF_I2S_PORT_SEC_SPK = 2, - LPAIF_I2S_PORT_SEC_MIC = 3, - LPAIF_I2S_PORT_MI2S = 4, - - LPAIF_I2S_PORT_MAX = 4, - LPAIF_I2S_PORT_NUM = 5, -}; - -#define LPAIF_I2SCTL_REG(port) LPAIF_I2SCTL_REG_ADDR(0x0, (port)) - -#define LPAIF_I2SCTL_LOOPBACK_MASK 0x8000 -#define LPAIF_I2SCTL_LOOPBACK_SHIFT 15 -#define LPAIF_I2SCTL_LOOPBACK_DISABLE (0 << LPAIF_I2SCTL_LOOPBACK_SHIFT) -#define LPAIF_I2SCTL_LOOPBACK_ENABLE (1 << LPAIF_I2SCTL_LOOPBACK_SHIFT) - -#define LPAIF_I2SCTL_SPKEN_MASK 0x4000 -#define LPAIF_I2SCTL_SPKEN_SHIFT 14 -#define LPAIF_I2SCTL_SPKEN_DISABLE (0 << LPAIF_I2SCTL_SPKEN_SHIFT) -#define LPAIF_I2SCTL_SPKEN_ENABLE (1 << LPAIF_I2SCTL_SPKEN_SHIFT) - -#define LPAIF_I2SCTL_SPKMODE_MASK 0x3C00 -#define LPAIF_I2SCTL_SPKMODE_SHIFT 10 -#define LPAIF_I2SCTL_SPKMODE_NONE (0 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_SD0 (1 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_SD1 (2 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_SD2 (3 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_SD3 (4 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_QUAD01 (5 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_QUAD23 (6 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_6CH (7 << LPAIF_I2SCTL_SPKMODE_SHIFT) -#define LPAIF_I2SCTL_SPKMODE_8CH (8 << LPAIF_I2SCTL_SPKMODE_SHIFT) - -#define LPAIF_I2SCTL_SPKMONO_MASK 0x0200 -#define LPAIF_I2SCTL_SPKMONO_SHIFT 9 -#define LPAIF_I2SCTL_SPKMONO_STEREO (0 << LPAIF_I2SCTL_SPKMONO_SHIFT) -#define LPAIF_I2SCTL_SPKMONO_MONO (1 << LPAIF_I2SCTL_SPKMONO_SHIFT) - -#define LPAIF_I2SCTL_WSSRC_MASK 0x0004 -#define LPAIF_I2SCTL_WSSRC_SHIFT 2 -#define LPAIF_I2SCTL_WSSRC_INTERNAL (0 << LPAIF_I2SCTL_WSSRC_SHIFT) -#define LPAIF_I2SCTL_WSSRC_EXTERNAL (1 << LPAIF_I2SCTL_WSSRC_SHIFT) - -#define LPAIF_I2SCTL_BITWIDTH_MASK 0x0003 -#define LPAIF_I2SCTL_BITWIDTH_SHIFT 0 -#define LPAIF_I2SCTL_BITWIDTH_16 (0 << LPAIF_I2SCTL_BITWIDTH_SHIFT) -#define LPAIF_I2SCTL_BITWIDTH_24 (1 << LPAIF_I2SCTL_BITWIDTH_SHIFT) -#define LPAIF_I2SCTL_BITWIDTH_32 (2 << LPAIF_I2SCTL_BITWIDTH_SHIFT) - -/* LPAIF IRQ */ - -#define LPAIF_IRQ_REG_BASE 0x3000 -#define LPAIF_IRQ_REG_STRIDE 0x1000 -#define LPAIF_IRQ_REG_ADDR(addr, port) \ - (LPAIF_IRQ_REG_BASE + (addr) + (LPAIF_IRQ_REG_STRIDE * (port))) - -enum lpaif_irq_ports { - LPAIF_IRQ_PORT_MIN = 0, - - LPAIF_IRQ_PORT_HOST = 0, - LPAIF_IRQ_PORT_ADSP = 1, - - LPAIF_IRQ_PORT_MAX = 2, - LPAIF_IRQ_PORT_NUM = 3, -}; - -#define LPAIF_IRQEN_REG(port) LPAIF_IRQ_REG_ADDR(0x0, (port)) -#define LPAIF_IRQSTAT_REG(port) LPAIF_IRQ_REG_ADDR(0x4, (port)) -#define LPAIF_IRQCLEAR_REG(port) LPAIF_IRQ_REG_ADDR(0xC, (port)) - -#define LPAIF_IRQ_BITSTRIDE 3 -#define LPAIF_IRQ_PER(chan) (1 << (LPAIF_IRQ_BITSTRIDE * (chan))) -#define LPAIF_IRQ_XRUN(chan) (2 << (LPAIF_IRQ_BITSTRIDE * (chan))) -#define LPAIF_IRQ_ERR(chan) (4 << (LPAIF_IRQ_BITSTRIDE * (chan))) -#define LPAIF_IRQ_ALL(chan) (7 << (LPAIF_IRQ_BITSTRIDE * (chan))) - -/* LPAIF DMA */ - -#define LPAIF_RDMA_REG_BASE 0x6000 -#define LPAIF_RDMA_REG_STRIDE 0x1000 -#define LPAIF_RDMA_REG_ADDR(addr, chan) \ - (LPAIF_RDMA_REG_BASE + (addr) + (LPAIF_RDMA_REG_STRIDE * (chan))) - -enum lpaif_dma_channels { - LPAIF_RDMA_CHAN_MIN = 0, - - LPAIF_RDMA_CHAN_MI2S = 0, - LPAIF_RDMA_CHAN_PCM0 = 1, - LPAIF_RDMA_CHAN_PCM1 = 2, - - LPAIF_RDMA_CHAN_MAX = 4, - LPAIF_RDMA_CHAN_NUM = 5, -}; - -#define LPAIF_RDMACTL_REG(chan) LPAIF_RDMA_REG_ADDR(0x00, (chan)) -#define LPAIF_RDMABASE_REG(chan) LPAIF_RDMA_REG_ADDR(0x04, (chan)) -#define LPAIF_RDMABUFF_REG(chan) LPAIF_RDMA_REG_ADDR(0x08, (chan)) -#define LPAIF_RDMACURR_REG(chan) LPAIF_RDMA_REG_ADDR(0x0C, (chan)) -#define LPAIF_RDMAPER_REG(chan) LPAIF_RDMA_REG_ADDR(0x10, (chan)) - -#define LPAIF_RDMACTL_BURSTEN_MASK 0x800 -#define LPAIF_RDMACTL_BURSTEN_SHIFT 11 -#define LPAIF_RDMACTL_BURSTEN_SINGLE (0 << LPAIF_RDMACTL_BURSTEN_SHIFT) -#define LPAIF_RDMACTL_BURSTEN_INCR4 (1 << LPAIF_RDMACTL_BURSTEN_SHIFT) - -#define LPAIF_RDMACTL_WPSCNT_MASK 0x700 -#define LPAIF_RDMACTL_WPSCNT_SHIFT 8 -#define LPAIF_RDMACTL_WPSCNT_ONE (0 << LPAIF_RDMACTL_WPSCNT_SHIFT) -#define LPAIF_RDMACTL_WPSCNT_TWO (1 << LPAIF_RDMACTL_WPSCNT_SHIFT) -#define LPAIF_RDMACTL_WPSCNT_THREE (2 << LPAIF_RDMACTL_WPSCNT_SHIFT) -#define LPAIF_RDMACTL_WPSCNT_FOUR (3 << LPAIF_RDMACTL_WPSCNT_SHIFT) -#define LPAIF_RDMACTL_WPSCNT_SIX (5 << LPAIF_RDMACTL_WPSCNT_SHIFT) -#define LPAIF_RDMACTL_WPSCNT_EIGHT (7 << LPAIF_RDMACTL_WPSCNT_SHIFT) - -#define LPAIF_RDMACTL_AUDINTF_MASK 0x0F0 -#define LPAIF_RDMACTL_AUDINTF_SHIFT 4 -#define LPAIF_RDMACTL_AUDINTF_NONE (0 << LPAIF_RDMACTL_AUDINTF_SHIFT) -#define LPAIF_RDMACTL_AUDINTF_CODEC (1 << LPAIF_RDMACTL_AUDINTF_SHIFT) -#define LPAIF_RDMACTL_AUDINTF_PCM (2 << LPAIF_RDMACTL_AUDINTF_SHIFT) -#define LPAIF_RDMACTL_AUDINTF_SEC_I2S (3 << LPAIF_RDMACTL_AUDINTF_SHIFT) -#define LPAIF_RDMACTL_AUDINTF_MI2S (4 << LPAIF_RDMACTL_AUDINTF_SHIFT) -#define LPAIF_RDMACTL_AUDINTF_HDMI (5 << LPAIF_RDMACTL_AUDINTF_SHIFT) -#define LPAIF_RDMACTL_AUDINTF_SEC_PCM (7 << LPAIF_RDMACTL_AUDINTF_SHIFT) - -#define LPAIF_RDMACTL_FIFOWM_MASK 0x00E -#define LPAIF_RDMACTL_FIFOWM_SHIFT 1 -#define LPAIF_RDMACTL_FIFOWM_1 (0 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_2 (1 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_3 (2 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_4 (3 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_5 (4 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_6 (5 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_7 (6 << LPAIF_RDMACTL_FIFOWM_SHIFT) -#define LPAIF_RDMACTL_FIFOWM_8 (7 << LPAIF_RDMACTL_FIFOWM_SHIFT) - -#define LPAIF_RDMACTL_ENABLE_MASK 0x1 -#define LPAIF_RDMACTL_ENABLE_SHIFT 0 -#define LPAIF_RDMACTL_ENABLE_OFF (0 << LPAIF_RDMACTL_ENABLE_SHIFT) -#define LPAIF_RDMACTL_ENABLE_ON (1 << LPAIF_RDMACTL_ENABLE_SHIFT) - -#endif /* __LPASS_LPAIF_H__ */ diff --git a/sound/soc/qcom/lpass-lpaif-reg.h b/sound/soc/qcom/lpass-lpaif-reg.h new file mode 100644 index 000000000000..95e22f131052 --- /dev/null +++ b/sound/soc/qcom/lpass-lpaif-reg.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * 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. + */ + +#ifndef __LPASS_LPAIF_REG_H__ +#define __LPASS_LPAIF_REG_H__ + +/* LPAIF I2S */ + +#define LPAIF_I2SCTL_REG_ADDR(v, addr, port) \ + (v->i2sctrl_reg_base + (addr) + v->i2sctrl_reg_stride * (port)) + +#define LPAIF_I2SCTL_REG(v, port) LPAIF_I2SCTL_REG_ADDR(v, 0x0, (port)) +#define LPAIF_I2SCTL_LOOPBACK_MASK 0x8000 +#define LPAIF_I2SCTL_LOOPBACK_SHIFT 15 +#define LPAIF_I2SCTL_LOOPBACK_DISABLE (0 << LPAIF_I2SCTL_LOOPBACK_SHIFT) +#define LPAIF_I2SCTL_LOOPBACK_ENABLE (1 << LPAIF_I2SCTL_LOOPBACK_SHIFT) + +#define LPAIF_I2SCTL_SPKEN_MASK 0x4000 +#define LPAIF_I2SCTL_SPKEN_SHIFT 14 +#define LPAIF_I2SCTL_SPKEN_DISABLE (0 << LPAIF_I2SCTL_SPKEN_SHIFT) +#define LPAIF_I2SCTL_SPKEN_ENABLE (1 << LPAIF_I2SCTL_SPKEN_SHIFT) + +#define LPAIF_I2SCTL_SPKMODE_MASK 0x3C00 +#define LPAIF_I2SCTL_SPKMODE_SHIFT 10 +#define LPAIF_I2SCTL_SPKMODE_NONE (0 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_SD0 (1 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_SD1 (2 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_SD2 (3 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_SD3 (4 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_QUAD01 (5 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_QUAD23 (6 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_6CH (7 << LPAIF_I2SCTL_SPKMODE_SHIFT) +#define LPAIF_I2SCTL_SPKMODE_8CH (8 << LPAIF_I2SCTL_SPKMODE_SHIFT) + +#define LPAIF_I2SCTL_SPKMONO_MASK 0x0200 +#define LPAIF_I2SCTL_SPKMONO_SHIFT 9 +#define LPAIF_I2SCTL_SPKMONO_STEREO (0 << LPAIF_I2SCTL_SPKMONO_SHIFT) +#define LPAIF_I2SCTL_SPKMONO_MONO (1 << LPAIF_I2SCTL_SPKMONO_SHIFT) + +#define LPAIF_I2SCTL_WSSRC_MASK 0x0004 +#define LPAIF_I2SCTL_WSSRC_SHIFT 2 +#define LPAIF_I2SCTL_WSSRC_INTERNAL (0 << LPAIF_I2SCTL_WSSRC_SHIFT) +#define LPAIF_I2SCTL_WSSRC_EXTERNAL (1 << LPAIF_I2SCTL_WSSRC_SHIFT) + +#define LPAIF_I2SCTL_BITWIDTH_MASK 0x0003 +#define LPAIF_I2SC