From 64895739835c431fbc62dfabbe2267fff552a2f2 Mon Sep 17 00:00:00 2001 From: Nenghua Cao Date: Mon, 3 Mar 2014 19:08:23 +0800 Subject: [PATCH 1/5] asoc: soc-core: fix coccinelle warnings sound/soc/soc-core.c:2708:6-13: WARNING: Assignment of bool to 0/1 sound/soc/soc-core.c:2726:3-10: WARNING: Assignment of bool to 0/1 More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Nenghua Cao Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index fe1df50805a3..3477525247c3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2818,7 +2818,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; int err; - bool type_2r = 0; + bool type_2r = false; unsigned int val2 = 0; unsigned int val, val_mask; @@ -2836,7 +2836,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, val |= val2 << rshift; } else { val2 = val2 << shift; - type_2r = 1; + type_2r = true; } } err = snd_soc_update_bits_locked(codec, reg, val_mask, val); From cece5656901f09db13fbb569ff04f627ec2e0ab6 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Wed, 12 Feb 2014 18:20:57 +0100 Subject: [PATCH 2/5] ASoC: add S/PDIF support to Armada 370 DB ASoC driver The Armada 370 DB board not only has analog audio input/output, but also S/PDIF input/output. This commit adds support for S/PDIF in the ASoC machine driver of the Armada 370 DB platform, and adjusts the Device Tree bindings documentation accordingly. Signed-off-by: Thomas Petazzoni Signed-off-by: Mark Brown --- .../bindings/sound/armada-370db-audio.txt | 9 ++++-- sound/soc/kirkwood/Kconfig | 1 + sound/soc/kirkwood/armada-370-db.c | 28 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/armada-370db-audio.txt b/Documentation/devicetree/bindings/sound/armada-370db-audio.txt index 3893b4d15a20..bf984d238620 100644 --- a/Documentation/devicetree/bindings/sound/armada-370db-audio.txt +++ b/Documentation/devicetree/bindings/sound/armada-370db-audio.txt @@ -11,14 +11,17 @@ Mandatory properties: * marvell,audio-controller: a phandle that points to the audio controller of the Armada 370 SoC. - * marvell,audio-codec: a phandle that points to the analog audio - codec connected to the Armada 370 SoC. + * marvell,audio-codec: a set of three phandles that points to: + + 1/ the analog audio codec connected to the Armada 370 SoC + 2/ the S/PDIF transceiver + 3/ the S/PDIF receiver Example: sound { compatible = "marvell,a370db-audio"; marvell,audio-controller = <&audio_controller>; - marvell,audio-codec = <&audio_codec>; + marvell,audio-codec = <&audio_codec &spdif_out &spdif_in>; status = "okay"; }; diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig index 2dc3ecf34801..49f8437665de 100644 --- a/sound/soc/kirkwood/Kconfig +++ b/sound/soc/kirkwood/Kconfig @@ -10,6 +10,7 @@ config SND_KIRKWOOD_SOC_ARMADA370_DB tristate "SoC Audio support for Armada 370 DB" depends on SND_KIRKWOOD_SOC && (ARCH_MVEBU || COMPILE_TEST) && I2C select SND_SOC_CS42L51 + select SND_SOC_SPDIF help Say Y if you want to add support for SoC audio on the Armada 370 Development Board. diff --git a/sound/soc/kirkwood/armada-370-db.c b/sound/soc/kirkwood/armada-370-db.c index 977639b3ffde..c44333849259 100644 --- a/sound/soc/kirkwood/armada-370-db.c +++ b/sound/soc/kirkwood/armada-370-db.c @@ -67,6 +67,20 @@ static struct snd_soc_dai_link a370db_dai[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, .ops = &a370db_ops, }, +{ + .name = "S/PDIF out", + .stream_name = "spdif-out", + .cpu_dai_name = "spdif", + .codec_dai_name = "dit-hifi", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, +}, +{ + .name = "S/PDIF in", + .stream_name = "spdif-in", + .cpu_dai_name = "spdif", + .codec_dai_name = "dir-hifi", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, +}, }; static struct snd_soc_card a370db = { @@ -95,6 +109,20 @@ static int a370db_probe(struct platform_device *pdev) of_parse_phandle(pdev->dev.of_node, "marvell,audio-codec", 0); + a370db_dai[1].cpu_of_node = a370db_dai[0].cpu_of_node; + a370db_dai[1].platform_of_node = a370db_dai[0].cpu_of_node; + + a370db_dai[1].codec_of_node = + of_parse_phandle(pdev->dev.of_node, + "marvell,audio-codec", 1); + + a370db_dai[2].cpu_of_node = a370db_dai[0].cpu_of_node; + a370db_dai[2].platform_of_node = a370db_dai[0].cpu_of_node; + + a370db_dai[2].codec_of_node = + of_parse_phandle(pdev->dev.of_node, + "marvell,audio-codec", 2); + return devm_snd_soc_register_card(card->dev, card); } From 657254714ad2ba69b73fcb02f0b1db378b1f220e Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 20 Feb 2014 09:08:43 +0900 Subject: [PATCH 3/5] ASoC: io: Remove support for ASoC cache in conjunction with regmap Since all regmap CODECs should be (and are) using the more advance regmap cache infrastructure remove the code which supports that and just proxy I/O straight through to regmap. Signed-off-by: Mark Brown --- sound/soc/soc-io.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 8aa086996866..260efc8466fc 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -23,21 +23,6 @@ static int hw_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { - int ret; - - if (!snd_soc_codec_volatile_register(codec, reg) && - reg < codec->driver->reg_cache_size && - !codec->cache_bypass) { - ret = snd_soc_cache_write(codec, reg, value); - if (ret < 0) - return -1; - } - - if (codec->cache_only) { - codec->cache_sync = 1; - return 0; - } - return regmap_write(codec->control_data, reg, value); } @@ -46,23 +31,11 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) int ret; unsigned int val; - if (reg >= codec->driver->reg_cache_size || - snd_soc_codec_volatile_register(codec, reg) || - codec->cache_bypass) { - if (codec->cache_only) - return -1; - - ret = regmap_read(codec->control_data, reg, &val); - if (ret == 0) - return val; - else - return -1; - } - - ret = snd_soc_cache_read(codec, reg, &val); - if (ret < 0) + ret = regmap_read(codec->control_data, reg, &val); + if (ret == 0) + return val; + else return -1; - return val; } /** From 43b956349de28884265e8237a5cd1f669fbaa485 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 12 Mar 2014 15:27:31 +0100 Subject: [PATCH 4/5] ASoC: mfld_machine: Convert to table based DAPM and control setup Use table based setup to register the controls and DAPM widgets and routes. This on one hand makes the code a bit cleaner and on the other hand the board level DAPM elements get registered in the card's DAPM context rather than in the CODEC's DAPM context. The mfld_machine driver is a bit special in that it directly writes to one of the CODEC registers from one of the control handlers. Previous to this patch it was able to get a pointer to the CODEC from the control, since the control was registered with the CODEC. This won't be possible anymore once the control is registered with the card. Since there are already global variables in the driver accessed in the same function the patch adds a global variable that holds a pointer to the CODEC and uses that. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/intel/mfld_machine.c | 49 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c index 0cef32e9d402..461694263c46 100644 --- a/sound/soc/intel/mfld_machine.c +++ b/sound/soc/intel/mfld_machine.c @@ -53,6 +53,7 @@ enum soc_mic_bias_zones { static unsigned int hs_switch; static unsigned int lo_dac; +static struct snd_soc_codec *mfld_codec; struct mfld_mc_private { void __iomem *int_base; @@ -100,8 +101,8 @@ static int headset_get_switch(struct snd_kcontrol *kcontrol, static int headset_set_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = &card->dapm; if (ucontrol->value.integer.value[0] == hs_switch) return 0; @@ -127,10 +128,8 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol, return 0; } -static void lo_enable_out_pins(struct snd_soc_codec *codec) +static void lo_enable_out_pins(struct snd_soc_dapm_context *dapm) { - struct snd_soc_dapm_context *dapm = &codec->dapm; - snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTL"); snd_soc_dapm_enable_pin_unlocked(dapm, "IHFOUTR"); snd_soc_dapm_enable_pin_unlocked(dapm, "LINEOUTL"); @@ -156,8 +155,8 @@ static int lo_get_switch(struct snd_kcontrol *kcontrol, static int lo_set_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = &card->dapm; if (ucontrol->value.integer.value[0] == lo_dac) return 0; @@ -167,35 +166,35 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol, /* we dont want to work with last state of lineout so just enable all * pins and then disable pins not required */ - lo_enable_out_pins(codec); + lo_enable_out_pins(dapm); switch (ucontrol->value.integer.value[0]) { case 0: pr_debug("set vibra path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT"); - snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0); + snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0); break; case 1: pr_debug("set hs path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones"); snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT"); - snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x22); + snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22); break; case 2: pr_debug("set spkr path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL"); snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR"); - snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x44); + snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44); break; case 3: pr_debug("set null path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR"); - snd_soc_update_bits(codec, SN95031_LOCTL, 0x66, 0x66); + snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66); break; } @@ -238,26 +237,11 @@ static void mfld_jack_check(unsigned int intr_status) static int mfld_init(struct snd_soc_pcm_runtime *runtime) { - struct snd_soc_codec *codec = runtime->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_dapm_context *dapm = &runtime->card->dapm; int ret_val; - /* Add jack sense widgets */ - snd_soc_dapm_new_controls(dapm, mfld_widgets, ARRAY_SIZE(mfld_widgets)); + mfld_codec = runtime->codec; - /* Set up the map */ - snd_soc_dapm_add_routes(dapm, mfld_map, ARRAY_SIZE(mfld_map)); - - /* always connected */ - snd_soc_dapm_enable_pin(dapm, "Headphones"); - snd_soc_dapm_enable_pin(dapm, "Mic"); - - ret_val = snd_soc_add_codec_controls(codec, mfld_snd_controls, - ARRAY_SIZE(mfld_snd_controls)); - if (ret_val) { - pr_err("soc_add_controls failed %d", ret_val); - return ret_val; - } /* default is earpiece pin, userspace sets it explcitly */ snd_soc_dapm_disable_pin(dapm, "Headphones"); /* default is lineout NC, userspace sets it explcitly */ @@ -352,6 +336,13 @@ static struct snd_soc_card snd_soc_card_mfld = { .owner = THIS_MODULE, .dai_link = mfld_msic_dailink, .num_links = ARRAY_SIZE(mfld_msic_dailink), + + .controls = mfld_snd_controls, + .num_controls = ARRAY_SIZE(mfld_snd_controls), + .dapm_widgets = mfld_widgets, + .num_dapm_widgets = ARRAY_SIZE(mfld_widgets), + .dapm_routes = mfld_map, + .num_dapm_routes = ARRAY_SIZE(mfld_map), }; static irqreturn_t snd_mfld_jack_intr_handler(int irq, void *dev) From 546d4dd3bb99466e4268256bad615a5ed6457a55 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 21 Mar 2014 20:23:51 +0100 Subject: [PATCH 5/5] ASoC: mfld_machine: Fix compile error Fixes: 115f3f8 ("ASoC: mfld_machine: Convert to table based DAPM and control setup") Reported-by: kbuild test robot Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/intel/mfld_machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c index 461694263c46..031d78783fc8 100644 --- a/sound/soc/intel/mfld_machine.c +++ b/sound/soc/intel/mfld_machine.c @@ -254,7 +254,7 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime) snd_soc_dapm_disable_pin(dapm, "LINEINR"); /* Headset and button jack detection */ - ret_val = snd_soc_jack_new(codec, "Intel(R) MID Audio Jack", + ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1, &mfld_jack); if (ret_val) {