From ecbb1b8d97a78a72003fcb19292da502d393bf80 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 6 Jul 2017 00:39:29 +0000 Subject: ASoC: hdmi-codec: ELD control corresponds to the PCM stream Current hdmi-codec driver is using hdmi_controls for "ELD" control. But, hdmi-codec driver might be used from many HDMIs. Thus, we need to correspond device number, otherwise we will receive below error. xxx: control x:x:x:ELD:x is already present This patch registers ELD control in .pcm_new by using .device = rtd->pcm->device to corresponding to PCM stream. Signed-off-by: Kuninori Morimoto [Takashi: use snd_ctl_new1()/snd_ctl_add()] Signed-off-by: Takashi Iwai Acked-by: Arnaud Pouliquen Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 22ed0dc..7686a80 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -399,18 +399,6 @@ static int hdmi_codec_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } - -static const struct snd_kcontrol_new hdmi_controls[] = { - { - .access = SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "ELD", - .info = hdmi_eld_ctl_info, - .get = hdmi_eld_ctl_get, - }, -}; - static int hdmi_codec_new_stream(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -668,6 +656,16 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai_driver *drv = dai->driver; struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + struct snd_kcontrol *kctl; + struct snd_kcontrol_new hdmi_eld_ctl = { + .access = SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = "ELD", + .info = hdmi_eld_ctl_info, + .get = hdmi_eld_ctl_get, + .device = rtd->pcm->device, + }; int ret; dev_dbg(dai->dev, "%s()\n", __func__); @@ -686,7 +684,12 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; - return 0; + /* add ELD ctl with the device number corresponding to the PCM stream */ + kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component); + if (!kctl) + return -ENOMEM; + + return snd_ctl_add(rtd->card->snd_card, kctl); } static struct snd_soc_dai_driver hdmi_i2s_dai = { @@ -732,8 +735,6 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, static struct snd_soc_codec_driver hdmi_codec = { .component_driver = { - .controls = hdmi_controls, - .num_controls = ARRAY_SIZE(hdmi_controls), .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), .dapm_routes = hdmi_routes, -- cgit v1.1 From 1d6463a3e23e55621101a1b9b842101988c596ff Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 11 Jul 2017 15:08:55 +0100 Subject: ASoC: hdmi-codec: make const array hdmi_codec_eld_spk_alloc_bits static Don't populate array hdmi_codec_eld_spk_alloc_bits on the stack but make it static. Makes the object code smaller by over 260 bytes: Before: text data bss dec hex filename 10882 3384 64 14330 37fa sound/soc/codecs/hdmi-codec.o After: text data bss dec hex filename 10557 3440 64 14061 36ed sound/soc/codecs/hdmi-codec.o Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 7686a80..509ab51 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -326,7 +326,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol, static unsigned long hdmi_codec_spk_mask_from_alloc(int spk_alloc) { int i; - const unsigned long hdmi_codec_eld_spk_alloc_bits[] = { + static const unsigned long hdmi_codec_eld_spk_alloc_bits[] = { [0] = FL | FR, [1] = LFE, [2] = FC, [3] = RL | RR, [4] = RC, [5] = FLC | FRC, [6] = RLC | RRC, }; -- cgit v1.1 From e7b2e30a3f88b02b13a9bde05044142b38456004 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 30 Jun 2017 16:46:33 -0500 Subject: ASoC: kirkwood-i2s: fix error return code in kirkwood_i2s_dev_probe() platform_get_irq() returns an error code, but the kirkwood-i2s driver ignores it and always returns -ENXIO. This is not correct, and prevents -EPROBE_DEFER from being propagated properly. Notice that platform_get_irq() no longer returns 0 on error. Print and propagate the return value of platform_get_irq on failure. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-i2s.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 3a36d60..3b09f71 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -550,9 +550,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) return PTR_ERR(priv->io); priv->irq = platform_get_irq(pdev, 0); - if (priv->irq <= 0) { - dev_err(&pdev->dev, "platform_get_irq failed\n"); - return -ENXIO; + if (priv->irq < 0) { + dev_err(&pdev->dev, "platform_get_irq failed: %d\n", priv->irq); + return priv->irq; } if (np) { -- cgit v1.1 From ea4daf81fc5a37766a606479f592cd9dfe6f1da8 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 10 Jul 2017 10:03:12 +0800 Subject: ASoC: rt5514: Move the auto disable DSP function to set_bias_level() Move the auto disable DSP function from the widget event "DAPM Pre" to the set_bias_level() function to avoid the unexpected behavior. While the SPI was recording using the DAI "rt5514-dsp-cpu-dai", the event "DAPM Pre" would be manipulated even the DAPM widgets were not connected, and it also would power off the DSP that cause the DSP buffered data lost. So the auto disable DSP function should move to the set_bias_level() function to make sure that it is only manipulated by the DAPM widgets are connected. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 49 +++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 31 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 1b6796c..a71e630 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -471,35 +471,6 @@ static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, return 0; } -static int rt5514_pre_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - /** - * If the DSP is enabled in start of recording, the DSP - * should be disabled, and sync back to normal recording - * settings to make sure recording properly. - */ - if (rt5514->dsp_enabled) { - rt5514->dsp_enabled = 0; - regmap_multi_reg_write(rt5514->i2c_regmap, - rt5514_i2c_patch, ARRAY_SIZE(rt5514_i2c_patch)); - regcache_mark_dirty(rt5514->regmap); - regcache_sync(rt5514->regmap); - } - break; - - default: - return 0; - } - - return 0; -} - static const struct snd_soc_dapm_widget rt5514_dapm_widgets[] = { /* Input Lines */ SND_SOC_DAPM_INPUT("DMIC1L"), @@ -607,8 +578,6 @@ static const struct snd_soc_dapm_widget rt5514_dapm_widgets[] = { /* Audio Interface */ SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), - - SND_SOC_DAPM_PRE("DAPM Pre", rt5514_pre_event), }; static const struct snd_soc_dapm_route rt5514_dapm_routes[] = { @@ -975,6 +944,24 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec, } break; + case SND_SOC_BIAS_STANDBY: + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + /* + * If the DSP is enabled in start of recording, the DSP + * should be disabled, and sync back to normal recording + * settings to make sure recording properly. + */ + if (rt5514->dsp_enabled) { + rt5514->dsp_enabled = 0; + regmap_multi_reg_write(rt5514->i2c_regmap, + rt5514_i2c_patch, + ARRAY_SIZE(rt5514_i2c_patch)); + regcache_mark_dirty(rt5514->regmap); + regcache_sync(rt5514->regmap); + } + } + break; + default: break; } -- cgit v1.1 From 7d8e00c78924d50eb71d3cf991096021eadce641 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Fri, 7 Jul 2017 16:58:57 +0800 Subject: ASoC: rt5663: Update the calibration funciton The patch updates the calibration funciton for getting the correct DC offset of headphone output. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 100 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 79 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index a33202a..18b3b52 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2986,47 +2986,75 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) { int value, count; - regmap_write(rt5663->regmap, RT5663_RC_CLK, 0x0280); + regmap_write(rt5663->regmap, RT5663_RESET, 0x0000); + msleep(20); + regmap_write(rt5663->regmap, RT5663_ANA_BIAS_CUR_4, 0x00a1); + regmap_write(rt5663->regmap, RT5663_RC_CLK, 0x0380); regmap_write(rt5663->regmap, RT5663_GLB_CLK, 0x8000); - regmap_write(rt5663->regmap, RT5663_DIG_MISC, 0x8001); + regmap_write(rt5663->regmap, RT5663_ADDA_CLK_1, 0x1000); regmap_write(rt5663->regmap, RT5663_VREF_RECMIX, 0x0032); - regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xa2be); - msleep(20); - regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xf2be); - regmap_write(rt5663->regmap, RT5663_PWR_DIG_2, 0x8400); - regmap_write(rt5663->regmap, RT5663_CHOP_ADC, 0x3000); - regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x003b); - regmap_write(rt5663->regmap, RT5663_PWR_DIG_1, 0x8df8); - regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x0003); - regmap_write(rt5663->regmap, RT5663_PWR_ANLG_3, 0x018c); - regmap_write(rt5663->regmap, RT5663_ADDA_CLK_1, 0x1111); + regmap_write(rt5663->regmap, RT5663_HP_IMP_SEN_19, 0x000c); + regmap_write(rt5663->regmap, RT5663_DUMMY_1, 0x0324); + regmap_write(rt5663->regmap, RT5663_DIG_MISC, 0x8001); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xa23b); + msleep(30); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xf23b); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x8000); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_3, 0x0008); regmap_write(rt5663->regmap, RT5663_PRE_DIV_GATING_1, 0xffff); regmap_write(rt5663->regmap, RT5663_PRE_DIV_GATING_2, 0xffff); + regmap_write(rt5663->regmap, RT5663_CBJ_1, 0x8c10); + regmap_write(rt5663->regmap, RT5663_IL_CMD_2, 0x00c1); + regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_1, 0xb880); + regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_2, 0x4110); + regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_2, 0x4118); + + count = 0; + while (true) { + regmap_read(rt5663->regmap, RT5663_INT_ST_2, &value); + if (!(value & 0x80)) + usleep_range(10000, 10005); + else + break; + + if (count > 200) + break; + } + + regmap_write(rt5663->regmap, RT5663_HP_IMP_SEN_19, 0x0000); regmap_write(rt5663->regmap, RT5663_DEPOP_2, 0x3003); + regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x0038); regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x003b); + regmap_write(rt5663->regmap, RT5663_PWR_DIG_2, 0x8400); + regmap_write(rt5663->regmap, RT5663_PWR_DIG_1, 0x8df8); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x8003); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_3, 0x018c); regmap_write(rt5663->regmap, RT5663_HP_CHARGE_PUMP_1, 0x1e32); - regmap_write(rt5663->regmap, RT5663_HP_CHARGE_PUMP_2, 0x1371); regmap_write(rt5663->regmap, RT5663_DACREF_LDO, 0x3b0b); - regmap_write(rt5663->regmap, RT5663_STO_DAC_MIXER, 0x2080); + regmap_write(rt5663->regmap, RT5663_STO_DAC_MIXER, 0x0000); regmap_write(rt5663->regmap, RT5663_BYPASS_STO_DAC, 0x000c); - regmap_write(rt5663->regmap, RT5663_HP_BIAS, 0xabba); + regmap_write(rt5663->regmap, RT5663_HP_BIAS, 0xafaa); regmap_write(rt5663->regmap, RT5663_CHARGE_PUMP_1, 0x2224); regmap_write(rt5663->regmap, RT5663_HP_OUT_EN, 0x8088); regmap_write(rt5663->regmap, RT5663_STO_DRE_9, 0x0017); regmap_write(rt5663->regmap, RT5663_STO_DRE_10, 0x0017); regmap_write(rt5663->regmap, RT5663_STO1_ADC_MIXER, 0x4040); + regmap_write(rt5663->regmap, RT5663_CHOP_ADC, 0x3000); regmap_write(rt5663->regmap, RT5663_RECMIX, 0x0005); regmap_write(rt5663->regmap, RT5663_ADDA_RST, 0xc000); regmap_write(rt5663->regmap, RT5663_STO1_HPF_ADJ1, 0x3320); regmap_write(rt5663->regmap, RT5663_HP_CALIB_2, 0x00c9); regmap_write(rt5663->regmap, RT5663_DUMMY_1, 0x004c); - regmap_write(rt5663->regmap, RT5663_ANA_BIAS_CUR_1, 0x7766); - regmap_write(rt5663->regmap, RT5663_BIAS_CUR_8, 0x4702); - msleep(200); + regmap_write(rt5663->regmap, RT5663_ANA_BIAS_CUR_1, 0x1111); + regmap_write(rt5663->regmap, RT5663_BIAS_CUR_8, 0x4402); + regmap_write(rt5663->regmap, RT5663_CHARGE_PUMP_2, 0x3311); regmap_write(rt5663->regmap, RT5663_HP_CALIB_1, 0x0069); - regmap_write(rt5663->regmap, RT5663_HP_CALIB_3, 0x06c2); - regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0x7b00); - regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0xfb00); + regmap_write(rt5663->regmap, RT5663_HP_CALIB_3, 0x06ce); + regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0x6800); + regmap_write(rt5663->regmap, RT5663_CHARGE_PUMP_2, 0x1100); + regmap_write(rt5663->regmap, RT5663_HP_CALIB_7, 0x0057); + regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0xe800); + count = 0; while (true) { regmap_read(rt5663->regmap, RT5663_HP_CALIB_1_1, &value); @@ -3039,6 +3067,36 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) return; count++; } + + regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0x6200); + regmap_write(rt5663->regmap, RT5663_HP_CALIB_7, 0x0059); + regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0xe200); + + count = 0; + while (true) { + regmap_read(rt5663->regmap, RT5663_HP_CALIB_1_1, &value); + if (value & 0x8000) + usleep_range(10000, 10005); + else + break; + + if (count > 200) + return; + count++; + } + + regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_1, 0xb8e0); + usleep_range(10000, 10005); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0x003b); + usleep_range(10000, 10005); + regmap_write(rt5663->regmap, RT5663_PWR_DIG_1, 0x0000); + usleep_range(10000, 10005); + regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x000b); + usleep_range(10000, 10005); + regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x0008); + usleep_range(10000, 10005); + regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x0000); + usleep_range(10000, 10005); } static int rt5663_i2c_probe(struct i2c_client *i2c, -- cgit v1.1 From 8f24412784bd0f544307bb184e3f264064f68ff0 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Fri, 7 Jul 2017 16:58:58 +0800 Subject: ASoC: rt5663: Optimize the Jack Type detection The patch optimizes the Jack Type detection. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 18b3b52..ebd9ae0 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -1508,7 +1508,7 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) { struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); - int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; + int val, i = 0; dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); @@ -1543,17 +1543,22 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) RT5663_IRQ_POW_SAV_MASK, RT5663_IRQ_POW_SAV_EN); snd_soc_update_bits(codec, RT5663_IRQ_1, RT5663_EN_IRQ_JD1_MASK, RT5663_EN_IRQ_JD1_EN); - while (i < 5) { - msleep(sleep_time[i]); - val = snd_soc_read(codec, RT5663_EM_JACK_TYPE_2) & - 0x0003; - dev_dbg(codec->dev, "%s: MX-00e7 val=%x sleep %d\n", - __func__, val, sleep_time[i]); - i++; - if (val == 0x1 || val == 0x2 || val == 0x3) + + while (true) { + regmap_read(rt5663->regmap, RT5663_INT_ST_2, &val); + if (!(val & 0x80)) + usleep_range(10000, 10005); + else + break; + + if (i > 200) break; + i++; } + + val = snd_soc_read(codec, RT5663_EM_JACK_TYPE_2) & 0x0003; dev_dbg(codec->dev, "%s val = %d\n", __func__, val); + switch (val) { case 1: case 2: -- cgit v1.1 From 1325734c97c533c2042794f2bd873486b4905cdb Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Fri, 7 Jul 2017 16:58:59 +0800 Subject: ASoC: rt5663: Modify the power sequence for reducing the pop sound The patch modifies the power sequence for reducing the pop sound. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index ebd9ae0..82edbcf 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2029,10 +2029,6 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, RT5663_HP_SIG_SRC1_SILENCE); } else { snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x000b, - 0x000b); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, - 0x0030); snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_DIS); snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); @@ -2055,9 +2051,6 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x0); snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_EN); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0x0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x000b, - 0x000b); } break; @@ -2068,6 +2061,31 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, return 0; } +static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + if (rt5663->codec_ver == CODEC_VER_0) + snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x003b, + 0x003b); + break; + + case SND_SOC_DAPM_POST_PMD: + if (rt5663->codec_ver == CODEC_VER_0) + snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x003b, 0); + break; + + default: + return 0; + } + + return 0; +} + static int rt5663_bst2_power(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -2187,6 +2205,9 @@ static const struct snd_soc_dapm_widget rt5663_dapm_widgets[] = { SND_SOC_DAPM_DAC("DAC R", NULL, SND_SOC_NOPM, 0, 0), /* Headphone*/ + SND_SOC_DAPM_SUPPLY("HP Charge Pump", SND_SOC_NOPM, 0, 0, + rt5663_charge_pump_event, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, rt5663_hp_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), @@ -2343,6 +2364,7 @@ static const struct snd_soc_dapm_route rt5663_dapm_routes[] = { { "STO1 DAC MIXR", NULL, "STO1 DAC R Power" }, { "STO1 DAC MIXR", NULL, "STO1 DAC Filter" }, + { "HP Amp", NULL, "HP Charge Pump" }, { "HP Amp", NULL, "DAC L" }, { "HP Amp", NULL, "DAC R" }, }; -- cgit v1.1 From 09b8852c759917e3ea10062b374692a5313cbfd8 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 10 Jul 2017 16:20:45 +0100 Subject: ASoC: rt5663: add in missing loop counter to avoid infinite loop The loop counter 'count' is missing an increment, so we could end up with an infinite loop. Add in a pre-increment to count to fix this. Detected by CoverityScan, CID#1450120 ("Logically Dead Code") Fixes: 1a425dbf1a10 ("ASoC: rt5663: Update the calibration funciton") Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 82edbcf..5b3c50c 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -3044,7 +3044,7 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) else break; - if (count > 200) + if (++count > 200) break; } -- cgit v1.1 From 450f0f6a8fb499a6ef3d10ab5c29a7c4650a9958 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 10 Jul 2017 11:14:56 +0800 Subject: ASoC: rt5663: Add the manual offset field to compensate the DC offset The patch adds the manual offset field in the devicetree to compensate the DC offset that will be different between the PCB layout. It only can be measured by the real production. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 55 ++++++++++++++++++++++++++++++++++++++++++----- sound/soc/codecs/rt5663.h | 2 ++ 2 files changed, 52 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 5b3c50c..963cda9 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -40,6 +40,7 @@ enum { struct rt5663_priv { struct snd_soc_codec *codec; + struct rt5663_platform_data pdata; struct regmap *regmap; struct delayed_work jack_detect_work; struct snd_soc_jack *hs_jack; @@ -57,6 +58,10 @@ struct rt5663_priv { int jack_type; }; +static const struct reg_sequence rt5663_patch_list[] = { + { 0x002a, 0x8080 }, +}; + static const struct reg_default rt5663_v2_reg[] = { { 0x0000, 0x0000 }, { 0x0001, 0xc8c8 }, @@ -476,7 +481,7 @@ static const struct reg_default rt5663_reg[] = { { 0x0023, 0x0039 }, { 0x0026, 0xc0c0 }, { 0x0029, 0x8080 }, - { 0x002a, 0xa0a0 }, + { 0x002a, 0x8080 }, { 0x002c, 0x000c }, { 0x002d, 0x0000 }, { 0x0040, 0x0808 }, @@ -1958,15 +1963,11 @@ static const struct snd_kcontrol_new rt5663_adda_r_mix[] = { static const struct snd_kcontrol_new rt5663_sto1_dac_l_mix[] = { SOC_DAPM_SINGLE("DAC L Switch", RT5663_STO_DAC_MIXER, RT5663_M_DAC_L1_STO_L_SHIFT, 1, 1), - SOC_DAPM_SINGLE("DAC R Switch", RT5663_STO_DAC_MIXER, - RT5663_M_DAC_R1_STO_L_SHIFT, 1, 1), }; static const struct snd_kcontrol_new rt5663_sto1_dac_r_mix[] = { SOC_DAPM_SINGLE("DAC L Switch", RT5663_STO_DAC_MIXER, RT5663_M_DAC_L1_STO_R_SHIFT, 1, 1), - SOC_DAPM_SINGLE("DAC R Switch", RT5663_STO_DAC_MIXER, - RT5663_M_DAC_R1_STO_R_SHIFT, 1, 1), }; /* Out Switch */ @@ -3126,9 +3127,20 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) usleep_range(10000, 10005); } +static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev) +{ + device_property_read_u32(dev, "realtek,dc_offset_l_manual", + &rt5663->pdata.dc_offset_l_manual); + device_property_read_u32(dev, "realtek,dc_offset_r_manual", + &rt5663->pdata.dc_offset_r_manual); + + return 0; +} + static int rt5663_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { + struct rt5663_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5663_priv *rt5663; int ret; unsigned int val; @@ -3142,6 +3154,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5663); + if (pdata) + rt5663->pdata = *pdata; + else + rt5663_parse_dp(rt5663, &i2c->dev); + regmap = devm_regmap_init_i2c(i2c, &temp_regmap); if (IS_ERR(regmap)) { ret = PTR_ERR(regmap); @@ -3190,6 +3207,34 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, regmap_write(rt5663->regmap, RT5663_RESET, 0); dev_dbg(&i2c->dev, "calibrate done\n"); + switch (rt5663->codec_ver) { + case CODEC_VER_1: + break; + case CODEC_VER_0: + ret = regmap_register_patch(rt5663->regmap, rt5663_patch_list, + ARRAY_SIZE(rt5663_patch_list)); + if (ret != 0) + dev_warn(&i2c->dev, + "Failed to apply regmap patch: %d\n", ret); + break; + default: + dev_err(&i2c->dev, "%s:Unknown codec type\n", __func__); + } + + if (rt5663->pdata.dc_offset_l_manual) { + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_2, + rt5663->pdata.dc_offset_l_manual >> 16); + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_3, + rt5663->pdata.dc_offset_l_manual & 0xffff); + } + + if (rt5663->pdata.dc_offset_r_manual) { + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_5, + rt5663->pdata.dc_offset_r_manual >> 16); + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_6, + rt5663->pdata.dc_offset_r_manual & 0xffff); + } + /* GPIO1 as IRQ */ regmap_update_bits(rt5663->regmap, RT5663_GPIO_1, RT5663_GP1_PIN_MASK, RT5663_GP1_PIN_IRQ); diff --git a/sound/soc/codecs/rt5663.h b/sound/soc/codecs/rt5663.h index 4621812..c5a9b69 100644 --- a/sound/soc/codecs/rt5663.h +++ b/sound/soc/codecs/rt5663.h @@ -12,6 +12,8 @@ #ifndef __RT5663_H__ #define __RT5663_H__ +#include + /* Info */ #define RT5663_RESET 0x0000 #define RT5663_VENDOR_ID 0x00fd -- cgit v1.1 From 4720c2fe196fc16fca9c902bec5c786ae4689842 Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Fri, 7 Jul 2017 10:31:10 +0900 Subject: ASoC: samsung: i2s: Support more resolution rates This driver can support more frequencies over 96KHz. There are no reasons to limit the frequency range below 96KHz. If codecs/amps or something else can't support higher resolution rates, the constraints would be set rates properly because each drivers have its own limits. I added the 'pcm_rates' field to the dai_data to be set rates by the compatibilities. As a result, rates will be set each devices respectively. For example of exynos5433, rates will be set from 8KHz to 192KHz. Signed-off-by: Jaechul Lee Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index af3ba4d..c9f87f7 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -50,6 +50,7 @@ struct samsung_i2s_variant_regs { struct samsung_i2s_dai_data { u32 quirks; + unsigned int pcm_rates; const struct samsung_i2s_variant_regs *i2s_variant_regs; }; @@ -1076,13 +1077,13 @@ static const struct snd_soc_component_driver samsung_i2s_component = { .name = "samsung-i2s", }; -#define SAMSUNG_I2S_RATES SNDRV_PCM_RATE_8000_96000 - #define SAMSUNG_I2S_FMTS (SNDRV_PCM_FMTBIT_S8 | \ SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE) -static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) +static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, + const struct samsung_i2s_dai_data *i2s_dai_data, + bool sec) { struct i2s_dai *i2s; @@ -1101,13 +1102,13 @@ static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) i2s->i2s_dai_drv.resume = i2s_resume; i2s->i2s_dai_drv.playback.channels_min = 1; i2s->i2s_dai_drv.playback.channels_max = 2; - i2s->i2s_dai_drv.playback.rates = SAMSUNG_I2S_RATES; + i2s->i2s_dai_drv.playback.rates = i2s_dai_data->pcm_rates; i2s->i2s_dai_drv.playback.formats = SAMSUNG_I2S_FMTS; if (!sec) { i2s->i2s_dai_drv.capture.channels_min = 1; i2s->i2s_dai_drv.capture.channels_max = 2; - i2s->i2s_dai_drv.capture.rates = SAMSUNG_I2S_RATES; + i2s->i2s_dai_drv.capture.rates = i2s_dai_data->pcm_rates; i2s->i2s_dai_drv.capture.formats = SAMSUNG_I2S_FMTS; } return i2s; @@ -1242,7 +1243,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) i2s_dai_data = (struct samsung_i2s_dai_data *) platform_get_device_id(pdev)->driver_data; - pri_dai = i2s_alloc_dai(pdev, false); + pri_dai = i2s_alloc_dai(pdev, i2s_dai_data, false); if (!pri_dai) { dev_err(&pdev->dev, "Unable to alloc I2S_pri\n"); return -ENOMEM; @@ -1316,7 +1317,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) goto err_disable_clk; if (quirks & QUIRK_SEC_DAI) { - sec_dai = i2s_alloc_dai(pdev, true); + sec_dai = i2s_alloc_dai(pdev, i2s_dai_data, true); if (!sec_dai) { dev_err(&pdev->dev, "Unable to alloc I2S_sec\n"); ret = -ENOMEM; @@ -1452,29 +1453,34 @@ static const struct samsung_i2s_variant_regs i2sv5_i2s1_regs = { static const struct samsung_i2s_dai_data i2sv3_dai_type = { .quirks = QUIRK_NO_MUXPSR, + .pcm_rates = SNDRV_PCM_RATE_8000_96000, .i2s_variant_regs = &i2sv3_regs, }; static const struct samsung_i2s_dai_data i2sv5_dai_type = { .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI | QUIRK_NEED_RSTCLR | QUIRK_SUPPORTS_IDMA, + .pcm_rates = SNDRV_PCM_RATE_8000_96000, .i2s_variant_regs = &i2sv3_regs, }; static const struct samsung_i2s_dai_data i2sv6_dai_type = { .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI | QUIRK_NEED_RSTCLR | QUIRK_SUPPORTS_TDM | QUIRK_SUPPORTS_IDMA, + .pcm_rates = SNDRV_PCM_RATE_8000_96000, .i2s_variant_regs = &i2sv6_regs, }; static const struct samsung_i2s_dai_data i2sv7_dai_type = { .quirks = QUIRK_PRI_6CHAN | QUIRK_SEC_DAI | QUIRK_NEED_RSTCLR | QUIRK_SUPPORTS_TDM, + .pcm_rates = SNDRV_PCM_RATE_8000_192000, .i2s_variant_regs = &i2sv7_regs, }; static const struct samsung_i2s_dai_data i2sv5_dai_type_i2s1 = { .quirks = QUIRK_PRI_6CHAN | QUIRK_NEED_RSTCLR, + .pcm_rates = SNDRV_PCM_RATE_8000_96000, .i2s_variant_regs = &i2sv5_i2s1_regs, }; -- cgit v1.1 From 27d30400c448264c1ac9434cb836de0c230af213 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 30 Jun 2017 15:43:50 -0500 Subject: ASoC: spear: fix error return code in spdif_in_probe() platform_get_irq() returns an error code, but the spdif_in driver ignores it and always returns -EINVAL. This is not correct, and prevents -EPROBE_DEFER from being propagated properly. Notice that platform_get_irq() no longer returns 0 on error: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e330b9a6bb35dc7097a4f02cb1ae7b6f96df92af Print error message and propagate the return value of platform_get_irq on failure. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/spear/spdif_in.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/spear/spdif_in.c b/sound/soc/spear/spdif_in.c index 977a078..7f32527 100644 --- a/sound/soc/spear/spdif_in.c +++ b/sound/soc/spear/spdif_in.c @@ -223,8 +223,10 @@ static int spdif_in_probe(struct platform_device *pdev) host->io_base = io_base; host->irq = platform_get_irq(pdev, 0); - if (host->irq < 0) - return -EINVAL; + if (host->irq < 0) { + dev_warn(&pdev->dev, "failed to get IRQ: %d\n", host->irq); + return host->irq; + } host->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(host->clk)) -- cgit v1.1 From cfe267da9de756d15eab095358b0b122c57816a6 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 30 Jun 2017 17:26:48 -0500 Subject: ASoC: twl6040: fix error return code in twl6040_probe() platform_get_irq() returns an error code, but the twl6040 driver ignores it and always returns -EINVAL. This is not correct, and prevents -EPROBE_DEFER from being propagated properly. Notice that platform_get_irq() no longer returns 0 on error. Print and propagate the return value of platform_get_irq on failure. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 2b6ad09..96cf94a 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -1123,8 +1123,8 @@ static int twl6040_probe(struct snd_soc_codec *codec) priv->plug_irq = platform_get_irq(pdev, 0); if (priv->plug_irq < 0) { - dev_err(codec->dev, "invalid irq\n"); - return -EINVAL; + dev_err(codec->dev, "invalid irq: %d\n", priv->plug_irq); + return priv->plug_irq; } INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work); -- cgit v1.1 From 2d397c518eead8b6c3cd817c29bc2d4fb1c41830 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 17 Jul 2017 07:44:21 +0200 Subject: ASoC: samsung: Remove non-existing CONFIG_CPU_S3C2413 There is no CONFIG_CPU_S3C2413 so get rid of it. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/s3c-i2s-v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index 8f42dea..ca522a9 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c @@ -27,7 +27,7 @@ #undef S3C_IIS_V2_SUPPORTED -#if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413) \ +#if defined(CONFIG_CPU_S3C2412) \ || defined(CONFIG_ARCH_S3C64XX) || defined(CONFIG_CPU_S5PV210) #define S3C_IIS_V2_SUPPORTED #endif -- cgit v1.1 From 4b2983da22d30c53d778b2e5035dc347dc4b0037 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Sun, 16 Jul 2017 21:12:21 -0500 Subject: ASoC: fsi: constify dev_pm_ops structure This dev_pm_ops structure is only stored in the pm field of a device_driver structure. This field is declared const, so dev_pm_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/sh/fsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 7c4bdd8..005b215 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -2109,7 +2109,7 @@ static int fsi_resume(struct device *dev) return 0; } -static struct dev_pm_ops fsi_pm_ops = { +static const struct dev_pm_ops fsi_pm_ops = { .suspend = fsi_suspend, .resume = fsi_resume, }; -- cgit v1.1 From da61a11823395c87db0471d8d54055fa5a961688 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Sun, 16 Jul 2017 21:12:39 -0500 Subject: ASoC: psc-ac97: constify dev_pm_ops structure This dev_pm_ops structure is only stored in the pm field of a device_driver structure. This field is declared const, so dev_pm_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/au1x/psc-ac97.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c index bb53c70..a2050ae 100644 --- a/sound/soc/au1x/psc-ac97.c +++ b/sound/soc/au1x/psc-ac97.c @@ -474,7 +474,7 @@ static int au1xpsc_ac97_drvresume(struct device *dev) return 0; } -static struct dev_pm_ops au1xpscac97_pmops = { +static const struct dev_pm_ops au1xpscac97_pmops = { .suspend = au1xpsc_ac97_drvsuspend, .resume = au1xpsc_ac97_drvresume, }; -- cgit v1.1 From 90982dcdda4f0163bc5e53f49301e155c2cd8547 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Sun, 16 Jul 2017 21:12:49 -0500 Subject: ASoC: au1x: psc-i2s: constify dev_pm_ops structure This dev_pm_ops structure is only stored in the pm field of a device_driver structure. This field is declared const, so dev_pm_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/au1x/psc-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c index 0bf9d62..e6eec08 100644 --- a/sound/soc/au1x/psc-i2s.c +++ b/sound/soc/au1x/psc-i2s.c @@ -392,7 +392,7 @@ static int au1xpsc_i2s_drvresume(struct device *dev) return 0; } -static struct dev_pm_ops au1xpsci2s_pmops = { +static const struct dev_pm_ops au1xpsci2s_pmops = { .suspend = au1xpsc_i2s_drvsuspend, .resume = au1xpsc_i2s_drvresume, }; -- cgit v1.1 From d5c6d43b3d94e7bf421ec2aaf21b4b7c79fa1850 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 14 Jul 2017 00:04:06 +0100 Subject: ASoC: Intel: Skylake: fix type in debug message Trivial fix to typo in debug message, dst_instacne should be dst_instance Signed-off-by: Colin Ian King Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index fb2f1f6..c5b4e0a 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -950,7 +950,7 @@ static void skl_dump_bind_info(struct skl_sst *ctx, struct skl_module_cfg { dev_dbg(ctx->dev, "%s: src module_id = %d src_instance=%d\n", __func__, src_module->id.module_id, src_module->id.pvt_id); - dev_dbg(ctx->dev, "%s: dst_module=%d dst_instacne=%d\n", __func__, + dev_dbg(ctx->dev, "%s: dst_module=%d dst_instance=%d\n", __func__, dst_module->id.module_id, dst_module->id.pvt_id); dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n", -- cgit v1.1 From 82e2b1e081906d3d86c4597250ab2939b209079f Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 01:16:46 -0500 Subject: ASoC: Intel: Skylake: constify snd_soc_dai_ops structures These structures are only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 0ebea34a..b1f2dba 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -628,7 +628,7 @@ static int skl_link_hw_free(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_dai_ops skl_pcm_dai_ops = { +static const struct snd_soc_dai_ops skl_pcm_dai_ops = { .startup = skl_pcm_open, .shutdown = skl_pcm_close, .prepare = skl_pcm_prepare, @@ -637,15 +637,15 @@ static struct snd_soc_dai_ops skl_pcm_dai_ops = { .trigger = skl_pcm_trigger, }; -static struct snd_soc_dai_ops skl_dmic_dai_ops = { +static const struct snd_soc_dai_ops skl_dmic_dai_ops = { .hw_params = skl_be_hw_params, }; -static struct snd_soc_dai_ops skl_be_ssp_dai_ops = { +static const struct snd_soc_dai_ops skl_be_ssp_dai_ops = { .hw_params = skl_be_hw_params, }; -static struct snd_soc_dai_ops skl_link_dai_ops = { +static const struct snd_soc_dai_ops skl_link_dai_ops = { .prepare = skl_link_pcm_prepare, .hw_params = skl_link_hw_params, .hw_free = skl_link_hw_free, -- cgit v1.1 From c115a3178b1dfacd57b643934bb6bbbd1a9557f0 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 01:26:06 -0500 Subject: ASoC: Intel: Atom: constify snd_soc_dai_ops structures These structures are only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index b082b31..49c7b88 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -471,7 +471,7 @@ static void sst_disable_ssp(struct snd_pcm_substream *substream, } } -static struct snd_soc_dai_ops sst_media_dai_ops = { +static const struct snd_soc_dai_ops sst_media_dai_ops = { .startup = sst_media_open, .shutdown = sst_media_close, .prepare = sst_media_prepare, @@ -480,11 +480,11 @@ static struct snd_soc_dai_ops sst_media_dai_ops = { .mute_stream = sst_media_digital_mute, }; -static struct snd_soc_dai_ops sst_compr_dai_ops = { +static const struct snd_soc_dai_ops sst_compr_dai_ops = { .mute_stream = sst_media_digital_mute, }; -static struct snd_soc_dai_ops sst_be_dai_ops = { +static const struct snd_soc_dai_ops sst_be_dai_ops = { .startup = sst_enable_ssp, .hw_params = sst_be_hw_params, .set_fmt = sst_set_format, -- cgit v1.1 From fa05899c12d54d3a1befa742f62d3188e551a87c Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 14 Jul 2017 14:36:32 +0800 Subject: ASoC: rt5665: force using PLL if MCLK is not suitable Idealy PLL will be set in machine driver if MCLK doesn't meet the requirement of codec. To let the codec driver be more general, we can use a common PLL setting once sysclk/pll doesn't set properly in machine driver. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5665.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 370ed54d..d3103ef 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -4098,9 +4098,12 @@ static int rt5665_hw_params(struct snd_pcm_substream *substream, rt5665->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5665->sysclk, rt5665->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", - rt5665->lrck[dai->id], dai->id); - return -EINVAL; + dev_warn(codec->dev, "Force using PLL"); + snd_soc_codec_set_pll(codec, 0, RT5665_PLL1_S_MCLK, + rt5665->sysclk, rt5665->lrck[dai->id] * 512); + snd_soc_codec_set_sysclk(codec, RT5665_SCLK_S_PLL1, 0, + rt5665->lrck[dai->id] * 512, 0); + pre_div = 1; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { -- cgit v1.1 From 53ba2aa314164f7fcd3acf9594313811256a52c4 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 15 Jul 2017 09:19:07 +0200 Subject: ASoC: rsnd: add missing of_node_put for_each_child_of_node performs an of_node_get on each iteration, so a jump out of the loop requires an of_node_put. The semantic patch that fixes this problem is as follows (http://coccinelle.lip6.fr): // @@ local idexpression n; expression e,e1; identifier l; @@ for_each_child_of_node(e1,n) { ... ( of_node_put(n); | e = n | + of_node_put(n); ? goto l; ) ... } ... l: ... when != n // Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ctu.c | 5 ++++- sound/soc/sh/rcar/dvc.c | 5 ++++- sound/soc/sh/rcar/mix.c | 5 ++++- sound/soc/sh/rcar/src.c | 6 +++++- sound/soc/sh/rcar/ssi.c | 6 +++++- 5 files changed, 22 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ctu.c b/sound/soc/sh/rcar/ctu.c index 4ba8f2f..e7f53f4 100644 --- a/sound/soc/sh/rcar/ctu.c +++ b/sound/soc/sh/rcar/ctu.c @@ -394,13 +394,16 @@ int rsnd_ctu_probe(struct rsnd_priv *priv) clk = devm_clk_get(dev, name); if (IS_ERR(clk)) { ret = PTR_ERR(clk); + of_node_put(np); goto rsnd_ctu_probe_done; } ret = rsnd_mod_init(priv, rsnd_mod_get(ctu), &rsnd_ctu_ops, clk, rsnd_mod_get_status, RSND_MOD_CTU, i); - if (ret) + if (ret) { + of_node_put(np); goto rsnd_ctu_probe_done; + } i++; } diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 99d2d94..1743ade 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -380,13 +380,16 @@ int rsnd_dvc_probe(struct rsnd_priv *priv) clk = devm_clk_get(dev, name); if (IS_ERR(clk)) { ret = PTR_ERR(clk); + of_node_put(np); goto rsnd_dvc_probe_done; } ret = rsnd_mod_init(priv, rsnd_mod_get(dvc), &rsnd_dvc_ops, clk, rsnd_mod_get_status, RSND_MOD_DVC, i); - if (ret) + if (ret) { + of_node_put(np); goto rsnd_dvc_probe_done; + } i++; } diff --git a/sound/soc/sh/rcar/mix.c b/sound/soc/sh/rcar/mix.c index 195fc7b..6c4826c 100644 --- a/sound/soc/sh/rcar/mix.c +++ b/sound/soc/sh/rcar/mix.c @@ -168,13 +168,16 @@ int rsnd_mix_probe(struct rsnd_priv *priv) clk = devm_clk_get(dev, name); if (IS_ERR(clk)) { ret = PTR_ERR(clk); + of_node_put(np); goto rsnd_mix_probe_done; } ret = rsnd_mod_init(priv, rsnd_mod_get(mix), &rsnd_mix_ops, clk, rsnd_mod_get_status, RSND_MOD_MIX, i); - if (ret) + if (ret) { + of_node_put(np); goto rsnd_mix_probe_done; + } i++; } diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 7aa239e..8e9a1de 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -581,20 +581,24 @@ int rsnd_src_probe(struct rsnd_priv *priv) src->irq = irq_of_parse_and_map(np, 0); if (!src->irq) { ret = -EINVAL; + of_node_put(np); goto rsnd_src_probe_done; } clk = devm_clk_get(dev, name); if (IS_ERR(clk)) { ret = PTR_ERR(clk); + of_node_put(np); goto rsnd_src_probe_done; } ret = rsnd_mod_init(priv, rsnd_mod_get(src), &rsnd_src_ops, clk, rsnd_mod_get_status, RSND_MOD_SRC, i); - if (ret) + if (ret) { + of_node_put(np); goto rsnd_src_probe_done; + } skip: i++; diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 46feddd..49cdc5e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -1079,6 +1079,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) clk = devm_clk_get(dev, name); if (IS_ERR(clk)) { ret = PTR_ERR(clk); + of_node_put(np); goto rsnd_ssi_probe_done; } @@ -1091,6 +1092,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) ssi->irq = irq_of_parse_and_map(np, 0); if (!ssi->irq) { ret = -EINVAL; + of_node_put(np); goto rsnd_ssi_probe_done; } @@ -1101,8 +1103,10 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) ret = rsnd_mod_init(priv, rsnd_mod_get(ssi), ops, clk, rsnd_ssi_get_status, RSND_MOD_SSI, i); - if (ret) + if (ret) { + of_node_put(np); goto rsnd_ssi_probe_done; + } i++; } -- cgit v1.1 From d51579e6effa19c1ca4d6a29c3841cb454d56af6 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:06 -0300 Subject: ASoC: sun4i-codec: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-codec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 1500699..4c37231 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -1171,9 +1171,8 @@ static int sun4i_codec_spk_event(struct snd_soc_dapm_widget *w, { struct sun4i_codec *scodec = snd_soc_card_get_drvdata(w->dapm->card); - if (scodec->gpio_pa) - gpiod_set_value_cansleep(scodec->gpio_pa, - !!SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value_cansleep(scodec->gpio_pa, + !!SND_SOC_DAPM_EVENT_ON(event)); return 0; } -- cgit v1.1 From 68feed90070e5133c0bfe26648410a39e092018d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:08 -0300 Subject: ASoC: adau1977: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/adau1977.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c index b319db6..ccc5cf0 100644 --- a/sound/soc/codecs/adau1977.c +++ b/sound/soc/codecs/adau1977.c @@ -388,8 +388,7 @@ static int adau1977_power_disable(struct adau1977 *adau1977) regcache_mark_dirty(adau1977->regmap); - if (adau1977->reset_gpio) - gpiod_set_value_cansleep(adau1977->reset_gpio, 0); + gpiod_set_value_cansleep(adau1977->reset_gpio, 0); regcache_cache_only(adau1977->regmap, true); @@ -420,8 +419,7 @@ static int adau1977_power_enable(struct adau1977 *adau1977) goto err_disable_avdd; } - if (adau1977->reset_gpio) - gpiod_set_value_cansleep(adau1977->reset_gpio, 1); + gpiod_set_value_cansleep(adau1977->reset_gpio, 1); regcache_cache_only(adau1977->regmap, false); -- cgit v1.1 From 89b13706c4bb6dae0263014051dd59986376faa5 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:07 -0300 Subject: ASoC: wm8804: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/wm8804.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index af95d648..fc69b87 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -623,8 +623,7 @@ int wm8804_probe(struct device *dev, struct regmap *regmap) return ret; } - if (wm8804->reset) - gpiod_set_value_cansleep(wm8804->reset, 1); + gpiod_set_value_cansleep(wm8804->reset, 1); ret = regmap_read(regmap, WM8804_RST_DEVID1, &id1); if (ret < 0) { -- cgit v1.1 From c5660778b4851b1aea5d848ccfde3f27949f6418 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:09 -0300 Subject: ASoC: cs35l33: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l33.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c index 6df29fa..1eea912 100644 --- a/sound/soc/codecs/cs35l33.c +++ b/sound/soc/codecs/cs35l33.c @@ -869,8 +869,7 @@ static int __maybe_unused cs35l33_runtime_resume(struct device *dev) dev_dbg(dev, "%s\n", __func__); - if (cs35l33->reset_gpio) - gpiod_set_value_cansleep(cs35l33->reset_gpio, 0); + gpiod_set_value_cansleep(cs35l33->reset_gpio, 0); ret = regulator_bulk_enable(cs35l33->num_core_supplies, cs35l33->core_supplies); @@ -881,8 +880,7 @@ static int __maybe_unused cs35l33_runtime_resume(struct device *dev) regcache_cache_only(cs35l33->regmap, false); - if (cs35l33->reset_gpio) - gpiod_set_value_cansleep(cs35l33->reset_gpio, 1); + gpiod_set_value_cansleep(cs35l33->reset_gpio, 1); msleep(CS35L33_BOOT_DELAY); @@ -1191,8 +1189,7 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client, return ret; } - if (cs35l33->reset_gpio) - gpiod_set_value_cansleep(cs35l33->reset_gpio, 1); + gpiod_set_value_cansleep(cs35l33->reset_gpio, 1); msleep(CS35L33_BOOT_DELAY); regcache_cache_only(cs35l33->regmap, false); @@ -1262,8 +1259,7 @@ static int cs35l33_i2c_remove(struct i2c_client *client) snd_soc_unregister_codec(&client->dev); - if (cs35l33->reset_gpio) - gpiod_set_value_cansleep(cs35l33->reset_gpio, 0); + gpiod_set_value_cansleep(cs35l33->reset_gpio, 0); pm_runtime_disable(&client->dev); regulator_bulk_disable(cs35l33->num_core_supplies, -- cgit v1.1 From db3be255a101da11f67c0f3053b750e767eb10fe Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:10 -0300 Subject: ASoC: cs35l34: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l34.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs35l34.c b/sound/soc/codecs/cs35l34.c index 0a747c6..dade899 100644 --- a/sound/soc/codecs/cs35l34.c +++ b/sound/soc/codecs/cs35l34.c @@ -1138,8 +1138,7 @@ static int cs35l34_i2c_remove(struct i2c_client *client) snd_soc_unregister_codec(&client->dev); - if (cs35l34->reset_gpio) - gpiod_set_value_cansleep(cs35l34->reset_gpio, 0); + gpiod_set_value_cansleep(cs35l34->reset_gpio, 0); pm_runtime_disable(&client->dev); regulator_bulk_disable(cs35l34->num_core_supplies, -- cgit v1.1 From 205cbac065f9589c77a79f26339cf63023f08f6e Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:11 -0300 Subject: ASoC: cs42l42: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l42.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index 55e4520..55caf5f 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -1898,8 +1898,7 @@ static int cs42l42_i2c_remove(struct i2c_client *i2c_client) snd_soc_unregister_codec(&i2c_client->dev); /* Hold down reset */ - if (cs42l42->reset_gpio) - gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); + gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); return 0; } @@ -1913,8 +1912,7 @@ static int cs42l42_runtime_suspend(struct device *dev) regcache_mark_dirty(cs42l42->regmap); /* Hold down reset */ - if (cs42l42->reset_gpio) - gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); + gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); /* remove power */ regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), @@ -1937,8 +1935,7 @@ static int cs42l42_runtime_resume(struct device *dev) return ret; } - if (cs42l42->reset_gpio) - gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); + gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); regcache_cache_only(cs42l42->regmap, false); regcache_sync(cs42l42->regmap); -- cgit v1.1 From 55be663dc71ec50f0e383c50886cbd3be69fcd2e Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:12 -0300 Subject: ASoC: cs53l30: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/cs53l30.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs53l30.c b/sound/soc/codecs/cs53l30.c index 06933a5..92fbe63 100644 --- a/sound/soc/codecs/cs53l30.c +++ b/sound/soc/codecs/cs53l30.c @@ -842,8 +842,7 @@ static int cs53l30_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); - if (priv->mute_gpio) - gpiod_set_value_cansleep(priv->mute_gpio, mute); + gpiod_set_value_cansleep(priv->mute_gpio, mute); return 0; } @@ -960,8 +959,7 @@ static int cs53l30_i2c_probe(struct i2c_client *client, goto error; } - if (cs53l30->reset_gpio) - gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); + gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); i2c_set_clientdata(client, cs53l30); @@ -1056,8 +1054,7 @@ static int cs53l30_i2c_remove(struct i2c_client *client) snd_soc_unregister_codec(&client->dev); /* Hold down reset */ - if (cs53l30->reset_gpio) - gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); + gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), cs53l30->supplies); @@ -1073,8 +1070,7 @@ static int cs53l30_runtime_suspend(struct device *dev) regcache_cache_only(cs53l30->regmap, true); /* Hold down reset */ - if (cs53l30->reset_gpio) - gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); + gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), cs53l30->supplies); @@ -1094,8 +1090,7 @@ static int cs53l30_runtime_resume(struct device *dev) return ret; } - if (cs53l30->reset_gpio) - gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); + gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); regcache_cache_only(cs53l30->regmap, false); ret = regcache_sync(cs53l30->regmap); -- cgit v1.1 From c5efe232e09ef29cc2f9e8333a49dd8891366c22 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 16 Jul 2017 18:11:13 -0300 Subject: ASoC: sta32x: Remove unneeded gpiod NULL check The gpiod API checks for NULL descriptors, so there is no need to duplicate the check in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 0790ae8..5b88847 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -847,8 +847,7 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, msleep(300); sta32x_watchdog_stop(sta32x); - if (sta32x->gpiod_nreset) - gpiod_set_value(sta32x->gpiod_nreset, 0); + gpiod_set_value(sta32x->gpiod_nreset, 0); regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); -- cgit v1.1 From 173f4612690ac569d9f912a31aa69af15b84047c Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Thu, 13 Jul 2017 19:42:20 +0800 Subject: ASoC: rt5514: Support the DSP recording continuously after the hotwording triggered The patch uses the IRQ to copy the PCM data to userspace continuously after the hotwording triggered from DSP. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 139 ++++++++++++++++++++++-------------------- sound/soc/codecs/rt5514-spi.h | 7 +-- 2 files changed, 76 insertions(+), 70 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 7ed62e8..950d1ff 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -43,9 +43,7 @@ struct rt5514_dsp { struct mutex dma_lock; struct snd_pcm_substream *substream; unsigned int buf_base, buf_limit, buf_rp; - size_t buf_size; - size_t dma_offset; - size_t dsp_offset; + size_t buf_size, get_size, dma_offset; }; static const struct snd_pcm_hardware rt5514_spi_pcm_hardware = { @@ -80,6 +78,8 @@ static void rt5514_spi_copy_work(struct work_struct *work) container_of(work, struct rt5514_dsp, copy_work.work); struct snd_pcm_runtime *runtime; size_t period_bytes, truncated_bytes = 0; + unsigned int cur_wp, remain_data; + u8 buf[8]; mutex_lock(&rt5514_dsp->dma_lock); if (!rt5514_dsp->substream) { @@ -90,8 +90,24 @@ static void rt5514_spi_copy_work(struct work_struct *work) runtime = rt5514_dsp->substream->runtime; period_bytes = snd_pcm_lib_period_bytes(rt5514_dsp->substream); - if (rt5514_dsp->buf_size - rt5514_dsp->dsp_offset < period_bytes) - period_bytes = rt5514_dsp->buf_size - rt5514_dsp->dsp_offset; + if (rt5514_dsp->get_size >= rt5514_dsp->buf_size) { + rt5514_spi_burst_read(RT5514_BUFFER_VOICE_WP, (u8 *)&buf, + sizeof(buf)); + cur_wp = buf[0] | buf[1] << 8 | buf[2] << 16 | + buf[3] << 24; + + if (cur_wp >= rt5514_dsp->buf_rp) + remain_data = (cur_wp - rt5514_dsp->buf_rp); + else + remain_data = + (rt5514_dsp->buf_limit - rt5514_dsp->buf_rp) + + (cur_wp - rt5514_dsp->buf_base); + + if (remain_data < period_bytes) { + schedule_delayed_work(&rt5514_dsp->copy_work, 5); + goto done; + } + } if (rt5514_dsp->buf_rp + period_bytes <= rt5514_dsp->buf_limit) { rt5514_spi_burst_read(rt5514_dsp->buf_rp, @@ -112,24 +128,58 @@ static void rt5514_spi_copy_work(struct work_struct *work) runtime->dma_area + rt5514_dsp->dma_offset + truncated_bytes, period_bytes - truncated_bytes); - rt5514_dsp->buf_rp = rt5514_dsp->buf_base + - period_bytes - truncated_bytes; + rt5514_dsp->buf_rp = rt5514_dsp->buf_base + period_bytes - + truncated_bytes; } + rt5514_dsp->get_size += period_bytes; rt5514_dsp->dma_offset += period_bytes; if (rt5514_dsp->dma_offset >= runtime->dma_bytes) rt5514_dsp->dma_offset = 0; - rt5514_dsp->dsp_offset += period_bytes; - snd_pcm_period_elapsed(rt5514_dsp->substream); - if (rt5514_dsp->dsp_offset < rt5514_dsp->buf_size) - schedule_delayed_work(&rt5514_dsp->copy_work, 5); + schedule_delayed_work(&rt5514_dsp->copy_work, 5); + done: mutex_unlock(&rt5514_dsp->dma_lock); } +static irqreturn_t rt5514_spi_irq(int irq, void *data) +{ + struct rt5514_dsp *rt5514_dsp = data; + u8 buf[8]; + + rt5514_dsp->get_size = 0; + rt5514_dsp->dma_offset = 0; + + /** + * The address area x1800XXXX is the register address, and it cannot + * support spi burst read perfectly. So we use the spi burst read + * individually to make sure the data correctly. + */ + rt5514_spi_burst_read(RT5514_BUFFER_VOICE_BASE, (u8 *)&buf, + sizeof(buf)); + rt5514_dsp->buf_base = buf[0] | buf[1] << 8 | buf[2] << 16 | + buf[3] << 24; + + rt5514_spi_burst_read(RT5514_BUFFER_VOICE_LIMIT, (u8 *)&buf, + sizeof(buf)); + rt5514_dsp->buf_limit = buf[0] | buf[1] << 8 | buf[2] << 16 | + buf[3] << 24; + + rt5514_spi_burst_read(RT5514_BUFFER_VOICE_WP, (u8 *)&buf, + sizeof(buf)); + rt5514_dsp->buf_rp = buf[0] | buf[1] << 8 | buf[2] << 16 | + buf[3] << 24; + + rt5514_dsp->buf_size = rt5514_dsp->buf_limit - rt5514_dsp->buf_base; + + schedule_delayed_work(&rt5514_dsp->copy_work, 0); + + return IRQ_HANDLED; +} + /* PCM for streaming audio from the DSP buffer */ static int rt5514_spi_pcm_open(struct snd_pcm_substream *substream) { @@ -170,59 +220,6 @@ static int rt5514_spi_hw_free(struct snd_pcm_substream *substream) return snd_pcm_lib_free_vmalloc_buffer(substream); } -static int rt5514_spi_prepare(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); - u8 buf[8]; - - rt5514_dsp->dma_offset = 0; - rt5514_dsp->dsp_offset = 0; - - /** - * The address area x1800XXXX is the register address, and it cannot - * support spi burst read perfectly. So we use the spi burst read - * individually to make sure the data correctly. - */ - rt5514_spi_burst_read(RT5514_BUFFER_VOICE_BASE, (u8 *)&buf, - sizeof(buf)); - rt5514_dsp->buf_base = buf[0] | buf[1] << 8 | buf[2] << 16 | - buf[3] << 24; - - rt5514_spi_burst_read(RT5514_BUFFER_VOICE_LIMIT, (u8 *)&buf, - sizeof(buf)); - rt5514_dsp->buf_limit = buf[0] | buf[1] << 8 | buf[2] << 16 | - buf[3] << 24; - - rt5514_spi_burst_read(RT5514_BUFFER_VOICE_RP, (u8 *)&buf, - sizeof(buf)); - rt5514_dsp->buf_rp = buf[0] | buf[1] << 8 | buf[2] << 16 | - buf[3] << 24; - - rt5514_spi_burst_read(RT5514_BUFFER_VOICE_SIZE, (u8 *)&buf, - sizeof(buf)); - rt5514_dsp->buf_size = buf[0] | buf[1] << 8 | buf[2] << 16 | - buf[3] << 24; - - return 0; -} - -static int rt5514_spi_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); - - if (cmd == SNDRV_PCM_TRIGGER_START) { - if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit && - rt5514_dsp->buf_rp && rt5514_dsp->buf_size) - schedule_delayed_work(&rt5514_dsp->copy_work, 0); - } - - return 0; -} - static snd_pcm_uframes_t rt5514_spi_pcm_pointer( struct snd_pcm_substream *substream) { @@ -238,8 +235,6 @@ static const struct snd_pcm_ops rt5514_spi_pcm_ops = { .open = rt5514_spi_pcm_open, .hw_params = rt5514_spi_hw_params, .hw_free = rt5514_spi_hw_free, - .trigger = rt5514_spi_trigger, - .prepare = rt5514_spi_prepare, .pointer = rt5514_spi_pcm_pointer, .mmap = snd_pcm_lib_mmap_vmalloc, .page = snd_pcm_lib_get_vmalloc_page, @@ -248,6 +243,7 @@ static const struct snd_pcm_ops rt5514_spi_pcm_ops = { static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) { struct rt5514_dsp *rt5514_dsp; + int ret; rt5514_dsp = devm_kzalloc(platform->dev, sizeof(*rt5514_dsp), GFP_KERNEL); @@ -257,6 +253,17 @@ static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) INIT_DELAYED_WORK(&rt5514_dsp->copy_work, rt5514_spi_copy_work); snd_soc_platform_set_drvdata(platform, rt5514_dsp); + if (rt5514_spi->irq) { + ret = devm_request_threaded_irq(&rt5514_spi->dev, + rt5514_spi->irq, NULL, rt5514_spi_irq, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5514-spi", + rt5514_dsp); + if (ret) + dev_err(&rt5514_spi->dev, + "%s Failed to reguest IRQ: %d\n", __func__, + ret); + } + return 0; } diff --git a/sound/soc/codecs/rt5514-spi.h b/sound/soc/codecs/rt5514-spi.h index f69b1cd..a6434ee 100644 --- a/sound/soc/codecs/rt5514-spi.h +++ b/sound/soc/codecs/rt5514-spi.h @@ -17,10 +17,9 @@ */ #define RT5514_SPI_BUF_LEN 240 -#define RT5514_BUFFER_VOICE_BASE 0x18001034 -#define RT5514_BUFFER_VOICE_LIMIT 0x18001038 -#define RT5514_BUFFER_VOICE_RP 0x1800103c -#define RT5514_BUFFER_VOICE_SIZE 0x18001040 +#define RT5514_BUFFER_VOICE_BASE 0x18000200 +#define RT5514_BUFFER_VOICE_LIMIT 0x18000204 +#define RT5514_BUFFER_VOICE_WP 0x1800020c /* SPI Command */ enum { -- cgit v1.1 From 583ac685986963737997d0f6df569a3daab9c097 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 00:47:35 -0500 Subject: ASoC: tegra: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Acked-by: Jon Hunter Signed-off-by: Mark Brown --- sound/soc/tegra/tegra30_i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index b2b279c..0b176ea 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c @@ -275,7 +275,7 @@ static int tegra30_i2s_probe(struct snd_soc_dai *dai) return 0; } -static struct snd_soc_dai_ops tegra30_i2s_dai_ops = { +static const struct snd_soc_dai_ops tegra30_i2s_dai_ops = { .set_fmt = tegra30_i2s_set_fmt, .hw_params = tegra30_i2s_hw_params, .trigger = tegra30_i2s_trigger, -- cgit v1.1 From fe49cd980fc15cbb7eeb8d1a4ef45a14b807b55d Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 00:52:23 -0500 Subject: ASoC: sun8i-codec: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Acked-by: Maxime Ripard Signed-off-by: Mark Brown --- sound/soc/sunxi/sun8i-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c index 5723c34..253ae0b 100644 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@ -341,7 +341,7 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = { "AIF1 Slot 0 Right"}, }; -static struct snd_soc_dai_ops sun8i_codec_dai_ops = { +static const struct snd_soc_dai_ops sun8i_codec_dai_ops = { .hw_params = sun8i_codec_hw_params, .set_fmt = sun8i_set_fmt, }; -- cgit v1.1 From 06305d72796076b09495daa4398a43ddb68a6caa Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 02:14:21 -0500 Subject: ASoC: fsl_spdif: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_spdif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 1ff467c..7e6cc4d 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -626,7 +626,7 @@ static int fsl_spdif_trigger(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_dai_ops fsl_spdif_dai_ops = { +static const struct snd_soc_dai_ops fsl_spdif_dai_ops = { .startup = fsl_spdif_startup, .hw_params = fsl_spdif_hw_params, .trigger = fsl_spdif_trigger, -- cgit v1.1 From 5d29e95eec1451d35ef6ce5b851fbc8b04f82d39 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 02:19:25 -0500 Subject: ASoC: fsl_esai: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 809a069..cef79a1 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -620,7 +620,7 @@ static int fsl_esai_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } -static struct snd_soc_dai_ops fsl_esai_dai_ops = { +static const struct snd_soc_dai_ops fsl_esai_dai_ops = { .startup = fsl_esai_startup, .shutdown = fsl_esai_shutdown, .trigger = fsl_esai_trigger, -- cgit v1.1 From 29a22ebfa4c44bf96b3d00d90b5e3b8128d8a162 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 02:23:51 -0500 Subject: ASoC: fsl_asrc: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 8cfffa7..806d399 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -542,7 +542,7 @@ static int fsl_asrc_dai_trigger(struct snd_pcm_substream *substream, int cmd, return 0; } -static struct snd_soc_dai_ops fsl_asrc_dai_ops = { +static const struct snd_soc_dai_ops fsl_asrc_dai_ops = { .hw_params = fsl_asrc_dai_hw_params, .hw_free = fsl_asrc_dai_hw_free, .trigger = fsl_asrc_dai_trigger, -- cgit v1.1 From 94372fceb2fb5d3d05d6db61c9658865d5e27ee4 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 02:08:53 -0500 Subject: ASoC: hisilicon: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/hisilicon/hi6210-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/hisilicon/hi6210-i2s.c b/sound/soc/hisilicon/hi6210-i2s.c index b193d3b..0c8f86d 100644 --- a/sound/soc/hisilicon/hi6210-i2s.c +++ b/sound/soc/hisilicon/hi6210-i2s.c @@ -517,7 +517,7 @@ static int hi6210_i2s_dai_probe(struct snd_soc_dai *dai) } -static struct snd_soc_dai_ops hi6210_i2s_dai_ops = { +static const struct snd_soc_dai_ops hi6210_i2s_dai_ops = { .trigger = hi6210_i2s_trigger, .hw_params = hi6210_i2s_hw_params, .set_fmt = hi6210_i2s_set_fmt, -- cgit v1.1 From 549acff975c9245ea8d469c0defa50e52489227c Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 01:10:19 -0500 Subject: ASoC: mediatek: mt2701: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index bc5d4db..10dcd69 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -595,7 +595,7 @@ static const struct snd_soc_dai_ops mt2701_afe_i2s_ops = { }; /* MRG BE DAIs */ -static struct snd_soc_dai_ops mt2701_btmrg_ops = { +static const struct snd_soc_dai_ops mt2701_btmrg_ops = { .startup = mt2701_btmrg_startup, .shutdown = mt2701_btmrg_shutdown, .hw_params = mt2701_btmrg_hw_params, -- cgit v1.1 From cb7534437956650ab0dcebf7a7b4795eb904d22a Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 01:05:08 -0500 Subject: ASoC: mmp-sspa: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-sspa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 9cc3501..64b85e3 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -380,7 +380,7 @@ static int mmp_sspa_probe(struct snd_soc_dai *dai) SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops mmp_sspa_dai_ops = { +static const struct snd_soc_dai_ops mmp_sspa_dai_ops = { .startup = mmp_sspa_startup, .shutdown = mmp_sspa_shutdown, .trigger = mmp_sspa_trigger, -- cgit v1.1 From 45d059a33aa48cb19a5ff589f71abcc4de4a8fbf Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 00:22:09 -0500 Subject: ASoC: zx-i2s: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/zte/zx-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c index 8bbad1d..9a05659 100644 --- a/sound/soc/zte/zx-i2s.c +++ b/sound/soc/zte/zx-i2s.c @@ -357,7 +357,7 @@ static void zx_i2s_shutdown(struct snd_pcm_substream *substream, clk_disable_unprepare(zx_i2s->dai_pclk); } -static struct snd_soc_dai_ops zx_i2s_dai_ops = { +static const struct snd_soc_dai_ops zx_i2s_dai_ops = { .trigger = zx_i2s_trigger, .hw_params = zx_i2s_hw_params, .set_fmt = zx_i2s_set_fmt, -- cgit v1.1 From 171dd51655b11331928dd39ff0e51a516e41424d Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 00:30:52 -0500 Subject: ASoC: zx-tdm: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/zte/zx-tdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/zte/zx-tdm.c b/sound/soc/zte/zx-tdm.c index bd632cc..dc95527 100644 --- a/sound/soc/zte/zx-tdm.c +++ b/sound/soc/zte/zx-tdm.c @@ -309,7 +309,7 @@ static void zx_tdm_shutdown(struct snd_pcm_substream *substream, clk_disable_unprepare(zx_tdm->dai_wclk); } -static struct snd_soc_dai_ops zx_tdm_dai_ops = { +static const struct snd_soc_dai_ops zx_tdm_dai_ops = { .trigger = zx_tdm_trigger, .hw_params = zx_tdm_hw_params, .set_fmt = zx_tdm_set_fmt, -- cgit v1.1 From 4d2c7e09a5c8ea3b20748c2942b6a686dced34ab Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 00:37:55 -0500 Subject: ASoC: zte: spdif: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/zte/zx-spdif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/zte/zx-spdif.c b/sound/soc/zte/zx-spdif.c index 9fa6463..b143f9f 100644 --- a/sound/soc/zte/zx-spdif.c +++ b/sound/soc/zte/zx-spdif.c @@ -264,7 +264,7 @@ static void zx_spdif_shutdown(struct snd_pcm_substream *substream, (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE \ | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops zx_spdif_dai_ops = { +static const struct snd_soc_dai_ops zx_spdif_dai_ops = { .trigger = zx_spdif_trigger, .startup = zx_spdif_startup, .shutdown = zx_spdif_shutdown, -- cgit v1.1 From fde0543f1129967dfa73f1fa3477c7fe12052da5 Mon Sep 17 00:00:00 2001 From: Dan Murphy Date: Wed, 12 Jul 2017 13:36:59 -0500 Subject: ASoC: tlv320aic32x4: Add support for tlv320aic32x6 Add support for the tlv320aic32x6 family of devices. These devices share the same register set as the tlv320aic32x4 and this driver can be re-used. TLV320aic32x6 data sheets are here: tlv320aic3256 - http://www.ti.com/lit/gpn/tlv320aic3256 tlv320aic3206 - http://www.ti.com/lit/gpn/tlv320aic3206 Signed-off-by: Dan Murphy Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic32x4-i2c.c | 2 ++ sound/soc/codecs/tlv320aic32x4-spi.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic32x4-i2c.c b/sound/soc/codecs/tlv320aic32x4-i2c.c index 59606cf..385fa2e 100644 --- a/sound/soc/codecs/tlv320aic32x4-i2c.c +++ b/sound/soc/codecs/tlv320aic32x4-i2c.c @@ -47,12 +47,14 @@ static int aic32x4_i2c_remove(struct i2c_client *i2c) static const struct i2c_device_id aic32x4_i2c_id[] = { { "tlv320aic32x4", 0 }, + { "tlv320aic32x6", 1 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id); static const struct of_device_id aic32x4_of_id[] = { { .compatible = "ti,tlv320aic32x4", }, + { .compatible = "ti,tlv320aic32x6", }, { /* senitel */ } }; MODULE_DEVICE_TABLE(of, aic32x4_of_id); diff --git a/sound/soc/codecs/tlv320aic32x4-spi.c b/sound/soc/codecs/tlv320aic32x4-spi.c index 724fcdd4..07d78ae 100644 --- a/sound/soc/codecs/tlv320aic32x4-spi.c +++ b/sound/soc/codecs/tlv320aic32x4-spi.c @@ -48,12 +48,14 @@ static int aic32x4_spi_remove(struct spi_device *spi) static const struct spi_device_id aic32x4_spi_id[] = { { "tlv320aic32x4", 0 }, + { "tlv320aic32x6", 1 }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(spi, aic32x4_spi_id); static const struct of_device_id aic32x4_of_id[] = { { .compatible = "ti,tlv320aic32x4", }, + { .compatible = "ti,tlv320aic32x6", }, { /* senitel */ } }; MODULE_DEVICE_TABLE(of, aic32x4_of_id); -- cgit v1.1 From b9045b9c6b79d2ea5b888a0f9e9aa156d09ba8a9 Mon Sep 17 00:00:00 2001 From: Dan Murphy Date: Wed, 12 Jul 2017 13:37:00 -0500 Subject: ASoC: tlv320aic32x4: Add gpio configuration to the codec Add the ability to configure the MFP1->MFP5 registers as GPIOs. In addition adding ALSA controls to get and set the GPIO state. Per the data sheet each MFP can be configured as a GPIO input only, output only or either an input or output. Signed-off-by: Dan Murphy Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic32x4.c | 206 +++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/tlv320aic32x4.h | 3 + 2 files changed, 209 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 28fdfc5..300ee28 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -74,6 +74,152 @@ struct aic32x4_priv { struct regulator *supply_iov; struct regulator *supply_dv; struct regulator *supply_av; + + struct aic32x4_setup_data *setup; + struct device *dev; +}; + +static int aic32x4_get_mfp1_gpio(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + u8 val; + + val = snd_soc_read(codec, AIC32X4_DINCTL); + + ucontrol->value.integer.value[0] = (val & 0x01); + + return 0; +}; + +static int aic32x4_set_mfp2_gpio(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + u8 val; + u8 gpio_check; + + val = snd_soc_read(codec, AIC32X4_DOUTCTL); + gpio_check = (val & AIC32X4_MFP_GPIO_ENABLED); + if (gpio_check != AIC32X4_MFP_GPIO_ENABLED) { + printk(KERN_ERR "%s: MFP2 is not configure as a GPIO output\n", + __func__); + return -EINVAL; + } + + if (ucontrol->value.integer.value[0] == (val & AIC32X4_MFP2_GPIO_OUT_HIGH)) + return 0; + + if (ucontrol->value.integer.value[0]) + val |= ucontrol->value.integer.value[0]; + else + val &= ~AIC32X4_MFP2_GPIO_OUT_HIGH; + + snd_soc_write(codec, AIC32X4_DOUTCTL, val); + + return 0; +}; + +static int aic32x4_get_mfp3_gpio(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + u8 val; + + val = snd_soc_read(codec, AIC32X4_SCLKCTL); + + ucontrol->value.integer.value[0] = (val & 0x01); + + return 0; +}; + +static int aic32x4_set_mfp4_gpio(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + u8 val; + u8 gpio_check; + + val = snd_soc_read(codec, AIC32X4_MISOCTL); + gpio_check = (val & AIC32X4_MFP_GPIO_ENABLED); + if (gpio_check != AIC32X4_MFP_GPIO_ENABLED) { + printk(KERN_ERR "%s: MFP4 is not configure as a GPIO output\n", + __func__); + return -EINVAL; + } + + if (ucontrol->value.integer.value[0] == (val & AIC32X4_MFP5_GPIO_OUT_HIGH)) + return 0; + + if (ucontrol->value.integer.value[0]) + val |= ucontrol->value.integer.value[0]; + else + val &= ~AIC32X4_MFP5_GPIO_OUT_HIGH; + + snd_soc_write(codec, AIC32X4_MISOCTL, val); + + return 0; +}; + +static int aic32x4_get_mfp5_gpio(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + u8 val; + + val = snd_soc_read(codec, AIC32X4_GPIOCTL); + ucontrol->value.integer.value[0] = ((val & 0x2) >> 1); + + return 0; +}; + +static int aic32x4_set_mfp5_gpio(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + u8 val; + u8 gpio_check; + + val = snd_soc_read(codec, AIC32X4_GPIOCTL); + gpio_check = (val & AIC32X4_MFP5_GPIO_OUTPUT); + if (gpio_check != AIC32X4_MFP5_GPIO_OUTPUT) { + printk(KERN_ERR "%s: MFP5 is not configure as a GPIO output\n", + __func__); + return -EINVAL; + } + + if (ucontrol->value.integer.value[0] == (val & 0x1)) + return 0; + + if (ucontrol->value.integer.value[0]) + val |= ucontrol->value.integer.value[0]; + else + val &= 0xfe; + + snd_soc_write(codec, AIC32X4_GPIOCTL, val); + + return 0; +}; + +static const struct snd_kcontrol_new aic32x4_mfp1[] = { + SOC_SINGLE_BOOL_EXT("MFP1 GPIO", 0, aic32x4_get_mfp1_gpio, NULL), +}; + +static const struct snd_kcontrol_new aic32x4_mfp2[] = { + SOC_SINGLE_BOOL_EXT("MFP2 GPIO", 0, NULL, aic32x4_set_mfp2_gpio), +}; + +static const struct snd_kcontrol_new aic32x4_mfp3[] = { + SOC_SINGLE_BOOL_EXT("MFP3 GPIO", 0, aic32x4_get_mfp3_gpio, NULL), +}; + +static const struct snd_kcontrol_new aic32x4_mfp4[] = { + SOC_SINGLE_BOOL_EXT("MFP4 GPIO", 0, NULL, aic32x4_set_mfp4_gpio), +}; + +static const struct snd_kcontrol_new aic32x4_mfp5[] = { + SOC_SINGLE_BOOL_EXT("MFP5 GPIO", 0, aic32x4_get_mfp5_gpio, + aic32x4_set_mfp5_gpio), }; /* 0dB min, 0.5dB steps */ @@ -734,6 +880,52 @@ static struct snd_soc_dai_driver aic32x4_dai = { .symmetric_rates = 1, }; +static void aic32x4_setup_gpios(struct snd_soc_codec *codec) +{ + struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + + /* setup GPIO functions */ + /* MFP1 */ + if (aic32x4->setup->gpio_func[0] != AIC32X4_MFPX_DEFAULT_VALUE) { + snd_soc_write(codec, AIC32X4_DINCTL, + aic32x4->setup->gpio_func[0]); + snd_soc_add_codec_controls(codec, aic32x4_mfp1, + ARRAY_SIZE(aic32x4_mfp1)); + } + + /* MFP2 */ + if (aic32x4->setup->gpio_func[1] != AIC32X4_MFPX_DEFAULT_VALUE) { + snd_soc_write(codec, AIC32X4_DOUTCTL, + aic32x4->setup->gpio_func[1]); + snd_soc_add_codec_controls(codec, aic32x4_mfp2, + ARRAY_SIZE(aic32x4_mfp2)); + } + + /* MFP3 */ + if (aic32x4->setup->gpio_func[2] != AIC32X4_MFPX_DEFAULT_VALUE) { + snd_soc_write(codec, AIC32X4_SCLKCTL, + aic32x4->setup->gpio_func[2]); + snd_soc_add_codec_controls(codec, aic32x4_mfp3, + ARRAY_SIZE(aic32x4_mfp3)); + } + + /* MFP4 */ + if (aic32x4->setup->gpio_func[3] != AIC32X4_MFPX_DEFAULT_VALUE) { + snd_soc_write(codec, AIC32X4_MISOCTL, + aic32x4->setup->gpio_func[3]); + snd_soc_add_codec_controls(codec, aic32x4_mfp4, + ARRAY_SIZE(aic32x4_mfp4)); + } + + /* MFP5 */ + if (aic32x4->setup->gpio_func[4] != AIC32X4_MFPX_DEFAULT_VALUE) { + snd_soc_write(codec, AIC32X4_GPIOCTL, + aic32x4->setup->gpio_func[4]); + snd_soc_add_codec_controls(codec, aic32x4_mfp5, + ARRAY_SIZE(aic32x4_mfp5)); + } +} + static int aic32x4_codec_probe(struct snd_soc_codec *codec) { struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); @@ -746,6 +938,9 @@ static int aic32x4_codec_probe(struct snd_soc_codec *codec) snd_soc_write(codec, AIC32X4_RESET, 0x01); + if (aic32x4->setup) + aic32x4_setup_gpios(codec); + /* Power platform configuration */ if (aic32x4->power_cfg & AIC32X4_PWR_MICBIAS_2075_LDOIN) { snd_soc_write(codec, AIC32X4_MICBIAS, AIC32X4_MICBIAS_LDOIN | @@ -810,10 +1005,20 @@ static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { static int aic32x4_parse_dt(struct aic32x4_priv *aic32x4, struct device_node *np) { + struct aic32x4_setup_data *aic32x4_setup; + + aic32x4_setup = devm_kzalloc(aic32x4->dev, sizeof(*aic32x4_setup), + GFP_KERNEL); + if (!aic32x4_setup) + return -ENOMEM; + aic32x4->swapdacs = false; aic32x4->micpga_routing = 0; aic32x4->rstn_gpio = of_get_named_gpio(np, "reset-gpios", 0); + if (of_property_read_u32_array(np, "aic32x4-gpio-func", + aic32x4_setup->gpio_func, 5) >= 0) + aic32x4->setup = aic32x4_setup; return 0; } @@ -932,6 +1137,7 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap) if (aic32x4 == NULL) return -ENOMEM; + aic32x4->dev = dev; dev_set_drvdata(dev, aic32x4); if (pdata) { diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h index a197dd5..da7cec4 100644 --- a/sound/soc/codecs/tlv320aic32x4.h +++ b/sound/soc/codecs/tlv320aic32x4.h @@ -44,8 +44,11 @@ int aic32x4_remove(struct device *dev); #define AIC32X4_IFACE4 31 #define AIC32X4_IFACE5 32 #define AIC32X4_IFACE6 33 +#define AIC32X4_GPIOCTL 52 #define AIC32X4_DOUTCTL 53 #define AIC32X4_DINCTL 54 +#define AIC32X4_MISOCTL 55 +#define AIC32X4_SCLKCTL 56 #define AIC32X4_DACSPB 60 #define AIC32X4_ADCSPB 61 #define AIC32X4_DACSETUP 63 -- cgit v1.1 From 72a63c6e78887f5c2063ce147b57fdfecf366e0e Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:37:26 -0500 Subject: ASoC: cs42l42: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l42.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index 55caf5f..a2324a0 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -911,7 +911,7 @@ static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops cs42l42_ops = { +static const struct snd_soc_dai_ops cs42l42_ops = { .hw_params = cs42l42_pcm_hw_params, .set_fmt = cs42l42_set_dai_fmt, .set_sysclk = cs42l42_set_sysclk, -- cgit v1.1 From 6ccf3a6d031c47d6319cb56ee35dd4b546905e91 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:37:36 -0500 Subject: ASoC: rt5663: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 963cda9..71c073c 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2888,7 +2888,7 @@ static int rt5663_resume(struct snd_soc_codec *codec) #define RT5663_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt5663_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5663_aif_dai_ops = { .hw_params = rt5663_hw_params, .set_fmt = rt5663_set_dai_fmt, .set_sysclk = rt5663_set_dai_sysclk, -- cgit v1.1 From f1d68ea36f4fe97ed1de8d40eaa43758b8386c29 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:37:43 -0500 Subject: ASoC: rt5616: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/rt5616.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 7d6e082..33bdfe7 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -1265,7 +1265,7 @@ static int rt5616_resume(struct snd_soc_codec *codec) #define RT5616_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt5616_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5616_aif_dai_ops = { .hw_params = rt5616_hw_params, .set_fmt = rt5616_set_dai_fmt, .set_sysclk = rt5616_set_dai_sysclk, -- cgit v1.1 From af2f010e0f12fdeb26fce502adf4b353daeb302c Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:37:48 -0500 Subject: ASoC: msm8916-wcd-analog: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a788029..aec1e16 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -753,7 +753,7 @@ static void pm8916_wcd_analog_shutdown(struct snd_pcm_substream *substream, RST_CTL_DIG_SW_RST_N_MASK, 0); } -static struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { +static const struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { .startup = pm8916_wcd_analog_startup, .shutdown = pm8916_wcd_analog_shutdown, }; -- cgit v1.1 From dfcfd4b68a551b7038e046040dac2a467f5efd10 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:37:54 -0500 Subject: ASoC: max98926: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/max98926.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index 1eff7e0..f16145d8 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -459,7 +459,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, #define MAX98926_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops max98926_dai_ops = { +static const struct snd_soc_dai_ops max98926_dai_ops = { .set_fmt = max98926_dai_set_fmt, .hw_params = max98926_dai_hw_params, }; -- cgit v1.1 From 9894dbafb6f864207f9e6aeaca2c8de949955651 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:37:59 -0500 Subject: ASoC: rt5514: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Also, make rt5514_aif_dai_ops static, as it is not used outside this module. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index a71e630..4ca73bf 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -1006,7 +1006,7 @@ static int rt5514_i2c_write(void *context, unsigned int reg, unsigned int val) #define RT5514_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -struct snd_soc_dai_ops rt5514_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5514_aif_dai_ops = { .hw_params = rt5514_hw_params, .set_fmt = rt5514_set_dai_fmt, .set_sysclk = rt5514_set_dai_sysclk, -- cgit v1.1 From a9689bb890ce633c3015ed51e4e2c6ee320fe4dc Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:38:14 -0500 Subject: ASoC: codecs: msm8916-wcd-digital: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-digital.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index f690442..7e3794f 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -788,7 +788,7 @@ static void msm8916_wcd_digital_shutdown(struct snd_pcm_substream *substream, LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, 0); } -static struct snd_soc_dai_ops msm8916_wcd_digital_dai_ops = { +static const struct snd_soc_dai_ops msm8916_wcd_digital_dai_ops = { .startup = msm8916_wcd_digital_startup, .shutdown = msm8916_wcd_digital_shutdown, .hw_params = msm8916_wcd_digital_hw_params, -- cgit v1.1 From df9401b47c346480e1c1068f12c1cd32e45809f1 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:38:26 -0500 Subject: ASoC: max9867: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2a40a69..3e421e9 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -350,7 +350,7 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return 0; } -static struct snd_soc_dai_ops max9867_dai_ops = { +static const struct snd_soc_dai_ops max9867_dai_ops = { .set_fmt = max9867_dai_set_fmt, .set_sysclk = max9867_set_dai_sysclk, .prepare = max9867_prepare, -- cgit v1.1 From fcf005a645e6855d68f98b9455f6b47ac2ed161c Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:38:32 -0500 Subject: ASoC: rk3036: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/inno_rk3036.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/inno_rk3036.c b/sound/soc/codecs/inno_rk3036.c index b918ba5..edf42d2 100644 --- a/sound/soc/codecs/inno_rk3036.c +++ b/sound/soc/codecs/inno_rk3036.c @@ -310,7 +310,7 @@ static int rk3036_codec_dai_hw_params(struct snd_pcm_substream *substream, SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops rk3036_codec_dai_ops = { +static const struct snd_soc_dai_ops rk3036_codec_dai_ops = { .set_fmt = rk3036_codec_dai_set_fmt, .hw_params = rk3036_codec_dai_hw_params, }; -- cgit v1.1 From 61b3b3cc68c4161ba202f401a6572250360ff18c Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:38:38 -0500 Subject: ASoC: hdac_hdmi: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index bc2e74f..e6de50a 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1360,7 +1360,7 @@ static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdac) } -static struct snd_soc_dai_ops hdmi_dai_ops = { +static const struct snd_soc_dai_ops hdmi_dai_ops = { .startup = hdac_hdmi_pcm_open, .shutdown = hdac_hdmi_pcm_close, .hw_params = hdac_hdmi_set_hw_params, -- cgit v1.1 From 73a995ca90544914a97ed33a4f7baef44ad110d0 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:38:43 -0500 Subject: ASoC: dwc: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c index 9160676..eebe9d3 100644 --- a/sound/soc/dwc/dwc-i2s.c +++ b/sound/soc/dwc/dwc-i2s.c @@ -381,7 +381,7 @@ static int dw_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) return ret; } -static struct snd_soc_dai_ops dw_i2s_dai_ops = { +static const struct snd_soc_dai_ops dw_i2s_dai_ops = { .startup = dw_i2s_startup, .shutdown = dw_i2s_shutdown, .hw_params = dw_i2s_hw_params, -- cgit v1.1 From 86464ef83af934b7e489c4e100d0136319794010 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 13 Jul 2017 15:38:47 -0500 Subject: ASoC: tas5720: constify snd_soc_dai_ops structure This structure is only stored in the ops field of a snd_soc_dai_driver structure. That field is declared const, so snd_soc_dai_ops structures that have this property can be declared as const also. Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/codecs/tas5720.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c index c65b917..01e9ed2 100644 --- a/sound/soc/codecs/tas5720.c +++ b/sound/soc/codecs/tas5720.c @@ -507,7 +507,7 @@ static struct snd_soc_codec_driver soc_codec_dev_tas5720 = { #define TAS5720_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |\ SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops tas5720_speaker_dai_ops = { +static const struct snd_soc_dai_ops tas5720_speaker_dai_ops = { .hw_params = tas5720_hw_params, .set_fmt = tas5720_set_dai_fmt, .set_tdm_slot = tas5720_set_dai_tdm_slot, -- cgit v1.1 From 32e1b60d8f91be932c4a624d4153224895b65ec7 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 17 Jul 2017 10:30:20 -0500 Subject: ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe() Remove unnecessary static on local variable ops. Such variable is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the code size. This issue was detected using Coccinelle and the following semantic patch: @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; In the following log you can see the difference in the code size. Also, there is a significant difference in the bss segment. This log is the output of the size command, before and after the code change: before: text data bss dec hex filename 3211 680 64 3955 f73 sound/soc/sh/rcar/ssiu.o after: text data bss dec hex filename 3207 592 0 3799 ed7 sound/soc/sh/rcar/ssiu.o Signed-off-by: Gustavo A. R. Silva Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssiu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index bed2c9c..4d94875 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c @@ -250,7 +250,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv) { struct device *dev = rsnd_priv_to_dev(priv); struct rsnd_ssiu *ssiu; - static struct rsnd_mod_ops *ops; + struct rsnd_mod_ops *ops; int i, nr, ret; /* same number to SSI */ -- cgit v1.1 From d26ed933581d924937aa92251afe1751cf86661c Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Tue, 18 Jul 2017 10:12:58 +0800 Subject: ASoC: rt5663: Modify the default value for ASRC function The patch modifies the default value for ASRC function. It could prevent the pop noise and recording no sound with ASRC function. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 71c073c..d3f7bc2 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -60,6 +60,7 @@ struct rt5663_priv { static const struct reg_sequence rt5663_patch_list[] = { { 0x002a, 0x8080 }, + { 0x0086, 0x0028 }, }; static const struct reg_default rt5663_v2_reg[] = { @@ -509,7 +510,7 @@ static const struct reg_default rt5663_reg[] = { { 0x0082, 0x0000 }, { 0x0083, 0x0000 }, { 0x0084, 0x0000 }, - { 0x0086, 0x0008 }, + { 0x0086, 0x0028 }, { 0x0087, 0x0000 }, { 0x008a, 0x0000 }, { 0x008b, 0x0000 }, -- cgit v1.1 From c7e79b2b2d2d7c13c6162ed8672357f4ad0fd8f5 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 14 Jul 2017 14:25:52 +0800 Subject: ASoC: rt274: add rt274 codec driver RT274 is a HD-A/SOC dual mode codec. This is the initial codec driver of SOC mode. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 7 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt274.c | 1228 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt274.h | 217 ++++++++ 4 files changed, 1454 insertions(+) create mode 100644 sound/soc/codecs/rt274.c create mode 100644 sound/soc/codecs/rt274.h (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 6c78b0b..024ddc9 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -114,6 +114,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_PCM5102A select SND_SOC_PCM512x_I2C if I2C select SND_SOC_PCM512x_SPI if SPI_MASTER + select SND_SOC_RT274 if I2C select SND_SOC_RT286 if I2C select SND_SOC_RT298 if I2C select SND_SOC_RT5514 if I2C @@ -716,11 +717,17 @@ config SND_SOC_RL6231 config SND_SOC_RL6347A tristate + default y if SND_SOC_RT274=y default y if SND_SOC_RT286=y default y if SND_SOC_RT298=y + default m if SND_SOC_RT274=m default m if SND_SOC_RT286=m default m if SND_SOC_RT298=m +config SND_SOC_RT274 + tristate + depends on I2C + config SND_SOC_RT286 tristate depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1755a54..a8a4b07 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -113,6 +113,7 @@ snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o snd-soc-pcm512x-spi-objs := pcm512x-spi.o snd-soc-rl6231-objs := rl6231.o snd-soc-rl6347a-objs := rl6347a.o +snd-soc-rt274-objs := rt274.o snd-soc-rt286-objs := rt286.o snd-soc-rt298-objs := rt298.o snd-soc-rt5514-objs := rt5514.o @@ -349,6 +350,7 @@ obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o +obj-$(CONFIG_SND_SOC_RT274) += snd-soc-rt274.o obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o obj-$(CONFIG_SND_SOC_RT298) += snd-soc-rt298.o obj-$(CONFIG_SND_SOC_RT5514) += snd-soc-rt5514.o diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c new file mode 100644 index 0000000..81e29ba --- /dev/null +++ b/sound/soc/codecs/rt274.c @@ -0,0 +1,1228 @@ +/* + * rt274.c -- RT274 ALSA SoC audio codec driver + * + * Copyright 2017 Realtek Semiconductor Corp. + * Author: Bard Liao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rl6347a.h" +#include "rt274.h" + +#define RT274_VENDOR_ID 0x10ec0274 + +struct rt274_priv { + struct reg_default *index_cache; + int index_cache_size; + struct regmap *regmap; + struct snd_soc_codec *codec; + struct i2c_client *i2c; + struct snd_soc_jack *jack; + struct delayed_work jack_detect_work; + int sys_clk; + int clk_id; + int fs; + bool master; +}; + +static const struct reg_default rt274_index_def[] = { + { 0x00, 0x1004 }, + { 0x01, 0xaaaa }, + { 0x02, 0x88aa }, + { 0x03, 0x0002 }, + { 0x04, 0xaa09 }, + { 0x05, 0x0700 }, + { 0x06, 0x6110 }, + { 0x07, 0x0200 }, + { 0x08, 0xa807 }, + { 0x09, 0x0021 }, + { 0x0a, 0x7770 }, + { 0x0b, 0x7770 }, + { 0x0c, 0x002b }, + { 0x0d, 0x2420 }, + { 0x0e, 0x65c0 }, + { 0x0f, 0x7770 }, + { 0x10, 0x0420 }, + { 0x11, 0x7418 }, + { 0x12, 0x6bd0 }, + { 0x13, 0x645f }, + { 0x14, 0x0400 }, + { 0x15, 0x8ccc }, + { 0x16, 0x4c50 }, + { 0x17, 0xff00 }, + { 0x18, 0x0003 }, + { 0x19, 0x2c11 }, + { 0x1a, 0x830b }, + { 0x1b, 0x4e4b }, + { 0x1c, 0x0000 }, + { 0x1d, 0x0000 }, + { 0x1e, 0x0000 }, + { 0x1f, 0x0000 }, + { 0x20, 0x51ff }, + { 0x21, 0x8000 }, + { 0x22, 0x8f00 }, + { 0x23, 0x88f4 }, + { 0x24, 0x0000 }, + { 0x25, 0x0000 }, + { 0x26, 0x0000 }, + { 0x27, 0x0000 }, + { 0x28, 0x0000 }, + { 0x29, 0x3000 }, + { 0x2a, 0x0000 }, + { 0x2b, 0x0000 }, + { 0x2c, 0x0f00 }, + { 0x2d, 0x100f }, + { 0x2e, 0x2902 }, + { 0x2f, 0xe280 }, + { 0x30, 0x1000 }, + { 0x31, 0x8400 }, + { 0x32, 0x5aaa }, + { 0x33, 0x8420 }, + { 0x34, 0xa20c }, + { 0x35, 0x096a }, + { 0x36, 0x5757 }, + { 0x37, 0xfe05 }, + { 0x38, 0x4901 }, + { 0x39, 0x110a }, + { 0x3a, 0x0010 }, + { 0x3b, 0x60d9 }, + { 0x3c, 0xf214 }, + { 0x3d, 0xc2ba }, + { 0x3e, 0xa928 }, + { 0x3f, 0x0000 }, + { 0x40, 0x9800 }, + { 0x41, 0x0000 }, + { 0x42, 0x2000 }, + { 0x43, 0x3d90 }, + { 0x44, 0x4900 }, + { 0x45, 0x5289 }, + { 0x46, 0x0004 }, + { 0x47, 0xa47a }, + { 0x48, 0xd049 }, + { 0x49, 0x0049 }, + { 0x4a, 0xa83b }, + { 0x4b, 0x0777 }, + { 0x4c, 0x065c }, + { 0x4d, 0x7fff }, + { 0x4e, 0x7fff }, + { 0x4f, 0x0000 }, + { 0x50, 0x0000 }, + { 0x51, 0x0000 }, + { 0x52, 0xbf5f }, + { 0x53, 0x3320 }, + { 0x54, 0xcc00 }, + { 0x55, 0x0000 }, + { 0x56, 0x3f00 }, + { 0x57, 0x0000 }, + { 0x58, 0x0000 }, + { 0x59, 0x0000 }, + { 0x5a, 0x1300 }, + { 0x5b, 0x005f }, + { 0x5c, 0x0000 }, + { 0x5d, 0x1001 }, + { 0x5e, 0x1000 }, + { 0x5f, 0x0000 }, + { 0x60, 0x5554 }, + { 0x61, 0xffc0 }, + { 0x62, 0xa000 }, + { 0x63, 0xd010 }, + { 0x64, 0x0000 }, + { 0x65, 0x3fb1 }, + { 0x66, 0x1881 }, + { 0x67, 0xc810 }, + { 0x68, 0x2000 }, + { 0x69, 0xfff0 }, + { 0x6a, 0x0300 }, + { 0x6b, 0x5060 }, + { 0x6c, 0x0000 }, + { 0x6d, 0x0000 }, + { 0x6e, 0x0c25 }, + { 0x6f, 0x0c0b }, + { 0x70, 0x8000 }, + { 0x71, 0x4008 }, + { 0x72, 0x0000 }, + { 0x73, 0x0800 }, + { 0x74, 0xa28f }, + { 0x75, 0xa050 }, + { 0x76, 0x7fe8 }, + { 0x77, 0xdb8c }, + { 0x78, 0x0000 }, + { 0x79, 0x0000 }, + { 0x7a, 0x2a96 }, + { 0x7b, 0x800f }, + { 0x7c, 0x0200 }, + { 0x7d, 0x1600 }, + { 0x7e, 0x0000 }, + { 0x7f, 0x0000 }, +}; +#define INDEX_CACHE_SIZE ARRAY_SIZE(rt274_index_def) + +static const struct reg_default rt274_reg[] = { + { 0x00170500, 0x00000400 }, + { 0x00220000, 0x00000031 }, + { 0x00239000, 0x00000057 }, + { 0x0023a000, 0x00000057 }, + { 0x00270500, 0x00000400 }, + { 0x00370500, 0x00000400 }, + { 0x00870500, 0x00000400 }, + { 0x00920000, 0x00000031 }, + { 0x00935000, 0x00000097 }, + { 0x00936000, 0x00000097 }, + { 0x00970500, 0x00000400 }, + { 0x00b37000, 0x00000400 }, + { 0x00b37200, 0x00000400 }, + { 0x00b37300, 0x00000400 }, + { 0x00c37000, 0x00000400 }, + { 0x00c37100, 0x00000400 }, + { 0x01270500, 0x00000400 }, + { 0x01370500, 0x00000400 }, + { 0x01371f00, 0x411111f0 }, + { 0x01937000, 0x00000000 }, + { 0x01970500, 0x00000400 }, + { 0x02050000, 0x0000001b }, + { 0x02139000, 0x00000080 }, + { 0x0213a000, 0x00000080 }, + { 0x02170100, 0x00000001 }, + { 0x02170500, 0x00000400 }, + { 0x02170700, 0x00000000 }, + { 0x02270100, 0x00000000 }, + { 0x02370100, 0x00000000 }, + { 0x01970700, 0x00000020 }, + { 0x00830000, 0x00000097 }, + { 0x00930000, 0x00000097 }, + { 0x01270700, 0x00000000 }, +}; + +static bool rt274_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0 ... 0xff: + case RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID): + case RT274_GET_HP_SENSE: + case RT274_GET_MIC_SENSE: + case RT274_PROC_COEF: + case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_DAC_OUT0, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_DAC_OUT1, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_ADC_IN1, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_ADC_IN2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DAC_OUT0, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DAC_OUT1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_ADC_IN2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DMIC1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DMIC2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_LINE1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_LINE2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_CONNECT_SEL, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_CONNECT_SEL, RT274_MIXER_IN1, 0): + case VERB_CMD(AC_VERB_GET_CONNECT_SEL, RT274_MIXER_IN2, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_DMIC1, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_DMIC2, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_LINE1, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_LINE2, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_UNSOLICITED_RESPONSE, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_UNSOLICITED_RESPONSE, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_UNSOLICITED_RESPONSE, RT274_INLINE_CMD, 0): + return true; + default: + return false; + } + + +} + +static bool rt274_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case 0 ... 0xff: + case RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID): + case RT274_GET_HP_SENSE: + case RT274_GET_MIC_SENSE: + case RT274_SET_AUDIO_POWER: + case RT274_SET_HPO_POWER: + case RT274_SET_DMIC1_POWER: + case RT274_LOUT_MUX: + case RT274_HPO_MUX: + case RT274_ADC0_MUX: + case RT274_ADC1_MUX: + case RT274_SET_MIC: + case RT274_SET_PIN_HPO: + case RT274_SET_PIN_LOUT3: + case RT274_SET_PIN_DMIC1: + case RT274_SET_AMP_GAIN_HPO: + case RT274_SET_DMIC2_DEFAULT: + case RT274_DAC0L_GAIN: + case RT274_DAC0R_GAIN: + case RT274_DAC1L_GAIN: + case RT274_DAC1R_GAIN: + case RT274_ADCL_GAIN: + case RT274_ADCR_GAIN: + case RT274_MIC_GAIN: + case RT274_HPOL_GAIN: + case RT274_HPOR_GAIN: + case RT274_LOUTL_GAIN: + case RT274_LOUTR_GAIN: + case RT274_DAC_FORMAT: + case RT274_ADC_FORMAT: + case RT274_COEF_INDEX: + case RT274_PROC_COEF: + case RT274_SET_AMP_GAIN_ADC_IN1: + case RT274_SET_AMP_GAIN_ADC_IN2: + case RT274_SET_POWER(RT274_DAC_OUT0): + case RT274_SET_POWER(RT274_DAC_OUT1): + case RT274_SET_POWER(RT274_ADC_IN1): + case RT274_SET_POWER(RT274_ADC_IN2): + case RT274_SET_POWER(RT274_DMIC2): + case RT274_SET_POWER(RT274_MIC): + case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_EAPD_BTLENABLE, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_DAC_OUT0, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_DAC_OUT1, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_ADC_IN1, 0): + case VERB_CMD(AC_VERB_GET_STREAM_FORMAT, RT274_ADC_IN2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DAC_OUT0, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DAC_OUT1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_ADC_IN2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DMIC1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_DMIC2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_LINE1, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_LINE2, 0): + case VERB_CMD(AC_VERB_GET_AMP_GAIN_MUTE, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_CONNECT_SEL, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_CONNECT_SEL, RT274_MIXER_IN1, 0): + case VERB_CMD(AC_VERB_GET_CONNECT_SEL, RT274_MIXER_IN2, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_DMIC1, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_DMIC2, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_LINE1, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_LINE2, 0): + case VERB_CMD(AC_VERB_GET_PIN_WIDGET_CONTROL, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_UNSOLICITED_RESPONSE, RT274_HP_OUT, 0): + case VERB_CMD(AC_VERB_GET_UNSOLICITED_RESPONSE, RT274_MIC, 0): + case VERB_CMD(AC_VERB_GET_UNSOLICITED_RESPONSE, RT274_INLINE_CMD, 0): + return true; + default: + return false; + } +} + +#ifdef CONFIG_PM +static void rt274_index_sync(struct snd_soc_codec *codec) +{ + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + int i; + + for (i = 0; i < INDEX_CACHE_SIZE; i++) { + snd_soc_write(codec, rt274->index_cache[i].reg, + rt274->index_cache[i].def); + } +} +#endif + +static int rt274_jack_detect(struct rt274_priv *rt274, bool *hp, bool *mic) +{ + unsigned int buf; + + *hp = false; + *mic = false; + + if (!rt274->codec) + return -EINVAL; + + regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); + *hp = buf & 0x80000000; + regmap_read(rt274->regmap, RT274_GET_MIC_SENSE, &buf); + *mic = buf & 0x80000000; + + pr_debug("*hp = %d *mic = %d\n", *hp, *mic); + + return 0; +} + +static void rt274_jack_detect_work(struct work_struct *work) +{ + struct rt274_priv *rt274 = + container_of(work, struct rt274_priv, jack_detect_work.work); + int status = 0; + bool hp = false; + bool mic = false; + + if (rt274_jack_detect(rt274, &hp, &mic) < 0) + return; + + if (hp == true) + status |= SND_JACK_HEADPHONE; + + if (mic == true) + status |= SND_JACK_MICROPHONE; + + snd_soc_jack_report(rt274->jack, status, + SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); +} + +static irqreturn_t rt274_irq(int irq, void *data); + +static int rt274_mic_detect(struct snd_soc_codec *codec, + struct snd_soc_jack *jack, void *data) +{ + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + if (jack == NULL) { + /* Disable jack detection */ + regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, + RT274_IRQ_EN, RT274_IRQ_DIS); + + return 0; + } + rt274->jack = jack; + + regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, + RT274_IRQ_EN, RT274_IRQ_EN); + + /* Send an initial report */ + rt274_irq(0, rt274); + + return 0; +} + +static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0); +static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); + +static const struct snd_kcontrol_new rt274_snd_controls[] = { + SOC_DOUBLE_R_TLV("DAC0 Playback Volume", RT274_DAC0L_GAIN, + RT274_DAC0R_GAIN, 0, 0x7f, 0, out_vol_tlv), + SOC_DOUBLE_R_TLV("DAC1 Playback Volume", RT274_DAC1L_GAIN, + RT274_DAC1R_GAIN, 0, 0x7f, 0, out_vol_tlv), + SOC_DOUBLE_R_TLV("ADC0 Capture Volume", RT274_ADCL_GAIN, + RT274_ADCR_GAIN, 0, 0x7f, 0, out_vol_tlv), + SOC_DOUBLE_R("ADC0 Capture Switch", RT274_ADCL_GAIN, + RT274_ADCR_GAIN, RT274_MUTE_SFT, 1, 1), + SOC_SINGLE_TLV("AMIC Volume", RT274_MIC_GAIN, + 0, 0x3, 0, mic_vol_tlv), +}; + +static const struct snd_kcontrol_new hpol_enable_control = + SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT274_HPOL_GAIN, + RT274_MUTE_SFT, 1, 1); + +static const struct snd_kcontrol_new hpor_enable_control = + SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT274_HPOR_GAIN, + RT274_MUTE_SFT, 1, 1); + +static const struct snd_kcontrol_new loutl_enable_control = + SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT274_LOUTL_GAIN, + RT274_MUTE_SFT, 1, 1); + +static const struct snd_kcontrol_new loutr_enable_control = + SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT274_LOUTR_GAIN, + RT274_MUTE_SFT, 1, 1); + +/* ADC0 source */ +static const char * const rt274_adc_src[] = { + "Mic", "Line1", "Line2", "Dmic" +}; + +static SOC_ENUM_SINGLE_DECL( + rt274_adc0_enum, RT274_ADC0_MUX, RT274_ADC_SEL_SFT, + rt274_adc_src); + +static const struct snd_kcontrol_new rt274_adc0_mux = + SOC_DAPM_ENUM("ADC 0 source", rt274_adc0_enum); + +static SOC_ENUM_SINGLE_DECL( + rt274_adc1_enum, RT274_ADC1_MUX, RT274_ADC_SEL_SFT, + rt274_adc_src); + +static const struct snd_kcontrol_new rt274_adc1_mux = + SOC_DAPM_ENUM("ADC 1 source", rt274_adc1_enum); + +static const char * const rt274_dac_src[] = { + "DAC OUT0", "DAC OUT1" +}; +/* HP-OUT source */ +static SOC_ENUM_SINGLE_DECL(rt274_hpo_enum, RT274_HPO_MUX, + 0, rt274_dac_src); + +static const struct snd_kcontrol_new rt274_hpo_mux = +SOC_DAPM_ENUM("HPO source", rt274_hpo_enum); + +/* Line out source */ +static SOC_ENUM_SINGLE_DECL(rt274_lout_enum, RT274_LOUT_MUX, + 0, rt274_dac_src); + +static const struct snd_kcontrol_new rt274_lout_mux = +SOC_DAPM_ENUM("LOUT source", rt274_lout_enum); + +static const struct snd_soc_dapm_widget rt274_dapm_widgets[] = { + /* Input Lines */ + SND_SOC_DAPM_INPUT("DMIC1 Pin"), + SND_SOC_DAPM_INPUT("DMIC2 Pin"), + SND_SOC_DAPM_INPUT("MIC"), + SND_SOC_DAPM_INPUT("LINE1"), + SND_SOC_DAPM_INPUT("LINE2"), + + /* DMIC */ + SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0), + + /* ADCs */ + SND_SOC_DAPM_ADC("ADC 0", NULL, RT274_SET_STREAMID_ADC1, 4, 0), + SND_SOC_DAPM_ADC("ADC 1", NULL, RT274_SET_STREAMID_ADC2, 4, 0), + + /* ADC Mux */ + SND_SOC_DAPM_MUX("ADC 0 Mux", SND_SOC_NOPM, 0, 0, + &rt274_adc0_mux), + SND_SOC_DAPM_MUX("ADC 1 Mux", SND_SOC_NOPM, 0, 0, + &rt274_adc1_mux), + + /* Audio Interface */ + SND_SOC_DAPM_AIF_IN("AIF1RXL", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_IN("AIF1RXR", "AIF1 Playback", 1, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("AIF1TXL", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("AIF1TXR", "AIF1 Capture", 1, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_IN("AIF2RXL", "AIF1 Playback", 2, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_IN("AIF2RXR", "AIF1 Playback", 3, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("AIF2TXL", "AIF1 Capture", 2, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("AIF2TXR", "AIF1 Capture", 3, SND_SOC_NOPM, 0, 0), + + /* Output Side */ + /* DACs */ + SND_SOC_DAPM_DAC("DAC 0", NULL, RT274_SET_STREAMID_DAC0, 4, 0), + SND_SOC_DAPM_DAC("DAC 1", NULL, RT274_SET_STREAMID_DAC1, 4, 0), + + /* Output Mux */ + SND_SOC_DAPM_MUX("HPO Mux", SND_SOC_NOPM, 0, 0, &rt274_hpo_mux), + SND_SOC_DAPM_MUX("LOUT Mux", SND_SOC_NOPM, 0, 0, &rt274_lout_mux), + + SND_SOC_DAPM_SUPPLY("HP Power", RT274_SET_PIN_HPO, + RT274_SET_PIN_SFT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("LOUT Power", RT274_SET_PIN_LOUT3, + RT274_SET_PIN_SFT, 0, NULL, 0), + + /* Output Mixer */ + SND_SOC_DAPM_PGA("DAC OUT0", SND_SOC_NOPM, 0, 0, + NULL, 0), + SND_SOC_DAPM_PGA("DAC OUT1", SND_SOC_NOPM, 0, 0, + NULL, 0), + + /* Output Pga */ + SND_SOC_DAPM_SWITCH("LOUT L", SND_SOC_NOPM, 0, 0, + &loutl_enable_control), + SND_SOC_DAPM_SWITCH("LOUT R", SND_SOC_NOPM, 0, 0, + &loutr_enable_control), + SND_SOC_DAPM_SWITCH("HPO L", SND_SOC_NOPM, 0, 0, + &hpol_enable_control), + SND_SOC_DAPM_SWITCH("HPO R", SND_SOC_NOPM, 0, 0, + &hpor_enable_control), + + /* Output Lines */ + SND_SOC_DAPM_OUTPUT("HPO Pin"), + SND_SOC_DAPM_OUTPUT("SPDIF"), + SND_SOC_DAPM_OUTPUT("LINE3"), +}; + +static const struct snd_soc_dapm_route rt274_dapm_routes[] = { + {"DMIC1", NULL, "DMIC1 Pin"}, + {"DMIC2", NULL, "DMIC2 Pin"}, + + {"ADC 0 Mux", "Mic", "MIC"}, + {"ADC 0 Mux", "Dmic", "DMIC1"}, + {"ADC 0 Mux", "Line1", "LINE1"}, + {"ADC 0 Mux", "Line2", "LINE2"}, + {"ADC 1 Mux", "Mic", "MIC"}, + {"ADC 1 Mux", "Dmic", "DMIC2"}, + {"ADC 1 Mux", "Line1", "LINE1"}, + {"ADC 1 Mux", "Line2", "LINE2"}, + + {"ADC 0", NULL, "ADC 0 Mux"}, + {"ADC 1", NULL, "ADC 1 Mux"}, + + {"AIF1TXL", NULL, "ADC 0"}, + {"AIF1TXR", NULL, "ADC 0"}, + {"AIF2TXL", NULL, "ADC 1"}, + {"AIF2TXR", NULL, "ADC 1"}, + + {"DAC 0", NULL, "AIF1RXL"}, + {"DAC 0", NULL, "AIF1RXR"}, + {"DAC 1", NULL, "AIF2RXL"}, + {"DAC 1", NULL, "AIF2RXR"}, + + {"DAC OUT0", NULL, "DAC 0"}, + + {"DAC OUT1", NULL, "DAC 1"}, + + {"LOUT Mux", "DAC OUT0", "DAC OUT0"}, + {"LOUT Mux", "DAC OUT1", "DAC OUT1"}, + + {"LOUT L", "Switch", "LOUT Mux"}, + {"LOUT R", "Switch", "LOUT Mux"}, + {"LOUT L", NULL, "LOUT Power"}, + {"LOUT R", NULL, "LOUT Power"}, + + {"LINE3", NULL, "LOUT L"}, + {"LINE3", NULL, "LOUT R"}, + + {"HPO Mux", "DAC OUT0", "DAC OUT0"}, + {"HPO Mux", "DAC OUT1", "DAC OUT1"}, + + {"HPO L", "Switch", "HPO Mux"}, + {"HPO R", "Switch", "HPO Mux"}, + {"HPO L", NULL, "HP Power"}, + {"HPO R", NULL, "HP Power"}, + + {"HPO Pin", NULL, "HPO L"}, + {"HPO Pin", NULL, "HPO R"}, +}; + +static int rt274_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + unsigned int val = 0; + int d_len_code = 0, c_len_code = 0; + + switch (params_rate(params)) { + /* bit 14 0:48K 1:44.1K */ + case 44100: + case 48000: + break; + default: + dev_err(codec->dev, "Unsupported sample rate %d\n", + params_rate(params)); + return -EINVAL; + } + switch (rt274->sys_clk) { + case 12288000: + case 24576000: + if (params_rate(params) != 48000) { + dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + params_rate(params), rt274->sys_clk); + return -EINVAL; + } + break; + case 11289600: + case 22579200: + if (params_rate(params) != 44100) { + dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + params_rate(params), rt274->sys_clk); + return -EINVAL; + } + break; + } + + if (params_channels(params) <= 16) { + /* bit 3:0 Number of Channel */ + val |= (params_channels(params) - 1); + } else { + dev_err(codec->dev, "Unsupported channels %d\n", + params_channels(params)); + return -EINVAL; + } + + switch (params_width(params)) { + /* bit 6:4 Bits per Sample */ + case 16: + d_len_code = 0; + c_len_code = 0; + val |= (0x1 << 4); + break; + case 32: + d_len_code = 2; + c_len_code = 3; + val |= (0x4 << 4); + break; + case 20: + d_len_code = 1; + c_len_code = 1; + val |= (0x2 << 4); + break; + case 24: + d_len_code = 2; + c_len_code = 2; + val |= (0x3 << 4); + break; + case 8: + d_len_code = 3; + c_len_code = 0; + break; + default: + return -EINVAL; + } + + if (rt274->master) + c_len_code = 0x3; + + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, 0xc018, d_len_code << 3 | c_len_code << 14); + dev_dbg(codec->dev, "format val = 0x%x\n", val); + + snd_soc_update_bits(codec, RT274_DAC_FORMAT, 0x407f, val); + snd_soc_update_bits(codec, RT274_ADC_FORMAT, 0x407f, val); + + return 0; +} + +static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct snd_soc_codec *codec = dai->codec; + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, RT274_I2S_MODE_MASK, RT274_I2S_MODE_M); + rt274->master = true; + break; + case SND_SOC_DAIFMT_CBS_CFS: + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, RT274_I2S_MODE_MASK, RT274_I2S_MODE_S); + rt274->master = false; + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + snd_soc_update_bits(codec, RT274_I2S_CTRL1, + RT274_I2S_FMT_MASK, RT274_I2S_FMT_I2S); + break; + case SND_SOC_DAIFMT_LEFT_J: + snd_soc_update_bits(codec, RT274_I2S_CTRL1, + RT274_I2S_FMT_MASK, RT274_I2S_FMT_LJ); + break; + case SND_SOC_DAIFMT_DSP_A: + snd_soc_update_bits(codec, RT274_I2S_CTRL1, + RT274_I2S_FMT_MASK, RT274_I2S_FMT_PCMA); + break; + case SND_SOC_DAIFMT_DSP_B: + snd_soc_update_bits(codec, RT274_I2S_CTRL1, + RT274_I2S_FMT_MASK, RT274_I2S_FMT_PCMB); + break; + default: + return -EINVAL; + } + /* bit 15 Stream Type 0:PCM 1:Non-PCM */ + snd_soc_update_bits(codec, RT274_DAC_FORMAT, 0x8000, 0); + snd_soc_update_bits(codec, RT274_ADC_FORMAT, 0x8000, 0); + + return 0; +} + +static int rt274_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, + unsigned int freq_in, unsigned int freq_out) +{ + struct snd_soc_codec *codec = dai->codec; + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + switch (source) { + case RT274_PLL2_S_MCLK: + snd_soc_update_bits(codec, RT274_PLL2_CTRL, + RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_MCLK); + break; + default: + dev_warn(codec->dev, "invalid pll source, use BCLK\n"); + case RT274_PLL2_S_BCLK: + snd_soc_update_bits(codec, RT274_PLL2_CTRL, + RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_BCLK); + break; + } + + if (source == RT274_PLL2_S_BCLK) { + snd_soc_update_bits(codec, RT274_MCLK_CTRL, + (0x3 << 12), (0x3 << 12)); + switch (rt274->fs) { + case 50: + snd_soc_write(codec, 0x7a, 0xaab6); + snd_soc_write(codec, 0x7b, 0x0301); + snd_soc_write(codec, 0x7c, 0x04fe); + break; + case 64: + snd_soc_write(codec, 0x7a, 0xaa96); + snd_soc_write(codec, 0x7b, 0x8003); + snd_soc_write(codec, 0x7c, 0x081e); + break; + case 128: + snd_soc_write(codec, 0x7a, 0xaa96); + snd_soc_write(codec, 0x7b, 0x8003); + snd_soc_write(codec, 0x7c, 0x080e); + break; + default: + dev_warn(codec->dev, "invalid freq_in, assume 4.8M\n"); + case 100: + snd_soc_write(codec, 0x7a, 0xaab6); + snd_soc_write(codec, 0x7b, 0x0301); + snd_soc_write(codec, 0x7c, 0x047e); + break; + } + } + + return 0; +} + +static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = dai->codec; + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + unsigned int clk_src, mclk_en; + + dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + + switch (clk_id) { + case RT274_SCLK_S_MCLK: + mclk_en = RT274_MCLK_MODE_EN; + clk_src = RT274_CLK_SRC_MCLK; + break; + case RT274_SCLK_S_PLL1: + mclk_en = RT274_MCLK_MODE_DIS; + clk_src = RT274_CLK_SRC_MCLK; + break; + case RT274_SCLK_S_PLL2: + mclk_en = RT274_MCLK_MODE_EN; + clk_src = RT274_CLK_SRC_PLL2; + break; + default: + mclk_en = RT274_MCLK_MODE_DIS; + clk_src = RT274_CLK_SRC_MCLK; + dev_warn(codec->dev, "invalid sysclk source, use PLL1\n"); + break; + } + snd_soc_update_bits(codec, RT274_MCLK_CTRL, + RT274_MCLK_MODE_MASK, mclk_en); + snd_soc_update_bits(codec, RT274_CLK_CTRL, + RT274_CLK_SRC_MASK, clk_src); + + switch (freq) { + case 19200000: + if (clk_id == RT274_SCLK_S_MCLK) { + dev_err(codec->dev, "Should not use MCLK\n"); + return -EINVAL; + } + snd_soc_update_bits(codec, + RT274_I2S_CTRL2, 0x40, 0x40); + break; + case 24000000: + if (clk_id == RT274_SCLK_S_MCLK) { + dev_err(codec->dev, "Should not use MCLK\n"); + return -EINVAL; + } + snd_soc_update_bits(codec, + RT274_I2S_CTRL2, 0x40, 0x0); + break; + case 12288000: + case 11289600: + snd_soc_update_bits(codec, + RT274_MCLK_CTRL, 0x1fcf, 0x0008); + break; + case 24576000: + case 22579200: + snd_soc_update_bits(codec, + RT274_MCLK_CTRL, 0x1fcf, 0x1543); + break; + default: + dev_err(codec->dev, "Unsupported system clock\n"); + return -EINVAL; + } + + rt274->sys_clk = freq; + rt274->clk_id = clk_id; + + return 0; +} + +static int rt274_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) +{ + struct snd_soc_codec *codec = dai->codec; + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + rt274->fs = ratio; + if ((ratio / 50) == 0) + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, 0x1000, 0x1000); + else + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, 0x1000, 0x0); + + + return 0; +} + +static int rt274_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, + unsigned int rx_mask, int slots, int slot_width) + +{ + struct snd_soc_codec *codec = dai->codec; + + if (rx_mask || tx_mask) { + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, RT274_TDM_EN, RT274_TDM_EN); + } else { + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, RT274_TDM_EN, RT274_TDM_DIS); + return 0; + } + + switch (slots) { + case 4: + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, RT274_TDM_CH_NUM, RT274_TDM_4CH); + break; + case 2: + snd_soc_update_bits(codec, + RT274_I2S_CTRL1, RT274_TDM_CH_NUM, RT274_TDM_2CH); + break; + default: + dev_err(codec->dev, + "Support 2 or 4 slots TDM only\n"); + return -EINVAL; + } + + return 0; +} + +static int rt274_set_bias_level(struct snd_soc_codec *codec, + enum snd_soc_bias_level level) +{ + switch (level) { + case SND_SOC_BIAS_PREPARE: + if (SND_SOC_BIAS_STANDBY == + snd_soc_codec_get_bias_level(codec)) { + snd_soc_write(codec, + RT274_SET_AUDIO_POWER, AC_PWRST_D0); + } + break; + + case SND_SOC_BIAS_STANDBY: + snd_soc_write(codec, + RT274_SET_AUDIO_POWER, AC_PWRST_D3); + break; + + default: + break; + } + + return 0; +} + +static irqreturn_t rt274_irq(int irq, void *data) +{ + struct rt274_priv *rt274 = data; + bool hp = false; + bool mic = false; + int ret, status = 0; + + /* Clear IRQ */ + regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, + RT274_IRQ_CLR, RT274_IRQ_CLR); + + ret = rt274_jack_detect(rt274, &hp, &mic); + + if (ret == 0) { + if (hp == true) + status |= SND_JACK_HEADPHONE; + + if (mic == true) + status |= SND_JACK_MICROPHONE; + + snd_soc_jack_report(rt274->jack, status, + SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); + + pm_wakeup_event(&rt274->i2c->dev, 300); + } + + return IRQ_HANDLED; +} + +static int rt274_probe(struct snd_soc_codec *codec) +{ + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + rt274->codec = codec; + + if (rt274->i2c->irq) { + INIT_DELAYED_WORK(&rt274->jack_detect_work, + rt274_jack_detect_work); + schedule_delayed_work(&rt274->jack_detect_work, + msecs_to_jiffies(1250)); + } + + return 0; +} + +static int rt274_remove(struct snd_soc_codec *codec) +{ + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + cancel_delayed_work_sync(&rt274->jack_detect_work); + + return 0; +} + +#ifdef CONFIG_PM +static int rt274_suspend(struct snd_soc_codec *codec) +{ + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + regcache_cache_only(rt274->regmap, true); + regcache_mark_dirty(rt274->regmap); + + return 0; +} + +static int rt274_resume(struct snd_soc_codec *codec) +{ + struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + + regcache_cache_only(rt274->regmap, false); + rt274_index_sync(codec); + regcache_sync(rt274->regmap); + + return 0; +} +#else +#define rt274_suspend NULL +#define rt274_resume NULL +#endif + +#define RT274_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) +#define RT274_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) + +static const struct snd_soc_dai_ops rt274_aif_dai_ops = { + .hw_params = rt274_hw_params, + .set_fmt = rt274_set_dai_fmt, + .set_sysclk = rt274_set_dai_sysclk, + .set_pll = rt274_set_dai_pll, + .set_bclk_ratio = rt274_set_bclk_ratio, + .set_tdm_slot = rt274_set_tdm_slot, +}; + +static struct snd_soc_dai_driver rt274_dai[] = { + { + .name = "rt274-aif1", + .id = RT274_AIF1, + .playback = { + .stream_name = "AIF1 Playback", + .channels_min = 1, + .channels_max = 2, + .rates = RT274_STEREO_RATES, + .formats = RT274_FORMATS, + }, + .capture = { + .stream_name = "AIF1 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = RT274_STEREO_RATES, + .formats = RT274_FORMATS, + }, + .ops = &rt274_aif_dai_ops, + .symmetric_rates = 1, + }, +}; + +static struct snd_soc_codec_driver soc_codec_dev_rt274 = { + .probe = rt274_probe, + .remove = rt274_remove, + .suspend = rt274_suspend, + .resume = rt274_resume, + .set_bias_level = rt274_set_bias_level, + .idle_bias_off = true, + .component_driver = { + .controls = rt274_snd_controls, + .num_controls = ARRAY_SIZE(rt274_snd_controls), + .dapm_widgets = rt274_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt274_dapm_widgets), + .dapm_routes = rt274_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt274_dapm_routes), + }, + .set_jack = rt274_mic_detect, +}; + +static const struct regmap_config rt274_regmap = { + .reg_bits = 32, + .val_bits = 32, + .max_register = 0x05bfffff, + .volatile_reg = rt274_volatile_register, + .readable_reg = rt274_readable_register, + .reg_write = rl6347a_hw_write, + .reg_read = rl6347a_hw_read, + .cache_type = REGCACHE_RBTREE, + .reg_defaults = rt274_reg, + .num_reg_defaults = ARRAY_SIZE(rt274_reg), +}; + +#ifdef CONFIG_OF +static const struct of_device_id rt274_of_match[] = { + {.compatible = "realtek,rt274"}, + {}, +}; +MODULE_DEVICE_TABLE(of, rt274_of_match); +#endif + +static const struct i2c_device_id rt274_i2c_id[] = { + {"rt274", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, rt274_i2c_id); + +static const struct acpi_device_id rt274_acpi_match[] = { + { "10EC0274", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(acpi, rt274_acpi_match); + +static int rt274_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct rt274_priv *rt274; + + int ret; + unsigned int val; + + rt274 = devm_kzalloc(&i2c->dev, sizeof(*rt274), + GFP_KERNEL); + if (rt274 == NULL) + return -ENOMEM; + + rt274->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt274_regmap); + if (IS_ERR(rt274->regmap)) { + ret = PTR_ERR(rt274->regmap); + dev_err(&i2c->dev, "Failed to allocate register map: %d\n", + ret); + return ret; + } + + regmap_read(rt274->regmap, + RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val); + if (val != RT274_VENDOR_ID) { + dev_err(&i2c->dev, + "Device with ID register %#x is not rt274\n", val); + return -ENODEV; + } + + rt274->index_cache = devm_kmemdup(&i2c->dev, rt274_index_def, + sizeof(rt274_index_def), GFP_KERNEL); + if (!rt274->index_cache) + return -ENOMEM; + + rt274->index_cache_size = INDEX_CACHE_SIZE; + rt274->i2c = i2c; + i2c_set_clientdata(i2c, rt274); + + /* reset codec */ + regmap_write(rt274->regmap, RT274_RESET, 0); + regmap_update_bits(rt274->regmap, 0x1a, 0x4000, 0x4000); + + /* Set Pad PDB is floating */ + regmap_update_bits(rt274->regmap, RT274_PAD_CTRL12, 0x3, 0x0); + regmap_write(rt274->regmap, RT274_COEF5b_INDEX, 0x01); + regmap_write(rt274->regmap, RT274_COEF5b_COEF, 0x8540); + regmap_update_bits(rt274->regmap, 0x6f, 0x0100, 0x0100); + /* Combo jack auto detect */ + regmap_write(rt274->regmap, 0x4a, 0x201b); + /* Aux mode off */ + regmap_update_bits(rt274->regmap, 0x6f, 0x3000, 0x2000); + /* HP DC Calibration */ + regmap_update_bits(rt274->regmap, 0x6f, 0xf, 0x0); + //Set NID=58h.Index 00h [15]= 1b; + regmap_write(rt274->regmap, RT274_COEF58_INDEX, 0x00); + regmap_write(rt274->regmap, RT274_COEF58_COEF, 0xb888); + msleep(500); + regmap_update_bits(rt274->regmap, 0x6f, 0xf, 0xb); + regmap_write(rt274->regmap, RT274_COEF58_INDEX, 0x00); + regmap_write(rt274->regmap, RT274_COEF58_COEF, 0x3888); + /* Set pin widget */ + regmap_write(rt274->regmap, RT274_SET_PIN_HPO, 0x40); + regmap_write(rt274->regmap, RT274_SET_PIN_LOUT3, 0x40); + regmap_write(rt274->regmap, RT274_SET_MIC, 0x20); + regmap_write(rt274->regmap, RT274_SET_PIN_DMIC1, 0x20); + + regmap_update_bits(rt274->regmap, RT274_I2S_CTRL2, 0xc004, 0x4004); + regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, + RT274_GPI2_SEL_MASK, RT274_GPI2_SEL_DMIC_CLK); + + /* jack detection */ + regmap_write(rt274->regmap, RT274_UNSOLICITED_HP_OUT, 0x81); + regmap_write(rt274->regmap, RT274_UNSOLICITED_MIC, 0x82); + + if (rt274->i2c->irq) { + ret = request_threaded_irq(rt274->i2c->irq, NULL, rt274_irq, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt274", rt274); + if (ret != 0) { + dev_err(&i2c->dev, + "Failed to reguest IRQ: %d\n", ret); + return ret; + } + } + + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt274, + rt274_dai, ARRAY_SIZE(rt274_dai)); + + return ret; +} + +static int rt274_i2c_remove(struct i2c_client *i2c) +{ + struct rt274_priv *rt274 = i2c_get_clientdata(i2c); + + if (i2c->irq) + free_irq(i2c->irq, rt274); + snd_soc_unregister_codec(&i2c->dev); + + return 0; +} + + +static struct i2c_driver rt274_i2c_driver = { + .driver = { + .name = "rt274", + .acpi_match_table = ACPI_PTR(rt274_acpi_match), +#ifdef CONFIG_OF + .of_match_table = of_match_ptr(rt274_of_match), +#endif + }, + .probe = rt274_i2c_probe, + .remove = rt274_i2c_remove, + .id_table = rt274_i2c_id, +}; + +module_i2c_driver(rt274_i2c_driver); + +MODULE_DESCRIPTION("ASoC RT274 driver"); +MODULE_AUTHOR("Bard Liao "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/rt274.h b/sound/soc/codecs/rt274.h new file mode 100644 index 0000000..4fd1bcb --- /dev/null +++ b/sound/soc/codecs/rt274.h @@ -0,0 +1,217 @@ +/* + * rt274.h -- RT274 ALSA SoC audio driver + * + * Copyright 2016 Realtek Microelectronics + * Author: Bard Liao + * + * 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 __RT274_H__ +#define __RT274_H__ + +#define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D) + +#define RT274_AUDIO_FUNCTION_GROUP 0x01 +#define RT274_DAC_OUT0 0x02 +#define RT274_DAC_OUT1 0x03 +#define RT274_ADC_IN2 0x08 +#define RT274_ADC_IN1 0x09 +#define RT274_DIG_CVT 0x0a +#define RT274_DMIC1 0x12 +#define RT274_DMIC2 0x13 +#define RT274_MIC 0x19 +#define RT274_LINE1 0x1a +#define RT274_LINE2 0x1b +#define RT274_LINE3 0x16 +#define RT274_SPDIF 0x1e +#define RT274_VENDOR_REGISTERS 0x20 +#define RT274_HP_OUT 0x21 +#define RT274_MIXER_IN1 0x22 +#define RT274_MIXER_IN2 0x23 +#define RT274_INLINE_CMD 0x55 + +#define RT274_SET_PIN_SFT 6 +#define RT274_SET_PIN_ENABLE 0x40 +#define RT274_SET_PIN_DISABLE 0 +#define RT274_SET_EAPD_HIGH 0x2 +#define RT274_SET_EAPD_LOW 0 + +#define RT274_MUTE_SFT 7 + +/* Verb commands */ +#define RT274_RESET\ + VERB_CMD(AC_VERB_SET_CODEC_RESET, RT274_AUDIO_FUNCTION_GROUP, 0) +#define RT274_GET_PARAM(NID, PARAM) VERB_CMD(AC_VERB_PARAMETERS, NID, PARAM) +#define RT274_SET_POWER(NID) VERB_CMD(AC_VERB_SET_POWER_STATE, NID, 0) +#define RT274_SET_AUDIO_POWER RT274_SET_POWER(RT274_AUDIO_FUNCTION_GROUP) +#define RT274_SET_HPO_POWER RT274_SET_POWER(RT274_HP_OUT) +#define RT274_SET_DMIC1_POWER RT274_SET_POWER(RT274_DMIC1) +#define RT274_LOUT_MUX\ + VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_LINE3, 0) +#define RT274_HPO_MUX\ + VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_HP_OUT, 0) +#define RT274_ADC0_MUX\ + VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_MIXER_IN1, 0) +#define RT274_ADC1_MUX\ + VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT274_MIXER_IN2, 0) +#define RT274_SET_MIC\ + VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_MIC, 0) +#define RT274_SET_PIN_LOUT3\ + VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_LINE3, 0) +#define RT274_SET_PIN_HPO\ + VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_HP_OUT, 0) +#define RT274_SET_PIN_DMIC1\ + VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_DMIC1, 0) +#define RT274_SET_PIN_SPDIF\ + VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT274_SPDIF, 0) +#define RT274_SET_PIN_DIG_CVT\ + VERB_CMD(AC_VERB_SET_DIGI_CONVERT_1, RT274_DIG_CVT, 0) +#define RT274_SET_AMP_GAIN_HPO\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_HP_OUT, 0) +#define RT274_SET_AMP_GAIN_ADC_IN1\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0) +#define RT274_SET_AMP_GAIN_ADC_IN2\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN2, 0) +#define RT274_GET_HP_SENSE\ + VERB_CMD(AC_VERB_GET_PIN_SENSE, RT274_HP_OUT, 0) +#define RT274_GET_MIC_SENSE\ + VERB_CMD(AC_VERB_GET_PIN_SENSE, RT274_MIC, 0) +#define RT274_SET_DMIC2_DEFAULT\ + VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT274_DMIC2, 0) +#define RT274_SET_SPDIF_DEFAULT\ + VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT274_SPDIF, 0) +#define RT274_DAC0L_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT0, 0xa000) +#define RT274_DAC0R_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT0, 0x9000) +#define RT274_DAC1L_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT1, 0xa000) +#define RT274_DAC1R_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_DAC_OUT1, 0x9000) +#define RT274_ADCL_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0x6000) +#define RT274_ADCR_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_ADC_IN1, 0x5000) +#define RT274_MIC_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_MIC, 0x7000) +#define RT274_LOUTL_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_LINE3, 0xa000) +#define RT274_LOUTR_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_LINE3, 0x9000) +#define RT274_HPOL_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_HP_OUT, 0xa000) +#define RT274_HPOR_GAIN\ + VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT274_HP_OUT, 0x9000) +#define RT274_DAC_FORMAT\ + VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT274_DAC_OUT0, 0) +#define RT274_ADC_FORMAT\ + VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT274_ADC_IN1, 0) +#define RT274_COEF_INDEX\ + VERB_CMD(AC_VERB_SET_COEF_INDEX, RT274_VENDOR_REGISTERS, 0) +#define RT274_PROC_COEF\ + VERB_CMD(AC_VERB_SET_PROC_COEF, RT274_VENDOR_REGISTERS, 0) +#define RT274_UNSOLICITED_INLINE_CMD\ + VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT274_INLINE_CMD, 0) +#define RT274_UNSOLICITED_HP_OUT\ + VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT274_HP_OUT, 0) +#define RT274_UNSOLICITED_MIC\ + VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT274_MIC, 0) +#define RT274_COEF58_INDEX\ + VERB_CMD(AC_VERB_SET_COEF_INDEX, 0x58, 0) +#define RT274_COEF58_COEF\ + VERB_CMD(AC_VERB_SET_PROC_COEF, 0x58, 0) +#define RT274_COEF5b_INDEX\ + VERB_CMD(AC_VERB_SET_COEF_INDEX, 0x5b, 0) +#define RT274_COEF5b_COEF\ + VERB_CMD(AC_VERB_SET_PROC_COEF, 0x5b, 0) +#define RT274_SET_STREAMID_DAC0\ + VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_DAC_OUT0, 0) +#define RT274_SET_STREAMID_DAC1\ + VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_DAC_OUT1, 0) +#define RT274_SET_STREAMID_ADC1\ + VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_ADC_IN1, 0) +#define RT274_SET_STREAMID_ADC2\ + VERB_CMD(AC_VERB_SET_CHANNEL_STREAMID, RT274_ADC_IN2, 0) + +/* Index registers */ +#define RT274_EAPD_GPIO_IRQ_CTRL 0x10 +#define RT274_PAD_CTRL12 0x35 +#define RT274_I2S_CTRL1 0x63 +#define RT274_I2S_CTRL2 0x64 +#define RT274_MCLK_CTRL 0x71 +#define RT274_CLK_CTRL 0x72 +#define RT274_PLL2_CTRL 0x7b + + +/* EAPD GPIO IRQ control (Index 0x10) */ +#define RT274_IRQ_DIS (0x0 << 13) +#define RT274_IRQ_EN (0x1 << 13) +#define RT274_IRQ_CLR (0x1 << 12) +#define RT274_GPI2_SEL_MASK (0x3 << 7) +#define RT274_GPI2_SEL_GPIO2 (0x0 << 7) +#define RT274_GPI2_SEL_I2S (0x1 << 7) +#define RT274_GPI2_SEL_DMIC_CLK (0x2 << 7) +#define RT274_GPI2_SEL_CBJ (0x3 << 7) + +/* Front I2S_Interface control 1 (Index 0x63) */ +#define RT274_I2S_MODE_MASK (0x1 << 11) +#define RT274_I2S_MODE_S (0x0 << 11) +#define RT274_I2S_MODE_M (0x1 << 11) +#define RT274_TDM_DIS (0x0 << 10) +#define RT274_TDM_EN (0x1 << 10) +#define RT274_TDM_CH_NUM (0x1 << 7) +#define RT274_TDM_2CH (0x0 << 7) +#define RT274_TDM_4CH (0x1 << 7) +#define RT274_I2S_FMT_MASK (0x3 << 8) +#define RT274_I2S_FMT_I2S (0x0 << 8) +#define RT274_I2S_FMT_LJ (0x1 << 8) +#define RT274_I2S_FMT_PCMA (0x2 << 8) +#define RT274_I2S_FMT_PCMB (0x3 << 8) + +/* MCLK clock domain control (Index 0x71) */ +#define RT274_MCLK_MODE_MASK (0x1 << 14) +#define RT274_MCLK_MODE_DIS (0x0 << 14) +#define RT274_MCLK_MODE_EN (0x1 << 14) + +/* Clock control (Index 0x72) */ +#define RT274_CLK_SRC_MASK (0x7 << 3) +#define RT274_CLK_SRC_MCLK (0x0 << 3) +#define RT274_CLK_SRC_PLL2 (0x3 << 3) + +/* PLL2 control (Index 0x7b) */ +#define RT274_PLL2_SRC_MASK (0x1 << 13) +#define RT274_PLL2_SRC_MCLK (0x0 << 13) +#define RT274_PLL2_SRC_BCLK (0x1 << 13) + +/* HP-OUT (0x21) */ +#define RT274_M_HP_MUX_SFT 14 +#define RT274_HP_SEL_MASK 0x1 +#define RT274_HP_SEL_SFT 0 +#define RT274_HP_SEL_F 0 +#define RT274_HP_SEL_S 1 + +/* ADC (0x22) (0x23) */ +#define RT274_ADC_SEL_MASK 0x7 +#define RT274_ADC_SEL_SFT 0 +#define RT274_ADC_SEL_MIC 0 +#define RT274_ADC_SEL_LINE1 1 +#define RT274_ADC_SEL_LINE2 2 +#define RT274_ADC_SEL_DMIC 3 + +#define RT274_SCLK_S_MCLK 0 +#define RT274_SCLK_S_PLL1 1 +#define RT274_SCLK_S_PLL2 2 + +#define RT274_PLL2_S_MCLK 0 +#define RT274_PLL2_S_BCLK 1 + +enum { + RT274_AIF1, + RT274_AIFS, +}; + +#endif /* __RT274_H__ */ + -- cgit v1.1 From 8a463639db5781ed52c972db013eba7d834f440d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:04 +0200 Subject: ALSA: als100: fix format string overflow warning The compiler sees that the format string might overflow for the longname: sound/isa/als100.c: In function 'snd_als100_pnp_detect': sound/isa/als100.c:225:27: error: ', dma ' directive writing 6 bytes into a region of size between 0 and 64 [-Werror=format-overflow=] sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/isa/als100.c:225:3: note: 'sprintf' output between 24 and 113 bytes into a destination of size 80 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", Open-coding "shortname" here gets us below the limit, and using snprintf() is a good idea too. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/isa/als100.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/isa/als100.c b/sound/isa/als100.c index bc9ea30..6a2c5b4 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -222,15 +222,16 @@ static int snd_card_als100_probe(int dev, if (pid->driver_data == SB_HW_DT019X) { strcpy(card->driver, "DT-019X"); strcpy(card->shortname, "Diamond Tech. DT-019X"); - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", - card->shortname, chip->name, chip->port, - irq[dev], dma8[dev]); + snprintf(card->longname, sizeof(card->longname), + "Diamond Tech. DT-019X, %s at 0x%lx, irq %d, dma %d", + chip->name, chip->port, irq[dev], dma8[dev]); } else { strcpy(card->driver, "ALS100"); strcpy(card->shortname, "Avance Logic ALS100"); - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, chip->name, chip->port, - irq[dev], dma8[dev], dma16[dev]); + snprintf(card->longname, sizeof(card->longname), + "Avance Logic ALS100, %s at 0x%lx, irq %d, dma %d&%d", + chip->name, chip->port, irq[dev], dma8[dev], + dma16[dev]); } if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) { -- cgit v1.1 From 6d8b04de87e1d736dad0ce7079e0ea112ab160c3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:05 +0200 Subject: ALSA: cs423x: fix format string overflow warning The snd_pcm name may overflow the card->longname total size: sound/isa/cs423x/cs4231.c: In function 'snd_cs4231_probe': sound/isa/cs423x/cs4231.c:115:26: error: ' at 0x' directive writing 6 bytes into a region of size between 1 and 80 [-Werror=format-overflow=] 0x%lx, irq %d, dma %d", sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This changes the driver to use snprintf() so we truncate the string instead of overflowing into the next field if that happens. I decided to split out the second format string for the extra DMA channel to keep the code simpler. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4231.c | 18 +++++++++++------- sound/isa/cs423x/cs4236.c | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index e8edd90..d90ab95 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -109,13 +109,17 @@ static int snd_cs4231_probe(struct device *dev, unsigned int n) if (error < 0) goto out; - strcpy(card->driver, "CS4231"); - strcpy(card->shortname, chip->pcm->name); - - sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - chip->pcm->name, chip->port, irq[n], dma1[n]); - if (dma2[n] >= 0) - sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]); + strlcpy(card->driver, "CS4231", sizeof(card->driver)); + strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); + + if (dma2[n] < 0) + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d, dma %d", + chip->pcm->name, chip->port, irq[n], dma1[n]); + else + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d, dma %d&%d", + chip->pcm->name, chip->port, irq[n], dma1[n], dma2[n]); error = snd_wss_mixer(chip); if (error < 0) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 1f9a3b2..4c09756 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -419,15 +419,17 @@ static int snd_cs423x_probe(struct snd_card *card, int dev) if (err < 0) return err; } - strcpy(card->driver, chip->pcm->name); - strcpy(card->shortname, chip->pcm->name); - sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", - chip->pcm->name, - chip->port, - irq[dev], - dma1[dev]); - if (dma2[dev] >= 0) - sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); + strlcpy(card->driver, chip->pcm->name, sizeof(card->driver)); + strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); + if (dma2[dev] < 0) + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %i, dma %i", + chip->pcm->name, chip->port, irq[dev], dma1[dev]); + else + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %i, dma %i&%d", + chip->pcm->name, chip->port, irq[dev], dma1[dev], + dma2[dev]); err = snd_wss_timer(chip, 0); if (err < 0) -- cgit v1.1 From 003d3e70dbebe9d99387f2eeda405b1950b808f2 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:06 +0200 Subject: ALSA: ad1848: fix format string overflow warning The snd_pcm name is too long to fit into the card shortname or a part of the longname: sound/isa/ad1848/ad1848.c: In function 'snd_ad1848_probe': sound/isa/ad1848/ad1848.c:116:26: error: ' at 0x' directive writing 6 bytes into a region of size between 1 and 80 [-Werror=format-overflow=] sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/isa/ad1848/ad1848.c:116:2: note: 'sprintf' output between 22 and 128 bytes into a destination of size 80 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ chip->pcm->name, chip->port, irq[n], dma1[n]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This changes the code to use length-checking functions that truncate if necessary. The "[Thinkpad]" substring is now also part of the snprintf(), as that could also overflow the buffer. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/isa/ad1848/ad1848.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index e739b1c..7c8e92f 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -110,13 +110,17 @@ static int snd_ad1848_probe(struct device *dev, unsigned int n) if (error < 0) goto out; - strcpy(card->driver, "AD1848"); - strcpy(card->shortname, chip->pcm->name); - - sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", - chip->pcm->name, chip->port, irq[n], dma1[n]); - if (thinkpad[n]) - strcat(card->longname, " [Thinkpad]"); + strlcpy(card->driver, "AD1848", sizeof(card->driver)); + strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); + + if (!thinkpad[n]) + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d, dma %d", + chip->pcm->name, chip->port, irq[n], dma1[n]); + else + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d, dma %d [Thinkpad]", + chip->pcm->name, chip->port, irq[n], dma1[n]); error = snd_card_register(card); if (error < 0) -- cgit v1.1 From 24d220773139ae03fc7bda692c5f6335ea457059 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:07 +0200 Subject: ALSA: opti9xx: fix format string overflow warning We pass a long name from "codec->pcm->name" into the longname string of the same length: sound/isa/opti9xx/miro.c: In function 'snd_miro_probe': sound/isa/opti9xx/miro.c:1356:39: error: '%s' directive writing up to 79 bytes into a region of size between 35 and 72 [-Werror=format-overflow=] sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", ^~ sound/isa/opti9xx/miro.c:1356:26: note: using the range [0, 4294967295] for directive argument sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/isa/opti9xx/miro.c:1356:2: note: 'sprintf' output between 32 and 185 bytes into a destination of size 80 sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", There is no easy way to avoid the theoretical overflow in this case, but using snprintf() will turn it into a harmless truncation. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/miro.c | 7 ++++--- sound/isa/opti9xx/opti92x-ad1848.c | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index bcbff56..1c5a12f 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -1353,9 +1353,10 @@ static int snd_miro_probe(struct snd_card *card) } strcpy(card->driver, "miro"); - sprintf(card->longname, "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, miro->name, codec->pcm->name, - miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); + snprintf(card->longname, sizeof(card->longname), + "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d", + card->shortname, miro->name, codec->pcm->name, + miro->wss_base + 4, miro->irq, miro->dma1, miro->dma2); if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) rmidi = NULL; diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index ceddb39..56dc581 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -879,13 +879,15 @@ static int snd_opti9xx_probe(struct snd_card *card) strcpy(card->driver, chip->name); sprintf(card->shortname, "OPTi %s", card->driver); #if defined(CS4231) || defined(OPTi93X) - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", - card->shortname, codec->pcm->name, - chip->wss_base + 4, irq, dma1, xdma2); + snprintf(card->longname, sizeof(card->longname), + "%s, %s at 0x%lx, irq %d, dma %d&%d", + card->shortname, codec->pcm->name, + chip->wss_base + 4, irq, dma1, xdma2); #else - sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", - card->shortname, codec->pcm->name, chip->wss_base + 4, irq, - dma1); + snprintf(card->longname, sizeof(card->longname), + "%s, %s at 0x%lx, irq %d, dma %d", + card->shortname, codec->pcm->name, chip->wss_base + 4, irq, + dma1); #endif /* CS4231 || OPTi93X */ if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) -- cgit v1.1 From c6e486ffb2e5a3a3e8f34fb24a6f6f2683cf010b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:08 +0200 Subject: ALSA: mixart: fix string overflow warning Using a temporary string produces warnings about a possible overflow in sprintf: sound/pci/mixart/mixart.c: In function 'snd_mixart_probe': sound/pci/mixart/mixart.c:1353:28: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 32 [-Werror=format-overflow=] sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); ^~~~~~~~~~~~~~ sound/pci/mixart/mixart.c:1353:28: note: using the range [-2147483648, 2147483647] for directive argument sound/pci/mixart/mixart.c:1353:3: note: 'sprintf' output between 10 and 51 bytes into a destination of size 32 sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/pci/mixart/mixart.c:1354:27: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 80 [-Werror=format-overflow=] sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); ^~~~~~~~~~~~~~ sound/pci/mixart/mixart.c:1354:27: note: using the range [-2147483648, 2147483647] for directive argument sound/pci/mixart/mixart.c:1354:3: note: 'sprintf' output between 10 and 99 bytes into a destination of size 80 Skipping the intermediate, we can get gcc to see that it is in fact safe here. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/pci/mixart/mixart.c | 10 +++++----- sound/pci/mixart/mixart.h | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 80d4399..6d7fbf3 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1313,9 +1313,6 @@ static int snd_mixart_probe(struct pci_dev *pci, } mgr->irq = pci->irq; - sprintf(mgr->shortname, "Digigram miXart"); - sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, irq %i", mgr->shortname, mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq); - /* init mailbox */ mgr->msg_fifo_readptr = 0; mgr->msg_fifo_writeptr = 0; @@ -1350,8 +1347,11 @@ static int snd_mixart_probe(struct pci_dev *pci, } strcpy(card->driver, CARD_NAME); - sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); - sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); + snprintf(card->shortname, sizeof(card->shortname), + "Digigram miXart [PCM #%d]", i); + snprintf(card->longname, sizeof(card->longname), + "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]", + mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); if ((err = snd_mixart_create(mgr, card, i)) < 0) { snd_card_free(card); diff --git a/sound/pci/mixart/mixart.h b/sound/pci/mixart/mixart.h index 4267438..69b3ece 100644 --- a/sound/pci/mixart/mixart.h +++ b/sound/pci/mixart/mixart.h @@ -74,10 +74,6 @@ struct mixart_mgr { /* memory-maps */ struct mem_area mem[2]; - /* share the name */ - char shortname[32]; /* short name of this soundcard */ - char longname[80]; /* name of this soundcard */ - /* one and only blocking message or notification may be pending */ u32 pending_event; wait_queue_head_t msg_sleep; -- cgit v1.1 From 7ad210ace5c1701421a4defa9d9e830a6f2ee56b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:09 +0200 Subject: ALSA: rme9652: fix format overflow warnings gcc-7 warns about a possible sprintf format string overflow with a temporary buffer that is used to print from another buffer of the same size: sound/pci/rme9652/hdspm.c: In function 'snd_hdspm_create_alsa_devices': sound/pci/rme9652/hdspm.c:2123:17: error: ' MIDIoverMADI' directive writing 13 bytes into a region of size between 1 and 32 [-Werror=format-overflow=] This extends the temporary buffer to twice the size, and changes the code to use the safer snprintf() across the entire file. The longer buffer is still necessary to avoid a format-truncation warning. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 48 +++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 254c3d0..2a3a916 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -2061,7 +2061,7 @@ static int snd_hdspm_create_midi(struct snd_card *card, struct hdspm *hdspm, int id) { int err; - char buf[32]; + char buf[64]; hdspm->midi[id].id = id; hdspm->midi[id].hdspm = hdspm; @@ -2120,19 +2120,23 @@ static int snd_hdspm_create_midi(struct snd_card *card, if ((id < 2) || ((2 == id) && ((MADI == hdspm->io_type) || (MADIface == hdspm->io_type)))) { if ((id == 0) && (MADIface == hdspm->io_type)) { - sprintf(buf, "%s MIDIoverMADI", card->shortname); + snprintf(buf, sizeof(buf), "%s MIDIoverMADI", + card->shortname); } else if ((id == 2) && (MADI == hdspm->io_type)) { - sprintf(buf, "%s MIDIoverMADI", card->shortname); + snprintf(buf, sizeof(buf), "%s MIDIoverMADI", + card->shortname); } else { - sprintf(buf, "%s MIDI %d", card->shortname, id+1); + snprintf(buf, sizeof(buf), "%s MIDI %d", + card->shortname, id+1); } err = snd_rawmidi_new(card, buf, id, 1, 1, &hdspm->midi[id].rmidi); if (err < 0) return err; - sprintf(hdspm->midi[id].rmidi->name, "%s MIDI %d", - card->id, id+1); + snprintf(hdspm->midi[id].rmidi->name, + sizeof(hdspm->midi[id].rmidi->name), + "%s MIDI %d", card->id, id+1); hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; snd_rawmidi_set_ops(hdspm->midi[id].rmidi, @@ -2148,14 +2152,16 @@ static int snd_hdspm_create_midi(struct snd_card *card, SNDRV_RAWMIDI_INFO_DUPLEX; } else { /* TCO MTC, read only */ - sprintf(buf, "%s MTC %d", card->shortname, id+1); + snprintf(buf, sizeof(buf), "%s MTC %d", + card->shortname, id+1); err = snd_rawmidi_new(card, buf, id, 1, 1, &hdspm->midi[id].rmidi); if (err < 0) return err; - sprintf(hdspm->midi[id].rmidi->name, - "%s MTC %d", card->id, id+1); + snprintf(hdspm->midi[id].rmidi->name, + sizeof(hdspm->midi[id].rmidi->name), + "%s MTC %d", card->id, id+1); hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; snd_rawmidi_set_ops(hdspm->midi[id].rmidi, @@ -6869,7 +6875,8 @@ static int snd_hdspm_create(struct snd_card *card, * when running with multiple cards. */ if (NULL == id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { - sprintf(card->id, "HDSPMx%06x", hdspm->serial); + snprintf(card->id, sizeof(card->id), + "HDSPMx%06x", hdspm->serial); snd_card_set_id(card, card->id); } } @@ -6954,17 +6961,18 @@ static int snd_hdspm_probe(struct pci_dev *pci, } if (hdspm->io_type != MADIface) { - sprintf(card->shortname, "%s_%x", - hdspm->card_name, - hdspm->serial); - sprintf(card->longname, "%s S/N 0x%x at 0x%lx, irq %d", - hdspm->card_name, - hdspm->serial, - hdspm->port, hdspm->irq); + snprintf(card->shortname, sizeof(card->shortname), "%s_%x", + hdspm->card_name, hdspm->serial); + snprintf(card->longname, sizeof(card->longname), + "%s S/N 0x%x at 0x%lx, irq %d", + hdspm->card_name, hdspm->serial, + hdspm->port, hdspm->irq); } else { - sprintf(card->shortname, "%s", hdspm->card_name); - sprintf(card->longname, "%s at 0x%lx, irq %d", - hdspm->card_name, hdspm->port, hdspm->irq); + snprintf(card->shortname, sizeof(card->shortname), "%s", + hdspm->card_name); + snprintf(card->longname, sizeof(card->longname), + "%s at 0x%lx, irq %d", + hdspm->card_name, hdspm->port, hdspm->irq); } err = snd_card_register(card); -- cgit v1.1 From 5051735221ba50cb5794b9194a8ad10a13368f2f Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 18 Jul 2017 13:48:10 +0200 Subject: ALSA: pcxhr: fix string overflow warnings With gcc-7, we get a warning about a possible string overflow: sound/pci/pcxhr/pcxhr.c: In function 'pcxhr_probe': sound/pci/pcxhr/pcxhr.c:1647:28: error: ' [PCM #' directive writing 7 bytes into a region of size between 1 and 32 [-Werror=format-overflow=] The shortname can simply be removed, and the longname can be changed into a shorter "name" string that is used in three places. Making it a little shorter (40 bytes) avoids the risk of overflowing completely, but I also use snprintf() here for extra clarity. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 19 ++++++++++--------- sound/pci/pcxhr/pcxhr.h | 3 +-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index bb7eee9..fa919f5 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1165,7 +1165,7 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip) struct snd_pcm *pcm; char name[32]; - sprintf(name, "pcxhr %d", chip->chip_idx); + snprintf(name, sizeof(name), "pcxhr %d", chip->chip_idx); if ((err = snd_pcm_new(chip->card, name, 0, chip->nb_streams_play, chip->nb_streams_capt, &pcm)) < 0) { @@ -1252,7 +1252,7 @@ static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_pcxhr *chip = entry->private_data; struct pcxhr_mgr *mgr = chip->mgr; - snd_iprintf(buffer, "\n%s\n", mgr->longname); + snd_iprintf(buffer, "\n%s\n", mgr->name); /* stats available when embedded DSP is running */ if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { @@ -1339,7 +1339,7 @@ static void pcxhr_proc_sync(struct snd_info_entry *entry, max_clock = PCXHR_CLOCK_TYPE_MAX; } - snd_iprintf(buffer, "\n%s\n", mgr->longname); + snd_iprintf(buffer, "\n%s\n", mgr->name); snd_iprintf(buffer, "Current Sample Clock\t: %s\n", texts[mgr->cur_clock_type]); snd_iprintf(buffer, "Current Sample Rate\t= %d\n", @@ -1597,10 +1597,9 @@ static int pcxhr_probe(struct pci_dev *pci, } mgr->irq = pci->irq; - sprintf(mgr->shortname, "Digigram %s", card_name); - sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i", - mgr->shortname, - mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); + snprintf(mgr->name, sizeof(mgr->name), + "Digigram at 0x%lx & 0x%lx, 0x%lx irq %i", + mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); /* ISR lock */ mutex_init(&mgr->lock); @@ -1644,8 +1643,10 @@ static int pcxhr_probe(struct pci_dev *pci, } strcpy(card->driver, DRIVER_NAME); - sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); - sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); + snprintf(card->shortname, sizeof(card->shortname), + "Digigram [PCM #%d]", i); + snprintf(card->longname, sizeof(card->longname), + "%s [PCM #%d]", mgr->name, i); if ((err = pcxhr_create(mgr, card, i)) < 0) { snd_card_free(card); diff --git a/sound/pci/pcxhr/pcxhr.h b/sound/pci/pcxhr/pcxhr.h index 9e39e50..d799cbd 100644 --- a/sound/pci/pcxhr/pcxhr.h +++ b/sound/pci/pcxhr/pcxhr.h @@ -75,8 +75,7 @@ struct pcxhr_mgr { unsigned long port[3]; /* share the name */ - char shortname[32]; /* short name of this soundcard */ - char longname[96]; /* name of this soundcard */ + char name[40]; /* name of this soundcard */ struct pcxhr_rmh *prmh; -- cgit v1.1 From 6c5a266029cc9b036643d08c2f9340d09ee03708 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 18 Jul 2017 22:35:06 +0530 Subject: ALSA: hda: constify pci_device_id. pci_device_id are not supposed to change at runtime. All functions working with pci_device_id provided by work with const pci_device_id. So mark the non-const structs as const. File size before: text data bss dec hex filename 2610 304 8 2922 b6a sound/hda/hdac_i915.o File size After adding 'const': text data bss dec hex filename 2674 240 8 2922 b6a sound/hda/hdac_i915.o Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/hda/hdac_i915.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c index 0659bf3..038a180 100644 --- a/sound/hda/hdac_i915.c +++ b/sound/hda/hdac_i915.c @@ -336,7 +336,7 @@ EXPORT_SYMBOL_GPL(snd_hdac_i915_register_notifier); /* check whether intel graphics is present */ static bool i915_gfx_present(void) { - static struct pci_device_id ids[] = { + static const struct pci_device_id ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), .class = PCI_BASE_CLASS_DISPLAY << 16, .class_mask = 0xff << 16 }, -- cgit v1.1 From 49a69163ddbe47063be960ad5c2fcfe94c8b473b Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 19 Jul 2017 09:52:12 +0800 Subject: ASoC: rt274: correct comment style There was a comment style issue in the driver. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt274.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index 81e29ba..fb683ff 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -1159,7 +1159,7 @@ static int rt274_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt274->regmap, 0x6f, 0x3000, 0x2000); /* HP DC Calibration */ regmap_update_bits(rt274->regmap, 0x6f, 0xf, 0x0); - //Set NID=58h.Index 00h [15]= 1b; + /* Set NID=58h.Index 00h [15]= 1b; */ regmap_write(rt274->regmap, RT274_COEF58_INDEX, 0x00); regmap_write(rt274->regmap, RT274_COEF58_COEF, 0xb888); msleep(500); -- cgit v1.1 From 1d5c5b6582cf829fc4c0c8eef6b9f9f0dc29c7b2 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Wed, 19 Jul 2017 10:20:23 +0800 Subject: ASoC: rt5663: Correct the mixer switch setting and remove redundant routing path The patch corrects the mixer siwtch setting that was the mistake in the previous commitment. And remove the redundant routing paths. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index d3f7bc2..45f8a98 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -59,7 +59,7 @@ struct rt5663_priv { }; static const struct reg_sequence rt5663_patch_list[] = { - { 0x002a, 0x8080 }, + { 0x002a, 0x8020 }, { 0x0086, 0x0028 }, }; @@ -482,7 +482,7 @@ static const struct reg_default rt5663_reg[] = { { 0x0023, 0x0039 }, { 0x0026, 0xc0c0 }, { 0x0029, 0x8080 }, - { 0x002a, 0x8080 }, + { 0x002a, 0x8020 }, { 0x002c, 0x000c }, { 0x002d, 0x0000 }, { 0x0040, 0x0808 }, @@ -1967,8 +1967,8 @@ static const struct snd_kcontrol_new rt5663_sto1_dac_l_mix[] = { }; static const struct snd_kcontrol_new rt5663_sto1_dac_r_mix[] = { - SOC_DAPM_SINGLE("DAC L Switch", RT5663_STO_DAC_MIXER, - RT5663_M_DAC_L1_STO_R_SHIFT, 1, 1), + SOC_DAPM_SINGLE("DAC R Switch", RT5663_STO_DAC_MIXER, + RT5663_M_DAC_R1_STO_R_SHIFT, 1, 1), }; /* Out Switch */ @@ -2358,11 +2358,9 @@ static const struct snd_soc_dapm_route rt5663_dapm_routes[] = { { "DAC R1", NULL, "ADDA MIXR" }, { "STO1 DAC MIXL", "DAC L Switch", "DAC L1" }, - { "STO1 DAC MIXL", "DAC R Switch", "DAC R1" }, { "STO1 DAC MIXL", NULL, "STO1 DAC L Power" }, { "STO1 DAC MIXL", NULL, "STO1 DAC Filter" }, { "STO1 DAC MIXR", "DAC R Switch", "DAC R1" }, - { "STO1 DAC MIXR", "DAC L Switch", "DAC L1" }, { "STO1 DAC MIXR", NULL, "STO1 DAC R Power" }, { "STO1 DAC MIXR", NULL, "STO1 DAC Filter" }, -- cgit v1.1 From ddc9e69b9dc23d4c0d8ed829575327746ea77a04 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 18 Jul 2017 20:34:17 +0300 Subject: ASoC: rt5677: Hide platform data in the module sources There is no user of legacy platform data. Remove separate header and hide its content inside module sources. Signed-off-by: Andy Shevchenko Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 29 +++++++++++++++++------------ sound/soc/codecs/rt5677.h | 30 +++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 36e530a..0f9642c 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -5019,25 +5020,21 @@ static const struct regmap_config rt5677_regmap = { }; static const struct i2c_device_id rt5677_i2c_id[] = { - { "rt5677", RT5677 }, - { "rt5676", RT5676 }, { } }; MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); static const struct of_device_id rt5677_of_match[] = { - { .compatible = "realtek,rt5677", }, + { .compatible = "realtek,rt5677", RT5677 }, { } }; MODULE_DEVICE_TABLE(of, rt5677_of_match); -#ifdef CONFIG_ACPI static const struct acpi_device_id rt5677_acpi_match[] = { { "RT5677CE", RT5677 }, { } }; MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); -#endif static void rt5677_read_acpi_properties(struct rt5677_priv *rt5677, struct device *dev) @@ -5147,7 +5144,6 @@ static void rt5677_free_irq(struct i2c_client *i2c) static int rt5677_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct rt5677_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5677_priv *rt5677; int ret; unsigned int val; @@ -5159,16 +5155,25 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5677); - rt5677->type = id->driver_data; + if (i2c->dev.of_node) { + const struct of_device_id *match_id; + + match_id = of_match_device(rt5677_of_match, &i2c->dev); + if (match_id) + rt5677->type = (enum rt5677_type)match_id->data; - if (pdata) - rt5677->pdata = *pdata; - else if (i2c->dev.of_node) rt5677_read_device_properties(rt5677, &i2c->dev); - else if (ACPI_HANDLE(&i2c->dev)) + } else if (ACPI_HANDLE(&i2c->dev)) { + const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(rt5677_acpi_match, &i2c->dev); + if (acpi_id) + rt5677->type = (enum rt5677_type)acpi_id->driver_data; + rt5677_read_acpi_properties(rt5677, &i2c->dev); - else + } else { return -EINVAL; + } /* pow-ldo2 and reset are optional. The codec pins may be statically * connected on the board without gpios. If the gpio device property diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index d46855a..9723997 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -12,7 +12,6 @@ #ifndef __RT5677_H__ #define __RT5677_H__ -#include #include #include @@ -1761,6 +1760,35 @@ enum { RT5677_I2S4_SOURCE = (0x1 << 18), }; +enum rt5677_dmic2_clk { + RT5677_DMIC_CLK1 = 0, + RT5677_DMIC_CLK2 = 1, +}; + +struct rt5677_platform_data { + /* IN1/IN2/LOUT1/LOUT2/LOUT3 can optionally be differential */ + bool in1_diff; + bool in2_diff; + bool lout1_diff; + bool lout2_diff; + bool lout3_diff; + /* DMIC2 clock source selection */ + enum rt5677_dmic2_clk dmic2_clk_pin; + + /* configures GPIO, 0 - floating, 1 - pulldown, 2 - pullup */ + u8 gpio_config[6]; + + /* jd1 can select 0 ~ 3 as OFF, GPIO1, GPIO2 and GPIO3 respectively */ + unsigned int jd1_gpio; + /* jd2 and jd3 can select 0 ~ 3 as + OFF, GPIO4, GPIO5 and GPIO6 respectively */ + unsigned int jd2_gpio; + unsigned int jd3_gpio; + + /* Set MICBIAS1 VDD 1v8 or 3v3 */ + bool micbias1_vdd_3v3; +}; + struct rt5677_priv { struct snd_soc_codec *codec; struct rt5677_platform_data pdata; -- cgit v1.1 From d4e753d3aa2c278cb1f7b4a61987c4037316e0fd Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 18 Jul 2017 20:34:18 +0300 Subject: ASoC: rt5677: Refactor code to avoid comparison unsigned >= 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rt5677_to_irq() has couple of redundant conditionals, one of which compares unsigned variable to be great than or equal to zero which is always true as compiler notices: sound/soc/codecs/rt5677.c: In function ‘rt5677_to_irq’: sound/soc/codecs/rt5677.c:4626:13: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] Refactor the code by removing redundant conditionals. Signed-off-by: Andy Shevchenko Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 50 ++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 0f9642c..a3cce57 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4625,35 +4625,27 @@ static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset) struct regmap_irq_chip_data *data = rt5677->irq_data; int irq; - if (offset >= RT5677_GPIO1 && offset <= RT5677_GPIO3) { - if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) || - (rt5677->pdata.jd1_gpio == 2 && - offset == RT5677_GPIO2) || - (rt5677->pdata.jd1_gpio == 3 && - offset == RT5677_GPIO3)) { - irq = RT5677_IRQ_JD1; - } else { - return -ENXIO; - } - } - - if (offset >= RT5677_GPIO4 && offset <= RT5677_GPIO6) { - if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) || - (rt5677->pdata.jd2_gpio == 2 && - offset == RT5677_GPIO5) || - (rt5677->pdata.jd2_gpio == 3 && - offset == RT5677_GPIO6)) { - irq = RT5677_IRQ_JD2; - } else if ((rt5677->pdata.jd3_gpio == 1 && - offset == RT5677_GPIO4) || - (rt5677->pdata.jd3_gpio == 2 && - offset == RT5677_GPIO5) || - (rt5677->pdata.jd3_gpio == 3 && - offset == RT5677_GPIO6)) { - irq = RT5677_IRQ_JD3; - } else { - return -ENXIO; - } + if ((rt5677->pdata.jd1_gpio == 1 && offset == RT5677_GPIO1) || + (rt5677->pdata.jd1_gpio == 2 && + offset == RT5677_GPIO2) || + (rt5677->pdata.jd1_gpio == 3 && + offset == RT5677_GPIO3)) { + irq = RT5677_IRQ_JD1; + } else if ((rt5677->pdata.jd2_gpio == 1 && offset == RT5677_GPIO4) || + (rt5677->pdata.jd2_gpio == 2 && + offset == RT5677_GPIO5) || + (rt5677->pdata.jd2_gpio == 3 && + offset == RT5677_GPIO6)) { + irq = RT5677_IRQ_JD2; + } else if ((rt5677->pdata.jd3_gpio == 1 && + offset == RT5677_GPIO4) || + (rt5677->pdata.jd3_gpio == 2 && + offset == RT5677_GPIO5) || + (rt5677->pdata.jd3_gpio == 3 && + offset == RT5677_GPIO6)) { + irq = RT5677_IRQ_JD3; + } else { + return -ENXIO; } return regmap_irq_get_virq(data, irq); -- cgit v1.1 From 3a4e1b93110362f0ca6f81c564b04b2aa4bab853 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 19 Jul 2017 17:26:41 +0200 Subject: ASoC: img: explicitly request exclusive reset control Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting reset lines") started to transition the reset control request API calls to explicitly state whether the driver needs exclusive or shared reset control behavior. Convert all drivers requesting exclusive resets to the explicit API call so the temporary transition helpers can be removed. No functional changes. Cc: Liam Girdwood Cc: Mark Brown Cc: alsa-devel@alsa-project.org Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/img/img-i2s-in.c | 2 +- sound/soc/img/img-i2s-out.c | 2 +- sound/soc/img/img-parallel-out.c | 2 +- sound/soc/img/img-spdif-in.c | 2 +- sound/soc/img/img-spdif-out.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/img/img-i2s-in.c b/sound/soc/img/img-i2s-in.c index 0389203..567f976 100644 --- a/sound/soc/img/img-i2s-in.c +++ b/sound/soc/img/img-i2s-in.c @@ -443,7 +443,7 @@ static int img_i2s_in_probe(struct platform_device *pdev) SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE; i2s->dai_driver.ops = &img_i2s_in_dai_ops; - rst = devm_reset_control_get(dev, "rst"); + rst = devm_reset_control_get_exclusive(dev, "rst"); if (IS_ERR(rst)) { if (PTR_ERR(rst) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; diff --git a/sound/soc/img/img-i2s-out.c b/sound/soc/img/img-i2s-out.c index 5f99713..78b7f6c 100644 --- a/sound/soc/img/img-i2s-out.c +++ b/sound/soc/img/img-i2s-out.c @@ -446,7 +446,7 @@ static int img_i2s_out_probe(struct platform_device *pdev) i2s->channel_base = base + (max_i2s_chan_pow_2 * 0x20); - i2s->rst = devm_reset_control_get(&pdev->dev, "rst"); + i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); if (IS_ERR(i2s->rst)) { if (PTR_ERR(i2s->rst) != -EPROBE_DEFER) dev_err(&pdev->dev, "No top level reset found\n"); diff --git a/sound/soc/img/img-parallel-out.c b/sound/soc/img/img-parallel-out.c index 33ceb20..23b0f0f 100644 --- a/sound/soc/img/img-parallel-out.c +++ b/sound/soc/img/img-parallel-out.c @@ -224,7 +224,7 @@ static int img_prl_out_probe(struct platform_device *pdev) prl->base = base; - prl->rst = devm_reset_control_get(&pdev->dev, "rst"); + prl->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); if (IS_ERR(prl->rst)) { if (PTR_ERR(prl->rst) != -EPROBE_DEFER) dev_err(&pdev->dev, "No top level reset found\n"); diff --git a/sound/soc/img/img-spdif-in.c b/sound/soc/img/img-spdif-in.c index 4d9953d..8adfd65 100644 --- a/sound/soc/img/img-spdif-in.c +++ b/sound/soc/img/img-spdif-in.c @@ -727,7 +727,7 @@ static int img_spdif_in_probe(struct platform_device *pdev) if (ret) return ret; - rst = devm_reset_control_get(&pdev->dev, "rst"); + rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); if (IS_ERR(rst)) { if (PTR_ERR(rst) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; diff --git a/sound/soc/img/img-spdif-out.c b/sound/soc/img/img-spdif-out.c index 08f93a5..383655d 100644 --- a/sound/soc/img/img-spdif-out.c +++ b/sound/soc/img/img-spdif-out.c @@ -334,7 +334,7 @@ static int img_spdif_out_probe(struct platform_device *pdev) spdif->base = base; - spdif->rst = devm_reset_control_get(&pdev->dev, "rst"); + spdif->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst"); if (IS_ERR(spdif->rst)) { if (PTR_ERR(spdif->rst) != -EPROBE_DEFER) dev_err(&pdev->dev, "No top level reset found\n"); -- cgit v1.1 From 635eac1e54d82c59f621a0f38a9bffae50f150c7 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 19 Jul 2017 17:26:42 +0200 Subject: ASoC: stm32: explicitly request exclusive reset control Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting reset lines") started to transition the reset control request API calls to explicitly state whether the driver needs exclusive or shared reset control behavior. Convert all drivers requesting exclusive resets to the explicit API call so the temporary transition helpers can be removed. No functional changes. Cc: Liam Girdwood Cc: Mark Brown Cc: Maxime Coquelin Cc: Alexandre Torgue Cc: alsa-devel@alsa-project.org Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/stm/stm32_i2s.c | 2 +- sound/soc/stm/stm32_sai.c | 2 +- sound/soc/stm/stm32_spdifrx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c index 8052629..6d0bf78 100644 --- a/sound/soc/stm/stm32_i2s.c +++ b/sound/soc/stm/stm32_i2s.c @@ -840,7 +840,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev, } /* Reset */ - rst = devm_reset_control_get(&pdev->dev, NULL); + rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (!IS_ERR(rst)) { reset_control_assert(rst); udelay(2); diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c index f771331..1258bef 100644 --- a/sound/soc/stm/stm32_sai.c +++ b/sound/soc/stm/stm32_sai.c @@ -85,7 +85,7 @@ static int stm32_sai_probe(struct platform_device *pdev) } /* reset */ - rst = reset_control_get(&pdev->dev, NULL); + rst = reset_control_get_exclusive(&pdev->dev, NULL); if (!IS_ERR(rst)) { reset_control_assert(rst); udelay(2); diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index 4e4250b..84cc567 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -930,7 +930,7 @@ static int stm32_spdifrx_probe(struct platform_device *pdev) return ret; } - rst = devm_reset_control_get(&pdev->dev, NULL); + rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (!IS_ERR(rst)) { reset_control_assert(rst); udelay(2); -- cgit v1.1 From 72bfa2117bdb4bb5b07dd5ed833ff3c318fc70b6 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 19 Jul 2017 17:26:43 +0200 Subject: ASoC: sun4i: explicitly request exclusive reset control Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting reset lines") started to transition the reset control request API calls to explicitly state whether the driver needs exclusive or shared reset control behavior. Convert all drivers requesting exclusive resets to the explicit API call so the temporary transition helpers can be removed. No functional changes. Cc: Liam Girdwood Cc: Mark Brown Cc: Maxime Ripard Cc: Chen-Yu Tsai Cc: alsa-devel@alsa-project.org Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-codec.c | 3 ++- sound/soc/sunxi/sun4i-i2s.c | 2 +- sound/soc/sunxi/sun4i-spdif.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 4c37231..73d054f 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -1573,7 +1573,8 @@ static int sun4i_codec_probe(struct platform_device *pdev) } if (quirks->has_reset) { - scodec->rst = devm_reset_control_get(&pdev->dev, NULL); + scodec->rst = devm_reset_control_get_exclusive(&pdev->dev, + NULL); if (IS_ERR(scodec->rst)) { dev_err(&pdev->dev, "Failed to get reset control\n"); return PTR_ERR(scodec->rst); diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 3635bbc..62b307b 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -716,7 +716,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev) } if (quirks->has_reset) { - i2s->rst = devm_reset_control_get(&pdev->dev, NULL); + i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(i2s->rst)) { dev_err(&pdev->dev, "Failed to get reset control\n"); return PTR_ERR(i2s->rst); diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c index eaefd07..c49f375 100644 --- a/sound/soc/sunxi/sun4i-spdif.c +++ b/sound/soc/sunxi/sun4i-spdif.c @@ -520,7 +520,8 @@ static int sun4i_spdif_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); if (quirks->has_reset) { - host->rst = devm_reset_control_get_optional(&pdev->dev, NULL); + host->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, + NULL); if (IS_ERR(host->rst) && PTR_ERR(host->rst) == -EPROBE_DEFER) { ret = -EPROBE_DEFER; dev_err(&pdev->dev, "Failed to get reset: %d\n", ret); -- cgit v1.1 From 181e8ce6a6c9a25ffbf10b09d8481f134c5a79ba Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Wed, 19 Jul 2017 17:26:44 +0200 Subject: ASoC: tegra: explicitly request exclusive reset control Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting reset lines") started to transition the reset control request API calls to explicitly state whether the driver needs exclusive or shared reset control behavior. Convert all drivers requesting exclusive resets to the explicit API call so the temporary transition helpers can be removed. No functional changes. Cc: Liam Girdwood Cc: Mark Brown Cc: Thierry Reding Cc: Jonathan Hunter Cc: alsa-devel@alsa-project.org Cc: linux-tegra@vger.kernel.org Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/tegra/tegra30_ahub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 8c10ae7..43679ae 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -544,8 +544,8 @@ static int tegra30_ahub_probe(struct platform_device *pdev) soc_data->mod_list_mask)) continue; - rst = reset_control_get(&pdev->dev, - configlink_mods[i].rst_name); + rst = reset_control_get_exclusive(&pdev->dev, + configlink_mods[i].rst_name); if (IS_ERR(rst)) { dev_err(&pdev->dev, "Can't get reset %s\n", configlink_mods[i].rst_name); -- cgit v1.1 From 0e46ccd5bc12ab28da9d2f514492aeead65f8332 Mon Sep 17 00:00:00 2001 From: Pradeep Tewani Date: Thu, 20 Jul 2017 11:40:55 +0530 Subject: ASoC: Intel: board: Remove .owner initialization in bxt_rt298 driver The .owner field is not required to be initialized in the driver. So, remove it. Signed-off-by: Pradeep Tewani Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_rt298.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 0c3a3cb..1daf98e 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -492,7 +492,6 @@ static int bxt_card_late_probe(struct snd_soc_card *card) /* broxton audio machine driver for SPT + RT298S */ static struct snd_soc_card broxton_rt298 = { .name = "broxton-rt298", - .owner = THIS_MODULE, .dai_link = broxton_rt298_dais, .num_links = ARRAY_SIZE(broxton_rt298_dais), .controls = broxton_controls, -- cgit v1.1 From 5622bc955898f4d5fa2ce8f507e5991b08367824 Mon Sep 17 00:00:00 2001 From: Pradeep Tewani Date: Thu, 20 Jul 2017 11:40:56 +0530 Subject: ASoC: hdac_hdmi: Add the vendor nid for Geminilake HDMI Geminilake HDMI codec has the different vendor nid. This patch adds the vendor nid as the part of driver data and uses it. Signed-off-by: Pradeep Tewani Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index bc2e74f..eb3ed8c 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -121,6 +121,10 @@ struct hdac_hdmi_dai_port_map { struct hdac_hdmi_cvt *cvt; }; +struct hdac_hdmi_drv_data { + unsigned int vendor_nid; +}; + struct hdac_hdmi_priv { struct hdac_hdmi_dai_port_map dai_map[HDA_MAX_CVTS]; struct list_head pin_list; @@ -131,6 +135,7 @@ struct hdac_hdmi_priv { int num_ports; struct mutex pin_mutex; struct hdac_chmap chmap; + struct hdac_hdmi_drv_data *drv_data; }; static struct hdac_hdmi_pcm * @@ -1321,6 +1326,7 @@ static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid) } #define INTEL_VENDOR_NID 0x08 +#define INTEL_GLK_VENDOR_NID 0x0b #define INTEL_GET_VENDOR_VERB 0xf81 #define INTEL_SET_VENDOR_VERB 0x781 #define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */ @@ -1329,14 +1335,17 @@ static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid) static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdac) { unsigned int vendor_param; + struct hdac_ext_device *edev = to_ehdac_device(hdac); + struct hdac_hdmi_priv *hdmi = edev->private_data; + unsigned int vendor_nid = hdmi->drv_data->vendor_nid; - vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0, + vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, INTEL_GET_VENDOR_VERB, 0); if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) return; vendor_param |= INTEL_EN_ALL_PIN_CVTS; - vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0, + vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, INTEL_SET_VENDOR_VERB, vendor_param); if (vendor_param == -1) return; @@ -1345,15 +1354,18 @@ static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdac) static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdac) { unsigned int vendor_param; + struct hdac_ext_device *edev = to_ehdac_device(hdac); + struct hdac_hdmi_priv *hdmi = edev->private_data; + unsigned int vendor_nid = hdmi->drv_data->vendor_nid; - vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0, + vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, INTEL_GET_VENDOR_VERB, 0); if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) return; /* enable DP1.2 mode */ vendor_param |= INTEL_EN_DP12; - vendor_param = snd_hdac_codec_read(hdac, INTEL_VENDOR_NID, 0, + vendor_param = snd_hdac_codec_read(hdac, vendor_nid, 0, INTEL_SET_VENDOR_VERB, vendor_param); if (vendor_param == -1) return; @@ -1927,6 +1939,14 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx) return port->eld.info.spk_alloc; } +static struct hdac_hdmi_drv_data intel_glk_drv_data = { + .vendor_nid = INTEL_GLK_VENDOR_NID, +}; + +static struct hdac_hdmi_drv_data intel_drv_data = { + .vendor_nid = INTEL_VENDOR_NID, +}; + static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) { struct hdac_device *codec = &edev->hdac; @@ -1935,6 +1955,8 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) struct hdac_ext_link *hlink = NULL; int num_dais = 0; int ret = 0; + struct hdac_driver *hdrv = drv_to_hdac_driver(codec->dev.driver); + const struct hda_device_id *hdac_id = hdac_get_device_id(codec, hdrv); /* hold the ref while we probe */ hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdac.dev)); @@ -1956,6 +1978,12 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; + if (hdac_id->driver_data) + hdmi_priv->drv_data = + (struct hdac_hdmi_drv_data *)hdac_id->driver_data; + else + hdmi_priv->drv_data = &intel_drv_data; + dev_set_drvdata(&codec->dev, edev); INIT_LIST_HEAD(&hdmi_priv->pin_list); @@ -2127,7 +2155,8 @@ static const struct hda_device_id hdmi_list[] = { HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0), HDA_CODEC_EXT_ENTRY(0x8086280a, 0x100000, "Broxton HDMI", 0), HDA_CODEC_EXT_ENTRY(0x8086280b, 0x100000, "Kabylake HDMI", 0), - HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI", 0), + HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI", + &intel_glk_drv_data), {} }; -- cgit v1.1 From 669eb871c440e19351c2d476d1837ed8a62afe16 Mon Sep 17 00:00:00 2001 From: Pradeep Tewani Date: Thu, 20 Jul 2017 11:40:57 +0530 Subject: ASoC: Intel: board: Add Geminilake platform support Geminilake also features rt298 codec, so use the same machine driver as Broxton. Geminilake uses SSP2 instead of SSP5. Signed-off-by: Pradeep Tewani Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_rt298.c | 84 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 1daf98e..a4b5bcb 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -114,7 +114,44 @@ static const struct snd_soc_dapm_route broxton_rt298_map[] = { { "iDisp2 Tx", NULL, "iDisp2_out"}, { "hifi1", NULL, "iDisp1 Tx"}, { "iDisp1 Tx", NULL, "iDisp1_out"}, +}; + +static const struct snd_soc_dapm_route geminilake_rt298_map[] = { + /* speaker */ + {"Speaker", NULL, "SPOR"}, + {"Speaker", NULL, "SPOL"}, + + /* HP jack connectors - unknown if we have jack detect */ + {"Headphone Jack", NULL, "HPO Pin"}, + + /* other jacks */ + {"MIC1", NULL, "Mic Jack"}, + + /* digital mics */ + {"DMIC1 Pin", NULL, "DMIC2"}, + {"DMic", NULL, "SoC DMIC"}, + + {"HDMI1", NULL, "hif5-0 Output"}, + {"HDMI2", NULL, "hif6-0 Output"}, + {"HDMI2", NULL, "hif7-0 Output"}, + + /* CODEC BE connections */ + { "AIF1 Playback", NULL, "ssp2 Tx"}, + { "ssp2 Tx", NULL, "codec0_out"}, + { "ssp2 Tx", NULL, "codec1_out"}, + + { "codec0_in", NULL, "ssp2 Rx" }, + { "ssp2 Rx", NULL, "AIF1 Capture" }, + { "dmic01_hifi", NULL, "DMIC01 Rx" }, + { "DMIC01 Rx", NULL, "Capture" }, + + { "hifi3", NULL, "iDisp3 Tx"}, + { "iDisp3 Tx", NULL, "iDisp3_out"}, + { "hifi2", NULL, "iDisp2 Tx"}, + { "iDisp2 Tx", NULL, "iDisp2_out"}, + { "hifi1", NULL, "iDisp1 Tx"}, + { "iDisp1 Tx", NULL, "iDisp1_out"}, }; static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd) @@ -505,9 +542,41 @@ static struct snd_soc_card broxton_rt298 = { }; +static struct snd_soc_card geminilake_rt298 = { + .name = "geminilake-rt298", + .dai_link = broxton_rt298_dais, + .num_links = ARRAY_SIZE(broxton_rt298_dais), + .controls = broxton_controls, + .num_controls = ARRAY_SIZE(broxton_controls), + .dapm_widgets = broxton_widgets, + .num_dapm_widgets = ARRAY_SIZE(broxton_widgets), + .dapm_routes = geminilake_rt298_map, + .num_dapm_routes = ARRAY_SIZE(geminilake_rt298_map), + .fully_routed = true, + .late_probe = bxt_card_late_probe, +}; + static int broxton_audio_probe(struct platform_device *pdev) { struct bxt_rt286_private *ctx; + struct snd_soc_card *card = + (struct snd_soc_card *)pdev->id_entry->driver_data; + int i; + + for (i = 0; i < ARRAY_SIZE(broxton_rt298_dais); i++) { + if (!strncmp(card->dai_link[i].codec_name, "i2c-INT343A:00", + I2C_NAME_SIZE)) { + if (!strncmp(card->name, "broxton-rt298", + PLATFORM_NAME_SIZE)) { + card->dai_link[i].name = "SSP5-Codec"; + card->dai_link[i].cpu_dai_name = "SSP5 Pin"; + } else if (!strncmp(card->name, "geminilake-rt298", + PLATFORM_NAME_SIZE)) { + card->dai_link[i].name = "SSP2-Codec"; + card->dai_link[i].cpu_dai_name = "SSP2 Pin"; + } + } + } ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); if (!ctx) @@ -515,18 +584,26 @@ static int broxton_audio_probe(struct platform_device *pdev) INIT_LIST_HEAD(&ctx->hdmi_pcm_list); - broxton_rt298.dev = &pdev->dev; - snd_soc_card_set_drvdata(&broxton_rt298, ctx); + card->dev = &pdev->dev; + snd_soc_card_set_drvdata(card, ctx); - return devm_snd_soc_register_card(&pdev->dev, &broxton_rt298); + return devm_snd_soc_register_card(&pdev->dev, card); } +static const struct platform_device_id bxt_board_ids[] = { + { .name = "bxt_alc298s_i2s", .driver_data = + (unsigned long)&broxton_rt298 }, + { .name = "glk_alc298s_i2s", .driver_data = + (unsigned long)&geminilake_rt298 }, +}; + static struct platform_driver broxton_audio = { .probe = broxton_audio_probe, .driver = { .name = "bxt_alc298s_i2s", .pm = &snd_soc_pm_ops, }, + .id_table = bxt_board_ids, }; module_platform_driver(broxton_audio) @@ -536,3 +613,4 @@ MODULE_AUTHOR("Senthilnathan Veppur "); MODULE_DESCRIPTION("Intel SST Audio for Broxton"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:bxt_alc298s_i2s"); +MODULE_ALIAS("platform:glk_alc298s_i2s"); -- cgit v1.1 From c0d1cb8366bab9963822c27b0d40cb8b32928cdc Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 18 Jul 2017 20:34:19 +0300 Subject: ASoC: rt5677: Remove never used variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are two variables that have never been used. sound/soc/codecs/rt5677.c:785:35: warning: ‘in_vol_tlv’ defined but not used [-Wunused-const-variable=] static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); sound/soc/codecs/rt5677.c:783:35: warning: ‘out_vol_tlv’ defined but not used [-Wunused-const-variable=] static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); Simple remove them. Signed-off-by: Andy Shevchenko Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index a3cce57..9e9de0e 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -780,9 +780,7 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on) return 0; } -static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0); -static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0); static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0); -- cgit v1.1 From e8be3a5ad335316ddf1b90e0386426093187bfc7 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Thu, 20 Jul 2017 12:05:34 +0800 Subject: ASoC: rt5514: Support the TDM docking mode The TDM docking mode can share the bus to other devices simultaneously. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 33 ++++++++++++++++++++++++++++++++- sound/soc/codecs/rt5514.h | 12 ++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 4ca73bf..a105c84 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -871,11 +871,38 @@ static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, { struct snd_soc_codec *codec = dai->codec; struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); - unsigned int val = 0; + unsigned int val = 0, val2 = 0; if (rx_mask || tx_mask) val |= RT5514_TDM_MODE; + switch (tx_mask) { + case 0x3: + val2 |= RT5514_TDM_DOCKING_MODE | RT5514_TDM_DOCKING_VALID_CH2 | + RT5514_TDM_DOCKING_START_SLOT0; + break; + + case 0x30: + val2 |= RT5514_TDM_DOCKING_MODE | RT5514_TDM_DOCKING_VALID_CH2 | + RT5514_TDM_DOCKING_START_SLOT4; + break; + + case 0xf: + val2 |= RT5514_TDM_DOCKING_MODE | RT5514_TDM_DOCKING_VALID_CH4 | + RT5514_TDM_DOCKING_START_SLOT0; + break; + + case 0xf0: + val2 |= RT5514_TDM_DOCKING_MODE | RT5514_TDM_DOCKING_VALID_CH4 | + RT5514_TDM_DOCKING_START_SLOT4; + break; + + default: + break; + } + + + switch (slots) { case 4: val |= RT5514_TDMSLOT_SEL_RX_4CH | RT5514_TDMSLOT_SEL_TX_4CH; @@ -921,6 +948,10 @@ static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, RT5514_CH_LEN_RX_MASK | RT5514_CH_LEN_TX_MASK | RT5514_TDM_MODE2, val); + regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL2, + RT5514_TDM_DOCKING_MODE | RT5514_TDM_DOCKING_VALID_CH_MASK | + RT5514_TDM_DOCKING_START_MASK, val2); + return 0; } diff --git a/sound/soc/codecs/rt5514.h b/sound/soc/codecs/rt5514.h index 02bc212..75024a4 100644 --- a/sound/soc/codecs/rt5514.h +++ b/sound/soc/codecs/rt5514.h @@ -164,6 +164,18 @@ #define RT5514_I2S_DL_24 (0x2 << 0) #define RT5514_I2S_DL_8 (0x3 << 0) +/* RT5514_I2S_CTRL2 (0x2014) */ +#define RT5514_TDM_DOCKING_MODE (0x1 << 31) +#define RT5514_TDM_DOCKING_MODE_SFT 31 +#define RT5514_TDM_DOCKING_VALID_CH_MASK (0x1 << 29) +#define RT5514_TDM_DOCKING_VALID_CH_SFT 29 +#define RT5514_TDM_DOCKING_VALID_CH2 (0x0 << 29) +#define RT5514_TDM_DOCKING_VALID_CH4 (0x1 << 29) +#define RT5514_TDM_DOCKING_START_MASK (0x1 << 28) +#define RT5514_TDM_DOCKING_START_SFT 28 +#define RT5514_TDM_DOCKING_START_SLOT0 (0x0 << 28) +#define RT5514_TDM_DOCKING_START_SLOT4 (0x1 << 28) + /* RT5514_DIG_SOURCE_CTRL (0x20a4) */ #define RT5514_AD1_DMIC_INPUT_SEL (0x1 << 1) #define RT5514_AD1_DMIC_INPUT_SEL_SFT 1 -- cgit v1.1 From 01dfb1ec15ce6120055401953265c7b51e899292 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 20 Jul 2017 13:07:50 +0800 Subject: ASoC: rt5665: add clcok control for master mode Add i2s clock control for codec master mode. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5665.c | 24 +++++++++++++++++++++++- sound/soc/codecs/rt5665.h | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index d3103ef..ef27561 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -4186,6 +4186,15 @@ static int rt5665_hw_params(struct snd_pcm_substream *substream, break; } + if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { + snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + RT5665_I2S2_M_PD_MASK, pre_div << RT5665_I2S2_M_PD_SFT); + } + if (rt5665->master[RT5665_AIF3]) { + snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + RT5665_I2S3_M_PD_MASK, pre_div << RT5665_I2S3_M_PD_SFT); + } + return 0; } @@ -4262,7 +4271,7 @@ static int rt5665_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, int source, unsigned int freq, int dir) { struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); - unsigned int reg_val = 0; + unsigned int reg_val = 0, src = 0; if (freq == rt5665->sysclk && clk_id == rt5665->sysclk_src) return 0; @@ -4270,12 +4279,15 @@ static int rt5665_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, switch (clk_id) { case RT5665_SCLK_S_MCLK: reg_val |= RT5665_SCLK_SRC_MCLK; + src = RT5665_CLK_SRC_MCLK; break; case RT5665_SCLK_S_PLL1: reg_val |= RT5665_SCLK_SRC_PLL1; + src = RT5665_CLK_SRC_PLL1; break; case RT5665_SCLK_S_RCCLK: reg_val |= RT5665_SCLK_SRC_RCCLK; + src = RT5665_CLK_SRC_RCCLK; break; default: dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); @@ -4283,6 +4295,16 @@ static int rt5665_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, } snd_soc_update_bits(codec, RT5665_GLB_CLK, RT5665_SCLK_SRC_MASK, reg_val); + + if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { + snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + RT5665_I2S2_SRC_MASK, src << RT5665_I2S2_SRC_SFT); + } + if (rt5665->master[RT5665_AIF3]) { + snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + RT5665_I2S3_SRC_MASK, src << RT5665_I2S3_SRC_SFT); + } + rt5665->sysclk = freq; rt5665->sysclk_src = clk_id; diff --git a/sound/soc/codecs/rt5665.h b/sound/soc/codecs/rt5665.h index 1db5c6a..8f08acb 100644 --- a/sound/soc/codecs/rt5665.h +++ b/sound/soc/codecs/rt5665.h @@ -1628,6 +1628,27 @@ #define RT5665_PWR_CLK1M_PD (0x0 << 8) #define RT5665_PWR_CLK1M_PU (0x1 << 8) +/* I2S Master Mode Clock Control 1 (0x00a0) */ +#define RT5665_CLK_SRC_MCLK (0x0) +#define RT5665_CLK_SRC_PLL1 (0x1) +#define RT5665_CLK_SRC_RCCLK (0x2) +#define RT5665_I2S_PD_1 (0x0) +#define RT5665_I2S_PD_2 (0x1) +#define RT5665_I2S_PD_3 (0x2) +#define RT5665_I2S_PD_4 (0x3) +#define RT5665_I2S_PD_6 (0x4) +#define RT5665_I2S_PD_8 (0x5) +#define RT5665_I2S_PD_12 (0x6) +#define RT5665_I2S_PD_16 (0x7) +#define RT5665_I2S2_SRC_MASK (0x3 << 12) +#define RT5665_I2S2_SRC_SFT 12 +#define RT5665_I2S2_M_PD_MASK (0x7 << 8) +#define RT5665_I2S2_M_PD_SFT 8 +#define RT5665_I2S3_SRC_MASK (0x3 << 4) +#define RT5665_I2S3_SRC_SFT 4 +#define RT5665_I2S3_M_PD_MASK (0x7 << 0) +#define RT5665_I2S3_M_PD_SFT 0 + /* EQ Control 1 (0x00b0) */ #define RT5665_EQ_SRC_DAC (0x0 << 15) -- cgit v1.1 From 8bfa426845419d1fe895fc5668ab29b3a0c36c85 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 20 Jul 2017 13:07:51 +0800 Subject: ASoC: rt5665: add clock sync control for master mode We can sleect the i2s clock source for each i2s bus in master mode. The choice is depended on the HW design and the use case. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5665.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index ef27561..7e64b25 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -1381,6 +1381,16 @@ static void rt5665_jack_detect_handler(struct work_struct *work) mutex_unlock(&rt5665->calibrate_mutex); } +static const char * const rt5665_clk_sync[] = { + "I2S1_1", "I2S1_2", "I2S2", "I2S3", "IF2 Slave", "IF3 Slave" +}; + +static const struct soc_enum rt5665_enum[] = { + SOC_ENUM_SINGLE(RT5665_I2S1_SDP, 11, 5, rt5665_clk_sync), + SOC_ENUM_SINGLE(RT5665_I2S2_SDP, 11, 5, rt5665_clk_sync), + SOC_ENUM_SINGLE(RT5665_I2S3_SDP, 11, 5, rt5665_clk_sync), +}; + static const struct snd_kcontrol_new rt5665_snd_controls[] = { /* Headphone Output Volume */ SOC_DOUBLE_R_EXT_TLV("Headphone Playback Volume", RT5665_HPL_GAIN, @@ -1446,6 +1456,11 @@ static const struct snd_kcontrol_new rt5665_snd_controls[] = { SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5665_STO2_ADC_BOOST, RT5665_STO2_ADC_L_BST_SFT, RT5665_STO2_ADC_R_BST_SFT, 3, 0, adc_bst_tlv), + + /* I2S3 CLK Source */ + SOC_ENUM("I2S1 Master Clk Sel", rt5665_enum[0]), + SOC_ENUM("I2S2 Master Clk Sel", rt5665_enum[1]), + SOC_ENUM("I2S3 Master Clk Sel", rt5665_enum[2]), }; /** -- cgit v1.1 From b833786b69c14fe98846c38d36d8f6e5e92ccdd8 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 24 Jul 2017 19:11:52 +0800 Subject: ASoC: rt5665: add MONOVOL Playback Volume control MONOVOL Playback Volume is a playback volume control on "MONOVOL MIX". Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5665.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 7e64b25..54ace3b 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -1402,6 +1402,9 @@ static const struct snd_kcontrol_new rt5665_snd_controls[] = { RT5665_L_VOL_SFT, 15, 1, snd_soc_get_volsw, rt5665_mono_vol_put, mono_vol_tlv), + SOC_SINGLE_TLV("MONOVOL Playback Volume", RT5665_MONO_OUT, + RT5665_L_VOL_SFT, 39, 1, out_vol_tlv), + /* Output Volume */ SOC_DOUBLE_TLV("OUT Playback Volume", RT5665_LOUT, RT5665_L_VOL_SFT, RT5665_R_VOL_SFT, 39, 1, out_vol_tlv), -- cgit v1.1 From 16d4498962c7b76a76553e8dd943abe1e9facc0d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 24 Jul 2017 01:45:59 +0000 Subject: ASoC: rsnd: don't use private_value on rsnd_kctrl_new() Current rsnd kctrl is using both .private_value (for rsnd_kctrl_cfg) and .private_data (for rsnd_mod) on snd_kcontrol. But only 1 private data (= rsnd_kctrl_cfg) can be enough if it has rsnd_mod pointer. This patch doesn't use private_value. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 14 ++++++-------- sound/soc/sh/rcar/rsnd.h | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 3f2ced2..acafb83 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1169,11 +1169,10 @@ static struct snd_pcm_ops rsnd_pcm_ops = { /* * snd_kcontrol */ -#define kcontrol_to_cfg(kctrl) ((struct rsnd_kctrl_cfg *)kctrl->private_value) static int rsnd_kctrl_info(struct snd_kcontrol *kctrl, struct snd_ctl_elem_info *uinfo) { - struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl); + struct rsnd_kctrl_cfg *cfg = snd_kcontrol_chip(kctrl); if (cfg->texts) { uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1199,7 +1198,7 @@ static int rsnd_kctrl_info(struct snd_kcontrol *kctrl, static int rsnd_kctrl_get(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *uc) { - struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl); + struct rsnd_kctrl_cfg *cfg = snd_kcontrol_chip(kctrl); int i; for (i = 0; i < cfg->size; i++) @@ -1214,8 +1213,7 @@ static int rsnd_kctrl_get(struct snd_kcontrol *kctrl, static int rsnd_kctrl_put(struct snd_kcontrol *kctrl, struct snd_ctl_elem_value *uc) { - struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); - struct rsnd_kctrl_cfg *cfg = kcontrol_to_cfg(kctrl); + struct rsnd_kctrl_cfg *cfg = snd_kcontrol_chip(kctrl); int i, change = 0; if (!cfg->accept(cfg->io)) @@ -1232,7 +1230,7 @@ static int rsnd_kctrl_put(struct snd_kcontrol *kctrl, } if (change && cfg->update) - cfg->update(cfg->io, mod); + cfg->update(cfg->io, cfg->mod); return change; } @@ -1284,14 +1282,13 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, .index = rtd->num, .get = rsnd_kctrl_get, .put = rsnd_kctrl_put, - .private_value = (unsigned long)cfg, }; int ret; if (size > RSND_MAX_CHANNELS) return -EINVAL; - kctrl = snd_ctl_new1(&knew, mod); + kctrl = snd_ctl_new1(&knew, cfg); if (!kctrl) return -ENOMEM; @@ -1307,6 +1304,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, cfg->card = card; cfg->kctrl = kctrl; cfg->io = io; + cfg->mod = mod; return 0; } diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 99c5761..c5de71f 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -614,6 +614,7 @@ struct rsnd_kctrl_cfg { struct rsnd_dai_stream *io; struct snd_card *card; struct snd_kcontrol *kctrl; + struct rsnd_mod *mod; }; #define RSND_MAX_CHANNELS 8 -- cgit v1.1 From 1628ef89042fdb90aaea657942455e00e160174d Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 24 Jul 2017 15:34:23 +0800 Subject: ASoC: rt5514: Add the I2S ASRC support The patch adds the I2S ASRC support. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5514.h | 7 +++++++ 2 files changed, 26 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index a105c84..882fdc4 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -63,6 +63,7 @@ static const struct reg_sequence rt5514_patch[] = { {RT5514_SRC_CTRL, 0x44000eee}, {RT5514_ANA_CTRL_LDO10, 0x00028604}, {RT5514_ANA_CTRL_ADCFED, 0x00000800}, + {RT5514_ASRC_IN_CTRL1, 0x00000003}, }; static const struct reg_default rt5514_reg[] = { @@ -471,6 +472,15 @@ static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, return 0; } +static int rt5514_i2s_use_asrc(struct snd_soc_dapm_widget *source, + struct snd_soc_dapm_widget *sink) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + + return (rt5514->sysclk > rt5514->lrck * 384); +} + static const struct snd_soc_dapm_widget rt5514_dapm_widgets[] = { /* Input Lines */ SND_SOC_DAPM_INPUT("DMIC1L"), @@ -541,6 +551,10 @@ static const struct snd_soc_dapm_widget rt5514_dapm_widgets[] = { RT5514_POW_PLL1_LDO_BIT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("PLL1", RT5514_PWR_ANA2, RT5514_POW_PLL1_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("ASRC AD1", 1, RT5514_CLK_CTRL2, + RT5514_CLK_AD0_ASRC_EN_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY_S("ASRC AD2", 1, RT5514_CLK_CTRL2, + RT5514_CLK_AD1_ASRC_EN_BIT, 0, NULL, 0), /* ADC Mux */ SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0, @@ -638,6 +652,7 @@ static const struct snd_soc_dapm_route rt5514_dapm_routes[] = { { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" }, { "Stereo1 ADC MIX", NULL, "adc stereo1 filter" }, { "adc stereo1 filter", NULL, "PLL1", rt5514_is_sys_clk_from_pll }, + { "adc stereo1 filter", NULL, "ASRC AD1", rt5514_i2s_use_asrc }, { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" }, { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" }, @@ -654,6 +669,7 @@ static const struct snd_soc_dapm_route rt5514_dapm_routes[] = { { "Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR" }, { "Stereo2 ADC MIX", NULL, "adc stereo2 filter" }, { "adc stereo2 filter", NULL, "PLL1", rt5514_is_sys_clk_from_pll }, + { "adc stereo2 filter", NULL, "ASRC AD2", rt5514_i2s_use_asrc }, { "AIF1TX", NULL, "Stereo1 ADC MIX"}, { "AIF1TX", NULL, "Stereo2 ADC MIX"}, @@ -706,6 +722,9 @@ static int rt5514_hw_params(struct snd_pcm_substream *substream, regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1, RT5514_I2S_DL_MASK, val_len); + regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1, + RT5514_CLK_AD_ANA1_SEL_MASK, + (pre_div + 1) << RT5514_CLK_AD_ANA1_SEL_SFT); regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2, RT5514_CLK_SYS_DIV_OUT_MASK | RT5514_SEL_ADC_OSR_MASK, pre_div << RT5514_CLK_SYS_DIV_OUT_SFT | diff --git a/sound/soc/codecs/rt5514.h b/sound/soc/codecs/rt5514.h index 75024a4..2dc40e6 100644 --- a/sound/soc/codecs/rt5514.h +++ b/sound/soc/codecs/rt5514.h @@ -37,6 +37,7 @@ #define RT5514_PLL3_CALIB_CTRL5 0x2124 #define RT5514_DELAY_BUF_CTRL1 0x2140 #define RT5514_DELAY_BUF_CTRL3 0x2148 +#define RT5514_ASRC_IN_CTRL1 0x2180 #define RT5514_DOWNFILTER0_CTRL1 0x2190 #define RT5514_DOWNFILTER0_CTRL2 0x2194 #define RT5514_DOWNFILTER0_CTRL3 0x2198 @@ -197,8 +198,14 @@ #define RT5514_CLK_AD0_EN_BIT 23 #define RT5514_CLK_DMIC_OUT_SEL_MASK (0x7 << 8) #define RT5514_CLK_DMIC_OUT_SEL_SFT 8 +#define RT5514_CLK_AD_ANA1_SEL_MASK (0xf << 0) +#define RT5514_CLK_AD_ANA1_SEL_SFT 0 /* RT5514_CLK_CTRL2 (0x2108) */ +#define RT5514_CLK_AD1_ASRC_EN (0x1 << 17) +#define RT5514_CLK_AD1_ASRC_EN_BIT 17 +#define RT5514_CLK_AD0_ASRC_EN (0x1 << 16) +#define RT5514_CLK_AD0_ASRC_EN_BIT 16 #define RT5514_CLK_SYS_DIV_OUT_MASK (0x7 << 8) #define RT5514_CLK_SYS_DIV_OUT_SFT 8 #define RT5514_SEL_ADC_OSR_MASK (0x7 << 4) -- cgit v1.1 From 8a43c2240c862bbf3fc612d0533b891bd75ec771 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 23 Jul 2017 22:53:24 +0530 Subject: ASoC: rt5514: constify acpi_device_id. acpi_device_id are not supposed to change at runtime. All functions working with acpi_device_id provided by work with const acpi_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 882fdc4..3d0aea8 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -1134,7 +1134,7 @@ MODULE_DEVICE_TABLE(of, rt5514_of_match); #endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt5514_acpi_match[] = { +static const struct acpi_device_id rt5514_acpi_match[] = { { "10EC5514", 0}, {}, }; -- cgit v1.1 From 1d89147cc3dfef185e701baad437fa91c0977384 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 23 Jul 2017 22:53:25 +0530 Subject: ASoC: rt5663: constify acpi_device_id. acpi_device_id are not supposed to change at runtime. All functions working with acpi_device_id provided by work with const acpi_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index a33202a..271cc81 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2956,7 +2956,7 @@ MODULE_DEVICE_TABLE(of, rt5663_of_match); #endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt5663_acpi_match[] = { +static const struct acpi_device_id rt5663_acpi_match[] = { { "10EC5663", 0}, {}, }; -- cgit v1.1 From f36544a425d3b75281a1601fe663086aec5b36c7 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 23 Jul 2017 22:53:26 +0530 Subject: ASoC: rt5659: constify acpi_device_id. acpi_device_id are not supposed to change at runtime. All functions working with acpi_device_id provided by work with const acpi_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index 1b70608..0a99fad 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -4222,7 +4222,7 @@ MODULE_DEVICE_TABLE(of, rt5659_of_match); #endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt5659_acpi_match[] = { +static const struct acpi_device_id rt5659_acpi_match[] = { { "10EC5658", 0, }, { "10EC5659", 0, }, { }, -- cgit v1.1 From abfedab1163a6b01ab400a67f4eed0fea3ccbdd1 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 23 Jul 2017 22:53:27 +0530 Subject: ASoC: rt5665: constify acpi_device_id. acpi_device_id are not supposed to change at runtime. All functions working with acpi_device_id provided by work with const acpi_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/codecs/rt5665.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 54ace3b..d0a9490 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -4970,7 +4970,7 @@ MODULE_DEVICE_TABLE(of, rt5665_of_match); #endif #ifdef CONFIG_ACPI -static struct acpi_device_id rt5665_acpi_match[] = { +static const struct acpi_device_id rt5665_acpi_match[] = { {"10EC5665", 0,}, {"10EC5666", 0,}, {"10EC5668", 0,}, -- cgit v1.1 From c2bf252536577db77c719f62a54cad2e4be5c4d7 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Wed, 26 Jul 2017 18:32:20 +0800 Subject: ASoC: rt5514: Use the IS_ENABLED to supports the module build The patch uses the macro IS_ENABLED to make sure that the SPI function also supports the module build. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 3d0aea8..21cbb56 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -31,7 +31,7 @@ #include "rl6231.h" #include "rt5514.h" -#if defined(CONFIG_SND_SOC_RT5514_SPI) +#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) #include "rt5514-spi.h" #endif @@ -312,7 +312,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, request_firmware(&fw, RT5514_FIRMWARE1, codec->dev); if (fw) { -#if defined(CONFIG_SND_SOC_RT5514_SPI) +#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) rt5514_spi_burst_write(0x4ff60000, fw->data, ((fw->size/8)+1)*8); #else @@ -325,7 +325,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, request_firmware(&fw, RT5514_FIRMWARE2, codec->dev); if (fw) { -#if defined(CONFIG_SND_SOC_RT5514_SPI) +#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) rt5514_spi_burst_write(0x4ffc0000, fw->data, ((fw->size/8)+1)*8); #else -- cgit v1.1 From 8215313c8bf487b6b15839be3c18fdd1598b1e79 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 26 Jul 2017 15:28:26 +0800 Subject: ASoC: rt5670: add symmetric_rates flag rt5670 requires symmetric rate of capture and playback. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 0ec7985..174141f 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -2743,6 +2743,7 @@ static struct snd_soc_dai_driver rt5670_dai[] = { .formats = RT5670_FORMATS, }, .ops = &rt5670_aif_dai_ops, + .symmetric_rates = 1, }, { .name = "rt5670-aif2", @@ -2762,6 +2763,7 @@ static struct snd_soc_dai_driver rt5670_dai[] = { .formats = RT5670_FORMATS, }, .ops = &rt5670_aif_dai_ops, + .symmetric_rates = 1, }, }; -- cgit v1.1 From a7e1149b64091ac87dfb18b177abb63ba4cbbd3d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 26 Jul 2017 05:17:08 +0000 Subject: ASoC: remove cache_bypass from snd_soc_codec snd_soc_codec .cache_bypass related operation code has been removed. Let's remove remaining code. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index b5ee294..b0380b5 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -577,7 +577,6 @@ static int max98927_probe(struct snd_soc_codec *codec) max98927->codec = codec; codec->control_data = max98927->regmap; - codec->cache_bypass = 1; /* Software Reset */ regmap_write(max98927->regmap, -- cgit v1.1 From d2d2c0a0f0e230e9650e778d0d5c7ed6d1bcffb0 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:28 +0530 Subject: ASoC: samsung: s3c2412: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/samsung/s3c2412-i2s.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c index 0a47182..bcd1cbd 100644 --- a/sound/soc/samsung/s3c2412-i2s.c +++ b/sound/soc/samsung/s3c2412-i2s.c @@ -71,7 +71,9 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai) /* Set MPLL as the source for IIS CLK */ clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); - clk_prepare_enable(s3c2412_i2s.iis_cclk); + ret = clk_prepare_enable(s3c2412_i2s.iis_cclk); + if (ret) + return ret; s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk; -- cgit v1.1 From 8698475a94d0b7eb21efaa346d507dc4932f2032 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:29 +0530 Subject: ASoC: samsung: s3c24xx: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/s3c24xx-i2s.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c index 91e6871..8d58d02 100644 --- a/sound/soc/samsung/s3c24xx-i2s.c +++ b/sound/soc/samsung/s3c24xx-i2s.c @@ -340,6 +340,7 @@ EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate); static int s3c24xx_i2s_probe(struct snd_soc_dai *dai) { + int ret; snd_soc_dai_init_dma_data(dai, &s3c24xx_i2s_pcm_stereo_out, &s3c24xx_i2s_pcm_stereo_in); @@ -348,7 +349,9 @@ static int s3c24xx_i2s_probe(struct snd_soc_dai *dai) pr_err("failed to get iis_clock\n"); return PTR_ERR(s3c24xx_i2s.iis_clk); } - clk_prepare_enable(s3c24xx_i2s.iis_clk); + ret = clk_prepare_enable(s3c24xx_i2s.iis_clk); + if (ret) + return ret; /* Configure the I2S pins (GPE0...GPE4) in correct mode */ s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2), @@ -377,7 +380,11 @@ static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) { - clk_prepare_enable(s3c24xx_i2s.iis_clk); + int ret; + + ret = clk_prepare_enable(s3c24xx_i2s.iis_clk); + if (ret) + return ret; writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); writel(s3c24xx_i2s.iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); -- cgit v1.1 From a7ad9a88300c813a945793e9dae84ceaf7809141 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:30 +0530 Subject: ASoC: samsung: pcm: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/pcm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index d50a637..37f95ee 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c @@ -522,7 +522,9 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get audio-bus clock\n"); return PTR_ERR(pcm->cclk); } - clk_prepare_enable(pcm->cclk); + ret = clk_prepare_enable(pcm->cclk); + if (ret) + return ret; /* record our pcm structure for later use in the callbacks */ dev_set_drvdata(&pdev->dev, pcm); @@ -533,7 +535,9 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) ret = PTR_ERR(pcm->pclk); goto err_dis_cclk; } - clk_prepare_enable(pcm->pclk); + ret = clk_prepare_enable(pcm->pclk); + if (ret) + goto err_dis_cclk; s3c_pcm_stereo_in[pdev->id].addr = mem_res->start + S3C_PCM_RXFIFO; s3c_pcm_stereo_out[pdev->id].addr = mem_res->start + S3C_PCM_TXFIFO; -- cgit v1.1 From f5c97c7b0438bec0aad9738af1baa698dae5bc09 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:31 +0530 Subject: ASoC: samsung: i2s: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index c9f87f7..daf7b89 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -551,7 +551,9 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, goto err; } - clk_prepare_enable(i2s->op_clk); + ret = clk_prepare_enable(i2s->op_clk); + if (ret) + goto err; i2s->rclk_srcrate = clk_get_rate(i2s->op_clk); /* Over-ride the other's */ @@ -1133,10 +1135,19 @@ static int i2s_runtime_suspend(struct device *dev) static int i2s_runtime_resume(struct device *dev) { struct i2s_dai *i2s = dev_get_drvdata(dev); + int ret; - clk_prepare_enable(i2s->clk); - if (i2s->op_clk) - clk_prepare_enable(i2s->op_clk); + ret = clk_prepare_enable(i2s->clk); + if (ret) + return ret; + + if (i2s->op_clk) { + ret = clk_prepare_enable(i2s->op_clk); + if (ret) { + clk_disable_unprepare(i2s->clk); + return ret; + } + } writel(i2s->suspend_i2scon, i2s->addr + I2SCON); writel(i2s->suspend_i2smod, i2s->addr + I2SMOD); -- cgit v1.1 From 0f11daf10b4ac6a6c8ea6b39552f119c595b5406 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:32 +0530 Subject: ASoC: samsung: spdif: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/spdif.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c index 779504f..cb59911 100644 --- a/sound/soc/samsung/spdif.c +++ b/sound/soc/samsung/spdif.c @@ -391,7 +391,9 @@ static int spdif_probe(struct platform_device *pdev) ret = -ENOENT; goto err0; } - clk_prepare_enable(spdif->pclk); + ret = clk_prepare_enable(spdif->pclk); + if (ret) + goto err0; spdif->sclk = devm_clk_get(&pdev->dev, "sclk_spdif"); if (IS_ERR(spdif->sclk)) { @@ -399,7 +401,9 @@ static int spdif_probe(struct platform_device *pdev) ret = -ENOENT; goto err1; } - clk_prepare_enable(spdif->sclk); + ret = clk_prepare_enable(spdif->sclk); + if (ret) + goto err1; /* Request S/PDIF Register's memory region */ if (!request_mem_region(mem_res->start, -- cgit v1.1 From 0d97ee867958a092f02e9cd7c865c278bcec18a6 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:33 +0530 Subject: ASoC: mxs-saif: Handle return value of clk_prepare_enable/clk_prepare. clk_prepare_enable() and clk_prepare() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/mxs/mxs-saif.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index b42f301..156aa7c 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c @@ -125,7 +125,9 @@ static int mxs_saif_set_clk(struct mxs_saif *saif, * * If MCLK is not used, we just set saif clk to 512*fs. */ - clk_prepare_enable(master_saif->clk); + ret = clk_prepare_enable(master_saif->clk); + if (ret) + return ret; if (master_saif->mclk_in_use) { switch (mclk / rate) { @@ -388,6 +390,7 @@ static int mxs_saif_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); + int ret; /* clear error status to 0 for each re-open */ saif->fifo_underrun = 0; @@ -401,7 +404,9 @@ static int mxs_saif_startup(struct snd_pcm_substream *substream, __raw_writel(BM_SAIF_CTRL_CLKGATE, saif->base + SAIF_CTRL + MXS_CLR_ADDR); - clk_prepare(saif->clk); + ret = clk_prepare(saif->clk); + if (ret) + return ret; return 0; } @@ -468,7 +473,9 @@ static int mxs_saif_hw_params(struct snd_pcm_substream *substream, if (ret) return ret; - clk_prepare(master_saif->clk); + ret = clk_prepare(master_saif->clk); + if (ret) + return ret; } scr = __raw_readl(saif->base + SAIF_CTRL); -- cgit v1.1 From eae37345c8653a3c797c1763c95289d924ee37a2 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:44:34 +0530 Subject: ASoC: jz4740: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/jz4740/jz4740-i2s.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/jz4740/jz4740-i2s.c b/sound/soc/jz4740/jz4740-i2s.c index 794a349..99394c0 100644 --- a/sound/soc/jz4740/jz4740-i2s.c +++ b/sound/soc/jz4740/jz4740-i2s.c @@ -133,6 +133,7 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream, { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); uint32_t conf, ctrl; + int ret; if (dai->active) return 0; @@ -141,7 +142,9 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream, ctrl |= JZ_AIC_CTRL_FLUSH; jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); - clk_prepare_enable(i2s->clk_i2s); + ret = clk_prepare_enable(i2s->clk_i2s); + if (ret) + return ret; conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); conf |= JZ_AIC_CONF_ENABLE; @@ -352,11 +355,18 @@ static int jz4740_i2s_resume(struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); uint32_t conf; + int ret; - clk_prepare_enable(i2s->clk_aic); + ret = clk_prepare_enable(i2s->clk_aic); + if (ret) + return ret; if (dai->active) { - clk_prepare_enable(i2s->clk_i2s); + ret = clk_prepare_enable(i2s->clk_i2s); + if (ret) { + clk_disable_unprepare(i2s->clk_aic); + return ret; + } conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); conf |= JZ_AIC_CONF_ENABLE; @@ -387,8 +397,11 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) { struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); uint32_t conf; + int ret; - clk_prepare_enable(i2s->clk_aic); + ret = clk_prepare_enable(i2s->clk_aic); + if (ret) + return ret; jz4740_i2c_init_pcm_config(i2s); snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, -- cgit v1.1 From 3643e9172649f97f2e6301582890202abcc0f97e Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:45:18 +0530 Subject: ASoC: sun4i-spdif: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-spdif.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c index c49f375..b4af4aa 100644 --- a/sound/soc/sunxi/sun4i-spdif.c +++ b/sound/soc/sunxi/sun4i-spdif.c @@ -458,11 +458,16 @@ static int sun4i_spdif_runtime_suspend(struct device *dev) static int sun4i_spdif_runtime_resume(struct device *dev) { struct sun4i_spdif_dev *host = dev_get_drvdata(dev); + int ret; - clk_prepare_enable(host->spdif_clk); - clk_prepare_enable(host->apb_clk); + ret = clk_prepare_enable(host->spdif_clk); + if (ret) + return ret; + ret = clk_prepare_enable(host->apb_clk); + if (ret) + clk_disable_unprepare(host->spdif_clk); - return 0; + return ret; } static int sun4i_spdif_probe(struct platform_device *pdev) -- cgit v1.1 From 260ea95cc027500ee5086e2ef568b8c915e66fb5 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 25 Jul 2017 15:45:37 +0530 Subject: ASoC: atmel: ac97c: Handle return value of clk_prepare_enable. clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/atmel/ac97c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 9d2c9d9..52b0522 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -783,7 +783,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "no peripheral clock\n"); return PTR_ERR(pclk); } - clk_prepare_enable(pclk); + retval = clk_prepare_enable(pclk); + if (retval) + return retval; retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, THIS_MODULE, @@ -897,9 +899,9 @@ static int atmel_ac97c_resume(struct device *pdev) { struct snd_card *card = dev_get_drvdata(pdev); struct atmel_ac97c *chip = card->private_data; + int ret = clk_prepare_enable(chip->pclk); - clk_prepare_enable(chip->pclk); - return 0; + return ret; } static SIMPLE_DEV_PM_OPS(atmel_ac97c_pm, atmel_ac97c_suspend, atmel_ac97c_resume); -- cgit v1.1 From 82444cdb4673c146d43f3f5ff3baf582d4f4cb41 Mon Sep 17 00:00:00 2001 From: Pradeep Tewani Date: Tue, 25 Jul 2017 11:59:46 +0530 Subject: ASoC: Intel: board: Fix missing sentinel for bxt_board_id Without a sentinel in the array of platform devices, we can get a panic so add a sentinel. Full stack dump below: [ 231.564705] BUG: KASAN: global-out-of-bounds in platform_match+0xb0/0x146 [ 231.565500] Read of size 1 at addr ffffffff8380a1a0 by task swapper/0/1 [ 231.566280] [ 231.566594] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-00289-g152771f #1 [ 231.567526] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.3-20161025_171302-gandalf 04/01/2014 [ 231.568730] Call Trace: [ 231.569128] dump_stack+0xf8/0x14a [ 231.569615] print_address_description+0x57/0x1e4 [ 231.570216] ? driver_probe_device+0x814/0x814 [ 231.570798] kasan_report+0x1cb/0x1eb [ 231.571302] ? platform_match+0xb0/0x146 [ 231.571833] __asan_load1+0x45/0x47 [ 231.572324] platform_match+0xb0/0x146 [ 231.572843] ? platform_uevent+0x73/0x73 [ 231.573370] __driver_attach+0x47/0x16a [ 231.573890] bus_for_each_dev+0x11a/0x15c [ 231.574422] ? bus_remove_file+0x57/0x57 [ 231.574951] ? do_raw_spin_unlock+0xc3/0xe0 [ 231.575501] driver_attach+0x2b/0x2e [ 231.576002] bus_add_driver+0x25e/0x3c5 [ 231.576520] ? set_debug_rodata+0x20/0x20 [ 231.584776] driver_register+0x13e/0x19d [ 231.585305] __platform_driver_register+0x6c/0x71 [ 231.585908] ? skl_driver_init+0x20/0x20 [ 231.586436] broxton_audio_init+0x17/0x19 [ 231.586976] do_one_initcall+0x11a/0x221 [ 231.587499] ? start_kernel+0x525/0x525 [ 231.588020] ? lock_downgrade+0x281/0x2ec [ 231.588557] ? trace_hardirqs_on_caller+0x223/0x267 [ 231.589169] ? _raw_spin_unlock_irqrestore+0x49/0x55 [ 231.589791] ? set_debug_rodata+0x20/0x20 [ 231.590324] kernel_init_freeable+0x1fd/0x2b0 [ 231.590891] ? rest_init+0x17c/0x17c [ 231.591384] kernel_init+0x11/0x157 [ 231.591876] ? rest_init+0x17c/0x17c [ 231.592371] ret_from_fork+0x2a/0x40 [ 231.592865] [ 231.593166] The buggy address belongs to the variable: [ 231.593806] bxt_board_ids+0x40/0x9e0 Fixes: 152771fbc3 ("ASoC: Intel: board: Add Geminilake platform support") Reported-by: kbuild test robot Signed-off-by: Pradeep Tewani Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_rt298.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index a4b5bcb..7843104 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -595,6 +595,7 @@ static const struct platform_device_id bxt_board_ids[] = { (unsigned long)&broxton_rt298 }, { .name = "glk_alc298s_i2s", .driver_data = (unsigned long)&geminilake_rt298 }, + {} }; static struct platform_driver broxton_audio = { -- cgit v1.1 From ea746a296df3670359ae7d43baa968b0a1a54a01 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 26 Jul 2017 20:00:19 +0800 Subject: ASoC: rt5670: merge ADC L/R Mux Some ADC L/R Muxes share the some control bit. So, merge them. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 174141f..0f4e5bc 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -1151,20 +1151,15 @@ static const char * const rt5670_stereo_adc1_src[] = { static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc1_enum, RT5670_STO1_ADC_MIXER, RT5670_ADC_1_SRC_SFT, rt5670_stereo_adc1_src); -static const struct snd_kcontrol_new rt5670_sto_adc_l1_mux = - SOC_DAPM_ENUM("Stereo1 ADC L1 source", rt5670_stereo1_adc1_enum); - -static const struct snd_kcontrol_new rt5670_sto_adc_r1_mux = - SOC_DAPM_ENUM("Stereo1 ADC R1 source", rt5670_stereo1_adc1_enum); +static const struct snd_kcontrol_new rt5670_sto_adc_1_mux = + SOC_DAPM_ENUM("Stereo1 ADC 1 Mux", rt5670_stereo1_adc1_enum); static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc1_enum, RT5670_STO2_ADC_MIXER, RT5670_ADC_1_SRC_SFT, rt5670_stereo_adc1_src); -static const struct snd_kcontrol_new rt5670_sto2_adc_l1_mux = - SOC_DAPM_ENUM("Stereo2 ADC L1 source", rt5670_stereo2_adc1_enum); +static const struct snd_kcontrol_new rt5670_sto2_adc_1_mux = + SOC_DAPM_ENUM("Stereo2 ADC 1 Mux", rt5670_stereo2_adc1_enum); -static const struct snd_kcontrol_new rt5670_sto2_adc_r1_mux = - SOC_DAPM_ENUM("Stereo2 ADC R1 source", rt5670_stereo2_adc1_enum); /* MX-27 MX-26 [11] */ static const char * const rt5670_stereo_adc2_src[] = { @@ -1174,20 +1169,15 @@ static const char * const rt5670_stereo_adc2_src[] = { static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc2_enum, RT5670_STO1_ADC_MIXER, RT5670_ADC_2_SRC_SFT, rt5670_stereo_adc2_src); -static const struct snd_kcontrol_new rt5670_sto_adc_l2_mux = - SOC_DAPM_ENUM("Stereo1 ADC L2 source", rt5670_stereo1_adc2_enum); - -static const struct snd_kcontrol_new rt5670_sto_adc_r2_mux = - SOC_DAPM_ENUM("Stereo1 ADC R2 source", rt5670_stereo1_adc2_enum); +static const struct snd_kcontrol_new rt5670_sto_adc_2_mux = + SOC_DAPM_ENUM("Stereo1 ADC 2 Mux", rt5670_stereo1_adc2_enum); static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc2_enum, RT5670_STO2_ADC_MIXER, RT5670_ADC_2_SRC_SFT, rt5670_stereo_adc2_src); -static const struct snd_kcontrol_new rt5670_sto2_adc_l2_mux = - SOC_DAPM_ENUM("Stereo2 ADC L2 source", rt5670_stereo2_adc2_enum); +static const struct snd_kcontrol_new rt5670_sto2_adc_2_mux = + SOC_DAPM_ENUM("Stereo2 ADC 2 Mux", rt5670_stereo2_adc2_enum); -static const struct snd_kcontrol_new rt5670_sto2_adc_r2_mux = - SOC_DAPM_ENUM("Stereo2 ADC R2 source", rt5670_stereo2_adc2_enum); /* MX-27 MX26 [10] */ static const char * const rt5670_stereo_adc_src[] = { @@ -1642,23 +1632,23 @@ static const struct snd_soc_dapm_widget rt5670_dapm_widgets[] = { SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0, &rt5670_sto1_dmic_mux), SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto_adc_l2_mux), + &rt5670_sto_adc_2_mux), SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto_adc_r2_mux), + &rt5670_sto_adc_2_mux), SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto_adc_l1_mux), + &rt5670_sto_adc_1_mux), SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto_adc_r1_mux), + &rt5670_sto_adc_1_mux), SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0, &rt5670_sto2_dmic_mux), SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto2_adc_l2_mux), + &rt5670_sto2_adc_2_mux), SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto2_adc_r2_mux), + &rt5670_sto2_adc_2_mux), SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto2_adc_l1_mux), + &rt5670_sto2_adc_1_mux), SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM, 0, 0, - &rt5670_sto2_adc_r1_mux), + &rt5670_sto2_adc_1_mux), SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0, &rt5670_sto2_adc_lr_mux), SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0, -- cgit v1.1 From 776bac64bf13e20c27f7ad168811abdf3b72f14d Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 27 Jul 2017 19:13:36 +0200 Subject: ASoC: samsung: Fix possible double iounmap on s3c24xx driver probe failure Commit 87b132bc0315 ("ASoC: samsung: s3c24{xx,12}-i2s: port to use generic dmaengine API") moved ioremap() call from s3c-i2s-v2.c:s3c_i2sv2_probe() to s3c2412-i2s.c:s3c2412_iis_dev_probe() and converted it to devm- resource managed interface. However the error path in first of them - s3c_i2sv2_probe() - was not updated. If getting a iis clock in s3c_i2sv2_probe() failed, the address space would be unmapped there. This could lead to: 1. double iounmap() later from devm-interface of s3c2412_iis_dev_probe()), 2. accessing the memory by other functions in s3c2412-i2s.c unit. Anyway, the owner of this mapped region should be s3c2412-i2s.c because it starts the mapping. Affected are drivers for S3C24xx family although issue was not reproduced. Fixes: 87b132bc0315 ("ASoC: samsung: s3c24{xx,12}-i2s: port to use generic dmaengine API") Signed-off-by: Krzysztof Kozlowski Acked-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/samsung/s3c-i2s-v2.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index ca522a9..9b28046 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c @@ -634,7 +634,6 @@ int s3c_i2sv2_probe(struct snd_soc_dai *dai, i2s->iis_pclk = clk_get(dev, "iis"); if (IS_ERR(i2s->iis_pclk)) { dev_err(dev, "failed to get iis_clock\n"); - iounmap(i2s->regs); return -ENOENT; } -- cgit v1.1 From 81ea6cc73c384e4093519e0c75394aa2a1941a10 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 27 Jul 2017 19:13:37 +0200 Subject: ASoC: samsung: Add missing prepare for iis clock of s3c24xx The s3c_i2sv2_probe() only enabled iis clock. Missing prepare isn't probably fatal, because for SoC clocks this is usually no-op, but for correctness this clock should be prepared. Signed-off-by: Krzysztof Kozlowski Acked-by: Arvind Yadav --- sound/soc/samsung/s3c-i2s-v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index 9b28046..3894bda 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c @@ -637,7 +637,7 @@ int s3c_i2sv2_probe(struct snd_soc_dai *dai, return -ENOENT; } - clk_enable(i2s->iis_pclk); + clk_prepare_enable(i2s->iis_pclk); /* Mark ourselves as in TXRX mode so we can run through our cleanup * process without warnings. */ -- cgit v1.1 From 6f187f7ef1c15dca9f720b18a7e928718fd1a8b3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 27 Jul 2017 19:13:38 +0200 Subject: ASoC: samsung: Add proper error paths to s3c24xx I2S driver s3c2412_i2s_probe() might fail so driver has to revert work done by s3c_i2sv2_probe() (clock enabling). Missing doing this would lead to clock enable in-balance. Signed-off-by: Krzysztof Kozlowski Acked-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/samsung/s3c-i2s-v2.c | 9 +++++++++ sound/soc/samsung/s3c-i2s-v2.h | 7 +++++++ sound/soc/samsung/s3c2412-i2s.c | 13 +++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index 3894bda..58c3e9b 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c @@ -651,6 +651,15 @@ int s3c_i2sv2_probe(struct snd_soc_dai *dai, } EXPORT_SYMBOL_GPL(s3c_i2sv2_probe); +void s3c_i2sv2_cleanup(struct snd_soc_dai *dai, + struct s3c_i2sv2_info *i2s) +{ + clk_disable_unprepare(i2s->iis_pclk); + clk_put(i2s->iis_pclk); + i2s->iis_pclk = NULL; +} +EXPORT_SYMBOL_GPL(s3c_i2sv2_cleanup); + #ifdef CONFIG_PM static int s3c2412_i2s_suspend(struct snd_soc_dai *dai) { diff --git a/sound/soc/samsung/s3c-i2s-v2.h b/sound/soc/samsung/s3c-i2s-v2.h index 182d805..3fca20f 100644 --- a/sound/soc/samsung/s3c-i2s-v2.h +++ b/sound/soc/samsung/s3c-i2s-v2.h @@ -92,6 +92,13 @@ extern int s3c_i2sv2_probe(struct snd_soc_dai *dai, unsigned long base); /** + * s3c_i2sv2_cleanup - cleanup resources allocated in s3c_i2sv2_probe + * @dai: The ASoC DAI structure supplied to the original probe. + * @i2s: Our local i2s structure to fill in. + */ +extern void s3c_i2sv2_cleanup(struct snd_soc_dai *dai, + struct s3c_i2sv2_info *i2s); +/** * s3c_i2sv2_register_component - register component and dai with soc core * @dev: DAI device * @id: DAI ID diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c index bcd1cbd..cc0840f 100644 --- a/sound/soc/samsung/s3c2412-i2s.c +++ b/sound/soc/samsung/s3c2412-i2s.c @@ -65,7 +65,8 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai) s3c2412_i2s.iis_cclk = devm_clk_get(dai->dev, "i2sclk"); if (IS_ERR(s3c2412_i2s.iis_cclk)) { pr_err("failed to get i2sclk clock\n"); - return PTR_ERR(s3c2412_i2s.iis_cclk); + ret = PTR_ERR(s3c2412_i2s.iis_cclk); + goto err; } /* Set MPLL as the source for IIS CLK */ @@ -73,20 +74,24 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai) clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); ret = clk_prepare_enable(s3c2412_i2s.iis_cclk); if (ret) - return ret; - - s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk; + goto err; /* Configure the I2S pins (GPE0...GPE4) in correct mode */ s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2), S3C_GPIO_PULL_NONE); return 0; + +err: + s3c_i2sv2_cleanup(dai, &s3c2412_i2s); + + return ret; } static int s3c2412_i2s_remove(struct snd_soc_dai *dai) { clk_disable_unprepare(s3c2412_i2s.iis_cclk); + s3c_i2sv2_cleanup(dai, &s3c2412_i2s); return 0; } -- cgit v1.1 From 3c9736aa1ab59e64ebc33b140b000f90c8f9de46 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 27 Jul 2017 01:32:06 +0000 Subject: ASoC: rsnd: merge snd_pcm_ops::open and snd_soc_dai_ops::startup Current rsnd driver has snd_pcm_ops::open and snd_soc_dai_ops::startup, but, these are called from soc_pcm_open in same time. This patch merge these into rsnd_soc_dai_startup() Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 80 +++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 49 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index acafb83..c345623 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -844,12 +844,28 @@ static int rsnd_soc_hw_rule_channels(struct snd_pcm_hw_params *params, ir, &ic); } -static void rsnd_soc_hw_constraint(struct snd_pcm_runtime *runtime, - struct snd_soc_dai *dai) +static struct snd_pcm_hardware rsnd_pcm_hardware = { + .info = SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID, + .buffer_bytes_max = 64 * 1024, + .period_bytes_min = 32, + .period_bytes_max = 8192, + .periods_min = 1, + .periods_max = 32, + .fifo_size = 256, +}; + +static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) { struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); + struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); + struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); struct snd_pcm_hw_constraint_list *constraint = &rdai->constraint; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int max_channels = rsnd_rdai_channels_get(rdai); + int ret; int i; /* @@ -866,34 +882,26 @@ static void rsnd_soc_hw_constraint(struct snd_pcm_runtime *runtime, constraint->count = i + 1; } + snd_soc_set_runtime_hwparams(substream, &rsnd_pcm_hardware); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, constraint); + snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + /* * Sampling Rate / Channel Limitation * It depends on Clock Master Mode */ - if (!rsnd_rdai_is_clk_master(rdai)) - return; - - snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - rsnd_soc_hw_rule_rate, dai, - SNDRV_PCM_HW_PARAM_CHANNELS, -1); - snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, - rsnd_soc_hw_rule_channels, dai, - SNDRV_PCM_HW_PARAM_RATE, -1); -} - -static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); - struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); - struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); - int ret; - - /* rsnd_io_to_runtime() is not yet enabled here */ - rsnd_soc_hw_constraint(substream->runtime, dai); + if (rsnd_rdai_is_clk_master(rdai)) { + snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + rsnd_soc_hw_rule_rate, dai, + SNDRV_PCM_HW_PARAM_CHANNELS, -1); + snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + rsnd_soc_hw_rule_channels, dai, + SNDRV_PCM_HW_PARAM_RATE, -1); + } /* * call rsnd_dai_call without spinlock @@ -1105,31 +1113,6 @@ static int rsnd_dai_probe(struct rsnd_priv *priv) /* * pcm ops */ -static struct snd_pcm_hardware rsnd_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID, - .buffer_bytes_max = 64 * 1024, - .period_bytes_min = 32, - .period_bytes_max = 8192, - .periods_min = 1, - .periods_max = 32, - .fifo_size = 256, -}; - -static int rsnd_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int ret = 0; - - snd_soc_set_runtime_hwparams(substream, &rsnd_pcm_hardware); - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - - return ret; -} - static int rsnd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { @@ -1159,7 +1142,6 @@ static snd_pcm_uframes_t rsnd_pointer(struct snd_pcm_substream *substream) } static struct snd_pcm_ops rsnd_pcm_ops = { - .open = rsnd_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = rsnd_hw_params, .hw_free = snd_pcm_lib_free_pages, -- cgit v1.1 From 007b6a54c305688d1db7255e5c724e3d76ba5aa4 Mon Sep 17 00:00:00 2001 From: Mihai Serban Date: Thu, 27 Jul 2017 17:55:10 +0300 Subject: ASoC: codecs: add wm8524 codec driver WM8524 is a 24-bit 192KHz stereo digital/analog converter (DAC) with integral charge pump and a simple hardware control interface. Product information can be found at: https://www.cirrus.com/products/wm8524/ Signed-off-by: Mihai Serban Signed-off-by: Shengjiu Wang Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/wm8524.c | 265 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 272 insertions(+) create mode 100644 sound/soc/codecs/wm8524.c (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 6c78b0b..c3d8aef 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -173,6 +173,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_WM8400 if MFD_WM8400 select SND_SOC_WM8510 if SND_SOC_I2C_AND_SPI select SND_SOC_WM8523 if I2C + select SND_SOC_WM8524 if GPIOLIB select SND_SOC_WM8580 if I2C select SND_SOC_WM8711 if SND_SOC_I2C_AND_SPI select SND_SOC_WM8727 @@ -967,6 +968,10 @@ config SND_SOC_WM8523 tristate "Wolfson Microelectronics WM8523 DAC" depends on I2C +config SND_SOC_WM8524 + tristate "Wolfson Microelectronics WM8524 DAC" + depends on GPIOLIB + config SND_SOC_WM8580 tristate "Wolfson Microelectronics WM8580 and WM8581 CODECs" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1755a54..66a8567 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -182,6 +182,7 @@ snd-soc-wm8350-objs := wm8350.o snd-soc-wm8400-objs := wm8400.o snd-soc-wm8510-objs := wm8510.o snd-soc-wm8523-objs := wm8523.o +snd-soc-wm8524-objs := wm8524.o snd-soc-wm8580-objs := wm8580.o snd-soc-wm8711-objs := wm8711.o snd-soc-wm8727-objs := wm8727.o @@ -414,6 +415,7 @@ obj-$(CONFIG_SND_SOC_WM8350) += snd-soc-wm8350.o obj-$(CONFIG_SND_SOC_WM8400) += snd-soc-wm8400.o obj-$(CONFIG_SND_SOC_WM8510) += snd-soc-wm8510.o obj-$(CONFIG_SND_SOC_WM8523) += snd-soc-wm8523.o +obj-$(CONFIG_SND_SOC_WM8524) += snd-soc-wm8524.o obj-$(CONFIG_SND_SOC_WM8580) += snd-soc-wm8580.o obj-$(CONFIG_SND_SOC_WM8711) += snd-soc-wm8711.o obj-$(CONFIG_SND_SOC_WM8727) += snd-soc-wm8727.o diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c new file mode 100644 index 0000000..f42ec66 --- /dev/null +++ b/sound/soc/codecs/wm8524.c @@ -0,0 +1,265 @@ +/* + * wm8524.c -- WM8524 ALSA SoC Audio driver + * + * Copyright 2009 Wolfson Microelectronics plc + * Copyright 2017 NXP + * + * Based on WM8523 ALSA SoC Audio driver written by Mark Brown + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WM8524_NUM_RATES 7 + +/* codec private data */ +struct wm8524_priv { + struct gpio_desc *mute; + unsigned int sysclk; + unsigned int rate_constraint_list[WM8524_NUM_RATES]; + struct snd_pcm_hw_constraint_list rate_constraint; +}; + + +static const struct snd_soc_dapm_widget wm8524_dapm_widgets[] = { +SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0), +SND_SOC_DAPM_OUTPUT("LINEVOUTL"), +SND_SOC_DAPM_OUTPUT("LINEVOUTR"), +}; + +static const struct snd_soc_dapm_route wm8524_dapm_routes[] = { + { "LINEVOUTL", NULL, "DAC" }, + { "LINEVOUTR", NULL, "DAC" }, +}; + +static const struct { + int value; + int ratio; +} lrclk_ratios[WM8524_NUM_RATES] = { + { 1, 128 }, + { 2, 192 }, + { 3, 256 }, + { 4, 384 }, + { 5, 512 }, + { 6, 768 }, + { 7, 1152 }, +}; + +static int wm8524_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + + /* The set of sample rates that can be supported depends on the + * MCLK supplied to the CODEC - enforce this. + */ + if (!wm8524->sysclk) { + dev_err(codec->dev, + "No MCLK configured, call set_sysclk() on init\n"); + return -EINVAL; + } + + snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &wm8524->rate_constraint); + + gpiod_set_value_cansleep(wm8524->mute, 1); + + return 0; +} + +static void wm8524_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + + gpiod_set_value_cansleep(wm8524->mute, 0); +} + +static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + unsigned int val; + int i, j = 0; + + wm8524->sysclk = freq; + + wm8524->rate_constraint.count = 0; + for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) { + val = freq / lrclk_ratios[i].ratio; + /* Check that it's a standard rate since core can't + * cope with others and having the odd rates confuses + * constraint matching. + */ + switch (val) { + case 8000: + case 32000: + case 44100: + case 48000: + case 88200: + case 96000: + case 176400: + case 192000: + dev_err(codec->dev, "Supported sample rate: %dHz\n", + val); + wm8524->rate_constraint_list[j++] = val; + wm8524->rate_constraint.count++; + break; + default: + dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", + val); + } + } + + /* Need at least one supported rate... */ + if (wm8524->rate_constraint.count == 0) + return -EINVAL; + + return 0; +} + +static int wm8524_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) +{ + fmt &= (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK | + SND_SOC_DAIFMT_MASTER_MASK); + + if (fmt != (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS)) { + dev_err(codec_dai->dev, "Invalid DAI format\n"); + return -EINVAL; + } + + return 0; +} + +static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream) +{ + struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(dai->codec); + + if (wm8524->mute) + gpiod_set_value_cansleep(wm8524->mute, mute); + + return 0; +} + +#define WM8524_RATES SNDRV_PCM_RATE_8000_192000 + +#define WM8524_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) + +static const struct snd_soc_dai_ops wm8524_dai_ops = { + .startup = wm8524_startup, + .shutdown = wm8524_shutdown, + .set_sysclk = wm8524_set_dai_sysclk, + .set_fmt = wm8524_set_fmt, + .mute_stream = wm8524_mute_stream, +}; + +static struct snd_soc_dai_driver wm8524_dai = { + .name = "wm8524-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = WM8524_RATES, + .formats = WM8524_FORMATS, + }, + .ops = &wm8524_dai_ops, +}; + +static int wm8524_probe(struct snd_soc_codec *codec) +{ + struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + + wm8524->rate_constraint.list = &wm8524->rate_constraint_list[0]; + wm8524->rate_constraint.count = + ARRAY_SIZE(wm8524->rate_constraint_list); + + return 0; +} + +static const struct snd_soc_codec_driver soc_codec_dev_wm8524 = { + .probe = wm8524_probe, + + .component_driver = { + .dapm_widgets = wm8524_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8524_dapm_widgets), + .dapm_routes = wm8524_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8524_dapm_routes), + }, +}; + +#ifdef CONFIG_OF +static const struct of_device_id wm8524_of_match[] = { + { .compatible = "wlf,wm8524" }, + { /* sentinel*/ } +}; +MODULE_DEVICE_TABLE(of, wm8524_of_match); +#endif + +static int wm8524_codec_probe(struct platform_device *pdev) +{ + struct wm8524_priv *wm8524; + int ret; + + wm8524 = devm_kzalloc(&pdev->dev, sizeof(struct wm8524_priv), + GFP_KERNEL); + if (wm8524 == NULL) + return -ENOMEM; + + platform_set_drvdata(pdev, wm8524); + + wm8524->mute = devm_gpiod_get(&pdev->dev, "wlf,mute", GPIOD_OUT_LOW); + if (IS_ERR(wm8524->mute)) { + ret = PTR_ERR(wm8524->mute); + dev_err(&pdev->dev, "Failed to get mute line: %d\n", ret); + return ret; + } + + ret = snd_soc_register_codec(&pdev->dev, + &soc_codec_dev_wm8524, &wm8524_dai, 1); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + snd_soc_unregister_platform(&pdev->dev); + } + + return ret; +} + +static int wm8524_codec_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +static struct platform_driver wm8524_codec_driver = { + .probe = wm8524_codec_probe, + .remove = wm8524_codec_remove, + .driver = { + .name = "wm8524-codec", + .of_match_table = wm8524_of_match, + }, +}; +module_platform_driver(wm8524_codec_driver); + +MODULE_DESCRIPTION("ASoC WM8524 driver"); +MODULE_AUTHOR("Mihai Serban "); +MODULE_ALIAS("platform:wm8524-codec"); +MODULE_LICENSE("GPL"); -- cgit v1.1 From c06425705a2565e6747b0adba6027c7b0b04858f Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Thu, 27 Jul 2017 16:38:36 +0800 Subject: ASoC: Intel: Add Kabylake machine driver for RT5663 This patch adds Kabylake I2S machine driver which uses RT5663 as headset on ssp1. Signed-off-by: Kevin Cheng Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 246 +++++++++++++++++++++++---- 1 file changed, 209 insertions(+), 37 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index f9ba977..090331b 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -34,7 +34,7 @@ #define MAXIM_DEV0_NAME "i2c-MX98927:00" #define MAXIM_DEV1_NAME "i2c-MX98927:01" -static struct snd_soc_card kabylake_audio_card; +static struct snd_soc_card *kabylake_audio_card; static const struct snd_pcm_hw_constraint_list *dmic_constraints; static struct snd_soc_jack skylake_hdmi[3]; @@ -117,6 +117,49 @@ static const struct snd_soc_dapm_route kabylake_map[] = { { "iDisp1 Tx", NULL, "iDisp1_out"}, }; +enum { + KBL_DPCM_AUDIO_5663_PB = 0, + KBL_DPCM_AUDIO_5663_CP, + KBL_DPCM_AUDIO_5663_HDMI1_PB, + KBL_DPCM_AUDIO_5663_HDMI2_PB, +}; + +static const struct snd_kcontrol_new kabylake_5663_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), +}; + +static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("DP", NULL), + SND_SOC_DAPM_SPK("HDMI", NULL), +}; + +static const struct snd_soc_dapm_route kabylake_5663_map[] = { + { "Headphone Jack", NULL, "HPOL" }, + { "Headphone Jack", NULL, "HPOR" }, + + /* other jacks */ + { "IN1P", NULL, "Headset Mic" }, + { "IN1N", NULL, "Headset Mic" }, + + { "HDMI", NULL, "hif5 Output" }, + { "DP", NULL, "hif6 Output" }, + + /* CODEC BE connections */ + { "AIF Playback", NULL, "ssp1 Tx" }, + { "ssp1 Tx", NULL, "codec1_out" }, + + { "codec0_in", NULL, "ssp1 Rx" }, + { "ssp1 Rx", NULL, "AIF Capture" }, + + { "hifi2", NULL, "iDisp2 Tx"}, + { "iDisp2 Tx", NULL, "iDisp2_out"}, + { "hifi1", NULL, "iDisp1 Tx"}, + { "iDisp1 Tx", NULL, "iDisp1_out"}, +}; + static struct snd_soc_codec_conf max98927_codec_conf[] = { { .dev_name = MAXIM_DEV0_NAME, @@ -165,7 +208,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) * Headset buttons map to the google Reference headset. * These can be configured by userspace. */ - ret = snd_soc_card_jack_new(&kabylake_audio_card, "Headset Jack", + ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, &ctx->kabylake_headset, NULL, 0); @@ -173,8 +216,18 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) dev_err(rtd->dev, "Headset Jack creation failed %d\n", ret); return ret; } - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + return ret; +} + +static int kabylake_rt5663_max98927_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + int ret; + + ret = kabylake_rt5663_codec_init(rtd); + if (ret) + return ret; + ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); if (ret) { dev_err(rtd->dev, "SoC DMIC ignore suspend failed %d\n", ret); @@ -184,7 +237,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } -static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) +static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device) { struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *dai = rtd->codec_dai; @@ -194,7 +247,7 @@ static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) if (!pcm) return -ENOMEM; - pcm->device = KBL_DPCM_AUDIO_HDMI1_PB; + pcm->device = device; pcm->codec_dai = dai; list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); @@ -202,40 +255,29 @@ static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) { - struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_dai *dai = rtd->codec_dai; - struct kbl_hdmi_pcm *pcm; - - pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); - if (!pcm) - return -ENOMEM; - - pcm->device = KBL_DPCM_AUDIO_HDMI2_PB; - pcm->codec_dai = dai; - - list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB); +} - return 0; +static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB); } static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) { - struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_dai *dai = rtd->codec_dai; - struct kbl_hdmi_pcm *pcm; - - pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); - if (!pcm) - return -ENOMEM; - - pcm->device = KBL_DPCM_AUDIO_HDMI3_PB; - pcm->codec_dai = dai; + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB); +} - list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); +static int kabylake_5663_hdmi1_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI1_PB); +} - return 0; +static int kabylake_5663_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5663_HDMI2_PB); } static unsigned int rates[] = { @@ -538,7 +580,7 @@ static struct snd_soc_dai_link kabylake_dais[] = { .no_pcm = 1, .codec_name = "i2c-10EC5663:00", .codec_dai_name = KBL_REALTEK_CODEC_DAI, - .init = kabylake_rt5663_codec_init, + .init = kabylake_rt5663_max98927_codec_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ignore_pmdown_time = 1, @@ -594,6 +636,108 @@ static struct snd_soc_dai_link kabylake_dais[] = { }, }; +static struct snd_soc_dai_link kabylake_5663_dais[] = { + /* Front End DAI links */ + [KBL_DPCM_AUDIO_5663_PB] = { + .name = "Kbl Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .ops = &kabylake_rt5663_fe_ops, + }, + [KBL_DPCM_AUDIO_5663_CP] = { + .name = "Kbl Audio Capture Port", + .stream_name = "Audio Record", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_capture = 1, + .ops = &kabylake_rt5663_fe_ops, + }, + [KBL_DPCM_AUDIO_5663_HDMI1_PB] = { + .name = "Kbl HDMI Port1", + .stream_name = "Hdmi1", + .cpu_dai_name = "HDMI1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_5663_HDMI2_PB] = { + .name = "Kbl HDMI Port2", + .stream_name = "Hdmi2", + .cpu_dai_name = "HDMI2 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + + /* Back End DAI links */ + { + /* SSP1 - Codec */ + .name = "SSP1-Codec", + .id = 0, + .cpu_dai_name = "SSP1 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = "i2c-10EC5663:00", + .codec_dai_name = KBL_REALTEK_CODEC_DAI, + .init = kabylake_rt5663_codec_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .ops = &kabylake_rt5663_ops, + .dpcm_playback = 1, + .dpcm_capture = 1, + }, + { + .name = "iDisp1", + .id = 1, + .cpu_dai_name = "iDisp1 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi1", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = kabylake_5663_hdmi1_init, + .no_pcm = 1, + }, + { + .name = "iDisp2", + .id = 2, + .cpu_dai_name = "iDisp2 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi2", + .platform_name = "0000:00:1f.3", + .init = kabylake_5663_hdmi2_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, +}; + #define NAME_SIZE 32 static int kabylake_card_late_probe(struct snd_soc_card *card) { @@ -624,7 +768,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) } /* kabylake audio machine driver for SPT + RT5663 */ -static struct snd_soc_card kabylake_audio_card = { +static struct snd_soc_card kabylake_audio_card_rt5663_m98927 = { .name = "kblrt5663max", .owner = THIS_MODULE, .dai_link = kabylake_dais, @@ -641,6 +785,22 @@ static struct snd_soc_card kabylake_audio_card = { .late_probe = kabylake_card_late_probe, }; +/* kabylake audio machine driver for RT5663 */ +static struct snd_soc_card kabylake_audio_card_rt5663 = { + .name = "kblrt5663", + .owner = THIS_MODULE, + .dai_link = kabylake_5663_dais, + .num_links = ARRAY_SIZE(kabylake_5663_dais), + .controls = kabylake_5663_controls, + .num_controls = ARRAY_SIZE(kabylake_5663_controls), + .dapm_widgets = kabylake_5663_widgets, + .num_dapm_widgets = ARRAY_SIZE(kabylake_5663_widgets), + .dapm_routes = kabylake_5663_map, + .num_dapm_routes = ARRAY_SIZE(kabylake_5663_map), + .fully_routed = true, + .late_probe = kabylake_card_late_probe, +}; + static int kabylake_audio_probe(struct platform_device *pdev) { struct kbl_rt5663_private *ctx; @@ -652,19 +812,30 @@ static int kabylake_audio_probe(struct platform_device *pdev) INIT_LIST_HEAD(&ctx->hdmi_pcm_list); - kabylake_audio_card.dev = &pdev->dev; - snd_soc_card_set_drvdata(&kabylake_audio_card, ctx); + kabylake_audio_card = + (struct snd_soc_card *)pdev->id_entry->driver_data; + + kabylake_audio_card->dev = &pdev->dev; + snd_soc_card_set_drvdata(kabylake_audio_card, ctx); pdata = dev_get_drvdata(&pdev->dev); if (pdata) dmic_constraints = pdata->dmic_num == 2 ? &constraints_dmic_2ch : &constraints_dmic_channels; - return devm_snd_soc_register_card(&pdev->dev, &kabylake_audio_card); + return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card); } static const struct platform_device_id kbl_board_ids[] = { - { .name = "kbl_rt5663_m98927" }, + { + .name = "kbl_rt5663", + .driver_data = (kernel_ulong_t)&kabylake_audio_card_rt5663, + }, + { + .name = "kbl_rt5663_m98927", + .driver_data = + (kernel_ulong_t)&kabylake_audio_card_rt5663_m98927, + }, { } }; @@ -684,4 +855,5 @@ MODULE_DESCRIPTION("Audio Machine driver-RT5663 & MAX98927 in I2S mode"); MODULE_AUTHOR("Naveen M "); MODULE_AUTHOR("Harsha Priya "); MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:kbl_rt5663"); MODULE_ALIAS("platform:kbl_rt5663_m98927"); -- cgit v1.1 From 0dfa7a046aa9a3e3dcaee59bfc23598679fc4247 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Thu, 27 Jul 2017 16:38:37 +0800 Subject: ASoC: Intel: Add Kabylake RT5663 machine driver entry Adds Kabylake rt5663 machine driver entry into machine table Signed-off-by: Kevin Cheng Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 334917e..01a2dd6 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -981,6 +981,11 @@ static struct sst_acpi_mach sst_kbl_devdata[] = { .quirk_data = &kbl_poppy_codecs, .pdata = &skl_dmic_data }, + { + .id = "10EC5663", + .drv_name = "kbl_rt5663", + .fw_filename = "intel/dsp_fw_kbl.bin", + }, {} }; -- cgit v1.1 From cc4db0e257d6a5d5ae2e2f042ac8d261caaf08fc Mon Sep 17 00:00:00 2001 From: Harsha Priya N Date: Thu, 27 Jul 2017 17:41:27 -0700 Subject: ASoC: Intel: Enabling 4 slot IV feedback for max98927 on Kabylake platform This patch enables 4 slot IV feedback for max98927 speaker amp codec. Signed-off-by: Harsha Priya Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 3fe4a08..74bbc00 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -365,11 +365,18 @@ static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream, return ret; } } - if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME) || - !strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) { - ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xF0, 3, 8, 16); + if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) { + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x30, 3, 8, 16); if (ret < 0) { - dev_err(rtd->dev, "set TDM slot err:%d\n", ret); + dev_err(rtd->dev, "DEV0 TDM slot err:%d\n", ret); + return ret; + } + } + + if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) { + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC0, 3, 8, 16); + if (ret < 0) { + dev_err(rtd->dev, "DEV1 TDM slot err:%d\n", ret); return ret; } } -- cgit v1.1 From 77a4525bc282b7072ebda5d6f6925ca6d604a16f Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 26 Jul 2017 02:35:07 +0200 Subject: ASoC: jack: fix snd_soc_codec_set_jack return error This patch changes the error code returned by snd_soc_codec_set_jack() from -EINVAL to -ENOTSUPP. The reason to do this is to make the caller aware that the underlying codec does not support this callback. This can make the caller write the code to handle this case properly. Other reason is that -EINVAL is not the correct error to return in this case anyway. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/soc-jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 7daf21f..42ca9f1 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -36,7 +36,7 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec, if (codec->driver->set_jack) return codec->driver->set_jack(codec, jack, data); else - return -EINVAL; + return -ENOTSUPP; } EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack); -- cgit v1.1 From f1e3f409d61372b742697d0b5e5cd17d09de37db Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 29 Jul 2017 11:40:55 -0300 Subject: ASoC: soc-pcm: Remove unused 'debugfs_dpcm_state' entry 'debugfs_dpcm_state' member from structure snd_soc_pcm_runtime is never used at all, so it is safe to remove it. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index dcc5ece..2ddf6aa 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -3010,8 +3010,7 @@ void soc_dpcm_debugfs_add(struct snd_soc_pcm_runtime *rtd) return; } - rtd->debugfs_dpcm_state = debugfs_create_file("state", 0444, - rtd->debugfs_dpcm_root, - rtd, &dpcm_state_fops); + debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root, + rtd, &dpcm_state_fops); } #endif -- cgit v1.1 From bf11ecb7eebd28d70bf5aa3170c6fe7156c33c5b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 31 Jul 2017 18:05:46 +0200 Subject: ASoC: codecs: fix wm8524 build error When CONFIG_OF is disabled, we run into a build error: sound/soc/codecs/wm8524.c:257:21: error: 'wm8524_of_match' undeclared here (not in a function); did you mean 'wm8524_dai'? This removes the unnecessary #ifdef around the match table. Fixes: 007b6a54c305 ("ASoC: codecs: add wm8524 codec driver") Signed-off-by: Arnd Bergmann Acked-by: Mihai Serban Signed-off-by: Mark Brown --- sound/soc/codecs/wm8524.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c index f42ec66..e22b76d 100644 --- a/sound/soc/codecs/wm8524.c +++ b/sound/soc/codecs/wm8524.c @@ -206,13 +206,11 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm8524 = { }, }; -#ifdef CONFIG_OF static const struct of_device_id wm8524_of_match[] = { { .compatible = "wlf,wm8524" }, { /* sentinel*/ } }; MODULE_DEVICE_TABLE(of, wm8524_of_match); -#endif static int wm8524_codec_probe(struct platform_device *pdev) { -- cgit v1.1 From c1bbaff6d7dd55314ee453df8dfe00befd7ce1b2 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Tue, 1 Aug 2017 19:14:02 +0800 Subject: ASoC: rt5663: Add the delay time to correct the calibration The patch adds the delay time to correct the calibration. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index 45f8a98..c1f0a72c 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -3058,6 +3058,7 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) regmap_write(rt5663->regmap, RT5663_PWR_ANLG_3, 0x018c); regmap_write(rt5663->regmap, RT5663_HP_CHARGE_PUMP_1, 0x1e32); regmap_write(rt5663->regmap, RT5663_DACREF_LDO, 0x3b0b); + msleep(40); regmap_write(rt5663->regmap, RT5663_STO_DAC_MIXER, 0x0000); regmap_write(rt5663->regmap, RT5663_BYPASS_STO_DAC, 0x000c); regmap_write(rt5663->regmap, RT5663_HP_BIAS, 0xafaa); -- cgit v1.1 From 60767abcea3dd1d47a4bd38398e1e8c1864975eb Mon Sep 17 00:00:00 2001 From: "guneshwor.o.singh@intel.com" Date: Fri, 28 Jul 2017 16:12:13 +0530 Subject: ASoC: Intel: Skylake: Reset the controller in probe Controller can be in reset state by default. Capability structure traversal requires the controller to be out of reset else it results in broken capability parsing. Hence make sure that controller is out of reset before parsing capabilities by doing a full reset. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 01a2dd6..b9e1310 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -702,6 +702,8 @@ static int skl_first_init(struct hdac_ext_bus *ebus) return -ENXIO; } + skl_init_chip(bus, true); + snd_hdac_bus_parse_capabilities(bus); if (skl_acquire_irq(ebus, 0) < 0) -- cgit v1.1 From 3fbbcf4dadb6c01d6411bac715a7448f96c3724c Mon Sep 17 00:00:00 2001 From: Dronamraju Santosh P K Date: Fri, 28 Jul 2017 16:12:14 +0530 Subject: ASoC: Intel: bxtn: Remove code loader reference in cleanup Since Broxton does not use code loader DMA, remove code loader cleanup in its dsp cleanup routine. Remove the iounmap too as it is done in skl_free_dsp(). Signed-off-by: Dronamraju Santosh P K Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/bxt-sst.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c index cf11b84..08a2c5e 100644 --- a/sound/soc/intel/skylake/bxt-sst.c +++ b/sound/soc/intel/skylake/bxt-sst.c @@ -629,11 +629,6 @@ void bxt_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) release_firmware(ctx->dsp->fw); skl_freeup_uuid_list(ctx); skl_ipc_free(&ctx->ipc); - ctx->dsp->cl_dev.ops.cl_cleanup_controller(ctx->dsp); - - if (ctx->dsp->addr.lpe) - iounmap(ctx->dsp->addr.lpe); - ctx->dsp->ops->free(ctx->dsp); } EXPORT_SYMBOL_GPL(bxt_sst_dsp_cleanup); -- cgit v1.1 From 693c0fb26a312d7cc866b1e9195187789b69e7e6 Mon Sep 17 00:00:00 2001 From: "guneshwor.o.singh@intel.com" Date: Fri, 28 Jul 2017 16:12:15 +0530 Subject: ASoC: Intel: Skylake: Remove return check for skl_codec_create() Since skl_codec_create() always returns 0, make it return void and remove return check. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index b9e1310..ab65151 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -528,7 +528,7 @@ static int probe_codec(struct hdac_ext_bus *ebus, int addr) } /* Codec initialization */ -static int skl_codec_create(struct hdac_ext_bus *ebus) +static void skl_codec_create(struct hdac_ext_bus *ebus) { struct hdac_bus *bus = ebus_to_hbus(ebus); int c, max_slots; @@ -559,8 +559,6 @@ static int skl_codec_create(struct hdac_ext_bus *ebus) } } } - - return 0; } static const struct hdac_bus_ops bus_core_ops = { @@ -612,9 +610,7 @@ static void skl_probe_work(struct work_struct *work) dev_info(bus->dev, "no hda codecs found!\n"); /* create codec instances */ - err = skl_codec_create(ebus); - if (err < 0) - goto out_err; + skl_codec_create(ebus); if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { err = snd_hdac_display_power(bus, false); -- cgit v1.1 From 10a5439f0e4db0b1c4c2a2f6c916d6501cfeae50 Mon Sep 17 00:00:00 2001 From: "guneshwor.o.singh@intel.com" Date: Fri, 28 Jul 2017 16:12:16 +0530 Subject: ASoC: Intel: Skylake: Fix potential null pointer dereference Check if the next sink is not null to avoid potential null pointer dereference in skl_tplg_bind_sinks(). Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 68c3f12..8c3ce08 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -925,7 +925,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, } } - if (!sink) + if (!sink && next_sink) return skl_tplg_bind_sinks(next_sink, skl, src_w, src_mconfig); return 0; -- cgit v1.1 From 47bea0c836867b6b1cdb714d58f2bfc8e2f5c386 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 29 Jul 2017 16:17:42 +0200 Subject: ASoC: sun4i-i2s: Extend quirks scope In preparation for the changes required to support newer SoCs then quirks has been moved and also added to the device structure. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 62b307b..d7ee7a4 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -90,6 +90,15 @@ #define SUN4I_I2S_RX_CHAN_SEL_REG 0x38 #define SUN4I_I2S_RX_CHAN_MAP_REG 0x3c +/** + * struct sun4i_i2s_quirks - Differences between SoC variants. + * + * @has_reset: SoC needs reset deasserted. + */ +struct sun4i_i2s_quirks { + bool has_reset; +}; + struct sun4i_i2s { struct clk *bus_clk; struct clk *mod_clk; @@ -100,6 +109,8 @@ struct sun4i_i2s { struct snd_dmaengine_dai_dma_data capture_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data; + + const struct sun4i_i2s_quirks *variant; }; struct sun4i_i2s_clk_div { @@ -654,10 +665,6 @@ static int sun4i_i2s_runtime_suspend(struct device *dev) return 0; } -struct sun4i_i2s_quirks { - bool has_reset; -}; - static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .has_reset = false, }; @@ -669,7 +676,6 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { static int sun4i_i2s_probe(struct platform_device *pdev) { struct sun4i_i2s *i2s; - const struct sun4i_i2s_quirks *quirks; struct resource *res; void __iomem *regs; int irq, ret; @@ -690,8 +696,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev) return irq; } - quirks = of_device_get_match_data(&pdev->dev); - if (!quirks) { + i2s->variant = of_device_get_match_data(&pdev->dev); + if (!i2s->variant) { dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); return -ENODEV; } @@ -715,7 +721,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev) return PTR_ERR(i2s->mod_clk); } - if (quirks->has_reset) { + if (i2s->variant->has_reset) { i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(i2s->rst)) { dev_err(&pdev->dev, "Failed to get reset control\n"); -- cgit v1.1 From 818010dac09183e99ff02e35836544b2e1d659f3 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 31 Jul 2017 13:47:42 +0800 Subject: ASoC: rt5514: Add the sanity checks of the buffer related address The patch add the sanity checks of the buffer related address to make sure the addresses are valid. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 950d1ff..6f513cc 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -173,9 +173,14 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data) rt5514_dsp->buf_rp = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24; + if (rt5514_dsp->buf_rp % 8) + rt5514_dsp->buf_rp = (rt5514_dsp->buf_rp / 8) * 8; + rt5514_dsp->buf_size = rt5514_dsp->buf_limit - rt5514_dsp->buf_base; - schedule_delayed_work(&rt5514_dsp->copy_work, 0); + if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit && + rt5514_dsp->buf_rp && rt5514_dsp->buf_size) + schedule_delayed_work(&rt5514_dsp->copy_work, 0); return IRQ_HANDLED; } -- cgit v1.1 From 19b4b7292615358b9599ff9410a3e564b4844e90 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 2 Aug 2017 17:55:13 +0800 Subject: ASoC: wm8523: Fix array size for bclk_ratios ARRAY_SIZE(bclk_ratios) returns 7 for current code, then it cannot catch the error if "no matching BCLK/fs ratio". Fix it. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/codecs/wm8523.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index 6d0a272..b1e4ce7 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c @@ -116,7 +116,7 @@ static struct { static struct { int value; int ratio; -} bclk_ratios[WM8523_NUM_RATES] = { +} bclk_ratios[] = { { 2, 32 }, { 3, 64 }, { 4, 128 }, -- cgit v1.1 From c0d088f04f115409287003b5fc0dfd3184d7d306 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 2 Aug 2017 17:55:14 +0800 Subject: ASoC: wm8523: Constfiy lrclk_ratios and bclk_ratios Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- sound/soc/codecs/wm8523.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index b1e4ce7..c7c33e9 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c @@ -100,7 +100,7 @@ static const struct snd_soc_dapm_route wm8523_dapm_routes[] = { { "LINEVOUTR", NULL, "DAC" }, }; -static struct { +static const struct { int value; int ratio; } lrclk_ratios[WM8523_NUM_RATES] = { @@ -113,7 +113,7 @@ static struct { { 7, 1152 }, }; -static struct { +static const struct { int value; int ratio; } bclk_ratios[] = { -- cgit v1.1 From 80bfd0431f7dc133f4edbc0b864f800c4ed7a3f4 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 2 Aug 2017 16:13:46 +0800 Subject: ASoC: wm8524: Don't use dev_err to show supported sample rate Switch to use dev_dbg instead. Signed-off-by: Axel Lin Acked-by: Mihai Serban Signed-off-by: Mark Brown --- sound/soc/codecs/wm8524.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c index e22b76d..b66147e 100644 --- a/sound/soc/codecs/wm8524.c +++ b/sound/soc/codecs/wm8524.c @@ -118,7 +118,7 @@ static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai, case 96000: case 176400: case 192000: - dev_err(codec->dev, "Supported sample rate: %dHz\n", + dev_dbg(codec->dev, "Supported sample rate: %dHz\n", val); wm8524->rate_constraint_list[j++] = val; wm8524->rate_constraint.count++; -- cgit v1.1 From 278982b50b28d654ff8cca0efb1ff6e835c6cc4c Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Wed, 2 Aug 2017 16:01:27 +0800 Subject: ASoC: rt5663: Seprate the DC offset between headphone and headset The patch seprates the DC offset between headphone and headset. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 52 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index c1f0a72c..be93231 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -1570,9 +1570,43 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) case 2: rt5663->jack_type = SND_JACK_HEADSET; rt5663_enable_push_button_irq(codec, true); + + if (rt5663->pdata.dc_offset_l_manual_mic) { + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_2, + rt5663->pdata.dc_offset_l_manual_mic >> + 16); + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_3, + rt5663->pdata.dc_offset_l_manual_mic & + 0xffff); + } + + if (rt5663->pdata.dc_offset_r_manual_mic) { + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_5, + rt5663->pdata.dc_offset_r_manual_mic >> + 16); + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_6, + rt5663->pdata.dc_offset_r_manual_mic & + 0xffff); + } break; default: rt5663->jack_type = SND_JACK_HEADPHONE; + + if (rt5663->pdata.dc_offset_l_manual) { + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_2, + rt5663->pdata.dc_offset_l_manual >> 16); + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_3, + rt5663->pdata.dc_offset_l_manual & + 0xffff); + } + + if (rt5663->pdata.dc_offset_r_manual) { + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_5, + rt5663->pdata.dc_offset_r_manual >> 16); + regmap_write(rt5663->regmap, RT5663_MIC_DECRO_6, + rt5663->pdata.dc_offset_r_manual & + 0xffff); + } break; } } else { @@ -3133,6 +3167,10 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev) &rt5663->pdata.dc_offset_l_manual); device_property_read_u32(dev, "realtek,dc_offset_r_manual", &rt5663->pdata.dc_offset_r_manual); + device_property_read_u32(dev, "realtek,dc_offset_l_manual_mic", + &rt5663->pdata.dc_offset_l_manual_mic); + device_property_read_u32(dev, "realtek,dc_offset_r_manual_mic", + &rt5663->pdata.dc_offset_r_manual_mic); return 0; } @@ -3221,20 +3259,6 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, dev_err(&i2c->dev, "%s:Unknown codec type\n", __func__); } - if (rt5663->pdata.dc_offset_l_manual) { - regmap_write(rt5663->regmap, RT5663_MIC_DECRO_2, - rt5663->pdata.dc_offset_l_manual >> 16); - regmap_write(rt5663->regmap, RT5663_MIC_DECRO_3, - rt5663->pdata.dc_offset_l_manual & 0xffff); - } - - if (rt5663->pdata.dc_offset_r_manual) { - regmap_write(rt5663->regmap, RT5663_MIC_DECRO_5, - rt5663->pdata.dc_offset_r_manual >> 16); - regmap_write(rt5663->regmap, RT5663_MIC_DECRO_6, - rt5663->pdata.dc_offset_r_manual & 0xffff); - } - /* GPIO1 as IRQ */ regmap_update_bits(rt5663->regmap, RT5663_GPIO_1, RT5663_GP1_PIN_MASK, RT5663_GP1_PIN_IRQ); -- cgit v1.1 From 29685e207b37ad7f415e4bf21320076c025f3df1 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Tue, 25 Jul 2017 10:48:14 +0200 Subject: ASoC: codec: add DT support in dmic codec Add of_table to allows DT probing. Signed-off-by: Arnaud Pouliquen Signed-off-by: Mark Brown --- sound/soc/codecs/dmic.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index c82b9dc..d50f142 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -73,9 +73,15 @@ static int dmic_dev_remove(struct platform_device *pdev) MODULE_ALIAS("platform:dmic-codec"); +static const struct of_device_id dmic_dev_match[] = { + {.compatible = "dmic-codec"}, + {} +}; + static struct platform_driver dmic_driver = { .driver = { .name = "dmic-codec", + .of_match_table = dmic_dev_match, }, .probe = dmic_dev_probe, .remove = dmic_dev_remove, -- cgit v1.1 From e3c6de48133ff1355f14a31a74a9027834c0fd65 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 2 Aug 2017 10:26:09 +0000 Subject: ASoC: rcar: unregister fixed rate on ADG ADG is registering fixed rate clock for audio_clkout, but it had not been unregister clock when removing. Salvator-X board is using ak4613 driver now, and it supports hw_constraints from commit 907cd8809eebc ("ASoC: ak4613: add hw_constraint rule for Sampling Rate"). And this calculation is using input clk. This ak4613 input clock is ADG clkout on Salvator-X. Because ADG had not been unregister clkout when unbinding, it receives fixed rate clk register error when re-binding. Thus, ak4613 can't get correct input clock, and hw_constraints will be failed after re-binding. This means Salvator-X board can't use sound after unbind/bind. This patch solves this issue. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/adg.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sound') diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index 197cb3e..5b5389e 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -610,6 +610,13 @@ void rsnd_adg_remove(struct rsnd_priv *priv) { struct device *dev = rsnd_priv_to_dev(priv); struct device_node *np = dev->of_node; + struct rsnd_adg *adg = priv->adg; + struct clk *clk; + int i; + + for_each_rsnd_clkout(clk, adg, i) + if (adg->clkout[i]) + clk_unregister_fixed_rate(adg->clkout[i]); of_clk_del_provider(np); -- cgit v1.1 From 2032ce4de818366adb78d8e0b29291ce58ae1e40 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 2 Aug 2017 15:17:46 +0200 Subject: ASoC: codecs: msm8916-wcd-digital: add support to set_sysclk This patch adds support to set_sysclk() which can let the sound card driver to set default mclk rate. In this case MCLK for internal audio codec is expected to be at 9.6MHz by default. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-digital.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index 7e3794f..661cd6d 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -568,6 +568,15 @@ static int msm8916_wcd_digital_codec_probe(struct snd_soc_codec *codec) return 0; } +static int msm8916_wcd_digital_codec_set_sysclk(struct snd_soc_codec *codec, + int clk_id, int source, + unsigned int freq, int dir) +{ + struct msm8916_wcd_digital_priv *p = dev_get_drvdata(codec->dev); + + return clk_set_rate(p->mclk, freq); +} + static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -823,6 +832,7 @@ static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = { static struct snd_soc_codec_driver msm8916_wcd_digital = { .probe = msm8916_wcd_digital_codec_probe, + .set_sysclk = msm8916_wcd_digital_codec_set_sysclk, .component_driver = { .controls = msm8916_wcd_digital_snd_controls, .num_controls = ARRAY_SIZE(msm8916_wcd_digital_snd_controls), -- cgit v1.1 From 820f7541f952afa8db08ccd420f29a2c6c148709 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 2 Aug 2017 15:17:46 +0200 Subject: ASoC: codecs: msm8916-wcd-digital: add support to set_sysclk This patch adds support to set_sysclk() which can let the sound card driver to set default mclk rate. In this case MCLK for internal audio codec is expected to be at 9.6MHz by default. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-digital.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index f690442..825cc7d 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -568,6 +568,15 @@ static int msm8916_wcd_digital_codec_probe(struct snd_soc_codec *codec) return 0; } +static int msm8916_wcd_digital_codec_set_sysclk(struct snd_soc_codec *codec, + int clk_id, int source, + unsigned int freq, int dir) +{ + struct msm8916_wcd_digital_priv *p = dev_get_drvdata(codec->dev); + + return clk_set_rate(p->mclk, freq); +} + static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -823,6 +832,7 @@ static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = { static struct snd_soc_codec_driver msm8916_wcd_digital = { .probe = msm8916_wcd_digital_codec_probe, + .set_sysclk = msm8916_wcd_digital_codec_set_sysclk, .component_driver = { .controls = msm8916_wcd_digital_snd_controls, .num_controls = ARRAY_SIZE(msm8916_wcd_digital_snd_controls), -- cgit v1.1 From 334822a3b21f5b622ae1954915003d636186e7b0 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 2 Aug 2017 15:17:47 +0200 Subject: ASoC: qcom: apq8016-sbc: set default mclk rate MCLK for internal audio codec is expected to be at 9.6MHz by default. This patch adds support to 9.6MHz to make the default case possible. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/qcom/apq8016_sbc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index d084d74..f07aa1e 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -34,13 +34,16 @@ struct apq8016_sbc_data { #define MIC_CTRL_QUA_WS_SLAVE_SEL_10 BIT(17) #define MIC_CTRL_TLMM_SCLK_EN BIT(1) #define SPKR_CTL_PRI_WS_SLAVE_SEL_11 (BIT(17) | BIT(16)) +#define DEFAULT_MCLK_RATE 9600000 static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_codec *codec; + struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_card *card = rtd->card; struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card); - int rval = 0; + int i, rval; switch (cpu_dai->id) { case MI2S_PRIMARY: @@ -63,12 +66,24 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) default: dev_err(card->dev, "unsupported cpu dai configuration\n"); - rval = -EINVAL; - break; + return -EINVAL; + + } + for (i = 0 ; i < dai_link->num_codecs; i++) { + struct snd_soc_dai *dai = rtd->codec_dais[i]; + + codec = dai->codec; + /* Set default mclk for internal codec */ + rval = snd_soc_codec_set_sysclk(codec, 0, 0, DEFAULT_MCLK_RATE, + SND_SOC_CLOCK_IN); + if (rval != 0 && rval != -ENOTSUPP) { + dev_warn(card->dev, "Failed to set mclk: %d\n", rval); + return rval; + } } - return rval; + return 0; } static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) -- cgit v1.1 From 3a88a3757dc654c29c87f4537053d0f3dc28d9e0 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 2 Aug 2017 15:17:48 +0200 Subject: ASoC: codecs: msm8916-wcd-digital: add CIC filter source selection path This patch fixes a missing selection of DMIC in CIC filter source path to dapm route. Without this patch dmic is not functional. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-digital.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index 825cc7d..d2993e7 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -218,6 +218,8 @@ static const char *const rx_mix1_text[] = { static const char *const dec_mux_text[] = { "ZERO", "ADC1", "ADC2", "ADC3", "DMIC1", "DMIC2" }; + +static const char *const cic_mux_text[] = { "AMIC", "DMIC" }; static const char *const rx_mix2_text[] = { "ZERO", "IIR1", "IIR2" }; static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" }; @@ -256,11 +258,21 @@ static const struct soc_enum dec1_mux_enum = SOC_ENUM_SINGLE( static const struct soc_enum dec2_mux_enum = SOC_ENUM_SINGLE( LPASS_CDC_CONN_TX_B1_CTL, 3, 6, dec_mux_text); +/* CIC */ +static const struct soc_enum cic1_mux_enum = SOC_ENUM_SINGLE( + LPASS_CDC_TX1_MUX_CTL, 0, 2, cic_mux_text); +static const struct soc_enum cic2_mux_enum = SOC_ENUM_SINGLE( + LPASS_CDC_TX2_MUX_CTL, 0, 2, cic_mux_text); + /* RDAC2 MUX */ static const struct snd_kcontrol_new dec1_mux = SOC_DAPM_ENUM( "DEC1 MUX Mux", dec1_mux_enum); static const struct snd_kcontrol_new dec2_mux = SOC_DAPM_ENUM( "DEC2 MUX Mux", dec2_mux_enum); +static const struct snd_kcontrol_new cic1_mux = SOC_DAPM_ENUM( + "CIC1 MUX Mux", cic1_mux_enum); +static const struct snd_kcontrol_new cic2_mux = SOC_DAPM_ENUM( + "CIC2 MUX Mux", cic2_mux_enum); static const struct snd_kcontrol_new rx_mix1_inp1_mux = SOC_DAPM_ENUM( "RX1 MIX1 INP1 Mux", rx_mix1_inp_enum[0]); static const struct snd_kcontrol_new rx_mix1_inp2_mux = SOC_DAPM_ENUM( @@ -500,6 +512,8 @@ static const struct snd_soc_dapm_widget msm8916_wcd_digital_dapm_widgets[] = { SND_SOC_DAPM_MUX("RX3 MIX1 INP3", SND_SOC_NOPM, 0, 0, &rx3_mix1_inp3_mux), + SND_SOC_DAPM_MUX("CIC1 MUX", SND_SOC_NOPM, 0, 0, &cic1_mux), + SND_SOC_DAPM_MUX("CIC2 MUX", SND_SOC_NOPM, 0, 0, &cic2_mux), /* TX */ SND_SOC_DAPM_MIXER("ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_MIXER("ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), @@ -536,6 +550,8 @@ static const struct snd_soc_dapm_widget msm8916_wcd_digital_dapm_widgets[] = { /* Connectivity Clock */ SND_SOC_DAPM_SUPPLY_S("CDC_CONN", -2, LPASS_CDC_CLK_OTHR_CTL, 2, 0, NULL, 0), + SND_SOC_DAPM_MIC("Digital Mic1", NULL), + SND_SOC_DAPM_MIC("Digital Mic2", NULL), }; @@ -655,6 +671,11 @@ static const struct snd_soc_dapm_route msm8916_wcd_digital_audio_map[] = { {"AIF1 Capture", NULL, "I2S TX2"}, {"AIF1 Capture", NULL, "I2S TX3"}, + {"CIC1 MUX", "DMIC", "DEC1 MUX"}, + {"CIC1 MUX", "AMIC", "DEC1 MUX"}, + {"CIC2 MUX", "DMIC", "DEC2 MUX"}, + {"CIC2 MUX", "AMIC", "DEC2 MUX"}, + /* Decimator Inputs */ {"DEC1 MUX", "DMIC1", "DMIC1"}, {"DEC1 MUX", "DMIC2", "DMIC2"}, @@ -673,8 +694,8 @@ static const struct snd_soc_dapm_route msm8916_wcd_digital_audio_map[] = { {"DMIC1", NULL, "DMIC_CLK"}, {"DMIC2", NULL, "DMIC_CLK"}, - {"I2S TX1", NULL, "DEC1 MUX"}, - {"I2S TX2", NULL, "DEC2 MUX"}, + {"I2S TX1", NULL, "CIC1 MUX"}, + {"I2S TX2", NULL, "CIC2 MUX"}, {"I2S TX1", NULL, "TX_I2S_CLK"}, {"I2S TX2", NULL, "TX_I2S_CLK"}, -- cgit v1.1 From d70c4a048195769ff22e65b9efe984de2259b974 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Wed, 2 Aug 2017 11:47:43 +0530 Subject: ASoC: Intel: Skylake: Use correct nuvoton codec ID Correcting the nau88l25 codec ID to match secondary codec and load the machine driver. Signed-off-by: Naveen M Signed-off-by: Harsha Priya Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 9e3f8c0..6b49feb 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -879,12 +879,12 @@ static void skl_remove(struct pci_dev *pci) static struct sst_codecs skl_codecs = { .num_codecs = 1, - .codecs = {"NAU88L25"} + .codecs = {"10508825"} }; static struct sst_codecs kbl_codecs = { .num_codecs = 1, - .codecs = {"NAU88L25"} + .codecs = {"10508825"} }; static struct sst_codecs bxt_codecs = { -- cgit v1.1 From da3cbb40f35b4b5ab66df9a23a717a4a5df1f992 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Wed, 2 Aug 2017 11:43:33 +0530 Subject: ASoC: Intel: kbl: Add new FEs for Multi-Playback & Echo-Reference Adding new frontends to support: 1. Parallel playback on 2 ports simultaneously 2. Echo reference capture capability Signed-off-by: Naveen M Signed-off-by: Sathya Prakash M R Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index b1f2dba..debdaac 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -675,6 +675,32 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { }, }, { + .name = "System Pin2", + .ops = &skl_pcm_dai_ops, + .playback = { + .stream_name = "Headset Playback", + .channels_min = HDA_MONO, + .channels_max = HDA_STEREO, + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_8000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + }, +}, +{ + .name = "Echoref Pin", + .ops = &skl_pcm_dai_ops, + .capture = { + .stream_name = "Echoreference Capture", + .channels_min = HDA_STEREO, + .channels_max = HDA_STEREO, + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_8000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + }, +}, +{ .name = "Reference Pin", .ops = &skl_pcm_dai_ops, .capture = { -- cgit v1.1 From b32ee384ac18d3e4db0ef45d23c3ff1c67113529 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Wed, 2 Aug 2017 11:43:34 +0530 Subject: ASoC: Intel: kbl: Add DAI links for Multi-Playback & Echo-reference Add new FE DAI links to support: 1. Parallel playback on 2 ports simultaneously 2. Echo reference capture capability Signed-off-by: Naveen M Signed-off-by: Sathya Prakash M R Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 24 ++++++++++++++++++++++ .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 24 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 090331b..4c70d5a 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -52,6 +52,8 @@ struct kbl_rt5663_private { enum { KBL_DPCM_AUDIO_PB = 0, KBL_DPCM_AUDIO_CP, + KBL_DPCM_AUDIO_HS_PB, + KBL_DPCM_AUDIO_ECHO_REF_CP, KBL_DPCM_AUDIO_REF_CP, KBL_DPCM_AUDIO_DMIC_CP, KBL_DPCM_AUDIO_HDMI1_PB, @@ -485,6 +487,28 @@ static struct snd_soc_dai_link kabylake_dais[] = { .dpcm_capture = 1, .ops = &kabylake_rt5663_fe_ops, }, + [KBL_DPCM_AUDIO_HS_PB] = { + .name = "Kbl Audio Headset Playback", + .stream_name = "Headset Audio", + .cpu_dai_name = "System Pin2", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_ECHO_REF_CP] = { + .name = "Kbl Audio Echo Reference cap", + .stream_name = "Echoreference Capture", + .cpu_dai_name = "Echoref Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .init = NULL, + .capture_only = 1, + .nonatomic = 1, + }, [KBL_DPCM_AUDIO_REF_CP] = { .name = "Kbl Audio Reference cap", .stream_name = "Wake on Voice", diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 74bbc00..64364de 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -62,6 +62,8 @@ struct kbl_codec_private { enum { KBL_DPCM_AUDIO_PB = 0, KBL_DPCM_AUDIO_CP, + KBL_DPCM_AUDIO_HS_PB, + KBL_DPCM_AUDIO_ECHO_REF_CP, KBL_DPCM_AUDIO_DMIC_CP, KBL_DPCM_AUDIO_HDMI1_PB, KBL_DPCM_AUDIO_HDMI2_PB, @@ -456,6 +458,28 @@ static struct snd_soc_dai_link kabylake_dais[] = { .dpcm_capture = 1, .ops = &kabylake_rt5663_fe_ops, }, + [KBL_DPCM_AUDIO_HS_PB] = { + .name = "Kbl Audio Headset Playback", + .stream_name = "Headset Audio", + .cpu_dai_name = "System Pin2", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_ECHO_REF_CP] = { + .name = "Kbl Audio Echo Reference cap", + .stream_name = "Echoreference Capture", + .cpu_dai_name = "Echoref Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .init = NULL, + .capture_only = 1, + .nonatomic = 1, + }, [KBL_DPCM_AUDIO_DMIC_CP] = { .name = "Kbl Audio DMIC cap", .stream_name = "dmiccap", -- cgit v1.1 From 0b06122fc8d0949a0aa7b817d98e031104802611 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Wed, 2 Aug 2017 11:43:35 +0530 Subject: ASoC: Intel: kbl: Add map for new DAIs for Multi-Playback & Echo Ref Modified DAPM Machine map for machine to suit the toplogy change required to enable features: Multi-Endpoint Playback Echo Reference Capture Signed-off-by: Naveen M Signed-off-by: Sathya Prakash M R Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 6 +++--- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 4c70d5a..12b34b9 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -99,12 +99,12 @@ static const struct snd_soc_dapm_route kabylake_map[] = { /* CODEC BE connections */ { "Left HiFi Playback", NULL, "ssp0 Tx" }, { "Right HiFi Playback", NULL, "ssp0 Tx" }, - { "ssp0 Tx", NULL, "codec0_out" }, + { "ssp0 Tx", NULL, "spk_out" }, { "AIF Playback", NULL, "ssp1 Tx" }, - { "ssp1 Tx", NULL, "codec1_out" }, + { "ssp1 Tx", NULL, "hs_out" }, - { "codec0_in", NULL, "ssp1 Rx" }, + { "hs_in", NULL, "ssp1 Rx" }, { "ssp1 Rx", NULL, "AIF Capture" }, /* DMIC */ diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 64364de..5ec9428 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -107,12 +107,12 @@ static const struct snd_soc_dapm_route kabylake_map[] = { /* CODEC BE connections */ { "Left HiFi Playback", NULL, "ssp0 Tx" }, { "Right HiFi Playback", NULL, "ssp0 Tx" }, - { "ssp0 Tx", NULL, "codec0_out" }, + { "ssp0 Tx", NULL, "spk_out" }, { "AIF Playback", NULL, "ssp1 Tx" }, - { "ssp1 Tx", NULL, "codec1_out" }, + { "ssp1 Tx", NULL, "hs_out" }, - { "codec0_in", NULL, "ssp1 Rx" }, + { "hs_in", NULL, "ssp1 Rx" }, { "ssp1 Rx", NULL, "AIF Capture" }, { "codec1_in", NULL, "ssp0 Rx" }, -- cgit v1.1 From 363d45385f403fdf60fe9f563ba87093289d7b35 Mon Sep 17 00:00:00 2001 From: Dharageswari R Date: Wed, 2 Aug 2017 21:51:12 +0530 Subject: ASoC: Intel: Skylake: Add num of cores in dsp ops Number of dsp cores may differ for different platforms hence adding it in dsp ops. Signed-off-by: Dharageswari R Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/bxt-sst.c | 1 - sound/soc/intel/skylake/skl-messages.c | 6 ++++++ sound/soc/intel/skylake/skl-sst.c | 2 -- sound/soc/intel/skylake/skl.h | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c index 08a2c5e..c404a42 100644 --- a/sound/soc/intel/skylake/bxt-sst.c +++ b/sound/soc/intel/skylake/bxt-sst.c @@ -584,7 +584,6 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, /* set the D0i3 check */ skl->ipc.ops.check_dsp_lp_on = skl_ipc_check_D0i0; - skl->cores.count = 2; skl->boot_complete = false; init_waitqueue_head(&skl->boot_wait); INIT_DELAYED_WORK(&skl->d0i3.work, bxt_set_dsp_D0i3); diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index c5b4e0a..7892e44 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -201,6 +201,7 @@ static struct skl_dsp_loader_ops bxt_get_loader_ops(void) static const struct skl_dsp_ops dsp_ops[] = { { .id = 0x9d70, + .num_cores = 2, .loader_ops = skl_get_loader_ops, .init = skl_sst_dsp_init, .init_fw = skl_sst_init_fw, @@ -208,6 +209,7 @@ static const struct skl_dsp_ops dsp_ops[] = { }, { .id = 0x9d71, + .num_cores = 2, .loader_ops = skl_get_loader_ops, .init = kbl_sst_dsp_init, .init_fw = skl_sst_init_fw, @@ -215,6 +217,7 @@ static const struct skl_dsp_ops dsp_ops[] = { }, { .id = 0x5a98, + .num_cores = 2, .loader_ops = bxt_get_loader_ops, .init = bxt_sst_dsp_init, .init_fw = bxt_sst_init_fw, @@ -222,6 +225,7 @@ static const struct skl_dsp_ops dsp_ops[] = { }, { .id = 0x3198, + .num_cores = 2, .loader_ops = bxt_get_loader_ops, .init = bxt_sst_dsp_init, .init_fw = bxt_sst_init_fw, @@ -275,6 +279,8 @@ int skl_init_dsp(struct skl *skl) return ret; skl->skl_sst->dsp_ops = ops; + skl->skl_sst->cores.count = ops->num_cores; + dev_dbg(bus->dev, "dsp registration status=%d\n", ret); return ret; diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c index aba9ea1..fd99e74 100644 --- a/sound/soc/intel/skylake/skl-sst.c +++ b/sound/soc/intel/skylake/skl-sst.c @@ -563,8 +563,6 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, sst->fw_ops = skl_fw_ops; - skl->cores.count = 2; - return 0; } EXPORT_SYMBOL_GPL(skl_sst_dsp_init); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index a6b134b..20017ee 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -90,6 +90,7 @@ struct skl_machine_pdata { struct skl_dsp_ops { int id; + unsigned int num_cores; struct skl_dsp_loader_ops (*loader_ops)(void); int (*init)(struct device *dev, void __iomem *mmio_base, int irq, const char *fw_name, -- cgit v1.1 From f0a550a88373b0b076785e059cca15f32ae9ffeb Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:13 +0530 Subject: ASoC: Intel: Skylake: Use num_core to allocate instead of macro For different platforms, number of dsp cores can vary. So instead of creating array of size SKL_DSP_CORES_MAX, use num_core in dsp_ops() of the respective platform to allocate core usage counts and states. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 18 +++++++++++++++++- sound/soc/intel/skylake/skl-sst-dsp.c | 2 +- sound/soc/intel/skylake/skl-sst-ipc.h | 6 ++---- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 7892e44..c6b60ee 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -253,6 +253,7 @@ int skl_init_dsp(struct skl *skl) struct skl_dsp_loader_ops loader_ops; int irq = bus->irq; const struct skl_dsp_ops *ops; + struct skl_dsp_cores *cores; int ret; /* enable ppcap interrupt */ @@ -279,7 +280,19 @@ int skl_init_dsp(struct skl *skl) return ret; skl->skl_sst->dsp_ops = ops; - skl->skl_sst->cores.count = ops->num_cores; + cores = &skl->skl_sst->cores; + cores->count = ops->num_cores; + + cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL); + if (!cores->state) + return -ENOMEM; + + cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count), + GFP_KERNEL); + if (!cores->usage_count) { + kfree(cores->state); + return -ENOMEM; + } dev_dbg(bus->dev, "dsp registration status=%d\n", ret); @@ -297,6 +310,9 @@ int skl_free_dsp(struct skl *skl) ctx->dsp_ops->cleanup(bus->dev, ctx); + kfree(ctx->cores.state); + kfree(ctx->cores.usage_count); + if (ctx->dsp->addr.lpe) iounmap(ctx->dsp->addr.lpe); diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c index 0833272..c2ba5ff 100644 --- a/sound/soc/intel/skylake/skl-sst-dsp.c +++ b/sound/soc/intel/skylake/skl-sst-dsp.c @@ -47,7 +47,7 @@ void skl_dsp_init_core_state(struct sst_dsp *ctx) skl->cores.state[SKL_DSP_CORE0_ID] = SKL_DSP_RUNNING; skl->cores.usage_count[SKL_DSP_CORE0_ID] = 1; - for (i = SKL_DSP_CORE0_ID + 1; i < SKL_DSP_CORES_MAX; i++) { + for (i = SKL_DSP_CORE0_ID + 1; i < skl->cores.count; i++) { skl->cores.state[i] = SKL_DSP_RESET; skl->cores.usage_count[i] = 0; } diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h index e057da27..e485e8f 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.h +++ b/sound/soc/intel/skylake/skl-sst-ipc.h @@ -44,12 +44,10 @@ struct skl_ipc_header { u32 extension; }; -#define SKL_DSP_CORES_MAX 2 - struct skl_dsp_cores { unsigned int count; - enum skl_dsp_states state[SKL_DSP_CORES_MAX]; - int usage_count[SKL_DSP_CORES_MAX]; + enum skl_dsp_states *state; + int *usage_count; }; /** -- cgit v1.1 From 4147a6e59a5c0b9cb0eeaa3e1f39fd9da491f35a Mon Sep 17 00:00:00 2001 From: Pardha Saradhi K Date: Wed, 2 Aug 2017 21:51:14 +0530 Subject: ASoC: Intel: Skylake: Add dsp cores management This patch adds support to manage additional cores on a demand basis. For instance, if module is set to run on certain core, the particular core is powered up in module init. The same is again powered down in module unload. Signed-off-by: Pardha Saradhi K Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 8c3ce08..350d238 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -596,24 +596,35 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe) if (mconfig->id.pvt_id < 0) return ret; skl_tplg_set_module_init_data(w); + + ret = skl_dsp_get_core(ctx->dsp, mconfig->core_id); + if (ret < 0) { + dev_err(ctx->dev, "Failed to wake up core %d ret=%d\n", + mconfig->core_id, ret); + return ret; + } + ret = skl_init_module(ctx, mconfig); if (ret < 0) { skl_put_pvt_id(ctx, uuid_mod, &mconfig->id.pvt_id); - return ret; + goto err; } skl_tplg_alloc_pipe_mcps(skl, mconfig); ret = skl_tplg_set_module_params(w, ctx); if (ret < 0) - return ret; + goto err; } return 0; +err: + skl_dsp_put_core(ctx->dsp, mconfig->core_id); + return ret; } static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx, struct skl_pipe *pipe) { - int ret; + int ret = 0; struct skl_pipe_module *w_module = NULL; struct skl_module_cfg *mconfig = NULL; @@ -630,10 +641,17 @@ static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx, return -EIO; } skl_put_pvt_id(ctx, uuid_mod, &mconfig->id.pvt_id); + + ret = skl_dsp_put_core(ctx->dsp, mconfig->core_id); + if (ret < 0) { + /* don't return; continue with other modules */ + dev_err(ctx->dev, "Failed to sleep core %d ret=%d\n", + mconfig->core_id, ret); + } } /* no modules to unload in this path, so return */ - return 0; + return ret; } /* -- cgit v1.1 From a838dcc286754f6ea6bcbee8eb76a5d626642fa7 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:15 +0530 Subject: ASoC: Intel: cnl: Add cnl dsp functions and registers This adds Cannonlake specific registers and support for CNL dsp related library functions for programming the registers to power up/down dsp cores, set/unset reset states for each core, enable/disable ipc interrupts and few wrappers to be called from elsewhere. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/cnl-sst-dsp.c | 274 ++++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/cnl-sst-dsp.h | 106 +++++++++++++ 2 files changed, 380 insertions(+) create mode 100644 sound/soc/intel/skylake/cnl-sst-dsp.c create mode 100644 sound/soc/intel/skylake/cnl-sst-dsp.h (limited to 'sound') diff --git a/sound/soc/intel/skylake/cnl-sst-dsp.c b/sound/soc/intel/skylake/cnl-sst-dsp.c new file mode 100644 index 0000000..2f83267 --- /dev/null +++ b/sound/soc/intel/skylake/cnl-sst-dsp.c @@ -0,0 +1,274 @@ +/* + * cnl-sst-dsp.c - CNL SST library generic function + * + * Copyright (C) 2016-17, Intel Corporation. + * Author: Guneshwor Singh + * + * Modified from: + * SKL SST library generic function + * Copyright (C) 2014-15, Intel Corporation. + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as 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. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ +#include +#include "../common/sst-dsp.h" +#include "../common/sst-ipc.h" +#include "../common/sst-dsp-priv.h" +#include "cnl-sst-dsp.h" + +/* various timeout values */ +#define CNL_DSP_PU_TO 50 +#define CNL_DSP_PD_TO 50 +#define CNL_DSP_RESET_TO 50 + +static int +cnl_dsp_core_set_reset_state(struct sst_dsp *ctx, unsigned int core_mask) +{ + /* update bits */ + sst_dsp_shim_update_bits_unlocked(ctx, + CNL_ADSP_REG_ADSPCS, CNL_ADSPCS_CRST(core_mask), + CNL_ADSPCS_CRST(core_mask)); + + /* poll with timeout to check if operation successful */ + return sst_dsp_register_poll(ctx, + CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CRST(core_mask), + CNL_ADSPCS_CRST(core_mask), + CNL_DSP_RESET_TO, + "Set reset"); +} + +static int +cnl_dsp_core_unset_reset_state(struct sst_dsp *ctx, unsigned int core_mask) +{ + /* update bits */ + sst_dsp_shim_update_bits_unlocked(ctx, CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CRST(core_mask), 0); + + /* poll with timeout to check if operation successful */ + return sst_dsp_register_poll(ctx, + CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CRST(core_mask), + 0, + CNL_DSP_RESET_TO, + "Unset reset"); +} + +static bool is_cnl_dsp_core_enable(struct sst_dsp *ctx, unsigned int core_mask) +{ + int val; + bool is_enable; + + val = sst_dsp_shim_read_unlocked(ctx, CNL_ADSP_REG_ADSPCS); + + is_enable = (val & CNL_ADSPCS_CPA(core_mask)) && + (val & CNL_ADSPCS_SPA(core_mask)) && + !(val & CNL_ADSPCS_CRST(core_mask)) && + !(val & CNL_ADSPCS_CSTALL(core_mask)); + + dev_dbg(ctx->dev, "DSP core(s) enabled? %d: core_mask %#x\n", + is_enable, core_mask); + + return is_enable; +} + +static int cnl_dsp_reset_core(struct sst_dsp *ctx, unsigned int core_mask) +{ + /* stall core */ + sst_dsp_shim_update_bits_unlocked(ctx, CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CSTALL(core_mask), + CNL_ADSPCS_CSTALL(core_mask)); + + /* set reset state */ + return cnl_dsp_core_set_reset_state(ctx, core_mask); +} + +static int cnl_dsp_start_core(struct sst_dsp *ctx, unsigned int core_mask) +{ + int ret; + + /* unset reset state */ + ret = cnl_dsp_core_unset_reset_state(ctx, core_mask); + if (ret < 0) + return ret; + + /* run core */ + sst_dsp_shim_update_bits_unlocked(ctx, CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CSTALL(core_mask), 0); + + if (!is_cnl_dsp_core_enable(ctx, core_mask)) { + cnl_dsp_reset_core(ctx, core_mask); + dev_err(ctx->dev, "DSP core mask %#x enable failed\n", + core_mask); + ret = -EIO; + } + + return ret; +} + +static int cnl_dsp_core_power_up(struct sst_dsp *ctx, unsigned int core_mask) +{ + /* update bits */ + sst_dsp_shim_update_bits_unlocked(ctx, CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_SPA(core_mask), + CNL_ADSPCS_SPA(core_mask)); + + /* poll with timeout to check if operation successful */ + return sst_dsp_register_poll(ctx, CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CPA(core_mask), + CNL_ADSPCS_CPA(core_mask), + CNL_DSP_PU_TO, + "Power up"); +} + +static int cnl_dsp_core_power_down(struct sst_dsp *ctx, unsigned int core_mask) +{ + /* update bits */ + sst_dsp_shim_update_bits_unlocked(ctx, CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_SPA(core_mask), 0); + + /* poll with timeout to check if operation successful */ + return sst_dsp_register_poll(ctx, + CNL_ADSP_REG_ADSPCS, + CNL_ADSPCS_CPA(core_mask), + 0, + CNL_DSP_PD_TO, + "Power down"); +} + +int cnl_dsp_enable_core(struct sst_dsp *ctx, unsigned int core_mask) +{ + int ret; + + /* power up */ + ret = cnl_dsp_core_power_up(ctx, core_mask); + if (ret < 0) { + dev_dbg(ctx->dev, "DSP core mask %#x power up failed", + core_mask); + return ret; + } + + return cnl_dsp_start_core(ctx, core_mask); +} + +int cnl_dsp_disable_core(struct sst_dsp *ctx, unsigned int core_mask) +{ + int ret; + + ret = cnl_dsp_reset_core(ctx, core_mask); + if (ret < 0) { + dev_err(ctx->dev, "DSP core mask %#x reset failed\n", + core_mask); + return ret; + } + + /* power down core*/ + ret = cnl_dsp_core_power_down(ctx, core_mask); + if (ret < 0) { + dev_err(ctx->dev, "DSP core mask %#x power down failed\n", + core_mask); + return ret; + } + + if (is_cnl_dsp_core_enable(ctx, core_mask)) { + dev_err(ctx->dev, "DSP core mask %#x disable failed\n", + core_mask); + ret = -EIO; + } + + return ret; +} + +irqreturn_t cnl_dsp_sst_interrupt(int irq, void *dev_id) +{ + struct sst_dsp *ctx = dev_id; + u32 val; + irqreturn_t ret = IRQ_NONE; + + spin_lock(&ctx->spinlock); + + val = sst_dsp_shim_read_unlocked(ctx, CNL_ADSP_REG_ADSPIS); + ctx->intr_status = val; + + if (val == 0xffffffff) { + spin_unlock(&ctx->spinlock); + return IRQ_NONE; + } + + if (val & CNL_ADSPIS_IPC) { + cnl_ipc_int_disable(ctx); + ret = IRQ_WAKE_THREAD; + } + + spin_unlock(&ctx->spinlock); + + return ret; +} + +void cnl_dsp_free(struct sst_dsp *dsp) +{ + cnl_ipc_int_disable(dsp); + + free_irq(dsp->irq, dsp); + cnl_ipc_op_int_disable(dsp); + cnl_dsp_disable_core(dsp, SKL_DSP_CORE0_MASK); +} +EXPORT_SYMBOL_GPL(cnl_dsp_free); + +void cnl_ipc_int_enable(struct sst_dsp *ctx) +{ + sst_dsp_shim_update_bits(ctx, CNL_ADSP_REG_ADSPIC, + CNL_ADSPIC_IPC, CNL_ADSPIC_IPC); +} + +void cnl_ipc_int_disable(struct sst_dsp *ctx) +{ + sst_dsp_shim_update_bits_unlocked(ctx, CNL_ADSP_REG_ADSPIC, + CNL_ADSPIC_IPC, 0); +} + +void cnl_ipc_op_int_enable(struct sst_dsp *ctx) +{ + /* enable IPC DONE interrupt */ + sst_dsp_shim_update_bits(ctx, CNL_ADSP_REG_HIPCCTL, + CNL_ADSP_REG_HIPCCTL_DONE, + CNL_ADSP_REG_HIPCCTL_DONE); + + /* enable IPC BUSY interrupt */ + sst_dsp_shim_update_bits(ctx, CNL_ADSP_REG_HIPCCTL, + CNL_ADSP_REG_HIPCCTL_BUSY, + CNL_ADSP_REG_HIPCCTL_BUSY); +} + +void cnl_ipc_op_int_disable(struct sst_dsp *ctx) +{ + /* disable IPC DONE interrupt */ + sst_dsp_shim_update_bits(ctx, CNL_ADSP_REG_HIPCCTL, + CNL_ADSP_REG_HIPCCTL_DONE, 0); + + /* disable IPC BUSY interrupt */ + sst_dsp_shim_update_bits(ctx, CNL_ADSP_REG_HIPCCTL, + CNL_ADSP_REG_HIPCCTL_BUSY, 0); +} + +bool cnl_ipc_int_status(struct sst_dsp *ctx) +{ + return sst_dsp_shim_read_unlocked(ctx, CNL_ADSP_REG_ADSPIS) & + CNL_ADSPIS_IPC; +} + +void cnl_ipc_free(struct sst_generic_ipc *ipc) +{ + cnl_ipc_op_int_disable(ipc->dsp); + sst_ipc_fini(ipc); +} diff --git a/sound/soc/intel/skylake/cnl-sst-dsp.h b/sound/soc/intel/skylake/cnl-sst-dsp.h new file mode 100644 index 0000000..2fe41b1 --- /dev/null +++ b/sound/soc/intel/skylake/cnl-sst-dsp.h @@ -0,0 +1,106 @@ +/* + * Cannonlake SST DSP Support + * + * Copyright (C) 2016-17, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as 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 __CNL_SST_DSP_H__ +#define __CNL_SST_DSP_H__ + +struct sst_dsp; +struct skl_sst; +struct sst_dsp_device; +struct sst_generic_ipc; + +/* Intel HD Audio General DSP Registers */ +#define CNL_ADSP_GEN_BASE 0x0 +#define CNL_ADSP_REG_ADSPCS (CNL_ADSP_GEN_BASE + 0x04) +#define CNL_ADSP_REG_ADSPIC (CNL_ADSP_GEN_BASE + 0x08) +#define CNL_ADSP_REG_ADSPIS (CNL_ADSP_GEN_BASE + 0x0c) + +/* Intel HD Audio Inter-Processor Communication Registers */ +#define CNL_ADSP_IPC_BASE 0xc0 +#define CNL_ADSP_REG_HIPCTDR (CNL_ADSP_IPC_BASE + 0x00) +#define CNL_ADSP_REG_HIPCTDA (CNL_ADSP_IPC_BASE + 0x04) +#define CNL_ADSP_REG_HIPCTDD (CNL_ADSP_IPC_BASE + 0x08) +#define CNL_ADSP_REG_HIPCIDR (CNL_ADSP_IPC_BASE + 0x10) +#define CNL_ADSP_REG_HIPCIDA (CNL_ADSP_IPC_BASE + 0x14) +#define CNL_ADSP_REG_HIPCIDD (CNL_ADSP_IPC_BASE + 0x18) +#define CNL_ADSP_REG_HIPCCTL (CNL_ADSP_IPC_BASE + 0x28) + +/* HIPCTDR */ +#define CNL_ADSP_REG_HIPCTDR_BUSY BIT(31) + +/* HIPCTDA */ +#define CNL_ADSP_REG_HIPCTDA_DONE BIT(31) + +/* HIPCIDR */ +#define CNL_ADSP_REG_HIPCIDR_BUSY BIT(31) + +/* HIPCIDA */ +#define CNL_ADSP_REG_HIPCIDA_DONE BIT(31) + +/* CNL HIPCCTL */ +#define CNL_ADSP_REG_HIPCCTL_DONE BIT(1) +#define CNL_ADSP_REG_HIPCCTL_BUSY BIT(0) + +/* CNL HIPCT */ +#define CNL_ADSP_REG_HIPCT_BUSY BIT(31) + +/* Intel HD Audio SRAM Window 1 */ +#define CNL_ADSP_SRAM1_BASE 0xa0000 + +#define CNL_ADSP_MMIO_LEN 0x10000 + +#define CNL_ADSP_W0_STAT_SZ 0x1000 + +#define CNL_ADSP_W0_UP_SZ 0x1000 + +#define CNL_ADSP_W1_SZ 0x1000 + +#define CNL_FW_STS_MASK 0xf + +#define CNL_ADSPIC_IPC 0x1 +#define CNL_ADSPIS_IPC 0x1 + +#define CNL_DSP_CORES 4 +#define CNL_DSP_CORES_MASK ((1 << CNL_DSP_CORES) - 1) + +/* core reset - asserted high */ +#define CNL_ADSPCS_CRST_SHIFT 0 +#define CNL_ADSPCS_CRST(x) (x << CNL_ADSPCS_CRST_SHIFT) + +/* core run/stall - when set to 1 core is stalled */ +#define CNL_ADSPCS_CSTALL_SHIFT 8 +#define CNL_ADSPCS_CSTALL(x) (x << CNL_ADSPCS_CSTALL_SHIFT) + +/* set power active - when set to 1 turn core on */ +#define CNL_ADSPCS_SPA_SHIFT 16 +#define CNL_ADSPCS_SPA(x) (x << CNL_ADSPCS_SPA_SHIFT) + +/* current power active - power status of cores, set by hardware */ +#define CNL_ADSPCS_CPA_SHIFT 24 +#define CNL_ADSPCS_CPA(x) (x << CNL_ADSPCS_CPA_SHIFT) + +int cnl_dsp_enable_core(struct sst_dsp *ctx, unsigned int core); +int cnl_dsp_disable_core(struct sst_dsp *ctx, unsigned int core); +irqreturn_t cnl_dsp_sst_interrupt(int irq, void *dev_id); +void cnl_dsp_free(struct sst_dsp *dsp); + +void cnl_ipc_int_enable(struct sst_dsp *ctx); +void cnl_ipc_int_disable(struct sst_dsp *ctx); +void cnl_ipc_op_int_enable(struct sst_dsp *ctx); +void cnl_ipc_op_int_disable(struct sst_dsp *ctx); +bool cnl_ipc_int_status(struct sst_dsp *ctx); +void cnl_ipc_free(struct sst_generic_ipc *ipc); + +#endif /*__CNL_SST_DSP_H__*/ -- cgit v1.1 From 2eed1b024a11b497766604ee8f95e22711859af2 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:16 +0530 Subject: ASoC: Intel: Skylake: Move platform specific init to platform dsp_init() Move ipc_init() from helper function to respective platform's dsp_init() as ipc_init() per platform can be different. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/bxt-sst.c | 4 ++++ sound/soc/intel/skylake/skl-sst-utils.c | 6 +----- sound/soc/intel/skylake/skl-sst.c | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c index c404a42..71042ac 100644 --- a/sound/soc/intel/skylake/bxt-sst.c +++ b/sound/soc/intel/skylake/bxt-sst.c @@ -581,6 +581,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, sst_dsp_mailbox_init(sst, (BXT_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ), SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ); + ret = skl_ipc_init(dev, skl); + if (ret) + return ret; + /* set the D0i3 check */ skl->ipc.ops.check_dsp_lp_on = skl_ipc_check_D0i0; diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c index 81ee251..369ef7ce 100644 --- a/sound/soc/intel/skylake/skl-sst-utils.c +++ b/sound/soc/intel/skylake/skl-sst-utils.c @@ -368,7 +368,6 @@ int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name, { struct skl_sst *skl; struct sst_dsp *sst; - int ret; skl = devm_kzalloc(dev, sizeof(*skl), GFP_KERNEL); if (skl == NULL) @@ -388,15 +387,12 @@ int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name, sst->dsp_ops = dsp_ops; init_waitqueue_head(&skl->mod_load_wait); INIT_LIST_HEAD(&sst->module_list); - ret = skl_ipc_init(dev, skl); - if (ret) - return ret; skl->is_first_boot = true; if (dsp) *dsp = skl; - return ret; + return 0; } int skl_prepare_lib_load(struct skl_sst *skl, struct skl_lib_info *linfo, diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c index fd99e74..6cc586d 100644 --- a/sound/soc/intel/skylake/skl-sst.c +++ b/sound/soc/intel/skylake/skl-sst.c @@ -561,6 +561,10 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, sst_dsp_mailbox_init(sst, (SKL_ADSP_SRAM0_BASE + SKL_ADSP_W0_STAT_SZ), SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ); + ret = skl_ipc_init(dev, skl); + if (ret) + return ret; + sst->fw_ops = skl_fw_ops; return 0; -- cgit v1.1 From 4bdb04f0e1b7600b87a92b4f98ba5490ceffdf4f Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:17 +0530 Subject: ASoC: Intel: cnl: Unstatify common ipc functions Common ipc functions can be reused for cnl, so make them non-static. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-sst-ipc.c | 6 +++--- sound/soc/intel/skylake/skl-sst-ipc.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-sst-ipc.c b/sound/soc/intel/skylake/skl-sst-ipc.c index 498b153..5234faf 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.c +++ b/sound/soc/intel/skylake/skl-sst-ipc.c @@ -283,7 +283,7 @@ enum skl_ipc_module_msg { IPC_MOD_SET_D0IX = 8 }; -static void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data, +void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data, size_t tx_size) { if (tx_size) @@ -347,7 +347,7 @@ out: } -static int skl_ipc_process_notification(struct sst_generic_ipc *ipc, +int skl_ipc_process_notification(struct sst_generic_ipc *ipc, struct skl_ipc_header header) { struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc); @@ -406,7 +406,7 @@ static int skl_ipc_set_reply_error_code(u32 reply) } } -static void skl_ipc_process_reply(struct sst_generic_ipc *ipc, +void skl_ipc_process_reply(struct sst_generic_ipc *ipc, struct skl_ipc_header header) { struct ipc_message *msg; diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h index e485e8f..55f2d2c 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.h +++ b/sound/soc/intel/skylake/skl-sst-ipc.h @@ -212,4 +212,10 @@ void skl_ipc_free(struct sst_generic_ipc *ipc); int skl_ipc_init(struct device *dev, struct skl_sst *skl); void skl_clear_module_cnt(struct sst_dsp *ctx); +void skl_ipc_process_reply(struct sst_generic_ipc *ipc, + struct skl_ipc_header header); +int skl_ipc_process_notification(struct sst_generic_ipc *ipc, + struct skl_ipc_header header); +void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data, + size_t tx_size); #endif /* __SKL_IPC_H */ -- cgit v1.1 From cb6a552846297094aac942a588fe7ed7922a6c11 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:18 +0530 Subject: ASoC: Intel: cnl: Add sst library functions for cnl platform This adds the necessary DSP functions specific for the Cannonlake platform which includes firmware download using host DMA, DO/D3 handlers, irq_thread handlers and sst ops. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/Makefile | 5 +- sound/soc/intel/skylake/cnl-sst-dsp.h | 6 + sound/soc/intel/skylake/cnl-sst.c | 495 ++++++++++++++++++++++++++++++++++ 3 files changed, 504 insertions(+), 2 deletions(-) create mode 100644 sound/soc/intel/skylake/cnl-sst.c (limited to 'sound') diff --git a/sound/soc/intel/skylake/Makefile b/sound/soc/intel/skylake/Makefile index e7d7772..3380deb 100644 --- a/sound/soc/intel/skylake/Makefile +++ b/sound/soc/intel/skylake/Makefile @@ -8,7 +8,8 @@ endif obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o # Skylake IPC Support -snd-soc-skl-ipc-objs := skl-sst-ipc.o skl-sst-dsp.o skl-sst-cldma.o \ - skl-sst.o bxt-sst.o skl-sst-utils.o +snd-soc-skl-ipc-objs := skl-sst-ipc.o skl-sst-dsp.o cnl-sst-dsp.o \ + skl-sst-cldma.o skl-sst.o bxt-sst.o cnl-sst.o \ + skl-sst-utils.o obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl-ipc.o diff --git a/sound/soc/intel/skylake/cnl-sst-dsp.h b/sound/soc/intel/skylake/cnl-sst-dsp.h index 2fe41b1..09bd218 100644 --- a/sound/soc/intel/skylake/cnl-sst-dsp.h +++ b/sound/soc/intel/skylake/cnl-sst-dsp.h @@ -103,4 +103,10 @@ void cnl_ipc_op_int_disable(struct sst_dsp *ctx); bool cnl_ipc_int_status(struct sst_dsp *ctx); void cnl_ipc_free(struct sst_generic_ipc *ipc); +int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, + const char *fw_name, struct skl_dsp_loader_ops dsp_ops, + struct skl_sst **dsp); +int cnl_sst_init_fw(struct device *dev, struct skl_sst *ctx); +void cnl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx); + #endif /*__CNL_SST_DSP_H__*/ diff --git a/sound/soc/intel/skylake/cnl-sst.c b/sound/soc/intel/skylake/cnl-sst.c new file mode 100644 index 0000000..7dcfe66 --- /dev/null +++ b/sound/soc/intel/skylake/cnl-sst.c @@ -0,0 +1,495 @@ +/* + * cnl-sst.c - DSP library functions for CNL platform + * + * Copyright (C) 2016-17, Intel Corporation. + * + * Author: Guneshwor Singh + * + * Modified from: + * HDA DSP library functions for SKL platform + * Copyright (C) 2014-15, Intel Corporation. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as 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. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include +#include +#include +#include + +#include "../common/sst-dsp.h" +#include "../common/sst-dsp-priv.h" +#include "../common/sst-ipc.h" +#include "cnl-sst-dsp.h" +#include "skl-sst-dsp.h" +#include "skl-sst-ipc.h" + +#define CNL_FW_ROM_INIT 0x1 +#define CNL_FW_INIT 0x5 +#define CNL_IPC_PURGE 0x01004000 +#define CNL_INIT_TIMEOUT 300 +#define CNL_BASEFW_TIMEOUT 3000 + +#define CNL_ADSP_SRAM0_BASE 0x80000 + +/* Firmware status window */ +#define CNL_ADSP_FW_STATUS CNL_ADSP_SRAM0_BASE +#define CNL_ADSP_ERROR_CODE (CNL_ADSP_FW_STATUS + 0x4) + +#define CNL_INSTANCE_ID 0 +#define CNL_BASE_FW_MODULE_ID 0 +#define CNL_ADSP_FW_HDR_OFFSET 0x2000 +#define CNL_ROM_CTRL_DMA_ID 0x9 + +static int cnl_prepare_fw(struct sst_dsp *ctx, const void *fwdata, u32 fwsize) +{ + + int ret, stream_tag; + + stream_tag = ctx->dsp_ops.prepare(ctx->dev, 0x40, fwsize, &ctx->dmab); + if (stream_tag <= 0) { + dev_err(ctx->dev, "dma prepare failed: 0%#x\n", stream_tag); + return stream_tag; + } + + ctx->dsp_ops.stream_tag = stream_tag; + memcpy(ctx->dmab.area, fwdata, fwsize); + + /* purge FW request */ + sst_dsp_shim_write(ctx, CNL_ADSP_REG_HIPCIDR, + CNL_ADSP_REG_HIPCIDR_BUSY | (CNL_IPC_PURGE | + ((stream_tag - 1) << CNL_ROM_CTRL_DMA_ID))); + + ret = cnl_dsp_enable_core(ctx, SKL_DSP_CORE0_MASK); + if (ret < 0) { + dev_err(ctx->dev, "dsp boot core failed ret: %d\n", ret); + ret = -EIO; + goto base_fw_load_failed; + } + + /* enable interrupt */ + cnl_ipc_int_enable(ctx); + cnl_ipc_op_int_enable(ctx); + + ret = sst_dsp_register_poll(ctx, CNL_ADSP_FW_STATUS, CNL_FW_STS_MASK, + CNL_FW_ROM_INIT, CNL_INIT_TIMEOUT, + "rom load"); + if (ret < 0) { + dev_err(ctx->dev, "rom init timeout, ret: %d\n", ret); + goto base_fw_load_failed; + } + + return 0; + +base_fw_load_failed: + ctx->dsp_ops.cleanup(ctx->dev, &ctx->dmab, stream_tag); + cnl_dsp_disable_core(ctx, SKL_DSP_CORE0_MASK); + + return ret; +} + +static int sst_transfer_fw_host_dma(struct sst_dsp *ctx) +{ + int ret; + + ctx->dsp_ops.trigger(ctx->dev, true, ctx->dsp_ops.stream_tag); + ret = sst_dsp_register_poll(ctx, CNL_ADSP_FW_STATUS, CNL_FW_STS_MASK, + CNL_FW_INIT, CNL_BASEFW_TIMEOUT, + "firmware boot"); + + ctx->dsp_ops.trigger(ctx->dev, false, ctx->dsp_ops.stream_tag); + ctx->dsp_ops.cleanup(ctx->dev, &ctx->dmab, ctx->dsp_ops.stream_tag); + + return ret; +} + +static int cnl_load_base_firmware(struct sst_dsp *ctx) +{ + struct firmware stripped_fw; + struct skl_sst *cnl = ctx->thread_context; + int ret; + + if (!ctx->fw) { + ret = request_firmware(&ctx->fw, ctx->fw_name, ctx->dev); + if (ret < 0) { + dev_err(ctx->dev, "request firmware failed: %d\n", ret); + goto cnl_load_base_firmware_failed; + } + } + + /* parse uuids if first boot */ + if (cnl->is_first_boot) { + ret = snd_skl_parse_uuids(ctx, ctx->fw, + CNL_ADSP_FW_HDR_OFFSET, 0); + if (ret < 0) + goto cnl_load_base_firmware_failed; + } + + stripped_fw.data = ctx->fw->data; + stripped_fw.size = ctx->fw->size; + skl_dsp_strip_extended_manifest(&stripped_fw); + + ret = cnl_prepare_fw(ctx, stripped_fw.data, stripped_fw.size); + if (ret < 0) { + dev_err(ctx->dev, "prepare firmware failed: %d\n", ret); + goto cnl_load_base_firmware_failed; + } + + ret = sst_transfer_fw_host_dma(ctx); + if (ret < 0) { + dev_err(ctx->dev, "transfer firmware failed: %d\n", ret); + cnl_dsp_disable_core(ctx, SKL_DSP_CORE0_MASK); + goto cnl_load_base_firmware_failed; + } + + ret = wait_event_timeout(cnl->boot_wait, cnl->boot_complete, + msecs_to_jiffies(SKL_IPC_BOOT_MSECS)); + if (ret == 0) { + dev_err(ctx->dev, "FW ready timed-out\n"); + cnl_dsp_disable_core(ctx, SKL_DSP_CORE0_MASK); + ret = -EIO; + goto cnl_load_base_firmware_failed; + } + + cnl->fw_loaded = true; + + return 0; + +cnl_load_base_firmware_failed: + release_firmware(ctx->fw); + ctx->fw = NULL; + + return ret; +} + +static int cnl_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id) +{ + struct skl_sst *cnl = ctx->thread_context; + unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); + struct skl_ipc_dxstate_info dx; + int ret; + + if (!cnl->fw_loaded) { + cnl->boot_complete = false; + ret = cnl_load_base_firmware(ctx); + if (ret < 0) { + dev_err(ctx->dev, "fw reload failed: %d\n", ret); + return ret; + } + + cnl->cores.state[core_id] = SKL_DSP_RUNNING; + return ret; + } + + ret = cnl_dsp_enable_core(ctx, core_mask); + if (ret < 0) { + dev_err(ctx->dev, "enable dsp core %d failed: %d\n", + core_id, ret); + goto err; + } + + if (core_id == SKL_DSP_CORE0_ID) { + /* enable interrupt */ + cnl_ipc_int_enable(ctx); + cnl_ipc_op_int_enable(ctx); + cnl->boot_complete = false; + + ret = wait_event_timeout(cnl->boot_wait, cnl->boot_complete, + msecs_to_jiffies(SKL_IPC_BOOT_MSECS)); + if (ret == 0) { + dev_err(ctx->dev, + "dsp boot timeout, status=%#x error=%#x\n", + sst_dsp_shim_read(ctx, CNL_ADSP_FW_STATUS), + sst_dsp_shim_read(ctx, CNL_ADSP_ERROR_CODE)); + goto err; + } + } else { + dx.core_mask = core_mask; + dx.dx_mask = core_mask; + + ret = skl_ipc_set_dx(&cnl->ipc, CNL_INSTANCE_ID, + CNL_BASE_FW_MODULE_ID, &dx); + if (ret < 0) { + dev_err(ctx->dev, "set_dx failed, core: %d ret: %d\n", + core_id, ret); + goto err; + } + } + cnl->cores.state[core_id] = SKL_DSP_RUNNING; + + return 0; +err: + cnl_dsp_disable_core(ctx, core_mask); + + return ret; +} + +static int cnl_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id) +{ + struct skl_sst *cnl = ctx->thread_context; + unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); + struct skl_ipc_dxstate_info dx; + int ret; + + dx.core_mask = core_mask; + dx.dx_mask = SKL_IPC_D3_MASK; + + ret = skl_ipc_set_dx(&cnl->ipc, CNL_INSTANCE_ID, + CNL_BASE_FW_MODULE_ID, &dx); + if (ret < 0) { + dev_err(ctx->dev, + "dsp core %d to d3 failed; continue reset\n", + core_id); + cnl->fw_loaded = false; + } + + /* disable interrupts if core 0 */ + if (core_id == SKL_DSP_CORE0_ID) { + skl_ipc_op_int_disable(ctx); + skl_ipc_int_disable(ctx); + } + + ret = cnl_dsp_disable_core(ctx, core_mask); + if (ret < 0) { + dev_err(ctx->dev, "disable dsp core %d failed: %d\n", + core_id, ret); + return ret; + } + + cnl->cores.state[core_id] = SKL_DSP_RESET; + + return ret; +} + +static unsigned int cnl_get_errno(struct sst_dsp *ctx) +{ + return sst_dsp_shim_read(ctx, CNL_ADSP_ERROR_CODE); +} + +static struct skl_dsp_fw_ops cnl_fw_ops = { + .set_state_D0 = cnl_set_dsp_D0, + .set_state_D3 = cnl_set_dsp_D3, + .load_fw = cnl_load_base_firmware, + .get_fw_errcode = cnl_get_errno, +}; + +static struct sst_ops cnl_ops = { + .irq_handler = cnl_dsp_sst_interrupt, + .write = sst_shim32_write, + .read = sst_shim32_read, + .ram_read = sst_memcpy_fromio_32, + .ram_write = sst_memcpy_toio_32, + .free = cnl_dsp_free, +}; + +#define CNL_IPC_GLB_NOTIFY_RSP_SHIFT 29 +#define CNL_IPC_GLB_NOTIFY_RSP_MASK 0x1 +#define CNL_IPC_GLB_NOTIFY_RSP_TYPE(x) (((x) >> CNL_IPC_GLB_NOTIFY_RSP_SHIFT) \ + & CNL_IPC_GLB_NOTIFY_RSP_MASK) + +static irqreturn_t cnl_dsp_irq_thread_handler(int irq, void *context) +{ + struct sst_dsp *dsp = context; + struct skl_sst *cnl = sst_dsp_get_thread_context(dsp); + struct sst_generic_ipc *ipc = &cnl->ipc; + struct skl_ipc_header header = {0}; + u32 hipcida, hipctdr, hipctdd; + int ipc_irq = 0; + + /* here we handle ipc interrupts only */ + if (!(dsp->intr_status & CNL_ADSPIS_IPC)) + return IRQ_NONE; + + hipcida = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCIDA); + hipctdr = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCTDR); + + /* reply message from dsp */ + if (hipcida & CNL_ADSP_REG_HIPCIDA_DONE) { + sst_dsp_shim_update_bits(dsp, CNL_ADSP_REG_HIPCCTL, + CNL_ADSP_REG_HIPCCTL_DONE, 0); + + /* clear done bit - tell dsp operation is complete */ + sst_dsp_shim_update_bits_forced(dsp, CNL_ADSP_REG_HIPCIDA, + CNL_ADSP_REG_HIPCIDA_DONE, CNL_ADSP_REG_HIPCIDA_DONE); + + ipc_irq = 1; + + /* unmask done interrupt */ + sst_dsp_shim_update_bits(dsp, CNL_ADSP_REG_HIPCCTL, + CNL_ADSP_REG_HIPCCTL_DONE, CNL_ADSP_REG_HIPCCTL_DONE); + } + + /* new message from dsp */ + if (hipctdr & CNL_ADSP_REG_HIPCTDR_BUSY) { + hipctdd = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCTDD); + header.primary = hipctdr; + header.extension = hipctdd; + dev_dbg(dsp->dev, "IPC irq: Firmware respond primary:%x", + header.primary); + dev_dbg(dsp->dev, "IPC irq: Firmware respond extension:%x", + header.extension); + + if (CNL_IPC_GLB_NOTIFY_RSP_TYPE(header.primary)) { + /* Handle Immediate reply from DSP Core */ + skl_ipc_process_reply(ipc, header); + } else { + dev_dbg(dsp->dev, "IPC irq: Notification from firmware\n"); + skl_ipc_process_notification(ipc, header); + } + /* clear busy interrupt */ + sst_dsp_shim_update_bits_forced(dsp, CNL_ADSP_REG_HIPCTDR, + CNL_ADSP_REG_HIPCTDR_BUSY, CNL_ADSP_REG_HIPCTDR_BUSY); + + /* set done bit to ack dsp */ + sst_dsp_shim_update_bits_forced(dsp, CNL_ADSP_REG_HIPCTDA, + CNL_ADSP_REG_HIPCTDA_DONE, CNL_ADSP_REG_HIPCTDA_DONE); + ipc_irq = 1; + } + + if (ipc_irq == 0) + return IRQ_NONE; + + cnl_ipc_int_enable(dsp); + + /* continue to send any remaining messages */ + schedule_work(&ipc->kwork); + + return IRQ_HANDLED; +} + +static struct sst_dsp_device cnl_dev = { + .thread = cnl_dsp_irq_thread_handler, + .ops = &cnl_ops, +}; + +static void cnl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg) +{ + struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->header); + + if (msg->tx_size) + sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size); + sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDD, + header->extension); + sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDR, + header->primary | CNL_ADSP_REG_HIPCIDR_BUSY); +} + +static bool cnl_ipc_is_dsp_busy(struct sst_dsp *dsp) +{ + u32 hipcidr; + + hipcidr = sst_dsp_shim_read_unlocked(dsp, CNL_ADSP_REG_HIPCIDR); + + return (hipcidr & CNL_ADSP_REG_HIPCIDR_BUSY); +} + +static int cnl_ipc_init(struct device *dev, struct skl_sst *cnl) +{ + struct sst_generic_ipc *ipc; + int err; + + ipc = &cnl->ipc; + ipc->dsp = cnl->dsp; + ipc->dev = dev; + + ipc->tx_data_max_size = CNL_ADSP_W1_SZ; + ipc->rx_data_max_size = CNL_ADSP_W0_UP_SZ; + + err = sst_ipc_init(ipc); + if (err) + return err; + + /* + * overriding tx_msg and is_dsp_busy since + * ipc registers are different for cnl + */ + ipc->ops.tx_msg = cnl_ipc_tx_msg; + ipc->ops.tx_data_copy = skl_ipc_tx_data_copy; + ipc->ops.is_dsp_busy = cnl_ipc_is_dsp_busy; + + return 0; +} + +int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, + const char *fw_name, struct skl_dsp_loader_ops dsp_ops, + struct skl_sst **dsp) +{ + struct skl_sst *cnl; + struct sst_dsp *sst; + int ret; + + ret = skl_sst_ctx_init(dev, irq, fw_name, dsp_ops, dsp, &cnl_dev); + if (ret < 0) { + dev_err(dev, "%s: no device\n", __func__); + return ret; + } + + cnl = *dsp; + sst = cnl->dsp; + sst->fw_ops = cnl_fw_ops; + sst->addr.lpe = mmio_base; + sst->addr.shim = mmio_base; + sst->addr.sram0_base = CNL_ADSP_SRAM0_BASE; + sst->addr.sram1_base = CNL_ADSP_SRAM1_BASE; + sst->addr.w0_stat_sz = CNL_ADSP_W0_STAT_SZ; + sst->addr.w0_up_sz = CNL_ADSP_W0_UP_SZ; + + sst_dsp_mailbox_init(sst, (CNL_ADSP_SRAM0_BASE + CNL_ADSP_W0_STAT_SZ), + CNL_ADSP_W0_UP_SZ, CNL_ADSP_SRAM1_BASE, + CNL_ADSP_W1_SZ); + + ret = cnl_ipc_init(dev, cnl); + if (ret) + return ret; + + cnl->boot_complete = false; + init_waitqueue_head(&cnl->boot_wait); + + return 0; +} +EXPORT_SYMBOL_GPL(cnl_sst_dsp_init); + +int cnl_sst_init_fw(struct device *dev, struct skl_sst *ctx) +{ + int ret; + struct sst_dsp *sst = ctx->dsp; + + ret = ctx->dsp->fw_ops.load_fw(sst); + if (ret < 0) { + dev_err(dev, "load base fw failed: %d", ret); + return ret; + } + + skl_dsp_init_core_state(sst); + + ctx->is_first_boot = false; + + return 0; +} +EXPORT_SYMBOL_GPL(cnl_sst_init_fw); + +void cnl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) +{ + if (ctx->dsp->fw) + release_firmware(ctx->dsp->fw); + + skl_freeup_uuid_list(ctx); + cnl_ipc_free(&ctx->ipc); + + ctx->dsp->ops->free(ctx->dsp); +} +EXPORT_SYMBOL_GPL(cnl_sst_dsp_cleanup); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Intel Cannonlake IPC driver"); -- cgit v1.1 From b003a345dc67c7a1c468ad8ff10b24d7dd12e12c Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:19 +0530 Subject: ASoC: Intel: cnl: add dsp ops for cannonlake Add cannonlake dsp support by adding its dsp_ops. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index c6b60ee..bfb3332 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -22,6 +22,7 @@ #include #include #include "skl-sst-dsp.h" +#include "cnl-sst-dsp.h" #include "skl-sst-ipc.h" #include "skl.h" #include "../common/sst-dsp.h" @@ -231,6 +232,14 @@ static const struct skl_dsp_ops dsp_ops[] = { .init_fw = bxt_sst_init_fw, .cleanup = bxt_sst_dsp_cleanup }, + { + .id = 0x9dc8, + .num_cores = 4, + .loader_ops = bxt_get_loader_ops, + .init = cnl_sst_dsp_init, + .init_fw = cnl_sst_init_fw, + .cleanup = cnl_sst_dsp_cleanup + }, }; const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id) -- cgit v1.1 From 86d7ce3dd717e09a442d35dae3f9c62c03e024d8 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Wed, 2 Aug 2017 21:51:20 +0530 Subject: ASoC: Intel: cnl: add pci id for cnl Enable cnl by adding its pci id in skl_ids[]. Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index ab65151..e612a40 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -996,6 +996,14 @@ static struct sst_acpi_mach sst_glk_devdata[] = { }, }; +static const struct sst_acpi_mach sst_cnl_devdata[] = { + { + .id = "INT34C2", + .drv_name = "cnl_rt274", + .fw_filename = "intel/dsp_fw_cnl.bin", + }, +}; + /* PCI IDs */ static const struct pci_device_id skl_ids[] = { /* Sunrise Point-LP */ @@ -1010,6 +1018,9 @@ static const struct pci_device_id skl_ids[] = { /* GLK */ { PCI_DEVICE(0x8086, 0x3198), .driver_data = (unsigned long)&sst_glk_devdata}, + /* CNL */ + { PCI_DEVICE(0x8086, 0x9dc8), + .driver_data = (unsigned long)&sst_cnl_devdata}, { 0, } }; MODULE_DEVICE_TABLE(pci, skl_ids); -- cgit v1.1 From 67e8ee9b4b387f5c4d12ad9b926a78a9bf3dc275 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 3 Aug 2017 23:20:01 +0530 Subject: ASoC: Intel: constify pci_device_id. pci_device_id are not supposed to change at runtime. All functions working with pci_device_id provided by work with const pci_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/atom/sst/sst_pci.c b/sound/soc/intel/atom/sst/sst_pci.c index 3a0b3bf..6906ee6 100644 --- a/sound/soc/intel/atom/sst/sst_pci.c +++ b/sound/soc/intel/atom/sst/sst_pci.c @@ -181,7 +181,7 @@ static void intel_sst_remove(struct pci_dev *pci) } /* PCI Routines */ -static struct pci_device_id intel_sst_ids[] = { +static const struct pci_device_id intel_sst_ids[] = { { PCI_VDEVICE(INTEL, SST_MRFLD_PCI_ID), 0}, { 0, } }; -- cgit v1.1 From 28a0989c995087129b11ca3e00eb37ab77c29bce Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 3 Aug 2017 20:20:40 +0900 Subject: ALSA: control: queue events within locking of controls_rwsem for TLV operation Any control event is queued by a call of snd_ctl_notify(). This function adds the event to each queue of opened file data corresponding to ALSA control character devices. This function acquired two types of lock; a counting semaphore for a list of the opened file data and a spinlock for card data opened by the file. Typically, this function is called after acquiring a counting semaphore for a list of elements in the card data. In current implementation of TLV request handler, the function is called after releasing the semaphore for a list of elements in the card data. This release is not necessarily needed. This commit removes the release to call the function within the critical section so that later commits are simple. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 3c6be14..d2e1edb 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1450,9 +1450,8 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv); if (err > 0) { struct snd_ctl_elem_id id = kctl->id; - up_read(&card->controls_rwsem); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id); - return 0; + err = 0; } } else { if (op_flag != SNDRV_CTL_TLV_OP_READ) { -- cgit v1.1 From 4c8099e9cad5ba11c770042549f68e7687eaa72b Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 3 Aug 2017 20:20:41 +0900 Subject: ALSA: control: use counting semaphore as write lock for TLV write/command operations In ALSA control interface, applications can execute three types of request for Type-Length-Value (TLV) data to a set of elements; read, write and command. In ALSA control core, all of the requests are handled within read lock to a counting semaphore, therefore several processes can run to access to the data at the same time for any purposes. This has an issue because write and command requests have side effect to change state of a set of elements for the TLV data. Concurrent access should be controlled for each of reference/change case. This commit uses the counting semaphore as read lock for TLV read requests, while use it as write lock for TLV write/command requests. The state of a set of elements for the TLV data is maintained exclusively between read requests and write/command requests, or between write and command requests. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 72 +++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index d2e1edb..f3bd9bd 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1414,7 +1414,6 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, struct snd_kcontrol *kctl; struct snd_kcontrol_volatile *vd; unsigned int len; - int err = 0; if (copy_from_user(&tlv, _tlv, sizeof(tlv))) return -EFAULT; @@ -1422,53 +1421,49 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, return -EINVAL; if (!tlv.numid) return -EINVAL; - down_read(&card->controls_rwsem); + kctl = snd_ctl_find_numid(card, tlv.numid); - if (kctl == NULL) { - err = -ENOENT; - goto __kctl_end; - } - if (kctl->tlv.p == NULL) { - err = -ENXIO; - goto __kctl_end; - } + if (kctl == NULL) + return -ENOENT; + + if (kctl->tlv.p == NULL) + return -ENXIO; + vd = &kctl->vd[tlv.numid - kctl->id.numid]; if ((op_flag == SNDRV_CTL_TLV_OP_READ && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) == 0) || (op_flag == SNDRV_CTL_TLV_OP_WRITE && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) == 0) || (op_flag == SNDRV_CTL_TLV_OP_CMD && - (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) { - err = -ENXIO; - goto __kctl_end; - } + (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) + return -ENXIO; + if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { - if (vd->owner != NULL && vd->owner != file) { - err = -EPERM; - goto __kctl_end; - } + int err; + + if (vd->owner != NULL && vd->owner != file) + return -EPERM; + err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv); + if (err < 0) + return err; if (err > 0) { struct snd_ctl_elem_id id = kctl->id; snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id); - err = 0; } } else { - if (op_flag != SNDRV_CTL_TLV_OP_READ) { - err = -ENXIO; - goto __kctl_end; - } + if (op_flag != SNDRV_CTL_TLV_OP_READ) + return -ENXIO; + len = kctl->tlv.p[1] + 2 * sizeof(unsigned int); - if (tlv.length < len) { - err = -ENOMEM; - goto __kctl_end; - } + if (tlv.length < len) + return -ENOMEM; + if (copy_to_user(_tlv->tlv, kctl->tlv.p, len)) - err = -EFAULT; + return -EFAULT; } - __kctl_end: - up_read(&card->controls_rwsem); - return err; + + return 0; } static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -1510,11 +1505,20 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg case SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS: return snd_ctl_subscribe_events(ctl, ip); case SNDRV_CTL_IOCTL_TLV_READ: - return snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_READ); + down_read(&ctl->card->controls_rwsem); + err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_READ); + up_read(&ctl->card->controls_rwsem); + return err; case SNDRV_CTL_IOCTL_TLV_WRITE: - return snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_WRITE); + down_write(&ctl->card->controls_rwsem); + err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_WRITE); + up_write(&ctl->card->controls_rwsem); + return err; case SNDRV_CTL_IOCTL_TLV_COMMAND: - return snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_CMD); + down_write(&ctl->card->controls_rwsem); + err = snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_CMD); + up_write(&ctl->card->controls_rwsem); + return err; case SNDRV_CTL_IOCTL_POWER: return -ENOPROTOOPT; case SNDRV_CTL_IOCTL_POWER_STATE: -- cgit v1.1 From 30d8340b5857550007ab6fe9744e4384dfa6e55c Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 3 Aug 2017 20:20:42 +0900 Subject: ALSA: control: obsolete user_ctl_lock At a previous commit, concurrent requests for TLV data are maintained exclusively between read requests and write/command requests. TLV callback handlers in each driver has no risk from concurrent access for reference/change. In current implementation, 'struct snd_card' has a mutex to control concurrent accesses to user-defined element sets. This commit obsoletes it. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 37 +++++++++++++------------------------ sound/core/init.c | 1 - 2 files changed, 13 insertions(+), 25 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index f3bd9bd..989292f 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1095,9 +1095,7 @@ static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol, char *src = ue->elem_data + snd_ctl_get_ioff(kcontrol, &ucontrol->id) * size; - mutex_lock(&ue->card->user_ctl_lock); memcpy(&ucontrol->value, src, size); - mutex_unlock(&ue->card->user_ctl_lock); return 0; } @@ -1110,11 +1108,9 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, char *dst = ue->elem_data + snd_ctl_get_ioff(kcontrol, &ucontrol->id) * size; - mutex_lock(&ue->card->user_ctl_lock); change = memcmp(&ucontrol->value, dst, size) != 0; if (change) memcpy(dst, &ucontrol->value, size); - mutex_unlock(&ue->card->user_ctl_lock); return change; } @@ -1124,44 +1120,37 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, unsigned int __user *tlv) { struct user_element *ue = kcontrol->private_data; - int change = 0; - void *new_data; if (op_flag == SNDRV_CTL_TLV_OP_WRITE) { + int change; + void *new_data; + if (size > 1024 * 128) /* sane value */ return -EINVAL; new_data = memdup_user(tlv, size); if (IS_ERR(new_data)) return PTR_ERR(new_data); - mutex_lock(&ue->card->user_ctl_lock); change = ue->tlv_data_size != size; if (!change) change = memcmp(ue->tlv_data, new_data, size); kfree(ue->tlv_data); ue->tlv_data = new_data; ue->tlv_data_size = size; - mutex_unlock(&ue->card->user_ctl_lock); + + return change; } else { - int ret = 0; + if (!ue->tlv_data_size || !ue->tlv_data) + return -ENXIO; + + if (size < ue->tlv_data_size) + return -ENOSPC; - mutex_lock(&ue->card->user_ctl_lock); - if (!ue->tlv_data_size || !ue->tlv_data) { - ret = -ENXIO; - goto err_unlock; - } - if (size < ue->tlv_data_size) { - ret = -ENOSPC; - goto err_unlock; - } if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size)) - ret = -EFAULT; -err_unlock: - mutex_unlock(&ue->card->user_ctl_lock); - if (ret) - return ret; + return -EFAULT; + + return 0; } - return change; } static int snd_ctl_elem_init_enum_names(struct user_element *ue) diff --git a/sound/core/init.c b/sound/core/init.c index b4365bc..6e219dc 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -248,7 +248,6 @@ int snd_card_new(struct device *parent, int idx, const char *xid, INIT_LIST_HEAD(&card->devices); init_rwsem(&card->controls_rwsem); rwlock_init(&card->ctl_files_rwlock); - mutex_init(&card->user_ctl_lock); INIT_LIST_HEAD(&card->controls); INIT_LIST_HEAD(&card->ctl_files); spin_lock_init(&card->files_lock); -- cgit v1.1 From 450296f305f139ccb363657efcea439afa4e762a Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 3 Aug 2017 20:20:43 +0900 Subject: ALSA: control: code refactoring TLV ioctl handler In a design of ALSA control core, execution path bifurcates depending on target element. When a set with the target element has a handler, it's called. Else, registered buffer is copied to user space. These two operations are apparently different. In current implementation, they're on the same function with a condition statement. This makes it a bit hard to understand conditions of each case. This commit splits codes for these two cases. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 132 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 91 insertions(+), 41 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 989292f..9238900 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1394,65 +1394,115 @@ static int snd_ctl_subscribe_events(struct snd_ctl_file *file, int __user *ptr) return 0; } +static int call_tlv_handler(struct snd_ctl_file *file, int op_flag, + struct snd_kcontrol *kctl, + struct snd_ctl_elem_id *id, + unsigned int __user *buf, unsigned int size) +{ + static const struct { + int op; + int perm; + } pairs[] = { + {SNDRV_CTL_TLV_OP_READ, SNDRV_CTL_ELEM_ACCESS_TLV_READ}, + {SNDRV_CTL_TLV_OP_WRITE, SNDRV_CTL_ELEM_ACCESS_TLV_WRITE}, + {SNDRV_CTL_TLV_OP_CMD, SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND}, + }; + struct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)]; + int i; + int err; + + /* Check support of the request for this element. */ + for (i = 0; i < ARRAY_SIZE(pairs); ++i) { + if (op_flag == pairs[i].op && (vd->access & pairs[i].perm)) + break; + } + if (i == ARRAY_SIZE(pairs)) + return -ENXIO; + + if (kctl->tlv.c == NULL) + return -ENXIO; + + /* When locked, this is unavailable. */ + if (vd->owner != NULL && vd->owner != file) + return -EPERM; + + err = kctl->tlv.c(kctl, op_flag, size, buf); + if (err < 0) + return err; + + if (err > 0) + snd_ctl_notify(file->card, SNDRV_CTL_EVENT_MASK_TLV, id); + + return 0; +} + +static int read_tlv_buf(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id, + unsigned int __user *buf, unsigned int size) +{ + struct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)]; + unsigned int len; + + if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)) + return -ENXIO; + + if (kctl->tlv.p == NULL) + return -ENXIO; + + len = sizeof(unsigned int) * 2 + kctl->tlv.p[1]; + if (size < len) + return -ENOMEM; + + if (copy_to_user(buf, kctl->tlv.p, len)) + return -EFAULT; + + return 0; +} + static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file, - struct snd_ctl_tlv __user *_tlv, + struct snd_ctl_tlv __user *buf, int op_flag) { - struct snd_card *card = file->card; - struct snd_ctl_tlv tlv; + struct snd_ctl_tlv header; + unsigned int *container; + unsigned int container_size; struct snd_kcontrol *kctl; + struct snd_ctl_elem_id id; struct snd_kcontrol_volatile *vd; - unsigned int len; - if (copy_from_user(&tlv, _tlv, sizeof(tlv))) + if (copy_from_user(&header, buf, sizeof(header))) return -EFAULT; - if (tlv.length < sizeof(unsigned int) * 2) + + /* In design of control core, numerical ID starts at 1. */ + if (header.numid == 0) return -EINVAL; - if (!tlv.numid) + + /* At least, container should include type and length fields. */ + if (header.length < sizeof(unsigned int) * 2) return -EINVAL; + container_size = header.length; + container = buf->tlv; - kctl = snd_ctl_find_numid(card, tlv.numid); + kctl = snd_ctl_find_numid(file->card, header.numid); if (kctl == NULL) return -ENOENT; - if (kctl->tlv.p == NULL) - return -ENXIO; - - vd = &kctl->vd[tlv.numid - kctl->id.numid]; - if ((op_flag == SNDRV_CTL_TLV_OP_READ && - (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) == 0) || - (op_flag == SNDRV_CTL_TLV_OP_WRITE && - (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) == 0) || - (op_flag == SNDRV_CTL_TLV_OP_CMD && - (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) - return -ENXIO; + /* Calculate index of the element in this set. */ + id = kctl->id; + snd_ctl_build_ioff(&id, kctl, header.numid - id.numid); + vd = &kctl->vd[snd_ctl_get_ioff(kctl, &id)]; if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { - int err; - - if (vd->owner != NULL && vd->owner != file) - return -EPERM; - - err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv); - if (err < 0) - return err; - if (err > 0) { - struct snd_ctl_elem_id id = kctl->id; - snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id); - } + return call_tlv_handler(file, op_flag, kctl, &id, container, + container_size); } else { - if (op_flag != SNDRV_CTL_TLV_OP_READ) - return -ENXIO; - - len = kctl->tlv.p[1] + 2 * sizeof(unsigned int); - if (tlv.length < len) - return -ENOMEM; - - if (copy_to_user(_tlv->tlv, kctl->tlv.p, len)) - return -EFAULT; + if (op_flag == SNDRV_CTL_TLV_OP_READ) { + return read_tlv_buf(kctl, &id, container, + container_size); + } } - return 0; + /* Not supported. */ + return -ENXIO; } static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -- cgit v1.1 From 6d4d41f011454240e6890068c41e7530fba9f387 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 3 Aug 2017 20:20:44 +0900 Subject: ALSA: control: code refactoring for TLV request handler to user element set User-defined element set registers own handler to get callbacks from TLV ioctl handler. In the handler, execution path bifurcates depending on requests from user space. At write request, container in given buffer is registered to the element set, or replaced old TLV data. At the read request, the registered data is copied to user space. The command request is not allowed. In current implementation, function of the handler includes codes for the two cases. This commit adds two helper functions for these cases so that readers can easily get the above design. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 76 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 30 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 9238900..9e7a457 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1114,43 +1114,59 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, return change; } -static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, - int op_flag, - unsigned int size, - unsigned int __user *tlv) +static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, + unsigned int size) { - struct user_element *ue = kcontrol->private_data; + struct user_element *ue = kctl->private_data; + unsigned int *container; + int change; - if (op_flag == SNDRV_CTL_TLV_OP_WRITE) { - int change; - void *new_data; + if (size > 1024 * 128) /* sane value */ + return -EINVAL; - if (size > 1024 * 128) /* sane value */ - return -EINVAL; + container = memdup_user(buf, size); + if (IS_ERR(container)) + return PTR_ERR(container); - new_data = memdup_user(tlv, size); - if (IS_ERR(new_data)) - return PTR_ERR(new_data); - change = ue->tlv_data_size != size; - if (!change) - change = memcmp(ue->tlv_data, new_data, size); - kfree(ue->tlv_data); - ue->tlv_data = new_data; - ue->tlv_data_size = size; - - return change; - } else { - if (!ue->tlv_data_size || !ue->tlv_data) - return -ENXIO; + change = ue->tlv_data_size != size; + if (!change) + change = memcmp(ue->tlv_data, container, size); + if (!change) { + kfree(container); + return 0; + } - if (size < ue->tlv_data_size) - return -ENOSPC; + kfree(ue->tlv_data); + ue->tlv_data = container; + ue->tlv_data_size = size; - if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size)) - return -EFAULT; + return change; +} - return 0; - } +static int read_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, + unsigned int size) +{ + struct user_element *ue = kctl->private_data; + + if (ue->tlv_data_size == 0 || ue->tlv_data == NULL) + return -ENXIO; + + if (size < ue->tlv_data_size) + return -ENOSPC; + + if (copy_to_user(buf, ue->tlv_data, ue->tlv_data_size)) + return -EFAULT; + + return 0; +} + +static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kctl, int op_flag, + unsigned int size, unsigned int __user *buf) +{ + if (op_flag == SNDRV_CTL_TLV_OP_WRITE) + return replace_user_tlv(kctl, buf, size); + else + return read_user_tlv(kctl, buf, size); } static int snd_ctl_elem_init_enum_names(struct user_element *ue) -- cgit v1.1 From 4647e8d512224265afad63aa27a6b22561f50d46 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Fri, 4 Aug 2017 21:04:41 +0530 Subject: ALSA: ice1712: add const to snd_ak4xxx_private structures Declare snd_ak4xxx_private structures as const as they are only passed to the function snd_ice1712_akm4xxx_init. This argument is of type const, so make the structures const. Done using Coccinelle: @match disable optional_qualifier@ identifier s; position p; @@ static struct snd_ak4xxx_private s@p={...}; @good1@ identifier match.s; position p; @@ snd_ice1712_akm4xxx_init(...,&s@p,...) @bad@ identifier match.s; position p!={match.p,good1.p}; @@ s@p @depends on !bad disable optional_qualifier@ identifier match.s; @@ static +const struct snd_ak4xxx_private s={...}; Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ice1712/delta.c | 12 ++++++------ sound/pci/ice1712/ews.c | 6 +++--- sound/pci/ice1712/hoontech.c | 2 +- sound/pci/ice1712/phase.c | 2 +- sound/pci/ice1712/revo.c | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index da5f37b..4e470f0 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -454,7 +454,7 @@ static struct snd_akm4xxx akm_audiophile = { } }; -static struct snd_ak4xxx_private akm_audiophile_priv = { +static const struct snd_ak4xxx_private akm_audiophile_priv = { .caddr = 2, .cif = 0, .data_mask = ICE1712_DELTA_AP_DOUT, @@ -475,7 +475,7 @@ static struct snd_akm4xxx akm_delta410 = { } }; -static struct snd_ak4xxx_private akm_delta410_priv = { +static const struct snd_ak4xxx_private akm_delta410_priv = { .caddr = 0, .cif = 0, .data_mask = ICE1712_DELTA_AP_DOUT, @@ -497,7 +497,7 @@ static struct snd_akm4xxx akm_delta1010lt = { } }; -static struct snd_ak4xxx_private akm_delta1010lt_priv = { +static const struct snd_ak4xxx_private akm_delta1010lt_priv = { .caddr = 2, .cif = 0, /* the default level of the CIF pin from AK4524 */ .data_mask = ICE1712_DELTA_1010LT_DOUT, @@ -519,7 +519,7 @@ static struct snd_akm4xxx akm_delta66e = { } }; -static struct snd_ak4xxx_private akm_delta66e_priv = { +static const struct snd_ak4xxx_private akm_delta66e_priv = { .caddr = 2, .cif = 0, /* the default level of the CIF pin from AK4524 */ .data_mask = ICE1712_DELTA_66E_DOUT, @@ -542,7 +542,7 @@ static struct snd_akm4xxx akm_delta44 = { } }; -static struct snd_ak4xxx_private akm_delta44_priv = { +static const struct snd_ak4xxx_private akm_delta44_priv = { .caddr = 2, .cif = 0, /* the default level of the CIF pin from AK4524 */ .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA, @@ -564,7 +564,7 @@ static struct snd_akm4xxx akm_vx442 = { } }; -static struct snd_ak4xxx_private akm_vx442_priv = { +static const struct snd_ak4xxx_private akm_vx442_priv = { .caddr = 2, .cif = 0, .data_mask = ICE1712_VX442_DOUT, diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index ec07136..5bc14e8 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -354,7 +354,7 @@ static struct snd_akm4xxx akm_ews88mt = { } }; -static struct snd_ak4xxx_private akm_ews88mt_priv = { +static const struct snd_ak4xxx_private akm_ews88mt_priv = { .caddr = 2, .cif = 1, /* CIF high */ .data_mask = ICE1712_EWS88_SERIAL_DATA, @@ -375,7 +375,7 @@ static struct snd_akm4xxx akm_ewx2496 = { } }; -static struct snd_ak4xxx_private akm_ewx2496_priv = { +static const struct snd_ak4xxx_private akm_ewx2496_priv = { .caddr = 2, .cif = 1, /* CIF high */ .data_mask = ICE1712_EWS88_SERIAL_DATA, @@ -396,7 +396,7 @@ static struct snd_akm4xxx akm_6fire = { } }; -static struct snd_ak4xxx_private akm_6fire_priv = { +static const struct snd_ak4xxx_private akm_6fire_priv = { .caddr = 2, .cif = 1, /* CIF high */ .data_mask = ICE1712_6FIRE_SERIAL_DATA, diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c index a40001c..de2fcc9 100644 --- a/sound/pci/ice1712/hoontech.c +++ b/sound/pci/ice1712/hoontech.c @@ -278,7 +278,7 @@ static int snd_ice1712_value_init(struct snd_ice1712 *ice) } }; - static struct snd_ak4xxx_private akm_stdsp24_mv_priv = { + static const struct snd_ak4xxx_private akm_stdsp24_mv_priv = { .caddr = 2, .cif = 1, /* CIF high */ .data_mask = ICE1712_STDSP24_SERIAL_DATA, diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index e9ca89c..4f85482 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c @@ -108,7 +108,7 @@ static struct snd_akm4xxx akm_phase22 = { .num_adcs = 2, }; -static struct snd_ak4xxx_private akm_phase22_priv = { +static const struct snd_ak4xxx_private akm_phase22_priv = { .caddr = 2, .cif = 1, .data_mask = 1 << 4, diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c index 1d81ae6..5cc4213 100644 --- a/sound/pci/ice1712/revo.c +++ b/sound/pci/ice1712/revo.c @@ -244,7 +244,7 @@ static struct snd_akm4xxx akm_revo_front = { .dac_info = revo71_front, }; -static struct snd_ak4xxx_private akm_revo_front_priv = { +static const struct snd_ak4xxx_private akm_revo_front_priv = { .caddr = 1, .cif = 0, .data_mask = VT1724_REVO_CDOUT, @@ -266,7 +266,7 @@ static struct snd_akm4xxx akm_revo_surround = { .dac_info = revo71_surround, }; -static struct snd_ak4xxx_private akm_revo_surround_priv = { +static const struct snd_ak4xxx_private akm_revo_surround_priv = { .caddr = 3, .cif = 0, .data_mask = VT1724_REVO_CDOUT, @@ -287,7 +287,7 @@ static struct snd_akm4xxx akm_revo51 = { .dac_info = revo51_dac, }; -static struct snd_ak4xxx_private akm_revo51_priv = { +static const struct snd_ak4xxx_private akm_revo51_priv = { .caddr = 2, .cif = 0, .data_mask = VT1724_REVO_CDOUT, @@ -305,7 +305,7 @@ static struct snd_akm4xxx akm_revo51_adc = { .adc_info = revo51_adc, }; -static struct snd_ak4xxx_private akm_revo51_adc_priv = { +static const struct snd_ak4xxx_private akm_revo51_adc_priv = { .caddr = 2, .cif = 0, .data_mask = VT1724_REVO_CDOUT, @@ -355,7 +355,7 @@ static struct snd_akm4xxx akm_ap192 = { .dac_info = ap192_dac, }; -static struct snd_ak4xxx_private akm_ap192_priv = { +static const struct snd_ak4xxx_private akm_ap192_priv = { .caddr = 2, .cif = 0, .data_mask = VT1724_REVO_CDOUT, -- cgit v1.1 From 3135432e429ef9b69f75ad06e81071e648753a26 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Fri, 4 Aug 2017 23:19:30 +0530 Subject: ALSA: ice1712: add const to snd_akm4xxx structures Declare snd_akm4xxx structures as const as they are only passed to the function snd_ice1712_akm4xxx_init. This argument is of type const, so make the structures const. Done using Coccinelle: @match disable optional_qualifier@ identifier s; position p; @@ static struct snd_akm4xxx s@p={...}; @good1@ identifier match.s; position p; @@ snd_ice1712_akm4xxx_init(...,&s@p,...) @bad@ identifier match.s; position p!={match.p,good1.p}; @@ s@p @depends on !bad disable optional_qualifier@ identifier match.s; @@ static +const struct snd_akm4xxx s={...}; Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ice1712/delta.c | 12 ++++++------ sound/pci/ice1712/ews.c | 6 +++--- sound/pci/ice1712/hoontech.c | 2 +- sound/pci/ice1712/juli.c | 2 +- sound/pci/ice1712/phase.c | 2 +- sound/pci/ice1712/quartet.c | 2 +- sound/pci/ice1712/revo.c | 10 +++++----- 7 files changed, 18 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index 4e470f0..6808bed 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -445,7 +445,7 @@ static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status = * initialize the chips on M-Audio cards */ -static struct snd_akm4xxx akm_audiophile = { +static const struct snd_akm4xxx akm_audiophile = { .type = SND_AK4528, .num_adcs = 2, .num_dacs = 2, @@ -466,7 +466,7 @@ static const struct snd_ak4xxx_private akm_audiophile_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_delta410 = { +static const struct snd_akm4xxx akm_delta410 = { .type = SND_AK4529, .num_adcs = 2, .num_dacs = 8, @@ -487,7 +487,7 @@ static const struct snd_ak4xxx_private akm_delta410_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_delta1010lt = { +static const struct snd_akm4xxx akm_delta1010lt = { .type = SND_AK4524, .num_adcs = 8, .num_dacs = 8, @@ -509,7 +509,7 @@ static const struct snd_ak4xxx_private akm_delta1010lt_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_delta66e = { +static const struct snd_akm4xxx akm_delta66e = { .type = SND_AK4524, .num_adcs = 4, .num_dacs = 4, @@ -532,7 +532,7 @@ static const struct snd_ak4xxx_private akm_delta66e_priv = { }; -static struct snd_akm4xxx akm_delta44 = { +static const struct snd_akm4xxx akm_delta44 = { .type = SND_AK4524, .num_adcs = 4, .num_dacs = 4, @@ -554,7 +554,7 @@ static const struct snd_ak4xxx_private akm_delta44_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_vx442 = { +static const struct snd_akm4xxx akm_vx442 = { .type = SND_AK4524, .num_adcs = 4, .num_dacs = 4, diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index 5bc14e8..b8af747 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -344,7 +344,7 @@ static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate) /* */ -static struct snd_akm4xxx akm_ews88mt = { +static const struct snd_akm4xxx akm_ews88mt = { .num_adcs = 8, .num_dacs = 8, .type = SND_AK4524, @@ -366,7 +366,7 @@ static const struct snd_ak4xxx_private akm_ews88mt_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_ewx2496 = { +static const struct snd_akm4xxx akm_ewx2496 = { .num_adcs = 2, .num_dacs = 2, .type = SND_AK4524, @@ -387,7 +387,7 @@ static const struct snd_ak4xxx_private akm_ewx2496_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_6fire = { +static const struct snd_akm4xxx akm_6fire = { .num_adcs = 6, .num_dacs = 6, .type = SND_AK4524, diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c index de2fcc9..f37ed0b 100644 --- a/sound/pci/ice1712/hoontech.c +++ b/sound/pci/ice1712/hoontech.c @@ -269,7 +269,7 @@ static void stdsp24_ak4524_lock(struct snd_akm4xxx *ak, int chip) static int snd_ice1712_value_init(struct snd_ice1712 *ice) { /* Hoontech STDSP24 with modified hardware */ - static struct snd_akm4xxx akm_stdsp24_mv = { + static const struct snd_akm4xxx akm_stdsp24_mv = { .num_adcs = 2, .num_dacs = 2, .type = SND_AK4524, diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 5bb1467..0dbaccf 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -282,7 +282,7 @@ static const struct snd_akm4xxx_dac_channel juli_dac[] = { }; -static struct snd_akm4xxx akm_juli_dac = { +static const struct snd_akm4xxx akm_juli_dac = { .type = SND_AK4358, .num_dacs = 8, /* DAC1 - analog out DAC2 - analog in monitor diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index 4f85482..67fbb28 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c @@ -102,7 +102,7 @@ static const unsigned char wm_vol[256] = { #define WM_VOL_MAX (sizeof(wm_vol) - 1) #define WM_VOL_MUTE 0x8000 -static struct snd_akm4xxx akm_phase22 = { +static const struct snd_akm4xxx akm_phase22 = { .type = SND_AK4524, .num_dacs = 2, .num_adcs = 2, diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c index f1b3732..d145b5e 100644 --- a/sound/pci/ice1712/quartet.c +++ b/sound/pci/ice1712/quartet.c @@ -386,7 +386,7 @@ static const struct snd_akm4xxx_adc_channel qtet_adc[] = { AK_CONTROL(PCM_34_CAPTURE_VOLUME, 2), }; -static struct snd_akm4xxx akm_qtet_dac = { +static const struct snd_akm4xxx akm_qtet_dac = { .type = SND_AK4620, .num_dacs = 4, /* DAC1 - Output 12 */ diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c index 5cc4213..6669c38 100644 --- a/sound/pci/ice1712/revo.c +++ b/sound/pci/ice1712/revo.c @@ -235,7 +235,7 @@ static const struct snd_akm4xxx_adc_channel revo51_adc[] = { }, }; -static struct snd_akm4xxx akm_revo_front = { +static const struct snd_akm4xxx akm_revo_front = { .type = SND_AK4381, .num_dacs = 2, .ops = { @@ -256,7 +256,7 @@ static const struct snd_ak4xxx_private akm_revo_front_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_revo_surround = { +static const struct snd_akm4xxx akm_revo_surround = { .type = SND_AK4355, .idx_offset = 1, .num_dacs = 6, @@ -278,7 +278,7 @@ static const struct snd_ak4xxx_private akm_revo_surround_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_revo51 = { +static const struct snd_akm4xxx akm_revo51 = { .type = SND_AK4358, .num_dacs = 8, .ops = { @@ -299,7 +299,7 @@ static const struct snd_ak4xxx_private akm_revo51_priv = { .mask_flags = 0, }; -static struct snd_akm4xxx akm_revo51_adc = { +static const struct snd_akm4xxx akm_revo51_adc = { .type = SND_AK5365, .num_adcs = 2, .adc_info = revo51_adc, @@ -346,7 +346,7 @@ static const struct snd_akm4xxx_dac_channel ap192_dac[] = { AK_DAC("PCM Playback Volume", 2) }; -static struct snd_akm4xxx akm_ap192 = { +static const struct snd_akm4xxx akm_ap192 = { .type = SND_AK4358, .num_dacs = 2, .ops = { -- cgit v1.1 From 2357f6f00098a437f9de084c3c34254d20dea789 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Sat, 5 Aug 2017 14:05:46 +0530 Subject: ALSA: hda: Add Cannonlake PCI ID Cannonlake is next generation Intel platform. This commit adds PCI ID for it. Signed-off-by: Guneshwor Singh Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 5ae8dda..f958d8d 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2389,6 +2389,9 @@ static const struct pci_device_id azx_ids[] = { /* Coffelake */ { PCI_DEVICE(0x8086, 0xa348), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, + /* Cannonlake */ + { PCI_DEVICE(0x8086, 0x9dc8), + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, /* Broxton-P(Apollolake) */ { PCI_DEVICE(0x8086, 0x5a98), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_BROXTON }, -- cgit v1.1 From 05d72cd5f1f03531e1e678f476bbe207a29ede87 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:53 +0530 Subject: ALSA: 6fire: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/6fire/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c index dcddfc3..bc2a24f 100644 --- a/sound/usb/6fire/chip.c +++ b/sound/usb/6fire/chip.c @@ -198,7 +198,7 @@ static void usb6fire_chip_disconnect(struct usb_interface *intf) } } -static struct usb_device_id device_table[] = { +static const struct usb_device_id device_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = 0x0ccd, -- cgit v1.1 From 5e055ea2117cb0bc840e72b5f506c2c460cfb1da Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:54 +0530 Subject: ALSA: bcd2000: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/bcd2000/bcd2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/bcd2000/bcd2000.c b/sound/usb/bcd2000/bcd2000.c index 2ff9d57..7371e5b 100644 --- a/sound/usb/bcd2000/bcd2000.c +++ b/sound/usb/bcd2000/bcd2000.c @@ -29,7 +29,7 @@ #define PREFIX "snd-bcd2000: " #define BUFSIZE 64 -static struct usb_device_id id_table[] = { +static const struct usb_device_id id_table[] = { { USB_DEVICE(0x1397, 0x00bd) }, { }, }; -- cgit v1.1 From 57ee11eaa1e985d73a2762d28ee1eeef037d10ec Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:55 +0530 Subject: ALSA: snd-usb-caiaq: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/caiaq/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index b871ba4..0fb6b1b7 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c @@ -81,7 +81,7 @@ enum { DEPTH_32 = 3 }; -static struct usb_device_id snd_usb_id_table[] = { +static const struct usb_device_id snd_usb_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = USB_VID_NATIVEINSTRUMENTS, -- cgit v1.1 From 8824ae2de876f7e73ca64937dca88e558db5b681 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:56 +0530 Subject: ALSA: usb-audio: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/card.c b/sound/usb/card.c index 6640277..3dc36d9 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -486,7 +486,7 @@ static bool get_alias_id(struct usb_device *dev, unsigned int *id) return false; } -static struct usb_device_id usb_audio_ids[]; /* defined below */ +static const struct usb_device_id usb_audio_ids[]; /* defined below */ /* look for the corresponding quirk */ static const struct snd_usb_audio_quirk * @@ -814,7 +814,7 @@ static int usb_audio_reset_resume(struct usb_interface *intf) #define usb_audio_reset_resume NULL #endif /* CONFIG_PM */ -static struct usb_device_id usb_audio_ids [] = { +static const struct usb_device_id usb_audio_ids [] = { #include "quirks-table.h" { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS), .bInterfaceClass = USB_CLASS_AUDIO, -- cgit v1.1 From 20ec43e22727086f508d28109867c451ede497d3 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:57 +0530 Subject: ALSA: ua101: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/misc/ua101.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index c19a5dd..b05cd38 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -1366,7 +1366,7 @@ static void ua101_disconnect(struct usb_interface *interface) mutex_unlock(&devices_mutex); } -static struct usb_device_id ua101_ids[] = { +static const struct usb_device_id ua101_ids[] = { { USB_DEVICE(0x0582, 0x0044) }, /* UA-1000 high speed */ { USB_DEVICE(0x0582, 0x007d) }, /* UA-101 high speed */ { USB_DEVICE(0x0582, 0x008d) }, /* UA-101 full speed */ -- cgit v1.1 From 7ab64aeb67b2eea6ceb42739f686858be47d4ac5 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:58 +0530 Subject: ALSA: us122l: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/usx2y/us122l.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index a33e31b2..b49d6e9 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -736,7 +736,7 @@ unlock: return err; } -static struct usb_device_id snd_us122l_usb_id_table[] = { +static const struct usb_device_id snd_us122l_usb_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = 0x0644, -- cgit v1.1 From 5e463d6d292a259bd1b50c56d9b2a547fc907afd Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Sun, 6 Aug 2017 12:18:59 +0530 Subject: ALSA: usbusx2y: constify usb_device_id. usb_device_id are not supposed to change at runtime. All functions working with usb_device_id provided by work with const usb_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usbusx2y.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 91e0e2a..4569c0e 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -313,7 +313,7 @@ static void usX2Y_unlinkSeq(struct snd_usX2Y_AsyncSeq *S) } -static struct usb_device_id snd_usX2Y_usb_id_table[] = { +static const struct usb_device_id snd_usX2Y_usb_id_table[] = { { .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = 0x1604, -- cgit v1.1 From 8d7313bfb1bb7d71a6ebc503215e4fb4a8964741 Mon Sep 17 00:00:00 2001 From: Christophe Jaillet Date: Mon, 7 Aug 2017 02:23:15 +0200 Subject: ASoC: mediatek: Fix an error checking code Check the value returned by 'devm_clk_get()' instead of the clock identifier which can never be an ERR code. Fixes: d6f3710a56e1 ("ASoC: mediatek: add structure define and clock control for 2701") Signed-off-by: Christophe JAILLET Signed-off-by: Mark Brown --- sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c index b815ecc..affa7fb 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-clock-ctrl.c @@ -75,7 +75,7 @@ int mt2701_init_clock(struct mtk_base_afe *afe) for (i = 0; i < MT2701_CLOCK_NUM; i++) { afe_priv->clocks[i] = devm_clk_get(afe->dev, aud_clks[i]); - if (IS_ERR(aud_clks[i])) { + if (IS_ERR(afe_priv->clocks[i])) { dev_warn(afe->dev, "%s devm_clk_get %s fail\n", __func__, aud_clks[i]); return PTR_ERR(aud_clks[i]); -- cgit v1.1 From b56bff43a965ffe03b4a994fd1a102059d272807 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 7 Aug 2017 18:39:32 +0800 Subject: ASoC: rt5514: reset dma_offset at hw_params dma_offset needs reset every time otherwise for consecutive PCM open the last dma_offset value will cause incorrect pointer position be reported to user space. Signed-off-by: Hsin-Yu Chao Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 6f513cc..640193d 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -151,7 +151,6 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data) u8 buf[8]; rt5514_dsp->get_size = 0; - rt5514_dsp->dma_offset = 0; /** * The address area x1800XXXX is the register address, and it cannot @@ -205,6 +204,7 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); rt5514_dsp->substream = substream; + rt5514_dsp->dma_offset = 0; mutex_unlock(&rt5514_dsp->dma_lock); return ret; -- cgit v1.1 From 92ff5d085ecc8255600551055262bf98a8f3f1d0 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 3 Aug 2017 21:30:20 +0530 Subject: ASoC: sunxi: make snd_soc_codec_driver structures as const Declare snd_soc_codec_driver structures as const as they are either passed as an argument to the function snd_soc_register_codec or stored as reference in field codec of type sun4i_codec_quirks. Both the fucntion argument and the codec field are of type const, so declare the structures with this property as const. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-codec.c | 6 +++--- sound/soc/sunxi/sun8i-codec.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 73d054f..c668b8b 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -762,7 +762,7 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Mic1", NULL, "VMIC" }, }; -static struct snd_soc_codec_driver sun4i_codec_codec = { +static const struct snd_soc_codec_driver sun4i_codec_codec = { .component_driver = { .controls = sun4i_codec_controls, .num_controls = ARRAY_SIZE(sun4i_codec_controls), @@ -1068,7 +1068,7 @@ static const struct snd_soc_dapm_route sun6i_codec_codec_dapm_routes[] = { { "Right ADC", NULL, "Right ADC Mixer" }, }; -static struct snd_soc_codec_driver sun6i_codec_codec = { +static const struct snd_soc_codec_driver sun6i_codec_codec = { .component_driver = { .controls = sun6i_codec_codec_widgets, .num_controls = ARRAY_SIZE(sun6i_codec_codec_widgets), @@ -1096,7 +1096,7 @@ static const struct snd_soc_dapm_widget sun8i_a23_codec_codec_widgets[] = { }; -static struct snd_soc_codec_driver sun8i_a23_codec_codec = { +static const struct snd_soc_codec_driver sun8i_a23_codec_codec = { .component_driver = { .controls = sun8i_a23_codec_codec_controls, .num_controls = ARRAY_SIZE(sun8i_a23_codec_codec_controls), diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c index 253ae0b..abfb710 100644 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@ -360,7 +360,7 @@ static struct snd_soc_dai_driver sun8i_codec_dai = { .ops = &sun8i_codec_dai_ops, }; -static struct snd_soc_codec_driver sun8i_soc_codec = { +static const struct snd_soc_codec_driver sun8i_soc_codec = { .component_driver = { .dapm_widgets = sun8i_codec_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(sun8i_codec_dapm_widgets), -- cgit v1.1 From 353c64dd19ebc99786c3578ea0444e1b5b1bb172 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 7 Aug 2017 09:08:52 -0300 Subject: ASoC: soc-core: Remove unneeded dentry member from snd_soc_codec There is no need to have the *debugfs_reg dentry member as part of the snd_soc_codec structure as its only usage is inside soc_init_codec_debugfs(). Use a local dentry variable instead. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 921622a..558efdf 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -339,11 +339,12 @@ static void soc_cleanup_component_debugfs(struct snd_soc_component *component) static void soc_init_codec_debugfs(struct snd_soc_component *component) { struct snd_soc_codec *codec = snd_soc_component_to_codec(component); + struct dentry *debugfs_reg; - codec->debugfs_reg = debugfs_create_file("codec_reg", 0644, - codec->component.debugfs_root, - codec, &codec_reg_fops); - if (!codec->debugfs_reg) + debugfs_reg = debugfs_create_file("codec_reg", 0644, + codec->component.debugfs_root, + codec, &codec_reg_fops); + if (!debugfs_reg) dev_warn(codec->dev, "ASoC: Failed to create codec register debugfs file\n"); } -- cgit v1.1 From d9a02c552cd69c466998e3afdf420cb4c0b9d9d9 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 7 Aug 2017 09:08:53 -0300 Subject: ASoC: soc-core: Use IS_ERR_OR_NULL() The check of IS_ERR or NULL pointer can be replaced by IS_ERR_OR_NULL(), which helps readability. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 558efdf..07d7084 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -495,7 +495,7 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card) static void snd_soc_debugfs_init(void) { snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL); - if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) { + if (IS_ERR_OR_NULL(snd_soc_debugfs_root)) { pr_warn("ASoC: Failed to create debugfs directory\n"); snd_soc_debugfs_root = NULL; return; -- cgit v1.1 From cf9e829eaf0195e722bc3a3929002a3fbe74dafa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 7 Aug 2017 02:06:23 +0000 Subject: ASoC: soc-core: rename "cmpnt" to "component" To unify notation, to readable. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 921622a..b214889 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3282,40 +3282,40 @@ static void snd_soc_component_del_unlocked(struct snd_soc_component *component) } int snd_soc_register_component(struct device *dev, - const struct snd_soc_component_driver *cmpnt_drv, + const struct snd_soc_component_driver *component_driver, struct snd_soc_dai_driver *dai_drv, int num_dai) { - struct snd_soc_component *cmpnt; + struct snd_soc_component *component; int ret; - cmpnt = kzalloc(sizeof(*cmpnt), GFP_KERNEL); - if (!cmpnt) { + component = kzalloc(sizeof(*component), GFP_KERNEL); + if (!component) { dev_err(dev, "ASoC: Failed to allocate memory\n"); return -ENOMEM; } - ret = snd_soc_component_initialize(cmpnt, cmpnt_drv, dev); + ret = snd_soc_component_initialize(component, component_driver, dev); if (ret) goto err_free; - cmpnt->ignore_pmdown_time = true; - cmpnt->registered_as_component = true; + component->ignore_pmdown_time = true; + component->registered_as_component = true; - ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, true); + ret = snd_soc_register_dais(component, dai_drv, num_dai, true); if (ret < 0) { dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret); goto err_cleanup; } - snd_soc_component_add(cmpnt); + snd_soc_component_add(component); return 0; err_cleanup: - snd_soc_component_cleanup(cmpnt); + snd_soc_component_cleanup(component); err_free: - kfree(cmpnt); + kfree(component); return ret; } EXPORT_SYMBOL_GPL(snd_soc_register_component); @@ -3327,22 +3327,22 @@ EXPORT_SYMBOL_GPL(snd_soc_register_component); */ void snd_soc_unregister_component(struct device *dev) { - struct snd_soc_component *cmpnt; + struct snd_soc_component *component; mutex_lock(&client_mutex); - list_for_each_entry(cmpnt, &component_list, list) { - if (dev == cmpnt->dev && cmpnt->registered_as_component) + list_for_each_entry(component, &component_list, list) { + if (dev == component->dev && component->registered_as_component) goto found; } mutex_unlock(&client_mutex); return; found: - snd_soc_tplg_component_remove(cmpnt, SND_SOC_TPLG_INDEX_ALL); - snd_soc_component_del_unlocked(cmpnt); + snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); + snd_soc_component_del_unlocked(component); mutex_unlock(&client_mutex); - snd_soc_component_cleanup(cmpnt); - kfree(cmpnt); + snd_soc_component_cleanup(component); + kfree(component); } EXPORT_SYMBOL_GPL(snd_soc_unregister_component); -- cgit v1.1 From 21a035287e28ec225fe7dfd1fffc509efd26a5db Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 7 Aug 2017 02:06:40 +0000 Subject: ASoC: soc-core: remove duplicate mutex_unlock from snd_soc_unregister_component() Current snd_soc_unregister_component() is using multiple mutex_unlock() for found/non-found cases. But it is unreadable and confusable code. This patch tidyup current code to be readable. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b214889..3bb8c63 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3328,21 +3328,25 @@ EXPORT_SYMBOL_GPL(snd_soc_register_component); void snd_soc_unregister_component(struct device *dev) { struct snd_soc_component *component; + int found = 0; mutex_lock(&client_mutex); list_for_each_entry(component, &component_list, list) { - if (dev == component->dev && component->registered_as_component) - goto found; + if (dev != component->dev || + !component->registered_as_component) + continue; + + snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); + snd_soc_component_del_unlocked(component); + found = 1; + break; } mutex_unlock(&client_mutex); - return; -found: - snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); - snd_soc_component_del_unlocked(component); - mutex_unlock(&client_mutex); - snd_soc_component_cleanup(component); - kfree(component); + if (found) { + snd_soc_component_cleanup(component); + kfree(component); + } } EXPORT_SYMBOL_GPL(snd_soc_unregister_component); -- cgit v1.1 From 06d15a2ede999a77f0d05aa600ed473d90d9a909 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 7 Aug 2017 18:29:18 -0500 Subject: ASoC: fsl: Convert to using %pOF instead of full_name Now that we have a custom printf format specifier, convert users of full_name to use %pOF instead. This is preparation to remove storing of the full path string for each node. Signed-off-by: Rob Herring Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 4 ++-- sound/soc/fsl/imx-audmux.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index ccadefc..ed8ea00 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -897,8 +897,8 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) ret = of_address_to_resource(ssi_np, 0, &res); if (ret) { - dev_err(&pdev->dev, "could not determine resources for %s\n", - ssi_np->full_name); + dev_err(&pdev->dev, "could not determine resources for %pOF\n", + ssi_np); of_node_put(ssi_np); return ret; } diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c index fc57da3..392d5ee 100644 --- a/sound/soc/fsl/imx-audmux.c +++ b/sound/soc/fsl/imx-audmux.c @@ -268,13 +268,13 @@ static int imx_audmux_parse_dt_defaults(struct platform_device *pdev, ret = of_property_read_u32(child, "fsl,audmux-port", &port); if (ret) { - dev_warn(&pdev->dev, "Failed to get fsl,audmux-port of child node \"%s\"\n", - child->full_name); + dev_warn(&pdev->dev, "Failed to get fsl,audmux-port of child node \"%pOF\"\n", + child); continue; } if (!of_property_read_bool(child, "fsl,port-config")) { - dev_warn(&pdev->dev, "child node \"%s\" does not have property fsl,port-config\n", - child->full_name); + dev_warn(&pdev->dev, "child node \"%pOF\" does not have property fsl,port-config\n", + child); continue; } @@ -292,15 +292,15 @@ static int imx_audmux_parse_dt_defaults(struct platform_device *pdev, } if (ret != -EOVERFLOW) { - dev_err(&pdev->dev, "Failed to read u32 at index %d of child %s\n", - i, child->full_name); + dev_err(&pdev->dev, "Failed to read u32 at index %d of child %pOF\n", + i, child); continue; } if (audmux_type == IMX31_AUDMUX) { if (i % 2) { - dev_err(&pdev->dev, "One pdcr value is missing in child node %s\n", - child->full_name); + dev_err(&pdev->dev, "One pdcr value is missing in child node %pOF\n", + child); continue; } imx_audmux_v2_configure_port(port, ptcr, pdcr); -- cgit v1.1 From a8ad0c85fbfa56c44161829f6433e59dcd84b731 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 4 Aug 2017 12:58:17 +0200 Subject: ASoC: samsung: odroid: Drop requirement of clocks in the sound node As suggested in reviews the requirement of clocks in the 'sound' node is dropped and instead a leaf clock is used to configure frequency of the audio root clock PLL. This can work now after the clock tree definitions have been updated to allow clock rate setting propagation on the path from the I2S controller up to the EPLL. This patch also lowers the CODEC master clock frequency so as to not exceed the maximum allowed 60 MHz at maximum audio sampling rates. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/odroid.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index 0c0b00e..00b7f45 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -19,8 +19,8 @@ struct odroid_priv { struct snd_soc_card card; struct snd_soc_dai_link dai_link; - struct clk *pll; - struct clk *rclk; + struct clk *clk_i2s_bus; + struct clk *sclk_i2s; }; static int odroid_card_startup(struct snd_pcm_substream *substream) @@ -58,13 +58,18 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - ret = clk_set_rate(priv->pll, pll_freq + 1); + ret = clk_set_rate(priv->clk_i2s_bus, pll_freq / 2 + 1); if (ret < 0) return ret; - rclk_freq = params_rate(params) * 256 * 4; + /* + * We add 1 to the rclk_freq value in order to avoid too low clock + * frequency values due to the EPLL output frequency not being exact + * multiple of the audio sampling rate. + */ + rclk_freq = params_rate(params) * 256 + 1; - ret = clk_set_rate(priv->rclk, rclk_freq); + ret = clk_set_rate(priv->sclk_i2s, rclk_freq); if (ret < 0) return ret; @@ -118,14 +123,6 @@ static int odroid_audio_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(card, priv); - priv->pll = devm_clk_get(dev, "epll"); - if (IS_ERR(priv->pll)) - return PTR_ERR(priv->pll); - - priv->rclk = devm_clk_get(dev, "i2s_rclk"); - if (IS_ERR(priv->rclk)) - return PTR_ERR(priv->rclk); - ret = snd_soc_of_parse_card_name(card, "model"); if (ret < 0) return ret; @@ -171,14 +168,31 @@ static int odroid_audio_probe(struct platform_device *pdev) link->name = "Primary"; link->stream_name = link->name; + + priv->sclk_i2s = of_clk_get_by_name(link->cpu_of_node, "i2s_opclk1"); + if (IS_ERR(priv->sclk_i2s)) { + ret = PTR_ERR(priv->sclk_i2s); + goto err_put_i2s_n; + } + + priv->clk_i2s_bus = of_clk_get_by_name(link->cpu_of_node, "iis"); + if (IS_ERR(priv->clk_i2s_bus)) { + ret = PTR_ERR(priv->clk_i2s_bus); + goto err_put_sclk; + } + ret = devm_snd_soc_register_card(dev, card); if (ret < 0) { dev_err(dev, "snd_soc_register_card() failed: %d\n", ret); - goto err_put_i2s_n; + goto err_put_clk_i2s; } return 0; +err_put_clk_i2s: + clk_put(priv->clk_i2s_bus); +err_put_sclk: + clk_put(priv->sclk_i2s); err_put_i2s_n: of_node_put(link->cpu_of_node); err_put_codec_n: @@ -192,6 +206,8 @@ static int odroid_audio_remove(struct platform_device *pdev) of_node_put(priv->dai_link.cpu_of_node); odroid_put_codec_of_nodes(&priv->dai_link); + clk_put(priv->sclk_i2s); + clk_put(priv->clk_i2s_bus); return 0; } -- cgit v1.1 From bf23c6a3813aac96e0af01565aba012b25c8bae5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 8 Aug 2017 01:32:08 +0000 Subject: ASoC: rsnd: move rsnd_ssi_config_init() execute condition into it. Make it the same style as other functions Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 49cdc5e..3ee7b2d 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -335,6 +335,9 @@ static void rsnd_ssi_config_init(struct rsnd_mod *mod, u32 wsr; int is_tdm; + if (rsnd_ssi_is_parent(mod, io)) + return; + is_tdm = rsnd_runtime_is_ssi_tdm(io); /* @@ -472,8 +475,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, if (ret < 0) return ret; - if (!rsnd_ssi_is_parent(mod, io)) - rsnd_ssi_config_init(mod, io); + rsnd_ssi_config_init(mod, io); rsnd_ssi_register_setup(mod); -- cgit v1.1 From bb002f925ae18c0c9d72d87b74b311a5209d7178 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 8 Aug 2017 01:32:42 +0000 Subject: ASoC: rsnd: rsnd_ssi_can_output_clk() macro For example SSI0/SSI1 case, SSI1 can share pin with SSI0. And then, SSI1 needs SSI0's clock. This clock controlling is very picky and difficult to understand in current code. This patch adds new rsnd_ssi_can_output_clk() macro, the code will be more understandable. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 3ee7b2d..434996d 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -106,6 +106,7 @@ struct rsnd_ssi { (rsnd_ssi_multi_slaves(io) & (1 << rsnd_mod_id(mod))) #define rsnd_ssi_is_run_mods(mod, io) \ (rsnd_ssi_run_mods(io) & (1 << rsnd_mod_id(mod))) +#define rsnd_ssi_can_output_clk(mod) (!__rsnd_ssi_is_pin_sharing(mod)) int rsnd_ssi_hdmi_port(struct rsnd_dai_stream *io) { @@ -255,7 +256,6 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, struct device *dev = rsnd_priv_to_dev(priv); struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_mod *ssi_parent_mod = rsnd_io_to_mod_ssip(io); int chan = rsnd_runtime_channel_for_ssi(io); int idx, ret; unsigned int main_rate; @@ -266,7 +266,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (!rsnd_rdai_is_clk_master(rdai)) return 0; - if (ssi_parent_mod && !rsnd_ssi_is_parent(mod, io)) + if (!rsnd_ssi_can_output_clk(mod)) return 0; if (rsnd_ssi_is_multi_slave(mod, io)) @@ -307,12 +307,11 @@ static void rsnd_ssi_master_clk_stop(struct rsnd_mod *mod, { struct rsnd_dai *rdai = rsnd_io_to_rdai(io); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_mod *ssi_parent_mod = rsnd_io_to_mod_ssip(io); if (!rsnd_rdai_is_clk_master(rdai)) return; - if (ssi_parent_mod && !rsnd_ssi_is_parent(mod, io)) + if (!rsnd_ssi_can_output_clk(mod)) return; if (ssi->usrcnt > 1) -- cgit v1.1 From 597b046f0d99b0b0123a715f8c8b1ea881d2bec6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 8 Aug 2017 01:31:39 +0000 Subject: ASoC: rsnd: control SSICR::EN correctly In case of SSI0 playback, SSI1 capture, SSI0 might be shared for clock output if clock master mode. Current rsnd driver had been assumed that SSI clock contiguous output which is needed for SSI parent needs SSICR::EN (SSI module enable) bit. But, this bit controls data input/output, not for clock. Clock contiguous output needs SSICR : FORCE, SCKD, SWSD, and SSIWSR : CONT. Not SSICR : EN. Because of this wrong assumption, and insufficient control, on current code, for example, if it starts SSI0(playback) -> SSI1(capture) order, SSI0 SSICR::EN bit will temporarily be 0. It causes playback side underrun error. This is bug. We can reproduce this issue with SSI+SRC (without DVC), and capture during playback operation. This patch fixup current (wrong) assumption, and control SSICR::EN bit correctly. Reported-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 46feddd..c5d5c6415 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -72,6 +72,7 @@ struct rsnd_ssi { u32 cr_own; u32 cr_clk; u32 cr_mode; + u32 cr_en; u32 wsr; int chan; int rate; @@ -291,6 +292,16 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (ret < 0) return ret; + /* + * SSI clock will be output contiguously + * by below settings. + * This means, rsnd_ssi_master_clk_start() + * and rsnd_ssi_register_setup() are necessary + * for SSI parent + * + * SSICR : FORCE, SCKD, SWSD + * SSIWSR : CONT + */ ssi->cr_clk = FORCE | SWL_32 | SCKD | SWSD | CKDV(idx); ssi->wsr = CONT; ssi->rate = rate; @@ -393,7 +404,8 @@ static void rsnd_ssi_register_setup(struct rsnd_mod *mod) rsnd_mod_write(mod, SSIWSR, ssi->wsr); rsnd_mod_write(mod, SSICR, ssi->cr_own | ssi->cr_clk | - ssi->cr_mode); /* without EN */ + ssi->cr_mode | + ssi->cr_en); } static void rsnd_ssi_pointer_init(struct rsnd_mod *mod, @@ -544,6 +556,8 @@ static int rsnd_ssi_start(struct rsnd_mod *mod, struct rsnd_dai_stream *io, struct rsnd_priv *priv) { + struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); + if (!rsnd_ssi_is_run_mods(mod, io)) return 0; @@ -554,7 +568,19 @@ static int rsnd_ssi_start(struct rsnd_mod *mod, if (rsnd_ssi_multi_slaves_runtime(io)) return 0; - rsnd_mod_bset(mod, SSICR, EN, EN); + /* + * EN is for data output. + * SSI parent EN is not needed. + */ + if (rsnd_ssi_is_parent(mod, io)) + return 0; + + ssi->cr_en = EN; + + rsnd_mod_write(mod, SSICR, ssi->cr_own | + ssi->cr_clk | + ssi->cr_mode | + ssi->cr_en); return 0; } @@ -569,13 +595,7 @@ static int rsnd_ssi_stop(struct rsnd_mod *mod, if (!rsnd_ssi_is_run_mods(mod, io)) return 0; - /* - * don't stop if not last user - * see also - * rsnd_ssi_start - * rsnd_ssi_interrupt - */ - if (ssi->usrcnt > 1) + if (rsnd_ssi_is_parent(mod, io)) return 0; /* @@ -595,6 +615,8 @@ static int rsnd_ssi_stop(struct rsnd_mod *mod, rsnd_mod_write(mod, SSICR, cr); /* disabled all */ rsnd_ssi_status_check(mod, IIRQ); + ssi->cr_en = 0; + return 0; } -- cgit v1.1 From ade82fdbae6905e80f107596f2e0b4df84490d28 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Wed, 9 Aug 2017 09:56:14 +0800 Subject: ASoC: rt5514: Eliminate the noise in the ASRC case In the ASRC case, there is the noise if the clock is asynchronous with the LRCK. The default settings will eliminate the noise. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 21cbb56..0eabe56 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -64,6 +64,8 @@ static const struct reg_sequence rt5514_patch[] = { {RT5514_ANA_CTRL_LDO10, 0x00028604}, {RT5514_ANA_CTRL_ADCFED, 0x00000800}, {RT5514_ASRC_IN_CTRL1, 0x00000003}, + {RT5514_DOWNFILTER0_CTRL3, 0x10000362}, + {RT5514_DOWNFILTER1_CTRL3, 0x10000362}, }; static const struct reg_default rt5514_reg[] = { @@ -89,10 +91,10 @@ static const struct reg_default rt5514_reg[] = { {RT5514_DELAY_BUF_CTRL3, 0x00000000}, {RT5514_DOWNFILTER0_CTRL1, 0x00020c2f}, {RT5514_DOWNFILTER0_CTRL2, 0x00020c2f}, - {RT5514_DOWNFILTER0_CTRL3, 0x00000362}, + {RT5514_DOWNFILTER0_CTRL3, 0x10000362}, {RT5514_DOWNFILTER1_CTRL1, 0x00020c2f}, {RT5514_DOWNFILTER1_CTRL2, 0x00020c2f}, - {RT5514_DOWNFILTER1_CTRL3, 0x00000362}, + {RT5514_DOWNFILTER1_CTRL3, 0x10000362}, {RT5514_ANA_CTRL_LDO10, 0x00028604}, {RT5514_ANA_CTRL_LDO18_16, 0x02000345}, {RT5514_ANA_CTRL_ADC12, 0x0000a2a8}, -- cgit v1.1 From 29d03ff5c752e02918e8319fdcc86faa374d36ec Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 9 Aug 2017 01:46:23 +0000 Subject: ASoC: rsnd: remove 16ch support for now R-Car Gen3 sound device can use TDM 16ch, but its usage is very limited. It is not yet supported. Let's remove unexpected/unsupported channel settings for now. This patch makes xx_ADINR register settings sanity without runtime check. R-Car Gen3 datasheet 40.4.7 Note on Usage of the SSIU Module When an SSIU module is used in "TDM-16ch mode", only the transfer with the external memory is available. Reported-by: Nguyen Viet Dung Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 3f2ced2..7fa40fc 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -726,7 +726,6 @@ static int rsnd_soc_set_dai_tdm_slot(struct snd_soc_dai *dai, case 2: case 6: case 8: - case 16: /* TDM Extend Mode */ rsnd_rdai_channels_set(rdai, slots); rsnd_rdai_ssi_lane_set(rdai, 1); @@ -740,7 +739,7 @@ static int rsnd_soc_set_dai_tdm_slot(struct snd_soc_dai *dai, } static unsigned int rsnd_soc_hw_channels_list[] = { - 2, 6, 8, 16, + 2, 6, 8, }; static unsigned int rsnd_soc_hw_rate_list[] = { @@ -1017,7 +1016,7 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv, drv->playback.rates = RSND_RATES; drv->playback.formats = RSND_FMTS; drv->playback.channels_min = 2; - drv->playback.channels_max = 16; + drv->playback.channels_max = 8; drv->playback.stream_name = rdai->playback.name; snprintf(rdai->capture.name, RSND_DAI_NAME_SIZE, @@ -1025,7 +1024,7 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv, drv->capture.rates = RSND_RATES; drv->capture.formats = RSND_FMTS; drv->capture.channels_min = 2; - drv->capture.channels_max = 16; + drv->capture.channels_max = 8; drv->capture.stream_name = rdai->capture.name; rdai->playback.rdai = rdai; -- cgit v1.1 From e0936c3471a8411a5df327641fa3ffe12a2fb07b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 9 Aug 2017 02:16:20 +0000 Subject: ASoC: rsnd: avoid duplicate free_irq() commit 1f8754d4daea5f ("ASoC: rsnd: don't call free_irq() on Parent SSI") fixed Parent SSI duplicate free_irq(). But on Renesas Sound, not only Parent SSI but also Multi SSI have same issue. This patch avoid duplicate free_irq() if it was not pure SSI. Fixes: 1f8754d4daea5f ("ASoC: rsnd: don't call free_irq() on Parent SSI") Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index c5d5c6415..90cc9c1 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -845,10 +845,10 @@ static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, struct rsnd_priv *priv) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_mod *ssi_parent_mod = rsnd_io_to_mod_ssip(io); + struct rsnd_mod *pure_ssi_mod = rsnd_io_to_mod_ssi(io); - /* Do nothing for SSI parent mod */ - if (ssi_parent_mod == mod) + /* Do nothing if non SSI (= SSI parent, multi SSI) mod */ + if (pure_ssi_mod != mod) return 0; /* PIO will request IRQ again */ -- cgit v1.1 From 65d55e8a3bb2d2a98078590cfa49cd508aa80e81 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 10 Aug 2017 09:50:51 +0200 Subject: ASoC: spear: Delete an error message for a failed memory allocation in two functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Acked-by: Viresh Kumar Signed-off-by: Mark Brown --- sound/soc/spear/spdif_in.c | 4 +--- sound/soc/spear/spdif_out.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/spear/spdif_in.c b/sound/soc/spear/spdif_in.c index 7f32527..01b28e5 100644 --- a/sound/soc/spear/spdif_in.c +++ b/sound/soc/spear/spdif_in.c @@ -216,10 +216,8 @@ static int spdif_in_probe(struct platform_device *pdev) return -EINVAL; host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); - if (!host) { - dev_warn(&pdev->dev, "kzalloc fail\n"); + if (!host) return -ENOMEM; - } host->io_base = io_base; host->irq = platform_get_irq(pdev, 0); diff --git a/sound/soc/spear/spdif_out.c b/sound/soc/spear/spdif_out.c index 0a72d52..58d5843 100644 --- a/sound/soc/spear/spdif_out.c +++ b/sound/soc/spear/spdif_out.c @@ -282,10 +282,8 @@ static int spdif_out_probe(struct platform_device *pdev) int ret; host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); - if (!host) { - dev_warn(&pdev->dev, "kzalloc fail\n"); + if (!host) return -ENOMEM; - } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); host->io_base = devm_ioremap_resource(&pdev->dev, res); -- cgit v1.1 From 213691c7e873206742b39751895d15b41a02b3d1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 10 Aug 2017 00:07:00 +0000 Subject: ASoC: rsnd: call free_irq() both DMA/PIO mode commit 701172dca15b ("ASoC: rsnd: don't use devm_request_irq() for SSI") exchanged devm_request_irq() to request_irq() for SSI, because SSI will fallback into PIO mode if DMA doesn't work. But, because of it, PIO mode needed to call free_irq() when removing, not only DMA mode. This patch call free_irq() both PIO/DMA. Otherwise, rsnd IRQ handler will be increased if user tried many unbind/bind. Fixes: 701172dca15b ("ASoC: rsnd: don't use devm_request_irq() for SSI") Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 0309de5..281ed0d 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -792,6 +792,23 @@ static int rsnd_ssi_common_probe(struct rsnd_mod *mod, return ret; } +static int rsnd_ssi_common_remove(struct rsnd_mod *mod, + struct rsnd_dai_stream *io, + struct rsnd_priv *priv) +{ + struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); + struct rsnd_mod *pure_ssi_mod = rsnd_io_to_mod_ssi(io); + + /* Do nothing if non SSI (= SSI parent, multi SSI) mod */ + if (pure_ssi_mod != mod) + return 0; + + /* PIO will request IRQ again */ + free_irq(ssi->irq, mod); + + return 0; +} + static int rsnd_ssi_pointer(struct rsnd_mod *mod, struct rsnd_dai_stream *io, snd_pcm_uframes_t *pointer) @@ -807,6 +824,7 @@ static int rsnd_ssi_pointer(struct rsnd_mod *mod, static struct rsnd_mod_ops rsnd_ssi_pio_ops = { .name = SSI_NAME, .probe = rsnd_ssi_common_probe, + .remove = rsnd_ssi_common_remove, .init = rsnd_ssi_init, .quit = rsnd_ssi_quit, .start = rsnd_ssi_start, @@ -841,23 +859,6 @@ static int rsnd_ssi_dma_probe(struct rsnd_mod *mod, return ret; } -static int rsnd_ssi_dma_remove(struct rsnd_mod *mod, - struct rsnd_dai_stream *io, - struct rsnd_priv *priv) -{ - struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - struct rsnd_mod *pure_ssi_mod = rsnd_io_to_mod_ssi(io); - - /* Do nothing if non SSI (= SSI parent, multi SSI) mod */ - if (pure_ssi_mod != mod) - return 0; - - /* PIO will request IRQ again */ - free_irq(ssi->irq, mod); - - return 0; -} - static int rsnd_ssi_fallback(struct rsnd_mod *mod, struct rsnd_dai_stream *io, struct rsnd_priv *priv) @@ -899,7 +900,7 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = { .name = SSI_NAME, .dma_req = rsnd_ssi_dma_req, .probe = rsnd_ssi_dma_probe, - .remove = rsnd_ssi_dma_remove, + .remove = rsnd_ssi_common_remove, .init = rsnd_ssi_init, .quit = rsnd_ssi_quit, .start = rsnd_ssi_start, -- cgit v1.1 From bf9b29c784b393d1e506945f1e24e871d2587eb3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 10 Aug 2017 00:07:20 +0000 Subject: ASoC: rsnd: add rsnd_ssi_flags_has/add() macro Current rsnd_ssi_mode_flags() is not useful. This patch adds new rsnd_ssi_flags_has/add() macro for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 281ed0d..ca9355b 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -101,7 +101,8 @@ struct rsnd_ssi { #define rsnd_ssi_to_dma(mod) ((ssi)->dma) #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) -#define rsnd_ssi_mode_flags(p) ((p)->flags) +#define rsnd_ssi_flags_has(p, f) ((p)->flags & f) +#define rsnd_ssi_flags_set(p, f) ((p)->flags |= f) #define rsnd_ssi_is_parent(ssi, io) ((ssi) == rsnd_io_to_mod_ssip(io)) #define rsnd_ssi_is_multi_slave(mod, io) \ (rsnd_ssi_multi_slaves(io) & (1 << rsnd_mod_id(mod))) @@ -114,10 +115,10 @@ int rsnd_ssi_hdmi_port(struct rsnd_dai_stream *io) struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io); struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - if (rsnd_ssi_mode_flags(ssi) & RSND_SSI_HDMI0) + if (rsnd_ssi_flags_has(ssi, RSND_SSI_HDMI0)) return RSND_SSI_HDMI_PORT0; - if (rsnd_ssi_mode_flags(ssi) & RSND_SSI_HDMI1) + if (rsnd_ssi_flags_has(ssi, RSND_SSI_HDMI1)) return RSND_SSI_HDMI_PORT1; return 0; @@ -132,7 +133,7 @@ int rsnd_ssi_use_busif(struct rsnd_dai_stream *io) if (!rsnd_ssi_is_dma_mode(mod)) return 0; - if (!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_NO_BUSIF)) + if (!(rsnd_ssi_flags_has(ssi, RSND_SSI_NO_BUSIF))) use_busif = 1; if (rsnd_io_to_mod_src(io)) use_busif = 1; @@ -986,13 +987,13 @@ static void __rsnd_ssi_parse_hdmi_connection(struct rsnd_priv *priv, ssi = rsnd_mod_to_ssi(mod); if (strstr(remote_ep->full_name, "hdmi0")) { - ssi->flags |= RSND_SSI_HDMI0; + rsnd_ssi_flags_set(ssi, RSND_SSI_HDMI0); dev_dbg(dev, "%s[%d] connected to HDMI0\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); } if (strstr(remote_ep->full_name, "hdmi1")) { - ssi->flags |= RSND_SSI_HDMI1; + rsnd_ssi_flags_set(ssi, RSND_SSI_HDMI1); dev_dbg(dev, "%s[%d] connected to HDMI1\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); } @@ -1025,7 +1026,7 @@ int __rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod) { struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); - return !!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_CLK_PIN_SHARE); + return !!(rsnd_ssi_flags_has(ssi, RSND_SSI_CLK_PIN_SHARE)); } static u32 *rsnd_ssi_get_status(struct rsnd_dai_stream *io, @@ -1108,10 +1109,10 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) } if (of_get_property(np, "shared-pin", NULL)) - ssi->flags |= RSND_SSI_CLK_PIN_SHARE; + rsnd_ssi_flags_set(ssi, RSND_SSI_CLK_PIN_SHARE); if (of_get_property(np, "no-busif", NULL)) - ssi->flags |= RSND_SSI_NO_BUSIF; + rsnd_ssi_flags_set(ssi, RSND_SSI_NO_BUSIF); ssi->irq = irq_of_parse_and_map(np, 0); if (!ssi->irq) { -- cgit v1.1 From b6e58fcacb3edc6245ecf700207ba675cba18018 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 10 Aug 2017 00:07:38 +0000 Subject: ASoC: rsnd: call request_irq/free_irq once in MIX case Each module's dai callback function availability is controlled by mod->status. For example "always called", "call once". In .probe/.remove case, it needs to be called always, because .probe will call xxx_attach() function on .probe, especially if platform is using MIXer. For example, below case, MIX0/DVC0/SSI0 needs to be called twice. playback = <&src0 &ctu02 &mix0 &dvc0 &ssi0>; playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>; But in this case, SSI0 will call request_irq() twice. This patch add new RSND_SSI_PROBED flag and control it Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/ssi.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index ca9355b..8bb4714 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -90,6 +90,7 @@ struct rsnd_ssi { #define RSND_SSI_NO_BUSIF (1 << 1) /* SSI+DMA without BUSIF */ #define RSND_SSI_HDMI0 (1 << 2) /* for HDMI0 */ #define RSND_SSI_HDMI1 (1 << 3) /* for HDMI1 */ +#define RSND_SSI_PROBED (1 << 4) #define for_each_rsnd_ssi(pos, priv, i) \ for (i = 0; \ @@ -103,6 +104,7 @@ struct rsnd_ssi { #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) #define rsnd_ssi_flags_has(p, f) ((p)->flags & f) #define rsnd_ssi_flags_set(p, f) ((p)->flags |= f) +#define rsnd_ssi_flags_del(p, f) ((p)->flags = ((p)->flags & ~f)) #define rsnd_ssi_is_parent(ssi, io) ((ssi) == rsnd_io_to_mod_ssip(io)) #define rsnd_ssi_is_multi_slave(mod, io) \ (rsnd_ssi_multi_slaves(io) & (1 << rsnd_mod_id(mod))) @@ -784,11 +786,22 @@ static int rsnd_ssi_common_probe(struct rsnd_mod *mod, /* * SSI might be called again as PIO fallback * It is easy to manual handling for IRQ request/free + * + * OTOH, this function might be called many times if platform is + * using MIX. It needs xxx_attach() many times on xxx_probe(). + * Because of it, we can't control .probe/.remove calling count by + * mod->status. + * But it don't need to call request_irq() many times. + * Let's control it by RSND_SSI_PROBED flag. */ - ret = request_irq(ssi->irq, - rsnd_ssi_interrupt, - IRQF_SHARED, - dev_name(dev), mod); + if (!rsnd_ssi_flags_has(ssi, RSND_SSI_PROBED)) { + ret = request_irq(ssi->irq, + rsnd_ssi_interrupt, + IRQF_SHARED, + dev_name(dev), mod); + + rsnd_ssi_flags_set(ssi, RSND_SSI_PROBED); + } return ret; } @@ -805,7 +818,11 @@ static int rsnd_ssi_common_remove(struct rsnd_mod *mod, return 0; /* PIO will request IRQ again */ - free_irq(ssi->irq, mod); + if (rsnd_ssi_flags_has(ssi, RSND_SSI_PROBED)) { + free_irq(ssi->irq, mod); + + rsnd_ssi_flags_del(ssi, RSND_SSI_PROBED); + } return 0; } -- cgit v1.1 From a180ba45b1cf630b3bd5912ce235b2ee16606b8e Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 3 Aug 2017 21:30:19 +0530 Subject: ASoC: codecs: add const to snd_soc_codec_driver structures Declare snd_soc_codec_driver structures as const as they are only passed as an argument to the function snd_soc_register_codec. This argument is of type const, so declare the structures with this property as const. In file codecs/sn95031.c, snd_soc_codec_driver structure is also used in a copy operation along with getting passed to snd_soc_register_codec. So, it can be made const too. Done using Coccinelle: @match disable optional_qualifier@ identifier s; position p; @@ static struct snd_soc_codec_driver s@p={...}; @good1@ identifier match.s; position p; @@ snd_soc_register_codec(...,&s@p,...) @bad@ identifier match.s; position p!={match.p,good1.p}; @@ s@p @depends on !bad disable optional_qualifier@ identifier match.s; @@ static +const struct snd_soc_codec_driver s={...}; Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/codecs/88pm860x-codec.c | 2 +- sound/soc/codecs/ab8500-codec.c | 2 +- sound/soc/codecs/ac97.c | 2 +- sound/soc/codecs/ad1836.c | 2 +- sound/soc/codecs/ad193x.c | 2 +- sound/soc/codecs/ad1980.c | 2 +- sound/soc/codecs/ad73311.c | 2 +- sound/soc/codecs/adau1373.c | 2 +- sound/soc/codecs/adau1701.c | 2 +- sound/soc/codecs/adau1977.c | 2 +- sound/soc/codecs/adav80x.c | 2 +- sound/soc/codecs/ads117x.c | 2 +- sound/soc/codecs/ak4104.c | 2 +- sound/soc/codecs/ak4535.c | 2 +- sound/soc/codecs/ak4554.c | 2 +- sound/soc/codecs/ak4613.c | 2 +- sound/soc/codecs/ak4641.c | 2 +- sound/soc/codecs/ak4642.c | 2 +- sound/soc/codecs/ak4671.c | 2 +- sound/soc/codecs/ak5386.c | 2 +- sound/soc/codecs/alc5623.c | 2 +- sound/soc/codecs/bt-sco.c | 2 +- sound/soc/codecs/cq93vc.c | 2 +- sound/soc/codecs/cs35l33.c | 2 +- sound/soc/codecs/cs35l34.c | 2 +- sound/soc/codecs/cs35l35.c | 2 +- sound/soc/codecs/cs4271.c | 2 +- sound/soc/codecs/cs42l51.c | 2 +- sound/soc/codecs/cs4349.c | 2 +- sound/soc/codecs/cs47l24.c | 2 +- sound/soc/codecs/cs53l30.c | 2 +- sound/soc/codecs/cx20442.c | 2 +- sound/soc/codecs/da7210.c | 2 +- sound/soc/codecs/da7213.c | 2 +- sound/soc/codecs/da7218.c | 2 +- sound/soc/codecs/da7219.c | 2 +- sound/soc/codecs/da732x.c | 2 +- sound/soc/codecs/da9055.c | 2 +- sound/soc/codecs/dmic.c | 2 +- sound/soc/codecs/es7134.c | 2 +- sound/soc/codecs/es8316.c | 2 +- sound/soc/codecs/es8328.c | 2 +- sound/soc/codecs/hdac_hdmi.c | 2 +- sound/soc/codecs/hdmi-codec.c | 2 +- sound/soc/codecs/ics43432.c | 2 +- sound/soc/codecs/inno_rk3036.c | 2 +- sound/soc/codecs/isabelle.c | 2 +- sound/soc/codecs/jz4740.c | 2 +- sound/soc/codecs/lm49453.c | 2 +- sound/soc/codecs/max98088.c | 2 +- sound/soc/codecs/max98090.c | 2 +- sound/soc/codecs/max98095.c | 2 +- sound/soc/codecs/max98357a.c | 2 +- sound/soc/codecs/max9850.c | 2 +- sound/soc/codecs/max9860.c | 2 +- sound/soc/codecs/max9867.c | 2 +- sound/soc/codecs/max98926.c | 2 +- sound/soc/codecs/mc13783.c | 2 +- sound/soc/codecs/ml26124.c | 2 +- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- sound/soc/codecs/msm8916-wcd-digital.c | 2 +- sound/soc/codecs/nau8540.c | 2 +- sound/soc/codecs/nau8810.c | 2 +- sound/soc/codecs/nau8824.c | 2 +- sound/soc/codecs/nau8825.c | 2 +- sound/soc/codecs/pcm1681.c | 2 +- sound/soc/codecs/pcm179x.c | 2 +- sound/soc/codecs/pcm3008.c | 2 +- sound/soc/codecs/pcm512x.c | 2 +- sound/soc/codecs/rt274.c | 2 +- sound/soc/codecs/rt286.c | 2 +- sound/soc/codecs/rt298.c | 2 +- sound/soc/codecs/rt5514.c | 2 +- sound/soc/codecs/rt5616.c | 2 +- sound/soc/codecs/rt5631.c | 2 +- sound/soc/codecs/rt5640.c | 2 +- sound/soc/codecs/rt5645.c | 2 +- sound/soc/codecs/rt5651.c | 2 +- sound/soc/codecs/rt5659.c | 2 +- sound/soc/codecs/rt5660.c | 2 +- sound/soc/codecs/rt5663.c | 2 +- sound/soc/codecs/rt5665.c | 2 +- sound/soc/codecs/rt5670.c | 2 +- sound/soc/codecs/rt5677.c | 2 +- sound/soc/codecs/sgtl5000.c | 2 +- sound/soc/codecs/si476x.c | 2 +- sound/soc/codecs/sirf-audio-codec.c | 2 +- sound/soc/codecs/sn95031.c | 2 +- sound/soc/codecs/spdif_receiver.c | 2 +- sound/soc/codecs/spdif_transmitter.c | 2 +- sound/soc/codecs/ssm2518.c | 2 +- sound/soc/codecs/ssm2602.c | 2 +- sound/soc/codecs/ssm4567.c | 2 +- sound/soc/codecs/stac9766.c | 2 +- sound/soc/codecs/tas2552.c | 2 +- sound/soc/codecs/tas5086.c | 2 +- sound/soc/codecs/tas5720.c | 2 +- sound/soc/codecs/tlv320aic23.c | 2 +- sound/soc/codecs/tlv320aic26.c | 2 +- sound/soc/codecs/tlv320aic31xx.c | 2 +- sound/soc/codecs/tlv320aic32x4.c | 2 +- sound/soc/codecs/tlv320aic3x.c | 2 +- sound/soc/codecs/tlv320dac33.c | 2 +- sound/soc/codecs/twl4030.c | 2 +- sound/soc/codecs/twl6040.c | 2 +- sound/soc/codecs/uda134x.c | 2 +- sound/soc/codecs/uda1380.c | 2 +- sound/soc/codecs/wl1273.c | 2 +- sound/soc/codecs/zx_aud96p22.c | 2 +- 109 files changed, 109 insertions(+), 109 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index b013a4c..848c5fe 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -1355,7 +1355,7 @@ static struct regmap *pm860x_get_regmap(struct device *dev) return pm860x->regmap; } -static struct snd_soc_codec_driver soc_codec_dev_pm860x = { +static const struct snd_soc_codec_driver soc_codec_dev_pm860x = { .probe = pm860x_probe, .remove = pm860x_remove, .set_bias_level = pm860x_set_bias_level, diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 312b2a1..006627b 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -2523,7 +2523,7 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) return status; } -static struct snd_soc_codec_driver ab8500_codec_driver = { +static const struct snd_soc_codec_driver ab8500_codec_driver = { .probe = ab8500_codec_probe, .component_driver = { .controls = ab8500_ctrls, diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index f7f04c6..440b4ce 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -112,7 +112,7 @@ static int ac97_soc_resume(struct snd_soc_codec *codec) #define ac97_soc_resume NULL #endif -static struct snd_soc_codec_driver soc_codec_dev_ac97 = { +static const struct snd_soc_codec_driver soc_codec_dev_ac97 = { .probe = ac97_soc_probe, .suspend = ac97_soc_suspend, .resume = ac97_soc_resume, diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index a478239..d0361ca 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c @@ -321,7 +321,7 @@ static int ad1836_remove(struct snd_soc_codec *codec) AD1836_ADC_SERFMT_MASK, 0); } -static struct snd_soc_codec_driver soc_codec_dev_ad1836 = { +static const struct snd_soc_codec_driver soc_codec_dev_ad1836 = { .probe = ad1836_probe, .remove = ad1836_remove, .suspend = ad1836_suspend, diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index d643557..d10988e 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -408,7 +408,7 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_ad193x = { +static const struct snd_soc_codec_driver soc_codec_dev_ad193x = { .probe = ad193x_codec_probe, .component_driver = { .controls = ad193x_snd_controls, diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index b7c1b9f..ce89bfb 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c @@ -295,7 +295,7 @@ static int ad1980_soc_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_ad1980 = { +static const struct snd_soc_codec_driver soc_codec_dev_ad1980 = { .probe = ad1980_soc_probe, .remove = ad1980_soc_remove, diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c index 3e358a4..d8d86a0 100644 --- a/sound/soc/codecs/ad73311.c +++ b/sound/soc/codecs/ad73311.c @@ -54,7 +54,7 @@ static struct snd_soc_dai_driver ad73311_dai = { .formats = SNDRV_PCM_FMTBIT_S16_LE, }, }; -static struct snd_soc_codec_driver soc_codec_dev_ad73311 = { +static const struct snd_soc_codec_driver soc_codec_dev_ad73311 = { .component_driver = { .dapm_widgets = ad73311_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index 8fa9045..a865945 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -1458,7 +1458,7 @@ static const struct regmap_config adau1373_regmap_config = { .num_reg_defaults = ARRAY_SIZE(adau1373_reg_defaults), }; -static struct snd_soc_codec_driver adau1373_codec_driver = { +static const struct snd_soc_codec_driver adau1373_codec_driver = { .probe = adau1373_probe, .resume = adau1373_resume, .set_bias_level = adau1373_set_bias_level, diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c index 3bad1bc..805afac 100644 --- a/sound/soc/codecs/adau1701.c +++ b/sound/soc/codecs/adau1701.c @@ -757,7 +757,7 @@ static int adau1701_resume(struct snd_soc_codec *codec) #define adau1701_suspend NULL #endif /* CONFIG_PM */ -static struct snd_soc_codec_driver adau1701_codec_drv = { +static const struct snd_soc_codec_driver adau1701_codec_drv = { .probe = adau1701_probe, .remove = adau1701_remove, .resume = adau1701_resume, diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c index b319db6..32928167 100644 --- a/sound/soc/codecs/adau1977.c +++ b/sound/soc/codecs/adau1977.c @@ -867,7 +867,7 @@ static int adau1977_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver adau1977_codec_driver = { +static const struct snd_soc_codec_driver adau1977_codec_driver = { .probe = adau1977_codec_probe, .set_bias_level = adau1977_set_bias_level, .set_sysclk = adau1977_set_sysclk, diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 6e793eb..da7ca81 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -825,7 +825,7 @@ static int adav80x_resume(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver adav80x_codec_driver = { +static const struct snd_soc_codec_driver adav80x_codec_driver = { .probe = adav80x_probe, .resume = adav80x_resume, .set_bias_level = adav80x_set_bias_level, diff --git a/sound/soc/codecs/ads117x.c b/sound/soc/codecs/ads117x.c index 90c756d..b7f0057 100644 --- a/sound/soc/codecs/ads117x.c +++ b/sound/soc/codecs/ads117x.c @@ -58,7 +58,7 @@ static struct snd_soc_dai_driver ads117x_dai = { .formats = ADS117X_FORMATS,}, }; -static struct snd_soc_codec_driver soc_codec_dev_ads117x = { +static const struct snd_soc_codec_driver soc_codec_dev_ads117x = { .component_driver = { .dapm_widgets = ads117x_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets), diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index 1a9d233..dbb1841 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c @@ -242,7 +242,7 @@ static int ak4104_soc_resume(struct snd_soc_codec *codec) #define ak4104_soc_resume NULL #endif /* CONFIG_PM */ -static struct snd_soc_codec_driver soc_codec_device_ak4104 = { +static const struct snd_soc_codec_driver soc_codec_device_ak4104 = { .probe = ak4104_probe, .remove = ak4104_remove, .suspend = ak4104_soc_suspend, diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index 66cfffd..e3c157d 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -390,7 +390,7 @@ static const struct regmap_config ak4535_regmap = { .num_reg_defaults = ARRAY_SIZE(ak4535_reg_defaults), }; -static struct snd_soc_codec_driver soc_codec_dev_ak4535 = { +static const struct snd_soc_codec_driver soc_codec_dev_ak4535 = { .resume = ak4535_resume, .set_bias_level = ak4535_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/ak4554.c b/sound/soc/codecs/ak4554.c index b92c548..0bb4fe5 100644 --- a/sound/soc/codecs/ak4554.c +++ b/sound/soc/codecs/ak4554.c @@ -64,7 +64,7 @@ static struct snd_soc_dai_driver ak4554_dai = { .symmetric_rates = 1, }; -static struct snd_soc_codec_driver soc_codec_dev_ak4554 = { +static const struct snd_soc_codec_driver soc_codec_dev_ak4554 = { .component_driver = { .dapm_widgets = ak4554_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c index 690edeb..b95bb8b 100644 --- a/sound/soc/codecs/ak4613.c +++ b/sound/soc/codecs/ak4613.c @@ -522,7 +522,7 @@ static int ak4613_resume(struct snd_soc_codec *codec) return regcache_sync(regmap); } -static struct snd_soc_codec_driver soc_codec_dev_ak4613 = { +static const struct snd_soc_codec_driver soc_codec_dev_ak4613 = { .suspend = ak4613_suspend, .resume = ak4613_resume, .set_bias_level = ak4613_set_bias_level, diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index ebdaf56..60142ff 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c @@ -524,7 +524,7 @@ static struct snd_soc_dai_driver ak4641_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_ak4641 = { +static const struct snd_soc_codec_driver soc_codec_dev_ak4641 = { .component_driver = { .controls = ak4641_snd_controls, .num_controls = ARRAY_SIZE(ak4641_snd_controls), diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 66de8a2..29530c5 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -550,7 +550,7 @@ static int ak4642_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_ak4642 = { +static const struct snd_soc_codec_driver soc_codec_dev_ak4642 = { .probe = ak4642_probe, .suspend = ak4642_suspend, .resume = ak4642_resume, diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c index 6088afa..dcfdff5 100644 --- a/sound/soc/codecs/ak4671.c +++ b/sound/soc/codecs/ak4671.c @@ -610,7 +610,7 @@ static struct snd_soc_dai_driver ak4671_dai = { .ops = &ak4671_dai_ops, }; -static struct snd_soc_codec_driver soc_codec_dev_ak4671 = { +static const struct snd_soc_codec_driver soc_codec_dev_ak4671 = { .set_bias_level = ak4671_set_bias_level, .component_driver = { .controls = ak4671_snd_controls, diff --git a/sound/soc/codecs/ak5386.c b/sound/soc/codecs/ak5386.c index 0ef2df2..d0e16c0 100644 --- a/sound/soc/codecs/ak5386.c +++ b/sound/soc/codecs/ak5386.c @@ -69,7 +69,7 @@ static int ak5386_soc_resume(struct snd_soc_codec *codec) #define ak5386_soc_resume NULL #endif /* CONFIG_PM */ -static struct snd_soc_codec_driver soc_codec_ak5386 = { +static const struct snd_soc_codec_driver soc_codec_ak5386 = { .probe = ak5386_soc_probe, .remove = ak5386_soc_remove, .suspend = ak5386_soc_suspend, diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c index d2e3a3e..1db965a 100644 --- a/sound/soc/codecs/alc5623.c +++ b/sound/soc/codecs/alc5623.c @@ -951,7 +951,7 @@ static int alc5623_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_device_alc5623 = { +static const struct snd_soc_codec_driver soc_codec_device_alc5623 = { .probe = alc5623_probe, .suspend = alc5623_suspend, .resume = alc5623_resume, diff --git a/sound/soc/codecs/bt-sco.c b/sound/soc/codecs/bt-sco.c index 8014e69..806191a 100644 --- a/sound/soc/codecs/bt-sco.c +++ b/sound/soc/codecs/bt-sco.c @@ -62,7 +62,7 @@ static struct snd_soc_dai_driver bt_sco_dai[] = { } }; -static struct snd_soc_codec_driver soc_codec_dev_bt_sco = { +static const struct snd_soc_codec_driver soc_codec_dev_bt_sco = { .component_driver = { .dapm_widgets = bt_sco_widgets, .num_dapm_widgets = ARRAY_SIZE(bt_sco_widgets), diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 7a2d9a2..6ed2cc3 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -128,7 +128,7 @@ static struct regmap *cq93vc_get_regmap(struct device *dev) return davinci_vc->regmap; } -static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { +static const struct snd_soc_codec_driver soc_codec_dev_cq93vc = { .set_bias_level = cq93vc_set_bias_level, .get_regmap = cq93vc_get_regmap, .component_driver = { diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c index 6df29fa..61d128b 100644 --- a/sound/soc/codecs/cs35l33.c +++ b/sound/soc/codecs/cs35l33.c @@ -831,7 +831,7 @@ static int cs35l33_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_cs35l33 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs35l33 = { .probe = cs35l33_probe, .set_bias_level = cs35l33_set_bias_level, diff --git a/sound/soc/codecs/cs35l34.c b/sound/soc/codecs/cs35l34.c index 0a747c6..15d712f 100644 --- a/sound/soc/codecs/cs35l34.c +++ b/sound/soc/codecs/cs35l34.c @@ -779,7 +779,7 @@ static int cs35l34_probe(struct snd_soc_codec *codec) } -static struct snd_soc_codec_driver soc_codec_dev_cs35l34 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs35l34 = { .probe = cs35l34_probe, .component_driver = { diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c index f1ee184..129978d 100644 --- a/sound/soc/codecs/cs35l35.c +++ b/sound/soc/codecs/cs35l35.c @@ -1079,7 +1079,7 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_cs35l35 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs35l35 = { .probe = cs35l35_codec_probe, .set_sysclk = cs35l35_codec_set_sysclk, .component_driver = { diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index d882477..49a8062 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -639,7 +639,7 @@ static int cs4271_codec_remove(struct snd_soc_codec *codec) return 0; }; -static struct snd_soc_codec_driver soc_codec_dev_cs4271 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs4271 = { .probe = cs4271_codec_probe, .remove = cs4271_codec_remove, .suspend = cs4271_soc_suspend, diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 96cfe38..f8072f1 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -504,7 +504,7 @@ static int cs42l51_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { +static const struct snd_soc_codec_driver soc_codec_device_cs42l51 = { .probe = cs42l51_codec_probe, .component_driver = { diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c index 231ca93..0a749c7 100644 --- a/sound/soc/codecs/cs4349.c +++ b/sound/soc/codecs/cs4349.c @@ -255,7 +255,7 @@ static struct snd_soc_dai_driver cs4349_dai = { .symmetric_rates = 1, }; -static struct snd_soc_codec_driver soc_codec_dev_cs4349 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs4349 = { .component_driver = { .controls = cs4349_snd_controls, .num_controls = ARRAY_SIZE(cs4349_snd_controls), diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index 47e6fdd..d323caa 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -1183,7 +1183,7 @@ static struct regmap *cs47l24_get_regmap(struct device *dev) return priv->core.arizona->regmap; } -static struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { +static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .probe = cs47l24_codec_probe, .remove = cs47l24_codec_remove, .get_regmap = cs47l24_get_regmap, diff --git a/sound/soc/codecs/cs53l30.c b/sound/soc/codecs/cs53l30.c index 06933a5..da4ee56 100644 --- a/sound/soc/codecs/cs53l30.c +++ b/sound/soc/codecs/cs53l30.c @@ -892,7 +892,7 @@ static int cs53l30_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver cs53l30_driver = { +static const struct snd_soc_codec_driver cs53l30_driver = { .probe = cs53l30_codec_probe, .set_bias_level = cs53l30_set_bias_level, .idle_bias_off = true, diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c index 2c12471..46b1fbb 100644 --- a/sound/soc/codecs/cx20442.c +++ b/sound/soc/codecs/cx20442.c @@ -398,7 +398,7 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec) static const u8 cx20442_reg; -static struct snd_soc_codec_driver cx20442_codec_dev = { +static const struct snd_soc_codec_driver cx20442_codec_dev = { .probe = cx20442_codec_probe, .remove = cx20442_codec_remove, .set_bias_level = cx20442_set_bias_level, diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 17053df..1af443c 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -1164,7 +1164,7 @@ static int da7210_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_da7210 = { +static const struct snd_soc_codec_driver soc_codec_dev_da7210 = { .probe = da7210_probe, .component_driver = { diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index c3e1189..cc0b2d2 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -1787,7 +1787,7 @@ static int da7213_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_da7213 = { +static const struct snd_soc_codec_driver soc_codec_dev_da7213 = { .probe = da7213_probe, .set_bias_level = da7213_set_bias_level, diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c index 6e1940e..b2d42ec 100644 --- a/sound/soc/codecs/da7218.c +++ b/sound/soc/codecs/da7218.c @@ -3035,7 +3035,7 @@ static int da7218_resume(struct snd_soc_codec *codec) #define da7218_resume NULL #endif -static struct snd_soc_codec_driver soc_codec_dev_da7218 = { +static const struct snd_soc_codec_driver soc_codec_dev_da7218 = { .probe = da7218_probe, .remove = da7218_remove, .suspend = da7218_suspend, diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index f71d72c..6f08853 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -1891,7 +1891,7 @@ static int da7219_resume(struct snd_soc_codec *codec) #define da7219_resume NULL #endif -static struct snd_soc_codec_driver soc_codec_dev_da7219 = { +static const struct snd_soc_codec_driver soc_codec_dev_da7219 = { .probe = da7219_probe, .remove = da7219_remove, .suspend = da7219_suspend, diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c index c1cc1c1..83db4d2 100644 --- a/sound/soc/codecs/da732x.c +++ b/sound/soc/codecs/da732x.c @@ -1499,7 +1499,7 @@ static int da732x_set_bias_level(struct snd_soc_codec *codec, return 0; } -static struct snd_soc_codec_driver soc_codec_dev_da732x = { +static const struct snd_soc_codec_driver soc_codec_dev_da732x = { .set_bias_level = da732x_set_bias_level, .component_driver = { .controls = da732x_snd_controls, diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c index 4efb5f8..bd7faae 100644 --- a/sound/soc/codecs/da9055.c +++ b/sound/soc/codecs/da9055.c @@ -1451,7 +1451,7 @@ static int da9055_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_da9055 = { +static const struct snd_soc_codec_driver soc_codec_dev_da9055 = { .probe = da9055_probe, .set_bias_level = da9055_set_bias_level, diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index c82b9dc..6fe6c0a 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -50,7 +50,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"DMIC AIF", NULL, "DMic"}, }; -static struct snd_soc_codec_driver soc_dmic = { +static const struct snd_soc_codec_driver soc_dmic = { .component_driver = { .dapm_widgets = dmic_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets), diff --git a/sound/soc/codecs/es7134.c b/sound/soc/codecs/es7134.c index 25ede82..3869025 100644 --- a/sound/soc/codecs/es7134.c +++ b/sound/soc/codecs/es7134.c @@ -69,7 +69,7 @@ static const struct snd_soc_dapm_route es7134_dapm_routes[] = { { "AOUTR", NULL, "DAC" }, }; -static struct snd_soc_codec_driver es7134_codec_driver = { +static const struct snd_soc_codec_driver es7134_codec_driver = { .component_driver = { .dapm_widgets = es7134_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(es7134_dapm_widgets), diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index ecc02449..4f35af6 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -554,7 +554,7 @@ static int es8316_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_es8316 = { +static const struct snd_soc_codec_driver soc_codec_dev_es8316 = { .probe = es8316_probe, .idle_bias_off = true, diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index ed7cc42..bcdb891 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -830,7 +830,7 @@ const struct regmap_config es8328_regmap_config = { }; EXPORT_SYMBOL_GPL(es8328_regmap_config); -static struct snd_soc_codec_driver es8328_codec_driver = { +static const struct snd_soc_codec_driver es8328_codec_driver = { .probe = es8328_codec_probe, .suspend = es8328_suspend, .resume = es8328_resume, diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index e6de50a..e808f94 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1858,7 +1858,7 @@ static void hdmi_codec_complete(struct device *dev) #define hdmi_codec_complete NULL #endif -static struct snd_soc_codec_driver hdmi_hda_codec = { +static const struct snd_soc_codec_driver hdmi_hda_codec = { .probe = hdmi_codec_probe, .remove = hdmi_codec_remove, .idle_bias_off = true, diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 509ab51..f288404 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -733,7 +733,7 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, return ret; } -static struct snd_soc_codec_driver hdmi_codec = { +static const struct snd_soc_codec_driver hdmi_codec = { .component_driver = { .dapm_widgets = hdmi_widgets, .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), diff --git a/sound/soc/codecs/ics43432.c b/sound/soc/codecs/ics43432.c index dd850b9..6512062 100644 --- a/sound/soc/codecs/ics43432.c +++ b/sound/soc/codecs/ics43432.c @@ -37,7 +37,7 @@ static struct snd_soc_dai_driver ics43432_dai = { }, }; -static struct snd_soc_codec_driver ics43432_codec_driver = { +static const struct snd_soc_codec_driver ics43432_codec_driver = { }; static int ics43432_probe(struct platform_device *pdev) diff --git a/sound/soc/codecs/inno_rk3036.c b/sound/soc/codecs/inno_rk3036.c index b918ba5..64b0be9 100644 --- a/sound/soc/codecs/inno_rk3036.c +++ b/sound/soc/codecs/inno_rk3036.c @@ -376,7 +376,7 @@ static int rk3036_codec_set_bias_level(struct snd_soc_codec *codec, return 0; } -static struct snd_soc_codec_driver rk3036_codec_driver = { +static const struct snd_soc_codec_driver rk3036_codec_driver = { .probe = rk3036_codec_probe, .remove = rk3036_codec_remove, .set_bias_level = rk3036_codec_set_bias_level, diff --git a/sound/soc/codecs/isabelle.c b/sound/soc/codecs/isabelle.c index a4b0ede..5ca9928 100644 --- a/sound/soc/codecs/isabelle.c +++ b/sound/soc/codecs/isabelle.c @@ -1087,7 +1087,7 @@ static struct snd_soc_dai_driver isabelle_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_isabelle = { +static const struct snd_soc_codec_driver soc_codec_dev_isabelle = { .set_bias_level = isabelle_set_bias_level, .component_driver = { .controls = isabelle_snd_controls, diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c index 0290fab..6324ccd 100644 --- a/sound/soc/codecs/jz4740.c +++ b/sound/soc/codecs/jz4740.c @@ -293,7 +293,7 @@ static int jz4740_codec_dev_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_jz4740_codec = { +static const struct snd_soc_codec_driver soc_codec_dev_jz4740_codec = { .probe = jz4740_codec_dev_probe, .set_bias_level = jz4740_codec_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c index 8d413c2..41e09d1 100644 --- a/sound/soc/codecs/lm49453.c +++ b/sound/soc/codecs/lm49453.c @@ -1389,7 +1389,7 @@ static struct snd_soc_dai_driver lm49453_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_lm49453 = { +static const struct snd_soc_codec_driver soc_codec_dev_lm49453 = { .set_bias_level = lm49453_set_bias_level, .component_driver = { .controls = lm49453_snd_controls, diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 72f7745..f0bb830 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -1698,7 +1698,7 @@ static int max98088_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_max98088 = { +static const struct snd_soc_codec_driver soc_codec_dev_max98088 = { .probe = max98088_probe, .remove = max98088_remove, .set_bias_level = max98088_set_bias_level, diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 6682848..13bcfb1 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -2499,7 +2499,7 @@ static void max98090_seq_notifier(struct snd_soc_dapm_context *dapm, } } -static struct snd_soc_codec_driver soc_codec_dev_max98090 = { +static const struct snd_soc_codec_driver soc_codec_dev_max98090 = { .probe = max98090_probe, .remove = max98090_remove, .seq_notifier = max98090_seq_notifier, diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 6f8a757..5ead87d 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -2102,7 +2102,7 @@ static int max98095_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_max98095 = { +static const struct snd_soc_codec_driver soc_codec_dev_max98095 = { .probe = max98095_probe, .remove = max98095_remove, .suspend = max98095_suspend, diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c index 6a6b68a..426ed2d 100644 --- a/sound/soc/codecs/max98357a.c +++ b/sound/soc/codecs/max98357a.c @@ -72,7 +72,7 @@ static int max98357a_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver max98357a_codec_driver = { +static const struct snd_soc_codec_driver max98357a_codec_driver = { .probe = max98357a_codec_probe, .component_driver = { .dapm_widgets = max98357a_dapm_widgets, diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index 0610840..a3dfc91 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c @@ -301,7 +301,7 @@ static int max9850_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_max9850 = { +static const struct snd_soc_codec_driver soc_codec_dev_max9850 = { .probe = max9850_probe, .set_bias_level = max9850_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/max9860.c b/sound/soc/codecs/max9860.c index 499bdbf..a2dc6a4 100644 --- a/sound/soc/codecs/max9860.c +++ b/sound/soc/codecs/max9860.c @@ -534,7 +534,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, return 0; } -static struct snd_soc_codec_driver max9860_codec_driver = { +static const struct snd_soc_codec_driver max9860_codec_driver = { .set_bias_level = max9860_set_bias_level, .idle_bias_off = true, diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2a40a69..6c0c0d6 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -413,7 +413,7 @@ static int max9867_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver max9867_codec = { +static const struct snd_soc_codec_driver max9867_codec = { .probe = max9867_probe, .component_driver = { .controls = max9867_snd_controls, diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index 1eff7e0..7a39bfb 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -496,7 +496,7 @@ static int max98926_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_max98926 = { +static const struct snd_soc_codec_driver soc_codec_dev_max98926 = { .probe = max98926_probe, .component_driver = { .controls = max98926_snd_controls, diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 9056270..4fd8d1d 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -733,7 +733,7 @@ static struct regmap *mc13783_get_regmap(struct device *dev) return dev_get_regmap(dev->parent, NULL); } -static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { +static const struct snd_soc_codec_driver soc_codec_dev_mc13783 = { .probe = mc13783_probe, .remove = mc13783_remove, .get_regmap = mc13783_get_regmap, diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c index 69e5e18..5cc960d 100644 --- a/sound/soc/codecs/ml26124.c +++ b/sound/soc/codecs/ml26124.c @@ -537,7 +537,7 @@ static int ml26124_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_ml26124 = { +static const struct snd_soc_codec_driver soc_codec_dev_ml26124 = { .probe = ml26124_probe, .set_bias_level = ml26124_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a788029..4cc52ce 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -785,7 +785,7 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { }, }; -static struct snd_soc_codec_driver pm8916_wcd_analog = { +static const struct snd_soc_codec_driver pm8916_wcd_analog = { .probe = pm8916_wcd_analog_probe, .remove = pm8916_wcd_analog_remove, .get_regmap = pm8916_get_regmap, diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index 661cd6d..43a915c 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -830,7 +830,7 @@ static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = { }, }; -static struct snd_soc_codec_driver msm8916_wcd_digital = { +static const struct snd_soc_codec_driver msm8916_wcd_digital = { .probe = msm8916_wcd_digital_codec_probe, .set_sysclk = msm8916_wcd_digital_codec_set_sysclk, .component_driver = { diff --git a/sound/soc/codecs/nau8540.c b/sound/soc/codecs/nau8540.c index c8bcb1d..f9c9933 100644 --- a/sound/soc/codecs/nau8540.c +++ b/sound/soc/codecs/nau8540.c @@ -735,7 +735,7 @@ static int __maybe_unused nau8540_resume(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver nau8540_codec_driver = { +static const struct snd_soc_codec_driver nau8540_codec_driver = { .set_sysclk = nau8540_set_sysclk, .set_pll = nau8540_set_pll, .suspend = nau8540_suspend, diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c index e455186..c8e2451 100644 --- a/sound/soc/codecs/nau8810.c +++ b/sound/soc/codecs/nau8810.c @@ -808,7 +808,7 @@ static const struct regmap_config nau8810_regmap_config = { .num_reg_defaults = ARRAY_SIZE(nau8810_reg_defaults), }; -static struct snd_soc_codec_driver nau8810_codec_driver = { +static const struct snd_soc_codec_driver nau8810_codec_driver = { .set_bias_level = nau8810_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c index 3a309b1..0240759 100644 --- a/sound/soc/codecs/nau8824.c +++ b/sound/soc/codecs/nau8824.c @@ -1469,7 +1469,7 @@ static int __maybe_unused nau8824_resume(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver nau8824_codec_driver = { +static const struct snd_soc_codec_driver nau8824_codec_driver = { .probe = nau8824_codec_probe, .set_sysclk = nau8824_set_sysclk, .set_pll = nau8824_set_pll, diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 46a30ea..000aa79 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -2388,7 +2388,7 @@ static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver nau8825_codec_driver = { +static const struct snd_soc_codec_driver nau8825_codec_driver = { .probe = nau8825_codec_probe, .remove = nau8825_codec_remove, .set_sysclk = nau8825_set_sysclk, diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index 0b14efa..c7e28dd 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c @@ -288,7 +288,7 @@ static const struct regmap_config pcm1681_regmap = { .readable_reg = pcm1681_accessible_reg, }; -static struct snd_soc_codec_driver soc_codec_dev_pcm1681 = { +static const struct snd_soc_codec_driver soc_codec_dev_pcm1681 = { .component_driver = { .controls = pcm1681_controls, .num_controls = ARRAY_SIZE(pcm1681_controls), diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index b813a15..82a3d9d 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -205,7 +205,7 @@ const struct regmap_config pcm179x_regmap_config = { }; EXPORT_SYMBOL_GPL(pcm179x_regmap_config); -static struct snd_soc_codec_driver soc_codec_dev_pcm179x = { +static const struct snd_soc_codec_driver soc_codec_dev_pcm179x = { .component_driver = { .controls = pcm179x_controls, .num_controls = ARRAY_SIZE(pcm179x_controls), diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c index 708af05..e59d8ff 100644 --- a/sound/soc/codecs/pcm3008.c +++ b/sound/soc/codecs/pcm3008.c @@ -98,7 +98,7 @@ static struct snd_soc_dai_driver pcm3008_dai = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_pcm3008 = { +static const struct snd_soc_codec_driver soc_codec_dev_pcm3008 = { .component_driver = { .dapm_widgets = pcm3008_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(pcm3008_dapm_widgets), diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 72b19e6..f1005a3 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -1344,7 +1344,7 @@ static struct snd_soc_dai_driver pcm512x_dai = { .ops = &pcm512x_dai_ops, }; -static struct snd_soc_codec_driver pcm512x_codec_driver = { +static const struct snd_soc_codec_driver pcm512x_codec_driver = { .set_bias_level = pcm512x_set_bias_level, .idle_bias_off = true, diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index fb683ff..58cfe24 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -1055,7 +1055,7 @@ static struct snd_soc_dai_driver rt274_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt274 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt274 = { .probe = rt274_probe, .remove = rt274_remove, .suspend = rt274_suspend, diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index 7899a2c..af6325c 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -1046,7 +1046,7 @@ static struct snd_soc_dai_driver rt286_dai[] = { }; -static struct snd_soc_codec_driver soc_codec_dev_rt286 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt286 = { .probe = rt286_probe, .remove = rt286_remove, .suspend = rt286_suspend, diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c index d9e96e6..ce96376 100644 --- a/sound/soc/codecs/rt298.c +++ b/sound/soc/codecs/rt298.c @@ -1113,7 +1113,7 @@ static struct snd_soc_dai_driver rt298_dai[] = { }; -static struct snd_soc_codec_driver soc_codec_dev_rt298 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt298 = { .probe = rt298_probe, .remove = rt298_remove, .suspend = rt298_suspend, diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 1b6796c..7a1b36f 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -1042,7 +1042,7 @@ struct snd_soc_dai_driver rt5514_dai[] = { } }; -static struct snd_soc_codec_driver soc_codec_dev_rt5514 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5514 = { .probe = rt5514_probe, .idle_bias_off = true, .set_bias_level = rt5514_set_bias_level, diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 7d6e082..3c5f555 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -1294,7 +1294,7 @@ static struct snd_soc_dai_driver rt5616_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5616 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5616 = { .probe = rt5616_probe, .suspend = rt5616_suspend, .resume = rt5616_resume, diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index 0e41808..55b04c5 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -1653,7 +1653,7 @@ static struct snd_soc_dai_driver rt5631_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5631 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5631 = { .probe = rt5631_probe, .set_bias_level = rt5631_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 1584ccc..438fe52 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2259,7 +2259,7 @@ static struct snd_soc_dai_driver rt5640_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5640 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5640 = { .probe = rt5640_probe, .remove = rt5640_remove, .suspend = rt5640_suspend, diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 9ec5816..ce31d0d 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3473,7 +3473,7 @@ static struct snd_soc_dai_driver rt5645_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5645 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5645 = { .probe = rt5645_probe, .remove = rt5645_remove, .suspend = rt5645_suspend, diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index db05b60..da60b28 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1664,7 +1664,7 @@ static struct snd_soc_dai_driver rt5651_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5651 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5651 = { .probe = rt5651_probe, .suspend = rt5651_suspend, .resume = rt5651_resume, diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index 1b70608..e8018fc 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -3730,7 +3730,7 @@ static struct snd_soc_dai_driver rt5659_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5659 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5659 = { .probe = rt5659_probe, .remove = rt5659_remove, .suspend = rt5659_suspend, diff --git a/sound/soc/codecs/rt5660.c b/sound/soc/codecs/rt5660.c index c93490d..d22ef00 100644 --- a/sound/soc/codecs/rt5660.c +++ b/sound/soc/codecs/rt5660.c @@ -1197,7 +1197,7 @@ static struct snd_soc_dai_driver rt5660_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5660 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5660 = { .probe = rt5660_probe, .remove = rt5660_remove, .suspend = rt5660_suspend, diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index a33202a..ebc5e3b 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2891,7 +2891,7 @@ static struct snd_soc_dai_driver rt5663_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5663 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5663 = { .probe = rt5663_probe, .remove = rt5663_remove, .suspend = rt5663_suspend, diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 370ed54d..2c40545 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -4562,7 +4562,7 @@ static struct snd_soc_dai_driver rt5665_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5665 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5665 = { .probe = rt5665_probe, .remove = rt5665_remove, .suspend = rt5665_suspend, diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 0ec7985..52a6ce8 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -2765,7 +2765,7 @@ static struct snd_soc_dai_driver rt5670_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5670 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5670 = { .probe = rt5670_probe, .remove = rt5670_remove, .suspend = rt5670_suspend, diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 36e530a..ce9b65d 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -4968,7 +4968,7 @@ static struct snd_soc_dai_driver rt5677_dai[] = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_rt5677 = { +static const struct snd_soc_codec_driver soc_codec_dev_rt5677 = { .probe = rt5677_probe, .remove = rt5677_remove, .suspend = rt5677_suspend, diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 8f6814c..68e7020 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1248,7 +1248,7 @@ static int sgtl5000_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver sgtl5000_driver = { +static const struct snd_soc_codec_driver sgtl5000_driver = { .probe = sgtl5000_probe, .remove = sgtl5000_remove, .set_bias_level = sgtl5000_set_bias_level, diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 5344f4a..354dc0d 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c @@ -236,7 +236,7 @@ static struct regmap *si476x_get_regmap(struct device *dev) return dev_get_regmap(dev->parent, NULL); } -static struct snd_soc_codec_driver soc_codec_dev_si476x = { +static const struct snd_soc_codec_driver soc_codec_dev_si476x = { .get_regmap = si476x_get_regmap, .component_driver = { .dapm_widgets = si476x_dapm_widgets, diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index 6bfd25c..50bc222 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c @@ -429,7 +429,7 @@ static int sirf_audio_codec_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_device_sirf_audio_codec = { +static const struct snd_soc_codec_driver soc_codec_device_sirf_audio_codec = { .probe = sirf_audio_codec_probe, .remove = sirf_audio_codec_remove, .dapm_widgets = sirf_audio_codec_dapm_widgets, diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index eae54c3..887923e 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c @@ -883,7 +883,7 @@ static int sn95031_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver sn95031_codec = { +static const struct snd_soc_codec_driver sn95031_codec = { .probe = sn95031_codec_probe, .set_bias_level = sn95031_set_vaud_bias, .idle_bias_off = true, diff --git a/sound/soc/codecs/spdif_receiver.c b/sound/soc/codecs/spdif_receiver.c index 234f87b..7acd051 100644 --- a/sound/soc/codecs/spdif_receiver.c +++ b/sound/soc/codecs/spdif_receiver.c @@ -37,7 +37,7 @@ static const struct snd_soc_dapm_route dir_routes[] = { SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) -static struct snd_soc_codec_driver soc_codec_spdif_dir = { +static const struct snd_soc_codec_driver soc_codec_spdif_dir = { .component_driver = { .dapm_widgets = dir_widgets, .num_dapm_widgets = ARRAY_SIZE(dir_widgets), diff --git a/sound/soc/codecs/spdif_transmitter.c b/sound/soc/codecs/spdif_transmitter.c index ee36753..063a64f 100644 --- a/sound/soc/codecs/spdif_transmitter.c +++ b/sound/soc/codecs/spdif_transmitter.c @@ -37,7 +37,7 @@ static const struct snd_soc_dapm_route dit_routes[] = { { "spdif-out", NULL, "Playback" }, }; -static struct snd_soc_codec_driver soc_codec_spdif_dit = { +static const struct snd_soc_codec_driver soc_codec_spdif_dit = { .component_driver = { .dapm_widgets = dit_widgets, .num_dapm_widgets = ARRAY_SIZE(dit_widgets), diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c index 38a85f3..15486fd1 100644 --- a/sound/soc/codecs/ssm2518.c +++ b/sound/soc/codecs/ssm2518.c @@ -710,7 +710,7 @@ static int ssm2518_set_sysclk(struct snd_soc_codec *codec, int clk_id, SSM2518_POWER1_NO_BCLK, val); } -static struct snd_soc_codec_driver ssm2518_codec_driver = { +static const struct snd_soc_codec_driver ssm2518_codec_driver = { .set_bias_level = ssm2518_set_bias_level, .set_sysclk = ssm2518_set_sysclk, .idle_bias_off = true, diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 993bde2..9b341c2 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -591,7 +591,7 @@ static int ssm260x_codec_probe(struct snd_soc_codec *codec) return ret; } -static struct snd_soc_codec_driver soc_codec_dev_ssm2602 = { +static const struct snd_soc_codec_driver soc_codec_dev_ssm2602 = { .probe = ssm260x_codec_probe, .resume = ssm2602_resume, .set_bias_level = ssm2602_set_bias_level, diff --git a/sound/soc/codecs/ssm4567.c b/sound/soc/codecs/ssm4567.c index a622623..4afedde 100644 --- a/sound/soc/codecs/ssm4567.c +++ b/sound/soc/codecs/ssm4567.c @@ -417,7 +417,7 @@ static struct snd_soc_dai_driver ssm4567_dai = { .ops = &ssm4567_dai_ops, }; -static struct snd_soc_codec_driver ssm4567_codec_driver = { +static const struct snd_soc_codec_driver ssm4567_codec_driver = { .set_bias_level = ssm4567_set_bias_level, .idle_bias_off = true, diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c index 9de7fe8..c66363a 100644 --- a/sound/soc/codecs/stac9766.c +++ b/sound/soc/codecs/stac9766.c @@ -307,7 +307,7 @@ static int stac9766_codec_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_stac9766 = { +static const struct snd_soc_codec_driver soc_codec_dev_stac9766 = { .component_driver = { .controls = stac9766_snd_ac97_controls, .num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls), diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c index 8840f72..49cf9bc 100644 --- a/sound/soc/codecs/tas2552.c +++ b/sound/soc/codecs/tas2552.c @@ -660,7 +660,7 @@ static int tas2552_resume(struct snd_soc_codec *codec) #define tas2552_resume NULL #endif -static struct snd_soc_codec_driver soc_codec_dev_tas2552 = { +static const struct snd_soc_codec_driver soc_codec_dev_tas2552 = { .probe = tas2552_codec_probe, .remove = tas2552_codec_remove, .suspend = tas2552_suspend, diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index b7de857..199272d 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -885,7 +885,7 @@ static int tas5086_remove(struct snd_soc_codec *codec) return 0; }; -static struct snd_soc_codec_driver soc_codec_dev_tas5086 = { +static const struct snd_soc_codec_driver soc_codec_dev_tas5086 = { .probe = tas5086_probe, .remove = tas5086_remove, .suspend = tas5086_soc_suspend, diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c index c65b917..d14b78b 100644 --- a/sound/soc/codecs/tas5720.c +++ b/sound/soc/codecs/tas5720.c @@ -483,7 +483,7 @@ static const struct snd_soc_dapm_route tas5720_audio_map[] = { { "OUT", NULL, "DAC" }, }; -static struct snd_soc_codec_driver soc_codec_dev_tas5720 = { +static const struct snd_soc_codec_driver soc_codec_dev_tas5720 = { .probe = tas5720_codec_probe, .remove = tas5720_codec_remove, .suspend = tas5720_suspend, diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 628a8ee..3d42138 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -576,7 +576,7 @@ static int tlv320aic23_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { +static const struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { .probe = tlv320aic23_codec_probe, .resume = tlv320aic23_resume, .set_bias_level = tlv320aic23_set_bias_level, diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 14aa96d..89421ca 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -319,7 +319,7 @@ static int aic26_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver aic26_soc_codec_dev = { +static const struct snd_soc_codec_driver aic26_soc_codec_dev = { .probe = aic26_probe, .component_driver = { .controls = aic26_snd_controls, diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index d7d03c9..54a87a9 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -1185,7 +1185,7 @@ static int aic31xx_codec_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_driver_aic31xx = { +static const struct snd_soc_codec_driver soc_codec_driver_aic31xx = { .probe = aic31xx_codec_probe, .remove = aic31xx_codec_remove, .set_bias_level = aic31xx_set_bias_level, diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 28fdfc5..ccfc955 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -792,7 +792,7 @@ static int aic32x4_codec_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { +static const struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { .probe = aic32x4_codec_probe, .set_bias_level = aic32x4_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 29bf8c8..405f460 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -1684,7 +1684,7 @@ static int aic3x_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_aic3x = { +static const struct snd_soc_codec_driver soc_codec_dev_aic3x = { .set_bias_level = aic3x_set_bias_level, .idle_bias_off = true, .probe = aic3x_probe, diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 7bcf01e..5b94a15 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -1433,7 +1433,7 @@ static int dac33_soc_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_tlv320dac33 = { +static const struct snd_soc_codec_driver soc_codec_dev_tlv320dac33 = { .read = dac33_read_reg_cache, .write = dac33_write_locked, .set_bias_level = dac33_set_bias_level, diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index a2104d6..d439c4c 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -2191,7 +2191,7 @@ static int twl4030_soc_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_twl4030 = { +static const struct snd_soc_codec_driver soc_codec_dev_twl4030 = { .probe = twl4030_soc_probe, .remove = twl4030_soc_remove, .read = twl4030_read, diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 2b6ad09..0dc21f7 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -1155,7 +1155,7 @@ static int twl6040_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_twl6040 = { +static const struct snd_soc_codec_driver soc_codec_dev_twl6040 = { .probe = twl6040_probe, .remove = twl6040_remove, .read = twl6040_read, diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index 5fdee87..77c9cc4 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -518,7 +518,7 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_uda134x = { +static const struct snd_soc_codec_driver soc_codec_dev_uda134x = { .probe = uda134x_soc_probe, .set_bias_level = uda134x_set_bias_level, .suspend_bias_off = true, diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 61cdc79..926c81a 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -720,7 +720,7 @@ static int uda1380_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_uda1380 = { +static const struct snd_soc_codec_driver soc_codec_dev_uda1380 = { .probe = uda1380_probe, .read = uda1380_read_reg_cache, .write = uda1380_write, diff --git a/sound/soc/codecs/wl1273.c b/sound/soc/codecs/wl1273.c index fcffb6e..942f164 100644 --- a/sound/soc/codecs/wl1273.c +++ b/sound/soc/codecs/wl1273.c @@ -480,7 +480,7 @@ static int wl1273_remove(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_wl1273 = { +static const struct snd_soc_codec_driver soc_codec_dev_wl1273 = { .probe = wl1273_probe, .remove = wl1273_remove, diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c index 032fb7c..36d0a70 100644 --- a/sound/soc/codecs/zx_aud96p22.c +++ b/sound/soc/codecs/zx_aud96p22.c @@ -261,7 +261,7 @@ static const struct snd_soc_dapm_route aud96p22_dapm_routes[] = { { "LINEOUTMN", NULL, "LD2" }, }; -static struct snd_soc_codec_driver aud96p22_driver = { +static const struct snd_soc_codec_driver aud96p22_driver = { .component_driver = { .controls = aud96p22_snd_controls, .num_controls = ARRAY_SIZE(aud96p22_snd_controls), -- cgit v1.1 From 7a0cf42edd9cc335572aa8614df0ebefa2f537be Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 10 Aug 2017 16:21:34 +0200 Subject: ASoC: compress: Delete error messages for a failed memory allocation in snd_soc_new_compress() Omit extra messages for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/soc-compress.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 206f36b..6c867d5 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -764,15 +764,12 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) direction = SND_COMPRESS_CAPTURE; compr = kzalloc(sizeof(*compr), GFP_KERNEL); - if (compr == NULL) { - snd_printk(KERN_ERR "Cannot allocate compr\n"); + if (!compr) return -ENOMEM; - } compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops), GFP_KERNEL); - if (compr->ops == NULL) { - dev_err(rtd->card->dev, "Cannot allocate compressed ops\n"); + if (!compr->ops) { ret = -ENOMEM; goto compr_err; } -- cgit v1.1 From 52981e29eedf6e90ee381c2c1a64be1848d3353e Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Wed, 9 Aug 2017 18:49:23 +0200 Subject: ASoC: codecs: msm8916-wcd-analog: move codec reset to probe This patch move the codec reset code from dai ops to codec probe, so that the codec is not held in reset when headset detection block is still active. Without this patch the codec block will be in reset as long as its not actively used, which means headset events will not be functional if the codec dai is not actively used. Point to note is that the headset detection blocks will work in low power when there is no active audio usecase and switch to micbias source when audio usecase is active. Existing dapms should put the codec in low power state anyway when there is no audio usecase. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a788029..f9a74ff 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -536,6 +536,9 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, wcd_reg_defaults_2_0[reg].def); + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + RST_CTL_DIG_SW_RST_N_MASK, + RST_CTL_DIG_SW_RST_N_REMOVE_RESET); return 0; } @@ -543,6 +546,9 @@ static int pm8916_wcd_analog_remove(struct snd_soc_codec *codec) { struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + RST_CTL_DIG_SW_RST_N_MASK, 0); + return regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); } @@ -736,28 +742,6 @@ static struct regmap *pm8916_get_regmap(struct device *dev) return dev_get_regmap(dev->parent, NULL); } -static int pm8916_wcd_analog_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - snd_soc_update_bits(dai->codec, CDC_D_CDC_RST_CTL, - RST_CTL_DIG_SW_RST_N_MASK, - RST_CTL_DIG_SW_RST_N_REMOVE_RESET); - - return 0; -} - -static void pm8916_wcd_analog_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - snd_soc_update_bits(dai->codec, CDC_D_CDC_RST_CTL, - RST_CTL_DIG_SW_RST_N_MASK, 0); -} - -static struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { - .startup = pm8916_wcd_analog_startup, - .shutdown = pm8916_wcd_analog_shutdown, -}; - static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { [0] = { .name = "pm8916_wcd_analog_pdm_rx", @@ -769,7 +753,6 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { .channels_min = 1, .channels_max = 3, }, - .ops = &pm8916_wcd_analog_dai_ops, }, [1] = { .name = "pm8916_wcd_analog_pdm_tx", @@ -781,7 +764,6 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { .channels_min = 1, .channels_max = 4, }, - .ops = &pm8916_wcd_analog_dai_ops, }, }; -- cgit v1.1 From 0d7820d0918efa6c2a53acdfc47cbfc3b48df727 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 10 Aug 2017 17:13:19 +0200 Subject: ASoC: rsnd: Delete an error message for a failed memory allocation in three functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/sh/rcar/adg.c | 4 +--- sound/soc/sh/rcar/core.c | 4 +--- sound/soc/sh/rcar/gen.c | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index 5b5389e..938baff 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -586,10 +586,8 @@ int rsnd_adg_probe(struct rsnd_priv *priv) int ret; adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL); - if (!adg) { - dev_err(dev, "ADG allocate failed\n"); + if (!adg) return -ENOMEM; - } ret = rsnd_mod_init(priv, &adg->mod, &adg_ops, NULL, NULL, 0, 0); diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 2c12ad2..650cc28 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1401,10 +1401,8 @@ static int rsnd_probe(struct platform_device *pdev) * init priv data */ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) { - dev_err(dev, "priv allocate failed\n"); + if (!priv) return -ENODEV; - } priv->pdev = pdev; priv->flags = (unsigned long)of_device_get_match_data(dev); diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index ee00e35..f04c410 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -406,10 +406,8 @@ int rsnd_gen_probe(struct rsnd_priv *priv) int ret; gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); - if (!gen) { - dev_err(dev, "GEN allocate failed\n"); + if (!gen) return -ENOMEM; - } priv->gen = gen; -- cgit v1.1 From a0ac441152238c9b474bafa46940511d9b2e9c7e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 8 Aug 2017 06:17:47 +0000 Subject: ASoC: soc-core: add snd_soc_rtdcom_xxx() Current snd_soc_pcm_runtime has platform / codec pointers, and we could use these specific pointer. But these will be replaced to more generic "component" soon, and will need more generic method to get each connected component pointer from rtd. This patch adds new snd_soc_rtdcom_xxx() to connect/disconnect component to rtd. It means same as previous "platform" / "codec" pointer style, but more generic. We can find necessary component pointer from rtd by using component driver name on snd_soc_rtdcom_lookup(). Here, the reason why it uses "driver name" is that "component name" was created by fmt_single_name() and difficult to use it from driver. Driver of course knows its "driver name", thus, using it is more easy. Signed-off-by: Kuninori Morimoto Tested-by: Arnaud Pouliquen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 07d7084..c2462e0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -551,6 +551,54 @@ static inline void snd_soc_debugfs_exit(void) #endif +static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd, + struct snd_soc_component *component) +{ + struct snd_soc_rtdcom_list *rtdcom; + struct snd_soc_rtdcom_list *new_rtdcom; + + for_each_rtdcom(rtd, rtdcom) { + /* already connected */ + if (rtdcom->component == component) + return 0; + } + + new_rtdcom = kmalloc(sizeof(*new_rtdcom), GFP_KERNEL); + if (!new_rtdcom) + return -ENOMEM; + + new_rtdcom->component = component; + INIT_LIST_HEAD(&new_rtdcom->list); + + list_add_tail(&new_rtdcom->list, &rtd->component_list); + + return 0; +} + +static void snd_soc_rtdcom_del_all(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_rtdcom_list *rtdcom1, *rtdcom2; + + for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) + kfree(rtdcom1); + + INIT_LIST_HEAD(&rtd->component_list); +} + +struct snd_soc_component *snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd, + const char *driver_name) +{ + struct snd_soc_rtdcom_list *rtdcom; + + for_each_rtdcom(rtd, rtdcom) { + if ((rtdcom->component->driver->name == driver_name) || + strcmp(rtdcom->component->driver->name, driver_name) == 0) + return rtdcom->component; + } + + return NULL; +} + struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, const char *dai_link, int stream) { @@ -575,6 +623,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( if (!rtd) return NULL; + INIT_LIST_HEAD(&rtd->component_list); rtd->card = card; rtd->dai_link = dai_link; rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) * @@ -592,6 +641,7 @@ static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd) { if (rtd && rtd->codec_dais) kfree(rtd->codec_dais); + snd_soc_rtdcom_del_all(rtd); kfree(rtd); } -- cgit v1.1 From 90be711e23f7c7ee7b3d6a6e5aa7ee9bab321f2e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 8 Aug 2017 06:18:10 +0000 Subject: ASoC: use snd_soc_rtdcom_add() and convert to consistent operation Basically, current ALSA SoC framework is based on CPU/Codec/Platform, but its operation doesn't have consistent. Thus, source code was unreadable, and difficult to understand. This patch connects each component (= CPU/Codec/Platform) to rtd by using snd_soc_rtdcom_add(), and convert uneven operations to consistent operation. Signed-off-by: Kuninori Morimoto Tested-by: Arnaud Pouliquen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 61 +++++++++++++++++++++++----------------------------- sound/soc/soc-pcm.c | 38 ++++++++++++++++---------------- 2 files changed, 46 insertions(+), 53 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c2462e0..bbbe003 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1100,6 +1100,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai_link_component *codecs = dai_link->codecs; struct snd_soc_dai_link_component cpu_dai_component; + struct snd_soc_component *component; struct snd_soc_dai **codec_dais; struct snd_soc_platform *platform; struct device_node *platform_of_node; @@ -1127,6 +1128,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, dai_link->cpu_dai_name); goto _err_defer; } + snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); rtd->num_codecs = dai_link->num_codecs; @@ -1139,6 +1141,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, codecs[i].dai_name); goto _err_defer; } + snd_soc_rtdcom_add(rtd, codec_dais[i]->component); } /* Single codec links expect codec and codec_dai in runtime data */ @@ -1151,6 +1154,23 @@ static int soc_bind_dai_link(struct snd_soc_card *card, platform_name = "snd-soc-dummy"; /* find one from the set of registered platforms */ + list_for_each_entry(component, &component_list, list) { + platform_of_node = component->dev->of_node; + if (!platform_of_node && component->dev->parent->of_node) + platform_of_node = component->dev->parent->of_node; + + if (dai_link->platform_of_node) { + if (platform_of_node != dai_link->platform_of_node) + continue; + } else { + if (strcmp(component->name, platform_name)) + continue; + } + + snd_soc_rtdcom_add(rtd, component); + } + + /* find one from the set of registered platforms */ list_for_each_entry(platform, &platform_list, list) { platform_of_node = platform->dev->of_node; if (!platform_of_node && platform->dev->parent->of_node) @@ -1235,27 +1255,15 @@ static void soc_remove_link_dais(struct snd_soc_card *card, static void soc_remove_link_components(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int order) { - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; - int i; + struct snd_soc_rtdcom_list *rtdcom; - /* remove the platform */ - if (platform && platform->component.driver->remove_order == order) - soc_remove_component(&platform->component); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; - /* remove the CODEC-side CODEC */ - for (i = 0; i < rtd->num_codecs; i++) { - component = rtd->codec_dais[i]->component; if (component->driver->remove_order == order) soc_remove_component(component); } - - /* remove any CPU-side CODEC */ - if (cpu_dai) { - if (cpu_dai->component->driver->remove_order == order) - soc_remove_component(cpu_dai->component); - } } static void soc_remove_dai_links(struct snd_soc_card *card) @@ -1607,21 +1615,13 @@ static int soc_probe_link_components(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int order) { - struct snd_soc_platform *platform = rtd->platform; struct snd_soc_component *component; - int i, ret; + struct snd_soc_rtdcom_list *rtdcom; + int ret; - /* probe the CPU-side component, if it is a CODEC */ - component = rtd->cpu_dai->component; - if (component->driver->probe_order == order) { - ret = soc_probe_component(card, component); - if (ret < 0) - return ret; - } + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; - /* probe the CODEC-side components */ - for (i = 0; i < rtd->num_codecs; i++) { - component = rtd->codec_dais[i]->component; if (component->driver->probe_order == order) { ret = soc_probe_component(card, component); if (ret < 0) @@ -1629,13 +1629,6 @@ static int soc_probe_link_components(struct snd_soc_card *card, } } - /* probe the platform */ - if (platform->component.driver->probe_order == order) { - ret = soc_probe_component(card, &platform->component); - if (ret < 0) - return ret; - } - return 0; } diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index dcc5ece..aa4c02d 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -450,6 +450,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; const char *codec_dai_name = "multicodec"; @@ -458,10 +460,12 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) pinctrl_pm_select_default_state(cpu_dai->dev); for (i = 0; i < rtd->num_codecs; i++) pinctrl_pm_select_default_state(rtd->codec_dais[i]->dev); - pm_runtime_get_sync(cpu_dai->dev); - for (i = 0; i < rtd->num_codecs; i++) - pm_runtime_get_sync(rtd->codec_dais[i]->dev); - pm_runtime_get_sync(platform->dev); + + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + pm_runtime_get_sync(component->dev); + } mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); @@ -599,15 +603,13 @@ platform_err: out: mutex_unlock(&rtd->pcm_mutex); - pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); - for (i = 0; i < rtd->num_codecs; i++) { - pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev); - pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; + + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); } - pm_runtime_mark_last_busy(cpu_dai->dev); - pm_runtime_put_autosuspend(cpu_dai->dev); for (i = 0; i < rtd->num_codecs; i++) { if (!rtd->codec_dais[i]->active) pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev); @@ -655,6 +657,8 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component; + struct snd_soc_rtdcom_list *rtdcom; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai; int i; @@ -711,17 +715,13 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) mutex_unlock(&rtd->pcm_mutex); - pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + for_each_rtdcom(rtd, rtdcom) { + component = rtdcom->component; - for (i = 0; i < rtd->num_codecs; i++) { - pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev); - pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); } - pm_runtime_mark_last_busy(cpu_dai->dev); - pm_runtime_put_autosuspend(cpu_dai->dev); - for (i = 0; i < rtd->num_codecs; i++) { if (!rtd->codec_dais[i]->active) pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev); -- cgit v1.1 From c997aabbd3503c61901059caf457115098f344a4 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 9 Aug 2017 08:40:14 +0200 Subject: ALSA: emux: Adjust one function call together with a variable assignment The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix the affected source code place. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/synth/emux/emux_seq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 55579f6..53820f7 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -144,7 +144,8 @@ snd_emux_create_port(struct snd_emux *emu, char *name, int i, type, cap; /* Allocate structures for this channel */ - if ((p = kzalloc(sizeof(*p), GFP_KERNEL)) == NULL) { + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) { snd_printk(KERN_ERR "no memory\n"); return NULL; } -- cgit v1.1 From 949a0c23de89c02907970de7214c16b47ccf0482 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 9 Aug 2017 09:11:26 +0200 Subject: ALSA: emux: Improve a size determination in two functions Replace the specification of data types by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/synth/emux/emux_seq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 53820f7..12acf18 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -149,7 +149,8 @@ snd_emux_create_port(struct snd_emux *emu, char *name, snd_printk(KERN_ERR "no memory\n"); return NULL; } - p->chset.channels = kcalloc(max_channels, sizeof(struct snd_midi_channel), GFP_KERNEL); + p->chset.channels = kcalloc(max_channels, sizeof(*p->chset.channels), + GFP_KERNEL); if (p->chset.channels == NULL) { snd_printk(KERN_ERR "no memory\n"); kfree(p); @@ -371,7 +372,7 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card) if (emu->midi_ports <= 0) return 0; - emu->vmidi = kcalloc(emu->midi_ports, sizeof(struct snd_rawmidi *), GFP_KERNEL); + emu->vmidi = kcalloc(emu->midi_ports, sizeof(*emu->vmidi), GFP_KERNEL); if (emu->vmidi == NULL) return -ENOMEM; -- cgit v1.1 From fbc020b48c85fc7e4ca42ceb095c76f294b00043 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 9 Aug 2017 09:22:42 +0200 Subject: ALSA: emux: Adjust four checks for null pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written !… Thus fix affected source code places. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/synth/emux/emux_seq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 12acf18..fd6cbd4 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -99,7 +99,7 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index) sprintf(tmpname, "%s Port %d", emu->name, i); p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS, 0, &pinfo); - if (p == NULL) { + if (!p) { snd_printk(KERN_ERR "can't create port\n"); return -ENOMEM; } @@ -151,7 +151,7 @@ snd_emux_create_port(struct snd_emux *emu, char *name, } p->chset.channels = kcalloc(max_channels, sizeof(*p->chset.channels), GFP_KERNEL); - if (p->chset.channels == NULL) { + if (!p->chset.channels) { snd_printk(KERN_ERR "no memory\n"); kfree(p); return NULL; @@ -373,7 +373,7 @@ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card) return 0; emu->vmidi = kcalloc(emu->midi_ports, sizeof(*emu->vmidi), GFP_KERNEL); - if (emu->vmidi == NULL) + if (!emu->vmidi) return -ENOMEM; for (i = 0; i < emu->midi_ports; i++) { @@ -405,7 +405,7 @@ int snd_emux_delete_virmidi(struct snd_emux *emu) { int i; - if (emu->vmidi == NULL) + if (!emu->vmidi) return 0; for (i = 0; i < emu->midi_ports; i++) { -- cgit v1.1 From 64a591e67e30599bed0179f187e034cc0828010e Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 9 Aug 2017 09:30:34 +0200 Subject: ALSA: emux: Delete two error messages for a failed memory allocation in snd_emux_create_port() Omit extra messages for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/synth/emux/emux_seq.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index fd6cbd4..396c406 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -145,14 +145,12 @@ snd_emux_create_port(struct snd_emux *emu, char *name, /* Allocate structures for this channel */ p = kzalloc(sizeof(*p), GFP_KERNEL); - if (!p) { - snd_printk(KERN_ERR "no memory\n"); + if (!p) return NULL; - } + p->chset.channels = kcalloc(max_channels, sizeof(*p->chset.channels), GFP_KERNEL); if (!p->chset.channels) { - snd_printk(KERN_ERR "no memory\n"); kfree(p); return NULL; } -- cgit v1.1 From 844f88edf9dd6ef84599abe6909e1e19b6bfaeda Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:32 +0530 Subject: ALSA: ali5451: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/ali5451/ali5451.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 8567f1e..39547e3 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1540,7 +1540,7 @@ static int snd_ali_close(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops snd_ali_playback_ops = { +static const struct snd_pcm_ops snd_ali_playback_ops = { .open = snd_ali_playback_open, .close = snd_ali_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1551,7 +1551,7 @@ static struct snd_pcm_ops snd_ali_playback_ops = { .pointer = snd_ali_playback_pointer, }; -static struct snd_pcm_ops snd_ali_capture_ops = { +static const struct snd_pcm_ops snd_ali_capture_ops = { .open = snd_ali_capture_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, @@ -1626,7 +1626,7 @@ static int snd_ali_modem_capture_open(struct snd_pcm_substream *substream) return snd_ali_modem_open(substream, 1, ALI_MODEM_IN_CHANNEL); } -static struct snd_pcm_ops snd_ali_modem_playback_ops = { +static const struct snd_pcm_ops snd_ali_modem_playback_ops = { .open = snd_ali_modem_playback_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, @@ -1637,7 +1637,7 @@ static struct snd_pcm_ops snd_ali_modem_playback_ops = { .pointer = snd_ali_pointer, }; -static struct snd_pcm_ops snd_ali_modem_capture_ops = { +static const struct snd_pcm_ops snd_ali_modem_capture_ops = { .open = snd_ali_modem_capture_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, @@ -1653,8 +1653,8 @@ struct ali_pcm_description { char *name; unsigned int playback_num; unsigned int capture_num; - struct snd_pcm_ops *playback_ops; - struct snd_pcm_ops *capture_ops; + const struct snd_pcm_ops *playback_ops; + const struct snd_pcm_ops *capture_ops; unsigned short class; }; -- cgit v1.1 From 0b5b233915b6ea8042f9dbb725a94e185dada530 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:33 +0530 Subject: ALSA: au88x0: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 1aa9701..848eb3c 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -439,7 +439,7 @@ static snd_pcm_uframes_t snd_vortex_pcm_pointer(struct snd_pcm_substream *substr } /* operators */ -static struct snd_pcm_ops snd_vortex_playback_ops = { +static const struct snd_pcm_ops snd_vortex_playback_ops = { .open = snd_vortex_pcm_open, .close = snd_vortex_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From afa04880f46bbf84a90ac508c752b7ed0d76f8be Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:34 +0530 Subject: ALSA: echoaudio: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index d15ecf9..7326695 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -826,7 +826,7 @@ static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream) /* pcm *_ops structures */ -static struct snd_pcm_ops analog_playback_ops = { +static const struct snd_pcm_ops analog_playback_ops = { .open = pcm_analog_out_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -837,7 +837,7 @@ static struct snd_pcm_ops analog_playback_ops = { .pointer = pcm_pointer, .page = snd_pcm_sgbuf_ops_page, }; -static struct snd_pcm_ops analog_capture_ops = { +static const struct snd_pcm_ops analog_capture_ops = { .open = pcm_analog_in_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -850,7 +850,7 @@ static struct snd_pcm_ops analog_capture_ops = { }; #ifdef ECHOCARD_HAS_DIGITAL_IO #ifndef ECHOCARD_HAS_VMIXER -static struct snd_pcm_ops digital_playback_ops = { +static const struct snd_pcm_ops digital_playback_ops = { .open = pcm_digital_out_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -862,7 +862,7 @@ static struct snd_pcm_ops digital_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; #endif /* !ECHOCARD_HAS_VMIXER */ -static struct snd_pcm_ops digital_capture_ops = { +static const struct snd_pcm_ops digital_capture_ops = { .open = pcm_digital_in_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 17e12921c51f5025e748ab84087900a7a5ecc919 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:35 +0530 Subject: ALSA: intel8x0: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index a8d7092..fcd032e 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1367,7 +1367,7 @@ static int snd_intel8x0_ali_spdifout_close(struct snd_pcm_substream *substream) } #endif -static struct snd_pcm_ops snd_intel8x0_playback_ops = { +static const struct snd_pcm_ops snd_intel8x0_playback_ops = { .open = snd_intel8x0_playback_open, .close = snd_intel8x0_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1378,7 +1378,7 @@ static struct snd_pcm_ops snd_intel8x0_playback_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_capture_ops = { +static const struct snd_pcm_ops snd_intel8x0_capture_ops = { .open = snd_intel8x0_capture_open, .close = snd_intel8x0_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1389,7 +1389,7 @@ static struct snd_pcm_ops snd_intel8x0_capture_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_capture_mic_ops = { +static const struct snd_pcm_ops snd_intel8x0_capture_mic_ops = { .open = snd_intel8x0_mic_open, .close = snd_intel8x0_mic_close, .ioctl = snd_pcm_lib_ioctl, @@ -1400,7 +1400,7 @@ static struct snd_pcm_ops snd_intel8x0_capture_mic_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = { +static const struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = { .open = snd_intel8x0_mic2_open, .close = snd_intel8x0_mic2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1411,7 +1411,7 @@ static struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_capture2_ops = { +static const struct snd_pcm_ops snd_intel8x0_capture2_ops = { .open = snd_intel8x0_capture2_open, .close = snd_intel8x0_capture2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1422,7 +1422,7 @@ static struct snd_pcm_ops snd_intel8x0_capture2_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_spdif_ops = { +static const struct snd_pcm_ops snd_intel8x0_spdif_ops = { .open = snd_intel8x0_spdif_open, .close = snd_intel8x0_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1433,7 +1433,7 @@ static struct snd_pcm_ops snd_intel8x0_spdif_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_ali_playback_ops = { +static const struct snd_pcm_ops snd_intel8x0_ali_playback_ops = { .open = snd_intel8x0_playback_open, .close = snd_intel8x0_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1444,7 +1444,7 @@ static struct snd_pcm_ops snd_intel8x0_ali_playback_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_ali_capture_ops = { +static const struct snd_pcm_ops snd_intel8x0_ali_capture_ops = { .open = snd_intel8x0_capture_open, .close = snd_intel8x0_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1455,7 +1455,7 @@ static struct snd_pcm_ops snd_intel8x0_ali_capture_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = { +static const struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = { .open = snd_intel8x0_mic_open, .close = snd_intel8x0_mic_close, .ioctl = snd_pcm_lib_ioctl, @@ -1466,7 +1466,7 @@ static struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = { +static const struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = { .open = snd_intel8x0_ali_ac97spdifout_open, .close = snd_intel8x0_ali_ac97spdifout_close, .ioctl = snd_pcm_lib_ioctl, @@ -1503,8 +1503,8 @@ static struct snd_pcm_ops snd_intel8x0_ali_spdifout_ops = { struct ich_pcm_table { char *suffix; - struct snd_pcm_ops *playback_ops; - struct snd_pcm_ops *capture_ops; + const struct snd_pcm_ops *playback_ops; + const struct snd_pcm_ops *capture_ops; size_t prealloc_size; size_t prealloc_max_size; int ac97_idx; -- cgit v1.1 From c06aab337e59fd7e75c14660c60a9773885ecb3b Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:36 +0530 Subject: ALSA: intel8x0m: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/intel8x0m.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 18ff668..2f1b878 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -685,7 +685,7 @@ static int snd_intel8x0m_capture_close(struct snd_pcm_substream *substream) } -static struct snd_pcm_ops snd_intel8x0m_playback_ops = { +static const struct snd_pcm_ops snd_intel8x0m_playback_ops = { .open = snd_intel8x0m_playback_open, .close = snd_intel8x0m_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -696,7 +696,7 @@ static struct snd_pcm_ops snd_intel8x0m_playback_ops = { .pointer = snd_intel8x0m_pcm_pointer, }; -static struct snd_pcm_ops snd_intel8x0m_capture_ops = { +static const struct snd_pcm_ops snd_intel8x0m_capture_ops = { .open = snd_intel8x0m_capture_open, .close = snd_intel8x0m_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -710,8 +710,8 @@ static struct snd_pcm_ops snd_intel8x0m_capture_ops = { struct ich_pcm_table { char *suffix; - struct snd_pcm_ops *playback_ops; - struct snd_pcm_ops *capture_ops; + const struct snd_pcm_ops *playback_ops; + const struct snd_pcm_ops *capture_ops; size_t prealloc_size; size_t prealloc_max_size; int ac97_idx; -- cgit v1.1 From 2aa0eae9702ede2af21191bce8c5848eea3306e4 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:37 +0530 Subject: ALSA: sis7019: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/sis7019.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index f3860b8..3518887 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -872,7 +872,7 @@ static int sis_pcm_capture_prepare(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops sis_playback_ops = { +static const struct snd_pcm_ops sis_playback_ops = { .open = sis_playback_open, .close = sis_substream_close, .ioctl = snd_pcm_lib_ioctl, @@ -883,7 +883,7 @@ static struct snd_pcm_ops sis_playback_ops = { .pointer = sis_pcm_pointer, }; -static struct snd_pcm_ops sis_capture_ops = { +static const struct snd_pcm_ops sis_capture_ops = { .open = sis_capture_open, .close = sis_substream_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 841c1ea0d8f813029c821044d3e899d5eb93400a Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 10 Aug 2017 17:17:38 +0530 Subject: ALSA: trident: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 64d3b8e..4561040 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2093,7 +2093,7 @@ static const struct snd_pcm_ops snd_trident_nx_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static struct snd_pcm_ops snd_trident_capture_ops = { +static const struct snd_pcm_ops snd_trident_capture_ops = { .open = snd_trident_capture_open, .close = snd_trident_capture_close, .ioctl = snd_trident_ioctl, @@ -2104,7 +2104,7 @@ static struct snd_pcm_ops snd_trident_capture_ops = { .pointer = snd_trident_capture_pointer, }; -static struct snd_pcm_ops snd_trident_si7018_capture_ops = { +static const struct snd_pcm_ops snd_trident_si7018_capture_ops = { .open = snd_trident_capture_open, .close = snd_trident_capture_close, .ioctl = snd_trident_ioctl, -- cgit v1.1 From 6fd9ff7b019f5629e0f1f3a10bd4c03adfd7ec4e Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 17:40:57 +0200 Subject: ALSA: usx2y: Delete an error message for a failed memory allocation in two functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usbusx2yaudio.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index dd40ca9..612aa7f 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -419,10 +419,8 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) if (is_playback && NULL == subs->tmpbuf) { /* allocate a temporary buffer for playback */ subs->tmpbuf = kcalloc(nr_of_packs(), subs->maxpacksize, GFP_KERNEL); - if (NULL == subs->tmpbuf) { - snd_printk(KERN_ERR "cannot malloc tmpbuf\n"); + if (!subs->tmpbuf) return -ENOMEM; - } } /* allocate and initialize data urbs */ for (i = 0; i < NRURBS; i++) { @@ -949,10 +947,9 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { usX2Y_substream[i] = kzalloc(sizeof(struct snd_usX2Y_substream), GFP_KERNEL); - if (NULL == usX2Y_substream[i]) { - snd_printk(KERN_ERR "cannot malloc\n"); + if (!usX2Y_substream[i]) return -ENOMEM; - } + usX2Y_substream[i]->usX2Y = usX2Y(card); } -- cgit v1.1 From 9ecb2406de33470b70b48a2e107730bd37547e31 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 18:38:25 +0200 Subject: ALSA: usb: Delete an error message for a failed memory allocation in two functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/usb/quirks.c | 5 ++--- sound/usb/stream.c | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index d7b0b0a..9db40d5 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -146,10 +146,9 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, unsigned *rate_table = NULL; fp = kmemdup(quirk->data, sizeof(*fp), GFP_KERNEL); - if (!fp) { - usb_audio_err(chip, "cannot memdup\n"); + if (!fp) return -ENOMEM; - } + INIT_LIST_HEAD(&fp->list); if (fp->nr_rates > MAX_NR_RATES) { kfree(fp); diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 8e9548bc..d1776e5 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -658,10 +658,8 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) continue; fp = kzalloc(sizeof(*fp), GFP_KERNEL); - if (! fp) { - dev_err(&dev->dev, "cannot malloc\n"); + if (!fp) return -ENOMEM; - } fp->iface = iface_no; fp->altsetting = altno; -- cgit v1.1 From b26113fa6ab5f78438c2918b333e0f1c78a471d5 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 19:39:06 +0200 Subject: ALSA: usb: caiaq: audio: Delete two error messages for a failed memory allocation in alloc_urbs() Omit extra messages for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. [Fixed the unused variable warning by this change as well -- tiwai] Signed-off-by: Markus Elfring Acked-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/caiaq/audio.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 8f66ba7..054645f 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -722,7 +722,6 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) int i, frame; struct urb **urbs; struct usb_device *usb_dev = cdev->chip.dev; - struct device *dev = caiaqdev_to_dev(cdev); unsigned int pipe; pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? @@ -731,7 +730,6 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); if (!urbs) { - dev_err(dev, "unable to kmalloc() urbs, OOM!?\n"); *ret = -ENOMEM; return NULL; } @@ -746,7 +744,6 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) urbs[i]->transfer_buffer = kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); if (!urbs[i]->transfer_buffer) { - dev_err(dev, "unable to kmalloc() transfer buffer, OOM!?\n"); *ret = -ENOMEM; return urbs; } -- cgit v1.1 From aef7758ff4ffcf9d7a03779f877228871efae4c0 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 13:20:16 +0200 Subject: ALSA: trident: Delete an error message for a failed memory allocation in snd_trident_tlb_alloc() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 4561040..d9bb6dd 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -3363,11 +3363,9 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident) trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); /* allocate shadow TLB page table (virtual addresses) */ trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); - if (trident->tlb.shadow_entries == NULL) { - dev_err(trident->card->dev, - "unable to allocate shadow TLB entries\n"); + if (!trident->tlb.shadow_entries) return -ENOMEM; - } + /* allocate and setup silent page and initialise TLB entries */ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) { -- cgit v1.1 From 1b2ff0c0c4803faa530cc1744cb0760f0703b416 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 14:24:41 +0200 Subject: ALSA: rme96: Delete two error messages for a failed memory allocation in snd_rme96_probe() Omit extra messages for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme96.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 2e19ba5..82e8c78 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -2489,15 +2489,11 @@ snd_rme96_probe(struct pci_dev *pci, #ifdef CONFIG_PM_SLEEP rme96->playback_suspend_buffer = vmalloc(RME96_BUFFER_SIZE); if (!rme96->playback_suspend_buffer) { - dev_err(card->dev, - "Failed to allocate playback suspend buffer!\n"); snd_card_free(card); return -ENOMEM; } rme96->capture_suspend_buffer = vmalloc(RME96_BUFFER_SIZE); if (!rme96->capture_suspend_buffer) { - dev_err(card->dev, - "Failed to allocate capture suspend buffer!\n"); snd_card_free(card); return -ENOMEM; } -- cgit v1.1 From d72a8010ae60551ad14f1385e637be101cf741b5 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 14:50:33 +0200 Subject: ALSA: rme96: Use common error handling code in snd_rme96_probe() Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme96.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 82e8c78..0cdfd53 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -2481,21 +2481,20 @@ snd_rme96_probe(struct pci_dev *pci, rme96 = card->private_data; rme96->card = card; rme96->pci = pci; - if ((err = snd_rme96_create(rme96)) < 0) { - snd_card_free(card); - return err; - } + err = snd_rme96_create(rme96); + if (err) + goto free_card; #ifdef CONFIG_PM_SLEEP rme96->playback_suspend_buffer = vmalloc(RME96_BUFFER_SIZE); if (!rme96->playback_suspend_buffer) { - snd_card_free(card); - return -ENOMEM; + err = -ENOMEM; + goto free_card; } rme96->capture_suspend_buffer = vmalloc(RME96_BUFFER_SIZE); if (!rme96->capture_suspend_buffer) { - snd_card_free(card); - return -ENOMEM; + err = -ENOMEM; + goto free_card; } #endif @@ -2521,14 +2520,16 @@ snd_rme96_probe(struct pci_dev *pci, } sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, rme96->port, rme96->irq); - - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + err = snd_card_register(card); + if (err) + goto free_card; + pci_set_drvdata(pci, card); dev++; return 0; +free_card: + snd_card_free(card); + return err; } static void snd_rme96_remove(struct pci_dev *pci) -- cgit v1.1 From 2cb98d010fdc7a545856baf32bce096fa431d250 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 15:18:56 +0200 Subject: ALSA: rme96: Adjust five checks for null pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix the affected source code places. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme96.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 0cdfd53..b488d74 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -1199,7 +1199,7 @@ snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream) snd_pcm_set_sync(substream); spin_lock_irq(&rme96->lock); - if (rme96->playback_substream != NULL) { + if (rme96->playback_substream) { spin_unlock_irq(&rme96->lock); return -EBUSY; } @@ -1248,7 +1248,7 @@ snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream) } spin_lock_irq(&rme96->lock); - if (rme96->capture_substream != NULL) { + if (rme96->capture_substream) { spin_unlock_irq(&rme96->lock); return -EBUSY; } @@ -1268,7 +1268,7 @@ snd_rme96_playback_adat_open(struct snd_pcm_substream *substream) snd_pcm_set_sync(substream); spin_lock_irq(&rme96->lock); - if (rme96->playback_substream != NULL) { + if (rme96->playback_substream) { spin_unlock_irq(&rme96->lock); return -EBUSY; } @@ -1315,7 +1315,7 @@ snd_rme96_capture_adat_open(struct snd_pcm_substream *substream) } spin_lock_irq(&rme96->lock); - if (rme96->capture_substream != NULL) { + if (rme96->capture_substream) { spin_unlock_irq(&rme96->lock); return -EBUSY; } @@ -1578,9 +1578,9 @@ snd_rme96_free(void *private_data) { struct rme96 *rme96 = (struct rme96 *)private_data; - if (rme96 == NULL) { + if (!rme96) return; - } + if (rme96->irq >= 0) { snd_rme96_trigger(rme96, RME96_STOP_BOTH); rme96->areg &= ~RME96_AR_DAC_EN; -- cgit v1.1 From 9dba54296b8b4ae14053bfea82b171aeb9e16710 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 16:10:32 +0200 Subject: ALSA: rme9652: Delete an error message for a failed memory allocation in snd_hdspm_create() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 2a3a916..d448cf4 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -6638,12 +6638,8 @@ static int snd_hdspm_create(struct snd_card *card, dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", sizeof(struct hdspm_mixer)); hdspm->mixer = kzalloc(sizeof(struct hdspm_mixer), GFP_KERNEL); - if (!hdspm->mixer) { - dev_err(card->dev, - "unable to kmalloc Mixer memory of %d Bytes\n", - (int)sizeof(struct hdspm_mixer)); + if (!hdspm->mixer) return -ENOMEM; - } hdspm->port_names_in = NULL; hdspm->port_names_out = NULL; -- cgit v1.1 From 7dfec5075f23cdf114f530979bdf3c8dc232ea22 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 16:50:06 +0200 Subject: ALSA: rme9652: Improve eight size determinations Replace the specification of data structures by variable references as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index d448cf4..8d339fb 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -6221,7 +6221,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, } levels->status2 = hdspm_read(hdspm, HDSPM_statusRegister2); - s = copy_to_user(argp, levels, sizeof(struct hdspm_peak_rms)); + s = copy_to_user(argp, levels, sizeof(*levels)); if (0 != s) { /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [Levels]\n", sizeof(struct hdspm_peak_rms), s); @@ -6266,7 +6266,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, ltc.input_format = no_video; } - s = copy_to_user(argp, <c, sizeof(struct hdspm_ltc)); + s = copy_to_user(argp, <c, sizeof(ltc)); if (0 != s) { /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); */ @@ -6357,7 +6357,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, if (copy_from_user(&mixer, argp, sizeof(mixer))) return -EFAULT; if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, - sizeof(struct hdspm_mixer))) + sizeof(*mixer.mixer))) return -EFAULT; break; @@ -6636,8 +6636,8 @@ static int snd_hdspm_create(struct snd_card *card, hdspm->irq = pci->irq; dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", - sizeof(struct hdspm_mixer)); - hdspm->mixer = kzalloc(sizeof(struct hdspm_mixer), GFP_KERNEL); + sizeof(*hdspm->mixer)); + hdspm->mixer = kzalloc(sizeof(*hdspm->mixer), GFP_KERNEL); if (!hdspm->mixer) return -ENOMEM; @@ -6774,8 +6774,7 @@ static int snd_hdspm_create(struct snd_card *card, if (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_tco_detect) { hdspm->midiPorts++; - hdspm->tco = kzalloc(sizeof(struct hdspm_tco), - GFP_KERNEL); + hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); if (NULL != hdspm->tco) { hdspm_tco_write(hdspm); } @@ -6789,8 +6788,7 @@ static int snd_hdspm_create(struct snd_card *card, case AES32: if (hdspm_read(hdspm, HDSPM_statusRegister) & HDSPM_tco_detect) { hdspm->midiPorts++; - hdspm->tco = kzalloc(sizeof(struct hdspm_tco), - GFP_KERNEL); + hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); if (NULL != hdspm->tco) { hdspm_tco_write(hdspm); } @@ -6941,7 +6939,7 @@ static int snd_hdspm_probe(struct pci_dev *pci, } err = snd_card_new(&pci->dev, index[dev], id[dev], - THIS_MODULE, sizeof(struct hdspm), &card); + THIS_MODULE, sizeof(*hdspm), &card); if (err < 0) return err; -- cgit v1.1 From da2ea374b28aa6e6e5621396e0ae58580fe94af8 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 17:07:09 +0200 Subject: ALSA: rme9652: Adjust seven checks for null pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written … Thus fix the affected source code places. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdspm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 8d339fb..25284d8 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -1521,7 +1521,7 @@ static void hdspm_silence_playback(struct hdspm *hdspm) int n = hdspm->period_bytes; void *buf = hdspm->playback_buffer; - if (buf == NULL) + if (!buf) return; for (i = 0; i < HDSPM_MAX_CHANNELS; i++) { @@ -4706,7 +4706,7 @@ static int snd_hdspm_create_controls(struct snd_card *card, break; } - if (NULL != list) { + if (list) { for (idx = 0; idx < limit; idx++) { err = snd_ctl_add(card, snd_ctl_new1(&list[idx], hdspm)); @@ -6069,13 +6069,13 @@ static int snd_hdspm_open(struct snd_pcm_substream *substream) snd_hdspm_capture_subinfo; if (playback) { - if (hdspm->capture_substream == NULL) + if (!hdspm->capture_substream) hdspm_stop_audio(hdspm); hdspm->playback_pid = current->pid; hdspm->playback_substream = substream; } else { - if (hdspm->playback_substream == NULL) + if (!hdspm->playback_substream) hdspm_stop_audio(hdspm); hdspm->capture_pid = current->pid; @@ -6775,9 +6775,9 @@ static int snd_hdspm_create(struct snd_card *card, HDSPM_s2_tco_detect) { hdspm->midiPorts++; hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); - if (NULL != hdspm->tco) { + if (hdspm->tco) hdspm_tco_write(hdspm); - } + dev_info(card->dev, "AIO/RayDAT TCO module found\n"); } else { hdspm->tco = NULL; @@ -6789,9 +6789,9 @@ static int snd_hdspm_create(struct snd_card *card, if (hdspm_read(hdspm, HDSPM_statusRegister) & HDSPM_tco_detect) { hdspm->midiPorts++; hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); - if (NULL != hdspm->tco) { + if (hdspm->tco) hdspm_tco_write(hdspm); - } + dev_info(card->dev, "MADI/AES TCO module found\n"); } else { hdspm->tco = NULL; @@ -6868,7 +6868,7 @@ static int snd_hdspm_create(struct snd_card *card, * this case, we don't set card->id to avoid collisions * when running with multiple cards. */ - if (NULL == id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { + if (!id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { snprintf(card->id, sizeof(card->id), "HDSPMx%06x", hdspm->serial); snd_card_set_id(card, card->id); -- cgit v1.1 From 343fd50561e13f1efb5ba72cc16ab12dcaf07df5 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:13 +0530 Subject: ALSA: aw2: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/aw2/aw2-alsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c index 8356180..9a49e42 100644 --- a/sound/pci/aw2/aw2-alsa.c +++ b/sound/pci/aw2/aw2-alsa.c @@ -52,7 +52,7 @@ MODULE_LICENSE("GPL"); * TYPEDEFS ********************************/ /* hardware definition */ -static struct snd_pcm_hardware snd_aw2_playback_hw = { +static const struct snd_pcm_hardware snd_aw2_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), @@ -69,7 +69,7 @@ static struct snd_pcm_hardware snd_aw2_playback_hw = { .periods_max = 1024, }; -static struct snd_pcm_hardware snd_aw2_capture_hw = { +static const struct snd_pcm_hardware snd_aw2_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), -- cgit v1.1 From d1876fe679cbfdfdcc3e7f84b779c99c919ef3f6 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:14 +0530 Subject: ALSA: ca0106: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 6165a57..2be30b8 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -296,7 +296,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = { }; /* hardware definition */ -static struct snd_pcm_hardware snd_ca0106_playback_hw = { +static const struct snd_pcm_hardware snd_ca0106_playback_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -317,7 +317,7 @@ static struct snd_pcm_hardware snd_ca0106_playback_hw = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_ca0106_capture_hw = { +static const struct snd_pcm_hardware snd_ca0106_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From 114d35496f2ba82ca5d4c39f76fac96330f72965 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:15 +0530 Subject: ALSA: cs46xx: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/cs46xx/cs46xx_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 709fb1a..0020fd0 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -1438,7 +1438,7 @@ static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static struct snd_pcm_hardware snd_cs46xx_playback = +static const struct snd_pcm_hardware snd_cs46xx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -1460,7 +1460,7 @@ static struct snd_pcm_hardware snd_cs46xx_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_cs46xx_capture = +static const struct snd_pcm_hardware snd_cs46xx_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | -- cgit v1.1 From 5875adc2a77021874249009011d01ceae31b139a Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:16 +0530 Subject: ALSA: korg1212: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/korg1212/korg1212.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index b28fe49..04cd71c 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -1231,7 +1231,7 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) return 0; } -static struct snd_pcm_hardware snd_korg1212_playback_info = +static const struct snd_pcm_hardware snd_korg1212_playback_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -1252,7 +1252,7 @@ static struct snd_pcm_hardware snd_korg1212_playback_info = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_korg1212_capture_info = +static const struct snd_pcm_hardware snd_korg1212_capture_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From d670315c4f08cf3f380d249c64b88171bd33a348 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:17 +0530 Subject: ALSA: cs5535audio: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio_pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index c208c1d..ee7065f 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -33,7 +33,7 @@ #include #include "cs5535audio.h" -static struct snd_pcm_hardware snd_cs5535audio_playback = +static const struct snd_pcm_hardware snd_cs5535audio_playback = { .info = ( SNDRV_PCM_INFO_MMAP | @@ -62,7 +62,7 @@ static struct snd_pcm_hardware snd_cs5535audio_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_cs5535audio_capture = +static const struct snd_pcm_hardware snd_cs5535audio_capture = { .info = ( SNDRV_PCM_INFO_MMAP | -- cgit v1.1 From 7c0ddf06d2432a4502aab100b4a306a47d7a60d3 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:18 +0530 Subject: ALSA: emu10k1: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1x.c | 4 ++-- sound/pci/emu10k1/emupcm.c | 10 +++++----- sound/pci/emu10k1/p16v.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 77a4413..2c2b12a 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -254,7 +254,7 @@ struct emu10k1x { }; /* hardware definition */ -static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { +static const struct snd_pcm_hardware snd_emu10k1x_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -273,7 +273,7 @@ static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_emu10k1x_capture_hw = { +static const struct snd_pcm_hardware snd_emu10k1x_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 5c9054a..2683b97 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -556,7 +556,7 @@ static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_hardware snd_emu10k1_efx_playback = +static const struct snd_pcm_hardware snd_emu10k1_efx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -975,7 +975,7 @@ static snd_pcm_uframes_t snd_emu10k1_capture_pointer(struct snd_pcm_substream *s * Playback support device description */ -static struct snd_pcm_hardware snd_emu10k1_playback = +static const struct snd_pcm_hardware snd_emu10k1_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -999,7 +999,7 @@ static struct snd_pcm_hardware snd_emu10k1_playback = * Capture support device description */ -static struct snd_pcm_hardware snd_emu10k1_capture = +static const struct snd_pcm_hardware snd_emu10k1_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1019,7 +1019,7 @@ static struct snd_pcm_hardware snd_emu10k1_capture = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_emu10k1_capture_efx = +static const struct snd_pcm_hardware snd_emu10k1_capture_efx = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1742,7 +1742,7 @@ static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_subs return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); } -static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = +static const struct snd_pcm_hardware snd_emu10k1_fx8010_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index c11f1a2..a30da78 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -122,7 +122,7 @@ */ /* hardware definition */ -static struct snd_pcm_hardware snd_p16v_playback_hw = { +static const struct snd_pcm_hardware snd_p16v_playback_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -143,7 +143,7 @@ static struct snd_pcm_hardware snd_p16v_playback_hw = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_p16v_capture_hw = { +static const struct snd_pcm_hardware snd_p16v_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From 5cf84795d3e1b6795a717e7c858a12486ccf760f Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:19 +0530 Subject: ALSA: lola: make snd_pcm_hardware const Make this const as it is only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/lola/lola_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/lola/lola_pcm.c b/sound/pci/lola/lola_pcm.c index 1268ba3..310b26a 100644 --- a/sound/pci/lola/lola_pcm.c +++ b/sound/pci/lola/lola_pcm.c @@ -197,7 +197,7 @@ static void lola_stream_reset(struct lola *chip, struct lola_stream *str) } } -static struct snd_pcm_hardware lola_pcm_hw = { +static const struct snd_pcm_hardware lola_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From 033bb5676d5961371b8ec130ee9f9f9202ebd263 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:20 +0530 Subject: ALSA: lx6464es: make snd_pcm_hardware const Make this const as it is only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx6464es.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c index f9c3e86..9655b08 100644 --- a/sound/pci/lx6464es/lx6464es.c +++ b/sound/pci/lx6464es/lx6464es.c @@ -77,7 +77,7 @@ MODULE_DEVICE_TABLE(pci, snd_lx6464es_ids); /* alsa callbacks */ -static struct snd_pcm_hardware lx_caps = { +static const struct snd_pcm_hardware lx_caps = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From 7d4edd425477a9b85c03d6623107465e8cecd938 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:21 +0530 Subject: ALSA: mixart: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/mixart/mixart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 6d7fbf3..aca3b34 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -675,7 +675,7 @@ static int snd_mixart_hw_free(struct snd_pcm_substream *subs) /* * TODO CONFIGURATION SPACE for all pcms, mono pcm must update channels_max */ -static struct snd_pcm_hardware snd_mixart_analog_caps = +static const struct snd_pcm_hardware snd_mixart_analog_caps = { .info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -696,7 +696,7 @@ static struct snd_pcm_hardware snd_mixart_analog_caps = .periods_max = (32*1024/256), }; -static struct snd_pcm_hardware snd_mixart_digital_caps = +static const struct snd_pcm_hardware snd_mixart_digital_caps = { .info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From 4f8f04e8bd53d77f32052b069e88c53267f09165 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:22 +0530 Subject: ALSA: ctxfi: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/ctpcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 9749780..358f520 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -21,7 +21,7 @@ #include /* Hardware descriptions for playback */ -static struct snd_pcm_hardware ct_pcm_playback_hw = { +static const struct snd_pcm_hardware ct_pcm_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -46,7 +46,7 @@ static struct snd_pcm_hardware ct_pcm_playback_hw = { .fifo_size = 0, }; -static struct snd_pcm_hardware ct_spdif_passthru_playback_hw = { +static const struct snd_pcm_hardware ct_spdif_passthru_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -69,7 +69,7 @@ static struct snd_pcm_hardware ct_spdif_passthru_playback_hw = { }; /* Hardware descriptions for capture */ -static struct snd_pcm_hardware ct_pcm_capture_hw = { +static const struct snd_pcm_hardware ct_pcm_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From ecc6a044eb62cad892de28d1ea80a5c6f11ff402 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:23 +0530 Subject: ALSA: pcxhr: make snd_pcm_hardware const Make this const as it is only used during a copy operation. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index fa919f5..e6f9aa6 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -986,7 +986,7 @@ static int pcxhr_hw_free(struct snd_pcm_substream *subs) /* * CONFIGURATION SPACE for all pcms, mono pcm must update channels_max */ -static struct snd_pcm_hardware pcxhr_caps = +static const struct snd_pcm_hardware pcxhr_caps = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | -- cgit v1.1 From 14ff46fd99077c3c15cbf38ab1795cbd0f16669e Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:24 +0530 Subject: ALSA: riptide: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index f067c76..44f3b48 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1315,7 +1315,7 @@ static int riptide_reset(struct cmdif *cif, struct snd_riptide *chip) return 0; } -static struct snd_pcm_hardware snd_riptide_playback = { +static const struct snd_pcm_hardware snd_riptide_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP_VALID), @@ -1334,7 +1334,7 @@ static struct snd_pcm_hardware snd_riptide_playback = { .periods_max = 64, .fifo_size = 0, }; -static struct snd_pcm_hardware snd_riptide_capture = { +static const struct snd_pcm_hardware snd_riptide_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP_VALID), -- cgit v1.1 From 18ed1cf00b9ad47021fda5d7392b32dadc788097 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:25 +0530 Subject: ALSA: rme9652: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdsp.c | 4 ++-- sound/pci/rme9652/rme9652.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index fe36d44..9535e6a 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -4211,7 +4211,7 @@ static int snd_hdsp_prepare(struct snd_pcm_substream *substream) return result; } -static struct snd_pcm_hardware snd_hdsp_playback_subinfo = +static const struct snd_pcm_hardware snd_hdsp_playback_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -4241,7 +4241,7 @@ static struct snd_pcm_hardware snd_hdsp_playback_subinfo = .fifo_size = 0 }; -static struct snd_pcm_hardware snd_hdsp_capture_subinfo = +static const struct snd_pcm_hardware snd_hdsp_capture_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 150d088..eff4993 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -2181,7 +2181,7 @@ static int snd_rme9652_prepare(struct snd_pcm_substream *substream) return result; } -static struct snd_pcm_hardware snd_rme9652_playback_subinfo = +static const struct snd_pcm_hardware snd_rme9652_playback_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -2205,7 +2205,7 @@ static struct snd_pcm_hardware snd_rme9652_playback_subinfo = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_rme9652_capture_subinfo = +static const struct snd_pcm_hardware snd_rme9652_capture_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From b57cac281589654cef6120f694cb09c267e85d24 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:26 +0530 Subject: ALSA: trident: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/trident/trident_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index d9bb6dd..eabd84d9 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -1727,7 +1727,7 @@ static snd_pcm_uframes_t snd_trident_spdif_pointer(struct snd_pcm_substream *sub * Playback support device description */ -static struct snd_pcm_hardware snd_trident_playback = +static const struct snd_pcm_hardware snd_trident_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1752,7 +1752,7 @@ static struct snd_pcm_hardware snd_trident_playback = * Capture support device description */ -static struct snd_pcm_hardware snd_trident_capture = +static const struct snd_pcm_hardware snd_trident_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1777,7 +1777,7 @@ static struct snd_pcm_hardware snd_trident_capture = * Foldback capture support device description */ -static struct snd_pcm_hardware snd_trident_foldback = +static const struct snd_pcm_hardware snd_trident_foldback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1801,7 +1801,7 @@ static struct snd_pcm_hardware snd_trident_foldback = * SPDIF playback support device description */ -static struct snd_pcm_hardware snd_trident_spdif = +static const struct snd_pcm_hardware snd_trident_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1822,7 +1822,7 @@ static struct snd_pcm_hardware snd_trident_spdif = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_trident_spdif_7018 = +static const struct snd_pcm_hardware snd_trident_spdif_7018 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From 420b0c1b78aed04b951418ca453673fd6c06c737 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:27 +0530 Subject: ALSA: ymfpci: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 1114166..edfd5824 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -845,7 +845,7 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static struct snd_pcm_hardware snd_ymfpci_playback = +static const struct snd_pcm_hardware snd_ymfpci_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -867,7 +867,7 @@ static struct snd_pcm_hardware snd_ymfpci_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_ymfpci_capture = +static const struct snd_pcm_hardware snd_ymfpci_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From dee49895b197936c02d27d651e58c90bac18f452 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Sat, 12 Aug 2017 21:01:28 +0530 Subject: ALSA: pci: make snd_pcm_hardware const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 4 ++-- sound/pci/als300.c | 4 ++-- sound/pci/als4000.c | 4 ++-- sound/pci/atiixp.c | 2 +- sound/pci/atiixp_modem.c | 2 +- sound/pci/bt87x.c | 4 ++-- sound/pci/cmipci.c | 12 ++++++------ sound/pci/cs4281.c | 4 ++-- sound/pci/ens1370.c | 6 +++--- sound/pci/es1938.c | 4 ++-- sound/pci/es1968.c | 4 ++-- sound/pci/fm801.c | 4 ++-- sound/pci/intel8x0.c | 2 +- sound/pci/intel8x0m.c | 2 +- sound/pci/maestro3.c | 4 ++-- sound/pci/rme32.c | 8 ++++---- sound/pci/rme96.c | 8 ++++---- sound/pci/sis7019.c | 4 ++-- sound/pci/sonicvibes.c | 4 ++-- sound/pci/via82xx.c | 2 +- sound/pci/via82xx_modem.c | 2 +- 21 files changed, 45 insertions(+), 45 deletions(-) (limited to 'sound') diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 8c36990..0bf2c04 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -283,7 +283,7 @@ snd_ad1889_hw_free(struct snd_pcm_substream *substream) return snd_pcm_lib_free_pages(substream); } -static struct snd_pcm_hardware snd_ad1889_playback_hw = { +static const struct snd_pcm_hardware snd_ad1889_playback_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, .formats = SNDRV_PCM_FMTBIT_S16_LE, @@ -300,7 +300,7 @@ static struct snd_pcm_hardware snd_ad1889_playback_hw = { /*.fifo_size = 0,*/ }; -static struct snd_pcm_hardware snd_ad1889_capture_hw = { +static const struct snd_pcm_hardware snd_ad1889_capture_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, .formats = SNDRV_PCM_FMTBIT_S16_LE, diff --git a/sound/pci/als300.c b/sound/pci/als300.c index ab75601..eaa2d85 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -328,7 +328,7 @@ static int snd_als300_ac97(struct snd_als300 *chip) * the card when it is running outside of legacy * mode. */ -static struct snd_pcm_hardware snd_als300_playback_hw = +static const struct snd_pcm_hardware snd_als300_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -347,7 +347,7 @@ static struct snd_pcm_hardware snd_als300_playback_hw = .periods_max = 2, }; -static struct snd_pcm_hardware snd_als300_capture_hw = +static const struct snd_pcm_hardware snd_als300_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 7844a75..26b097e 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -592,7 +592,7 @@ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id) /*****************************************************************/ -static struct snd_pcm_hardware snd_als4000_playback = +static const struct snd_pcm_hardware snd_als4000_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -611,7 +611,7 @@ static struct snd_pcm_hardware snd_als4000_playback = .fifo_size = 0 }; -static struct snd_pcm_hardware snd_als4000_capture = +static const struct snd_pcm_hardware snd_als4000_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index a40c918..de53c2a 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1009,7 +1009,7 @@ static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) /* * pcm hardware definition, identical for all DMA types */ -static struct snd_pcm_hardware snd_atiixp_pcm_hw = +static const struct snd_pcm_hardware snd_atiixp_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 52e0ea7..a586635 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -834,7 +834,7 @@ static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) /* * pcm hardware definition, identical for all DMA types */ -static struct snd_pcm_hardware snd_atiixp_pcm_hw = +static const struct snd_pcm_hardware snd_atiixp_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index de02342..d8ade87 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -353,7 +353,7 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static struct snd_pcm_hardware snd_bt87x_digital_hw = { +static const struct snd_pcm_hardware snd_bt87x_digital_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -370,7 +370,7 @@ static struct snd_pcm_hardware snd_bt87x_digital_hw = { .periods_max = 255, }; -static struct snd_pcm_hardware snd_bt87x_analog_hw = { +static const struct snd_pcm_hardware snd_bt87x_analog_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index a460cb6..a45245f 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -1477,7 +1477,7 @@ static irqreturn_t snd_cmipci_interrupt(int irq, void *dev_id) */ /* playback on channel A */ -static struct snd_pcm_hardware snd_cmipci_playback = +static const struct snd_pcm_hardware snd_cmipci_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1497,7 +1497,7 @@ static struct snd_pcm_hardware snd_cmipci_playback = }; /* capture on channel B */ -static struct snd_pcm_hardware snd_cmipci_capture = +static const struct snd_pcm_hardware snd_cmipci_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1517,7 +1517,7 @@ static struct snd_pcm_hardware snd_cmipci_capture = }; /* playback on channel B - stereo 16bit only? */ -static struct snd_pcm_hardware snd_cmipci_playback2 = +static const struct snd_pcm_hardware snd_cmipci_playback2 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1537,7 +1537,7 @@ static struct snd_pcm_hardware snd_cmipci_playback2 = }; /* spdif playback on channel A */ -static struct snd_pcm_hardware snd_cmipci_playback_spdif = +static const struct snd_pcm_hardware snd_cmipci_playback_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1557,7 +1557,7 @@ static struct snd_pcm_hardware snd_cmipci_playback_spdif = }; /* spdif playback on channel A (32bit, IEC958 subframes) */ -static struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe = +static const struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1577,7 +1577,7 @@ static struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe = }; /* spdif capture on channel B */ -static struct snd_pcm_hardware snd_cmipci_capture_spdif = +static const struct snd_pcm_hardware snd_cmipci_capture_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index ee7ba4b..ec42476 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -847,7 +847,7 @@ static snd_pcm_uframes_t snd_cs4281_pointer(struct snd_pcm_substream *substream) snd_cs4281_peekBA0(chip, dma->regDCC) - 1; } -static struct snd_pcm_hardware snd_cs4281_playback = +static const struct snd_pcm_hardware snd_cs4281_playback = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -872,7 +872,7 @@ static struct snd_pcm_hardware snd_cs4281_playback = .fifo_size = CS4281_FIFO_SIZE, }; -static struct snd_pcm_hardware snd_cs4281_capture = +static const struct snd_pcm_hardware snd_cs4281_capture = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index f0d978e..d4cd645 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1059,7 +1059,7 @@ static snd_pcm_uframes_t snd_ensoniq_capture_pointer(struct snd_pcm_substream *s return ptr; } -static struct snd_pcm_hardware snd_ensoniq_playback1 = +static const struct snd_pcm_hardware snd_ensoniq_playback1 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1086,7 +1086,7 @@ static struct snd_pcm_hardware snd_ensoniq_playback1 = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_ensoniq_playback2 = +static const struct snd_pcm_hardware snd_ensoniq_playback2 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1106,7 +1106,7 @@ static struct snd_pcm_hardware snd_ensoniq_playback2 = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_ensoniq_capture = +static const struct snd_pcm_hardware snd_ensoniq_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 069902a..9d248eb 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -900,7 +900,7 @@ static int snd_es1938_pcm_hw_free(struct snd_pcm_substream *substream) /* ---------------------------------------------------------------------- * Audio1 Capture (ADC) * ----------------------------------------------------------------------*/ -static struct snd_pcm_hardware snd_es1938_capture = +static const struct snd_pcm_hardware snd_es1938_capture = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER), @@ -922,7 +922,7 @@ static struct snd_pcm_hardware snd_es1938_capture = /* ----------------------------------------------------------------------- * Audio2 Playback (DAC) * -----------------------------------------------------------------------*/ -static struct snd_pcm_hardware snd_es1938_playback = +static const struct snd_pcm_hardware snd_es1938_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 2ec2b1c..0b1845c 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -1290,7 +1290,7 @@ static snd_pcm_uframes_t snd_es1968_pcm_pointer(struct snd_pcm_substream *substr return bytes_to_frames(substream->runtime, ptr % es->dma_size); } -static struct snd_pcm_hardware snd_es1968_playback = { +static const struct snd_pcm_hardware snd_es1968_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -1311,7 +1311,7 @@ static struct snd_pcm_hardware snd_es1968_playback = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_es1968_capture = { +static const struct snd_pcm_hardware snd_es1968_capture = { .info = (SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 8e6b04b..73a67bc 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -599,7 +599,7 @@ static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static struct snd_pcm_hardware snd_fm801_playback = +static const struct snd_pcm_hardware snd_fm801_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -619,7 +619,7 @@ static struct snd_pcm_hardware snd_fm801_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_fm801_capture = +static const struct snd_pcm_hardware snd_fm801_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index fcd032e..851ccff 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1115,7 +1115,7 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs return bytes_to_frames(substream->runtime, ptr); } -static struct snd_pcm_hardware snd_intel8x0_stream = +static const struct snd_pcm_hardware snd_intel8x0_stream = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 2f1b878..3a4769a 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -611,7 +611,7 @@ static int snd_intel8x0m_pcm_prepare(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_hardware snd_intel8x0m_stream = +static const struct snd_pcm_hardware snd_intel8x0m_stream = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index cafea6d..97ac80a 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -1681,7 +1681,7 @@ static irqreturn_t snd_m3_interrupt(int irq, void *dev_id) /* */ -static struct snd_pcm_hardware snd_m3_playback = +static const struct snd_pcm_hardware snd_m3_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -1702,7 +1702,7 @@ static struct snd_pcm_hardware snd_m3_playback = .periods_max = 1024, }; -static struct snd_pcm_hardware snd_m3_capture = +static const struct snd_pcm_hardware snd_m3_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index e4cdef9..f0906ba 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -314,7 +314,7 @@ static int snd_rme32_capture_copy_kernel(struct snd_pcm_substream *substream, /* * SPDIF I/O capabilities (half-duplex mode) */ -static struct snd_pcm_hardware snd_rme32_spdif_info = { +static const struct snd_pcm_hardware snd_rme32_spdif_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -340,7 +340,7 @@ static struct snd_pcm_hardware snd_rme32_spdif_info = { /* * ADAT I/O capabilities (half-duplex mode) */ -static struct snd_pcm_hardware snd_rme32_adat_info = +static const struct snd_pcm_hardware snd_rme32_adat_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -365,7 +365,7 @@ static struct snd_pcm_hardware snd_rme32_adat_info = /* * SPDIF I/O capabilities (full-duplex mode) */ -static struct snd_pcm_hardware snd_rme32_spdif_fd_info = { +static const struct snd_pcm_hardware snd_rme32_spdif_fd_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -391,7 +391,7 @@ static struct snd_pcm_hardware snd_rme32_spdif_fd_info = { /* * ADAT I/O capabilities (full-duplex mode) */ -static struct snd_pcm_hardware snd_rme32_adat_fd_info = +static const struct snd_pcm_hardware snd_rme32_adat_fd_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index b488d74..dcfa4d7 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -384,7 +384,7 @@ snd_rme96_capture_copy_kernel(struct snd_pcm_substream *substream, /* * Digital output capabilities (S/PDIF) */ -static struct snd_pcm_hardware snd_rme96_playback_spdif_info = +static const struct snd_pcm_hardware snd_rme96_playback_spdif_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -415,7 +415,7 @@ static struct snd_pcm_hardware snd_rme96_playback_spdif_info = /* * Digital input capabilities (S/PDIF) */ -static struct snd_pcm_hardware snd_rme96_capture_spdif_info = +static const struct snd_pcm_hardware snd_rme96_capture_spdif_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -446,7 +446,7 @@ static struct snd_pcm_hardware snd_rme96_capture_spdif_info = /* * Digital output capabilities (ADAT) */ -static struct snd_pcm_hardware snd_rme96_playback_adat_info = +static const struct snd_pcm_hardware snd_rme96_playback_adat_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -473,7 +473,7 @@ static struct snd_pcm_hardware snd_rme96_playback_adat_info = /* * Digital input capabilities (ADAT) */ -static struct snd_pcm_hardware snd_rme96_capture_adat_info = +static const struct snd_pcm_hardware snd_rme96_capture_adat_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 3518887..964acf3 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -159,7 +159,7 @@ struct sis7019 { * We'll add a constraint upon open that limits the period and buffer sample * size to values that are legal for the hardware. */ -static struct snd_pcm_hardware sis_playback_hw_info = { +static const struct snd_pcm_hardware sis_playback_hw_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -180,7 +180,7 @@ static struct snd_pcm_hardware sis_playback_hw_info = { .periods_max = (0xfff9 / 9), }; -static struct snd_pcm_hardware sis_capture_hw_info = { +static const struct snd_pcm_hardware sis_capture_hw_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 784d762..a8abb15 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -776,7 +776,7 @@ static snd_pcm_uframes_t snd_sonicvibes_capture_pointer(struct snd_pcm_substream return bytes_to_frames(substream->runtime, ptr); } -static struct snd_pcm_hardware snd_sonicvibes_playback = +static const struct snd_pcm_hardware snd_sonicvibes_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -795,7 +795,7 @@ static struct snd_pcm_hardware snd_sonicvibes_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_sonicvibes_capture = +static const struct snd_pcm_hardware snd_sonicvibes_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index c767b86..3a1c0b8 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1150,7 +1150,7 @@ static int snd_via8233_capture_prepare(struct snd_pcm_substream *substream) /* * pcm hardware definition, identical for both playback and capture */ -static struct snd_pcm_hardware snd_via82xx_hw = +static const struct snd_pcm_hardware snd_via82xx_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 55f79b2..8a69221 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -714,7 +714,7 @@ static int snd_via82xx_pcm_prepare(struct snd_pcm_substream *substream) /* * pcm hardware definition, identical for both playback and capture */ -static struct snd_pcm_hardware snd_via82xx_hw = +static const struct snd_pcm_hardware snd_via82xx_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From c38774d830aef6710676e7e5797d979c2bbb45ba Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 18:14:54 +0200 Subject: ALSA: pcxhr: Delete an error message for a failed memory allocation in pcxhr_create() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index e6f9aa6..f9ae72f 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1215,10 +1215,8 @@ static int pcxhr_create(struct pcxhr_mgr *mgr, }; chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (! chip) { - dev_err(card->dev, "cannot allocate chip\n"); + if (!chip) return -ENOMEM; - } chip->card = card; chip->chip_idx = idx; -- cgit v1.1 From a357f3d1ee95953c9f04617f3045838260f3401f Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 18:45:42 +0200 Subject: ALSA: mixart: Delete an error message for a failed memory allocation in snd_mixart_create() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/mixart/mixart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index aca3b34..a74f1ad 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1052,10 +1052,8 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int }; chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (! chip) { - dev_err(card->dev, "cannot allocate chip\n"); + if (!chip) return -ENOMEM; - } chip->card = card; chip->chip_idx = idx; -- cgit v1.1 From f197acd27e9782a317f070e4ec465f5da460afd1 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 19:09:23 +0200 Subject: ALSA: ca0106: Delete an error message for a failed memory allocation in snd_ca0106_pcm_open_capture_channel() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 2be30b8..cd27b55 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -660,11 +660,9 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); - if (epcm == NULL) { - dev_err(chip->card->dev, - "open_capture_channel: failed epcm alloc\n"); + if (!epcm) return -ENOMEM; - } + epcm->emu = chip; epcm->substream = substream; epcm->channel_id=channel_id; -- cgit v1.1 From 2b223a91197ffd45d556625edf2939f07f2b7730 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 19:54:20 +0200 Subject: ALSA: opl3: Delete an error message for a failed memory allocation in snd_opl3_new() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_lib.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index d5e5b46..588963d 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -355,10 +355,8 @@ int snd_opl3_new(struct snd_card *card, *ropl3 = NULL; opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL); - if (opl3 == NULL) { - snd_printk(KERN_ERR "opl3: cannot allocate\n"); + if (!opl3) return -ENOMEM; - } opl3->card = card; opl3->hardware = hardware; -- cgit v1.1 From 30b2aeb8a85c2f91f23c95e2b6723a464d0ee6d3 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 20:20:11 +0200 Subject: ALSA: mpu401: Delete an error message for a failed memory allocation in snd_mpu401_uart_new() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401_uart.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 3a7c317..cc34738 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -545,7 +545,6 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, return err; mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); if (mpu == NULL) { - snd_printk(KERN_ERR "mpu401_uart: cannot allocate\n"); snd_device_free(card, rmidi); return -ENOMEM; } -- cgit v1.1 From ec1f43c83b9df3052209e0c7e7d936e15251c867 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 20:40:17 +0200 Subject: ALSA: mpu401: Use common error handling code in snd_mpu401_uart_new() Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401_uart.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index cc34738..e8bdea1 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -545,8 +545,8 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, return err; mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); if (mpu == NULL) { - snd_device_free(card, rmidi); - return -ENOMEM; + err = -ENOMEM; + goto free_device; } rmidi->private_data = mpu; rmidi->private_free = snd_mpu401_uart_free; @@ -562,8 +562,8 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, snd_printk(KERN_ERR "mpu401_uart: " "unable to grab port 0x%lx size %d\n", port, res_size); - snd_device_free(card, rmidi); - return -EBUSY; + err = -EBUSY; + goto free_device; } } if (info_flags & MPU401_INFO_MMIO) { @@ -583,8 +583,8 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, "MPU401 UART", (void *) mpu)) { snd_printk(KERN_ERR "mpu401_uart: " "unable to grab IRQ %d\n", irq); - snd_device_free(card, rmidi); - return -EBUSY; + err = -EBUSY; + goto free_device; } } if (irq < 0 && !(info_flags & MPU401_INFO_IRQ_HOOK)) @@ -612,6 +612,9 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, if (rrawmidi) *rrawmidi = rmidi; return 0; +free_device: + snd_device_free(card, rmidi); + return err; } EXPORT_SYMBOL(snd_mpu401_uart_new); -- cgit v1.1 From f1a77dc17103e53e43f33beab67a287feafa6aa3 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Sat, 12 Aug 2017 20:50:16 +0200 Subject: ALSA: mpu401: Adjust four checks for null pointers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script “checkpatch.pl” pointed information out like the following. Comparison to NULL could be written !… Thus fix the affected source code places. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401_uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index e8bdea1..b997222 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -136,7 +136,7 @@ irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id) { struct snd_mpu401 *mpu = dev_id; - if (mpu == NULL) + if (!mpu) return IRQ_NONE; _snd_mpu401_uart_interrupt(mpu); return IRQ_HANDLED; @@ -157,7 +157,7 @@ irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id) { struct snd_mpu401 *mpu = dev_id; - if (mpu == NULL) + if (!mpu) return IRQ_NONE; uart_interrupt_tx(mpu); return IRQ_HANDLED; @@ -544,7 +544,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, out_enable, in_enable, &rmidi)) < 0) return err; mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); - if (mpu == NULL) { + if (!mpu) { err = -ENOMEM; goto free_device; } @@ -558,7 +558,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, if (! (info_flags & MPU401_INFO_INTEGRATED)) { int res_size = hardware == MPU401_HW_PC98II ? 4 : 2; mpu->res = request_region(port, res_size, "MPU401 UART"); - if (mpu->res == NULL) { + if (!mpu->res) { snd_printk(KERN_ERR "mpu401_uart: " "unable to grab port 0x%lx size %d\n", port, res_size); -- cgit v1.1 From 58a24fc163d7079cbd4fed47b8ec96469140d722 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:27:59 +0530 Subject: ALSA: ad1816a: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 5c815f5..5c6df15 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -653,7 +653,7 @@ int snd_ad1816a_create(struct snd_card *card, return 0; } -static struct snd_pcm_ops snd_ad1816a_playback_ops = { +static const struct snd_pcm_ops snd_ad1816a_playback_ops = { .open = snd_ad1816a_playback_open, .close = snd_ad1816a_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -664,7 +664,7 @@ static struct snd_pcm_ops snd_ad1816a_playback_ops = { .pointer = snd_ad1816a_playback_pointer, }; -static struct snd_pcm_ops snd_ad1816a_capture_ops = { +static const struct snd_pcm_ops snd_ad1816a_capture_ops = { .open = snd_ad1816a_capture_open, .close = snd_ad1816a_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From e79a560ef79982f27b3d4798895d6542ed373a2f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:00 +0530 Subject: ALSA: es1688: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 5d3df96..ec7e68b 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -706,7 +706,7 @@ exit: return err; } -static struct snd_pcm_ops snd_es1688_playback_ops = { +static const struct snd_pcm_ops snd_es1688_playback_ops = { .open = snd_es1688_playback_open, .close = snd_es1688_playback_close, .ioctl = snd_es1688_ioctl, @@ -717,7 +717,7 @@ static struct snd_pcm_ops snd_es1688_playback_ops = { .pointer = snd_es1688_playback_pointer, }; -static struct snd_pcm_ops snd_es1688_capture_ops = { +static const struct snd_pcm_ops snd_es1688_capture_ops = { .open = snd_es1688_capture_open, .close = snd_es1688_capture_close, .ioctl = snd_es1688_ioctl, -- cgit v1.1 From 8965e53d1bbc414da9c227eb725f07e872b13c9e Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:01 +0530 Subject: ALSA: es18xx: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index ae17a65..77023e4 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1665,7 +1665,7 @@ static int snd_es18xx_probe(struct snd_es18xx *chip, return snd_es18xx_initialize(chip, mpu_port, fm_port); } -static struct snd_pcm_ops snd_es18xx_playback_ops = { +static const struct snd_pcm_ops snd_es18xx_playback_ops = { .open = snd_es18xx_playback_open, .close = snd_es18xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1676,7 +1676,7 @@ static struct snd_pcm_ops snd_es18xx_playback_ops = { .pointer = snd_es18xx_playback_pointer, }; -static struct snd_pcm_ops snd_es18xx_capture_ops = { +static const struct snd_pcm_ops snd_es18xx_capture_ops = { .open = snd_es18xx_capture_open, .close = snd_es18xx_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From ca58ba6c97cad549b2b243566a4d474bdcaa2c54 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:02 +0530 Subject: ALSA: gus: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/gus/gus_pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 6b3da01..36e852f 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -842,7 +842,7 @@ static const struct snd_kcontrol_new snd_gf1_pcm_volume_control1 = .put = snd_gf1_pcm_volume_put }; -static struct snd_pcm_ops snd_gf1_pcm_playback_ops = { +static const struct snd_pcm_ops snd_gf1_pcm_playback_ops = { .open = snd_gf1_pcm_playback_open, .close = snd_gf1_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -856,7 +856,7 @@ static struct snd_pcm_ops snd_gf1_pcm_playback_ops = { .fill_silence = snd_gf1_pcm_playback_silence, }; -static struct snd_pcm_ops snd_gf1_pcm_capture_ops = { +static const struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .open = snd_gf1_pcm_capture_open, .close = snd_gf1_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From b6dca4622a0fbad4b5f5160dfaabfe5d7bbc1b61 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:03 +0530 Subject: ALSA: msnd: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/msnd/msnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/msnd/msnd.c b/sound/isa/msnd/msnd.c index 8109ab3..ae9562c 100644 --- a/sound/isa/msnd/msnd.c +++ b/sound/isa/msnd/msnd.c @@ -572,7 +572,7 @@ snd_msnd_playback_pointer(struct snd_pcm_substream *substream) } -static struct snd_pcm_ops snd_msnd_playback_ops = { +static const struct snd_pcm_ops snd_msnd_playback_ops = { .open = snd_msnd_playback_open, .close = snd_msnd_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -669,7 +669,7 @@ static int snd_msnd_capture_hw_params(struct snd_pcm_substream *substream, } -static struct snd_pcm_ops snd_msnd_capture_ops = { +static const struct snd_pcm_ops snd_msnd_capture_ops = { .open = snd_msnd_capture_open, .close = snd_msnd_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 84c8f90f0db341aefdd62726c2fe6724d155bbfe Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:04 +0530 Subject: ALSA: emu8000: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 2ee8d67..9409827 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -670,7 +670,7 @@ static snd_pcm_uframes_t emu8k_pcm_pointer(struct snd_pcm_substream *subs) } -static struct snd_pcm_ops emu8k_pcm_ops = { +static const struct snd_pcm_ops emu8k_pcm_ops = { .open = emu8k_pcm_open, .close = emu8k_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 3066ad553ddf6befd37275608c45318bcd2ef7ea Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:05 +0530 Subject: ALSA: sb16: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/sb/sb16_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 4be1350..6fc6325 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -838,7 +838,7 @@ int snd_sb16dsp_configure(struct snd_sb * chip) return 0; } -static struct snd_pcm_ops snd_sb16_playback_ops = { +static const struct snd_pcm_ops snd_sb16_playback_ops = { .open = snd_sb16_playback_open, .close = snd_sb16_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -849,7 +849,7 @@ static struct snd_pcm_ops snd_sb16_playback_ops = { .pointer = snd_sb16_playback_pointer, }; -static struct snd_pcm_ops snd_sb16_capture_ops = { +static const struct snd_pcm_ops snd_sb16_capture_ops = { .open = snd_sb16_capture_open, .close = snd_sb16_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 991768532d3e521bc3cfb667a19b1daae06593e6 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:06 +0530 Subject: ALSA: sb8: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/sb/sb8_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 0f302be..f5d8f2d 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -572,7 +572,7 @@ static int snd_sb8_close(struct snd_pcm_substream *substream) * Initialization part */ -static struct snd_pcm_ops snd_sb8_playback_ops = { +static const struct snd_pcm_ops snd_sb8_playback_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, @@ -583,7 +583,7 @@ static struct snd_pcm_ops snd_sb8_playback_ops = { .pointer = snd_sb8_playback_pointer, }; -static struct snd_pcm_ops snd_sb8_capture_ops = { +static const struct snd_pcm_ops snd_sb8_capture_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From aa5ebc7831bf3822fb3762e700dc848f3f78f728 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 11 Aug 2017 17:28:07 +0530 Subject: ALSA: wss: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/wss/wss_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 9f4e2e3..29adb01 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -1901,7 +1901,7 @@ int snd_wss_create(struct snd_card *card, } EXPORT_SYMBOL(snd_wss_create); -static struct snd_pcm_ops snd_wss_playback_ops = { +static const struct snd_pcm_ops snd_wss_playback_ops = { .open = snd_wss_playback_open, .close = snd_wss_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1912,7 +1912,7 @@ static struct snd_pcm_ops snd_wss_playback_ops = { .pointer = snd_wss_playback_pointer, }; -static struct snd_pcm_ops snd_wss_capture_ops = { +static const struct snd_pcm_ops snd_wss_capture_ops = { .open = snd_wss_capture_open, .close = snd_wss_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 4428ffa1fe66a9e3cf68bba3ad135f17be4ed674 Mon Sep 17 00:00:00 2001 From: Sapthagiri Baratam Date: Mon, 14 Aug 2017 15:46:24 +0100 Subject: arizona: anc: Correct setting of FCx_MIC_MODE_SEL The mask rather than the shift is accidentally passed to the SOC_ENUM_SINGLE macro which results in the wrong bits being set for this control, change to using the shift to correct this. Signed-off-by: Sapthagiri Baratam Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 0a734d9..a1149f6 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -710,7 +710,7 @@ const struct soc_enum arizona_anc_input_src[] = { ARRAY_SIZE(arizona_anc_input_src_text), arizona_anc_input_src_text), SOC_ENUM_SINGLE(ARIZONA_FCL_ADC_REFORMATTER_CONTROL, - ARIZONA_FCL_MIC_MODE_SEL, + ARIZONA_FCL_MIC_MODE_SEL_SHIFT, ARRAY_SIZE(arizona_anc_channel_src_text), arizona_anc_channel_src_text), SOC_ENUM_SINGLE(ARIZONA_ANC_SRC, @@ -718,7 +718,7 @@ const struct soc_enum arizona_anc_input_src[] = { ARRAY_SIZE(arizona_anc_input_src_text), arizona_anc_input_src_text), SOC_ENUM_SINGLE(ARIZONA_FCR_ADC_REFORMATTER_CONTROL, - ARIZONA_FCR_MIC_MODE_SEL, + ARIZONA_FCR_MIC_MODE_SEL_SHIFT, ARRAY_SIZE(arizona_anc_channel_src_text), arizona_anc_channel_src_text), }; -- cgit v1.1 From 9ab51b9469e6a63dbf4385bdd02704e87b65a039 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 13 Aug 2017 16:00:33 +0100 Subject: ASoC: max98926: make max98926_spk_tlv and max98926_current_tlv static max98926_spk_tlv and max98926_current_tlv are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: symbol 'max98926_spk_tlv' was not declared. Should it be static? symbol 'max98926_current_tlv' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/max98926.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index f16145d8..13d2708 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -213,8 +213,8 @@ static bool max98926_readable_register(struct device *dev, unsigned int reg) } }; -DECLARE_TLV_DB_SCALE(max98926_spk_tlv, -600, 100, 0); -DECLARE_TLV_DB_RANGE(max98926_current_tlv, +static DECLARE_TLV_DB_SCALE(max98926_spk_tlv, -600, 100, 0); +static DECLARE_TLV_DB_RANGE(max98926_current_tlv, 0, 11, TLV_DB_SCALE_ITEM(20, 20, 0), 12, 15, TLV_DB_SCALE_ITEM(320, 40, 0), ); -- cgit v1.1 From e5e8e6182a3b9514cde41d957684b59ee8f6cf21 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 13 Aug 2017 16:08:03 +0100 Subject: ASoC: rt5514: make array rt5514_dai static The array rt5514_dai is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warnings: symbol 'rt5514_dai' was not declared. Should it be static? warning: symbol 'rt5514_dai' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 0eabe56..a694ce9 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -1066,7 +1066,7 @@ static const struct snd_soc_dai_ops rt5514_aif_dai_ops = { .set_tdm_slot = rt5514_set_tdm_slot, }; -struct snd_soc_dai_driver rt5514_dai[] = { +static struct snd_soc_dai_driver rt5514_dai[] = { { .name = "rt5514-aif1", .id = 0, -- cgit v1.1 From def4b1243e56774fdc47de9292111a344f14e88c Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 13 Aug 2017 16:28:08 +0100 Subject: ASoC: zx_aud96p22: make array aud96p22_dt_ids static The array aud96p22_dt_ids is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: symbol 'aud96p22_dt_ids' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/zx_aud96p22.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c index 032fb7c..bc23ce1 100644 --- a/sound/soc/codecs/zx_aud96p22.c +++ b/sound/soc/codecs/zx_aud96p22.c @@ -382,7 +382,7 @@ static int aud96p22_i2c_remove(struct i2c_client *i2c) return 0; } -const struct of_device_id aud96p22_dt_ids[] = { +static const struct of_device_id aud96p22_dt_ids[] = { { .compatible = "zte,zx-aud96p22", }, { } }; -- cgit v1.1 From fa99125e2acca4e85de57cff55aea9fc7cb2930a Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 13 Aug 2017 16:37:15 +0100 Subject: ASoC: samsung: make tm2_dapm_widgets and tm2_pm_ops static tm2_dapm_widgets and tm2_pm_ops are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: symbol 'tm2_dapm_widgets' was not declared. Should it be static? symbol 'tm2_pm_ops' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/samsung/tm2_wm5110.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c index 24cc9d6..68698f3 100644 --- a/sound/soc/samsung/tm2_wm5110.c +++ b/sound/soc/samsung/tm2_wm5110.c @@ -318,7 +318,7 @@ static const struct snd_kcontrol_new tm2_controls[] = { SOC_DAPM_PIN_SWITCH("Headset Mic"), }; -const struct snd_soc_dapm_widget tm2_dapm_widgets[] = { +static const struct snd_soc_dapm_widget tm2_dapm_widgets[] = { SND_SOC_DAPM_HP("HP", NULL), SND_SOC_DAPM_SPK("SPK", NULL), SND_SOC_DAPM_SPK("RCV", NULL), @@ -521,7 +521,7 @@ static void tm2_pm_complete(struct device *dev) tm2_start_sysclk(card); } -const struct dev_pm_ops tm2_pm_ops = { +static const struct dev_pm_ops tm2_pm_ops = { .prepare = tm2_pm_prepare, .suspend = snd_soc_suspend, .resume = snd_soc_resume, -- cgit v1.1 From 0cc798651a7796712a7bee1f3c865e82967d933f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:31 +0530 Subject: ASoC: samsung: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/samsung/idma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index 3e40815..5c59c95 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -325,7 +325,7 @@ static int idma_close(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops idma_ops = { +static const struct snd_pcm_ops idma_ops = { .open = idma_open, .close = idma_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From d92dd70e9a47cce7d51bda584e7910efd0c4ba20 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:47 +0530 Subject: ASoC: samsung: make snd_soc_platform_driver const Make this const as it is only passed as the 2nd argument to the function devm_snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/samsung/idma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index 5c59c95..a635df6 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -399,7 +399,7 @@ void idma_reg_addr_init(void __iomem *regs, dma_addr_t addr) } EXPORT_SYMBOL_GPL(idma_reg_addr_init); -static struct snd_soc_platform_driver asoc_idma_platform = { +static const struct snd_soc_platform_driver asoc_idma_platform = { .ops = &idma_ops, .pcm_new = idma_new, .pcm_free = idma_free, -- cgit v1.1 From c5755fbc0702ddb38d2b476a49327b59d4d75a00 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 14 Aug 2017 09:46:59 +0800 Subject: ASoC: rt5663: Fine tune for the headphone output pop sound The patch fine tunes for the headphone output pop sound. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index be93231..fdc2bbc 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -1565,6 +1565,10 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) val = snd_soc_read(codec, RT5663_EM_JACK_TYPE_2) & 0x0003; dev_dbg(codec->dev, "%s val = %d\n", __func__, val); + snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK, + RT5663_OSW_HP_L_EN | RT5663_OSW_HP_R_EN); + switch (val) { case 1: case 2: @@ -2073,6 +2077,8 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7766); snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); + snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, + 0x8000); snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x3000); } @@ -2105,14 +2111,19 @@ static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - if (rt5663->codec_ver == CODEC_VER_0) - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x003b, - 0x003b); + if (rt5663->codec_ver == CODEC_VER_0) { + snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, + 0x0030); + snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, + 0x0003); + } break; case SND_SOC_DAPM_POST_PMD: - if (rt5663->codec_ver == CODEC_VER_0) - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x003b, 0); + if (rt5663->codec_ver == CODEC_VER_0) { + snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); + snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); + } break; default: -- cgit v1.1 From e731a870153271c861f06dc09e6acb5781b973f3 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:24 +0530 Subject: ASoC: au1x: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/au1x/dbdma2.c | 2 +- sound/soc/au1x/dma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index b5d1caa..6a035ca 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -304,7 +304,7 @@ static int au1xpsc_pcm_close(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops au1xpsc_pcm_ops = { +static const struct snd_pcm_ops au1xpsc_pcm_ops = { .open = au1xpsc_pcm_open, .close = au1xpsc_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index fcf5a9a..19457e2 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -277,7 +277,7 @@ static snd_pcm_uframes_t alchemy_pcm_pointer(struct snd_pcm_substream *ss) return bytes_to_frames(ss->runtime, location); } -static struct snd_pcm_ops alchemy_pcm_ops = { +static const struct snd_pcm_ops alchemy_pcm_ops = { .open = alchemy_pcm_open, .close = alchemy_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From e76b3f41a3c39fae342fe4db530c3917199cfa96 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:25 +0530 Subject: ASoC: blackfin: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-ac97-pcm.c | 2 +- sound/soc/blackfin/bf5xx-i2s-pcm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 913e292..8c1d198 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c @@ -308,7 +308,7 @@ static int bf5xx_pcm_copy_user(struct snd_pcm_substream *substream, } #endif -static struct snd_pcm_ops bf5xx_pcm_ac97_ops = { +static const struct snd_pcm_ops bf5xx_pcm_ac97_ops = { .open = bf5xx_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = bf5xx_pcm_hw_params, diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 470d99a..51cae76 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -318,7 +318,7 @@ static int bf5xx_pcm_silence(struct snd_pcm_substream *substream, return 0; } -static struct snd_pcm_ops bf5xx_pcm_i2s_ops = { +static const struct snd_pcm_ops bf5xx_pcm_i2s_ops = { .open = bf5xx_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = bf5xx_pcm_hw_params, -- cgit v1.1 From b6ed072028705620ea2937ddafd77a202df034af Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:26 +0530 Subject: ASoC: fsl: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 2 +- sound/soc/fsl/imx-pcm-fiq.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index ed8ea00..979ed1b 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -870,7 +870,7 @@ static struct device_node *find_ssi_node(struct device_node *dma_channel_np) return NULL; } -static struct snd_pcm_ops fsl_dma_ops = { +static const struct snd_pcm_ops fsl_dma_ops = { .open = fsl_dma_open, .close = fsl_dma_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 92410f7..9ce3761 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -227,7 +227,7 @@ static int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, return ret; } -static struct snd_pcm_ops imx_pcm_ops = { +static const struct snd_pcm_ops imx_pcm_ops = { .open = snd_imx_open, .close = snd_imx_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 1f7e70b..66042ce 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -287,7 +287,7 @@ psc_dma_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_pcm_ops psc_dma_ops = { +static const struct snd_pcm_ops psc_dma_ops = { .open = psc_dma_open, .close = psc_dma_close, .hw_free = psc_dma_hw_free, -- cgit v1.1 From 779238e28e42ff49f314df217de146b14d72c582 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:42 +0530 Subject: ASoC: fsl: make snd_soc_platform_driver const Make these const as they are only passed as the 2nd argument to the function snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/fsl/imx-pcm-fiq.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 9ce3761..aef1f78 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -341,7 +341,7 @@ static void imx_pcm_fiq_free(struct snd_pcm *pcm) imx_pcm_free(pcm); } -static struct snd_soc_platform_driver imx_soc_platform_fiq = { +static const struct snd_soc_platform_driver imx_soc_platform_fiq = { .ops = &imx_pcm_ops, .pcm_new = imx_pcm_fiq_new, .pcm_free = imx_pcm_fiq_free, diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 66042ce..e63029f 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -356,7 +356,7 @@ static void psc_dma_free(struct snd_pcm *pcm) } } -static struct snd_soc_platform_driver mpc5200_audio_dma_platform = { +static const struct snd_soc_platform_driver mpc5200_audio_dma_platform = { .ops = &psc_dma_ops, .pcm_new = &psc_dma_new, .pcm_free = &psc_dma_free, -- cgit v1.1 From 83823c43c25a62b529f9dbad48c182b3d1fdddd1 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:43 +0530 Subject: ASoC: nuc900: make snd_soc_platform_driver const Make this const as it is only passed as the 2nd argument to the function devm_snd_soc_register_platform, which is of type const. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/nuc900/nuc900-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index 2cca055..cd0486c 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -299,7 +299,7 @@ static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver nuc900_soc_platform = { +static const struct snd_soc_platform_driver nuc900_soc_platform = { .ops = &nuc900_dma_ops, .pcm_new = nuc900_dma_new, }; -- cgit v1.1 From 3a7f221723a6f0032a7d908f3f91ab8604f0311f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:29 +0530 Subject: ASoC: omap: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/omap/omap-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 94e9ff7..e2f1245 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -162,7 +162,7 @@ static int omap_pcm_mmap(struct snd_pcm_substream *substream, runtime->dma_addr, runtime->dma_bytes); } -static struct snd_pcm_ops omap_pcm_ops = { +static const struct snd_pcm_ops omap_pcm_ops = { .open = omap_pcm_open, .close = snd_dmaengine_pcm_close_release_chan, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 27bfda02662152f5e0d17731063cfcb342904b58 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:44 +0530 Subject: ASoC: omap: make snd_soc_platform_driver const Make this const as it is only passed as the 2nd argument to the function devm_snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/omap/omap-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index e2f1245..aca2c43 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -243,7 +243,7 @@ out: return ret; } -static struct snd_soc_platform_driver omap_soc_platform = { +static const struct snd_soc_platform_driver omap_soc_platform = { .ops = &omap_pcm_ops, .pcm_new = omap_pcm_new, .pcm_free = omap_pcm_free_dma_buffers, -- cgit v1.1 From 3d882b0ec6a50c5adff8e94a69d284543460fbe6 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:45 +0530 Subject: ASoC: pxa: make snd_soc_platform_driver const Make these const as they are only passed as the 2nd argument to the function devm_snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-pcm.c | 2 +- sound/soc/pxa/pxa2xx-pcm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 5b5f1a4..38d5999 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -211,7 +211,7 @@ err: return ret; } -static struct snd_soc_platform_driver mmp_soc_platform = { +static const struct snd_soc_platform_driver mmp_soc_platform = { .ops = &mmp_pcm_ops, .pcm_new = mmp_pcm_new, .pcm_free = mmp_pcm_free_dma_buffers, diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index b51d7a0..636895a 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -84,7 +84,7 @@ static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static struct snd_soc_platform_driver pxa2xx_soc_platform = { +static const struct snd_soc_platform_driver pxa2xx_soc_platform = { .ops = &pxa2xx_pcm_ops, .pcm_new = pxa2xx_soc_pcm_new, .pcm_free = pxa2xx_pcm_free_dma_buffers, -- cgit v1.1 From d7622fa715f20dbc7c1ab0dbdd714be5a2b4c3bd Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:30 +0530 Subject: ASoC: pxa: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-pcm.c | 2 +- sound/soc/pxa/pxa2xx-pcm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 38d5999..624d9bd 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -131,7 +131,7 @@ static int mmp_pcm_mmap(struct snd_pcm_substream *substream, vma->vm_end - vma->vm_start, vma->vm_page_prot); } -static struct snd_pcm_ops mmp_pcm_ops = { +static const struct snd_pcm_ops mmp_pcm_ops = { .open = mmp_pcm_open, .close = snd_dmaengine_pcm_close_release_chan, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index 636895a..e64958d 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -45,7 +45,7 @@ static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops pxa2xx_pcm_ops = { +static const struct snd_pcm_ops pxa2xx_pcm_ops = { .open = __pxa2xx_pcm_open, .close = __pxa2xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 50d50c33d29a868bd58e0f320c19b9e9e7084a2a Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:46 +0530 Subject: ASoC: qcom: make snd_soc_platform_driver const Make this const as it is only passed as the 2nd argument to the function devm_snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index 7aabf08..fb3576a 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -557,7 +557,7 @@ static void lpass_platform_pcm_free(struct snd_pcm *pcm) } } -static struct snd_soc_platform_driver lpass_platform_driver = { +static const struct snd_soc_platform_driver lpass_platform_driver = { .pcm_new = lpass_platform_pcm_new, .pcm_free = lpass_platform_pcm_free, .ops = &lpass_platform_pcm_ops, -- cgit v1.1 From 517725545179be8d32730844f1619ee31ef04bf3 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:48 +0530 Subject: ASoC: sh: make snd_soc_platform_driver const Make these const as they are either passed as the 2nd argument to the function devm_snd_soc_register_platform or snd_soc_register_platform, and the arguments are of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 2 +- sound/soc/sh/fsi.c | 2 +- sound/soc/sh/rcar/core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 8fad444..81c7433 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -320,7 +320,7 @@ static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver sh7760_soc_platform = { +static const struct snd_soc_platform_driver sh7760_soc_platform = { .ops = &camelot_pcm_ops, .pcm_new = camelot_pcm_new, }; diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 7c4bdd8..90021b8 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1818,7 +1818,7 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { }, }; -static struct snd_soc_platform_driver fsi_soc_platform = { +static const struct snd_soc_platform_driver fsi_soc_platform = { .ops = &fsi_pcm_ops, .pcm_new = fsi_pcm_new, }; diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 3f2ced2..e50f7e7 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1339,7 +1339,7 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } -static struct snd_soc_platform_driver rsnd_soc_platform = { +static const struct snd_soc_platform_driver rsnd_soc_platform = { .ops = &rsnd_pcm_ops, .pcm_new = rsnd_pcm_new, }; -- cgit v1.1 From 42271d951c1f9a6a3ae0392d245256d973b2fc58 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:49 +0530 Subject: ASoC: txx9: make snd_soc_platform_driver const Make this const as it is only passed as the 2nd argument to the function devm_snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index 7912bf0..7df95df 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -403,7 +403,7 @@ static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) return 0; } -static struct snd_soc_platform_driver txx9aclc_soc_platform = { +static const struct snd_soc_platform_driver txx9aclc_soc_platform = { .probe = txx9aclc_pcm_probe, .remove = txx9aclc_pcm_remove, .ops = &txx9aclc_pcm_ops, -- cgit v1.1 From 5144468efb076b1859477de19257dd7ec9c24ed3 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:33 +0530 Subject: ASoC: txx9: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index 7df95df..a2bb68f 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -271,7 +271,7 @@ static int txx9aclc_pcm_close(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops txx9aclc_pcm_ops = { +static const struct snd_pcm_ops txx9aclc_pcm_ops = { .open = txx9aclc_pcm_open, .close = txx9aclc_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From c9f3d3441311792a0beb410af74e1aad4c3f715d Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:50 +0530 Subject: ASoC: soc-utils: make snd_soc_platform_driver const Make this const as it is only passed as the 2nd argument to the function snd_soc_register_platform, which is of type const. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 644d9a9..e30aacb 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,7 +284,7 @@ static const struct snd_pcm_ops dummy_dma_ops = { .ioctl = snd_pcm_lib_ioctl, }; -static struct snd_soc_platform_driver dummy_platform = { +static const struct snd_soc_platform_driver dummy_platform = { .ops = &dummy_dma_ops, }; -- cgit v1.1 From 0ed6f15701efa0d62b4556900cd67a726578389e Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:40 +0530 Subject: ASoC: codecs: make snd_soc_platform_driver const Make these const as they are either passed as the 2nd argument to the function devm_snd_soc_register_platform or snd_soc_register_platform, and the arguments are of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l24.c | 2 +- sound/soc/codecs/rt5514-spi.c | 2 +- sound/soc/codecs/wm5102.c | 2 +- sound/soc/codecs/wm5110.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index d323caa..505dbc9 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -1213,7 +1213,7 @@ static struct snd_compr_ops cs47l24_compr_ops = { .copy = wm_adsp_compr_copy, }; -static struct snd_soc_platform_driver cs47l24_compr_platform = { +static const struct snd_soc_platform_driver cs47l24_compr_platform = { .compr_ops = &cs47l24_compr_ops, }; diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 7ed62e8..87a587f 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -260,7 +260,7 @@ static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) return 0; } -static struct snd_soc_platform_driver rt5514_spi_platform = { +static const struct snd_soc_platform_driver rt5514_spi_platform = { .probe = rt5514_spi_pcm_probe, .ops = &rt5514_spi_pcm_ops, }; diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 1fe358e..f500692 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -2027,7 +2027,7 @@ static struct snd_compr_ops wm5102_compr_ops = { .copy = wm_adsp_compr_copy, }; -static struct snd_soc_platform_driver wm5102_compr_platform = { +static const struct snd_soc_platform_driver wm5102_compr_platform = { .compr_ops = &wm5102_compr_ops, }; diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 1bc9421..d6fae139 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -2382,7 +2382,7 @@ static struct snd_compr_ops wm5110_compr_ops = { .copy = wm_adsp_compr_copy, }; -static struct snd_soc_platform_driver wm5110_compr_platform = { +static const struct snd_soc_platform_driver wm5110_compr_platform = { .compr_ops = &wm5110_compr_ops, }; -- cgit v1.1 From 80cc4df8b46e91c28a6d39dd0ba76bd9c83c18ce Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Mon, 14 Aug 2017 17:08:41 +0530 Subject: ASoC: Intel: make snd_soc_platform_driver const Make these const as they are only passed as the 2nd argument to the function snd_soc_register_platform, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 2 +- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 2 +- sound/soc/intel/haswell/sst-haswell-pcm.c | 2 +- sound/soc/intel/skylake/skl-pcm.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 49c7b88..b272df5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -705,7 +705,7 @@ static int sst_soc_probe(struct snd_soc_platform *platform) return sst_dsp_init_v2_dpcm(platform); } -static struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_platform_driver sst_soc_platform_drv = { .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index 4765ad4..84cb568 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -395,7 +395,7 @@ static int sst_byt_pcm_remove(struct snd_soc_platform *platform) return 0; } -static struct snd_soc_platform_driver byt_soc_platform = { +static const struct snd_soc_platform_driver byt_soc_platform = { .probe = sst_byt_pcm_probe, .remove = sst_byt_pcm_remove, .ops = &sst_byt_pcm_ops, diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index 9e4094e..c044400 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -1135,7 +1135,7 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform) return 0; } -static struct snd_soc_platform_driver hsw_soc_platform = { +static const struct snd_soc_platform_driver hsw_soc_platform = { .probe = hsw_pcm_probe, .remove = hsw_pcm_remove, .ops = &hsw_pcm_ops, diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index debdaac..e98d825 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1310,7 +1310,7 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) return 0; } -static struct snd_soc_platform_driver skl_platform_drv = { +static const struct snd_soc_platform_driver skl_platform_drv = { .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, -- cgit v1.1 From f2c402ba55fe7cc3924de683ac5eef99c75eab04 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:27 +0530 Subject: ASoC: intel: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index 84cb568..c545293 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -309,7 +309,7 @@ static int sst_byt_pcm_mmap(struct snd_pcm_substream *substream, return snd_pcm_lib_default_mmap(substream, vma); } -static struct snd_pcm_ops sst_byt_pcm_ops = { +static const struct snd_pcm_ops sst_byt_pcm_ops = { .open = sst_byt_pcm_open, .close = sst_byt_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From f70eab3aad004b7496755ec77763bfd6e2eff553 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:28 +0530 Subject: ASoC: nuc900: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/nuc900/nuc900-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index cd0486c..bd6dfa2 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -271,7 +271,7 @@ static int nuc900_dma_mmap(struct snd_pcm_substream *substream, runtime->dma_addr, runtime->dma_bytes); } -static struct snd_pcm_ops nuc900_dma_ops = { +static const struct snd_pcm_ops nuc900_dma_ops = { .open = nuc900_dma_open, .close = nuc900_dma_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From b23bd34c402d08a2c1d6facdba4a75e016601c12 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Mon, 14 Aug 2017 11:26:32 +0530 Subject: ASoC: sh: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 2 +- sound/soc/sh/fsi.c | 2 +- sound/soc/sh/rcar/core.c | 2 +- sound/soc/sh/siu_pcm.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 81c7433..35788a6 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -294,7 +294,7 @@ static snd_pcm_uframes_t camelot_pos(struct snd_pcm_substream *substream) return bytes_to_frames(runtime, pos); } -static struct snd_pcm_ops camelot_pcm_ops = { +static const struct snd_pcm_ops camelot_pcm_ops = { .open = camelot_pcm_open, .close = camelot_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 90021b8..5d7d9fe 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1755,7 +1755,7 @@ static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream) return fsi_sample2frame(fsi, io->buff_sample_pos); } -static struct snd_pcm_ops fsi_pcm_ops = { +static const struct snd_pcm_ops fsi_pcm_ops = { .open = fsi_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = fsi_hw_params, diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index e50f7e7..08f3a06 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1158,7 +1158,7 @@ static snd_pcm_uframes_t rsnd_pointer(struct snd_pcm_substream *substream) return pointer; } -static struct snd_pcm_ops rsnd_pcm_ops = { +static const struct snd_pcm_ops rsnd_pcm_ops = { .open = rsnd_pcm_open, .ioctl = snd_pcm_lib_ioctl, .hw_params = rsnd_hw_params, diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 82902f5..3118cb0e 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -593,7 +593,7 @@ static void siu_pcm_free(struct snd_pcm *pcm) dev_dbg(pcm->card->dev, "%s\n", __func__); } -static struct snd_pcm_ops siu_pcm_ops = { +static const struct snd_pcm_ops siu_pcm_ops = { .open = siu_pcm_open, .close = siu_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 0aef27cab880d9612331350c008aec00cbb3d247 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 12 Aug 2017 13:00:49 +0200 Subject: ASoC: sun4i-i2s: Add clkdiv offsets to quirks The BCLKDIV and MCLKDIV found on newer SoCs start from an offset of 1. Add the functionality to adjust the division values according to the needs to the device being used. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index d7ee7a4..9a35313 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -94,9 +94,13 @@ * struct sun4i_i2s_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. + * @mclk_offset: Value by which mclkdiv needs to be adjusted. + * @bclk_offset: Value by which bclkdiv needs to be adjusted. */ struct sun4i_i2s_quirks { bool has_reset; + unsigned int mclk_offset; + unsigned int bclk_offset; }; struct sun4i_i2s { @@ -237,6 +241,10 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s, if (mclk_div < 0) return -EINVAL; + /* Adjust the clock division values if needed */ + bclk_div += i2s->variant->bclk_offset; + mclk_div += i2s->variant->mclk_offset; + regmap_write(i2s->regmap, SUN4I_I2S_CLK_DIV_REG, SUN4I_I2S_CLK_DIV_BCLK(bclk_div) | SUN4I_I2S_CLK_DIV_MCLK(mclk_div) | -- cgit v1.1 From cd1c63df5fa8196d8ed5138f1ecc22bbabf5f6df Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 12 Aug 2017 13:00:50 +0200 Subject: ASoC: sun4i-i2s: Add regmap config to quirks The newer SoCs have a larger range than the original SoC that this driver was developed for. By adding the regmap config to the quirks then the driver can initialise the managed register map correctly. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 9a35313..f6f3c40 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -94,11 +94,13 @@ * struct sun4i_i2s_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. + * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. */ struct sun4i_i2s_quirks { bool has_reset; + const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; unsigned int bclk_offset; }; @@ -674,11 +676,13 @@ static int sun4i_i2s_runtime_suspend(struct device *dev) } static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { - .has_reset = false, + .has_reset = false, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, }; static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { - .has_reset = true, + .has_reset = true, + .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, }; static int sun4i_i2s_probe(struct platform_device *pdev) @@ -717,7 +721,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev) } i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, - &sun4i_i2s_regmap_config); + i2s->variant->sun4i_i2s_regmap); if (IS_ERR(i2s->regmap)) { dev_err(&pdev->dev, "Regmap initialisation failed\n"); return PTR_ERR(i2s->regmap); -- cgit v1.1 From 3509476e522baaa68813609801c48aa428bae81a Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 12 Aug 2017 13:00:51 +0200 Subject: ASoC: sun4i-i2s: Add TX FIFO offset to quirks It has been seen that the newer SoCs have a different TX FIFO address. Add this to the quirks structure. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index f6f3c40..dfb794f 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -94,12 +94,14 @@ * struct sun4i_i2s_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. + * @reg_offset_txdata: offset of the tx fifo. * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. */ struct sun4i_i2s_quirks { bool has_reset; + unsigned int reg_offset_txdata; /* TX FIFO */ const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; unsigned int bclk_offset; @@ -677,11 +679,13 @@ static int sun4i_i2s_runtime_suspend(struct device *dev) static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .has_reset = false, + .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, }; static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .has_reset = true, + .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, }; @@ -750,7 +754,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev) } } - i2s->playback_dma_data.addr = res->start + SUN4I_I2S_FIFO_TX_REG; + i2s->playback_dma_data.addr = res->start + + i2s->variant->reg_offset_txdata; i2s->playback_dma_data.maxburst = 8; i2s->capture_dma_data.addr = res->start + SUN4I_I2S_FIFO_RX_REG; -- cgit v1.1 From 60ea0394a602d5abc24bd2381fa0966a8720eec1 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 21:45:37 +0200 Subject: ASoC: blackfin: Delete an error message for a failed memory allocation in sport_create() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/blackfin/bf6xx-sport.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/blackfin/bf6xx-sport.c b/sound/soc/blackfin/bf6xx-sport.c index dfb7443..1bc3e0a 100644 --- a/sound/soc/blackfin/bf6xx-sport.c +++ b/sound/soc/blackfin/bf6xx-sport.c @@ -388,10 +388,9 @@ struct sport_device *sport_create(struct platform_device *pdev) int ret; sport = kzalloc(sizeof(*sport), GFP_KERNEL); - if (!sport) { - dev_err(dev, "Unable to allocate memory for sport device\n"); + if (!sport) return NULL; - } + sport->pdev = pdev; ret = sport_get_resource(sport); -- cgit v1.1 From 11fca34b2783408dbf37e42a38e4b55d54d6fa3a Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 22:02:47 +0200 Subject: ASoC: blackfin: Use common error handling code in sport_create() Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/blackfin/bf6xx-sport.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/blackfin/bf6xx-sport.c b/sound/soc/blackfin/bf6xx-sport.c index 1bc3e0a..fcddebf 100644 --- a/sound/soc/blackfin/bf6xx-sport.c +++ b/sound/soc/blackfin/bf6xx-sport.c @@ -394,19 +394,18 @@ struct sport_device *sport_create(struct platform_device *pdev) sport->pdev = pdev; ret = sport_get_resource(sport); - if (ret) { - kfree(sport); - return NULL; - } + if (ret) + goto free_data; ret = sport_request_resource(sport); - if (ret) { - kfree(sport); - return NULL; - } + if (ret) + goto free_data; dev_dbg(dev, "SPORT create success\n"); return sport; +free_data: + kfree(sport); + return NULL; } EXPORT_SYMBOL(sport_create); -- cgit v1.1 From 11f25bbaaa87bf583a453b202db9c8ee9b3cbd50 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 22:20:07 +0200 Subject: ASoC: blackfin: Add some spaces for better code readability Use space characters at some source code places according to the Linux coding style convention. Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/blackfin/bf6xx-sport.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/blackfin/bf6xx-sport.c b/sound/soc/blackfin/bf6xx-sport.c index fcddebf..d2caadf 100644 --- a/sound/soc/blackfin/bf6xx-sport.c +++ b/sound/soc/blackfin/bf6xx-sport.c @@ -129,7 +129,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, for (i = 0; i < fragcount; ++i) { desc[i].next_desc_addr = &(desc[i + 1]); - desc[i].start_addr = (unsigned long)buf + i*fragsize; + desc[i].start_addr = (unsigned long)buf + i * fragsize; desc[i].cfg = cfg; desc[i].x_count = count; desc[i].x_modify = wdsize; @@ -138,7 +138,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, } /* make circular */ - desc[fragcount-1].next_desc_addr = desc; + desc[fragcount - 1].next_desc_addr = desc; } int sport_config_tx_dma(struct sport_device *sport, void *buf, @@ -148,7 +148,7 @@ int sport_config_tx_dma(struct sport_device *sport, void *buf, unsigned int cfg; dma_addr_t addr; - count = fragsize/sport->wdsize; + count = fragsize / sport->wdsize; if (sport->tx_desc) dma_free_coherent(NULL, sport->tx_desc_size, @@ -166,8 +166,7 @@ int sport_config_tx_dma(struct sport_device *sport, void *buf, cfg = DMAFLOW_LIST | DI_EN | compute_wdsize(sport->wdsize) | NDSIZE_6; setup_desc(sport->tx_desc, buf, fragcount, fragsize, - cfg|DMAEN, count, sport->wdsize); - + cfg | DMAEN, count, sport->wdsize); return 0; } EXPORT_SYMBOL(sport_config_tx_dma); @@ -179,7 +178,7 @@ int sport_config_rx_dma(struct sport_device *sport, void *buf, unsigned int cfg; dma_addr_t addr; - count = fragsize/sport->wdsize; + count = fragsize / sport->wdsize; if (sport->rx_desc) dma_free_coherent(NULL, sport->rx_desc_size, @@ -198,8 +197,7 @@ int sport_config_rx_dma(struct sport_device *sport, void *buf, | WNR | NDSIZE_6; setup_desc(sport->rx_desc, buf, fragcount, fragsize, - cfg|DMAEN, count, sport->wdsize); - + cfg | DMAEN, count, sport->wdsize); return 0; } EXPORT_SYMBOL(sport_config_rx_dma); @@ -226,7 +224,7 @@ static irqreturn_t sport_tx_irq(int irq, void *dev_id) static unsigned long status; status = get_dma_curr_irqstat(sport->tx_dma_chan); - if (status & (DMA_DONE|DMA_ERR)) { + if (status & (DMA_DONE | DMA_ERR)) { clear_dma_irqstat(sport->tx_dma_chan); SSYNC(); } @@ -241,7 +239,7 @@ static irqreturn_t sport_rx_irq(int irq, void *dev_id) unsigned long status; status = get_dma_curr_irqstat(sport->rx_dma_chan); - if (status & (DMA_DONE|DMA_ERR)) { + if (status & (DMA_DONE | DMA_ERR)) { clear_dma_irqstat(sport->rx_dma_chan); SSYNC(); } -- cgit v1.1 From b88845484d05c2910ffc40a7d30fa36e58b2dd0d Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 16:04:53 +0200 Subject: ASoC: dwc: Delete an error message for a failed memory allocation in dw_i2s_probe() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-i2s.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c index eebe9d3..e27e21f 100644 --- a/sound/soc/dwc/dwc-i2s.c +++ b/sound/soc/dwc/dwc-i2s.c @@ -617,10 +617,8 @@ static int dw_i2s_probe(struct platform_device *pdev) const char *clk_id; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); - if (!dev) { - dev_warn(&pdev->dev, "kzalloc fail\n"); + if (!dev) return -ENOMEM; - } dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL); if (!dw_i2s_dai) -- cgit v1.1 From c7591edc2abd279018abb68aea5bdc604b8f56dd Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 09:35:33 +0200 Subject: ASoC: kirkwood: Delete an error message for a failed memory allocation in kirkwood_i2s_dev_probe() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-i2s.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 3b09f71..105a73c 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -538,10 +538,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) int err; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) { - dev_err(&pdev->dev, "allocation failed\n"); + if (!priv) return -ENOMEM; - } + dev_set_drvdata(&pdev->dev, priv); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); -- cgit v1.1 From dd80627d0688709a77233787a9c9d7e1f8e419ac Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 10 Aug 2017 18:18:20 +0200 Subject: ASoC: fsi: Delete an error message for a failed memory allocation in fsi_probe() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/sh/fsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 005b215..1f41cf1 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1962,10 +1962,8 @@ static int fsi_probe(struct platform_device *pdev) } master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL); - if (!master) { - dev_err(&pdev->dev, "Could not allocate master\n"); + if (!master) return -ENOMEM; - } master->base = devm_ioremap_nocache(&pdev->dev, res->start, resource_size(res)); -- cgit v1.1 From b48b2710913d583ff93c365413532e1a7cd60d84 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 10 Aug 2017 18:38:09 +0200 Subject: ASoC: rockchip: Delete an error message for a failed memory allocation in rockchip_i2s_probe() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/rockchip/rockchip_i2s.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 199338f..b659046 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -579,10 +579,8 @@ static int rockchip_i2s_probe(struct platform_device *pdev) int val; i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); - if (!i2s) { - dev_err(&pdev->dev, "Can't allocate rk_i2s_dev\n"); + if (!i2s) return -ENOMEM; - } i2s->dev = &pdev->dev; -- cgit v1.1 From dc09233908cf47339f5000dc54574685e917af77 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 16:51:46 +0200 Subject: ASoC: DaVinci: Delete an error message for a failed memory allocation in two functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 2 -- sound/soc/davinci/davinci-vcif.c | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 56ec1d3..d486908 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1602,8 +1602,6 @@ static struct davinci_mcasp_pdata *davinci_mcasp_set_pdata_from_of( pdata = devm_kmemdup(&pdev->dev, match->data, sizeof(*pdata), GFP_KERNEL); if (!pdata) { - dev_err(&pdev->dev, - "Failed to allocate memory for pdata\n"); ret = -ENOMEM; return pdata; } diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c index c77d921..5415b72 100644 --- a/sound/soc/davinci/davinci-vcif.c +++ b/sound/soc/davinci/davinci-vcif.c @@ -210,11 +210,8 @@ static int davinci_vcif_probe(struct platform_device *pdev) davinci_vcif_dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_vcif_dev), GFP_KERNEL); - if (!davinci_vcif_dev) { - dev_dbg(&pdev->dev, - "could not allocate memory for private data\n"); + if (!davinci_vcif_dev) return -ENOMEM; - } /* DMA tx params */ davinci_vcif_dev->davinci_vc = davinci_vc; -- cgit v1.1 From 3013c75fadc581160be8d89c2c0f29219971c58f Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 12 Aug 2017 23:50:28 +0100 Subject: ASoC: hdmi-codec: make a function and two arrays static The function hdmi_codec_eld_chmap and arrays hdmi_codec_stereo_chmaps and hdmi_codec_8ch_chmaps are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnings: symbol 'hdmi_codec_eld_chmap' was not declared. Should it be static? symbol 'hdmi_codec_stereo_chmaps' was not declared. Should it be static? symbol 'hdmi_codec_8ch_chmaps' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 509ab51..f752041 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -67,14 +67,14 @@ struct hdmi_codec_cea_spk_alloc { }; /* Channel maps stereo HDMI */ -const struct snd_pcm_chmap_elem hdmi_codec_stereo_chmaps[] = { +static const struct snd_pcm_chmap_elem hdmi_codec_stereo_chmaps[] = { { .channels = 2, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, { } }; /* Channel maps for multi-channel playbacks, up to 8 n_ch */ -const struct snd_pcm_chmap_elem hdmi_codec_8ch_chmaps[] = { +static const struct snd_pcm_chmap_elem hdmi_codec_8ch_chmaps[] = { { .channels = 2, /* CA_ID 0x00 */ .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, { .channels = 4, /* CA_ID 0x01 */ @@ -340,7 +340,7 @@ static unsigned long hdmi_codec_spk_mask_from_alloc(int spk_alloc) return spk_mask; } -void hdmi_codec_eld_chmap(struct hdmi_codec_priv *hcp) +static void hdmi_codec_eld_chmap(struct hdmi_codec_priv *hcp) { u8 spk_alloc; unsigned long spk_mask; -- cgit v1.1 From 2675be5a004ee0d8155d2ad48cad95920f727921 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Mon, 14 Aug 2017 22:00:40 +0200 Subject: ALSA: rme9652: Use common error handling code in two functions Add a jump target so that a bit of exception handling can be better reused in these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdsp.c | 13 ++++++------- sound/pci/rme9652/rme9652.c | 14 ++++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 9535e6a..0ff41f9 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -5381,17 +5381,16 @@ static int snd_hdsp_probe(struct pci_dev *pci, card->private_free = snd_hdsp_card_free; hdsp->dev = dev; hdsp->pci = pci; - - if ((err = snd_hdsp_create(card, hdsp)) < 0) { - snd_card_free(card); - return err; - } + err = snd_hdsp_create(card, hdsp); + if (err) + goto free_card; strcpy(card->shortname, "Hammerfall DSP"); sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, hdsp->port, hdsp->irq); - - if ((err = snd_card_register(card)) < 0) { + err = snd_card_register(card); + if (err) { +free_card: snd_card_free(card); return err; } diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index eff4993..df648b1 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -2618,19 +2618,17 @@ static int snd_rme9652_probe(struct pci_dev *pci, card->private_free = snd_rme9652_card_free; rme9652->dev = dev; rme9652->pci = pci; - - if ((err = snd_rme9652_create(card, rme9652, precise_ptr[dev])) < 0) { - snd_card_free(card); - return err; - } + err = snd_rme9652_create(card, rme9652, precise_ptr[dev]); + if (err) + goto free_card; strcpy(card->shortname, rme9652->card_name); sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, rme9652->port, rme9652->irq); - - - if ((err = snd_card_register(card)) < 0) { + err = snd_card_register(card); + if (err) { +free_card: snd_card_free(card); return err; } -- cgit v1.1 From c9480d055e306a855f8a8d2b3b097773cd0d5ad0 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 14 Aug 2017 19:13:26 +0200 Subject: sound: emu8000: constify emu8000_ops The structure emu8000_ops is only copied into another structure, so it can be const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000_callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000_callback.c b/sound/isa/sb/emu8000_callback.c index d28d712..5a48550 100644 --- a/sound/isa/sb/emu8000_callback.c +++ b/sound/isa/sb/emu8000_callback.c @@ -62,7 +62,7 @@ static void snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int ch); /* * set up operators */ -static struct snd_emux_operators emu8000_ops = { +static const struct snd_emux_operators emu8000_ops = { .owner = THIS_MODULE, .get_voice = get_voice, .prepare = start_voice, -- cgit v1.1 From 443be77e4b09d98c28196dca7132a1191ecf742b Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 15:10:43 +0200 Subject: ASoC: Freescale: Delete an error message for a failed memory allocation in three functions Omit an extra message for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc_dma.c | 4 +--- sound/soc/fsl/fsl_dma.c | 1 - sound/soc/fsl/fsl_ssi.c | 4 +--- 3 files changed, 2 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index 282d841..2baf196 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -279,10 +279,8 @@ static int fsl_asrc_dma_startup(struct snd_pcm_substream *substream) struct fsl_asrc_pair *pair; pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); - if (!pair) { - dev_err(dev, "failed to allocate pair\n"); + if (!pair) return -ENOMEM; - } pair->asrc_priv = asrc_priv; diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 979ed1b..c173596 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -905,7 +905,6 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL); if (!dma) { - dev_err(&pdev->dev, "could not allocate dma object\n"); of_node_put(ssi_np); return -ENOMEM; } diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 173cb84..64598d1 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -1432,10 +1432,8 @@ static int fsl_ssi_probe(struct platform_device *pdev) ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private), GFP_KERNEL); - if (!ssi_private) { - dev_err(&pdev->dev, "could not allocate DAI object\n"); + if (!ssi_private) return -ENOMEM; - } ssi_private->soc = of_id->data; ssi_private->dev = &pdev->dev; -- cgit v1.1 From eb2c18309491325381172cc2838006c5e9fdd0f4 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 15 Aug 2017 10:09:54 +0200 Subject: ALSA: firewire-motu: constify snd_rawmidi_ops structures These snd_rawmidi_ops structures are only passed as the third argument of snd_rawmidi_set_ops. This argument is const, so the snd_rawmidi_ops structures can be const too. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Reviewed-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/motu/motu-midi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c index e3acfcc..e55cab6 100644 --- a/sound/firewire/motu/motu-midi.c +++ b/sound/firewire/motu/motu-midi.c @@ -128,12 +128,12 @@ static void set_midi_substream_names(struct snd_motu *motu, int snd_motu_create_midi_devices(struct snd_motu *motu) { - static struct snd_rawmidi_ops capture_ops = { + static const struct snd_rawmidi_ops capture_ops = { .open = midi_capture_open, .close = midi_capture_close, .trigger = midi_capture_trigger, }; - static struct snd_rawmidi_ops playback_ops = { + static const struct snd_rawmidi_ops playback_ops = { .open = midi_playback_open, .close = midi_playback_close, .trigger = midi_playback_trigger, -- cgit v1.1 From a4fe6f37269623b3be21e3697d59677809ef512b Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 15 Aug 2017 17:10:08 +0200 Subject: ASoC: blackfin: constify snd_soc_dai_ops structures These snd_soc_dai_ops structures are only stored in the ops field of a snd_soc_dai_driver structure, which is const. Thus, the snd_soc_dai_ops structures can be const too. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/blackfin/bf6xx-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/blackfin/bf6xx-i2s.c b/sound/soc/blackfin/bf6xx-i2s.c index bd3b4d4..819cff1 100644 --- a/sound/soc/blackfin/bf6xx-i2s.c +++ b/sound/soc/blackfin/bf6xx-i2s.c @@ -164,7 +164,7 @@ static int bfin_i2s_resume(struct snd_soc_dai *dai) #define BFIN_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops bfin_i2s_dai_ops = { +static const struct snd_soc_dai_ops bfin_i2s_dai_ops = { .hw_params = bfin_i2s_hw_params, .set_fmt = bfin_i2s_set_dai_fmt, }; -- cgit v1.1 From 0966a2588779d0d44706f973c1e8ff240be43017 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 15 Aug 2017 17:10:09 +0200 Subject: ASoC: rockchip: constify snd_soc_dai_ops structures These snd_soc_dai_ops structures are only stored in the ops field of a snd_soc_dai_driver structure, which is const. Thus, the snd_soc_dai_ops structures can be const too. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/rockchip/rockchip_pdm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rockchip_pdm.c b/sound/soc/rockchip/rockchip_pdm.c index c5ddeed..400e29e 100644 --- a/sound/soc/rockchip/rockchip_pdm.c +++ b/sound/soc/rockchip/rockchip_pdm.c @@ -249,7 +249,7 @@ static int rockchip_pdm_dai_probe(struct snd_soc_dai *dai) return 0; } -static struct snd_soc_dai_ops rockchip_pdm_dai_ops = { +static const struct snd_soc_dai_ops rockchip_pdm_dai_ops = { .set_fmt = rockchip_pdm_set_fmt, .trigger = rockchip_pdm_trigger, .hw_params = rockchip_pdm_hw_params, -- cgit v1.1 From a6a67da3da332dbde7c04cba9fccef04648c704a Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 15 Aug 2017 17:10:10 +0200 Subject: ASoC: codecs: es8316: constify snd_soc_dai_ops structures These snd_soc_dai_ops structures are only stored in the ops field of a snd_soc_dai_driver structure, which is const. Thus, the snd_soc_dai_ops structures can be const too. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/codecs/es8316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index ecc02449..f5cf48c 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -502,7 +502,7 @@ static int es8316_mute(struct snd_soc_dai *dai, int mute) #define ES8316_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops es8316_ops = { +static const struct snd_soc_dai_ops es8316_ops = { .startup = es8316_pcm_startup, .hw_params = es8316_pcm_hw_params, .set_fmt = es8316_set_dai_fmt, -- cgit v1.1 From 66f41da341cd97ad362c4a40e1c9a0a28d746f81 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 15 Aug 2017 17:10:11 +0200 Subject: ASoC: codecs: zx_aud96p22: constify snd_soc_dai_ops structures These snd_soc_dai_ops structures are only stored in the ops field of a snd_soc_dai_driver structure, which is const. Thus, the snd_soc_dai_ops structures can be const too. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/codecs/zx_aud96p22.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c index bc23ce1..0e5b43b 100644 --- a/sound/soc/codecs/zx_aud96p22.c +++ b/sound/soc/codecs/zx_aud96p22.c @@ -312,7 +312,7 @@ static int aud96p22_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; } -static struct snd_soc_dai_ops aud96p22_dai_ops = { +static const struct snd_soc_dai_ops aud96p22_dai_ops = { .set_fmt = aud96p22_set_fmt, }; -- cgit v1.1 From a1150d40b219af1344f7bcc9b365dc5ec7bfbb65 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 15 Aug 2017 17:10:12 +0200 Subject: ASoC: spear: constify snd_soc_dai_ops structures These snd_soc_dai_ops structures are only stored in the ops field of a snd_soc_dai_driver structure, which is const. Thus, the snd_soc_dai_ops structures can be const too. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/spear/spdif_in.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/spear/spdif_in.c b/sound/soc/spear/spdif_in.c index 01b28e5..78a6a36 100644 --- a/sound/soc/spear/spdif_in.c +++ b/sound/soc/spear/spdif_in.c @@ -151,7 +151,7 @@ static int spdif_in_trigger(struct snd_pcm_substream *substream, int cmd, return ret; } -static struct snd_soc_dai_ops spdif_in_dai_ops = { +static const struct snd_soc_dai_ops spdif_in_dai_ops = { .shutdown = spdif_in_shutdown, .trigger = spdif_in_trigger, .hw_params = spdif_in_hw_params, -- cgit v1.1 From 8937ea0f3c3a90da3c594a4e2b038d2c7b282eec Mon Sep 17 00:00:00 2001 From: Lori Hikichi Date: Mon, 14 Aug 2017 15:06:49 -0700 Subject: ASoC: cygnus: Add support for 384kHz frame rates Allow the audio ports to operate at 384kHz. Signed-off-by: Lori Hikichi Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-ssp.c | 235 +++++++++++---------------------------------- 1 file changed, 55 insertions(+), 180 deletions(-) (limited to 'sound') diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index e710bb0..1a57a4e 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -27,12 +27,6 @@ #define DEFAULT_VCO 1354750204 -#define CYGNUS_TDM_RATE \ - (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | \ - SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_22050 | \ - SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ - SNDRV_PCM_RATE_48000) - #define CAPTURE_FCI_ID_BASE 0x180 #define CYGNUS_SSP_TRISTATE_MASK 0x001fff #define CYGNUS_PLLCLKSEL_MASK 0xf @@ -234,152 +228,20 @@ static const struct pll_macro_entry pll_predef_mclk[] = { {98304000, 2}, }; +#define CYGNUS_RATE_MIN 8000 +#define CYGNUS_RATE_MAX 384000 + /* List of valid frame sizes for tdm mode */ static const int ssp_valid_tdm_framesize[] = {32, 64, 128, 256, 512}; -/* - * Use this relationship to derive the sampling rate (lrclk) - * lrclk = (mclk) / ((2*mclk_to_sclk_ratio) * (32 * SCLK))). - * - * Use mclk and pll_ch from the table above - * - * Valid SCLK = 0/1/2/4/8/12 - * - * mclk_to_sclk_ratio = number of MCLK per SCLK. Division is twice the - * value programmed in this field. - * Valid mclk_to_sclk_ratio = 1 through to 15 - * - * eg: To set lrclk = 48khz, set mclk = 12288000, mclk_to_sclk_ratio = 2, - * SCLK = 64 - */ -struct _ssp_clk_coeff { - u32 mclk; - u32 sclk_rate; - u32 rate; - u32 mclk_rate; +static const unsigned int cygnus_rates[] = { + 8000, 11025, 16000, 22050, 32000, 44100, 48000, + 88200, 96000, 176400, 192000, 352800, 384000 }; -static const struct _ssp_clk_coeff ssp_clk_coeff[] = { - { 4096000, 32, 16000, 4}, - { 4096000, 32, 32000, 2}, - { 4096000, 64, 8000, 4}, - { 4096000, 64, 16000, 2}, - { 4096000, 64, 32000, 1}, - { 4096000, 128, 8000, 2}, - { 4096000, 128, 16000, 1}, - { 4096000, 256, 8000, 1}, - - { 6144000, 32, 16000, 6}, - { 6144000, 32, 32000, 3}, - { 6144000, 32, 48000, 2}, - { 6144000, 32, 96000, 1}, - { 6144000, 64, 8000, 6}, - { 6144000, 64, 16000, 3}, - { 6144000, 64, 48000, 1}, - { 6144000, 128, 8000, 3}, - - { 8192000, 32, 32000, 4}, - { 8192000, 64, 16000, 4}, - { 8192000, 64, 32000, 2}, - { 8192000, 128, 8000, 4}, - { 8192000, 128, 16000, 2}, - { 8192000, 128, 32000, 1}, - { 8192000, 256, 8000, 2}, - { 8192000, 256, 16000, 1}, - { 8192000, 512, 8000, 1}, - - {12288000, 32, 32000, 6}, - {12288000, 32, 48000, 4}, - {12288000, 32, 96000, 2}, - {12288000, 32, 192000, 1}, - {12288000, 64, 16000, 6}, - {12288000, 64, 32000, 3}, - {12288000, 64, 48000, 2}, - {12288000, 64, 96000, 1}, - {12288000, 128, 8000, 6}, - {12288000, 128, 16000, 3}, - {12288000, 128, 48000, 1}, - {12288000, 256, 8000, 3}, - - {16384000, 64, 32000, 4}, - {16384000, 128, 16000, 4}, - {16384000, 128, 32000, 2}, - {16384000, 256, 8000, 4}, - {16384000, 256, 16000, 2}, - {16384000, 256, 32000, 1}, - {16384000, 512, 8000, 2}, - {16384000, 512, 16000, 1}, - - {24576000, 32, 96000, 4}, - {24576000, 32, 192000, 2}, - {24576000, 64, 32000, 6}, - {24576000, 64, 48000, 4}, - {24576000, 64, 96000, 2}, - {24576000, 64, 192000, 1}, - {24576000, 128, 16000, 6}, - {24576000, 128, 32000, 3}, - {24576000, 128, 48000, 2}, - {24576000, 256, 8000, 6}, - {24576000, 256, 16000, 3}, - {24576000, 256, 48000, 1}, - {24576000, 512, 8000, 3}, - - {49152000, 32, 192000, 4}, - {49152000, 64, 96000, 4}, - {49152000, 64, 192000, 2}, - {49152000, 128, 32000, 6}, - {49152000, 128, 48000, 4}, - {49152000, 128, 96000, 2}, - {49152000, 128, 192000, 1}, - {49152000, 256, 16000, 6}, - {49152000, 256, 32000, 3}, - {49152000, 256, 48000, 2}, - {49152000, 256, 96000, 1}, - {49152000, 512, 8000, 6}, - {49152000, 512, 16000, 3}, - {49152000, 512, 48000, 1}, - - { 5644800, 32, 22050, 4}, - { 5644800, 32, 44100, 2}, - { 5644800, 32, 88200, 1}, - { 5644800, 64, 11025, 4}, - { 5644800, 64, 22050, 2}, - { 5644800, 64, 44100, 1}, - - {11289600, 32, 44100, 4}, - {11289600, 32, 88200, 2}, - {11289600, 32, 176400, 1}, - {11289600, 64, 22050, 4}, - {11289600, 64, 44100, 2}, - {11289600, 64, 88200, 1}, - {11289600, 128, 11025, 4}, - {11289600, 128, 22050, 2}, - {11289600, 128, 44100, 1}, - - {22579200, 32, 88200, 4}, - {22579200, 32, 176400, 2}, - {22579200, 64, 44100, 4}, - {22579200, 64, 88200, 2}, - {22579200, 64, 176400, 1}, - {22579200, 128, 22050, 4}, - {22579200, 128, 44100, 2}, - {22579200, 128, 88200, 1}, - {22579200, 256, 11025, 4}, - {22579200, 256, 22050, 2}, - {22579200, 256, 44100, 1}, - - {45158400, 32, 176400, 4}, - {45158400, 64, 88200, 4}, - {45158400, 64, 176400, 2}, - {45158400, 128, 44100, 4}, - {45158400, 128, 88200, 2}, - {45158400, 128, 176400, 1}, - {45158400, 256, 22050, 4}, - {45158400, 256, 44100, 2}, - {45158400, 256, 88200, 1}, - {45158400, 512, 11025, 4}, - {45158400, 512, 22050, 2}, - {45158400, 512, 44100, 1}, +static const struct snd_pcm_hw_constraint_list cygnus_rate_constraint = { + .count = ARRAY_SIZE(cygnus_rates), + .list = cygnus_rates, }; static struct cygnus_aio_port *cygnus_dai_get_portinfo(struct snd_soc_dai *dai) @@ -679,40 +541,55 @@ static int pll_configure_mclk(struct cygnus_audio *cygaud, u32 mclk, return p_entry->pll_ch_num; } -static int cygnus_ssp_set_clocks(struct cygnus_aio_port *aio, - struct cygnus_audio *cygaud) +static int cygnus_ssp_set_clocks(struct cygnus_aio_port *aio) { - u32 value, i = 0; + u32 value; u32 mask = 0xf; u32 sclk; - bool found = false; - const struct _ssp_clk_coeff *p_entry = NULL; + u32 mclk_rate; + unsigned int bit_rate; + unsigned int ratio; - for (i = 0; i < ARRAY_SIZE(ssp_clk_coeff); i++) { - p_entry = &ssp_clk_coeff[i]; - if ((p_entry->rate == aio->lrclk) && - (p_entry->sclk_rate == aio->bit_per_frame) && - (p_entry->mclk == aio->mclk)) { - found = true; - break; - } - } - if (!found) { + bit_rate = aio->bit_per_frame * aio->lrclk; + + /* + * Check if the bit clock can be generated from the given MCLK. + * MCLK must be a perfect multiple of bit clock and must be one of the + * following values... (2,4,6,8,10,12,14) + */ + if ((aio->mclk % bit_rate) != 0) + return -EINVAL; + + ratio = aio->mclk / bit_rate; + switch (ratio) { + case 2: + case 4: + case 6: + case 8: + case 10: + case 12: + case 14: + mclk_rate = ratio / 2; + break; + + default: dev_err(aio->cygaud->dev, - "No valid match found in ssp_clk_coeff array\n"); + "Invalid combination of MCLK and BCLK\n"); dev_err(aio->cygaud->dev, "lrclk = %u, bits/frame = %u, mclk = %u\n", aio->lrclk, aio->bit_per_frame, aio->mclk); return -EINVAL; } - sclk = aio->bit_per_frame; - if (sclk == 512) - sclk = 0; - /* sclks_per_1fs_div = sclk cycles/32 */ - sclk /= 32; /* Set sclk rate */ switch (aio->port_type) { case PORT_TDM: + sclk = aio->bit_per_frame; + if (sclk == 512) + sclk = 0; + + /* sclks_per_1fs_div = sclk cycles/32 */ + sclk /= 32; + /* Set number of bitclks per frame */ value = readl(aio->cygaud->audio + aio->regs.i2s_cfg); value &= ~(mask << I2S_OUT_CFGX_SCLKS_PER_1FS_DIV32); @@ -731,7 +608,7 @@ static int cygnus_ssp_set_clocks(struct cygnus_aio_port *aio, /* Set MCLK_RATE ssp port (spdif and ssp are the same) */ value = readl(aio->cygaud->audio + aio->regs.i2s_mclk_cfg); value &= ~(0xf << I2S_OUT_MCLKRATE_SHIFT); - value |= (p_entry->mclk_rate << I2S_OUT_MCLKRATE_SHIFT); + value |= (mclk_rate << I2S_OUT_MCLKRATE_SHIFT); writel(value, aio->cygaud->audio + aio->regs.i2s_mclk_cfg); dev_dbg(aio->cygaud->dev, "mclk cfg reg = 0x%x\n", value); @@ -745,7 +622,6 @@ static int cygnus_ssp_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(dai); - struct cygnus_audio *cygaud = snd_soc_dai_get_drvdata(dai); int rate, bitres; u32 value; u32 mask = 0x1f; @@ -841,7 +717,7 @@ static int cygnus_ssp_hw_params(struct snd_pcm_substream *substream, aio->lrclk = rate; if (!aio->is_slave) - ret = cygnus_ssp_set_clocks(aio, cygaud); + ret = cygnus_ssp_set_clocks(aio); return ret; } @@ -888,6 +764,11 @@ static int cygnus_ssp_startup(struct snd_pcm_substream *substream, else aio->clk_trace.cap_en = true; + substream->runtime->hw.rate_min = CYGNUS_RATE_MIN; + substream->runtime->hw.rate_max = CYGNUS_RATE_MAX; + + snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &cygnus_rate_constraint); return 0; } @@ -1261,9 +1142,7 @@ static const struct snd_soc_dai_ops cygnus_ssp_dai_ops = { .playback = { \ .channels_min = 1, \ .channels_max = 16, \ - .rates = CYGNUS_TDM_RATE | SNDRV_PCM_RATE_88200 | \ - SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | \ - SNDRV_PCM_RATE_192000, \ + .rates = SNDRV_PCM_RATE_KNOT, \ .formats = SNDRV_PCM_FMTBIT_S8 | \ SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S32_LE, \ @@ -1271,9 +1150,7 @@ static const struct snd_soc_dai_ops cygnus_ssp_dai_ops = { .capture = { \ .channels_min = 2, \ .channels_max = 16, \ - .rates = CYGNUS_TDM_RATE | SNDRV_PCM_RATE_88200 | \ - SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | \ - SNDRV_PCM_RATE_192000, \ + .rates = SNDRV_PCM_RATE_KNOT, \ .formats = SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S32_LE, \ }, \ @@ -1293,9 +1170,7 @@ static struct snd_soc_dai_driver cygnus_spdif_dai_info = { .playback = { .channels_min = 2, .channels_max = 2, - .rates = CYGNUS_TDM_RATE | SNDRV_PCM_RATE_88200 | - SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | - SNDRV_PCM_RATE_192000, + .rates = SNDRV_PCM_RATE_KNOT, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, }, -- cgit v1.1 From 7b814a7d4e83b0917efef9dd11a8c095371f987c Mon Sep 17 00:00:00 2001 From: Anton Vasilyev Date: Tue, 15 Aug 2017 15:19:54 +0300 Subject: ASoC: samsung: i2s: Null pointer dereference on samsung_i2s_remove If (quirks & QUIRK_SEC_DAI == 0) then samsung_i2s_probe() doesn't allocate sec_dai and pri_dai->sec_dai remains Null, but samsung_i2s_remove() performs pri_dai->sec_dai dereference in any case. The patch removes useless reinitialization of sec_dai at samsung_i2s_remove(), because resources are under devm control. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index daf7b89..10a4da0 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1388,13 +1388,9 @@ err_disable_clk: static int samsung_i2s_remove(struct platform_device *pdev) { - struct i2s_dai *pri_dai, *sec_dai; + struct i2s_dai *pri_dai; pri_dai = dev_get_drvdata(&pdev->dev); - sec_dai = pri_dai->sec_dai; - - pri_dai->sec_dai = NULL; - sec_dai->pri_dai = NULL; pm_runtime_get_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); -- cgit v1.1 From d0148eb4a41e65ac95bfaaa13c75364b95b1e052 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 11 Aug 2017 17:12:19 +0300 Subject: ASoC: simple-scu-card: Parse off codec widgets Signed-off-by: Daniel Baluta Signed-off-by: Mark Brown --- sound/soc/generic/simple-scu-card.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c index a75b385..0bb3da7 100644 --- a/sound/soc/generic/simple-scu-card.c +++ b/sound/soc/generic/simple-scu-card.c @@ -191,6 +191,10 @@ static int asoc_simple_card_parse_of(struct simple_card_data *priv) if (!node) return -EINVAL; + ret = asoc_simple_card_of_parse_widgets(card, PREFIX); + if (ret < 0) + return ret; + ret = asoc_simple_card_of_parse_routing(card, PREFIX, 0); if (ret < 0) return ret; -- cgit v1.1 From 2d5f8487818b9231dfb244adda5e890e004b4a76 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Fri, 11 Aug 2017 21:26:49 +0530 Subject: ASoC: Intel: kbl: make snd_pcm_hw_constraint_list const Make these const as they are only passed to the function snd_pcm_hw_constraint_list having the corresponding argument as const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 12b34b9..8bdd613 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -286,7 +286,7 @@ static unsigned int rates[] = { 48000, }; -static struct snd_pcm_hw_constraint_list constraints_rates = { +static const struct snd_pcm_hw_constraint_list constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -296,7 +296,7 @@ static unsigned int channels[] = { 2, }; -static struct snd_pcm_hw_constraint_list constraints_channels = { +static const struct snd_pcm_hw_constraint_list constraints_channels = { .count = ARRAY_SIZE(channels), .list = channels, .mask = 0, @@ -425,7 +425,7 @@ static unsigned int rates_16000[] = { 16000, }; -static struct snd_pcm_hw_constraint_list constraints_16000 = { +static const struct snd_pcm_hw_constraint_list constraints_16000 = { .count = ARRAY_SIZE(rates_16000), .list = rates_16000, }; -- cgit v1.1 From 2788808a1bb4dd0b20c4cea2a98b9fda4c354682 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Fri, 11 Aug 2017 21:57:15 +0530 Subject: ASoC: Intel: Skylake: make skl_dsp_fw_ops const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/intel/skylake/bxt-sst.c | 2 +- sound/soc/intel/skylake/cnl-sst.c | 2 +- sound/soc/intel/skylake/skl-sst.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c index 71042ac..5e1ac99 100644 --- a/sound/soc/intel/skylake/bxt-sst.c +++ b/sound/soc/intel/skylake/bxt-sst.c @@ -530,7 +530,7 @@ static int bxt_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id) return 0; } -static struct skl_dsp_fw_ops bxt_fw_ops = { +static const struct skl_dsp_fw_ops bxt_fw_ops = { .set_state_D0 = bxt_set_dsp_D0, .set_state_D3 = bxt_set_dsp_D3, .set_state_D0i3 = bxt_schedule_dsp_D0i3, diff --git a/sound/soc/intel/skylake/cnl-sst.c b/sound/soc/intel/skylake/cnl-sst.c index 7dcfe66..48ef04d 100644 --- a/sound/soc/intel/skylake/cnl-sst.c +++ b/sound/soc/intel/skylake/cnl-sst.c @@ -277,7 +277,7 @@ static unsigned int cnl_get_errno(struct sst_dsp *ctx) return sst_dsp_shim_read(ctx, CNL_ADSP_ERROR_CODE); } -static struct skl_dsp_fw_ops cnl_fw_ops = { +static const struct skl_dsp_fw_ops cnl_fw_ops = { .set_state_D0 = cnl_set_dsp_D0, .set_state_D3 = cnl_set_dsp_D3, .load_fw = cnl_load_base_firmware, diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c index 6cc586d..a7ad734 100644 --- a/sound/soc/intel/skylake/skl-sst.c +++ b/sound/soc/intel/skylake/skl-sst.c @@ -503,7 +503,7 @@ static void skl_clear_module_table(struct sst_dsp *ctx) } } -static struct skl_dsp_fw_ops skl_fw_ops = { +static const struct skl_dsp_fw_ops skl_fw_ops = { .set_state_D0 = skl_set_dsp_D0, .set_state_D3 = skl_set_dsp_D3, .load_fw = skl_load_base_firmware, @@ -512,7 +512,7 @@ static struct skl_dsp_fw_ops skl_fw_ops = { .unload_mod = skl_unload_module, }; -static struct skl_dsp_fw_ops kbl_fw_ops = { +static const struct skl_dsp_fw_ops kbl_fw_ops = { .set_state_D0 = skl_set_dsp_D0, .set_state_D3 = skl_set_dsp_D3, .load_fw = skl_load_base_firmware, -- cgit v1.1 From 70bad123ea5bec47329bc8681cbb8e8431188ba2 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 12 Aug 2017 08:33:02 +0200 Subject: ASoC: Intel: constify snd_compr_codec_caps structures These snd_compr_codec_caps structures are only copied into other structures, so they can be const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst_drv_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c index ce689c5..71af544 100644 --- a/sound/soc/intel/atom/sst/sst_drv_interface.c +++ b/sound/soc/intel/atom/sst/sst_drv_interface.c @@ -407,7 +407,7 @@ static int sst_cdev_caps(struct snd_compr_caps *caps) return 0; } -static struct snd_compr_codec_caps caps_mp3 = { +static const struct snd_compr_codec_caps caps_mp3 = { .num_descriptors = 1, .descriptor[0].max_ch = 2, .descriptor[0].sample_rates[0] = 48000, @@ -424,7 +424,7 @@ static struct snd_compr_codec_caps caps_mp3 = { .descriptor[0].formats = 0, }; -static struct snd_compr_codec_caps caps_aac = { +static const struct snd_compr_codec_caps caps_aac = { .num_descriptors = 2, .descriptor[1].max_ch = 2, .descriptor[0].sample_rates[0] = 48000, -- cgit v1.1 From 92ec46da6e35f5f7ff39741517a9466c82d1afb9 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Fri, 11 Aug 2017 11:25:41 +0200 Subject: ASoC: Medfield: Delete an error message for a failed memory allocation in snd_mfld_mc_probe() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/mfld_machine.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/mfld_machine.c b/sound/soc/intel/boards/mfld_machine.c index 4e08885..6f44acf 100644 --- a/sound/soc/intel/boards/mfld_machine.c +++ b/sound/soc/intel/boards/mfld_machine.c @@ -376,10 +376,8 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) /* audio interrupt base of SRAM location where * interrupts are stored by System FW */ mc_drv_ctx = devm_kzalloc(&pdev->dev, sizeof(*mc_drv_ctx), GFP_ATOMIC); - if (!mc_drv_ctx) { - pr_err("allocation failed\n"); + if (!mc_drv_ctx) return -ENOMEM; - } irq_mem = platform_get_resource_byname( pdev, IORESOURCE_MEM, "IRQ_BASE"); -- cgit v1.1 From 4dbcc5ff2513f2192dc2a5dfdbb9ad3d7e891e85 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 16:09:01 +0530 Subject: ASoC: codecs: make snd_compr_ops const Make these const as they are only stored in the compr_ops field of a snd_soc_platform_driver structure, which is of type const. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l24.c | 2 +- sound/soc/codecs/wm5102.c | 2 +- sound/soc/codecs/wm5110.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index 47e6fdd..c1cbe23 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -1203,7 +1203,7 @@ static struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { }, }; -static struct snd_compr_ops cs47l24_compr_ops = { +static const struct snd_compr_ops cs47l24_compr_ops = { .open = cs47l24_open, .free = wm_adsp_compr_free, .set_params = wm_adsp_compr_set_params, diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 1fe358e..a8bdbe4 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -2017,7 +2017,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { }, }; -static struct snd_compr_ops wm5102_compr_ops = { +static const struct snd_compr_ops wm5102_compr_ops = { .open = wm5102_open, .free = wm_adsp_compr_free, .set_params = wm_adsp_compr_set_params, diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 1bc9421..8aa136c 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -2372,7 +2372,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { }, }; -static struct snd_compr_ops wm5110_compr_ops = { +static const struct snd_compr_ops wm5110_compr_ops = { .open = wm5110_open, .free = wm_adsp_compr_free, .set_params = wm_adsp_compr_set_params, -- cgit v1.1 From 2eccea8cdeb8fe455fc3a45b4e097f118449c3ef Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 7 Aug 2017 02:06:55 +0000 Subject: ASoC: soc-core: snd_soc_unregister_component() unregister all component Current snd_soc_unregister_component() unregisters first found component only which was specified by dev. This style can't specify concrete component if system registered some component with same dev. And system need to call this function many times. This patch unregister all related component by 1 call. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b1860b14..50c8dba 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3365,11 +3365,12 @@ err_free: EXPORT_SYMBOL_GPL(snd_soc_register_component); /** - * snd_soc_unregister_component - Unregister a component from the ASoC core + * snd_soc_unregister_component - Unregister all related component + * from the ASoC core * * @dev: The device to unregister */ -void snd_soc_unregister_component(struct device *dev) +static int __snd_soc_unregister_component(struct device *dev) { struct snd_soc_component *component; int found = 0; @@ -3391,6 +3392,13 @@ void snd_soc_unregister_component(struct device *dev) snd_soc_component_cleanup(component); kfree(component); } + + return found; +} + +void snd_soc_unregister_component(struct device *dev) +{ + while (__snd_soc_unregister_component(dev)); } EXPORT_SYMBOL_GPL(snd_soc_unregister_component); -- cgit v1.1 From bb1c928df78ee6e3665a0d013e74108cc9abf34b Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 14:14:09 +0530 Subject: ALSA: aoa: make snd_kcontrol_new const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/aoa/codecs/onyx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c index a04edff..d2d96ca 100644 --- a/sound/aoa/codecs/onyx.c +++ b/sound/aoa/codecs/onyx.c @@ -167,7 +167,7 @@ static int onyx_snd_vol_put(struct snd_kcontrol *kcontrol, return 1; } -static struct snd_kcontrol_new volume_control = { +static const struct snd_kcontrol_new volume_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Volume", .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, @@ -229,7 +229,7 @@ static int onyx_snd_inputgain_put(struct snd_kcontrol *kcontrol, return n != v; } -static struct snd_kcontrol_new inputgain_control = { +static const struct snd_kcontrol_new inputgain_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Capture Volume", .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, @@ -284,7 +284,7 @@ static int onyx_snd_capture_source_put(struct snd_kcontrol *kcontrol, return 1; } -static struct snd_kcontrol_new capture_source_control = { +static const struct snd_kcontrol_new capture_source_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, /* If we name this 'Input Source', it properly shows up in * alsamixer as a selection, * but it's shown under the @@ -348,7 +348,7 @@ static int onyx_snd_mute_put(struct snd_kcontrol *kcontrol, return !err ? (v != c) : err; } -static struct snd_kcontrol_new mute_control = { +static const struct snd_kcontrol_new mute_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, @@ -476,7 +476,7 @@ static int onyx_spdif_mask_get(struct snd_kcontrol *kcontrol, return 0; } -static struct snd_kcontrol_new onyx_spdif_mask = { +static const struct snd_kcontrol_new onyx_spdif_mask = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), @@ -533,7 +533,7 @@ static int onyx_spdif_put(struct snd_kcontrol *kcontrol, return 1; } -static struct snd_kcontrol_new onyx_spdif_ctrl = { +static const struct snd_kcontrol_new onyx_spdif_ctrl = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), -- cgit v1.1 From 7df3859bf71b9c36683846fa07d68ed89f769d72 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 14:14:10 +0530 Subject: ALSA: pcxhr: make snd_kcontrol_new const Make these const as they are only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr_mixer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c index 36875df..d9a1c6c 100644 --- a/sound/pci/pcxhr/pcxhr_mixer.c +++ b/sound/pci/pcxhr/pcxhr_mixer.c @@ -185,7 +185,7 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol, return changed; } -static struct snd_kcontrol_new pcxhr_control_analog_level = { +static const struct snd_kcontrol_new pcxhr_control_analog_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ), @@ -409,7 +409,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol, return changed; } -static struct snd_kcontrol_new snd_pcxhr_pcm_vol = +static const struct snd_kcontrol_new snd_pcxhr_pcm_vol = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | -- cgit v1.1 From fdbf0488040622b225e8019d96693236dceaf832 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 14:14:11 +0530 Subject: ALSA: hda: make snd_kcontrol_new const Make these const as they are only passed as the 3rd argument to the function snd_hda_gen_add_kctl, which is of type const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 4 ++-- sound/pci/hda/patch_sigmatel.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index e0fb8c6..7578573 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -505,7 +505,7 @@ static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol, return 1; } -static struct snd_kcontrol_new ad1983_auto_smux_mixer = { +static const struct snd_kcontrol_new ad1983_auto_smux_mixer = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "IEC958 Playback Source", .info = ad1983_auto_smux_enum_info, @@ -788,7 +788,7 @@ static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol, return 1; } -static struct snd_kcontrol_new ad1988_auto_smux_mixer = { +static const struct snd_kcontrol_new ad1988_auto_smux_mixer = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "IEC958 Playback Source", .info = ad1988_auto_smux_enum_info, diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 6cefdf6..63d15b5 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -961,7 +961,7 @@ static int stac_smux_enum_put(struct snd_kcontrol *kcontrol, &spec->cur_smux[smux_idx]); } -static struct snd_kcontrol_new stac_smux_mixer = { +static const struct snd_kcontrol_new stac_smux_mixer = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "IEC958 Playback Source", /* count set later */ -- cgit v1.1 From aeb6fa0f15c71a18f757d1686822b6c34cf81399 Mon Sep 17 00:00:00 2001 From: Peng Donglin Date: Wed, 16 Aug 2017 22:47:53 +0800 Subject: ASoC: compress: Set reasonable compress id string For dynamic compress rtd, the codec_dai may not have any actual meaning(like snd-soc-dummy-dai), so compress id can just use the value of dai_link->stream_name. But for others, its codec_dai has actual meaning, so compress id can include codec_dai name. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/soc-compress.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 6c867d5..2cb8d3b 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -737,9 +737,6 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) } /* check client and interface hw capabilities */ - snprintf(new_name, sizeof(new_name), "%s %s-%d", - rtd->dai_link->stream_name, codec_dai->name, num); - if (codec_dai->driver->playback.channels_min) playback = 1; if (codec_dai->driver->capture.channels_min) @@ -758,7 +755,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) return -EINVAL; } - if(playback) + if (playback) direction = SND_COMPRESS_PLAYBACK; else direction = SND_COMPRESS_CAPTURE; @@ -794,19 +791,18 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) else if (rtd->dai_link->dpcm_capture) be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd; memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops)); - } else + } else { + snprintf(new_name, sizeof(new_name), "%s %s-%d", + rtd->dai_link->stream_name, codec_dai->name, num); + memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); + } /* Add copy callback for not memory mapped DSPs */ if (platform->driver->compr_ops && platform->driver->compr_ops->copy) compr->ops->copy = soc_compr_copy; mutex_init(&compr->lock); - - snprintf(new_name, sizeof(new_name), "%s %s-%d", - rtd->dai_link->stream_name, - rtd->codec_dai->name, num); - ret = snd_compress_new(rtd->card->snd_card, num, direction, new_name, compr); if (ret < 0) { -- cgit v1.1 From 1491c68a2248747de0bfb83350c5096954b40dce Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:16 +0530 Subject: ALSA: drivers: mpu401: constify pnp_device_id pnp_device_id are not supposed to change at runtime. All functions working with pnp_device_id provided by work with const pnp_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index 9b86e00..b671576 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -148,7 +148,7 @@ static struct platform_driver snd_mpu401_driver = { #define IO_EXTENT 2 -static struct pnp_device_id snd_mpu401_pnpids[] = { +static const struct pnp_device_id snd_mpu401_pnpids[] = { { .id = "PNPb006" }, { .id = "" } }; -- cgit v1.1 From 05cb183e87931c722b9bc2e2e59243628efaab75 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:17 +0530 Subject: ALSA: es18xx: constify pnp_device_id and pnp_card_device_id *_device_id are not supposed to change at runtime. All functions working with *_device_id provided by work with const *_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 77023e4..ed66f9f 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -2017,7 +2017,7 @@ static int isa_registered; static int pnp_registered; static int pnpc_registered; -static struct pnp_device_id snd_audiodrive_pnpbiosids[] = { +static const struct pnp_device_id snd_audiodrive_pnpbiosids[] = { { .id = "ESS1869" }, { .id = "ESS1879" }, { .id = "" } /* end */ @@ -2062,7 +2062,7 @@ static int snd_audiodrive_pnp(int dev, struct snd_es18xx *chip, return 0; } -static struct pnp_card_device_id snd_audiodrive_pnpids[] = { +static const struct pnp_card_device_id snd_audiodrive_pnpids[] = { /* ESS 1868 (integrated on Compaq dual P-Pro motherboard and Genius 18PnP 3D) */ { .id = "ESS1868", .devs = { { "ESS1868" }, { "ESS0000" } } }, /* ESS 1868 (integrated on Maxisound Cards) */ -- cgit v1.1 From 607b5d7f7a03c98705ba08c8f3a328ea5f678076 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:18 +0530 Subject: ALSA: opl3sa2: constify pnp_device_id and pnp_card_device_id *_device_id are not supposed to change at runtime. All functions working with *_device_id provided by work with const *_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/opl3sa2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 4098e3e0..7cce4cd 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -141,7 +141,7 @@ struct snd_opl3sa2 { #ifdef CONFIG_PNP -static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = { +static const struct pnp_device_id snd_opl3sa2_pnpbiosids[] = { { .id = "YMH0021" }, { .id = "NMX2210" }, /* Gateway Solo 2500 */ { .id = "" } /* end */ @@ -149,7 +149,7 @@ static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = { MODULE_DEVICE_TABLE(pnp, snd_opl3sa2_pnpbiosids); -static struct pnp_card_device_id snd_opl3sa2_pnpids[] = { +static const struct pnp_card_device_id snd_opl3sa2_pnpids[] = { /* Yamaha YMF719E-S (Genius Sound Maker 3DX) */ { .id = "YMH0020", .devs = { { "YMH0021" } } }, /* Yamaha OPL3-SA3 (integrated on Intel's Pentium II AL440LX motherboard) */ -- cgit v1.1 From 287b546c7080ecef3513f3da87a27eabd50e8100 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:19 +0530 Subject: ALSA: ad1816a: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 7692265..4be6c12 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -63,7 +63,7 @@ MODULE_PARM_DESC(enable, "Enable ad1816a based soundcard."); module_param_array(clockfreq, int, NULL, 0444); MODULE_PARM_DESC(clockfreq, "Clock frequency for ad1816a driver (default = 0)."); -static struct pnp_card_device_id snd_ad1816a_pnpids[] = { +static const struct pnp_card_device_id snd_ad1816a_pnpids[] = { /* Analog Devices AD1815 */ { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } }, /* Analog Device AD1816? */ -- cgit v1.1 From 815cfec76aff754a8ab32d07c4c0fff400f7d0c7 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:20 +0530 Subject: ALSA: als100: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/als100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 6a2c5b4..f63142e 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -79,7 +79,7 @@ struct snd_card_als100 { struct snd_sb *chip; }; -static struct pnp_card_device_id snd_als100_pnpids[] = { +static const struct pnp_card_device_id snd_als100_pnpids[] = { /* DT197A30 */ { .id = "RWB1688", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } }, -- cgit v1.1 From 1d906e85483f7e04238c06a16c332cf8a3de004b Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:21 +0530 Subject: ALSA: azt2320: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/azt2320.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index fff186f..4e6fad4 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -79,7 +79,7 @@ struct snd_card_azt2320 { struct snd_wss *chip; }; -static struct pnp_card_device_id snd_azt2320_pnpids[] = { +static const struct pnp_card_device_id snd_azt2320_pnpids[] = { /* PRO16V */ { .id = "AZT1008", .devs = { { "AZT1008" }, { "AZT2001" }, } }, /* Aztech Sound Galaxy 16 */ -- cgit v1.1 From 06891ec6e0b6e2214a6eccfaa8be33ef5bd2b393 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:22 +0530 Subject: ALSA: cmi8330: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/cmi8330.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index f64b29a..6b8c469 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -182,7 +182,7 @@ struct snd_cmi8330 { #ifdef CONFIG_PNP -static struct pnp_card_device_id snd_cmi8330_pnpids[] = { +static const struct pnp_card_device_id snd_cmi8330_pnpids[] = { { .id = "CMI0001", .devs = { { "@X@0001" }, { "@@@0001" }, { "@H@0001" }, { "A@@0001" } } }, { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, { .id = "" } -- cgit v1.1 From 3f41b75cb1e77aa2f381115ed9fad4c5c79e6d05 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:23 +0530 Subject: ALSA: cs4236: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4236.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 4c09756..70559e5 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -149,7 +149,7 @@ static const struct pnp_device_id snd_cs423x_pnpbiosids[] = { MODULE_DEVICE_TABLE(pnp, snd_cs423x_pnpbiosids); #define CS423X_ISAPNP_DRIVER "cs4232_isapnp" -static struct pnp_card_device_id snd_cs423x_pnpids[] = { +static const struct pnp_card_device_id snd_cs423x_pnpids[] = { /* Philips PCA70PS */ { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, /* TerraTec Maestro 32/96 (CS4232) */ -- cgit v1.1 From 4f624a1cb755de31e532883681554271afc92f7f Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:24 +0530 Subject: ALSA: es1688: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 36320e7..a826c13 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -321,7 +321,7 @@ static int snd_es968_pnp_resume(struct pnp_card_link *pcard) } #endif -static struct pnp_card_device_id snd_es968_pnpids[] = { +static const struct pnp_card_device_id snd_es968_pnpids[] = { { .id = "ESS0968", .devs = { { "@@@0968" }, } }, { .id = "ESS0968", .devs = { { "ESS0968" }, } }, { .id = "", } /* end */ -- cgit v1.1 From 45fbe60734dab264b1ac33e7eeacff681e7d2eb4 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:25 +0530 Subject: ALSA: gus: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/gus/interwave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 0687b7e..a6fc26b 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -136,7 +136,7 @@ struct snd_interwave { static int isa_registered; static int pnp_registered; -static struct pnp_card_device_id snd_interwave_pnpids[] = { +static const struct pnp_card_device_id snd_interwave_pnpids[] = { #ifndef SNDRV_STB /* Gravis UltraSound Plug & Play */ { .id = "GRV0001", .devs = { { .id = "GRV0000" } } }, -- cgit v1.1 From 1ef428bf9bb2d2580630c4ea1f74af8f79de8398 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:26 +0530 Subject: ALSA: msnd: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/msnd/msnd_pinnacle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index fc4fb19..45e561c 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -1192,7 +1192,7 @@ static void snd_msnd_pnp_remove(struct pnp_card_link *pcard) static int isa_registered; static int pnp_registered; -static struct pnp_card_device_id msnd_pnpids[] = { +static const struct pnp_card_device_id msnd_pnpids[] = { /* Pinnacle PnP */ { .id = "BVJ0440", .devs = { { "TBS0000" }, { "TBS0001" } } }, { .id = "" } /* end */ -- cgit v1.1 From 529d25761173cba9e5cd8e1629c6477a141fce6d Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:27 +0530 Subject: ALSA: opti9xx: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/miro.c | 2 +- sound/isa/opti9xx/opti92x-ad1848.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 1c5a12f..8894c7c 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -143,7 +143,7 @@ static int snd_miro_pnp_is_probed; #ifdef CONFIG_PNP -static struct pnp_card_device_id snd_miro_pnpids[] = { +static const struct pnp_card_device_id snd_miro_pnpids[] = { /* PCM20 and PCM12 in PnP mode */ { .id = "MIR0924", .devs = { { "MIR0000" }, { "MIR0002" }, { "MIR0005" } }, }, diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 56dc581..505cd81 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -151,7 +151,7 @@ static int snd_opti9xx_pnp_is_probed; #ifdef CONFIG_PNP -static struct pnp_card_device_id snd_opti9xx_pnpids[] = { +static const struct pnp_card_device_id snd_opti9xx_pnpids[] = { #ifndef OPTi93X /* OPTi 82C924 */ { .id = "OPT0924", -- cgit v1.1 From e6a76e2fdabf703e41a82fdb39a960f506a4c467 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:28 +0530 Subject: ALSA: sb16: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/sb/sb16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 917a93d..8f9ebeb 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -145,7 +145,7 @@ struct snd_card_sb16 { #ifdef CONFIG_PNP -static struct pnp_card_device_id snd_sb16_pnpids[] = { +static const struct pnp_card_device_id snd_sb16_pnpids[] = { #ifndef SNDRV_SBAWE /* Sound Blaster 16 PnP */ { .id = "CTL0024", .devs = { { "CTL0031" } } }, -- cgit v1.1 From 05e20b265c9068d2f5871e3fcddc366d5f6feecb Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:29 +0530 Subject: ALSA: sscape: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/sscape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 1cd2908..733adee 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -88,7 +88,7 @@ MODULE_PARM_DESC(joystick, "Enable gameport."); static int isa_registered; static int pnp_registered; -static struct pnp_card_device_id sscape_pnpids[] = { +static const struct pnp_card_device_id sscape_pnpids[] = { { .id = "ENS3081", .devs = { { "ENS0000" } } }, /* Soundscape PnP */ { .id = "ENS4081", .devs = { { "ENS1011" } } }, /* VIVO90 */ { .id = "" } /* end */ -- cgit v1.1 From 60f6f0d3f79ea932c0d05d1d9137ef98c3dae9a9 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 17 Aug 2017 15:36:30 +0530 Subject: ALSA: wavefront: constify pnp_card_device_id pnp_card_device_id are not supposed to change at runtime. All functions working with pnp_card_device_id provided by work with const pnp_card_device_id. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/isa/wavefront/wavefront.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index da4e9a8..b1989fa 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -88,7 +88,7 @@ MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly lo static int isa_registered; static int pnp_registered; -static struct pnp_card_device_id snd_wavefront_pnpids[] = { +static const struct pnp_card_device_id snd_wavefront_pnpids[] = { /* Tropez */ { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } }, /* Tropez+ */ -- cgit v1.1 From db566fb981a98a052a830de6244e41577fb4e94f Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:49 +0530 Subject: ALSA: arm: make snd_pcm_hardware const Make this const as it is only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 4140b1b..74cf452 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -348,7 +348,7 @@ static irqreturn_t aaci_irq(int irq, void *devid) /* * ALSA support. */ -static struct snd_pcm_hardware aaci_hw_info = { +static const struct snd_pcm_hardware aaci_hw_info = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | -- cgit v1.1 From 85ab373843a642a4b4e9228095e6233521e55494 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:50 +0530 Subject: ALSA: atmel: make snd_pcm_hardware const Make this const as it is only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 9d2c9d9..f85131b 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -66,7 +66,7 @@ struct atmel_ac97c { #define ac97c_readl(chip, reg) \ __raw_readl((chip)->regs + AC97C_##reg) -static struct snd_pcm_hardware atmel_ac97c_hw = { +static const struct snd_pcm_hardware atmel_ac97c_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED -- cgit v1.1 From b6c0b7156167b8a0f82576adaaa9d7287296bbfc Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:51 +0530 Subject: ALSA: drivers: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/drivers/aloop.c | 2 +- sound/drivers/dummy.c | 2 +- sound/drivers/ml403-ac97cr.c | 4 ++-- sound/drivers/pcsp/pcsp_lib.c | 2 +- sound/drivers/vx/vx_pcm.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 54f348a..6e02ee0 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -561,7 +561,7 @@ static snd_pcm_uframes_t loopback_pointer(struct snd_pcm_substream *substream) return bytes_to_frames(runtime, pos); } -static struct snd_pcm_hardware loopback_pcm_hardware = +static const struct snd_pcm_hardware loopback_pcm_hardware = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE | diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index dd5ed03..c0939a0 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -520,7 +520,7 @@ static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream) return get_dummy_ops(substream)->pointer(substream); } -static struct snd_pcm_hardware dummy_pcm_hardware = { +static const struct snd_pcm_hardware dummy_pcm_hardware = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index bdcb572..d634e10 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -373,7 +373,7 @@ struct snd_ml403_ac97cr { struct snd_pcm_indirect2 capture_ind2_rec; }; -static struct snd_pcm_hardware snd_ml403_ac97cr_playback = { +static const struct snd_pcm_hardware snd_ml403_ac97cr_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -392,7 +392,7 @@ static struct snd_pcm_hardware snd_ml403_ac97cr_playback = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_ml403_ac97cr_capture = { +static const struct snd_pcm_hardware snd_ml403_ac97cr_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c index 44b3632..2f5a35f 100644 --- a/sound/drivers/pcsp/pcsp_lib.c +++ b/sound/drivers/pcsp/pcsp_lib.c @@ -285,7 +285,7 @@ static snd_pcm_uframes_t snd_pcsp_playback_pointer(struct snd_pcm_substream return bytes_to_frames(substream->runtime, pos); } -static struct snd_pcm_hardware snd_pcsp_playback = { +static const struct snd_pcm_hardware snd_pcsp_playback = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_HALF_DUPLEX | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index d318a33..380a028 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -500,7 +500,7 @@ static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe) * playback hw information */ -static struct snd_pcm_hardware vx_pcm_playback_hw = { +static const struct snd_pcm_hardware vx_pcm_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP_VALID /*|*/ /*SNDRV_PCM_INFO_RESUME*/), @@ -891,7 +891,7 @@ static const struct snd_pcm_ops vx_pcm_playback_ops = { * playback hw information */ -static struct snd_pcm_hardware vx_pcm_capture_hw = { +static const struct snd_pcm_hardware vx_pcm_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP_VALID /*|*/ /*SNDRV_PCM_INFO_RESUME*/), -- cgit v1.1 From aec5465485144e7b68da765f18d46bde4576c009 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:52 +0530 Subject: ALSA: isa: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a_lib.c | 4 ++-- sound/isa/es1688/es1688_lib.c | 4 ++-- sound/isa/es18xx.c | 4 ++-- sound/isa/gus/gus_pcm.c | 4 ++-- sound/isa/msnd/msnd.c | 4 ++-- sound/isa/sb/emu8000_pcm.c | 2 +- sound/isa/sb/sb16_main.c | 4 ++-- sound/isa/sb/sb8_main.c | 4 ++-- sound/isa/wss/wss_lib.c | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 5c6df15..9232014 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -339,7 +339,7 @@ static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id) } -static struct snd_pcm_hardware snd_ad1816a_playback = { +static const struct snd_pcm_hardware snd_ad1816a_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | @@ -358,7 +358,7 @@ static struct snd_pcm_hardware snd_ad1816a_playback = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_ad1816a_capture = { +static const struct snd_pcm_hardware snd_ad1816a_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index ec7e68b..f9c0662 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -526,7 +526,7 @@ static snd_pcm_uframes_t snd_es1688_capture_pointer(struct snd_pcm_substream *su */ -static struct snd_pcm_hardware snd_es1688_playback = +static const struct snd_pcm_hardware snd_es1688_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -544,7 +544,7 @@ static struct snd_pcm_hardware snd_es1688_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_es1688_capture = +static const struct snd_pcm_hardware snd_es1688_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index ed66f9f..2a6960c 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -838,7 +838,7 @@ static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *su return pos >> chip->dma1_shift; } -static struct snd_pcm_hardware snd_es18xx_playback = +static const struct snd_pcm_hardware snd_es18xx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | @@ -858,7 +858,7 @@ static struct snd_pcm_hardware snd_es18xx_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_es18xx_capture = +static const struct snd_pcm_hardware snd_es18xx_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 36e852f..131b289 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -650,7 +650,7 @@ static void snd_gf1_pcm_interrupt_dma_read(struct snd_gus_card * gus) } } -static struct snd_pcm_hardware snd_gf1_pcm_playback = +static const struct snd_pcm_hardware snd_gf1_pcm_playback = { .info = SNDRV_PCM_INFO_NONINTERLEAVED, .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | @@ -668,7 +668,7 @@ static struct snd_pcm_hardware snd_gf1_pcm_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_gf1_pcm_capture = +static const struct snd_pcm_hardware snd_gf1_pcm_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/isa/msnd/msnd.c b/sound/isa/msnd/msnd.c index ae9562c..569897f 100644 --- a/sound/isa/msnd/msnd.c +++ b/sound/isa/msnd/msnd.c @@ -437,7 +437,7 @@ static void snd_msnd_capture_reset_queue(struct snd_msnd *chip, } } -static struct snd_pcm_hardware snd_msnd_playback = { +static const struct snd_pcm_hardware snd_msnd_playback = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -456,7 +456,7 @@ static struct snd_pcm_hardware snd_msnd_playback = { .fifo_size = 0, }; -static struct snd_pcm_hardware snd_msnd_capture = { +static const struct snd_pcm_hardware snd_msnd_capture = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 9409827..8f34551 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -157,7 +157,7 @@ static int calc_rate_offset(int hz) /* */ -static struct snd_pcm_hardware emu8k_pcm_hw = { +static const struct snd_pcm_hardware emu8k_pcm_hw = { #ifdef USE_NONINTERLEAVE .info = SNDRV_PCM_INFO_NONINTERLEAVED, #else diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 6fc6325..3e39ba2 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -473,7 +473,7 @@ static snd_pcm_uframes_t snd_sb16_capture_pointer(struct snd_pcm_substream *subs */ -static struct snd_pcm_hardware snd_sb16_playback = +static const struct snd_pcm_hardware snd_sb16_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -491,7 +491,7 @@ static struct snd_pcm_hardware snd_sb16_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_sb16_capture = +static const struct snd_pcm_hardware snd_sb16_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index f5d8f2d..d45df5c 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -447,7 +447,7 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *subst */ -static struct snd_pcm_hardware snd_sb8_playback = +static const struct snd_pcm_hardware snd_sb8_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -466,7 +466,7 @@ static struct snd_pcm_hardware snd_sb8_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_sb8_capture = +static const struct snd_pcm_hardware snd_sb8_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 29adb01..8a85204 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -1452,7 +1452,7 @@ static int snd_wss_probe(struct snd_wss *chip) */ -static struct snd_pcm_hardware snd_wss_playback = +static const struct snd_pcm_hardware snd_wss_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -1472,7 +1472,7 @@ static struct snd_pcm_hardware snd_wss_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_wss_capture = +static const struct snd_pcm_hardware snd_wss_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From 3068116f532639cc0420b30ac574af470c051e85 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:53 +0530 Subject: ALSA: mips: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/mips/hal2.c | 2 +- sound/mips/sgio2audio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index 3318c15..367d6c37 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -496,7 +496,7 @@ static void hal2_free_dmabuf(struct hal2_codec *codec) DMA_ATTR_NON_CONSISTENT); } -static struct snd_pcm_hardware hal2_pcm_hw = { +static const struct snd_pcm_hardware hal2_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 0ebc1c3..603892f 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -532,7 +532,7 @@ static irqreturn_t snd_sgio2audio_error_isr(int irq, void *dev_id) /* PCM part */ /* PCM hardware definition */ -static struct snd_pcm_hardware snd_sgio2audio_pcm_hw = { +static const struct snd_pcm_hardware snd_sgio2audio_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | -- cgit v1.1 From aa38e71d050c4a0006b55cd1b5199f7b8c6f5deb Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:54 +0530 Subject: ALSA: pci: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0_pcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 848eb3c..53714e0 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -30,7 +30,7 @@ #define VORTEX_PCM_TYPE(x) (x->name[40]) /* hardware definition */ -static struct snd_pcm_hardware snd_vortex_playback_hw_adb = { +static const struct snd_pcm_hardware snd_vortex_playback_hw_adb = { .info = (SNDRV_PCM_INFO_MMAP | /* SNDRV_PCM_INFO_RESUME | */ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_INTERLEAVED | @@ -51,7 +51,7 @@ static struct snd_pcm_hardware snd_vortex_playback_hw_adb = { }; #ifndef CHIP_AU8820 -static struct snd_pcm_hardware snd_vortex_playback_hw_a3d = { +static const struct snd_pcm_hardware snd_vortex_playback_hw_a3d = { .info = (SNDRV_PCM_INFO_MMAP | /* SNDRV_PCM_INFO_RESUME | */ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_INTERLEAVED | @@ -71,7 +71,7 @@ static struct snd_pcm_hardware snd_vortex_playback_hw_a3d = { .periods_max = 64, }; #endif -static struct snd_pcm_hardware snd_vortex_playback_hw_spdif = { +static const struct snd_pcm_hardware snd_vortex_playback_hw_spdif = { .info = (SNDRV_PCM_INFO_MMAP | /* SNDRV_PCM_INFO_RESUME | */ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_INTERLEAVED | @@ -94,7 +94,7 @@ static struct snd_pcm_hardware snd_vortex_playback_hw_spdif = { }; #ifndef CHIP_AU8810 -static struct snd_pcm_hardware snd_vortex_playback_hw_wt = { +static const struct snd_pcm_hardware snd_vortex_playback_hw_wt = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), -- cgit v1.1 From d9b1b34fed50caf9a4d93af2490941f252669dcd Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:55 +0530 Subject: ALSA: pcmcia: make snd_pcm_hardware const Make this const as it is only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index b48aa0a..d788409 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -193,7 +193,7 @@ static int pdacf_pcm_prepare(struct snd_pcm_substream *subs) * capture hw information */ -static struct snd_pcm_hardware pdacf_pcm_capture_hw = { +static const struct snd_pcm_hardware pdacf_pcm_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From 21bf6cf5565c15ea76c13ce88441212f3a1f99ef Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:56 +0530 Subject: ALSA: ppc: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index a5843fc..45f0295 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -509,7 +509,7 @@ static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) * hw info */ -static struct snd_pcm_hardware snd_pmac_playback = +static const struct snd_pcm_hardware snd_pmac_playback = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | @@ -528,7 +528,7 @@ static struct snd_pcm_hardware snd_pmac_playback = .periods_max = PMAC_MAX_FRAGS, }; -static struct snd_pcm_hardware snd_pmac_capture = +static const struct snd_pcm_hardware snd_pmac_capture = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | -- cgit v1.1 From cd196fe2d6e0921ebc521fca5d51be144e8ea241 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:57 +0530 Subject: ALSA: sh: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/sh/aica.c | 2 +- sound/sh/sh_dac_audio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/sh/aica.c b/sound/sh/aica.c index ab4802d..822608d 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -211,7 +211,7 @@ static void aica_chn_halt(void) } /* ALSA code below */ -static struct snd_pcm_hardware snd_pcm_aica_playback_hw = { +static const struct snd_pcm_hardware snd_pcm_aica_playback_hw = { .info = (SNDRV_PCM_INFO_NONINTERLEAVED), .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index c1e00ed..a077f1c 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -93,7 +93,7 @@ static void dac_audio_set_rate(struct snd_sh_dac *chip) /* PCM INTERFACE */ -static struct snd_pcm_hardware snd_sh_dac_pcm_hw = { +static const struct snd_pcm_hardware snd_sh_dac_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | -- cgit v1.1 From 688ed206e16e13973cfb9e4d10c6a75768ebfd48 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:58 +0530 Subject: ALSA: sparc: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 2 +- sound/sparc/cs4231.c | 4 ++-- sound/sparc/dbri.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 35c1f6a..a6864fd 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -666,7 +666,7 @@ static snd_pcm_uframes_t snd_amd7930_capture_pointer(struct snd_pcm_substream *s } /* Playback and capture have identical properties. */ -static struct snd_pcm_hardware snd_amd7930_pcm_hw = +static const struct snd_pcm_hardware snd_amd7930_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 3d7d425..f5192b3 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1089,7 +1089,7 @@ static int snd_cs4231_probe(struct snd_cs4231 *chip) return 0; /* all things are ok.. */ } -static struct snd_pcm_hardware snd_cs4231_playback = { +static const struct snd_pcm_hardware snd_cs4231_playback = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -1113,7 +1113,7 @@ static struct snd_pcm_hardware snd_cs4231_playback = { .periods_max = 1024, }; -static struct snd_pcm_hardware snd_cs4231_capture = { +static const struct snd_pcm_hardware snd_cs4231_capture = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 52063b2..72b6c4a 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -1980,7 +1980,7 @@ static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id) /**************************************************************************** PCM Interface ****************************************************************************/ -static struct snd_pcm_hardware snd_dbri_pcm_hw = { +static const struct snd_pcm_hardware snd_dbri_pcm_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From aaffbf7824dde48dc9f72ffa1beb8a1dcb767fe1 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:45:59 +0530 Subject: ALSA: usb: make snd_pcm_hardware const Make this const as it is only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/usb/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 9aa5b18..a4f3390 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -857,7 +857,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) return ret; } -static struct snd_pcm_hardware snd_usb_hardware = +static const struct snd_pcm_hardware snd_usb_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From a977d0452fc8c4d6539dafeccac900761776a0aa Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 14:46:00 +0530 Subject: ALSA: parisc: make snd_pcm_hardware const Make these const as they are only used in a copy operation. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 5911eb3..cb2bc54 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -260,7 +260,7 @@ snd_harmony_rate_bits(int rate) return HARMONY_SR_44KHZ; } -static struct snd_pcm_hardware snd_harmony_playback = +static const struct snd_pcm_hardware snd_harmony_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | @@ -281,7 +281,7 @@ static struct snd_pcm_hardware snd_harmony_playback = .fifo_size = 0, }; -static struct snd_pcm_hardware snd_harmony_capture = +static const struct snd_pcm_hardware snd_harmony_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From 393a829bb2f7e12403cb7ff3b62539c27a543a2c Mon Sep 17 00:00:00 2001 From: Harsha Priya N Date: Wed, 16 Aug 2017 15:37:11 -0700 Subject: ASoC: Intel: kbl_rt5663_rt5514_max98927: Add rt5514 spi dailink This patch adds a dai to rt5514-spi driver for wake on voice functionality. Signed-off-by: Hsin-yu Chao Signed-off-by: Harsha Priya Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/Kconfig | 3 ++- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index b301bff..b3c7f55 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig @@ -255,11 +255,12 @@ config SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH tristate "ASoC Audio driver for KBL with RT5663, RT5514 and MAX98927 in I2S Mode" - depends on X86_INTEL_LPSS && I2C + depends on X86_INTEL_LPSS && I2C && SPI select SND_SOC_INTEL_SST select SND_SOC_INTEL_SKYLAKE select SND_SOC_RT5663 select SND_SOC_RT5514 + select SND_SOC_RT5514_SPI select SND_SOC_MAX98927 select SND_SOC_HDAC_HDMI help diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 5ec9428..b51dff6 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -65,6 +65,7 @@ enum { KBL_DPCM_AUDIO_HS_PB, KBL_DPCM_AUDIO_ECHO_REF_CP, KBL_DPCM_AUDIO_DMIC_CP, + KBL_DPCM_AUDIO_RT5514_DSP, KBL_DPCM_AUDIO_HDMI1_PB, KBL_DPCM_AUDIO_HDMI2_PB, }; @@ -480,6 +481,14 @@ static struct snd_soc_dai_link kabylake_dais[] = { .capture_only = 1, .nonatomic = 1, }, + [KBL_DPCM_AUDIO_RT5514_DSP] = { + .name = "rt5514 dsp", + .stream_name = "Wake on Voice", + .cpu_dai_name = "spi-PRP0001:00", + .platform_name = "spi-PRP0001:00", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + }, [KBL_DPCM_AUDIO_DMIC_CP] = { .name = "Kbl Audio DMIC cap", .stream_name = "dmiccap", -- cgit v1.1 From f77bb3b778e85d3477a9e3e0236545663f16793e Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 15:46:07 +0530 Subject: ASoC: fsl: make snd_pcm_hardware const Make these const as they are only passed as the 2nd argument to the function snd_soc_set_runtime_hwparams, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc_dma.c | 2 +- sound/soc/fsl/imx-pcm-fiq.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index 2baf196..e1b97e5 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -20,7 +20,7 @@ #define FSL_ASRC_DMABUF_SIZE (256 * 1024) -static struct snd_pcm_hardware snd_imx_hardware = { +static const struct snd_pcm_hardware snd_imx_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP | diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index aef1f78..4e5fefe 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -154,7 +154,7 @@ static snd_pcm_uframes_t snd_imx_pcm_pointer(struct snd_pcm_substream *substream return bytes_to_frames(substream->runtime, iprtd->offset); } -static struct snd_pcm_hardware snd_imx_hardware = { +static const struct snd_pcm_hardware snd_imx_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP | -- cgit v1.1 From 636d7e289c0a59dd3febfe6a2e7e5bd56eaa91b8 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 15:46:10 +0530 Subject: ASoC: kirkwood: make snd_pcm_hardware const Make this const as it is either passed as the 2nd argument to the function snd_soc_set_runtime_hwparams, which is const or used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index dafd22e..cf23af1 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -27,7 +27,7 @@ static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs) return snd_soc_dai_get_drvdata(soc_runtime->cpu_dai); } -static struct snd_pcm_hardware kirkwood_dma_snd_hw = { +static const struct snd_pcm_hardware kirkwood_dma_snd_hw = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | -- cgit v1.1 From 5c2e035e69ffff4c8b3f0a2ddfefa102ad9d9d42 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 15:46:11 +0530 Subject: ASoC: sh: make snd_pcm_hardware const Make these const as they are only passed as the 2nd argument to the function snd_soc_set_runtime_hwparams, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 2 +- sound/soc/sh/fsi.c | 2 +- sound/soc/sh/rcar/core.c | 2 +- sound/soc/sh/siu_dai.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 35788a6..1e7d417 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -89,7 +89,7 @@ struct camelot_pcm { #define DMABRG_PREALLOC_BUFFER 32 * 1024 #define DMABRG_PREALLOC_BUFFER_MAX 32 * 1024 -static struct snd_pcm_hardware camelot_pcm_hardware = { +static const struct snd_pcm_hardware camelot_pcm_hardware = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 5d7d9fe..39ec772 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1710,7 +1710,7 @@ static const struct snd_soc_dai_ops fsi_dai_ops = { * pcm ops */ -static struct snd_pcm_hardware fsi_pcm_hardware = { +static const struct snd_pcm_hardware fsi_pcm_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID, diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index df39831..1071332 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -843,7 +843,7 @@ static int rsnd_soc_hw_rule_channels(struct snd_pcm_hw_params *params, ir, &ic); } -static struct snd_pcm_hardware rsnd_pcm_hardware = { +static const struct snd_pcm_hardware rsnd_pcm_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID, diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index 4a22aad..1605029 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c @@ -333,7 +333,7 @@ static void siu_dai_spbstop(struct siu_port *port_info) /* API functions */ /* Playback and capture hardware properties are identical */ -static struct snd_pcm_hardware siu_dai_pcm_hw = { +static const struct snd_pcm_hardware siu_dai_pcm_hw = { .info = SNDRV_PCM_INFO_INTERLEAVED, .formats = SNDRV_PCM_FMTBIT_S16, .rates = SNDRV_PCM_RATE_8000_48000, -- cgit v1.1 From 193e25e1fe822f30a02aa9bf99880345eb242d35 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 15:46:12 +0530 Subject: ASoC: qcom: make snd_pcm_hardware const Make this const as it is either passed as the 2nd argument to the function snd_soc_set_runtime_hwparams, which is const or used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index fb3576a..e1945e1 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -32,7 +32,7 @@ struct lpass_pcm_data { #define LPASS_PLATFORM_BUFFER_SIZE (16 * 1024) #define LPASS_PLATFORM_PERIODS 2 -static struct snd_pcm_hardware lpass_platform_pcm_hardware = { +static const struct snd_pcm_hardware lpass_platform_pcm_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | -- cgit v1.1 From a7468e478a95db31c0f64e8497fadd9df5c49789 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 15:46:08 +0530 Subject: ASoC: Intel: Atom: make snd_pcm_hardware const Make this const as it is only used in a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index b272df5..43e7fdd 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -76,7 +76,7 @@ int sst_unregister_dsp(struct sst_device *dev) } EXPORT_SYMBOL_GPL(sst_unregister_dsp); -static struct snd_pcm_hardware sst_platform_pcm_hw = { +static const struct snd_pcm_hardware sst_platform_pcm_hw = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_DOUBLE | SNDRV_PCM_INFO_PAUSE | -- cgit v1.1 From 8df397ff0e281d5324d4b7a7e9fa56c4188e0a66 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 17 Aug 2017 15:46:09 +0530 Subject: ASoC: Intel: Skylake: make snd_pcm_hardware const Make this const as it is only passed as the 2nd argument to the function snd_soc_set_runtime_hwparams, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e98d825..f6c9adb 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -33,7 +33,7 @@ #define HDA_STEREO 2 #define HDA_QUAD 4 -static struct snd_pcm_hardware azx_pcm_hw = { +static const struct snd_pcm_hardware azx_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | -- cgit v1.1 From 23c7159a799f3364720b3d250f57bc8e26b17287 Mon Sep 17 00:00:00 2001 From: huang lin Date: Thu, 17 Aug 2017 10:24:44 +0800 Subject: ASoC: codec: use enable pin to control dmic start and stop on some board use enable pin to control dmic start and stop, so add this feature in dmic driver. Signed-off-by: Lin Huang Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 2 +- sound/soc/codecs/dmic.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 6c78b0b..952c44d 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -71,7 +71,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_DA732X if I2C select SND_SOC_DA9055 if I2C select SND_SOC_DIO2125 - select SND_SOC_DMIC + select SND_SOC_DMIC if GPIOLIB select SND_SOC_ES8316 if I2C select SND_SOC_ES8328_SPI if SPI_MASTER select SND_SOC_ES8328_I2C if I2C diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index d50f142..b88a1ee 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -19,6 +19,8 @@ * */ +#include +#include #include #include #include @@ -27,6 +29,34 @@ #include #include +static int dmic_daiops_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + struct gpio_desc *dmic_en = snd_soc_dai_get_drvdata(dai); + + if (!dmic_en) + return 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + gpiod_set_value(dmic_en, 1); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + gpiod_set_value(dmic_en, 0); + break; + } + + return 0; +} + +static const struct snd_soc_dai_ops dmic_dai_ops = { + .trigger = dmic_daiops_trigger, +}; + static struct snd_soc_dai_driver dmic_dai = { .name = "dmic-hifi", .capture = { @@ -38,8 +68,23 @@ static struct snd_soc_dai_driver dmic_dai = { | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE, }, + .ops = &dmic_dai_ops, }; +static int dmic_codec_probe(struct snd_soc_codec *codec) +{ + struct gpio_desc *dmic_en; + + dmic_en = devm_gpiod_get_optional(codec->dev, + "dmicen", GPIOD_OUT_LOW); + if (IS_ERR(dmic_en)) + return PTR_ERR(dmic_en); + + snd_soc_codec_set_drvdata(codec, dmic_en); + + return 0; +} + static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0, SND_SOC_NOPM, 0, 0), @@ -50,7 +95,8 @@ static const struct snd_soc_dapm_route intercon[] = { {"DMIC AIF", NULL, "DMic"}, }; -static struct snd_soc_codec_driver soc_dmic = { +static const struct snd_soc_codec_driver soc_dmic = { + .probe = dmic_codec_probe, .component_driver = { .dapm_widgets = dmic_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets), -- cgit v1.1 From d46b1828406f74bc2d9ffe15e9a7b76ddbffbf7f Mon Sep 17 00:00:00 2001 From: Harsha Priya N Date: Wed, 16 Aug 2017 16:19:55 +0530 Subject: ASoC: Intel: kbl: Enabling ASRC for RT5663 codec on kabylake platform Patch fixes cracking noise in rt5663 headphones for kbl platform by calling rt5663_sel_asrc_clk_src() for RT5663_AD_STEREO_FILTER to set ASRC. The ASRC function is for asynchronous MCLK and LRCLK. For RT5663 ASRC should be enabled to support pcm format with 100fs. ASRC function will track i2s clock and generate corresponding system clock for codec. Calling this func helps select clock source for both RT5663_AD_STEREO_FILTER and RT5663_DA_STEREO_FILTER filters which fixes the crackling sound. Signed-off-by: Harsha Priya Signed-off-by: Shruthi Sudhakar Signed-off-by: Naveen M Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 8bdd613..c144214 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -356,11 +356,13 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret; - ret = snd_soc_dai_set_sysclk(codec_dai, - RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN); /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, RT5663_DA_STEREO_FILTER, 1); + rt5663_sel_asrc_clk_src(codec_dai->codec, + RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, + RT5663_CLK_SEL_I2S1_ASRC); + ret = snd_soc_dai_set_sysclk(codec_dai, + RT5663_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN); if (ret < 0) dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); -- cgit v1.1 From 052fba77f57b9f243ad3a45a21c809bddcd03627 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:29:24 +0530 Subject: ASoC: aux1x: make snd_soc_ops const Make this const as it is only stored in the ops field of a snd_soc_dai_link structure, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/au1x/db1200.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/au1x/db1200.c b/sound/soc/au1x/db1200.c index 5c73061..301e1fc 100644 --- a/sound/soc/au1x/db1200.c +++ b/sound/soc/au1x/db1200.c @@ -99,7 +99,7 @@ static int db1200_i2s_startup(struct snd_pcm_substream *substream) return 0; } -static struct snd_soc_ops db1200_i2s_wm8731_ops = { +static const struct snd_soc_ops db1200_i2s_wm8731_ops = { .startup = db1200_i2s_startup, }; -- cgit v1.1 From 7f8159acecb3bb58c0d782813dc605ebef63b317 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:29:25 +0530 Subject: ASoC: cirrus: make snd_soc_ops const Make these const as they are only stored in the ops field of a snd_soc_dai_link structure, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/cirrus/edb93xx.c | 2 +- sound/soc/cirrus/snappercl15.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/cirrus/edb93xx.c b/sound/soc/cirrus/edb93xx.c index 85962657..c53bd6f 100644 --- a/sound/soc/cirrus/edb93xx.c +++ b/sound/soc/cirrus/edb93xx.c @@ -56,7 +56,7 @@ static int edb93xx_hw_params(struct snd_pcm_substream *substream, SND_SOC_CLOCK_OUT); } -static struct snd_soc_ops edb93xx_ops = { +static const struct snd_soc_ops edb93xx_ops = { .hw_params = edb93xx_hw_params, }; diff --git a/sound/soc/cirrus/snappercl15.c b/sound/soc/cirrus/snappercl15.c index 98089df..2334ec1 100644 --- a/sound/soc/cirrus/snappercl15.c +++ b/sound/soc/cirrus/snappercl15.c @@ -45,7 +45,7 @@ static int snappercl15_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_ops snappercl15_ops = { +static const struct snd_soc_ops snappercl15_ops = { .hw_params = snappercl15_hw_params, }; -- cgit v1.1 From e23d834876390d6b8d4d35057e9ecd899a44193a Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:29:26 +0530 Subject: ASoC: generic: make snd_soc_ops const Make these const as they are only stored in the ops field of a snd_soc_dai_link structure, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card.c | 2 +- sound/soc/generic/audio-graph-scu-card.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 105ec3a..d3497a3 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -95,7 +95,7 @@ static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) asoc_simple_card_clk_disable(&dai_props->codec_dai); } -static struct snd_soc_ops asoc_graph_card_ops = { +static const struct snd_soc_ops asoc_graph_card_ops = { .startup = asoc_graph_card_startup, .shutdown = asoc_graph_card_shutdown, }; diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index dcd2df3..3da9acd 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c @@ -56,7 +56,7 @@ static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) asoc_simple_card_clk_disable(dai_props); } -static struct snd_soc_ops asoc_graph_card_ops = { +static const struct snd_soc_ops asoc_graph_card_ops = { .startup = asoc_graph_card_startup, .shutdown = asoc_graph_card_shutdown, }; -- cgit v1.1 From c12a4a40b4fdaefa6c2578e86d277410e1a9cea1 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:29:28 +0530 Subject: ASoC: rockchip: make snd_soc_ops const Make this const as it is only stored in the ops field of a snd_soc_dai_link structure, which is const. Done using Coccinelle Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3288_hdmi_analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rk3288_hdmi_analog.c b/sound/soc/rockchip/rk3288_hdmi_analog.c index dbc53e4..42227b0 100644 --- a/sound/soc/rockchip/rk3288_hdmi_analog.c +++ b/sound/soc/rockchip/rk3288_hdmi_analog.c @@ -147,7 +147,7 @@ static int rk_init(struct snd_soc_pcm_runtime *runtime) return 0; } -static struct snd_soc_ops rk_ops = { +static const struct snd_soc_ops rk_ops = { .hw_params = rk_hw_params, }; -- cgit v1.1 From 2af236391f5a167630ebca0eced832afcc4634e0 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:29:29 +0530 Subject: ASoC: samsung: make snd_soc_ops const Make these const as they are only stored in the ops field of a snd_soc_dai_link structure, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/jive_wm8750.c | 2 +- sound/soc/samsung/s3c24xx_simtec.c | 2 +- sound/soc/samsung/s3c24xx_uda134x.c | 2 +- sound/soc/samsung/smdk_spdif.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c index 7fcb51f..529b10d 100644 --- a/sound/soc/samsung/jive_wm8750.c +++ b/sound/soc/samsung/jive_wm8750.c @@ -79,7 +79,7 @@ static int jive_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_ops jive_ops = { +static const struct snd_soc_ops jive_ops = { .hw_params = jive_hw_params, }; diff --git a/sound/soc/samsung/s3c24xx_simtec.c b/sound/soc/samsung/s3c24xx_simtec.c index dcc008d..6de63f3 100644 --- a/sound/soc/samsung/s3c24xx_simtec.c +++ b/sound/soc/samsung/s3c24xx_simtec.c @@ -211,7 +211,7 @@ static int simtec_call_startup(struct s3c24xx_audio_simtec_pdata *pd) return 0; } -static struct snd_soc_ops simtec_snd_ops = { +static const struct snd_soc_ops simtec_snd_ops = { .hw_params = simtec_hw_params, }; diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c index 55538e3..c65c89d 100644 --- a/sound/soc/samsung/s3c24xx_uda134x.c +++ b/sound/soc/samsung/s3c24xx_uda134x.c @@ -199,7 +199,7 @@ static int s3c24xx_uda134x_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_ops s3c24xx_uda134x_ops = { +static const struct snd_soc_ops s3c24xx_uda134x_ops = { .startup = s3c24xx_uda134x_startup, .shutdown = s3c24xx_uda134x_shutdown, .hw_params = s3c24xx_uda134x_hw_params, diff --git a/sound/soc/samsung/smdk_spdif.c b/sound/soc/samsung/smdk_spdif.c index a2f2363..7fc7cc6 100644 --- a/sound/soc/samsung/smdk_spdif.c +++ b/sound/soc/samsung/smdk_spdif.c @@ -144,7 +144,7 @@ static int smdk_hw_params(struct snd_pcm_substream *substream, return ret; } -static struct snd_soc_ops smdk_spdif_ops = { +static const struct snd_soc_ops smdk_spdif_ops = { .hw_params = smdk_hw_params, }; -- cgit v1.1 From a46d0592d164c017342d2d86e5d123735ec046ae Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:29:30 +0530 Subject: ASoC: sh: make snd_soc_ops const Make this const as it is only stored in the ops field of a snd_soc_dai_link structure, which is const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/sh/migor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sh/migor.c b/sound/soc/sh/migor.c index 672bcd4..ecb057f 100644 --- a/sound/soc/sh/migor.c +++ b/sound/soc/sh/migor.c @@ -98,7 +98,7 @@ static int migor_hw_free(struct snd_pcm_substream *substream) return 0; } -static struct snd_soc_ops migor_dai_ops = { +static const struct snd_soc_ops migor_dai_ops = { .hw_params = migor_hw_params, .hw_free = migor_hw_free, }; -- cgit v1.1 From cc6e25631ddd4f3295fc79568f2145c437849e63 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:45:08 +0530 Subject: ASoC: bcm: make snd_soc_dai_driver const Make this const as it is only used during a copy operation. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-ssp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index e710bb0..cdd5e82 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -1288,7 +1288,7 @@ static const struct snd_soc_dai_driver cygnus_ssp_dai_info[] = { INIT_CPU_DAI(2), }; -static struct snd_soc_dai_driver cygnus_spdif_dai_info = { +static const struct snd_soc_dai_driver cygnus_spdif_dai_info = { .name = "cygnus-spdif", .playback = { .channels_min = 2, -- cgit v1.1 From 6e37f933ed1ade3201dd609d103c0ef79c0ef6b0 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 16 Aug 2017 22:45:09 +0530 Subject: ASoC: codecs: make snd_soc_dai_driver and snd_soc_component_driver const Make these two structure variables const as they are either used in a copy operation or passed to devm_snd_soc_register_component having the corresponding argument as const. Done using Coccinelle. Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 2 +- sound/soc/codecs/lm4857.c | 2 +- sound/soc/codecs/max9768.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index f288404..d73d2c1 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -692,7 +692,7 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, return snd_ctl_add(rtd->card->snd_card, kctl); } -static struct snd_soc_dai_driver hdmi_i2s_dai = { +static const struct snd_soc_dai_driver hdmi_i2s_dai = { .name = "i2s-hifi", .id = DAI_ID_I2S, .playback = { diff --git a/sound/soc/codecs/lm4857.c b/sound/soc/codecs/lm4857.c index 558de10..1e96407 100644 --- a/sound/soc/codecs/lm4857.c +++ b/sound/soc/codecs/lm4857.c @@ -100,7 +100,7 @@ static const struct snd_soc_dapm_route lm4857_routes[] = { { "EP", "Earpiece", "Mode" }, }; -static struct snd_soc_component_driver lm4857_component_driver = { +static const struct snd_soc_component_driver lm4857_component_driver = { .controls = lm4857_controls, .num_controls = ARRAY_SIZE(lm4857_controls), .dapm_widgets = lm4857_dapm_widgets, diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index 5b82e26..7017c03 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c @@ -151,7 +151,7 @@ static int max9768_probe(struct snd_soc_component *component) return 0; } -static struct snd_soc_component_driver max9768_component_driver = { +static const struct snd_soc_component_driver max9768_component_driver = { .probe = max9768_probe, .controls = max9768_volume, .num_controls = ARRAY_SIZE(max9768_volume), -- cgit v1.1 From 5a9a8eca7996d5947905f853ab0c6717b4f2b7a0 Mon Sep 17 00:00:00 2001 From: Stephen Barber Date: Thu, 17 Aug 2017 15:17:46 -0700 Subject: ALSA: usb-audio: don't retry snd_usb_ctl_msg after timeout A few calls to snd_usb_ctl_msg wrap the function in a retry loop. In the worst case, the timeout for snd_usb_ctl_msg is 5 seconds, which when retried 10 times (for example, if a device is removed) could cause a probe to hang for ~50 seconds. Example stack trace from 3.14 which triggered a hung task timeout: Call Trace: [] ? inet6_set_link_af.part.35+0x12/0x12 [] schedule+0x6e/0x70 [] schedule_timeout+0xfc/0x13c [] ? rcu_read_unlock_sched_notrace+0x17/0x17 [] __wait_for_common+0x153/0x190 [] ? __wait_for_common+0x153/0x190 [] ? wake_up_state+0x12/0x12 [] wait_for_completion_timeout+0x1d/0x1f [] usb_start_wait_urb+0x93/0xf1 [] usb_control_msg+0xe1/0x11d [] snd_usb_ctl_msg+0x9c/0xf1 [snd_usb_audio] [] snd_usb_mixer_set_ctl_value+0x124/0xab1 [snd_usb_audio] [] snd_usb_mixer_set_ctl_value+0x1c3/0xab1 [snd_usb_audio] [] snd_usb_mixer_set_ctl_value+0x521/0xab1 [snd_usb_audio] [] snd_usb_mixer_add_control+0x36a/0x1264 [snd_usb_audio] [] snd_usb_mixer_add_control+0x805/0x1264 [snd_usb_audio] [] ? usb_free_urb+0x1a/0x1c [] snd_usb_mixer_add_control+0x11d9/0x1264 [snd_usb_audio] [] snd_usb_create_mixer+0xbc/0x286 [snd_usb_audio] [] 0xffffffffc02cac17 [] usb_probe_interface+0x17c/0x21c [] driver_probe_device+0xae/0x1fa [] __device_attach_driver+0x5f/0x66 [] ? driver_probe_device+0x1fa/0x1fa [] bus_for_each_drv+0x87/0xaa [] __device_attach+0x9d/0x101 [] device_initial_probe+0x13/0x15 [] bus_probe_device+0x33/0x96 [] device_add+0x328/0x547 [] usb_set_configuration+0x624/0x674 [] generic_probe+0x45/0x77 [] usb_probe_device+0x2d/0x40 [] driver_probe_device+0xae/0x1fa [] __device_attach_driver+0x5f/0x66 [] ? driver_probe_device+0x1fa/0x1fa [] bus_for_each_drv+0x87/0xaa [] __device_attach+0x9d/0x101 [] device_initial_probe+0x13/0x15 [] bus_probe_device+0x33/0x96 [] device_add+0x328/0x547 [] ? add_device_randomness+0x111/0x130 [] usb_new_device+0x2a2/0x3c0 [] hub_thread+0xa3d/0xeed [] ? __schedule+0x41e/0x5ac [] ? finish_wait+0x62/0x62 [] ? usb_reset_device+0x16a/0x16a [] kthread+0x108/0x110 [] ? __kthread_parkme+0x67/0x67 [] ret_from_fork+0x7c/0xb0 [] ? __kthread_parkme+0x67/0x67 Signed-off-by: Stephen Barber Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 082736c..253fc94 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -318,12 +318,15 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, while (timeout-- > 0) { idx = snd_usb_ctrl_intf(chip) | (cval->head.id << 8); - if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, - USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, - validx, idx, buf, val_len) >= val_len) { + err = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, + USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, + validx, idx, buf, val_len); + if (err >= val_len) { *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); err = 0; goto out; + } else if (err == -ETIMEDOUT) { + goto out; } } usb_audio_dbg(chip, @@ -483,12 +486,15 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, while (timeout-- > 0) { idx = snd_usb_ctrl_intf(chip) | (cval->head.id << 8); - if (snd_usb_ctl_msg(chip->dev, - usb_sndctrlpipe(chip->dev, 0), request, - USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, - validx, idx, buf, val_len) >= 0) { + err = snd_usb_ctl_msg(chip->dev, + usb_sndctrlpipe(chip->dev, 0), request, + USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, + validx, idx, buf, val_len); + if (err >= 0) { err = 0; goto out; + } else if (err == -ETIMEDOUT) { + goto out; } } usb_audio_dbg(chip, "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", -- cgit v1.1 From 3bcfe80f1c471b6bbade9f1a725778ea0471bb49 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Thu, 17 Aug 2017 21:05:52 +0200 Subject: ASoC: tegra: Remove SoC-specific Kconfig depends and selects This removes the SoC-specific dependencies on the platform drivers, as well as SoC-specific selections of platform drivers for the machine drivers. The rationale behind this change is that the dependencies are not actual build dependencies but run-time ones. The previously listed SoCs were also incomplete: for instance, tegra124 uses the tegra30 platform drivers, which could not be built without ARCH_TEGRA_3x_SOC set. Descriptions of the tristates are also added to allow these options to be set via defconfig/menuconfig. Signed-off-by: Paul Kocialkowski Acked-by: Thierry Reding Signed-off-by: Mark Brown --- sound/soc/tegra/Kconfig | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index efbe8d4..6875fc3 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -9,8 +9,8 @@ config SND_SOC_TEGRA Say Y or M here if you want support for SoC audio on Tegra. config SND_SOC_TEGRA20_AC97 - tristate - depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC + tristate "Tegra20 AC97 interface" + depends on SND_SOC_TEGRA select SND_SOC_AC97_BUS select SND_SOC_TEGRA20_DAS help @@ -19,16 +19,16 @@ config SND_SOC_TEGRA20_AC97 machine drivers to support below. config SND_SOC_TEGRA20_DAS - tristate - depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC + tristate "Tegra20 DAS module" + depends on SND_SOC_TEGRA help Say Y or M if you want to add support for the Tegra20 DAS module. You will also need to select the individual machine drivers to support below. config SND_SOC_TEGRA20_I2S - tristate - depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC + tristate "Tegra20 I2S interface" + depends on SND_SOC_TEGRA select SND_SOC_TEGRA20_DAS help Say Y or M if you want to add support for codecs attached to the @@ -36,8 +36,8 @@ config SND_SOC_TEGRA20_I2S machine drivers to support below. config SND_SOC_TEGRA20_SPDIF - tristate - depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC + tristate "Tegra20 SPDIF interface" + depends on SND_SOC_TEGRA default m help Say Y or M if you want to add support for the Tegra20 SPDIF interface. @@ -45,16 +45,16 @@ config SND_SOC_TEGRA20_SPDIF below. config SND_SOC_TEGRA30_AHUB - tristate - depends on SND_SOC_TEGRA && ARCH_TEGRA_3x_SOC + tristate "Tegra30 AHUB module" + depends on SND_SOC_TEGRA help - Say Y or M if you want to add support for the Tegra20 AHUB module. + Say Y or M if you want to add support for the Tegra30 AHUB module. You will also need to select the individual machine drivers to support below. config SND_SOC_TEGRA30_I2S - tristate - depends on SND_SOC_TEGRA && ARCH_TEGRA_3x_SOC + tristate "Tegra30 I2S interface" + depends on SND_SOC_TEGRA select SND_SOC_TEGRA30_AHUB help Say Y or M if you want to add support for codecs attached to the @@ -64,8 +64,6 @@ config SND_SOC_TEGRA30_I2S config SND_SOC_TEGRA_RT5640 tristate "SoC Audio support for Tegra boards using an RT5640 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC - select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_RT5640 help Say Y or M here if you want to add support for SoC audio on Tegra @@ -74,8 +72,6 @@ config SND_SOC_TEGRA_RT5640 config SND_SOC_TEGRA_WM8753 tristate "SoC Audio support for Tegra boards using a WM8753 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC - select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_WM8753 help Say Y or M here if you want to add support for SoC audio on Tegra @@ -84,8 +80,6 @@ config SND_SOC_TEGRA_WM8753 config SND_SOC_TEGRA_WM8903 tristate "SoC Audio support for Tegra boards using a WM8903 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC - select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_WM8903 help Say Y or M here if you want to add support for SoC audio on Tegra @@ -94,7 +88,7 @@ config SND_SOC_TEGRA_WM8903 config SND_SOC_TEGRA_WM9712 tristate "SoC Audio support for Tegra boards using a WM9712 codec" - depends on SND_SOC_TEGRA && ARCH_TEGRA_2x_SOC && GPIOLIB + depends on SND_SOC_TEGRA && GPIOLIB select SND_SOC_TEGRA20_AC97 select SND_SOC_WM9712 help @@ -104,7 +98,6 @@ config SND_SOC_TEGRA_WM9712 config SND_SOC_TEGRA_TRIMSLICE tristate "SoC Audio support for TrimSlice board" depends on SND_SOC_TEGRA && I2C - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC select SND_SOC_TLV320AIC23_I2C help Say Y or M here if you want to add support for SoC audio on the @@ -113,7 +106,6 @@ config SND_SOC_TEGRA_TRIMSLICE config SND_SOC_TEGRA_ALC5632 tristate "SoC Audio support for Tegra boards using an ALC5632 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC select SND_SOC_ALC5632 help Say Y or M here if you want to add support for SoC audio on the @@ -122,8 +114,6 @@ config SND_SOC_TEGRA_ALC5632 config SND_SOC_TEGRA_MAX98090 tristate "SoC Audio support for Tegra boards using a MAX98090 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC - select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_MAX98090 help Say Y or M here if you want to add support for SoC audio on Tegra @@ -132,8 +122,6 @@ config SND_SOC_TEGRA_MAX98090 config SND_SOC_TEGRA_RT5677 tristate "SoC Audio support for Tegra boards using a RT5677 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC - select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_RT5677 help Say Y or M here if you want to add support for SoC audio on Tegra @@ -142,8 +130,6 @@ config SND_SOC_TEGRA_RT5677 config SND_SOC_TEGRA_SGTL5000 tristate "SoC Audio support for Tegra boards using a SGTL5000 codec" depends on SND_SOC_TEGRA && I2C && GPIOLIB - select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC - select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_SGTL5000 help Say Y or M here if you want to add support for SoC audio on Tegra -- cgit v1.1 From f6c1626e28f22115ded520300b56fa049c068f4f Mon Sep 17 00:00:00 2001 From: Ryder Lee Date: Fri, 18 Aug 2017 09:28:50 +0800 Subject: ASoC: mediatek: switch to use platform_get_irq_byname() Switch to use platform_get_irq_byname() so that binding can be agnostic of the IRQ order. Signed-off-by: Ryder Lee CC: Garlic Tseng Signed-off-by: Mark Brown --- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index 10dcd69..8fda182 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -1496,14 +1496,12 @@ static int mt2701_afe_runtime_resume(struct device *dev) static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) { - int ret, i; - unsigned int irq_id; struct mtk_base_afe *afe; struct mt2701_afe_private *afe_priv; struct resource *res; struct device *dev; + int i, irq_id, ret; - ret = 0; afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); if (!afe) return -ENOMEM; @@ -1516,11 +1514,12 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) afe->dev = &pdev->dev; dev = afe->dev; - irq_id = platform_get_irq(pdev, 0); - if (!irq_id) { - dev_err(dev, "%s no irq found\n", dev->of_node->name); - return -ENXIO; + irq_id = platform_get_irq_byname(pdev, "asys"); + if (irq_id < 0) { + dev_err(dev, "unable to get ASYS IRQ\n"); + return irq_id; } + ret = devm_request_irq(dev, irq_id, mt2701_asys_isr, IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); if (ret) { -- cgit v1.1 From 728c4a87f31d30669a103dac1851a15f4e2af03c Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:35:59 +0530 Subject: ASoC: codecs: constify snd_soc_dai_ops structures snd_soc_dai_ops are not supposed to change at runtime. All functions working with snd_soc_dai_ops provided by work with const snd_soc_dai_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l42.c | 2 +- sound/soc/codecs/es8316.c | 2 +- sound/soc/codecs/hdac_hdmi.c | 2 +- sound/soc/codecs/inno_rk3036.c | 2 +- sound/soc/codecs/max9867.c | 2 +- sound/soc/codecs/max98926.c | 2 +- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- sound/soc/codecs/msm8916-wcd-digital.c | 2 +- sound/soc/codecs/rt5616.c | 2 +- sound/soc/codecs/rt5663.c | 2 +- sound/soc/codecs/tas5720.c | 2 +- sound/soc/codecs/zx_aud96p22.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index 55e4520..9e860df 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -911,7 +911,7 @@ static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops cs42l42_ops = { +static const struct snd_soc_dai_ops cs42l42_ops = { .hw_params = cs42l42_pcm_hw_params, .set_fmt = cs42l42_set_dai_fmt, .set_sysclk = cs42l42_set_sysclk, diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index ecc02449..f5cf48c 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -502,7 +502,7 @@ static int es8316_mute(struct snd_soc_dai *dai, int mute) #define ES8316_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops es8316_ops = { +static const struct snd_soc_dai_ops es8316_ops = { .startup = es8316_pcm_startup, .hw_params = es8316_pcm_hw_params, .set_fmt = es8316_set_dai_fmt, diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index bc2e74f..e6de50a 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1360,7 +1360,7 @@ static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdac) } -static struct snd_soc_dai_ops hdmi_dai_ops = { +static const struct snd_soc_dai_ops hdmi_dai_ops = { .startup = hdac_hdmi_pcm_open, .shutdown = hdac_hdmi_pcm_close, .hw_params = hdac_hdmi_set_hw_params, diff --git a/sound/soc/codecs/inno_rk3036.c b/sound/soc/codecs/inno_rk3036.c index b918ba5..edf42d2 100644 --- a/sound/soc/codecs/inno_rk3036.c +++ b/sound/soc/codecs/inno_rk3036.c @@ -310,7 +310,7 @@ static int rk3036_codec_dai_hw_params(struct snd_pcm_substream *substream, SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops rk3036_codec_dai_ops = { +static const struct snd_soc_dai_ops rk3036_codec_dai_ops = { .set_fmt = rk3036_codec_dai_set_fmt, .hw_params = rk3036_codec_dai_hw_params, }; diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2a40a69..3e421e9 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -350,7 +350,7 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return 0; } -static struct snd_soc_dai_ops max9867_dai_ops = { +static const struct snd_soc_dai_ops max9867_dai_ops = { .set_fmt = max9867_dai_set_fmt, .set_sysclk = max9867_set_dai_sysclk, .prepare = max9867_prepare, diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index 1eff7e0..f16145d8 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -459,7 +459,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, #define MAX98926_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops max98926_dai_ops = { +static const struct snd_soc_dai_ops max98926_dai_ops = { .set_fmt = max98926_dai_set_fmt, .hw_params = max98926_dai_hw_params, }; diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a788029..aec1e16 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -753,7 +753,7 @@ static void pm8916_wcd_analog_shutdown(struct snd_pcm_substream *substream, RST_CTL_DIG_SW_RST_N_MASK, 0); } -static struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { +static const struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { .startup = pm8916_wcd_analog_startup, .shutdown = pm8916_wcd_analog_shutdown, }; diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index f690442..7e3794f 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -788,7 +788,7 @@ static void msm8916_wcd_digital_shutdown(struct snd_pcm_substream *substream, LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, 0); } -static struct snd_soc_dai_ops msm8916_wcd_digital_dai_ops = { +static const struct snd_soc_dai_ops msm8916_wcd_digital_dai_ops = { .startup = msm8916_wcd_digital_startup, .shutdown = msm8916_wcd_digital_shutdown, .hw_params = msm8916_wcd_digital_hw_params, diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 7d6e082..33bdfe7 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -1265,7 +1265,7 @@ static int rt5616_resume(struct snd_soc_codec *codec) #define RT5616_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt5616_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5616_aif_dai_ops = { .hw_params = rt5616_hw_params, .set_fmt = rt5616_set_dai_fmt, .set_sysclk = rt5616_set_dai_sysclk, diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index a33202a..af642c0 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2860,7 +2860,7 @@ static int rt5663_resume(struct snd_soc_codec *codec) #define RT5663_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt5663_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5663_aif_dai_ops = { .hw_params = rt5663_hw_params, .set_fmt = rt5663_set_dai_fmt, .set_sysclk = rt5663_set_dai_sysclk, diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c index c65b917..01e9ed2 100644 --- a/sound/soc/codecs/tas5720.c +++ b/sound/soc/codecs/tas5720.c @@ -507,7 +507,7 @@ static struct snd_soc_codec_driver soc_codec_dev_tas5720 = { #define TAS5720_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |\ SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops tas5720_speaker_dai_ops = { +static const struct snd_soc_dai_ops tas5720_speaker_dai_ops = { .hw_params = tas5720_hw_params, .set_fmt = tas5720_set_dai_fmt, .set_tdm_slot = tas5720_set_dai_tdm_slot, diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c index 032fb7c..855011e 100644 --- a/sound/soc/codecs/zx_aud96p22.c +++ b/sound/soc/codecs/zx_aud96p22.c @@ -312,7 +312,7 @@ static int aud96p22_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; } -static struct snd_soc_dai_ops aud96p22_dai_ops = { +static const struct snd_soc_dai_ops aud96p22_dai_ops = { .set_fmt = aud96p22_set_fmt, }; -- cgit v1.1 From eb59d73cb535ba32df928f210fb9a8529bf465c0 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:35:59 +0530 Subject: ASoC: codecs: constify snd_soc_dai_ops structures snd_soc_dai_ops are not supposed to change at runtime. All functions working with snd_soc_dai_ops provided by work with const snd_soc_dai_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l42.c | 2 +- sound/soc/codecs/es8316.c | 2 +- sound/soc/codecs/inno_rk3036.c | 2 +- sound/soc/codecs/max9867.c | 2 +- sound/soc/codecs/max98926.c | 2 +- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- sound/soc/codecs/rt5616.c | 2 +- sound/soc/codecs/rt5663.c | 2 +- sound/soc/codecs/tas5720.c | 2 +- sound/soc/codecs/zx_aud96p22.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index 55e4520..9e860df 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -911,7 +911,7 @@ static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops cs42l42_ops = { +static const struct snd_soc_dai_ops cs42l42_ops = { .hw_params = cs42l42_pcm_hw_params, .set_fmt = cs42l42_set_dai_fmt, .set_sysclk = cs42l42_set_sysclk, diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index 4f35af6..da2d353 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -502,7 +502,7 @@ static int es8316_mute(struct snd_soc_dai *dai, int mute) #define ES8316_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops es8316_ops = { +static const struct snd_soc_dai_ops es8316_ops = { .startup = es8316_pcm_startup, .hw_params = es8316_pcm_hw_params, .set_fmt = es8316_set_dai_fmt, diff --git a/sound/soc/codecs/inno_rk3036.c b/sound/soc/codecs/inno_rk3036.c index 64b0be9..6b59b6f 100644 --- a/sound/soc/codecs/inno_rk3036.c +++ b/sound/soc/codecs/inno_rk3036.c @@ -310,7 +310,7 @@ static int rk3036_codec_dai_hw_params(struct snd_pcm_substream *substream, SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops rk3036_codec_dai_ops = { +static const struct snd_soc_dai_ops rk3036_codec_dai_ops = { .set_fmt = rk3036_codec_dai_set_fmt, .hw_params = rk3036_codec_dai_hw_params, }; diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 6c0c0d6..2f60924 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -350,7 +350,7 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return 0; } -static struct snd_soc_dai_ops max9867_dai_ops = { +static const struct snd_soc_dai_ops max9867_dai_ops = { .set_fmt = max9867_dai_set_fmt, .set_sysclk = max9867_set_dai_sysclk, .prepare = max9867_prepare, diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index 7a39bfb..59d03d0 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -459,7 +459,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, #define MAX98926_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) -static struct snd_soc_dai_ops max98926_dai_ops = { +static const struct snd_soc_dai_ops max98926_dai_ops = { .set_fmt = max98926_dai_set_fmt, .hw_params = max98926_dai_hw_params, }; diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 4cc52ce..f07674e 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -753,7 +753,7 @@ static void pm8916_wcd_analog_shutdown(struct snd_pcm_substream *substream, RST_CTL_DIG_SW_RST_N_MASK, 0); } -static struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { +static const struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { .startup = pm8916_wcd_analog_startup, .shutdown = pm8916_wcd_analog_shutdown, }; diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 3c5f555..c94e94f 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -1265,7 +1265,7 @@ static int rt5616_resume(struct snd_soc_codec *codec) #define RT5616_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt5616_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5616_aif_dai_ops = { .hw_params = rt5616_hw_params, .set_fmt = rt5616_set_dai_fmt, .set_sysclk = rt5616_set_dai_sysclk, diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index ebc5e3b..1bbe363 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -2860,7 +2860,7 @@ static int rt5663_resume(struct snd_soc_codec *codec) #define RT5663_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) -static struct snd_soc_dai_ops rt5663_aif_dai_ops = { +static const struct snd_soc_dai_ops rt5663_aif_dai_ops = { .hw_params = rt5663_hw_params, .set_fmt = rt5663_set_dai_fmt, .set_sysclk = rt5663_set_dai_sysclk, diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c index d14b78b..a736a2a 100644 --- a/sound/soc/codecs/tas5720.c +++ b/sound/soc/codecs/tas5720.c @@ -507,7 +507,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_tas5720 = { #define TAS5720_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |\ SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE) -static struct snd_soc_dai_ops tas5720_speaker_dai_ops = { +static const struct snd_soc_dai_ops tas5720_speaker_dai_ops = { .hw_params = tas5720_hw_params, .set_fmt = tas5720_set_dai_fmt, .set_tdm_slot = tas5720_set_dai_tdm_slot, diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c index 36d0a70..51fad48 100644 --- a/sound/soc/codecs/zx_aud96p22.c +++ b/sound/soc/codecs/zx_aud96p22.c @@ -312,7 +312,7 @@ static int aud96p22_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; } -static struct snd_soc_dai_ops aud96p22_dai_ops = { +static const struct snd_soc_dai_ops aud96p22_dai_ops = { .set_fmt = aud96p22_set_fmt, }; -- cgit v1.1 From ab566fd52309971da595af057fd480aed82ca0e2 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 17:36:10 +0530 Subject: ASoC: ux500: constify snd_soc_dai_ops structures snd_soc_dai_ops are not supposed to change at runtime. All functions working with snd_soc_dai_ops provided by work with const snd_soc_dai_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Mark Brown --- sound/soc/ux500/ux500_msp_dai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/ux500/ux500_msp_dai.c b/sound/soc/ux500/ux500_msp_dai.c index ec5152a..625b72a 100644 --- a/sound/soc/ux500/ux500_msp_dai.c +++ b/sound/soc/ux500/ux500_msp_dai.c @@ -707,7 +707,7 @@ static int ux500_msp_dai_probe(struct snd_soc_dai *dai) return 0; } -static struct snd_soc_dai_ops ux500_msp_dai_ops[] = { +static const struct snd_soc_dai_ops ux500_msp_dai_ops[] = { { .set_sysclk = ux500_msp_dai_set_dai_sysclk, .set_fmt = ux500_msp_dai_set_dai_fmt, -- cgit v1.1 From 18f6dda9f8776354809d5ffa04627503dbb6f2e1 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:09 +0530 Subject: ALSA: aoa: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/aoa/soundbus/i2sbus/pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c index 053b09c..e618531 100644 --- a/sound/aoa/soundbus/i2sbus/pcm.c +++ b/sound/aoa/soundbus/i2sbus/pcm.c @@ -778,7 +778,7 @@ static snd_pcm_uframes_t i2sbus_playback_pointer(struct snd_pcm_substream return i2sbus_pcm_pointer(i2sdev, 0); } -static struct snd_pcm_ops i2sbus_playback_ops = { +static const struct snd_pcm_ops i2sbus_playback_ops = { .open = i2sbus_playback_open, .close = i2sbus_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -848,7 +848,7 @@ static snd_pcm_uframes_t i2sbus_record_pointer(struct snd_pcm_substream return i2sbus_pcm_pointer(i2sdev, 1); } -static struct snd_pcm_ops i2sbus_record_ops = { +static const struct snd_pcm_ops i2sbus_record_ops = { .open = i2sbus_record_open, .close = i2sbus_record_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 28f054802aa18c248341c6113566457b5a036485 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:10 +0530 Subject: ALSA: arm: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 4 ++-- sound/arm/pxa2xx-pcm.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 74cf452..1b9f440 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -635,7 +635,7 @@ static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cm return ret; } -static struct snd_pcm_ops aaci_playback_ops = { +static const struct snd_pcm_ops aaci_playback_ops = { .open = aaci_pcm_open, .close = aaci_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -738,7 +738,7 @@ static int aaci_pcm_capture_prepare(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops aaci_capture_ops = { +static const struct snd_pcm_ops aaci_capture_ops = { .open = aaci_pcm_open, .close = aaci_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c index 83fcfac..1c6f4b4 100644 --- a/sound/arm/pxa2xx-pcm.c +++ b/sound/arm/pxa2xx-pcm.c @@ -68,7 +68,7 @@ static int pxa2xx_pcm_close(struct snd_pcm_substream *substream) return __pxa2xx_pcm_close(substream); } -static struct snd_pcm_ops pxa2xx_pcm_ops = { +static const struct snd_pcm_ops pxa2xx_pcm_ops = { .open = pxa2xx_pcm_open, .close = pxa2xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 1086373713fbd602ab73c1968e5f91f15f647c49 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:11 +0530 Subject: ALSA: atmel: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index f85131b..5402f82 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -461,7 +461,7 @@ atmel_ac97c_capture_pointer(struct snd_pcm_substream *substream) return frames; } -static struct snd_pcm_ops atmel_ac97_playback_ops = { +static const struct snd_pcm_ops atmel_ac97_playback_ops = { .open = atmel_ac97c_playback_open, .close = atmel_ac97c_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -472,7 +472,7 @@ static struct snd_pcm_ops atmel_ac97_playback_ops = { .pointer = atmel_ac97c_playback_pointer, }; -static struct snd_pcm_ops atmel_ac97_capture_ops = { +static const struct snd_pcm_ops atmel_ac97_capture_ops = { .open = atmel_ac97c_capture_open, .close = atmel_ac97c_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From f95925829b96199e4182438c3ea880ee15066b01 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:12 +0530 Subject: ALSA: drivers: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/drivers/aloop.c | 4 ++-- sound/drivers/ml403-ac97cr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 6e02ee0..135adb1 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -750,7 +750,7 @@ static int loopback_close(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops loopback_playback_ops = { +static const struct snd_pcm_ops loopback_playback_ops = { .open = loopback_open, .close = loopback_close, .ioctl = snd_pcm_lib_ioctl, @@ -763,7 +763,7 @@ static struct snd_pcm_ops loopback_playback_ops = { .mmap = snd_pcm_lib_mmap_vmalloc, }; -static struct snd_pcm_ops loopback_capture_ops = { +static const struct snd_pcm_ops loopback_capture_ops = { .open = loopback_open, .close = loopback_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/drivers/ml403-ac97cr.c b/sound/drivers/ml403-ac97cr.c index d634e10..18fd129 100644 --- a/sound/drivers/ml403-ac97cr.c +++ b/sound/drivers/ml403-ac97cr.c @@ -759,7 +759,7 @@ static int snd_ml403_ac97cr_capture_close(struct snd_pcm_substream *substream) return 0; } -static struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { +static const struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { .open = snd_ml403_ac97cr_playback_open, .close = snd_ml403_ac97cr_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -770,7 +770,7 @@ static struct snd_pcm_ops snd_ml403_ac97cr_playback_ops = { .pointer = snd_ml403_ac97cr_pcm_pointer, }; -static struct snd_pcm_ops snd_ml403_ac97cr_capture_ops = { +static const struct snd_pcm_ops snd_ml403_ac97cr_capture_ops = { .open = snd_ml403_ac97cr_capture_open, .close = snd_ml403_ac97cr_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From b2165f3889ace44ee21a41ca72467be3119121db Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:13 +0530 Subject: ALSA: firewire: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/firewire/isight.c | 2 +- sound/firewire/motu/motu-pcm.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c index 48d6dca..5826aa8 100644 --- a/sound/firewire/isight.c +++ b/sound/firewire/isight.c @@ -444,7 +444,7 @@ static snd_pcm_uframes_t isight_pointer(struct snd_pcm_substream *substream) static int isight_create_pcm(struct isight *isight) { - static struct snd_pcm_ops ops = { + static const struct snd_pcm_ops ops = { .open = isight_open, .close = isight_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index a2b50df..1466e46 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -352,7 +352,7 @@ static int playback_ack(struct snd_pcm_substream *substream) int snd_motu_create_pcm_devices(struct snd_motu *motu) { - static struct snd_pcm_ops capture_ops = { + static const struct snd_pcm_ops capture_ops = { .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -365,7 +365,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) .page = snd_pcm_lib_get_vmalloc_page, .mmap = snd_pcm_lib_mmap_vmalloc, }; - static struct snd_pcm_ops playback_ops = { + static const struct snd_pcm_ops playback_ops = { .open = pcm_open, .close = pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 915a38d324d23f4fa53306a3a834f54a9f6da17c Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:14 +0530 Subject: ALSA: mips: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/mips/hal2.c | 4 ++-- sound/mips/sgio2audio.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index 367d6c37..37d378a 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -711,7 +711,7 @@ static int hal2_capture_ack(struct snd_pcm_substream *substream) hal2_capture_transfer); } -static struct snd_pcm_ops hal2_playback_ops = { +static const struct snd_pcm_ops hal2_playback_ops = { .open = hal2_playback_open, .close = hal2_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -723,7 +723,7 @@ static struct snd_pcm_ops hal2_playback_ops = { .ack = hal2_playback_ack, }; -static struct snd_pcm_ops hal2_capture_ops = { +static const struct snd_pcm_ops hal2_capture_ops = { .open = hal2_capture_open, .close = hal2_capture_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 603892f..71c9421 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -675,7 +675,7 @@ snd_sgio2audio_pcm_pointer(struct snd_pcm_substream *substream) } /* operators */ -static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { +static const struct snd_pcm_ops snd_sgio2audio_playback1_ops = { .open = snd_sgio2audio_playback1_open, .close = snd_sgio2audio_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -688,7 +688,7 @@ static struct snd_pcm_ops snd_sgio2audio_playback1_ops = { .mmap = snd_pcm_lib_mmap_vmalloc, }; -static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { +static const struct snd_pcm_ops snd_sgio2audio_playback2_ops = { .open = snd_sgio2audio_playback2_open, .close = snd_sgio2audio_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -701,7 +701,7 @@ static struct snd_pcm_ops snd_sgio2audio_playback2_ops = { .mmap = snd_pcm_lib_mmap_vmalloc, }; -static struct snd_pcm_ops snd_sgio2audio_capture_ops = { +static const struct snd_pcm_ops snd_sgio2audio_capture_ops = { .open = snd_sgio2audio_capture_open, .close = snd_sgio2audio_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From c2992b19a7a00055443d25b9256c39ad7b3e3d69 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:15 +0530 Subject: ALSA: parisc: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index cb2bc54..4eddd81 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -596,7 +596,7 @@ snd_harmony_hw_free(struct snd_pcm_substream *ss) return snd_pcm_lib_free_pages(ss); } -static struct snd_pcm_ops snd_harmony_playback_ops = { +static const struct snd_pcm_ops snd_harmony_playback_ops = { .open = snd_harmony_playback_open, .close = snd_harmony_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -607,7 +607,7 @@ static struct snd_pcm_ops snd_harmony_playback_ops = { .pointer = snd_harmony_playback_pointer, }; -static struct snd_pcm_ops snd_harmony_capture_ops = { +static const struct snd_pcm_ops snd_harmony_capture_ops = { .open = snd_harmony_capture_open, .close = snd_harmony_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From e0c24d8b27593475c33710d2497e1e0b745c2d12 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:16 +0530 Subject: ALSA: pcmcia: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index d788409..4a2354b 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -266,7 +266,7 @@ static snd_pcm_uframes_t pdacf_pcm_capture_pointer(struct snd_pcm_substream *sub /* * operators for PCM capture */ -static struct snd_pcm_ops pdacf_pcm_capture_ops = { +static const struct snd_pcm_ops pdacf_pcm_capture_ops = { .open = pdacf_pcm_capture_open, .close = pdacf_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 3179a3ea7125b8139aa977d7f8715f4960c241f8 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:17 +0530 Subject: ALSA: ppc: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 4 ++-- sound/ppc/snd_ps3.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 45f0295..48dd44f8 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -681,7 +681,7 @@ static int snd_pmac_capture_close(struct snd_pcm_substream *subs) /* */ -static struct snd_pcm_ops snd_pmac_playback_ops = { +static const struct snd_pcm_ops snd_pmac_playback_ops = { .open = snd_pmac_playback_open, .close = snd_pmac_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -692,7 +692,7 @@ static struct snd_pcm_ops snd_pmac_playback_ops = { .pointer = snd_pmac_playback_pointer, }; -static struct snd_pcm_ops snd_pmac_capture_ops = { +static const struct snd_pcm_ops snd_pmac_capture_ops = { .open = snd_pmac_capture_open, .close = snd_pmac_capture_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c index cdd44ab..36f34f4 100644 --- a/sound/ppc/snd_ps3.c +++ b/sound/ppc/snd_ps3.c @@ -772,7 +772,7 @@ static struct snd_kcontrol_new spdif_ctls[] = { }, }; -static struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { +static const struct snd_pcm_ops snd_ps3_pcm_spdif_ops = { .open = snd_ps3_pcm_open, .close = snd_ps3_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 46a085a3e70681fe2e184ec5c36e7e3146d12576 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:18 +0530 Subject: ALSA: sh: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/sh/aica.c | 2 +- sound/sh/sh_dac_audio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/sh/aica.c b/sound/sh/aica.c index 822608d..fdc680a 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -436,7 +436,7 @@ static unsigned long snd_aicapcm_pcm_pointer(struct snd_pcm_substream return readl(AICA_CONTROL_CHANNEL_SAMPLE_NUMBER); } -static struct snd_pcm_ops snd_aicapcm_playback_ops = { +static const struct snd_pcm_ops snd_aicapcm_playback_ops = { .open = snd_aicapcm_pcm_open, .close = snd_aicapcm_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index a077f1c..e71e6a7 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -252,7 +252,7 @@ snd_pcm_uframes_t snd_sh_dac_pcm_pointer(struct snd_pcm_substream *substream) } /* pcm ops */ -static struct snd_pcm_ops snd_sh_dac_pcm_ops = { +static const struct snd_pcm_ops snd_sh_dac_pcm_ops = { .open = snd_sh_dac_pcm_open, .close = snd_sh_dac_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 544d6272c8c85684db10e96910adc9f55f2b6350 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:19 +0530 Subject: ALSA: sparc: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 4 ++-- sound/sparc/cs4231.c | 4 ++-- sound/sparc/dbri.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index a6864fd..56f1741 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -733,7 +733,7 @@ static int snd_amd7930_hw_free(struct snd_pcm_substream *substream) return snd_pcm_lib_free_pages(substream); } -static struct snd_pcm_ops snd_amd7930_playback_ops = { +static const struct snd_pcm_ops snd_amd7930_playback_ops = { .open = snd_amd7930_playback_open, .close = snd_amd7930_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -744,7 +744,7 @@ static struct snd_pcm_ops snd_amd7930_playback_ops = { .pointer = snd_amd7930_playback_pointer, }; -static struct snd_pcm_ops snd_amd7930_capture_ops = { +static const struct snd_pcm_ops snd_amd7930_capture_ops = { .open = snd_amd7930_capture_open, .close = snd_amd7930_capture_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index f5192b3..e73c962 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1203,7 +1203,7 @@ static int snd_cs4231_capture_close(struct snd_pcm_substream *substream) * XXX the audio AUXIO register... */ -static struct snd_pcm_ops snd_cs4231_playback_ops = { +static const struct snd_pcm_ops snd_cs4231_playback_ops = { .open = snd_cs4231_playback_open, .close = snd_cs4231_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1214,7 +1214,7 @@ static struct snd_pcm_ops snd_cs4231_playback_ops = { .pointer = snd_cs4231_playback_pointer, }; -static struct snd_pcm_ops snd_cs4231_capture_ops = { +static const struct snd_pcm_ops snd_cs4231_capture_ops = { .open = snd_cs4231_capture_open, .close = snd_cs4231_capture_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 72b6c4a..abc7bd5 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2213,7 +2213,7 @@ static snd_pcm_uframes_t snd_dbri_pointer(struct snd_pcm_substream *substream) return ret; } -static struct snd_pcm_ops snd_dbri_ops = { +static const struct snd_pcm_ops snd_dbri_ops = { .open = snd_dbri_open, .close = snd_dbri_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 7a205f5db56d9055ff368ab5103275d0164a41c8 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:20 +0530 Subject: ALSA: spi: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index fac7e6e..1ef52ed 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -322,7 +322,7 @@ snd_at73c213_pcm_pointer(struct snd_pcm_substream *substream) return pos; } -static struct snd_pcm_ops at73c213_playback_ops = { +static const struct snd_pcm_ops at73c213_playback_ops = { .open = snd_at73c213_pcm_open, .close = snd_at73c213_pcm_close, .ioctl = snd_pcm_lib_ioctl, -- cgit v1.1 From 31cb1fb41df3b871d337544ed5199a135e606f69 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Fri, 18 Aug 2017 13:15:21 +0530 Subject: ALSA: usb: constify snd_pcm_ops structures snd_pcm_ops are not supposed to change at runtime. All functions working with snd_pcm_ops provided by work with const snd_pcm_ops. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/usb/6fire/pcm.c | 2 +- sound/usb/caiaq/audio.c | 2 +- sound/usb/hiface/pcm.c | 2 +- sound/usb/misc/ua101.c | 4 ++-- sound/usb/pcm.c | 4 ++-- sound/usb/usx2y/usbusx2yaudio.c | 2 +- sound/usb/usx2y/usx2yhwdeppcm.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index 36f4115..224a6a5 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c @@ -555,7 +555,7 @@ static snd_pcm_uframes_t usb6fire_pcm_pointer( return ret; } -static struct snd_pcm_ops pcm_ops = { +static const struct snd_pcm_ops pcm_ops = { .open = usb6fire_pcm_open, .close = usb6fire_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index 054645f..fb1c1ea 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c @@ -338,7 +338,7 @@ unlock: } /* operators for both playback and capture */ -static struct snd_pcm_ops snd_usb_caiaq_ops = { +static const struct snd_pcm_ops snd_usb_caiaq_ops = { .open = snd_usb_caiaq_substream_open, .close = snd_usb_caiaq_substream_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/usb/hiface/pcm.c b/sound/usb/hiface/pcm.c index 33db205..175d8d6 100644 --- a/sound/usb/hiface/pcm.c +++ b/sound/usb/hiface/pcm.c @@ -513,7 +513,7 @@ static snd_pcm_uframes_t hiface_pcm_pointer(struct snd_pcm_substream *alsa_sub) return bytes_to_frames(alsa_sub->runtime, dma_offset); } -static struct snd_pcm_ops pcm_ops = { +static const struct snd_pcm_ops pcm_ops = { .open = hiface_pcm_open, .close = hiface_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index b05cd38..386fbfd 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -890,7 +890,7 @@ static snd_pcm_uframes_t playback_pcm_pointer(struct snd_pcm_substream *subs) return ua101_pcm_pointer(ua, &ua->playback); } -static struct snd_pcm_ops capture_pcm_ops = { +static const struct snd_pcm_ops capture_pcm_ops = { .open = capture_pcm_open, .close = capture_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -903,7 +903,7 @@ static struct snd_pcm_ops capture_pcm_ops = { .mmap = snd_pcm_lib_mmap_vmalloc, }; -static struct snd_pcm_ops playback_pcm_ops = { +static const struct snd_pcm_ops playback_pcm_ops = { .open = playback_pcm_open, .close = playback_pcm_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index a4f3390..b9c9a19 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -1690,7 +1690,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream return -EINVAL; } -static struct snd_pcm_ops snd_usb_playback_ops = { +static const struct snd_pcm_ops snd_usb_playback_ops = { .open = snd_usb_playback_open, .close = snd_usb_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1703,7 +1703,7 @@ static struct snd_pcm_ops snd_usb_playback_ops = { .mmap = snd_pcm_lib_mmap_vmalloc, }; -static struct snd_pcm_ops snd_usb_capture_ops = { +static const struct snd_pcm_ops snd_usb_capture_ops = { .open = snd_usb_capture_open, .close = snd_usb_capture_close, .ioctl = snd_pcm_lib_ioctl, diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 612aa7f..f93b355 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -905,7 +905,7 @@ static int snd_usX2Y_pcm_close(struct snd_pcm_substream *substream) } -static struct snd_pcm_ops snd_usX2Y_pcm_ops = +static const struct snd_pcm_ops snd_usX2Y_pcm_ops = { .open = snd_usX2Y_pcm_open, .close = snd_usX2Y_pcm_close, diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index d51c7fd..0d05052 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -587,7 +587,7 @@ static int snd_usX2Y_usbpcm_close(struct snd_pcm_substream *substream) } -static struct snd_pcm_ops snd_usX2Y_usbpcm_ops = +static const struct snd_pcm_ops snd_usX2Y_usbpcm_ops = { .open = snd_usX2Y_usbpcm_open, .close = snd_usX2Y_usbpcm_close, -- cgit v1.1 From 7b42cfafdcbf73bd58687cbe3157b9ca4a0fd2e5 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 20 Aug 2017 13:49:06 +0900 Subject: ALSA: control: queue events within locking of controls_rwsem for ELEM_WRITE operation Any control event is queued by a call of snd_ctl_notify(). This function adds the event to each queue of opened file data corresponding to ALSA control character devices. This function acquired two types of lock; a counting semaphore for a list of the opened file data and a spinlock for card data opened by the file. Typically, this function is called after acquiring a counting semaphore for a list of elements in the card data. In current implementation of a handler for ELEM_WRITE request, the function is called after releasing the semaphore for a list of elements in the card data. This release is not necessarily needed. This commit removes the release to call the function within the critical section so that later commits are simple. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 9e7a457..79fdb36 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -948,9 +948,8 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, } if (result > 0) { struct snd_ctl_elem_id id = control->id; - up_read(&card->controls_rwsem); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id); - return 0; + result = 0; } } up_read(&card->controls_rwsem); -- cgit v1.1 From becf9e5d553c2389d857a3c178ce80fdb34a02e1 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 20 Aug 2017 13:49:07 +0900 Subject: ALSA: control: code refactoring for ELEM_READ/ELEM_WRITE operations ALSA control core handles ELEM_READ/ELEM_WRITE requests within lock acquisition of a counting semaphore. The lock is acquired in helper functions in the end of call path before calling implementations of each driver. ioctl(2) with SNDRV_CTL_ELEM_READ ... ->snd_ctl_ioctl() ->snd_ctl_elem_read_user() ->snd_ctl_elem_read() ->down_read(controls_rwsem) ->snd_ctl_find_id() ->struct snd_kcontrol.get() ->up_read(controls_rwsem) ioctl(2) with SNDRV_CTL_ELEM_WRITE ... ->snd_ctl_ioctl() ->snd_ctl_elem_write_user() ->snd_ctl_elem_write() ->down_read(controls_rwsem) ->snd_ctl_find_id() ->struct snd_kcontrol.put() ->up_read(controls_rwsem) This commit moves the lock acquisition to middle of the call graph to simplify the helper functions. As a result: ioctl(2) with SNDRV_CTL_ELEM_READ ... ->snd_ctl_ioctl() ->snd_ctl_elem_read_user() ->down_read(controls_rwsem) ->snd_ctl_elem_read() ->snd_ctl_find_id() ->struct snd_kcontrol.get() ->up_read(controls_rwsem) ioctl(2) with SNDRV_CTL_ELEM_WRITE ... ->snd_ctl_ioctl() ->snd_ctl_elem_write_user() ->down_read(controls_rwsem) ->snd_ctl_elem_write() ->snd_ctl_find_id() ->struct snd_kcontrol.put() ->up_read(controls_rwsem) Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 77 ++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 79fdb36..1c1fc08 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -881,24 +881,18 @@ static int snd_ctl_elem_read(struct snd_card *card, struct snd_kcontrol *kctl; struct snd_kcontrol_volatile *vd; unsigned int index_offset; - int result; - down_read(&card->controls_rwsem); kctl = snd_ctl_find_id(card, &control->id); - if (kctl == NULL) { - result = -ENOENT; - } else { - index_offset = snd_ctl_get_ioff(kctl, &control->id); - vd = &kctl->vd[index_offset]; - if ((vd->access & SNDRV_CTL_ELEM_ACCESS_READ) && - kctl->get != NULL) { - snd_ctl_build_ioff(&control->id, kctl, index_offset); - result = kctl->get(kctl, control); - } else - result = -EPERM; - } - up_read(&card->controls_rwsem); - return result; + if (kctl == NULL) + return -ENOENT; + + index_offset = snd_ctl_get_ioff(kctl, &control->id); + vd = &kctl->vd[index_offset]; + if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) && kctl->get == NULL) + return -EPERM; + + snd_ctl_build_ioff(&control->id, kctl, index_offset); + return kctl->get(kctl, control); } static int snd_ctl_elem_read_user(struct snd_card *card, @@ -913,8 +907,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card, snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (result >= 0) + if (result >= 0) { + down_read(&card->controls_rwsem); result = snd_ctl_elem_read(card, control); + up_read(&card->controls_rwsem); + } snd_power_unlock(card); if (result >= 0) if (copy_to_user(_control, control, sizeof(*control))) @@ -931,29 +928,28 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, unsigned int index_offset; int result; - down_read(&card->controls_rwsem); kctl = snd_ctl_find_id(card, &control->id); - if (kctl == NULL) { - result = -ENOENT; - } else { - index_offset = snd_ctl_get_ioff(kctl, &control->id); - vd = &kctl->vd[index_offset]; - if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || - kctl->put == NULL || - (file && vd->owner && vd->owner != file)) { - result = -EPERM; - } else { - snd_ctl_build_ioff(&control->id, kctl, index_offset); - result = kctl->put(kctl, control); - } - if (result > 0) { - struct snd_ctl_elem_id id = control->id; - snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id); - result = 0; - } + if (kctl == NULL) + return -ENOENT; + + index_offset = snd_ctl_get_ioff(kctl, &control->id); + vd = &kctl->vd[index_offset]; + if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || kctl->put == NULL || + (file && vd->owner && vd->owner != file)) { + return -EPERM; } - up_read(&card->controls_rwsem); - return result; + + snd_ctl_build_ioff(&control->id, kctl, index_offset); + result = kctl->put(kctl, control); + if (result < 0) + return result; + + if (result > 0) { + struct snd_ctl_elem_id id = control->id; + snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id); + } + + return 0; } static int snd_ctl_elem_write_user(struct snd_ctl_file *file, @@ -970,8 +966,11 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, card = file->card; snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (result >= 0) + if (result >= 0) { + down_read(&card->controls_rwsem); result = snd_ctl_elem_write(card, file, control); + up_read(&card->controls_rwsem); + } snd_power_unlock(card); if (result >= 0) if (copy_to_user(_control, control, sizeof(*control))) -- cgit v1.1 From 5bbb1ab5bd0b01c4f0b19ae03fdfec487f839517 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 20 Aug 2017 13:49:08 +0900 Subject: ALSA: control: use counting semaphore as write lock for ELEM_WRITE operation In ALSA control interface, applications can execute two types of request for value of members on each element; ELEM_READ and ELEM_WRITE. In ALSA control core, these two requests are handled within read lock of a counting semaphore, therefore several processes can run to execute these two requests at the same time. This has an issue because ELEM_WRITE requests have an effect to change state of the target element. Concurrent access should be controlled for each of ELEM_READ/ELEM_WRITE case. This commit uses the counting semaphore as write lock for ELEM_WRITE requests, while use it as read lock for ELEM_READ requests. The state of a target element is maintained exclusively between ELEM_WRITE/ELEM_READ operations. There's a concern. If the counting semaphore is acquired for read lock in implementations of 'struct snd_kcontrol.put()' in each driver, this commit shall cause dead lock. As of v4.13-rc5, 'snd-mixer-oss.ko', 'snd-emu10k1.ko' and 'snd-soc-sst-atom-hifi2-platform.ko' includes codes for read locks, but these are not in a call graph from 'struct snd_kcontrol.put(). Therefore, this commit is safe. In current implementation, the same solution is applied for the other operations to element; e.g. ELEM_LOCK and ELEM_UNLOCK. There's another discussion about an overhead to maintain concurrent access to an element during operating the other elements on the same card instance, because the lock primitive is originally implemented to maintain a list of elements on the card instance. There's a substantial difference between per-element-list lock and per-element lock. Here, let me investigate another idea to add per-element lock to maintain the concurrent accesses with inquiry/change requests to an element. It's not so frequent for applications to operate members on elements, while adding a new lock primitive to structure increases memory footprint for all of element sets somehow. Experimentally, inquiry operation is more frequent than change operation and usage of counting semaphore for the inquiry operation brings no blocking to the other inquiry operations. Thus the overhead is not so critical for usual applications. For the above reasons, in this commit, the per-element lock is not introduced. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 1c1fc08..249140c 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -967,9 +967,9 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); if (result >= 0) { - down_read(&card->controls_rwsem); + down_write(&card->controls_rwsem); result = snd_ctl_elem_write(card, file, control); - up_read(&card->controls_rwsem); + up_write(&card->controls_rwsem); } snd_power_unlock(card); if (result >= 0) -- cgit v1.1 From 8b460c76bd17128db90d69a3f8b4ad2ee744d118 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 20 Aug 2017 21:25:03 +0900 Subject: ALSA: firewire-motu: add specification flag for position of flag for MIDI messages In protocols of MOTU FireWire series, when transferring MIDI messages, transmitter set existence flag to one byte on first several quadlets. The position differs depending on protocols and models, however two cases are confirmed; in 5th byte and 8th byte from MSB side. This commit adds a series of specification flag to describe them. When the existence flag is in the 5th byte, SND_MOTU_SPEC_[R|T]X_MIDI_2ND_Q is used. Else, another set of the flag is used. Here, '_Q' means quadlet. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/motu/motu-pcm.c | 2 +- sound/firewire/motu/motu-protocol-v2.c | 5 ----- sound/firewire/motu/motu-protocol-v3.c | 5 ----- sound/firewire/motu/motu-stream.c | 38 ++++++++++++++++++++++++++++++++-- sound/firewire/motu/motu.c | 11 +++++++--- sound/firewire/motu/motu.h | 6 +++++- 6 files changed, 50 insertions(+), 17 deletions(-) (limited to 'sound') diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c index 1466e46..4330220 100644 --- a/sound/firewire/motu/motu-pcm.c +++ b/sound/firewire/motu/motu-pcm.c @@ -145,7 +145,7 @@ static int pcm_open(struct snd_pcm_substream *substream) mutex_lock(&motu->mutex); - err = protocol->cache_packet_formats(motu); + err = snd_motu_stream_cache_packet_formats(motu); if (err < 0) goto err_locked; diff --git a/sound/firewire/motu/motu-protocol-v2.c b/sound/firewire/motu/motu-protocol-v2.c index 05b5d287..525b746 100644 --- a/sound/firewire/motu/motu-protocol-v2.c +++ b/sound/firewire/motu/motu-protocol-v2.c @@ -217,12 +217,7 @@ static int v2_cache_packet_formats(struct snd_motu *motu) calculate_differed_part(&motu->rx_packet_formats, motu->spec->flags, data, V2_OPT_OUT_IFACE_MASK, V2_OPT_OUT_IFACE_SHIFT); - motu->tx_packet_formats.midi_flag_offset = 4; - motu->tx_packet_formats.midi_byte_offset = 6; motu->tx_packet_formats.pcm_byte_offset = 10; - - motu->rx_packet_formats.midi_flag_offset = 4; - motu->rx_packet_formats.midi_byte_offset = 6; motu->rx_packet_formats.pcm_byte_offset = 10; return 0; diff --git a/sound/firewire/motu/motu-protocol-v3.c b/sound/firewire/motu/motu-protocol-v3.c index ddb6472..c7cd986 100644 --- a/sound/firewire/motu/motu-protocol-v3.c +++ b/sound/firewire/motu/motu-protocol-v3.c @@ -291,12 +291,7 @@ static int v3_cache_packet_formats(struct snd_motu *motu) V3_ENABLE_OPT_OUT_IFACE_A, V3_NO_ADAT_OPT_OUT_IFACE_A, V3_ENABLE_OPT_OUT_IFACE_B, V3_NO_ADAT_OPT_OUT_IFACE_B); - motu->tx_packet_formats.midi_flag_offset = 8; - motu->tx_packet_formats.midi_byte_offset = 7; motu->tx_packet_formats.pcm_byte_offset = 10; - - motu->rx_packet_formats.midi_flag_offset = 8; - motu->rx_packet_formats.midi_byte_offset = 7; motu->rx_packet_formats.pcm_byte_offset = 10; return 0; diff --git a/sound/firewire/motu/motu-stream.c b/sound/firewire/motu/motu-stream.c index bd45802..dc5541c 100644 --- a/sound/firewire/motu/motu-stream.c +++ b/sound/firewire/motu/motu-stream.c @@ -33,7 +33,8 @@ static int start_both_streams(struct snd_motu *motu, unsigned int rate) u32 data; int err; - if (motu->spec->flags & SND_MOTU_SPEC_HAS_MIDI) + if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || + (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q)) midi_ports = 1; /* Set packet formation to our packet streaming engine. */ @@ -42,6 +43,12 @@ static int start_both_streams(struct snd_motu *motu, unsigned int rate) if (err < 0) return err; + if ((motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || + (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) + midi_ports = 1; + else + midi_ports = 0; + err = amdtp_motu_set_parameters(&motu->tx_stream, rate, midi_ports, &motu->tx_packet_formats); if (err < 0) @@ -141,6 +148,33 @@ static void stop_isoc_ctx(struct snd_motu *motu, struct amdtp_stream *stream) fw_iso_resources_free(resources); } +int snd_motu_stream_cache_packet_formats(struct snd_motu *motu) +{ + int err; + + err = motu->spec->protocol->cache_packet_formats(motu); + if (err < 0) + return err; + + if (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) { + motu->tx_packet_formats.midi_flag_offset = 4; + motu->tx_packet_formats.midi_byte_offset = 6; + } else if (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q) { + motu->tx_packet_formats.midi_flag_offset = 8; + motu->tx_packet_formats.midi_byte_offset = 7; + } + + if (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) { + motu->rx_packet_formats.midi_flag_offset = 4; + motu->rx_packet_formats.midi_byte_offset = 6; + } else if (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q) { + motu->rx_packet_formats.midi_flag_offset = 8; + motu->rx_packet_formats.midi_byte_offset = 7; + } + + return 0; +} + static int ensure_packet_formats(struct snd_motu *motu) { __be32 reg; @@ -184,7 +218,7 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate) stop_both_streams(motu); } - err = protocol->cache_packet_formats(motu); + err = snd_motu_stream_cache_packet_formats(motu); if (err < 0) return err; diff --git a/sound/firewire/motu/motu.c b/sound/firewire/motu/motu.c index bf779cf..13d26e3 100644 --- a/sound/firewire/motu/motu.c +++ b/sound/firewire/motu/motu.c @@ -103,7 +103,10 @@ static void do_registration(struct work_struct *work) if (err < 0) goto error; - if (motu->spec->flags & SND_MOTU_SPEC_HAS_MIDI) { + if ((motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_2ND_Q) || + (motu->spec->flags & SND_MOTU_SPEC_RX_MIDI_3RD_Q) || + (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_2ND_Q) || + (motu->spec->flags & SND_MOTU_SPEC_TX_MIDI_3RD_Q)) { err = snd_motu_create_midi_devices(motu); if (err < 0) goto error; @@ -197,7 +200,8 @@ static struct snd_motu_spec motu_828mk2 = { SND_MOTU_SPEC_TX_MICINST_CHUNK | SND_MOTU_SPEC_TX_RETURN_CHUNK | SND_MOTU_SPEC_HAS_OPT_IFACE_A | - SND_MOTU_SPEC_HAS_MIDI, + SND_MOTU_SPEC_RX_MIDI_2ND_Q | + SND_MOTU_SPEC_TX_MIDI_2ND_Q, .analog_in_ports = 8, .analog_out_ports = 8, @@ -213,7 +217,8 @@ static struct snd_motu_spec motu_828mk3 = { SND_MOTU_SPEC_TX_REVERB_CHUNK | SND_MOTU_SPEC_HAS_OPT_IFACE_A | SND_MOTU_SPEC_HAS_OPT_IFACE_B | - SND_MOTU_SPEC_HAS_MIDI, + SND_MOTU_SPEC_RX_MIDI_3RD_Q | + SND_MOTU_SPEC_TX_MIDI_3RD_Q, .analog_in_ports = 8, .analog_out_ports = 8, diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h index 8d6a4a3..4b23cf3 100644 --- a/sound/firewire/motu/motu.h +++ b/sound/firewire/motu/motu.h @@ -82,7 +82,10 @@ enum snd_motu_spec_flags { SND_MOTU_SPEC_TX_AESEBU_CHUNK = 0x0020, SND_MOTU_SPEC_HAS_OPT_IFACE_A = 0x0040, SND_MOTU_SPEC_HAS_OPT_IFACE_B = 0x0080, - SND_MOTU_SPEC_HAS_MIDI = 0x0100, + SND_MOTU_SPEC_RX_MIDI_2ND_Q = 0x0100, + SND_MOTU_SPEC_RX_MIDI_3RD_Q = 0x0200, + SND_MOTU_SPEC_TX_MIDI_2ND_Q = 0x0400, + SND_MOTU_SPEC_TX_MIDI_3RD_Q = 0x0800, }; #define SND_MOTU_CLOCK_RATE_COUNT 6 @@ -146,6 +149,7 @@ void snd_motu_transaction_unregister(struct snd_motu *motu); int snd_motu_stream_init_duplex(struct snd_motu *motu); void snd_motu_stream_destroy_duplex(struct snd_motu *motu); +int snd_motu_stream_cache_packet_formats(struct snd_motu *motu); int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate); void snd_motu_stream_stop_duplex(struct snd_motu *motu); int snd_motu_stream_lock_try(struct snd_motu *motu); -- cgit v1.1 From 3a93d082bacf887b47737c4b75c083dea7570832 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 20 Aug 2017 21:25:04 +0900 Subject: ALSA: firewire-motu: add support for MOTU Audio Express MOTU Audio Express is one of third generation in MOTU FireWire series, produced in 2011. This model consists of three chips: * TI TSB41AB2 (Physical layer for IEEE 1394 bus) * Microchip USB3300 (Hi-Speed USB Device with ULPI interface) * Xilinx Spartan-3A FPGA, XC3S400A (Link layer for IEEE 1394 bus, packet processing and data block processing layer) This commit adds support for this model. As I expected, it works with current implementaion of protocol version 3. On the other hand, the unit has a quirk to request subaction originated by any driver. 11:45:51.287643 firewire_ohci 0000:03:00.0: AT spd 2 tl 1f, ffc1 -> ffc0, -reserved-, QW req, fffff0000b14 = 02000200 11:45:51.289193 firewire_ohci 0000:03:00.0: AR spd 2 tl 1f, ffc0 -> ffc1, ack_complete, W resp 11:45:51.289381 fireire_core 0000:03:00.0: unsolicited response (source ffc0, tlabel 1f) 11:45:51.313071 firewire_ohci 0000:03:00.0: AT spd 2 tl 20, ffc1 -> ffc0, ack_pending , QW req, fffff0000b14 = 02000200 11:45:51.314539 firewire_ohci 0000:03:00.0: AR spd 2 tl 20, ffc0 -> ffc1, ack_complete, W resp In 1394 OHCI (rev.1.1), after OUTPUT_LAST* descriptors is processed, 'xferStaus' field is filled with 'ContextControl[0:15]' (see clause 7.1.3). 5 bits in LSB side of the field has ack code in acknowledge from the unit (see clause 7.2.2). A list of the code is shown in Table 3-2. As long as I investigated, in a case of the '-reserved-' acknowledge message from the unit, the field has 0x10. On the table, this value is 'Reserved for definition by future 1394 standards'. As long as I know, any specifications of IEEE 1394 has no such extensions, thus the unit is out of specification. Besides, I note that the unit does not always acknowledge with the invalid code. I guess this is a bug of firmware. I confirmed the bug in firmware version 1.04 and this is the latest one. $ cd linux-firewire-utils $ python2 ./src/crpp < /sys/bus/firewire/devices/fw1/config_rom ROM header and bus information block ----------------------------------------------------------------- 400 0410a756 bus_info_length 4, crc_length 16, crc 42838 404 31333934 bus_name "1394" 408 20ff7000 irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 255, max_rec 7 (256) 40c 0001f200 company_id 0001f2 | 410 000a8a7b device_id 00000a8a7b | EUI-64 0001f200000a8a7b root directory ----------------------------------------------------------------- 414 0004ef04 directory_length 4, crc 61188 418 030001f2 vendor 41c 0c0083c0 node capabilities per IEEE 1394 420 d1000002 --> unit directory at 428 424 8d000005 --> eui-64 leaf at 438 unit directory at 428 ----------------------------------------------------------------- 428 00031680 directory_length 3, crc 5760 42c 120001f2 specifier id 430 13000033 version 434 17104800 model eui-64 leaf at 438 ----------------------------------------------------------------- 438 00025ef3 leaf_length 2, crc 24307 43c 0001f200 company_id 0001f2 | 440 000a8a7b device_id 00000a8a7b | EUI-64 0001f200000a8a7b Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/motu/motu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sound') diff --git a/sound/firewire/motu/motu.c b/sound/firewire/motu/motu.c index 13d26e3..fddeb11 100644 --- a/sound/firewire/motu/motu.c +++ b/sound/firewire/motu/motu.c @@ -224,6 +224,18 @@ static struct snd_motu_spec motu_828mk3 = { .analog_out_ports = 8, }; +static struct snd_motu_spec motu_audio_express = { + .name = "AudioExpress", + .protocol = &snd_motu_protocol_v3, + .flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 | + SND_MOTU_SPEC_TX_MICINST_CHUNK | + SND_MOTU_SPEC_TX_RETURN_CHUNK | + SND_MOTU_SPEC_RX_MIDI_2ND_Q | + SND_MOTU_SPEC_TX_MIDI_3RD_Q, + .analog_in_ports = 2, + .analog_out_ports = 4, +}; + #define SND_MOTU_DEV_ENTRY(model, data) \ { \ .match_flags = IEEE1394_MATCH_VENDOR_ID | \ @@ -239,6 +251,7 @@ static const struct ieee1394_device_id motu_id_table[] = { SND_MOTU_DEV_ENTRY(0x101800, &motu_828mk2), SND_MOTU_DEV_ENTRY(0x106800, &motu_828mk3), /* FireWire only. */ SND_MOTU_DEV_ENTRY(0x100800, &motu_828mk3), /* Hybrid. */ + SND_MOTU_DEV_ENTRY(0x104800, &motu_audio_express), { } }; MODULE_DEVICE_TABLE(ieee1394, motu_id_table); -- cgit v1.1 From b65cb7a590274bf5dbf5bbccbbd0c495c27ab14d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 21 Aug 2017 07:03:01 +0000 Subject: ASoC: rsnd: tidyup comments position/space/tab Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/dma.c | 2 +- sound/soc/sh/rcar/src.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 60aa5e96..041ec10 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c @@ -604,8 +604,8 @@ rsnd_gen2_dma_addr(struct rsnd_dai_stream *io, dma_addr_t in_addr; } dma_addrs[3][2][3] = { /* SRC */ + /* Capture */ {{{ 0, 0 }, - /* Capture */ { RDMA_SRC_O_N(src, id), RDMA_SRC_I_P(src, id) }, { RDMA_CMD_O_N(src, id), RDMA_SRC_I_P(src, id) } }, /* Playback */ diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 8e9a1de..4640039 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -108,7 +108,6 @@ unsigned int rsnd_src_get_rate(struct rsnd_priv *priv, int is_play = rsnd_io_is_play(io); /* - * * Playback * runtime_rate -> [SRC] -> convert_rate * @@ -203,13 +202,13 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, use_src = (fin != fout) | rsnd_src_sync_is_enabled(mod); /* - * SRC_ADINR + * SRC_ADINR */ adinr = rsnd_get_adinr_bit(mod, io) | rsnd_runtime_channel_original(io); /* - * SRC_IFSCR / SRC_IFSVR + * SRC_IFSCR / SRC_IFSVR */ ifscr = 0; fsrate = 0; @@ -223,7 +222,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, } /* - * SRC_SRCCR / SRC_ROUTE_MODE0 + * SRC_SRCCR / SRC_ROUTE_MODE0 */ cr = 0x00011110; route = 0x0; -- cgit v1.1 From 1107a293b7c33723ace2a8d18f5c6febcd576d7a Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:21:35 +0800 Subject: ASoC: s3c24xx_uda134x: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/samsung/s3c24xx_uda134x.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c index c65c89d..5fb3bab 100644 --- a/sound/soc/samsung/s3c24xx_uda134x.c +++ b/sound/soc/samsung/s3c24xx_uda134x.c @@ -237,7 +237,6 @@ static int s3c24xx_uda134x_probe(struct platform_device *pdev) mutex_init(&priv->clk_lock); card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, priv); ret = devm_snd_soc_register_card(&pdev->dev, card); -- cgit v1.1 From 5c23bc7cb6b6b40ddf7864e5dead647625e2f386 Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:23:19 +0800 Subject: ASoC: atmel: Remove unnecessary function call The function platform_set_drvdata copies the value the variable card to card->dev->driver_data, then the address of &pdev->dev is assigned to card->dev in atmel_classd_asoc_card_init, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will do the same copy operation, so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-classd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index b7ef8c5..0cd7caa 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -652,7 +652,6 @@ static int atmel_classd_probe(struct platform_device *pdev) } snd_soc_card_set_drvdata(card, dd); - platform_set_drvdata(pdev, card); ret = atmel_classd_asoc_card_init(dev, card); if (ret) { -- cgit v1.1 From acd617a461ed811894f4318c9b952fa002f3be21 Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:25:25 +0800 Subject: ASoC: atmel: Remove unnecessary function call The function platform_set_drvdata copies the value the variable card to card->dev->driver_data, then the address of &pdev->dev is assigned to card->dev in atmel_pdmic_asoc_card_init, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will do the same copy operation, so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-pdmic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index c917df7..8e3d34b 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -694,7 +694,6 @@ static int atmel_pdmic_probe(struct platform_device *pdev) } snd_soc_card_set_drvdata(card, dd); - platform_set_drvdata(pdev, card); ret = atmel_pdmic_asoc_card_init(dev, card); if (ret) { -- cgit v1.1 From dc94d245a57b76f38c7a936cf900cc38237638de Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:25:46 +0800 Subject: ASoC: rockchip: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3288_hdmi_analog.c | 2 -- sound/soc/rockchip/rk3399_gru_sound.c | 1 - 2 files changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rk3288_hdmi_analog.c b/sound/soc/rockchip/rk3288_hdmi_analog.c index 42227b0..fa44e39 100644 --- a/sound/soc/rockchip/rk3288_hdmi_analog.c +++ b/sound/soc/rockchip/rk3288_hdmi_analog.c @@ -272,8 +272,6 @@ static int snd_rk_mc_probe(struct platform_device *pdev) return ret; } - platform_set_drvdata(pdev, card); - return ret; } diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 3475c61..70c0908 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -362,7 +362,6 @@ static int rockchip_sound_probe(struct platform_device *pdev) rockchip_dailinks[DAILINK_RT5514_DSP].platform_name = kstrdup_const(dev_name(dev), GFP_KERNEL); card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) -- cgit v1.1 From 4c316783ee88eee4f045fbb31344471c6607b6ed Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:26:25 +0800 Subject: ASoC: mxs-sgtl5000: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/mxs/mxs-sgtl5000.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index a96276e..2ed3240 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c @@ -140,7 +140,6 @@ static int mxs_sgtl5000_probe(struct platform_device *pdev) } card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) { -- cgit v1.1 From 70024ebc51cc4a10a2945188e1129ae594830ca2 Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:43:57 +0800 Subject: ASoC: qcom: Remove useless function call The function platform_set_drvdata(pdev, data) copies the value of the variable data to pdev->dev.driver_data,but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will override it, so i think that the former copy operation is useless and can be removed. Signed-off-by: Peng Donglin Acked-by: Banajit Goswami Signed-off-by: Mark Brown --- sound/soc/qcom/apq8016_sbc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index f07aa1e..96a079d 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -206,7 +206,6 @@ static int apq8016_sbc_platform_probe(struct platform_device *pdev) if (IS_ERR(data->spkr_iomux)) return PTR_ERR(data->spkr_iomux); - platform_set_drvdata(pdev, data); snd_soc_card_set_drvdata(card, data); return devm_snd_soc_register_card(&pdev->dev, card); -- cgit v1.1 From 3bb2991c1d4d487323fde7b5b63985798c91a03f Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:44:58 +0800 Subject: ASoC: qcom: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Acked-by: Banajit Goswami Signed-off-by: Mark Brown --- sound/soc/qcom/storm.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/qcom/storm.c b/sound/soc/qcom/storm.c index c5207af..a9fa972 100644 --- a/sound/soc/qcom/storm.c +++ b/sound/soc/qcom/storm.c @@ -99,7 +99,6 @@ static int storm_platform_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); ret = snd_soc_of_parse_card_name(card, "qcom,model"); if (ret) { -- cgit v1.1 From 827807549e690c84bba5aac99b58dfbd52fcef8c Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:55:13 +0800 Subject: ASoC: sun4i-codec: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev in create_card,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-codec.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index c668b8b..baa9007 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -1655,7 +1655,6 @@ static int sun4i_codec_probe(struct platform_device *pdev) goto err_unregister_codec; } - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, scodec); ret = snd_soc_register_card(card); -- cgit v1.1 From 6eb4f27419d9250ac632df15d9dcf916d84b9944 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:32 +0200 Subject: ASoC: sun4i-i2s: Add regmap fields for channels On the original i2s block the channel mapping and selection were configured for stereo audio by default: This is not the case with the newer SoCs and they are also located at different offsets. To support the newer SoC then regmap fields have been added to the quirks and these are initialised to their correct settings during probing. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 77 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index dfb794f..87feb5a 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -82,7 +82,7 @@ #define SUN4I_I2S_TX_CNT_REG 0x2c #define SUN4I_I2S_TX_CHAN_SEL_REG 0x30 -#define SUN4I_I2S_TX_CHAN_SEL(num_chan) (((num_chan) - 1) << 0) +#define SUN4I_I2S_CHAN_SEL(num_chan) (((num_chan) - 1) << 0) #define SUN4I_I2S_TX_CHAN_MAP_REG 0x34 #define SUN4I_I2S_TX_CHAN_MAP(chan, sample) ((sample) << (chan << 2)) @@ -98,6 +98,10 @@ * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. + * @field_txchanmap: location of the tx channel mapping register. + * @field_rxchanmap: location of the rx channel mapping register. + * @field_txchansel: location of the tx channel select bit fields. + * @field_rxchansel: location of the rx channel select bit fields. */ struct sun4i_i2s_quirks { bool has_reset; @@ -105,6 +109,12 @@ struct sun4i_i2s_quirks { const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; unsigned int bclk_offset; + + /* Register fields for i2s */ + struct reg_field field_txchanmap; + struct reg_field field_rxchanmap; + struct reg_field field_txchansel; + struct reg_field field_rxchansel; }; struct sun4i_i2s { @@ -118,6 +128,12 @@ struct sun4i_i2s { struct snd_dmaengine_dai_dma_data capture_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data; + /* Register fields for i2s */ + struct regmap_field *field_txchanmap; + struct regmap_field *field_rxchanmap; + struct regmap_field *field_txchansel; + struct regmap_field *field_rxchansel; + const struct sun4i_i2s_quirks *variant; }; @@ -268,6 +284,17 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, if (params_channels(params) != 2) return -EINVAL; + /* Map the channels for playback and capture */ + regmap_field_write(i2s->field_txchanmap, 0x76543210); + regmap_field_write(i2s->field_rxchanmap, 0x00003210); + + /* Configure the channels */ + regmap_field_write(i2s->field_txchansel, + SUN4I_I2S_CHAN_SEL(params_channels(params))); + + regmap_field_write(i2s->field_rxchansel, + SUN4I_I2S_CHAN_SEL(params_channels(params))); + switch (params_physical_width(params)) { case 16: width = DMA_SLAVE_BUSWIDTH_2_BYTES; @@ -490,13 +517,6 @@ static int sun4i_i2s_startup(struct snd_pcm_substream *substream, SUN4I_I2S_CTRL_SDO_EN_MASK, SUN4I_I2S_CTRL_SDO_EN(0)); - /* Enable the first two channels */ - regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG, - SUN4I_I2S_TX_CHAN_SEL(2)); - - /* Map them to the two first samples coming in */ - regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, - SUN4I_I2S_TX_CHAN_MAP(0, 0) | SUN4I_I2S_TX_CHAN_MAP(1, 1)); return clk_prepare_enable(i2s->mod_clk); } @@ -681,14 +701,49 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .has_reset = false, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), + .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), + .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), + .field_rxchansel = REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2), }; static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .has_reset = true, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), + .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), + .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), + .field_rxchansel = REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2), }; +static int sun4i_i2s_init_regmap_fields(struct device *dev, + struct sun4i_i2s *i2s) +{ + i2s->field_txchanmap = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_txchanmap); + if (IS_ERR(i2s->field_txchanmap)) + return PTR_ERR(i2s->field_txchanmap); + + i2s->field_rxchanmap = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_rxchanmap); + if (IS_ERR(i2s->field_rxchanmap)) + return PTR_ERR(i2s->field_rxchanmap); + + i2s->field_txchansel = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_txchansel); + if (IS_ERR(i2s->field_txchansel)) + return PTR_ERR(i2s->field_txchansel); + + i2s->field_rxchansel = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_rxchansel); + return PTR_ERR_OR_ZERO(i2s->field_rxchansel); +} + static int sun4i_i2s_probe(struct platform_device *pdev) { struct sun4i_i2s *i2s; @@ -782,6 +837,12 @@ static int sun4i_i2s_probe(struct platform_device *pdev) goto err_suspend; } + ret = sun4i_i2s_init_regmap_fields(&pdev->dev, i2s); + if (ret) { + dev_err(&pdev->dev, "Could not initialise regmap fields\n"); + goto err_suspend; + } + return 0; err_suspend: -- cgit v1.1 From 771647159125e93547f15daa14131a30a26f9b60 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:33 +0200 Subject: ASoC: sun4i-i2s: Add regfields for word size select and sample resolution On newer SoCs the location of the slot width select and sample resolution are different and also there is a bigger range of support. For the current supported rates then an offset is required. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 87feb5a..563de78 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -98,6 +98,9 @@ * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. + * @fmt_offset: Value by which wss and sr needs to be adjusted. + * @field_fmt_wss: regmap field to set word select size. + * @field_fmt_sr: regmap field to set sample resolution. * @field_txchanmap: location of the tx channel mapping register. * @field_rxchanmap: location of the rx channel mapping register. * @field_txchansel: location of the tx channel select bit fields. @@ -109,8 +112,11 @@ struct sun4i_i2s_quirks { const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; unsigned int bclk_offset; + unsigned int fmt_offset; /* Register fields for i2s */ + struct reg_field field_fmt_wss; + struct reg_field field_fmt_sr; struct reg_field field_txchanmap; struct reg_field field_rxchanmap; struct reg_field field_txchansel; @@ -129,6 +135,8 @@ struct sun4i_i2s { struct snd_dmaengine_dai_dma_data playback_dma_data; /* Register fields for i2s */ + struct regmap_field *field_fmt_wss; + struct regmap_field *field_fmt_sr; struct regmap_field *field_txchanmap; struct regmap_field *field_rxchanmap; struct regmap_field *field_txchansel; @@ -314,9 +322,10 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, - SUN4I_I2S_FMT0_WSS_MASK | SUN4I_I2S_FMT0_SR_MASK, - SUN4I_I2S_FMT0_WSS(wss) | SUN4I_I2S_FMT0_SR(sr)); + regmap_field_write(i2s->field_fmt_wss, + wss + i2s->variant->fmt_offset); + regmap_field_write(i2s->field_fmt_sr, + sr + i2s->variant->fmt_offset); return sun4i_i2s_set_clk_rate(i2s, params_rate(params), params_width(params)); @@ -701,6 +710,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .has_reset = false, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), + .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -711,6 +722,8 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .has_reset = true, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), + .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -720,6 +733,18 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { static int sun4i_i2s_init_regmap_fields(struct device *dev, struct sun4i_i2s *i2s) { + i2s->field_fmt_wss = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_wss); + if (IS_ERR(i2s->field_fmt_wss)) + return PTR_ERR(i2s->field_fmt_wss); + + i2s->field_fmt_sr = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_sr); + if (IS_ERR(i2s->field_fmt_sr)) + return PTR_ERR(i2s->field_fmt_sr); + i2s->field_txchanmap = devm_regmap_field_alloc(dev, i2s->regmap, i2s->variant->field_txchanmap); -- cgit v1.1 From 296935213feb7bcb72ab8750a8cacb66baeb0eb3 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:34 +0200 Subject: ASoC: sun4i-i2s: bclk and lrclk polarity tidyup On newer SoCs the bit fields for the blck and lrclk polarity are in a different locations. Use regmap fields to set the polarity bits as intended. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 563de78..8c7ad5b 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -50,6 +50,8 @@ #define SUN4I_I2S_FMT0_FMT_RIGHT_J (2 << 0) #define SUN4I_I2S_FMT0_FMT_LEFT_J (1 << 0) #define SUN4I_I2S_FMT0_FMT_I2S (0 << 0) +#define SUN4I_I2S_FMT0_POLARITY_INVERTED (1) +#define SUN4I_I2S_FMT0_POLARITY_NORMAL (0) #define SUN4I_I2S_FMT1_REG 0x08 #define SUN4I_I2S_FIFO_TX_REG 0x0c @@ -101,6 +103,8 @@ * @fmt_offset: Value by which wss and sr needs to be adjusted. * @field_fmt_wss: regmap field to set word select size. * @field_fmt_sr: regmap field to set sample resolution. + * @field_fmt_bclk: regmap field to set clk polarity. + * @field_fmt_lrclk: regmap field to set frame polarity. * @field_txchanmap: location of the tx channel mapping register. * @field_rxchanmap: location of the rx channel mapping register. * @field_txchansel: location of the tx channel select bit fields. @@ -117,6 +121,8 @@ struct sun4i_i2s_quirks { /* Register fields for i2s */ struct reg_field field_fmt_wss; struct reg_field field_fmt_sr; + struct reg_field field_fmt_bclk; + struct reg_field field_fmt_lrclk; struct reg_field field_txchanmap; struct reg_field field_rxchanmap; struct reg_field field_txchansel; @@ -137,6 +143,8 @@ struct sun4i_i2s { /* Register fields for i2s */ struct regmap_field *field_fmt_wss; struct regmap_field *field_fmt_sr; + struct regmap_field *field_fmt_bclk; + struct regmap_field *field_fmt_lrclk; struct regmap_field *field_txchanmap; struct regmap_field *field_rxchanmap; struct regmap_field *field_txchansel; @@ -335,6 +343,8 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); u32 val; + u32 bclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL; + u32 lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL; /* DAI Mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -359,32 +369,25 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_IB_IF: /* Invert both clocks */ - val = SUN4I_I2S_FMT0_BCLK_POLARITY_INVERTED | - SUN4I_I2S_FMT0_LRCLK_POLARITY_INVERTED; + bclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; + lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; break; case SND_SOC_DAIFMT_IB_NF: /* Invert bit clock */ - val = SUN4I_I2S_FMT0_BCLK_POLARITY_INVERTED | - SUN4I_I2S_FMT0_LRCLK_POLARITY_NORMAL; + bclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; break; case SND_SOC_DAIFMT_NB_IF: /* Invert frame clock */ - val = SUN4I_I2S_FMT0_LRCLK_POLARITY_INVERTED | - SUN4I_I2S_FMT0_BCLK_POLARITY_NORMAL; + lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_INVERTED; break; case SND_SOC_DAIFMT_NB_NF: - /* Nothing to do for both normal cases */ - val = SUN4I_I2S_FMT0_BCLK_POLARITY_NORMAL | - SUN4I_I2S_FMT0_LRCLK_POLARITY_NORMAL; break; default: return -EINVAL; } - regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, - SUN4I_I2S_FMT0_BCLK_POLARITY_MASK | - SUN4I_I2S_FMT0_LRCLK_POLARITY_MASK, - val); + regmap_field_write(i2s->field_fmt_bclk, bclk_polarity); + regmap_field_write(i2s->field_fmt_lrclk, lrclk_polarity); /* DAI clock master masks */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -712,6 +715,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), + .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), + .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -724,6 +729,8 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), + .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), + .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -745,6 +752,18 @@ static int sun4i_i2s_init_regmap_fields(struct device *dev, if (IS_ERR(i2s->field_fmt_sr)) return PTR_ERR(i2s->field_fmt_sr); + i2s->field_fmt_bclk = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_bclk); + if (IS_ERR(i2s->field_fmt_bclk)) + return PTR_ERR(i2s->field_fmt_bclk); + + i2s->field_fmt_lrclk = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_lrclk); + if (IS_ERR(i2s->field_fmt_lrclk)) + return PTR_ERR(i2s->field_fmt_lrclk); + i2s->field_txchanmap = devm_regmap_field_alloc(dev, i2s->regmap, i2s->variant->field_txchanmap); -- cgit v1.1 From 5f93b0639634929b8349f9f9d83e1d881c1c7d4a Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:35 +0200 Subject: ASoC: sun4i-i2s: Add mclk enable regmap field The location of the mclk output enable bit is different on newer SoCs. Use a regmap field to enable it. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 8c7ad5b..761b7c0 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -101,6 +101,7 @@ * @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. * @fmt_offset: Value by which wss and sr needs to be adjusted. + * @field_clkdiv_mclk_en: regmap field to enable mclk output. * @field_fmt_wss: regmap field to set word select size. * @field_fmt_sr: regmap field to set sample resolution. * @field_fmt_bclk: regmap field to set clk polarity. @@ -119,6 +120,7 @@ struct sun4i_i2s_quirks { unsigned int fmt_offset; /* Register fields for i2s */ + struct reg_field field_clkdiv_mclk_en; struct reg_field field_fmt_wss; struct reg_field field_fmt_sr; struct reg_field field_fmt_bclk; @@ -141,6 +143,7 @@ struct sun4i_i2s { struct snd_dmaengine_dai_dma_data playback_dma_data; /* Register fields for i2s */ + struct regmap_field *field_clkdiv_mclk_en; struct regmap_field *field_fmt_wss; struct regmap_field *field_fmt_sr; struct regmap_field *field_fmt_bclk; @@ -283,8 +286,9 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s, regmap_write(i2s->regmap, SUN4I_I2S_CLK_DIV_REG, SUN4I_I2S_CLK_DIV_BCLK(bclk_div) | - SUN4I_I2S_CLK_DIV_MCLK(mclk_div) | - SUN4I_I2S_CLK_DIV_MCLK_EN); + SUN4I_I2S_CLK_DIV_MCLK(mclk_div)); + + regmap_field_write(i2s->field_clkdiv_mclk_en, 1); return 0; } @@ -713,6 +717,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .has_reset = false, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .field_clkdiv_mclk_en = REG_FIELD(SUN4I_I2S_CLK_DIV_REG, 7, 7), .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), @@ -727,6 +732,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .has_reset = true, .reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG, .sun4i_i2s_regmap = &sun4i_i2s_regmap_config, + .field_clkdiv_mclk_en = REG_FIELD(SUN4I_I2S_CLK_DIV_REG, 7, 7), .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 2, 3), .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), @@ -740,6 +746,12 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { static int sun4i_i2s_init_regmap_fields(struct device *dev, struct sun4i_i2s *i2s) { + i2s->field_clkdiv_mclk_en = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_clkdiv_mclk_en); + if (IS_ERR(i2s->field_clkdiv_mclk_en)) + return PTR_ERR(i2s->field_clkdiv_mclk_en); + i2s->field_fmt_wss = devm_regmap_field_alloc(dev, i2s->regmap, i2s->variant->field_fmt_wss); -- cgit v1.1 From dfd2293c8626f1282e6a6e30f591c0a83146f3d4 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:36 +0200 Subject: ASoC: sun4i-i2s: Add regmap field to set DAI format On the newer SoCs the bits to configure the operational mode are located in a different register. Add a regmap field so that this location can be configured. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 761b7c0..d9910f6 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -106,6 +106,7 @@ * @field_fmt_sr: regmap field to set sample resolution. * @field_fmt_bclk: regmap field to set clk polarity. * @field_fmt_lrclk: regmap field to set frame polarity. + * @field_fmt_mode: regmap field to set the operational mode. * @field_txchanmap: location of the tx channel mapping register. * @field_rxchanmap: location of the rx channel mapping register. * @field_txchansel: location of the tx channel select bit fields. @@ -125,6 +126,7 @@ struct sun4i_i2s_quirks { struct reg_field field_fmt_sr; struct reg_field field_fmt_bclk; struct reg_field field_fmt_lrclk; + struct reg_field field_fmt_mode; struct reg_field field_txchanmap; struct reg_field field_rxchanmap; struct reg_field field_txchansel; @@ -148,6 +150,7 @@ struct sun4i_i2s { struct regmap_field *field_fmt_sr; struct regmap_field *field_fmt_bclk; struct regmap_field *field_fmt_lrclk; + struct regmap_field *field_fmt_mode; struct regmap_field *field_txchanmap; struct regmap_field *field_rxchanmap; struct regmap_field *field_txchansel; @@ -365,9 +368,7 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, - SUN4I_I2S_FMT0_FMT_MASK, - val); + regmap_field_write(i2s->field_fmt_mode, val); /* DAI clock polarity */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { @@ -722,6 +723,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -737,6 +739,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2), @@ -776,6 +779,12 @@ static int sun4i_i2s_init_regmap_fields(struct device *dev, if (IS_ERR(i2s->field_fmt_lrclk)) return PTR_ERR(i2s->field_fmt_lrclk); + i2s->field_fmt_mode = + devm_regmap_field_alloc(dev, i2s->regmap, + i2s->variant->field_fmt_mode); + if (IS_ERR(i2s->field_fmt_mode)) + return PTR_ERR(i2s->field_fmt_mode); + i2s->field_txchanmap = devm_regmap_field_alloc(dev, i2s->regmap, i2s->variant->field_txchanmap); -- cgit v1.1 From d03d2737e2d20c6ffb242154a69e1a9313adb632 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:37 +0200 Subject: ASoC: sun4i-i2s: Check for slave select bit The newer SoCs do not have this setting. Instead they set the pin direction. Add a check to see if the bit is valid and if so set it accordingly. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index d9910f6..573acca 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -96,6 +96,7 @@ * struct sun4i_i2s_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. + * @has_slave_select_bit: SoC has a bit to enable slave mode. * @reg_offset_txdata: offset of the tx fifo. * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. @@ -114,6 +115,7 @@ */ struct sun4i_i2s_quirks { bool has_reset; + bool has_slave_select_bit; unsigned int reg_offset_txdata; /* TX FIFO */ const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; @@ -394,24 +396,25 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) regmap_field_write(i2s->field_fmt_bclk, bclk_polarity); regmap_field_write(i2s->field_fmt_lrclk, lrclk_polarity); - /* DAI clock master masks */ - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - /* BCLK and LRCLK master */ - val = SUN4I_I2S_CTRL_MODE_MASTER; - break; - case SND_SOC_DAIFMT_CBM_CFM: - /* BCLK and LRCLK slave */ - val = SUN4I_I2S_CTRL_MODE_SLAVE; - break; - default: - return -EINVAL; + if (i2s->variant->has_slave_select_bit) { + /* DAI clock master masks */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + /* BCLK and LRCLK master */ + val = SUN4I_I2S_CTRL_MODE_MASTER; + break; + case SND_SOC_DAIFMT_CBM_CFM: + /* BCLK and LRCLK slave */ + val = SUN4I_I2S_CTRL_MODE_SLAVE; + break; + default: + return -EINVAL; + } + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_MODE_MASK, + val); } - regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_MODE_MASK, - val); - /* Set significant bits in our FIFOs */ regmap_update_bits(i2s->regmap, SUN4I_I2S_FIFO_CTRL_REG, SUN4I_I2S_FIFO_CTRL_TX_MODE_MASK | @@ -723,6 +726,7 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .has_slave_select_bit = true, .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), @@ -739,6 +743,7 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 5), .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 6, 6), .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .has_slave_select_bit = true, .field_fmt_mode = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 1), .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31), .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31), -- cgit v1.1 From 043b8daa578f30c2ba685ad13b121fd138b95750 Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:38 +0200 Subject: ASoC: sun4i-i2s: Update global enable with bitmask The default value of the config register is different on newer SoCs and therefore enabling/disabling with a register write will clear bits used to set the direction of the clock and frame pins. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 573acca..19d50ca 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -529,8 +529,8 @@ static int sun4i_i2s_startup(struct snd_pcm_substream *substream, struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); /* Enable the whole hardware block */ - regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG, - SUN4I_I2S_CTRL_GL_EN); + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN); /* Enable the first output line */ regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, @@ -553,7 +553,8 @@ static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream, SUN4I_I2S_CTRL_SDO_EN_MASK, 0); /* Disable the whole hardware block */ - regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG, 0); + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_GL_EN, 0); } static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, -- cgit v1.1 From 7d2993811a1e07cd128847f07f63aae66a78d14b Mon Sep 17 00:00:00 2001 From: Marcus Cooper Date: Sat, 19 Aug 2017 14:48:39 +0200 Subject: ASoC: sun4i-i2s: Add support for H3 The sun8i-h3 introduces a lot of changes to the i2s block such as different register locations, extended clock division and more operational modes. As we have to consider the earlier implementation then these changes need to be isolated. None of the new functionality has been implemented yet, the driver has just been expanded to allow it work on the H3 SoC. Signed-off-by: Marcus Cooper Reviewed-by: Chen-Yu Tsai Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-i2s.c | 176 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 19d50ca..04f9258 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -92,11 +92,41 @@ #define SUN4I_I2S_RX_CHAN_SEL_REG 0x38 #define SUN4I_I2S_RX_CHAN_MAP_REG 0x3c +/* Defines required for sun8i-h3 support */ +#define SUN8I_I2S_CTRL_BCLK_OUT BIT(18) +#define SUN8I_I2S_CTRL_LRCK_OUT BIT(17) + +#define SUN8I_I2S_FMT0_LRCK_PERIOD_MASK GENMASK(17, 8) +#define SUN8I_I2S_FMT0_LRCK_PERIOD(period) ((period - 1) << 8) + +#define SUN8I_I2S_INT_STA_REG 0x0c +#define SUN8I_I2S_FIFO_TX_REG 0x20 + +#define SUN8I_I2S_CHAN_CFG_REG 0x30 +#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASK GENMASK(6, 4) +#define SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(chan) (chan - 1) +#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK GENMASK(2, 0) +#define SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(chan) (chan - 1) + +#define SUN8I_I2S_TX_CHAN_MAP_REG 0x44 +#define SUN8I_I2S_TX_CHAN_SEL_REG 0x34 +#define SUN8I_I2S_TX_CHAN_OFFSET_MASK GENMASK(13, 11) +#define SUN8I_I2S_TX_CHAN_OFFSET(offset) (offset << 12) +#define SUN8I_I2S_TX_CHAN_EN_MASK GENMASK(11, 4) +#define SUN8I_I2S_TX_CHAN_EN(num_chan) (((1 << num_chan) - 1) << 4) + +#define SUN8I_I2S_RX_CHAN_SEL_REG 0x54 +#define SUN8I_I2S_RX_CHAN_MAP_REG 0x58 + /** * struct sun4i_i2s_quirks - Differences between SoC variants. * * @has_reset: SoC needs reset deasserted. * @has_slave_select_bit: SoC has a bit to enable slave mode. + * @has_fmt_set_lrck_period: SoC requires lrclk period to be set. + * @has_chcfg: tx and rx slot number need to be set. + * @has_chsel_tx_chen: SoC requires that the tx channels are enabled. + * @has_chsel_offset: SoC uses offset for selecting dai operational mode. * @reg_offset_txdata: offset of the tx fifo. * @sun4i_i2s_regmap: regmap config to use. * @mclk_offset: Value by which mclkdiv needs to be adjusted. @@ -116,6 +146,10 @@ struct sun4i_i2s_quirks { bool has_reset; bool has_slave_select_bit; + bool has_fmt_set_lrck_period; + bool has_chcfg; + bool has_chsel_tx_chen; + bool has_chsel_offset; unsigned int reg_offset_txdata; /* TX FIFO */ const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; @@ -173,6 +207,7 @@ static const struct sun4i_i2s_clk_div sun4i_i2s_bclk_div[] = { { .div = 8, .val = 3 }, { .div = 12, .val = 4 }, { .div = 16, .val = 5 }, + /* TODO - extend divide ratio supported by newer SoCs */ }; static const struct sun4i_i2s_clk_div sun4i_i2s_mclk_div[] = { @@ -184,6 +219,7 @@ static const struct sun4i_i2s_clk_div sun4i_i2s_mclk_div[] = { { .div = 12, .val = 5 }, { .div = 16, .val = 6 }, { .div = 24, .val = 7 }, + /* TODO - extend divide ratio supported by newer SoCs */ }; static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s, @@ -295,6 +331,12 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s, regmap_field_write(i2s->field_clkdiv_mclk_en, 1); + /* Set sync period */ + if (i2s->variant->has_fmt_set_lrck_period) + regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, + SUN8I_I2S_FMT0_LRCK_PERIOD_MASK, + SUN8I_I2S_FMT0_LRCK_PERIOD(32)); + return 0; } @@ -303,12 +345,22 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); - int sr, wss; + int sr, wss, channels; u32 width; - if (params_channels(params) != 2) + channels = params_channels(params); + if (channels != 2) return -EINVAL; + if (i2s->variant->has_chcfg) { + regmap_update_bits(i2s->regmap, SUN8I_I2S_CHAN_CFG_REG, + SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM_MASK, + SUN8I_I2S_CHAN_CFG_TX_SLOT_NUM(channels)); + regmap_update_bits(i2s->regmap, SUN8I_I2S_CHAN_CFG_REG, + SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM_MASK, + SUN8I_I2S_CHAN_CFG_RX_SLOT_NUM(channels)); + } + /* Map the channels for playback and capture */ regmap_field_write(i2s->field_txchanmap, 0x76543210); regmap_field_write(i2s->field_rxchanmap, 0x00003210); @@ -320,6 +372,11 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, regmap_field_write(i2s->field_rxchansel, SUN4I_I2S_CHAN_SEL(params_channels(params))); + if (i2s->variant->has_chsel_tx_chen) + regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG, + SUN8I_I2S_TX_CHAN_EN_MASK, + SUN8I_I2S_TX_CHAN_EN(channels)); + switch (params_physical_width(params)) { case 16: width = DMA_SLAVE_BUSWIDTH_2_BYTES; @@ -352,6 +409,7 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); u32 val; + u32 offset = 0; u32 bclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL; u32 lrclk_polarity = SUN4I_I2S_FMT0_POLARITY_NORMAL; @@ -359,6 +417,7 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: val = SUN4I_I2S_FMT0_FMT_I2S; + offset = 1; break; case SND_SOC_DAIFMT_LEFT_J: val = SUN4I_I2S_FMT0_FMT_LEFT_J; @@ -370,6 +429,21 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } + if (i2s->variant->has_chsel_offset) { + /* + * offset being set indicates that we're connected to an i2s + * device, however offset is only used on the sun8i block and + * i2s shares the same setting with the LJ format. Increment + * val so that the bit to value to write is correct. + */ + if (offset > 0) + val++; + /* blck offset determines whether i2s or LJ */ + regmap_update_bits(i2s->regmap, SUN8I_I2S_TX_CHAN_SEL_REG, + SUN8I_I2S_TX_CHAN_OFFSET_MASK, + SUN8I_I2S_TX_CHAN_OFFSET(offset)); + } + regmap_field_write(i2s->field_fmt_mode, val); /* DAI clock polarity */ @@ -413,6 +487,29 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, SUN4I_I2S_CTRL_MODE_MASK, val); + } else { + /* + * The newer i2s block does not have a slave select bit, + * instead the clk pins are configured as inputs. + */ + /* DAI clock master masks */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + /* BCLK and LRCLK master */ + val = SUN8I_I2S_CTRL_BCLK_OUT | + SUN8I_I2S_CTRL_LRCK_OUT; + break; + case SND_SOC_DAIFMT_CBM_CFM: + /* BCLK and LRCLK slave */ + val = 0; + break; + default: + return -EINVAL; + } + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN8I_I2S_CTRL_BCLK_OUT | + SUN8I_I2S_CTRL_LRCK_OUT, + val); } /* Set significant bits in our FIFOs */ @@ -653,6 +750,27 @@ static bool sun4i_i2s_volatile_reg(struct device *dev, unsigned int reg) } } +static bool sun8i_i2s_rd_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case SUN8I_I2S_FIFO_TX_REG: + return false; + + default: + return true; + } +} + +static bool sun8i_i2s_volatile_reg(struct device *dev, unsigned int reg) +{ + if (reg == SUN8I_I2S_INT_STA_REG) + return true; + if (reg == SUN8I_I2S_FIFO_TX_REG) + return false; + + return sun4i_i2s_volatile_reg(dev, reg); +} + static const struct reg_default sun4i_i2s_reg_defaults[] = { { SUN4I_I2S_CTRL_REG, 0x00000000 }, { SUN4I_I2S_FMT0_REG, 0x0000000c }, @@ -666,6 +784,20 @@ static const struct reg_default sun4i_i2s_reg_defaults[] = { { SUN4I_I2S_RX_CHAN_MAP_REG, 0x00003210 }, }; +static const struct reg_default sun8i_i2s_reg_defaults[] = { + { SUN4I_I2S_CTRL_REG, 0x00060000 }, + { SUN4I_I2S_FMT0_REG, 0x00000033 }, + { SUN4I_I2S_FMT1_REG, 0x00000030 }, + { SUN4I_I2S_FIFO_CTRL_REG, 0x000400f0 }, + { SUN4I_I2S_DMA_INT_CTRL_REG, 0x00000000 }, + { SUN4I_I2S_CLK_DIV_REG, 0x00000000 }, + { SUN8I_I2S_CHAN_CFG_REG, 0x00000000 }, + { SUN8I_I2S_TX_CHAN_SEL_REG, 0x00000000 }, + { SUN8I_I2S_TX_CHAN_MAP_REG, 0x00000000 }, + { SUN8I_I2S_RX_CHAN_SEL_REG, 0x00000000 }, + { SUN8I_I2S_RX_CHAN_MAP_REG, 0x00000000 }, +}; + static const struct regmap_config sun4i_i2s_regmap_config = { .reg_bits = 32, .reg_stride = 4, @@ -680,6 +812,19 @@ static const struct regmap_config sun4i_i2s_regmap_config = { .volatile_reg = sun4i_i2s_volatile_reg, }; +static const struct regmap_config sun8i_i2s_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = SUN8I_I2S_RX_CHAN_MAP_REG, + .cache_type = REGCACHE_FLAT, + .reg_defaults = sun8i_i2s_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(sun8i_i2s_reg_defaults), + .writeable_reg = sun4i_i2s_wr_reg, + .readable_reg = sun8i_i2s_rd_reg, + .volatile_reg = sun8i_i2s_volatile_reg, +}; + static int sun4i_i2s_runtime_resume(struct device *dev) { struct sun4i_i2s *i2s = dev_get_drvdata(dev); @@ -752,6 +897,29 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .field_rxchansel = REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2), }; +static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { + .has_reset = true, + .reg_offset_txdata = SUN8I_I2S_FIFO_TX_REG, + .sun4i_i2s_regmap = &sun8i_i2s_regmap_config, + .mclk_offset = 1, + .bclk_offset = 2, + .fmt_offset = 3, + .has_fmt_set_lrck_period = true, + .has_chcfg = true, + .has_chsel_tx_chen = true, + .has_chsel_offset = true, + .field_clkdiv_mclk_en = REG_FIELD(SUN4I_I2S_CLK_DIV_REG, 8, 8), + .field_fmt_wss = REG_FIELD(SUN4I_I2S_FMT0_REG, 0, 2), + .field_fmt_sr = REG_FIELD(SUN4I_I2S_FMT0_REG, 4, 6), + .field_fmt_bclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 7, 7), + .field_fmt_lrclk = REG_FIELD(SUN4I_I2S_FMT0_REG, 19, 19), + .field_fmt_mode = REG_FIELD(SUN4I_I2S_CTRL_REG, 4, 5), + .field_txchanmap = REG_FIELD(SUN8I_I2S_TX_CHAN_MAP_REG, 0, 31), + .field_rxchanmap = REG_FIELD(SUN8I_I2S_RX_CHAN_MAP_REG, 0, 31), + .field_txchansel = REG_FIELD(SUN8I_I2S_TX_CHAN_SEL_REG, 0, 2), + .field_rxchansel = REG_FIELD(SUN8I_I2S_RX_CHAN_SEL_REG, 0, 2), +}; + static int sun4i_i2s_init_regmap_fields(struct device *dev, struct sun4i_i2s *i2s) { @@ -952,6 +1120,10 @@ static const struct of_device_id sun4i_i2s_match[] = { .compatible = "allwinner,sun6i-a31-i2s", .data = &sun6i_a31_i2s_quirks, }, + { + .compatible = "allwinner,sun8i-h3-i2s", + .data = &sun8i_h3_i2s_quirks, + }, {} }; MODULE_DEVICE_TABLE(of, sun4i_i2s_match); -- cgit v1.1 From e5d619e9b924c03b4e5e6be7c03f1346150104b9 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 18 Aug 2017 18:33:35 +0200 Subject: ASoC: fsl-asoc-card: don't print EPROBE_DEFER as error Probe deferral is to be expected during normal operation, so avoid printing an error when it is encountered. Signed-off-by: Lucas Stach Reviewed-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl-asoc-card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 9998aea..2db4d0c 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -683,7 +683,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(&priv->card, priv); ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); - if (ret) + if (ret && ret != -EPROBE_DEFER) dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); asrc_fail: -- cgit v1.1 From b286401752c61de9c2335a1c9748243bb53649de Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 13:22:00 +0800 Subject: ASoC: mediatek: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 1 - sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 1 - sound/soc/mediatek/mt8173/mt8173-rt5650.c | 1 - 3 files changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c index 5e383eb..99c1521 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c @@ -222,7 +222,6 @@ static int mt8173_rt5650_rt5514_dev_probe(struct platform_device *pdev) mt8173_rt5650_rt5514_codecs[1].of_node; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c index fed1f15..42de84c 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c @@ -279,7 +279,6 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev) } card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c index a784708..e69c141 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c @@ -311,7 +311,6 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev) return -EINVAL; } card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) -- cgit v1.1 From e4eabf75ad9a0d4afb4a35c8c4fac7e437d5da06 Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 14:02:17 +0800 Subject: ASoC: tegra: Remove unnecessary function call First of all,the address of pdev->dev is assigned to card->dev,then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data, but when calling snd_soc_register_card,the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/tegra/tegra_alc5632.c | 1 - sound/soc/tegra/tegra_max98090.c | 1 - sound/soc/tegra/tegra_rt5640.c | 1 - sound/soc/tegra/tegra_rt5677.c | 1 - sound/soc/tegra/tegra_sgtl5000.c | 1 - sound/soc/tegra/tegra_wm8753.c | 1 - sound/soc/tegra/tegra_wm8903.c | 1 - sound/soc/tegra/tegra_wm9712.c | 1 - sound/soc/tegra/trimslice.c | 1 - 9 files changed, 9 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index 0509902..053fe4c 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c @@ -173,7 +173,6 @@ static int tegra_alc5632_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, alc5632); alc5632->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index c34a54d..41feee9 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c @@ -229,7 +229,6 @@ static int tegra_max98090_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c index 93a3568..02f27fe 100644 --- a/sound/soc/tegra/tegra_rt5640.c +++ b/sound/soc/tegra/tegra_rt5640.c @@ -174,7 +174,6 @@ static int tegra_rt5640_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); machine->gpio_hp_det = of_get_named_gpio_flags( diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c index ebf58d0..3dbf0e1 100644 --- a/sound/soc/tegra/tegra_rt5677.c +++ b/sound/soc/tegra/tegra_rt5677.c @@ -222,7 +222,6 @@ static int tegra_rt5677_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); diff --git a/sound/soc/tegra/tegra_sgtl5000.c b/sound/soc/tegra/tegra_sgtl5000.c index 6dda01f..45a4aa9 100644 --- a/sound/soc/tegra/tegra_sgtl5000.c +++ b/sound/soc/tegra/tegra_sgtl5000.c @@ -124,7 +124,6 @@ static int tegra_sgtl5000_driver_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); ret = snd_soc_of_parse_card_name(card, "nvidia,model"); diff --git a/sound/soc/tegra/tegra_wm8753.c b/sound/soc/tegra/tegra_wm8753.c index d0ab0026..23a810e 100644 --- a/sound/soc/tegra/tegra_wm8753.c +++ b/sound/soc/tegra/tegra_wm8753.c @@ -132,7 +132,6 @@ static int tegra_wm8753_driver_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); ret = snd_soc_of_parse_card_name(card, "nvidia,model"); diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index dbfb492..d4a4a2b 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -252,7 +252,6 @@ static int tegra_wm8903_driver_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); machine->gpio_spkr_en = of_get_named_gpio(np, "nvidia,spkr-en-gpios", diff --git a/sound/soc/tegra/tegra_wm9712.c b/sound/soc/tegra/tegra_wm9712.c index c9cd224..864a334 100644 --- a/sound/soc/tegra/tegra_wm9712.c +++ b/sound/soc/tegra/tegra_wm9712.c @@ -81,7 +81,6 @@ static int tegra_wm9712_driver_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); machine->codec = platform_device_alloc("wm9712-codec", -1); diff --git a/sound/soc/tegra/trimslice.c b/sound/soc/tegra/trimslice.c index c9dcad9..99bcdd9 100644 --- a/sound/soc/tegra/trimslice.c +++ b/sound/soc/tegra/trimslice.c @@ -127,7 +127,6 @@ static int tegra_snd_trimslice_probe(struct platform_device *pdev) return -ENOMEM; card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, trimslice); trimslice_tlv320aic23_dai.codec_of_node = of_parse_phandle(np, -- cgit v1.1 From c996b52df44b83d227d7664d2838ed1c6739c850 Mon Sep 17 00:00:00 2001 From: Donglin Peng Date: Sun, 20 Aug 2017 14:01:10 +0800 Subject: ASoC: ux500: Remove unnecessary function call First of all,the address of pdev->dev is assigned to mop500_card.dev, then the function platform_set_drvdata copies the value the variable card to pdev->dev.driver_data,but when calling snd_soc_register_card, the function dev_set_drvdata(card->dev, card) will also do the same copy operation,so i think that the former copy operation can be removed. Signed-off-by: Peng Donglin Signed-off-by: Mark Brown --- sound/soc/ux500/mop500.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c index b50f68a..9298580 100644 --- a/sound/soc/ux500/mop500.c +++ b/sound/soc/ux500/mop500.c @@ -111,7 +111,6 @@ static int mop500_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n", __func__, mop500_card.name); - platform_set_drvdata(pdev, &mop500_card); snd_soc_card_set_drvdata(&mop500_card, NULL); -- cgit v1.1 From e269998d588f8ad96eaf86916e23b8ee3d2b9f1b Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 17 Aug 2017 10:02:09 +0200 Subject: ASoC: codecs: msm8916-wcd-analog: get micbias voltage from dt This patch adds bindings in DT to provide required micbias voltage which could be specific to board. With this new binding, now the mic bias voltage is left at hardware default value if the device tree does not specify any mic bias voltage value. Correct micbias value is required for mbhc buttons to work. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a0de3e7..8633524 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -93,8 +93,12 @@ #define MICB_1_EN_TX3_GND_SEL_TX_GND 0 #define CDC_A_MICB_1_VAL (0xf141) +#define MICB_MIN_VAL 1600 +#define MICB_STEP_SIZE 50 +#define MICB_VOLTAGE_REGVAL(v) ((v - MICB_MIN_VAL)/MICB_STEP_SIZE) #define MICB_1_VAL_MICB_OUT_VAL_MASK GENMASK(7, 3) #define MICB_1_VAL_MICB_OUT_VAL_V2P70V ((0x16) << 3) +#define MICB_1_VAL_MICB_OUT_VAL_V1P80V ((0x4) << 3) #define CDC_A_MICB_1_CTL (0xf142) #define MICB_1_CTL_CFILT_REF_SEL_MASK BIT(1) @@ -225,6 +229,7 @@ struct pm8916_wcd_analog_priv { struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; unsigned int micbias1_cap_mode; unsigned int micbias2_cap_mode; + unsigned int micbias_mv; }; static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" }; @@ -265,18 +270,25 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = { static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) { + struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE); - snd_soc_write(codec, CDC_A_MICB_1_VAL, MICB_1_VAL_MICB_OUT_VAL_V2P70V); - /* - * Special headset needs MICBIAS as 2.7V so wait for - * 50 msec for the MICBIAS to reach 2.7 volts. - */ - msleep(50); + if (wcd->micbias_mv) { + snd_soc_write(codec, CDC_A_MICB_1_VAL, + MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); + /* + * Special headset needs MICBIAS as 2.7V so wait for + * 50 msec for the MICBIAS to reach 2.7 volts. + */ + if (wcd->micbias_mv >= 2700) + msleep(50); + } + snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0); @@ -795,6 +807,9 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev, else priv->micbias2_cap_mode = MICB_1_EN_NO_EXT_BYP_CAP; + of_property_read_u32(dev->of_node, "qcom,micbias-lvl", + &priv->micbias_mv); + return 0; } -- cgit v1.1 From de66b3455023e6f78fdf55a387c604c6b0114869 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 17 Aug 2017 10:02:10 +0200 Subject: ASoC: codecs: msm8916-wcd-analog: add MBHC support MBHC (MultiButton Headset Control) support is available in pm8921 in two blocks, one to detect mechanical headset insertion and removal and other block to support headset type detection and 5 button detection and othe features like impedance calculation. This patch adds support to: 1> Support to NC and NO type of headset Jacks. 2> Mechanical insertion and detection of headset jack. 3> Detect a 3 pole Headphone and a 4 pole Headset. 4> Detect 5 buttons. Tested it on DB410c with Audio Mezz board with 4 pole and 3 pole headset/headphones. Signed-off-by: Srinivas Kandagatla Tested-by: Damien Riegel Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 373 +++++++++++++++++++++++++++++++++- 1 file changed, 372 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 8633524..f834a63 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -12,9 +12,16 @@ #include #include #include +#include #define CDC_D_REVISION1 (0xf000) #define CDC_D_PERPH_SUBTYPE (0xf005) +#define CDC_D_INT_EN_SET (0x015) +#define CDC_D_INT_EN_CLR (0x016) +#define MBHC_SWITCH_INT BIT(7) +#define MBHC_MIC_ELECTRICAL_INS_REM_DET BIT(6) +#define MBHC_BUTTON_PRESS_DET BIT(5) +#define MBHC_BUTTON_RELEASE_DET BIT(4) #define CDC_D_CDC_RST_CTL (0xf046) #define RST_CTL_DIG_SW_RST_N_MASK BIT(7) #define RST_CTL_DIG_SW_RST_N_RESET 0 @@ -37,6 +44,8 @@ #define DIG_CLK_CTL_RXD1_CLK_EN BIT(0) #define DIG_CLK_CTL_RXD2_CLK_EN BIT(1) #define DIG_CLK_CTL_RXD3_CLK_EN BIT(2) +#define DIG_CLK_CTL_D_MBHC_CLK_EN_MASK BIT(3) +#define DIG_CLK_CTL_D_MBHC_CLK_EN BIT(3) #define DIG_CLK_CTL_TXD_CLK_EN BIT(4) #define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6) #define DIG_CLK_CTL_NCP_CLK_EN BIT(6) @@ -132,8 +141,51 @@ #define MICB_1_INT_TX3_INT_PULLUP_EN_TX1N_TO_GND 0 #define CDC_A_MICB_2_EN (0xf144) +#define CDC_A_MICB_2_EN_ENABLE BIT(7) +#define CDC_A_MICB_2_PULL_DOWN_EN_MASK BIT(5) +#define CDC_A_MICB_2_PULL_DOWN_EN BIT(5) #define CDC_A_TX_1_2_ATEST_CTL_2 (0xf145) #define CDC_A_MASTER_BIAS_CTL (0xf146) +#define CDC_A_MBHC_DET_CTL_1 (0xf147) +#define CDC_A_MBHC_DET_CTL_L_DET_EN BIT(7) +#define CDC_A_MBHC_DET_CTL_GND_DET_EN BIT(6) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION BIT(5) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_REMOVAL (0) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK BIT(5) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT (5) +#define CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO BIT(4) +#define CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_MANUAL BIT(3) +#define CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_MASK GENMASK(4, 3) +#define CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN BIT(2) +#define CDC_A_MBHC_DET_CTL_2 (0xf150) +#define CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 (BIT(7) | BIT(6)) +#define CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD BIT(5) +#define CDC_A_PLUG_TYPE_MASK GENMASK(4, 3) +#define CDC_A_HPHL_PLUG_TYPE_NO BIT(4) +#define CDC_A_GND_PLUG_TYPE_NO BIT(3) +#define CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN_MASK BIT(0) +#define CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN BIT(0) +#define CDC_A_MBHC_FSM_CTL (0xf151) +#define CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN BIT(7) +#define CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK BIT(7) +#define CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA (0x3 << 4) +#define CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK GENMASK(6, 4) +#define CDC_A_MBHC_DBNC_TIMER (0xf152) +#define CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS BIT(3) +#define CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS (0x9 << 4) +#define CDC_A_MBHC_BTN0_ZDET_CTL_0 (0xf153) +#define CDC_A_MBHC_BTN1_ZDET_CTL_1 (0xf154) +#define CDC_A_MBHC_BTN2_ZDET_CTL_2 (0xf155) +#define CDC_A_MBHC_BTN3_CTL (0xf156) +#define CDC_A_MBHC_BTN4_CTL (0xf157) +#define CDC_A_MBHC_BTN_VREF_FINE_SHIFT (2) +#define CDC_A_MBHC_BTN_VREF_FINE_MASK GENMASK(4, 2) +#define CDC_A_MBHC_BTN_VREF_COARSE_MASK GENMASK(7, 5) +#define CDC_A_MBHC_BTN_VREF_COARSE_SHIFT (5) +#define CDC_A_MBHC_BTN_VREF_MASK (CDC_A_MBHC_BTN_VREF_COARSE_MASK | \ + CDC_A_MBHC_BTN_VREF_FINE_MASK) +#define CDC_A_MBHC_RESULT_1 (0xf158) +#define CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK GENMASK(4, 0) #define CDC_A_TX_1_EN (0xf160) #define CDC_A_TX_2_EN (0xf161) #define CDC_A_TX_1_2_TEST_CTL_1 (0xf162) @@ -217,16 +269,34 @@ #define MSM8916_WCD_ANALOG_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ SNDRV_PCM_FMTBIT_S24_LE) +static int btn_mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_BTN_4; +static int hs_jack_mask = SND_JACK_HEADPHONE | SND_JACK_HEADSET; + static const char * const supply_names[] = { "vdd-cdc-io", "vdd-cdc-tx-rx-cx", }; +#define MBHC_MAX_BUTTONS (5) + struct pm8916_wcd_analog_priv { u16 pmic_rev; u16 codec_version; + bool mbhc_btn_enabled; + /* special event to detect accessory type */ + bool mbhc_btn0_pressed; + bool detect_accessory_type; struct clk *mclk; + struct snd_soc_codec *codec; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; + struct snd_soc_jack *jack; + bool hphl_jack_type_normally_open; + bool gnd_jack_type_normally_open; + /* Voltage threshold when internal current source of 100uA is used */ + u32 vref_btn_cs[MBHC_MAX_BUTTONS]; + /* Voltage threshold when microphone bias is ON */ + u32 vref_btn_micb[MBHC_MAX_BUTTONS]; unsigned int micbias1_cap_mode; unsigned int micbias2_cap_mode; unsigned int micbias_mv; @@ -373,6 +443,97 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct wcd->micbias1_cap_mode); } +static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) +{ + struct snd_soc_codec *codec = wcd->codec; + u32 plug_type = 0; + u32 int_en_mask; + + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, + CDC_A_MBHC_DET_CTL_L_DET_EN | + CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION | + CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO | + CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN); + + if (wcd->hphl_jack_type_normally_open) + plug_type |= CDC_A_HPHL_PLUG_TYPE_NO; + + if (wcd->gnd_jack_type_normally_open) + plug_type |= CDC_A_GND_PLUG_TYPE_NO; + + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, + CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 | + CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD | + plug_type | + CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN); + + + snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, + CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS | + CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS); + + /* enable MBHC clock */ + snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL, + DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, + DIG_CLK_CTL_D_MBHC_CLK_EN); + + int_en_mask = MBHC_SWITCH_INT; + if (wcd->mbhc_btn_enabled) + int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET; + + snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0); + snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask); + wcd->mbhc_btn0_pressed = false; + wcd->detect_accessory_type = true; +} + +static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, + bool micbias2_enabled) +{ + struct snd_soc_codec *codec = priv->codec; + u32 coarse, fine, reg_val, reg_addr; + int *vrefs, i; + + if (!micbias2_enabled) { /* use internal 100uA Current source */ + /* Enable internal 2.2k Internal Rbias Resistor */ + snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, + MICB_1_INT_TX2_INT_RBIAS_EN_MASK, + MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); + /* Remove pull down on MIC BIAS2 */ + snd_soc_update_bits(codec, CDC_A_MICB_2_EN, + CDC_A_MICB_2_PULL_DOWN_EN_MASK, + 0); + /* enable 100uA internal current source */ + snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK, + CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA); + } + snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK, + CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN); + + if (micbias2_enabled) + vrefs = &priv->vref_btn_micb[0]; + else + vrefs = &priv->vref_btn_cs[0]; + + /* program vref ranges for all the buttons */ + reg_addr = CDC_A_MBHC_BTN0_ZDET_CTL_0; + for (i = 0; i < MBHC_MAX_BUTTONS; i++) { + /* split mv in to coarse parts of 100mv & fine parts of 12mv */ + coarse = (vrefs[i] / 100); + fine = ((vrefs[i] % 100) / 12); + reg_val = (coarse << CDC_A_MBHC_BTN_VREF_COARSE_SHIFT) | + (fine << CDC_A_MBHC_BTN_VREF_FINE_SHIFT); + snd_soc_update_bits(codec, reg_addr, + CDC_A_MBHC_BTN_VREF_MASK, + reg_val); + reg_addr++; + } + + return 0; +} + static int pm8916_wcd_analog_enable_micbias_int2(struct snd_soc_dapm_widget *w, struct snd_kcontrol @@ -381,6 +542,15 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + switch (event) { + case SND_SOC_DAPM_POST_PMU: + pm8916_mbhc_configure_bias(wcd, true); + break; + case SND_SOC_DAPM_POST_PMD: + pm8916_mbhc_configure_bias(wcd, false); + break; + } + return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, wcd->micbias2_cap_mode); } @@ -548,9 +718,14 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, wcd_reg_defaults_2_0[reg].def); + priv->codec = codec; + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, RST_CTL_DIG_SW_RST_N_MASK, RST_CTL_DIG_SW_RST_N_REMOVE_RESET); + + pm8916_wcd_setup_mbhc(priv); + return 0; } @@ -749,11 +924,130 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("A_MCLK2", CDC_D_CDC_TOP_CLK_CTL, 3, 0, NULL, 0), }; +static int pm8916_wcd_analog_set_jack(struct snd_soc_codec *codec, + struct snd_soc_jack *jack, + void *data) +{ + struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + + wcd->jack = jack; + + return 0; +} + static struct regmap *pm8916_get_regmap(struct device *dev) { return dev_get_regmap(dev->parent, NULL); } +static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) +{ + struct pm8916_wcd_analog_priv *priv = arg; + + if (priv->detect_accessory_type) { + struct snd_soc_codec *codec = priv->codec; + u32 val = snd_soc_read(codec, CDC_A_MBHC_RESULT_1); + + /* check if its BTN0 thats released */ + if ((val >= 0) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) + priv->mbhc_btn0_pressed = false; + + } else { + snd_soc_jack_report(priv->jack, 0, btn_mask); + } + + return IRQ_HANDLED; +} + +static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) +{ + struct pm8916_wcd_analog_priv *priv = arg; + struct snd_soc_codec *codec = priv->codec; + u32 btn_result; + + btn_result = snd_soc_read(codec, CDC_A_MBHC_RESULT_1) & + CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; + + switch (btn_result) { + case 0xf: + snd_soc_jack_report(priv->jack, SND_JACK_BTN_4, btn_mask); + break; + case 0x7: + snd_soc_jack_report(priv->jack, SND_JACK_BTN_3, btn_mask); + break; + case 0x3: + snd_soc_jack_report(priv->jack, SND_JACK_BTN_2, btn_mask); + break; + case 0x1: + snd_soc_jack_report(priv->jack, SND_JACK_BTN_1, btn_mask); + break; + case 0x0: + /* handle BTN_0 specially for type detection */ + if (priv->detect_accessory_type) + priv->mbhc_btn0_pressed = true; + else + snd_soc_jack_report(priv->jack, + SND_JACK_BTN_0, btn_mask); + break; + default: + dev_err(codec->dev, + "Unexpected button press result (%x)", btn_result); + break; + } + + return IRQ_HANDLED; +} + + +static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) +{ + struct pm8916_wcd_analog_priv *priv = arg; + struct snd_soc_codec *codec = priv->codec; + bool ins = false; + + if (snd_soc_read(codec, CDC_A_MBHC_DET_CTL_1) & + CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) + ins = true; + + /* Set the detection type appropriately */ + snd_soc_update_bits(codec, CDC_A_MBHC_DET_CTL_1, + CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK, + (!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT)); + + + if (ins) { /* hs insertion */ + bool micbias_enabled = false; + + if (snd_soc_read(codec, CDC_A_MICB_2_EN) & + CDC_A_MICB_2_EN_ENABLE) + micbias_enabled = true; + + pm8916_mbhc_configure_bias(priv, micbias_enabled); + + /* + * if only a btn0 press event is receive just before + * insert event then its a 3 pole headphone else if + * both press and release event received then its + * a headset. + */ + if (priv->mbhc_btn0_pressed) + snd_soc_jack_report(priv->jack, + SND_JACK_HEADPHONE, hs_jack_mask); + else + snd_soc_jack_report(priv->jack, + SND_JACK_HEADSET, hs_jack_mask); + + priv->detect_accessory_type = false; + + } else { /* removal */ + snd_soc_jack_report(priv->jack, 0, hs_jack_mask); + priv->detect_accessory_type = true; + priv->mbhc_btn0_pressed = false; + } + + return IRQ_HANDLED; +} + static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { [0] = { .name = "pm8916_wcd_analog_pdm_rx", @@ -782,6 +1076,7 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { static const struct snd_soc_codec_driver pm8916_wcd_analog = { .probe = pm8916_wcd_analog_probe, .remove = pm8916_wcd_analog_remove, + .set_jack = pm8916_wcd_analog_set_jack, .get_regmap = pm8916_get_regmap, .component_driver = { .controls = pm8916_wcd_analog_snd_controls, @@ -796,6 +1091,7 @@ static const struct snd_soc_codec_driver pm8916_wcd_analog = { static int pm8916_wcd_analog_parse_dt(struct device *dev, struct pm8916_wcd_analog_priv *priv) { + int rval; if (of_property_read_bool(dev->of_node, "qcom,micbias1-ext-cap")) priv->micbias1_cap_mode = MICB_1_EN_EXT_BYP_CAP; @@ -810,6 +1106,39 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev, of_property_read_u32(dev->of_node, "qcom,micbias-lvl", &priv->micbias_mv); + if (of_property_read_bool(dev->of_node, + "qcom,hphl-jack-type-normally-open")) + priv->hphl_jack_type_normally_open = true; + else + priv->hphl_jack_type_normally_open = false; + + if (of_property_read_bool(dev->of_node, + "qcom,gnd-jack-type-normally-open")) + priv->gnd_jack_type_normally_open = true; + else + priv->gnd_jack_type_normally_open = false; + + priv->mbhc_btn_enabled = true; + rval = of_property_read_u32_array(dev->of_node, + "qcom,mbhc-vthreshold-low", + &priv->vref_btn_cs[0], + MBHC_MAX_BUTTONS); + if (rval < 0) { + priv->mbhc_btn_enabled = false; + } else { + rval = of_property_read_u32_array(dev->of_node, + "qcom,mbhc-vthreshold-high", + &priv->vref_btn_micb[0], + MBHC_MAX_BUTTONS); + if (rval < 0) + priv->mbhc_btn_enabled = false; + } + + if (!priv->mbhc_btn_enabled) + dev_err(dev, + "DT property missing, MBHC btn detection disabled\n"); + + return 0; } @@ -817,7 +1146,7 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev) { struct pm8916_wcd_analog_priv *priv; struct device *dev = &pdev->dev; - int ret, i; + int ret, i, irq; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -849,6 +1178,48 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev) return ret; } + irq = platform_get_irq_byname(pdev, "mbhc_switch_int"); + if (irq < 0) { + dev_err(dev, "failed to get mbhc switch irq\n"); + return irq; + } + + ret = devm_request_irq(dev, irq, pm8916_mbhc_switch_irq_handler, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "mbhc switch irq", priv); + if (ret) + dev_err(dev, "cannot request mbhc switch irq\n"); + + if (priv->mbhc_btn_enabled) { + irq = platform_get_irq_byname(pdev, "mbhc_but_press_det"); + if (irq < 0) { + dev_err(dev, "failed to get button press irq\n"); + return irq; + } + + ret = devm_request_irq(dev, irq, mbhc_btn_press_irq_handler, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "mbhc btn press irq", priv); + if (ret) + dev_err(dev, "cannot request mbhc button press irq\n"); + + irq = platform_get_irq_byname(pdev, "mbhc_but_rel_det"); + if (irq < 0) { + dev_err(dev, "failed to get button release irq\n"); + return irq; + } + + ret = devm_request_irq(dev, irq, mbhc_btn_release_irq_handler, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "mbhc btn release irq", priv); + if (ret) + dev_err(dev, "cannot request mbhc button release irq\n"); + + } + dev_set_drvdata(dev, priv); return snd_soc_register_codec(dev, &pm8916_wcd_analog, -- cgit v1.1 From b47b91c8504c62f95ddff2876620d68697927bd4 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Thu, 17 Aug 2017 10:02:11 +0200 Subject: ASoC: qcom: apq8016-sbc: Add support to Headset JACK This patch adds support to Headset JACK, also provides board specific vref ranges for mbhc buttons to be detected. This headset supports both 3 pole and 4 pole headset type and 5 buttons. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- sound/soc/qcom/apq8016_sbc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sound') diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index 96a079d..d49adc8 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -21,12 +21,16 @@ #include #include #include +#include #include +#include #include struct apq8016_sbc_data { void __iomem *mic_iomux; void __iomem *spkr_iomux; + struct snd_soc_jack jack; + bool jack_setup; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -70,6 +74,31 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) } + if (!pdata->jack_setup) { + struct snd_jack *jack; + + rval = snd_soc_card_jack_new(card, "Headset Jack", + SND_JACK_HEADSET | + SND_JACK_HEADPHONE | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | + SND_JACK_BTN_4, + &pdata->jack, NULL, 0); + + if (rval < 0) { + dev_err(card->dev, "Unable to add Headphone Jack\n"); + return rval; + } + + jack = pdata->jack.jack; + + snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + pdata->jack_setup = true; + } + for (i = 0 ; i < dai_link->num_codecs; i++) { struct snd_soc_dai *dai = rtd->codec_dais[i]; @@ -81,6 +110,11 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) dev_warn(card->dev, "Failed to set mclk: %d\n", rval); return rval; } + rval = snd_soc_codec_set_jack(codec, &pdata->jack, NULL); + if (rval != 0 && rval != -ENOTSUPP) { + dev_warn(card->dev, "Failed to set jack: %d\n", rval); + return rval; + } } return 0; -- cgit v1.1 From 80b649039240ec41a6ab0a5e347853bc78abfd2d Mon Sep 17 00:00:00 2001 From: Harsha Priya N Date: Mon, 21 Aug 2017 12:26:52 -0700 Subject: ASoC: Intel: Headset button support in kabylake machine driver This patch adds headset button support for kabylake machine driver (kbl_rt5663_rt5514_max98927). Signed-off-by: Hsin-yu Chao Signed-off-by: Harsha Priya Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index b51dff6..69681b0 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -18,6 +18,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -176,6 +177,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) int ret; struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_jack *jack; /* * Headset buttons map to the google Reference headset. @@ -190,6 +192,12 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } + jack = &ctx->kabylake_headset; + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + rt5663_set_jack_detect(codec, &ctx->kabylake_headset); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC"); -- cgit v1.1 From bd29ae969042c87413157c02d4f2a787d0212da3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:44 +0200 Subject: ASoC: jack: Manage gpios via devres Let's be lazy -- this patch adds the devres code to snd_soc_jack_add_gpios() for releasing the gpio resources at device removal automagically. After this patch, you don't have to call snd_soc_jack_free_gpios() manually as long as it's managed from the machine driver. What about the gpios assigned in other levels? Well, you might still need to free the resources manually, depending on how the component unbind works. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/soc-jack.c | 52 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 42ca9f1..4c83734 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -22,6 +22,12 @@ #include #include +struct jack_gpio_tbl { + int count; + struct snd_soc_jack *jack; + struct snd_soc_jack_gpio *gpios; +}; + /** * snd_soc_codec_set_jack - configure codec jack. * @codec: CODEC @@ -333,6 +339,28 @@ static int snd_soc_jack_pm_notifier(struct notifier_block *nb, return NOTIFY_DONE; } +static void jack_free_gpios(struct snd_soc_jack *jack, int count, + struct snd_soc_jack_gpio *gpios) +{ + int i; + + for (i = 0; i < count; i++) { + gpiod_unexport(gpios[i].desc); + unregister_pm_notifier(&gpios[i].pm_notifier); + free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]); + cancel_delayed_work_sync(&gpios[i].work); + gpiod_put(gpios[i].desc); + gpios[i].jack = NULL; + } +} + +static void jack_devres_free_gpios(struct device *dev, void *res) +{ + struct jack_gpio_tbl *tbl = res; + + jack_free_gpios(tbl->jack, tbl->count, tbl->gpios); +} + /** * snd_soc_jack_add_gpios - Associate GPIO pins with an ASoC jack * @@ -347,6 +375,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios) { int i, ret; + struct jack_gpio_tbl *tbl; + + tbl = devres_alloc(jack_devres_free_gpios, sizeof(*tbl), GFP_KERNEL); + if (!tbl) + return -ENOMEM; + tbl->jack = jack; + tbl->count = count; + tbl->gpios = gpios; for (i = 0; i < count; i++) { if (!gpios[i].name) { @@ -424,12 +460,14 @@ got_gpio: msecs_to_jiffies(gpios[i].debounce_time)); } + devres_add(jack->card->dev, tbl); return 0; err: gpio_free(gpios[i].gpio); undo: - snd_soc_jack_free_gpios(jack, i, gpios); + jack_free_gpios(jack, i, gpios); + devres_free(tbl); return ret; } @@ -471,16 +509,8 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpiods); void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, struct snd_soc_jack_gpio *gpios) { - int i; - - for (i = 0; i < count; i++) { - gpiod_unexport(gpios[i].desc); - unregister_pm_notifier(&gpios[i].pm_notifier); - free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]); - cancel_delayed_work_sync(&gpios[i].work); - gpiod_put(gpios[i].desc); - gpios[i].jack = NULL; - } + jack_free_gpios(jack, count, gpios); + devres_destroy(jack->card->dev, jack_devres_free_gpios, NULL, NULL); } EXPORT_SYMBOL_GPL(snd_soc_jack_free_gpios); #endif /* CONFIG_GPIOLIB */ -- cgit v1.1 From 8244fd7e489a586e63a36302105a2a1ece28a3c6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:45 +0200 Subject: ASoC: fsl: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/fsl/imx-es8328.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c index 20e7400..9953438 100644 --- a/sound/soc/fsl/imx-es8328.c +++ b/sound/soc/fsl/imx-es8328.c @@ -203,9 +203,6 @@ static int imx_es8328_remove(struct platform_device *pdev) { struct imx_es8328_data *data = platform_get_drvdata(pdev); - snd_soc_jack_free_gpios(&headset_jack, ARRAY_SIZE(headset_jack_gpios), - headset_jack_gpios); - snd_soc_unregister_card(&data->card); return 0; -- cgit v1.1 From 2661112fcc5fe555130f383a21e6ce5152570403 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:46 +0200 Subject: ASoC: simple-card: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/generic/simple-card.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index dfaf48f..6959a74 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -104,12 +104,6 @@ static int asoc_simple_card_init_jack(struct snd_soc_card *card, return 0; } -static void asoc_simple_card_remove_jack(struct asoc_simple_jack *sjack) -{ - if (gpio_is_valid(sjack->gpio.gpio)) - snd_soc_jack_free_gpios(&sjack->jack, 1, &sjack->gpio); -} - static int asoc_simple_card_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -493,10 +487,6 @@ err: static int asoc_simple_card_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); - struct simple_card_data *priv = snd_soc_card_get_drvdata(card); - - asoc_simple_card_remove_jack(&priv->hp_jack); - asoc_simple_card_remove_jack(&priv->mic_jack); return asoc_simple_card_clean_reference(card); } -- cgit v1.1 From 51f25e7f9270378cee0526184ecaaae6c847a5f6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:47 +0200 Subject: ASoC: intel: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/intel/boards/byt-max98090.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/byt-max98090.c b/sound/soc/intel/boards/byt-max98090.c index 047be7f..0f8b820 100644 --- a/sound/soc/intel/boards/byt-max98090.c +++ b/sound/soc/intel/boards/byt-max98090.c @@ -173,20 +173,8 @@ static int byt_max98090_probe(struct platform_device *pdev) return 0; } -static int byt_max98090_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = platform_get_drvdata(pdev); - struct byt_max98090_private *priv = snd_soc_card_get_drvdata(card); - - snd_soc_jack_free_gpios(&priv->jack, ARRAY_SIZE(hs_jack_gpios), - hs_jack_gpios); - - return 0; -} - static struct platform_driver byt_max98090_driver = { .probe = byt_max98090_probe, - .remove = byt_max98090_remove, .driver = { .name = "byt-max98090", .pm = &snd_soc_pm_ops, -- cgit v1.1 From 90c265c65a3216ea236ed8e81d0a8d6411c26e88 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:48 +0200 Subject: ASoC: omap: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/omap/ams-delta.c | 10 ---------- sound/soc/omap/omap-twl4030.c | 13 ------------- sound/soc/omap/rx51.c | 9 --------- 3 files changed, 32 deletions(-) (limited to 'sound') diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 16cc95f..6c49f3d 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -513,15 +513,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int ams_delta_card_remove(struct snd_soc_card *card) -{ - snd_soc_jack_free_gpios(&ams_delta_hook_switch, - ARRAY_SIZE(ams_delta_hook_switch_gpios), - ams_delta_hook_switch_gpios); - - return 0; -} - /* DAI glue - connects codec <--> CPU */ static struct snd_soc_dai_link ams_delta_dai_link = { .name = "CX20442", @@ -540,7 +531,6 @@ static struct snd_soc_dai_link ams_delta_dai_link = { static struct snd_soc_card ams_delta_audio_card = { .name = "AMS_DELTA", .owner = THIS_MODULE, - .remove = ams_delta_card_remove, .dai_link = &ams_delta_dai_link, .num_links = 1, diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index a24b0de..cccc316 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c @@ -208,18 +208,6 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd) return ret; } -static int omap_twl4030_card_remove(struct snd_soc_card *card) -{ - struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card); - - if (priv->jack_detect > 0) - snd_soc_jack_free_gpios(&priv->hs_jack, - ARRAY_SIZE(hs_jack_gpios), - hs_jack_gpios); - - return 0; -} - /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link omap_twl4030_dai_links[] = { { @@ -247,7 +235,6 @@ static struct snd_soc_dai_link omap_twl4030_dai_links[] = { /* Audio machine driver */ static struct snd_soc_card omap_twl4030_card = { .owner = THIS_MODULE, - .remove = omap_twl4030_card_remove, .dai_link = omap_twl4030_dai_links, .num_links = ARRAY_SIZE(omap_twl4030_dai_links), diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 3aeb65f..57448bd 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -311,14 +311,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) return err; } -static int rx51_card_remove(struct snd_soc_card *card) -{ - snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios), - rx51_av_jack_gpios); - - return 0; -} - /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link rx51_dai[] = { { @@ -361,7 +353,6 @@ static struct snd_soc_codec_conf rx51_codec_conf[] = { static struct snd_soc_card rx51_sound_card = { .name = "RX-51", .owner = THIS_MODULE, - .remove = rx51_card_remove, .dai_link = rx51_dai, .num_links = ARRAY_SIZE(rx51_dai), .aux_dev = rx51_aux_dev, -- cgit v1.1 From 7676b40606666547544998e5bc9e7f492fa2e13f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:49 +0200 Subject: ASoC: pxa: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/pxa/hx4700.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c index a9ac881..6cdef5d 100644 --- a/sound/soc/pxa/hx4700.c +++ b/sound/soc/pxa/hx4700.c @@ -138,13 +138,6 @@ static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) return err; } -static int hx4700_card_remove(struct snd_soc_card *card) -{ - snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio); - - return 0; -} - /* hx4700 digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link hx4700_dai = { .name = "ak4641", @@ -163,7 +156,6 @@ static struct snd_soc_dai_link hx4700_dai = { static struct snd_soc_card snd_soc_card_hx4700 = { .name = "iPAQ hx4700", .owner = THIS_MODULE, - .remove = hx4700_card_remove, .dai_link = &hx4700_dai, .num_links = 1, .dapm_widgets = hx4700_dapm_widgets, -- cgit v1.1 From 790b82898db2f42e3430ca84ac9bc3bd7ab474ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:50 +0200 Subject: ASoC: samsung: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/samsung/h1940_uda1380.c | 9 --------- sound/soc/samsung/rx1950_uda1380.c | 10 ---------- sound/soc/samsung/smartq_wm8987.c | 9 --------- 3 files changed, 28 deletions(-) (limited to 'sound') diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c index 5f5825f..0519351 100644 --- a/sound/soc/samsung/h1940_uda1380.c +++ b/sound/soc/samsung/h1940_uda1380.c @@ -170,14 +170,6 @@ static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int h1940_uda1380_card_remove(struct snd_soc_card *card) -{ - snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), - hp_jack_gpios); - - return 0; -} - /* s3c24xx digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link h1940_uda1380_dai[] = { { @@ -197,7 +189,6 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = { static struct snd_soc_card h1940_asoc = { .name = "h1940", .owner = THIS_MODULE, - .remove = h1940_uda1380_card_remove, .dai_link = h1940_uda1380_dai, .num_links = ARRAY_SIZE(h1940_uda1380_dai), diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c index fa096ab..a064ca7 100644 --- a/sound/soc/samsung/rx1950_uda1380.c +++ b/sound/soc/samsung/rx1950_uda1380.c @@ -31,7 +31,6 @@ #include "s3c24xx-i2s.h" static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd); -static int rx1950_uda1380_card_remove(struct snd_soc_card *card); static int rx1950_startup(struct snd_pcm_substream *substream); static int rx1950_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); @@ -118,7 +117,6 @@ static const struct snd_soc_dapm_route audio_map[] = { static struct snd_soc_card rx1950_asoc = { .name = "rx1950", .owner = THIS_MODULE, - .remove = rx1950_uda1380_card_remove, .dai_link = rx1950_uda1380_dai, .num_links = ARRAY_SIZE(rx1950_uda1380_dai), @@ -219,14 +217,6 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int rx1950_uda1380_card_remove(struct snd_soc_card *card) -{ - snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), - hp_jack_gpios); - - return 0; -} - static int __init rx1950_init(void) { int ret; diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c index 425ee2b..cf0f54e 100644 --- a/sound/soc/samsung/smartq_wm8987.c +++ b/sound/soc/samsung/smartq_wm8987.c @@ -160,14 +160,6 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd) return err; } -static int smartq_wm8987_card_remove(struct snd_soc_card *card) -{ - snd_soc_jack_free_gpios(&smartq_jack, ARRAY_SIZE(smartq_jack_gpios), - smartq_jack_gpios); - - return 0; -} - static struct snd_soc_dai_link smartq_dai[] = { { .name = "wm8987", @@ -186,7 +178,6 @@ static struct snd_soc_dai_link smartq_dai[] = { static struct snd_soc_card snd_soc_smartq = { .name = "SmartQ", .owner = THIS_MODULE, - .remove = smartq_wm8987_card_remove, .dai_link = smartq_dai, .num_links = ARRAY_SIZE(smartq_dai), -- cgit v1.1 From 2a8bd83af30e3045b8b251191e759a2be9877816 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 13:59:51 +0200 Subject: ASoC: tegra: Remove superfluous snd_soc_jack_free_gpios() call Since jack gpios are managed via devres, we don't have to call snd_jack_free_gpios() at release any longer. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/tegra/tegra_alc5632.c | 13 ------------- sound/soc/tegra/tegra_max98090.c | 18 ------------------ sound/soc/tegra/tegra_rt5640.c | 13 ------------- sound/soc/tegra/tegra_rt5677.c | 18 ------------------ sound/soc/tegra/tegra_wm8903.c | 5 ----- 5 files changed, 67 deletions(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index 0509902..0038315 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c @@ -124,18 +124,6 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int tegra_alc5632_card_remove(struct snd_soc_card *card) -{ - struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); - - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack, 1, - &tegra_alc5632_hp_jack_gpio); - } - - return 0; -} - static struct snd_soc_dai_link tegra_alc5632_dai = { .name = "ALC5632", .stream_name = "ALC5632 PCM", @@ -150,7 +138,6 @@ static struct snd_soc_dai_link tegra_alc5632_dai = { static struct snd_soc_card snd_soc_tegra_alc5632 = { .name = "tegra-alc5632", .owner = THIS_MODULE, - .remove = tegra_alc5632_card_remove, .dai_link = &tegra_alc5632_dai, .num_links = 1, .controls = tegra_alc5632_controls, diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index c34a54d..955067a 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c @@ -176,23 +176,6 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int tegra_max98090_card_remove(struct snd_soc_card *card) -{ - struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); - - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1, - &tegra_max98090_hp_jack_gpio); - } - - if (gpio_is_valid(machine->gpio_mic_det)) { - snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1, - &tegra_max98090_mic_jack_gpio); - } - - return 0; -} - static struct snd_soc_dai_link tegra_max98090_dai = { .name = "max98090", .stream_name = "max98090 PCM", @@ -206,7 +189,6 @@ static struct snd_soc_dai_link tegra_max98090_dai = { static struct snd_soc_card snd_soc_tegra_max98090 = { .name = "tegra-max98090", .owner = THIS_MODULE, - .remove = tegra_max98090_card_remove, .dai_link = &tegra_max98090_dai, .num_links = 1, .controls = tegra_max98090_controls, diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c index 93a3568..76ed604 100644 --- a/sound/soc/tegra/tegra_rt5640.c +++ b/sound/soc/tegra/tegra_rt5640.c @@ -126,18 +126,6 @@ static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int tegra_rt5640_card_remove(struct snd_soc_card *card) -{ - struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); - - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_jack_free_gpios(&tegra_rt5640_hp_jack, 1, - &tegra_rt5640_hp_jack_gpio); - } - - return 0; -} - static struct snd_soc_dai_link tegra_rt5640_dai = { .name = "RT5640", .stream_name = "RT5640 PCM", @@ -151,7 +139,6 @@ static struct snd_soc_dai_link tegra_rt5640_dai = { static struct snd_soc_card snd_soc_tegra_rt5640 = { .name = "tegra-rt5640", .owner = THIS_MODULE, - .remove = tegra_rt5640_card_remove, .dai_link = &tegra_rt5640_dai, .num_links = 1, .controls = tegra_rt5640_controls, diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c index ebf58d0..dc5a295 100644 --- a/sound/soc/tegra/tegra_rt5677.c +++ b/sound/soc/tegra/tegra_rt5677.c @@ -169,23 +169,6 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int tegra_rt5677_card_remove(struct snd_soc_card *card) -{ - struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); - - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_jack_free_gpios(&tegra_rt5677_hp_jack, 1, - &tegra_rt5677_hp_jack_gpio); - } - - if (gpio_is_valid(machine->gpio_mic_present)) { - snd_soc_jack_free_gpios(&tegra_rt5677_mic_jack, 1, - &tegra_rt5677_mic_jack_gpio); - } - - return 0; -} - static struct snd_soc_dai_link tegra_rt5677_dai = { .name = "RT5677", .stream_name = "RT5677 PCM", @@ -199,7 +182,6 @@ static struct snd_soc_dai_link tegra_rt5677_dai = { static struct snd_soc_card snd_soc_tegra_rt5677 = { .name = "tegra-rt5677", .owner = THIS_MODULE, - .remove = tegra_rt5677_card_remove, .dai_link = &tegra_rt5677_dai, .num_links = 1, .controls = tegra_rt5677_controls, diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index dbfb492..ce498cc 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -205,11 +205,6 @@ static int tegra_wm8903_remove(struct snd_soc_card *card) struct snd_soc_codec *codec = codec_dai->codec; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 1, - &tegra_wm8903_hp_jack_gpio); - } - wm8903_mic_detect(codec, NULL, 0, 0); return 0; -- cgit v1.1 From 4958471b0d2110a34df0b45803e6f24ed89b857b Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 22 Aug 2017 15:57:21 +0800 Subject: ASoC: soc-core: Allow searching dai driver name in snd_soc_find_dai Currently we are searching dai name in snd_soc_find_dai, which could either be dai driver name or component device name(for legacy naming). Allow searching dai driver name in snd_soc_find_dai too, so that we can use dai driver name to find legacy naming dais. Signed-off-by: Jeffy Chen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 50c8dba..6fab0ff 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1000,7 +1000,7 @@ static struct snd_soc_component *soc_find_component( /** * snd_soc_find_dai - Find a registered DAI * - * @dlc: name of the DAI and optional component info to match + * @dlc: name of the DAI or the DAI driver and optional component info to match * * This function will search all registered components and their DAIs to * find the DAI of the same name. The component's of_node and name @@ -1028,7 +1028,8 @@ struct snd_soc_dai *snd_soc_find_dai( if (dlc->name && strcmp(component->name, dlc->name)) continue; list_for_each_entry(dai, &component->dai_list, list) { - if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)) + if (dlc->dai_name && strcmp(dai->name, dlc->dai_name) + && strcmp(dai->driver->name, dlc->dai_name)) continue; return dai; -- cgit v1.1 From 782fbec745d84fa06708e703a92a431c4344daf0 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Tue, 22 Aug 2017 22:58:15 +0900 Subject: ALSA: firewire: add const qualifier to identifiers for read-only symbols Drivers in ALSA firewire stack still includes some symbols which can be moved to a section for read-only symbols. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/bebob/bebob.h | 2 +- sound/firewire/bebob/bebob_focusrite.c | 6 +++--- sound/firewire/bebob/bebob_maudio.c | 2 +- sound/firewire/bebob/bebob_terratec.c | 2 +- sound/firewire/bebob/bebob_yamaha_terratec.c | 2 +- sound/firewire/dice/dice.c | 2 +- sound/firewire/fireface/ff-protocol-ff400.c | 2 +- sound/firewire/fireface/ff.c | 2 +- sound/firewire/fireface/ff.h | 4 ++-- sound/firewire/fireworks/fireworks_proc.c | 2 +- sound/firewire/motu/motu.c | 6 +++--- sound/firewire/oxfw/oxfw-scs1x.c | 11 +++++------ sound/firewire/tascam/tascam.c | 2 +- 13 files changed, 22 insertions(+), 23 deletions(-) (limited to 'sound') diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h index 17678d6..df1b1e9 100644 --- a/sound/firewire/bebob/bebob.h +++ b/sound/firewire/bebob/bebob.h @@ -58,7 +58,7 @@ enum snd_bebob_clock_type { struct snd_bebob_clock_spec { unsigned int num; const char *const *labels; - enum snd_bebob_clock_type *types; + const enum snd_bebob_clock_type *types; int (*get)(struct snd_bebob *bebob, unsigned int *id); }; struct snd_bebob_rate_spec { diff --git a/sound/firewire/bebob/bebob_focusrite.c b/sound/firewire/bebob/bebob_focusrite.c index f110900..52b8b61 100644 --- a/sound/firewire/bebob/bebob_focusrite.c +++ b/sound/firewire/bebob/bebob_focusrite.c @@ -103,12 +103,12 @@ saffire_write_quad(struct snd_bebob *bebob, u64 offset, u32 value) &data, sizeof(__be32), 0); } -static enum snd_bebob_clock_type saffirepro_10_clk_src_types[] = { +static const enum snd_bebob_clock_type saffirepro_10_clk_src_types[] = { SND_BEBOB_CLOCK_TYPE_INTERNAL, SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ }; -static enum snd_bebob_clock_type saffirepro_26_clk_src_types[] = { +static const enum snd_bebob_clock_type saffirepro_26_clk_src_types[] = { SND_BEBOB_CLOCK_TYPE_INTERNAL, SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* ADAT1 */ @@ -201,7 +201,7 @@ end: } const struct snd_bebob_spec saffire_le_spec; -static enum snd_bebob_clock_type saffire_both_clk_src_types[] = { +static const enum snd_bebob_clock_type saffire_both_clk_src_types[] = { SND_BEBOB_CLOCK_TYPE_INTERNAL, SND_BEBOB_CLOCK_TYPE_EXTERNAL, }; diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c index d10208f..bd55620 100644 --- a/sound/firewire/bebob/bebob_maudio.c +++ b/sound/firewire/bebob/bebob_maudio.c @@ -340,7 +340,7 @@ end: } /* Clock source control for special firmware */ -static enum snd_bebob_clock_type special_clk_types[] = { +static const enum snd_bebob_clock_type special_clk_types[] = { SND_BEBOB_CLOCK_TYPE_INTERNAL, /* With digital mute */ SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* SPDIF/ADAT */ SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ diff --git a/sound/firewire/bebob/bebob_terratec.c b/sound/firewire/bebob/bebob_terratec.c index 2fdaf93..9770c21 100644 --- a/sound/firewire/bebob/bebob_terratec.c +++ b/sound/firewire/bebob/bebob_terratec.c @@ -8,7 +8,7 @@ #include "./bebob.h" -static enum snd_bebob_clock_type phase88_rack_clk_src_types[] = { +static const enum snd_bebob_clock_type phase88_rack_clk_src_types[] = { SND_BEBOB_CLOCK_TYPE_INTERNAL, SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ diff --git a/sound/firewire/bebob/bebob_yamaha_terratec.c b/sound/firewire/bebob/bebob_yamaha_terratec.c index a6be3e7..8bd78fe 100644 --- a/sound/firewire/bebob/bebob_yamaha_terratec.c +++ b/sound/firewire/bebob/bebob_yamaha_terratec.c @@ -31,7 +31,7 @@ * Yamaha GO 44 and GO 46. Yamaha and Terratec had cooperated for these models. */ -static enum snd_bebob_clock_type clk_src_types[] = { +static const enum snd_bebob_clock_type clk_src_types[] = { SND_BEBOB_CLOCK_TYPE_INTERNAL, SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ }; diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c index 25e9f77..4ddb4cd 100644 --- a/sound/firewire/dice/dice.c +++ b/sound/firewire/dice/dice.c @@ -26,7 +26,7 @@ MODULE_LICENSE("GPL v2"); */ static bool force_two_pcm_support(struct fw_unit *unit) { - const char *const models[] = { + static const char *const models[] = { /* TC Electronic models. */ "StudioKonnekt48", /* Focusrite models. */ diff --git a/sound/firewire/fireface/ff-protocol-ff400.c b/sound/firewire/fireface/ff-protocol-ff400.c index fcec6de..12aa15d 100644 --- a/sound/firewire/fireface/ff-protocol-ff400.c +++ b/sound/firewire/fireface/ff-protocol-ff400.c @@ -356,7 +356,7 @@ static void ff400_dump_clock_config(struct snd_ff *ff, snd_iprintf(buffer, "Sync to clock source: %s\n", src); } -struct snd_ff_protocol snd_ff_protocol_ff400 = { +const struct snd_ff_protocol snd_ff_protocol_ff400 = { .get_clock = ff400_get_clock, .begin_session = ff400_begin_session, .finish_session = ff400_finish_session, diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c index eee7c8e..4974bc7 100644 --- a/sound/firewire/fireface/ff.c +++ b/sound/firewire/fireface/ff.c @@ -157,7 +157,7 @@ static void snd_ff_remove(struct fw_unit *unit) } } -static struct snd_ff_spec spec_ff400 = { +static const struct snd_ff_spec spec_ff400 = { .name = "Fireface400", .pcm_capture_channels = {18, 14, 10}, .pcm_playback_channels = {18, 14, 10}, diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index 3cb812a..64df44b 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -47,7 +47,7 @@ struct snd_ff_spec { unsigned int midi_in_ports; unsigned int midi_out_ports; - struct snd_ff_protocol *protocol; + const struct snd_ff_protocol *protocol; }; struct snd_ff { @@ -112,7 +112,7 @@ struct snd_ff_protocol { u64 midi_rx_port_1_reg; }; -extern struct snd_ff_protocol snd_ff_protocol_ff400; +extern const struct snd_ff_protocol snd_ff_protocol_ff400; int snd_ff_transaction_register(struct snd_ff *ff); int snd_ff_transaction_reregister(struct snd_ff *ff); diff --git a/sound/firewire/fireworks/fireworks_proc.c b/sound/firewire/fireworks/fireworks_proc.c index beb0a0f..9c21f31 100644 --- a/sound/firewire/fireworks/fireworks_proc.c +++ b/sound/firewire/fireworks/fireworks_proc.c @@ -12,7 +12,7 @@ static inline const char* get_phys_name(struct snd_efw_phys_grp *grp, bool input) { - const char *const ch_type[] = { + static const char *const ch_type[] = { "Analog", "S/PDIF", "ADAT", "S/PDIF or ADAT", "Mirroring", "Headphones", "I2S", "Guitar", "Pirzo Guitar", "Guitar String", }; diff --git a/sound/firewire/motu/motu.c b/sound/firewire/motu/motu.c index 2bbb764..0d6b526 100644 --- a/sound/firewire/motu/motu.c +++ b/sound/firewire/motu/motu.c @@ -194,7 +194,7 @@ static void motu_bus_update(struct fw_unit *unit) snd_motu_transaction_reregister(motu); } -static struct snd_motu_spec motu_828mk2 = { +static const struct snd_motu_spec motu_828mk2 = { .name = "828mk2", .protocol = &snd_motu_protocol_v2, .flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 | @@ -208,7 +208,7 @@ static struct snd_motu_spec motu_828mk2 = { .analog_out_ports = 8, }; -static struct snd_motu_spec motu_828mk3 = { +static const struct snd_motu_spec motu_828mk3 = { .name = "828mk3", .protocol = &snd_motu_protocol_v3, .flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 | @@ -225,7 +225,7 @@ static struct snd_motu_spec motu_828mk3 = { .analog_out_ports = 8, }; -static struct snd_motu_spec motu_audio_express = { +static const struct snd_motu_spec motu_audio_express = { .name = "AudioExpress", .protocol = &snd_motu_protocol_v3, .flags = SND_MOTU_SPEC_SUPPORT_CLOCK_X2 | diff --git a/sound/firewire/oxfw/oxfw-scs1x.c b/sound/firewire/oxfw/oxfw-scs1x.c index 93209eb..02d5956 100644 --- a/sound/firewire/oxfw/oxfw-scs1x.c +++ b/sound/firewire/oxfw/oxfw-scs1x.c @@ -297,12 +297,6 @@ static void midi_capture_trigger(struct snd_rawmidi_substream *stream, int up) } } -static const struct snd_rawmidi_ops midi_capture_ops = { - .open = midi_capture_open, - .close = midi_capture_close, - .trigger = midi_capture_trigger, -}; - static int midi_playback_open(struct snd_rawmidi_substream *stream) { return 0; @@ -363,6 +357,11 @@ void snd_oxfw_scs1x_update(struct snd_oxfw *oxfw) int snd_oxfw_scs1x_add(struct snd_oxfw *oxfw) { + static const struct snd_rawmidi_ops midi_capture_ops = { + .open = midi_capture_open, + .close = midi_capture_close, + .trigger = midi_capture_trigger, + }; static const struct snd_rawmidi_ops midi_playback_ops = { .open = midi_playback_open, .close = midi_playback_close, diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c index 9dc93a7..44ad41f 100644 --- a/sound/firewire/tascam/tascam.c +++ b/sound/firewire/tascam/tascam.c @@ -12,7 +12,7 @@ MODULE_DESCRIPTION("TASCAM FireWire series Driver"); MODULE_AUTHOR("Takashi Sakamoto "); MODULE_LICENSE("GPL v2"); -static struct snd_tscm_spec model_specs[] = { +static const struct snd_tscm_spec model_specs[] = { { .name = "FW-1884", .has_adat = true, -- cgit v1.1 From e8a91ae18bdc0bcedd2a07e42e66ca09dc2105d2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Aug 2017 16:13:27 +0200 Subject: ALSA: ice1712: Add support for STAudio ADCIII STAudio ADCIII has the same SSID as Hoontech STDSP24, but requires a slightly different configuration. This patch allows user to choose this model via model=staudio option to set the proper configuration for the board. Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=1048934 Signed-off-by: Takashi Iwai --- sound/pci/ice1712/hoontech.c | 39 ++++++++++++++++++++++++++++++++++----- sound/pci/ice1712/hoontech.h | 1 + 2 files changed, 35 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c index f37ed0b..fa301d3 100644 --- a/sound/pci/ice1712/hoontech.c +++ b/sound/pci/ice1712/hoontech.c @@ -166,7 +166,7 @@ static void snd_ice1712_stdsp24_midi2(struct snd_ice1712 *ice, int activate) mutex_unlock(&ice->gpio_mutex); } -static int snd_ice1712_hoontech_init(struct snd_ice1712 *ice) +static int hoontech_init(struct snd_ice1712 *ice, bool staudio) { struct hoontech_spec *spec; int box, chn; @@ -203,7 +203,10 @@ static int snd_ice1712_hoontech_init(struct snd_ice1712 *ice) ICE1712_STDSP24_3_INSEL(spec->boxbits, 0); /* let's go - activate only functions in first box */ - spec->config = 0; + if (staudio) + spec->config = ICE1712_STDSP24_MUTE; + else + spec->config = 0; /* ICE1712_STDSP24_MUTE | ICE1712_STDSP24_INSEL | ICE1712_STDSP24_DAREAR; */ @@ -226,9 +229,16 @@ static int snd_ice1712_hoontech_init(struct snd_ice1712 *ice) ICE1712_STDSP24_BOX_CHN4 | ICE1712_STDSP24_BOX_MIDI1 | ICE1712_STDSP24_BOX_MIDI2; - spec->boxconfig[1] = - spec->boxconfig[2] = - spec->boxconfig[3] = 0; + if (staudio) { + spec->boxconfig[1] = + spec->boxconfig[2] = + spec->boxconfig[3] = spec->boxconfig[0]; + } else { + spec->boxconfig[1] = + spec->boxconfig[2] = + spec->boxconfig[3] = 0; + } + snd_ice1712_stdsp24_darear(ice, (spec->config & ICE1712_STDSP24_DAREAR) ? 1 : 0); snd_ice1712_stdsp24_mute(ice, @@ -248,6 +258,16 @@ static int snd_ice1712_hoontech_init(struct snd_ice1712 *ice) return 0; } +static int snd_ice1712_hoontech_init(struct snd_ice1712 *ice) +{ + return hoontech_init(ice, false); +} + +static int snd_ice1712_staudio_init(struct snd_ice1712 *ice) +{ + return hoontech_init(ice, true); +} + /* * AK4524 access */ @@ -351,5 +371,14 @@ struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] = { .model = "ez8", .chip_init = snd_ice1712_ez8_init, }, + { + /* STAudio ADCIII has the same SSID as Hoontech StA DSP24, + * thus identified only via the explicit model option + */ + .subvendor = ICE1712_SUBDEVICE_STAUDIO_ADCIII, /* a dummy id */ + .name = "STAudio ADCIII", + .model = "staudio", + .chip_init = snd_ice1712_staudio_init, + }, { } /* terminator */ }; diff --git a/sound/pci/ice1712/hoontech.h b/sound/pci/ice1712/hoontech.h index cc1da1e..7f94943 100644 --- a/sound/pci/ice1712/hoontech.h +++ b/sound/pci/ice1712/hoontech.h @@ -34,6 +34,7 @@ #define ICE1712_SUBDEVICE_STDSP24_VALUE 0x00010010 /* A dummy id for Hoontech SoundTrack Audio DSP 24 Value */ #define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */ #define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */ +#define ICE1712_SUBDEVICE_STAUDIO_ADCIII 0x00010002 /* A dummy id for STAudio ADCIII */ extern struct snd_ice1712_card_info snd_ice1712_hoontech_cards[]; -- cgit v1.1 From c16293560a1c188a05cba1dcc46548d33b641c06 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 22 Aug 2017 00:02:03 +0000 Subject: ASoC: rsnd: remove unused rsnd_xxx_to_dma() Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/src.c | 1 - sound/soc/sh/rcar/ssi.c | 1 - 2 files changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 4640039..510b68a 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -27,7 +27,6 @@ struct rsnd_src { #define RSND_SRC_NAME_SIZE 16 #define rsnd_src_get(priv, id) ((struct rsnd_src *)(priv->src) + id) -#define rsnd_src_to_dma(src) ((src)->dma) #define rsnd_src_nr(priv) ((priv)->src_nr) #define rsnd_src_sync_is_enabled(mod) (rsnd_mod_to_src(mod)->sen.val) diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 8bb4714..fffc07e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -99,7 +99,6 @@ struct rsnd_ssi { i++) #define rsnd_ssi_get(priv, id) ((struct rsnd_ssi *)(priv->ssi) + id) -#define rsnd_ssi_to_dma(mod) ((ssi)->dma) #define rsnd_ssi_nr(priv) ((priv)->ssi_nr) #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod) #define rsnd_ssi_flags_has(p, f) ((p)->flags & f) -- cgit v1.1 From 2cded8c891fe04bea5772fad20c96c72315b9014 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 22 Aug 2017 17:33:33 +0200 Subject: ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe() Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/drivers/pcsp/pcsp.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'sound') diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 72e2d00..0dd3f46 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) return err; err = snd_pcsp_create(card); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; + if (!nopcm) { err = snd_pcsp_new_pcm(&pcsp_chip); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; } err = snd_pcsp_new_mixer(&pcsp_chip, nopcm); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; strcpy(card->driver, "PC-Speaker"); strcpy(card->shortname, "pcsp"); @@ -131,12 +126,14 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) pcsp_chip.port); err = snd_card_register(card); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; return 0; + +free_card: + snd_card_free(card); + return err; } static int alsa_card_pcsp_init(struct device *dev) -- cgit v1.1 From f628c4ed3de499f027d3ae70cbb46c6dfadfc098 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 22 Aug 2017 23:35:48 +0800 Subject: ASoC: rockchip: Correct 'dmic-delay' property name The 'dmic-delay' property name is different with the dt-binding. So correct it with 'dmic-wakeup-delay-ms'. Fixes: 3a6f9dce6116 (ASoC: rk3399_gru_sound: fix recording pop at first attempt) Signed-off-by: Jeffy Chen Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3399_gru_sound.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 70c0908..566ccb3 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -38,7 +38,7 @@ #define SOUND_FS 256 -static unsigned int rt5514_dmic_delay; +static unsigned int dmic_wakeup_delay; static struct snd_soc_jack rockchip_sound_jack; @@ -126,7 +126,7 @@ static int rockchip_sound_rt5514_hw_params(struct snd_pcm_substream *substream, } /* Wait for DMIC stable */ - msleep(rt5514_dmic_delay); + msleep(dmic_wakeup_delay); return 0; } @@ -348,13 +348,13 @@ static int rockchip_sound_probe(struct platform_device *pdev) return -ENODEV; } - /* Set DMIC delay */ - ret = device_property_read_u32(&pdev->dev, "dmic-delay", - &rt5514_dmic_delay); + /* Set DMIC wakeup delay */ + ret = device_property_read_u32(&pdev->dev, "dmic-wakeup-delay-ms", + &dmic_wakeup_delay); if (ret) { - rt5514_dmic_delay = 0; + dmic_wakeup_delay = 0; dev_dbg(&pdev->dev, - "no optional property 'dmic-delay' found, default: no delay\n"); + "no optional property 'dmic-wakeup-delay-ms' found, default: no delay\n"); } rockchip_dailinks[DAILINK_RT5514_DSP].cpu_name = kstrdup_const(dev_name(dev), GFP_KERNEL); -- cgit v1.1 From cbb7eb20bb7c73b27e8ece8f871458ab0eab8253 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 22 Aug 2017 18:43:42 +0200 Subject: ALSA: ctxfi: Use common error handling code in two functions Add jump targets so that a bit of exception handling can be better reused at the end of these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/ctpcm.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 358f520..b36e37a 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c @@ -140,27 +140,28 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream) err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); - if (err < 0) { - kfree(apcm); - return err; - } + if (err < 0) + goto free_pcm; + err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1024, UINT_MAX); - if (err < 0) { - kfree(apcm); - return err; - } + if (err < 0) + goto free_pcm; apcm->timer = ct_timer_instance_new(atc->timer, apcm); if (!apcm->timer) { - kfree(apcm); - return -ENOMEM; + err = -ENOMEM; + goto free_pcm; } runtime->private_data = apcm; runtime->private_free = ct_atc_pcm_free_substream; return 0; + +free_pcm: + kfree(apcm); + return err; } static int ct_pcm_playback_close(struct snd_pcm_substream *substream) @@ -286,27 +287,28 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream) err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); - if (err < 0) { - kfree(apcm); - return err; - } + if (err < 0) + goto free_pcm; + err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1024, UINT_MAX); - if (err < 0) { - kfree(apcm); - return err; - } + if (err < 0) + goto free_pcm; apcm->timer = ct_timer_instance_new(atc->timer, apcm); if (!apcm->timer) { - kfree(apcm); - return -ENOMEM; + err = -ENOMEM; + goto free_pcm; } runtime->private_data = apcm; runtime->private_free = ct_atc_pcm_free_substream; return 0; + +free_pcm: + kfree(apcm); + return err; } static int ct_pcm_capture_close(struct snd_pcm_substream *substream) -- cgit v1.1 From 62a939477173fabfe9f52114fab878a00b87f9a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Aug 2017 16:52:10 +0200 Subject: ALSA: hda - Implement mic-mute LED mode enum Dell laptops have another LED for mic-mute in addition to the master mute. The former is tied with the capture switch (in a reverse way) while the latter is tied with the master playback switch. We already have an enum control to change the behavior for the master mute LED in different ways, e.g. keeping always off or turning off at mute. But, the mic-mute LED has no such management but its behavior is hard-coded. This patch implements an enum control to change the mic-mute LED behavior like what we have for the master mute LED. The ctl provides four modes: keep-on, keep-off, follow-capture and follow-mute. The default mode is the last one, follow-mute, which follows the capture mute, i.e. LED turning on when the capture is off, and turning off when the capture is active. Signed-off-by: Takashi Iwai --- sound/pci/hda/dell_wmi_helper.c | 87 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/dell_wmi_helper.c b/sound/pci/hda/dell_wmi_helper.c index 7efa7bd..44b1e15 100644 --- a/sound/pci/hda/dell_wmi_helper.c +++ b/sound/pci/hda/dell_wmi_helper.c @@ -5,12 +5,47 @@ #if IS_ENABLED(CONFIG_DELL_LAPTOP) #include +enum { + MICMUTE_LED_ON, + MICMUTE_LED_OFF, + MICMUTE_LED_FOLLOW_CAPTURE, + MICMUTE_LED_FOLLOW_MUTE, +}; + +static int dell_led_mode = MICMUTE_LED_FOLLOW_MUTE; +static int dell_capture; static int dell_led_value; static int (*dell_micmute_led_set_func)(int); static void (*dell_old_cap_hook)(struct hda_codec *, struct snd_kcontrol *, struct snd_ctl_elem_value *); +static void call_micmute_led_update(void) +{ + int val; + + switch (dell_led_mode) { + case MICMUTE_LED_ON: + val = 1; + break; + case MICMUTE_LED_OFF: + val = 0; + break; + case MICMUTE_LED_FOLLOW_CAPTURE: + val = dell_capture; + break; + case MICMUTE_LED_FOLLOW_MUTE: + default: + val = !dell_capture; + break; + } + + if (val == dell_led_value) + return; + dell_led_value = val; + dell_micmute_led_set_func(dell_led_value); +} + static void update_dell_wmi_micmute_led(struct hda_codec *codec, struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -22,15 +57,54 @@ static void update_dell_wmi_micmute_led(struct hda_codec *codec, return; if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) { /* TODO: How do I verify if it's a mono or stereo here? */ - int val = (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) ? 0 : 1; - if (val == dell_led_value) - return; - dell_led_value = val; - if (dell_micmute_led_set_func) - dell_micmute_led_set_func(dell_led_value); + dell_capture = (ucontrol->value.integer.value[0] || + ucontrol->value.integer.value[1]); + call_micmute_led_update(); } } +static int dell_mic_mute_led_mode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static const char * const texts[] = { + "On", "Off", "Follow Capture", "Follow Mute", + }; + + return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); +} + +static int dell_mic_mute_led_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.enumerated.item[0] = dell_led_mode; + return 0; +} + +static int dell_mic_mute_led_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + unsigned int mode; + + mode = ucontrol->value.enumerated.item[0]; + if (mode > MICMUTE_LED_FOLLOW_MUTE) + mode = MICMUTE_LED_FOLLOW_MUTE; + if (mode == dell_led_mode) + return 0; + dell_led_mode = mode; + call_micmute_led_update(); + return 1; +} + +static const struct snd_kcontrol_new dell_mic_mute_mode_ctls[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Mic Mute-LED Mode", + .info = dell_mic_mute_led_mode_info, + .get = dell_mic_mute_led_mode_get, + .put = dell_mic_mute_led_mode_put, + }, + {} +}; static void alc_fixup_dell_wmi(struct hda_codec *codec, const struct hda_fixup *fix, int action) @@ -55,6 +129,7 @@ static void alc_fixup_dell_wmi(struct hda_codec *codec, dell_old_cap_hook = spec->gen.cap_sync_hook; spec->gen.cap_sync_hook = update_dell_wmi_micmute_led; removefunc = false; + add_mixer(spec, dell_mic_mute_mode_ctls); } } -- cgit v1.1 From e17a85eccfa0b7d0089af218b0c468d4b8a3c3c2 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 22 Aug 2017 19:58:30 +0200 Subject: ALSA: cmipci: Use common error handling code in snd_cmipci_probe() Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index a45245f..26a6578 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -3295,20 +3295,23 @@ static int snd_cmipci_probe(struct pci_dev *pci, break; } - if ((err = snd_cmipci_create(card, pci, dev, &cm)) < 0) { - snd_card_free(card); - return err; - } + err = snd_cmipci_create(card, pci, dev, &cm); + if (err < 0) + goto free_card; + card->private_data = cm; - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + err = snd_card_register(card); + if (err < 0) + goto free_card; + pci_set_drvdata(pci, card); dev++; return 0; +free_card: + snd_card_free(card); + return err; } static void snd_cmipci_remove(struct pci_dev *pci) -- cgit v1.1 From 97d15a141f84a02d40d2ee442df5c6bd2f62b3d8 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 23 Aug 2017 08:40:37 +0200 Subject: ALSA: pcm: Use common error handling code in _snd_pcm_new() Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/core/pcm.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 89c7485..048df96 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -783,21 +783,27 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device, INIT_LIST_HEAD(&pcm->list); if (id) strlcpy(pcm->id, id, sizeof(pcm->id)); - if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) { - snd_pcm_free(pcm); - return err; - } - if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count)) < 0) { - snd_pcm_free(pcm); - return err; - } - if ((err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops)) < 0) { - snd_pcm_free(pcm); - return err; - } + + err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, + playback_count); + if (err < 0) + goto free_pcm; + + err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_CAPTURE, capture_count); + if (err < 0) + goto free_pcm; + + err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops); + if (err < 0) + goto free_pcm; + if (rpcm) *rpcm = pcm; return 0; + +free_pcm: + snd_pcm_free(pcm); + return err; } /** -- cgit v1.1 From c8da9be4a75f1f63024a16b976c5be47405c13dc Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 23 Aug 2017 09:20:29 +0200 Subject: ALSA: pcm: Adjust nine function calls together with a variable assignment The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix the affected source code places. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/core/pcm.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 048df96..c790f79 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -523,7 +523,9 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) sprintf(name, "pcm%i%c", pcm->device, pstr->stream == SNDRV_PCM_STREAM_PLAYBACK ? 'p' : 'c'); - if ((entry = snd_info_create_card_entry(pcm->card, name, pcm->card->proc_root)) == NULL) + entry = snd_info_create_card_entry(pcm->card, name, + pcm->card->proc_root); + if (!entry) return -ENOMEM; entry->mode = S_IFDIR | S_IRUGO | S_IXUGO; if (snd_info_register(entry) < 0) { @@ -531,8 +533,8 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) return -ENOMEM; } pstr->proc_root = entry; - - if ((entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root)) != NULL) { + entry = snd_info_create_card_entry(pcm->card, "info", pstr->proc_root); + if (entry) { snd_info_set_text_ops(entry, pstr, snd_pcm_stream_proc_info_read); if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); @@ -542,8 +544,9 @@ static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) pstr->proc_info_entry = entry; #ifdef CONFIG_SND_PCM_XRUN_DEBUG - if ((entry = snd_info_create_card_entry(pcm->card, "xrun_debug", - pstr->proc_root)) != NULL) { + entry = snd_info_create_card_entry(pcm->card, "xrun_debug", + pstr->proc_root); + if (entry) { entry->c.text.read = snd_pcm_xrun_debug_read; entry->c.text.write = snd_pcm_xrun_debug_write; entry->mode |= S_IWUSR; @@ -580,7 +583,9 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) card = substream->pcm->card; sprintf(name, "sub%i", substream->number); - if ((entry = snd_info_create_card_entry(card, name, substream->pstr->proc_root)) == NULL) + entry = snd_info_create_card_entry(card, name, + substream->pstr->proc_root); + if (!entry) return -ENOMEM; entry->mode = S_IFDIR | S_IRUGO | S_IXUGO; if (snd_info_register(entry) < 0) { @@ -588,8 +593,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) return -ENOMEM; } substream->proc_root = entry; - - if ((entry = snd_info_create_card_entry(card, "info", substream->proc_root)) != NULL) { + entry = snd_info_create_card_entry(card, "info", substream->proc_root); + if (entry) { snd_info_set_text_ops(entry, substream, snd_pcm_substream_proc_info_read); if (snd_info_register(entry) < 0) { @@ -598,8 +603,9 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) } } substream->proc_info_entry = entry; - - if ((entry = snd_info_create_card_entry(card, "hw_params", substream->proc_root)) != NULL) { + entry = snd_info_create_card_entry(card, "hw_params", + substream->proc_root); + if (entry) { snd_info_set_text_ops(entry, substream, snd_pcm_substream_proc_hw_params_read); if (snd_info_register(entry) < 0) { @@ -608,8 +614,9 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) } } substream->proc_hw_params_entry = entry; - - if ((entry = snd_info_create_card_entry(card, "sw_params", substream->proc_root)) != NULL) { + entry = snd_info_create_card_entry(card, "sw_params", + substream->proc_root); + if (entry) { snd_info_set_text_ops(entry, substream, snd_pcm_substream_proc_sw_params_read); if (snd_info_register(entry) < 0) { @@ -618,8 +625,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) } } substream->proc_sw_params_entry = entry; - - if ((entry = snd_info_create_card_entry(card, "status", substream->proc_root)) != NULL) { + entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL); + if (entry) { snd_info_set_text_ops(entry, substream, snd_pcm_substream_proc_status_read); if (snd_info_register(entry) < 0) { @@ -1230,7 +1237,8 @@ static void snd_pcm_proc_init(void) { struct snd_info_entry *entry; - if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) { + entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL); + if (entry) { snd_info_set_text_ops(entry, NULL, snd_pcm_proc_read); if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); -- cgit v1.1 From dd1f7ab8a88ddc8fbb304aaca25f549e26fa8529 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 23 Aug 2017 09:45:06 +0200 Subject: ALSA: timer: Adjust a condition check in snd_timer_resolution() The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix the affected source code place. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/core/timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/timer.c b/sound/core/timer.c index a9b9a27..6051aed 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -393,7 +393,8 @@ unsigned long snd_timer_resolution(struct snd_timer_instance *timeri) if (timeri == NULL) return 0; - if ((timer = timeri->timer) != NULL) { + timer = timeri->timer; + if (timer) { if (timer->hw.c_resolution) return timer->hw.c_resolution(timer); return timer->hw.resolution; -- cgit v1.1 From 1ae0e4ce554fb57dc4d5e1eb8e6d302e3f18b0b4 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 23 Aug 2017 09:30:41 +0200 Subject: ALSA: timer: Use common error handling code in alsa_timer_init() Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Takashi Iwai --- sound/core/timer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/core/timer.c b/sound/core/timer.c index 6051aed..6cdd04a 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -2097,8 +2097,7 @@ static int __init alsa_timer_init(void) err = snd_timer_register_system(); if (err < 0) { pr_err("ALSA: unable to register system timer (%i)\n", err); - put_device(&timer_dev); - return err; + goto put_timer; } err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, @@ -2106,12 +2105,15 @@ static int __init alsa_timer_init(void) if (err < 0) { pr_err("ALSA: unable to register timer device (%i)\n", err); snd_timer_free_all(); - put_device(&timer_dev); - return err; + goto put_timer; } snd_timer_proc_init(); return 0; + +put_timer: + put_device(&timer_dev); + return err; } static void __exit alsa_timer_exit(void) -- cgit v1.1 From f3f7df7635bd5fb6dbc8de150613d327a3bd6171 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 23 Aug 2017 08:03:43 +0200 Subject: ASoC: tegra: Fix unused variable warning Fixes: 2a8bd83af30e ("ASoC: tegra: Remove superfluous snd_soc_jack_free_gpios() call") Reported-by: Stephen Rothwell Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/tegra/tegra_wm8903.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index ce498cc..05f9594 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -203,7 +203,6 @@ static int tegra_wm8903_remove(struct snd_soc_card *card) snd_soc_get_pcm_runtime(card, card->dai_link[0].name); struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_codec *codec = codec_dai->codec; - struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); wm8903_mic_detect(codec, NULL, 0, 0); -- cgit v1.1 From 6cbcad079ecdb8ecd214d33688fd7f19167fe57a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 23 Aug 2017 05:11:44 +0000 Subject: ASoC: wm8524: remove unnecessary snd_soc_unregister_platform() wm8524 doesn't register platform, unregister platform is not needed Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8524.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c index b66147e..856a695 100644 --- a/sound/soc/codecs/wm8524.c +++ b/sound/soc/codecs/wm8524.c @@ -233,10 +233,8 @@ static int wm8524_codec_probe(struct platform_device *pdev) ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8524, &wm8524_dai, 1); - if (ret < 0) { + if (ret < 0) dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - snd_soc_unregister_platform(&pdev->dev); - } return ret; } -- cgit v1.1 From b4e0180306f10a9d808b855dd77cdd0d7ae4f3fa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 22 Aug 2017 04:56:06 +0000 Subject: ASoC: simple-scu-card: Add pm callbacks to platform driver Set snd_soc_pm_ops for the pm ops to make sure that the ASoC level of PM operations are going to happen. This is needed to get suspend/resume working correctly when the audio is using simple-scu-card. Reported-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/generic/simple-scu-card.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c index 0bb3da7..48606c6 100644 --- a/sound/soc/generic/simple-scu-card.c +++ b/sound/soc/generic/simple-scu-card.c @@ -300,6 +300,7 @@ MODULE_DEVICE_TABLE(of, asoc_simple_of_match); static struct platform_driver asoc_simple_card = { .driver = { .name = "simple-scu-audio-card", + .pm = &snd_soc_pm_ops, .of_match_table = asoc_simple_of_match, }, .probe = asoc_simple_card_probe, -- cgit v1.1 From 7b828a35ff834e45e5758a8a3f9d11db0526f9e1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 22 Aug 2017 04:56:44 +0000 Subject: ASoC: audio-graph-card: Add pm callbacks to platform driver Set snd_soc_pm_ops for the pm ops to make sure that the ASoC level of PM operations are going to happen. This is needed to get suspend/resume working correctly when the audio is using audio-graph-card. Reported-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 105ec3a..6304891 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -325,6 +325,7 @@ MODULE_DEVICE_TABLE(of, asoc_graph_of_match); static struct platform_driver asoc_graph_card = { .driver = { .name = "asoc-audio-graph-card", + .pm = &snd_soc_pm_ops, .of_match_table = asoc_graph_of_match, }, .probe = asoc_graph_card_probe, -- cgit v1.1 From 0995fb7c9802dd76422db384991f32296f8fbe1f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 22 Aug 2017 04:57:12 +0000 Subject: ASoC: audio-graph-scu-card: Add pm callbacks to platform driver Set snd_soc_pm_ops for the pm ops to make sure that the ASoC level of PM operations are going to happen. This is needed to get suspend/resume working correctly when the audio is using audio-graph-scu-card. Reported-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-scu-card.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index dcd2df3..da73e5d 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c @@ -398,6 +398,7 @@ MODULE_DEVICE_TABLE(of, asoc_graph_of_match); static struct platform_driver asoc_graph_card = { .driver = { .name = "asoc-audio-graph-scu-card", + .pm = &snd_soc_pm_ops, .of_match_table = asoc_graph_of_match, }, .probe = asoc_graph_card_probe, -- cgit v1.1 From 731209cc041779faac963578d901cb1caacbd738 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 23 Aug 2017 12:20:07 +0200 Subject: ALSA: usb-midi: Use common error handling code in __snd_usbmidi_create() Add jump targets so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Acked-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/usb/midi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/usb/midi.c b/sound/usb/midi.c index a35f4146..bd9d022 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -2435,10 +2435,8 @@ int __snd_usbmidi_create(struct snd_card *card, err = -ENXIO; break; } - if (err < 0) { - kfree(umidi); - return err; - } + if (err < 0) + goto free_midi; /* create rawmidi device */ out_ports = 0; @@ -2448,23 +2446,25 @@ int __snd_usbmidi_create(struct snd_card *card, in_ports += hweight16(endpoints[i].in_cables); } err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports); - if (err < 0) { - kfree(umidi); - return err; - } + if (err < 0) + goto free_midi; /* create endpoint/port structures */ if (quirk && quirk->type == QUIRK_MIDI_MIDIMAN) err = snd_usbmidi_create_endpoints_midiman(umidi, &endpoints[0]); else err = snd_usbmidi_create_endpoints(umidi, endpoints); - if (err < 0) { - return err; - } + if (err < 0) + goto exit; usb_autopm_get_interface_no_resume(umidi->iface); list_add_tail(&umidi->list, midi_list); return 0; + +free_midi: + kfree(umidi); +exit: + return err; } EXPORT_SYMBOL(__snd_usbmidi_create); -- cgit v1.1 From 3b3011adada3bba47c56c205634e1b32512e0c7c Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Tue, 22 Aug 2017 16:45:50 +0530 Subject: ASoC: Intel: Skylake: Fix to free dsp resource on ipc_init failure For some dsp init error path, irq and few more resources are not freed. This results in oops. So, fix it by freeing up the resources on ipc_init failure. Signed-off-by: Subhransu S. Prusty Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/bxt-sst.c | 4 +++- sound/soc/intel/skylake/cnl-sst.c | 4 +++- sound/soc/intel/skylake/skl-sst.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c index 5e1ac99..4524211 100644 --- a/sound/soc/intel/skylake/bxt-sst.c +++ b/sound/soc/intel/skylake/bxt-sst.c @@ -582,8 +582,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, SKL_ADSP_W0_UP_SZ, BXT_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ); ret = skl_ipc_init(dev, skl); - if (ret) + if (ret) { + skl_dsp_free(sst); return ret; + } /* set the D0i3 check */ skl->ipc.ops.check_dsp_lp_on = skl_ipc_check_D0i0; diff --git a/sound/soc/intel/skylake/cnl-sst.c b/sound/soc/intel/skylake/cnl-sst.c index 48ef04d..387de38 100644 --- a/sound/soc/intel/skylake/cnl-sst.c +++ b/sound/soc/intel/skylake/cnl-sst.c @@ -450,8 +450,10 @@ int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, CNL_ADSP_W1_SZ); ret = cnl_ipc_init(dev, cnl); - if (ret) + if (ret) { + skl_dsp_free(sst); return ret; + } cnl->boot_complete = false; init_waitqueue_head(&cnl->boot_wait); diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c index a7ad734..a436abf 100644 --- a/sound/soc/intel/skylake/skl-sst.c +++ b/sound/soc/intel/skylake/skl-sst.c @@ -562,8 +562,10 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, SKL_ADSP_W0_UP_SZ, SKL_ADSP_SRAM1_BASE, SKL_ADSP_W1_SZ); ret = skl_ipc_init(dev, skl); - if (ret) + if (ret) { + skl_dsp_free(sst); return ret; + } sst->fw_ops = skl_fw_ops; -- cgit v1.1 From f77d443c4c299aff5ad9c74811dd063f4d8bebcf Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Tue, 22 Aug 2017 16:45:51 +0530 Subject: ASoC: Intel: Skylake: Fix to free resources for dsp_init failure unmap mmio and free memory resources if dsp_init fails. Signed-off-by: Subhransu S. Prusty Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index bfb3332..f0f11f5 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -277,8 +277,10 @@ int skl_init_dsp(struct skl *skl) } ops = skl_get_dsp_ops(skl->pci->device); - if (!ops) - return -EIO; + if (!ops) { + goto unmap_mmio; + ret = -EIO; + } loader_ops = ops->loader_ops(); ret = ops->init(bus->dev, mmio_base, irq, @@ -286,25 +288,35 @@ int skl_init_dsp(struct skl *skl) &skl->skl_sst); if (ret < 0) - return ret; + goto unmap_mmio; skl->skl_sst->dsp_ops = ops; cores = &skl->skl_sst->cores; cores->count = ops->num_cores; cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL); - if (!cores->state) - return -ENOMEM; + if (!cores->state) { + ret = -ENOMEM; + goto unmap_mmio; + } cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count), GFP_KERNEL); if (!cores->usage_count) { - kfree(cores->state); - return -ENOMEM; + ret = -ENOMEM; + goto free_core_state; } dev_dbg(bus->dev, "dsp registration status=%d\n", ret); + return 0; + +free_core_state: + kfree(cores->state); + +unmap_mmio: + iounmap(mmio_base); + return ret; } -- cgit v1.1 From c360e0c3ab8ef8d0fd6b5501a407b9a2be4f204d Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Tue, 22 Aug 2017 16:45:52 +0530 Subject: ASoC: Intel: Skylake: Fix to free correct dev id in free_irq The dev_id passed by the driver in request_threaded_irq is an ebus pointer, whereas to free_irq it is hdac_bus. Fix by passing correct dev_id to free_irq. Signed-off-by: Subhransu S. Prusty Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index e612a40..d62ffbc 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -415,7 +415,7 @@ static int skl_free(struct hdac_ext_bus *ebus) snd_hdac_ext_stop_streams(ebus); if (bus->irq >= 0) - free_irq(bus->irq, (void *)bus); + free_irq(bus->irq, (void *)ebus); snd_hdac_bus_free_stream_pages(bus); snd_hdac_stream_free_all(ebus); snd_hdac_link_free_all(ebus); -- cgit v1.1 From 7b992c24de78a206b3abd07192686d2d5db5012c Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Tue, 22 Aug 2017 16:45:53 +0530 Subject: ASoC: Intel: Skylake: Fix DSP core ref count for init failure During dsp init failure, the ref count is not incremented and dsp is powered down. But as the skl driver calls put_core for the init failure it decrements the dsp core ref count and ref count becomes unbalanced. This results in dsp core powered up in further runtime suspend/resume cycles and never powered down. So increment the ref count before dsp core powerup and for any failure, decrement in put_core will be balanced. Signed-off-by: Subhransu S. Prusty Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-sst-dsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c index c2ba5ff..19ee1d4 100644 --- a/sound/soc/intel/skylake/skl-sst-dsp.c +++ b/sound/soc/intel/skylake/skl-sst-dsp.c @@ -351,6 +351,8 @@ int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id) return -EINVAL; } + skl->cores.usage_count[core_id]++; + if (skl->cores.state[core_id] == SKL_DSP_RESET) { ret = ctx->fw_ops.set_state_D0(ctx, core_id); if (ret < 0) { @@ -359,8 +361,6 @@ int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id) } } - skl->cores.usage_count[core_id]++; - out: dev_dbg(ctx->dev, "core id %d state %d usage_count %d\n", core_id, skl->cores.state[core_id], -- cgit v1.1 From cb0236eca79c8ceb5cdb8d2a15ce272e754d2921 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 22 Aug 2017 15:32:35 -0500 Subject: ASoC: codecs: rt5645: add quirks for Asus T100HA Fix jack detection and dmic setup Signed-off-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 9ec5816..500bb42 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3637,6 +3637,24 @@ static const struct dmi_system_id dmi_platform_gpd_win[] = { {} }; +static struct rt5645_platform_data general_platform_data2 = { + .dmic1_data_pin = RT5645_DMIC_DATA_IN2N, + .dmic2_data_pin = RT5645_DMIC2_DISABLE, + .jd_mode = 3, + .inv_jd1_1 = true, +}; + +static struct dmi_system_id dmi_platform_asus_t100ha[] = { + { + .ident = "ASUS T100HAN", + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "T100HAN"), + }, + }, + { } +}; + static bool rt5645_check_dp(struct device *dev) { if (device_property_present(dev, "realtek,in2-differential") || @@ -3689,6 +3707,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645->pdata = general_platform_data; else if (dmi_check_system(dmi_platform_gpd_win)) rt5645->pdata = gpd_win_platform_data; + else if (dmi_check_system(dmi_platform_asus_t100ha)) + rt5645->pdata = general_platform_data2; if (quirk != -1) { rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk); -- cgit v1.1 From c26d8389be4dab2bb5a8ac16211a9966bf67091a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 22 Aug 2017 15:32:37 -0500 Subject: ASoC: codecs: rt5670: add jack detection quirk for Dell Venue 5585 Jack is not detected by default, using jdmode=3 works fine Signed-off-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index 0f4e5bc..4ea51b4 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -2851,6 +2851,17 @@ static const struct dmi_system_id dmi_platform_intel_bytcht_jdmode2[] = { {} }; +static const struct dmi_system_id dmi_platform_intel_bytcht_jdmode3[] = { + { + .ident = "Dell Venue 8 Pro 5855", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5855"), + }, + }, + {} +}; + static int rt5670_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -2880,6 +2891,11 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_IN2P; rt5670->pdata.dev_gpio = true; rt5670->pdata.jd_mode = 2; + } else if (dmi_check_system(dmi_platform_intel_bytcht_jdmode3)) { + rt5670->pdata.dmic_en = true; + rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_IN2P; + rt5670->pdata.dev_gpio = true; + rt5670->pdata.jd_mode = 3; } rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); -- cgit v1.1 From af43173c80e424e2e5bc964c9d6a01cdaece8291 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 23 Aug 2017 14:45:20 +0200 Subject: ALSA: fireface: Use common error handling code in pcm_open() Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Reviewed-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/fireface/ff-pcm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index d12a0e3..e3c1630 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -138,16 +138,12 @@ static int pcm_open(struct snd_pcm_substream *substream) return err; err = pcm_init_hw_params(ff, substream); - if (err < 0) { - snd_ff_stream_lock_release(ff); - return err; - } + if (err < 0) + goto release_lock; err = ff->spec->protocol->get_clock(ff, &rate, &src); - if (err < 0) { - snd_ff_stream_lock_release(ff); - return err; - } + if (err < 0) + goto release_lock; if (src != SND_FF_CLOCK_SRC_INTERNAL) { for (i = 0; i < CIP_SFC_COUNT; ++i) { @@ -159,8 +155,8 @@ static int pcm_open(struct snd_pcm_substream *substream) * streaming engine can't support. */ if (i >= CIP_SFC_COUNT) { - snd_ff_stream_lock_release(ff); - return -EIO; + err = -EIO; + goto release_lock; } substream->runtime->hw.rate_min = rate; @@ -177,6 +173,10 @@ static int pcm_open(struct snd_pcm_substream *substream) snd_pcm_set_sync(substream); return 0; + +release_lock: + snd_ff_stream_lock_release(ff); + return err; } static int pcm_close(struct snd_pcm_substream *substream) -- cgit v1.1 From 9b419cd41b592f44127aeead34d5df24dff800f0 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 23 Aug 2017 17:39:25 +0530 Subject: ALSA: aaci: constify ac97_pcm structures ac97_pcm are not supposed to change at runtime. All functions working with ac97_pcm provided by work with const ac97_pcm. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 1b9f440..0114ffe 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -786,7 +786,7 @@ static SIMPLE_DEV_PM_OPS(aaci_dev_pm_ops, aaci_suspend, aaci_resume); #endif -static struct ac97_pcm ac97_defs[] = { +static const struct ac97_pcm ac97_defs[] = { [0] = { /* Front PCM */ .exclusive = 1, .r = { -- cgit v1.1 From 3ca8590be8e784d7b2c806f2bb7dcc2b492fdea5 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 23 Aug 2017 17:39:26 +0530 Subject: ALSA: ac97c: constify ac97_pcm structures ac97_pcm are not supposed to change at runtime. All functions working with ac97_pcm provided by work with const ac97_pcm. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 5402f82..24623c7 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -558,7 +558,7 @@ static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev) return retval; } -static struct ac97_pcm at91_ac97_pcm_defs[] = { +static const struct ac97_pcm at91_ac97_pcm_defs[] = { /* Playback */ { .exclusive = 1, -- cgit v1.1 From 9715f0bdb61e98652a1c84408f2bc059d01ce85b Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 23 Aug 2017 17:39:27 +0530 Subject: ALSA: atiixp: constify ac97_pcm structures ac97_pcm are not supposed to change at runtime. All functions working with ac97_pcm provided by work with const ac97_pcm. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index de53c2a..7ae63d4 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1183,7 +1183,7 @@ static const struct snd_pcm_ops snd_atiixp_spdif_ops = { .pointer = snd_atiixp_pcm_pointer, }; -static struct ac97_pcm atiixp_pcm_defs[] = { +static const struct ac97_pcm atiixp_pcm_defs[] = { /* front PCM */ { .exclusive = 1, -- cgit v1.1 From 668d06165c4a7d5bbb29fadd3e1b2d610b73c456 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Wed, 23 Aug 2017 17:39:28 +0530 Subject: ALSA: intel8x0: constify ac97_pcm structures ac97_pcm are not supposed to change at runtime. All functions working with ac97_pcm provided by work with const ac97_pcm. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 851ccff..4c24346 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1721,7 +1721,7 @@ static void snd_intel8x0_mixer_free_ac97(struct snd_ac97 *ac97) chip->ac97[ac97->num] = NULL; } -static struct ac97_pcm ac97_pcm_defs[] = { +static const struct ac97_pcm ac97_pcm_defs[] = { /* front PCM */ { .exclusive = 1, -- cgit v1.1 From faa119099e4942152fd2ff823ae9961ad00db475 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 23 Aug 2017 17:58:42 +0530 Subject: ALSA: ctxfi: make hw structures const Make these const as they are only used in a copy operation. Done using Coccinelle: @match disable optional_qualifier@ identifier s; @@ static struct hw s = {...}; @ref@ position p; identifier match.s; @@ s@p @good1@ position ref.p; identifier match.s,f,c; expression e; @@ ( e = s@p | e = s@p.f | c(...,s@p.f,...) | c(...,s@p,...) ) @bad depends on !good1@ position ref.p; identifier match.s; @@ s@p @depends on forall !bad disable optional_qualifier@ identifier match.s; @@ static + const struct hw s; Signed-off-by: Bhumika Goyal Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/cthw20k1.c | 2 +- sound/pci/ctxfi/cthw20k2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index 79edd88..8e6eb9d 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c @@ -2154,7 +2154,7 @@ static void hw_write_pci(struct hw *hw, u32 reg, u32 data) &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags); } -static struct hw ct20k1_preset = { +static const struct hw ct20k1_preset = { .irq = -1, .card_init = hw_card_init, diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 18ee776..b866d6b 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c @@ -2220,7 +2220,7 @@ static void hw_write_20kx(struct hw *hw, u32 reg, u32 data) writel(data, hw->mem_base + reg); } -static struct hw ct20k2_preset = { +static const struct hw ct20k2_preset = { .irq = -1, .card_init = hw_card_init, -- cgit v1.1 From cd6d6477f130c861c42e6eddc060e7c880e94bf3 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Wed, 23 Aug 2017 20:05:22 +0530 Subject: ASoC: rt5645: make rt5645_platform_data const Make these const as they are only used during a copy operation. Done using Coccinelle. @match disable optional_qualifier@ identifier s; @@ static struct rt5645_platform_data s = {...}; @ref@ position p; identifier match.s; @@ s@p @good1@ position ref.p; identifier match.s,f,c; expression e; @@ ( e = s@p | e = s@p.f | c(...,s@p.f,...) | c(...,s@p,...) ) @bad depends on !good1@ position ref.p; identifier match.s; @@ s@p @depends on forall !bad disable optional_qualifier@ identifier match.s; @@ static + const struct rt5645_platform_data s; Signed-off-by: Bhumika Goyal Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 500bb42..d2f0380 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3559,7 +3559,7 @@ static const struct acpi_device_id rt5645_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, rt5645_acpi_match); #endif -static struct rt5645_platform_data general_platform_data = { +static const struct rt5645_platform_data general_platform_data = { .dmic1_data_pin = RT5645_DMIC1_DISABLE, .dmic2_data_pin = RT5645_DMIC_DATA_IN2P, .jd_mode = 3, @@ -3593,7 +3593,7 @@ static const struct dmi_system_id dmi_platform_intel_braswell[] = { { } }; -static struct rt5645_platform_data buddy_platform_data = { +static const struct rt5645_platform_data buddy_platform_data = { .dmic1_data_pin = RT5645_DMIC_DATA_GPIO5, .dmic2_data_pin = RT5645_DMIC_DATA_IN2P, .jd_mode = 3, @@ -3610,7 +3610,7 @@ static struct dmi_system_id dmi_platform_intel_broadwell[] = { { } }; -static struct rt5645_platform_data gpd_win_platform_data = { +static const struct rt5645_platform_data gpd_win_platform_data = { .jd_mode = 3, .inv_jd1_1 = true, }; -- cgit v1.1 From 9149916f1e8c912c585ddebf12a98e99bd81aafe Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Wed, 23 Aug 2017 19:37:12 +0530 Subject: ASoC: Intel: Skylake: Fix uninitialized return On failure to get dsp_ops, dsp_init returns error without assigning ret. ret is assigned in code path which will never be executed. Fix it. Fixes: f77d443c4c29 ("ASoC: Intel: Skylake: Fix to free resources for dsp_init failure" Reported-by: kbuild test robot Signed-off-by: Subhransu S. Prusty Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index f0f11f5..697d07b 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -278,8 +278,8 @@ int skl_init_dsp(struct skl *skl) ops = skl_get_dsp_ops(skl->pci->device); if (!ops) { - goto unmap_mmio; ret = -EIO; + goto unmap_mmio; } loader_ops = ops->loader_ops(); -- cgit v1.1 From 5d3806eea2dd19b083c729a32aded6d012ead5ae Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Thu, 24 Aug 2017 11:55:28 +0530 Subject: ALSA: nm256: constify snd_ac97_res_table snd_ac97_res_table are not supposed to change at runtime. All functions working with snd_ac97_res_table provided by work with const snd_ac97_res_table. So mark the non-const structs as const. Signed-off-by: Arvind Yadav Signed-off-by: Takashi Iwai --- sound/pci/nm256/nm256.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 0ef8054..b97f4ea 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1271,7 +1271,7 @@ snd_nm256_ac97_write(struct snd_ac97 *ac97, } /* static resolution table */ -static struct snd_ac97_res_table nm256_res_table[] = { +static const struct snd_ac97_res_table nm256_res_table[] = { { AC97_MASTER, 0x1f1f }, { AC97_HEADPHONE, 0x1f1f }, { AC97_MASTER_MONO, 0x001f }, -- cgit v1.1 From fb8027ebfd4b8a3050edba66805bc360ed9b3f11 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 24 Aug 2017 10:46:14 +0900 Subject: ALSA: control: delegate TLV eventing to each driver In a design of ALSA control core, a set of elements is represented by 'struct snd_kcontrol' to share common attributes. The set of elements shares TLV (Type-Length-Value) data, too. On the other hand, in ALSA control interface/protocol for applications, a TLV operation is committed to an element. Totally, the operation can have sub-effect to the other elements in the set. For example, TLV_WRITE operation is expected to change TLV data, which returns to applications. Applications attempt to change the TLV data per element, but in the above design, they can effect to elements in the same set. As a default, ALSA control core has no implementation except for TLV_READ operation. Thus, the above design looks to have no issue. However, in kernel APIs of ALSA control component, developers can program a handler for any request of the TLV operation. Therefore, for elements in a set which has the handler, applications can commit TLV_WRITE and TLV_COMMAND requests. For the above scenario, ALSA control core assist notification. When the handler returns positive value, the core queueing an event for a requested element. However, this includes design defects that the event is not queued for the other element in a set. Actually, developers can program the handlers to keep per-element TLV data, but it depends on each driver. As of v4.13-rc6, there's no driver in tree to utilize the notification, except for user-defined element set. This commit delegates the notification into each driver to prevent developers from the design defects. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index de976a8..d6a8502 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1138,6 +1138,8 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, ue->tlv_data = container; ue->tlv_data_size = size; + snd_ctl_notify(ue->card, SNDRV_CTL_EVENT_MASK_TLV, &kctl->id); + return change; } @@ -1423,7 +1425,6 @@ static int call_tlv_handler(struct snd_ctl_file *file, int op_flag, }; struct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)]; int i; - int err; /* Check support of the request for this element. */ for (i = 0; i < ARRAY_SIZE(pairs); ++i) { @@ -1440,14 +1441,7 @@ static int call_tlv_handler(struct snd_ctl_file *file, int op_flag, if (vd->owner != NULL && vd->owner != file) return -EPERM; - err = kctl->tlv.c(kctl, op_flag, size, buf); - if (err < 0) - return err; - - if (err > 0) - snd_ctl_notify(file->card, SNDRV_CTL_EVENT_MASK_TLV, id); - - return 0; + return kctl->tlv.c(kctl, op_flag, size, buf); } static int read_tlv_buf(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id, -- cgit v1.1 From da4288287b68fe6902629f4e5306aba2a554bc4b Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 24 Aug 2017 10:46:15 +0900 Subject: ALSA: control: queue TLV event for a set of user-defined element In a design of user-defined element set, applications allow to change TLV data on the set. This operation doesn't only affects to a target element, but also to elements in the set. This commit generates TLV event for all of elements in the set when the TLV data is changed. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index d6a8502..6ddffe85 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1117,6 +1117,8 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, { struct user_element *ue = kctl->private_data; unsigned int *container; + struct snd_ctl_elem_id id; + int i; int change; if (size > 1024 * 128) /* sane value */ @@ -1138,7 +1140,10 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, ue->tlv_data = container; ue->tlv_data_size = size; - snd_ctl_notify(ue->card, SNDRV_CTL_EVENT_MASK_TLV, &kctl->id); + for (i = 0; i < kctl->count; ++i) { + snd_ctl_build_ioff(&id, kctl, i); + snd_ctl_notify(ue->card, SNDRV_CTL_EVENT_MASK_TLV, &id); + } return change; } -- cgit v1.1 From b8e2204b25a50e389dfb50eeff163fa796a8ec6e Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 24 Aug 2017 10:46:16 +0900 Subject: ALSA: control: TLV data is unavailable at initial state of user-defined element set For user-defined element set, in its initial state, TLV data is not registered. It's firstly available when any application register it by an additional operation. However, in current implementation, it's available in its initial state. As a result, applications get -ENXIO to read it. This commit controls its readability to manage info flags properly. In an initial state, elements don't have SND_CTL_ELEM_ACCESS_TLV_READ flag. Once TLV write operation is executed, they get the flag. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 6ddffe85..51d4b4a 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1118,6 +1118,7 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, struct user_element *ue = kctl->private_data; unsigned int *container; struct snd_ctl_elem_id id; + unsigned int mask = 0; int i; int change; @@ -1136,13 +1137,21 @@ static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, return 0; } + if (ue->tlv_data == NULL) { + /* Now TLV data is available. */ + for (i = 0; i < kctl->count; ++i) + kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; + mask = SNDRV_CTL_EVENT_MASK_INFO; + } + kfree(ue->tlv_data); ue->tlv_data = container; ue->tlv_data_size = size; + mask |= SNDRV_CTL_EVENT_MASK_TLV; for (i = 0; i < kctl->count; ++i) { snd_ctl_build_ioff(&id, kctl, i); - snd_ctl_notify(ue->card, SNDRV_CTL_EVENT_MASK_TLV, &id); + snd_ctl_notify(ue->card, mask, &id); } return change; @@ -1277,8 +1286,10 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, access = SNDRV_CTL_ELEM_ACCESS_READWRITE; access &= (SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE | - SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE); - if (access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) + SNDRV_CTL_ELEM_ACCESS_TLV_WRITE); + + /* In initial state, nothing is available as TLV container. */ + if (access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) access |= SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; access |= SNDRV_CTL_ELEM_ACCESS_USER; @@ -1341,7 +1352,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, kctl->get = snd_ctl_elem_user_get; if (access & SNDRV_CTL_ELEM_ACCESS_WRITE) kctl->put = snd_ctl_elem_user_put; - if (access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) + if (access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) kctl->tlv.c = snd_ctl_elem_user_tlv; /* This function manage to free the instance on failure. */ -- cgit v1.1 From 56026714bd45fccda710114982789c5145285560 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 24 Aug 2017 13:07:41 +0300 Subject: ASoC: codecs: msm8916-wcd-analog: always true condition Static checkers complain that unsigned int val is always >= 0. The context is that snd_soc_read() returns -1U on error. This is harmless because we're checking that CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK is not set, and it will always be set for -1U. I could have just removed the check against -1 but I preserved it because I thought it helped with readability. Signed-off-by: Dan Carpenter Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index f834a63..cd4d60e 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -949,7 +949,7 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) u32 val = snd_soc_read(codec, CDC_A_MBHC_RESULT_1); /* check if its BTN0 thats released */ - if ((val >= 0) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) + if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) priv->mbhc_btn0_pressed = false; } else { -- cgit v1.1 From d18420b0a0b8f8f51f55fc654b2e0eb86d8b41d7 Mon Sep 17 00:00:00 2001 From: Hsin-Yu Chao Date: Wed, 23 Aug 2017 18:29:31 +0800 Subject: ASoC: rt5514: expose Hotword Model control This change exposes mixer control 'Hotword Model' for switching hotword model in runtime. This new function requires updated firmware to load hotword model at address 0x4ff80000. Signed-off-by: Hsin-Yu Chao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/rt5514.h | 3 +++ 2 files changed, 55 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index a694ce9..0e239e8 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -302,6 +302,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); struct snd_soc_codec *codec = rt5514->codec; const struct firmware *fw = NULL; + int ret = 0; if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled) return 0; @@ -338,6 +339,27 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, fw = NULL; } + if (rt5514->model_buf && rt5514->model_len) { + ret = rt5514_spi_burst_write(0x4ff80000, + rt5514->model_buf, + ((rt5514->model_len / 8) + 1) * 8); + if (ret) { + dev_err(codec->dev, + "Model load failed %d\n", ret); + return ret; + } + } else { + request_firmware(&fw, RT5514_FIRMWARE3, + codec->dev); + if (fw) { + rt5514_spi_burst_write(0x4ff80000, + fw->data, + ((fw->size/8)+1)*8); + release_firmware(fw); + fw = NULL; + } + } + /* DSP run */ regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x00055148); @@ -352,6 +374,34 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, return 0; } +static int rt5514_hotword_model_put(struct snd_kcontrol *kcontrol, + const unsigned int __user *bytes, unsigned int size) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); + struct snd_soc_codec *codec = rt5514->codec; + int ret = 0; + + if (rt5514->model_buf || rt5514->model_len < size) { + if (rt5514->model_buf) + devm_kfree(codec->dev, rt5514->model_buf); + rt5514->model_buf = devm_kmalloc(codec->dev, size, GFP_KERNEL); + if (!rt5514->model_buf) { + ret = -ENOMEM; + goto done; + } + } + + /* Skips the TLV header. */ + bytes += 2; + + if (copy_from_user(rt5514->model_buf, bytes, size)) + ret = -EFAULT; +done: + rt5514->model_len = (ret ? 0 : size); + return ret; +} + static const struct snd_kcontrol_new rt5514_snd_controls[] = { SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST, RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv), @@ -363,6 +413,8 @@ static const struct snd_kcontrol_new rt5514_snd_controls[] = { adc_vol_tlv), SOC_SINGLE_EXT("DSP Voice Wake Up", SND_SOC_NOPM, 0, 1, 0, rt5514_dsp_voice_wake_up_get, rt5514_dsp_voice_wake_up_put), + SND_SOC_BYTES_TLV("Hotword Model", 0x8504, + NULL, rt5514_hotword_model_put), }; /* ADC Mixer*/ diff --git a/sound/soc/codecs/rt5514.h b/sound/soc/codecs/rt5514.h index 2dc40e6..803311c 100644 --- a/sound/soc/codecs/rt5514.h +++ b/sound/soc/codecs/rt5514.h @@ -255,6 +255,7 @@ #define RT5514_FIRMWARE1 "rt5514_dsp_fw1.bin" #define RT5514_FIRMWARE2 "rt5514_dsp_fw2.bin" +#define RT5514_FIRMWARE3 "rt5514_dsp_fw3.bin" /* System Clock Source */ enum { @@ -281,6 +282,8 @@ struct rt5514_priv { int pll_in; int pll_out; int dsp_enabled; + u8 *model_buf; + unsigned int model_len; }; #endif /* __RT5514_H__ */ -- cgit v1.1 From e6b4c525d94e6fb28d5c4b9eb4016caa12f68841 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 24 Aug 2017 22:11:07 +0200 Subject: ALSA: pcm: Correct broken procfs set up The commit c8da9be4a75f ("ALSA: pcm: Adjust nine function calls together with a variable assignment") contained a badly incorrect conversion, a "status" PCM procfs creation was replaced with the next one. Luckily, this could be spotted easily by the kernel runtime warning. Fixes: c8da9be4a75f ("ALSA: pcm: Adjust nine function calls together...") Reported-by: Fabio Estevam Tested-by: Fabio Estevam Signed-off-by: Takashi Iwai --- sound/core/pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/core/pcm.c b/sound/core/pcm.c index c790f79..7eadb7f 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -625,7 +625,8 @@ static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) } } substream->proc_sw_params_entry = entry; - entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL); + entry = snd_info_create_card_entry(card, "status", + substream->proc_root); if (entry) { snd_info_set_text_ops(entry, substream, snd_pcm_substream_proc_status_read); -- cgit v1.1 From 6a6dafda937cfcdbbfe46a3e093de8bb929ba52d Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 24 Aug 2017 12:40:17 +0800 Subject: ASoC: Add a sanity check before using dai driver name The dai driver's name is allowed to be NULL. So add a sanity check for that. Signed-off-by: Jeffy Chen Reported-by: Donglin Peng Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6fab0ff..74c1706 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1029,7 +1029,8 @@ struct snd_soc_dai *snd_soc_find_dai( continue; list_for_each_entry(dai, &component->dai_list, list) { if (dlc->dai_name && strcmp(dai->name, dlc->dai_name) - && strcmp(dai->driver->name, dlc->dai_name)) + && (!dai->driver->name + || strcmp(dai->driver->name, dlc->dai_name))) continue; return dai; -- cgit v1.1 From 9fc129f6e5de01ce5fccf033485e40dfa429b45c Mon Sep 17 00:00:00 2001 From: Shreyas NC Date: Wed, 23 Aug 2017 19:33:48 +0530 Subject: ASoC: Intel: Skylake: Parse multiple manifest data blocks Currently we can parse a single manifest data block. But manifest private data can have multiple data blocks. So, fix the parsing logic to parse multiple data blocks by returning offset of each parsed data block. Signed-off-by: Shreyas NC Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 350d238..f14b373 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -2721,14 +2721,12 @@ static int skl_tplg_get_manifest_tkn(struct device *dev, tkn_count = tkn_count + ret; tkn_elem++; - tuple_size += tkn_count * - sizeof(struct snd_soc_tplg_vendor_value_elem); - break; } + tuple_size += (tkn_count * sizeof(*tkn_elem)); tkn_count = 0; } - return 0; + return off; } /* @@ -2751,11 +2749,10 @@ static int skl_tplg_get_manifest_data(struct snd_soc_tplg_manifest *manifest, num_blocks = ret; off += array->size; - array = (struct snd_soc_tplg_vendor_array *) - (manifest->priv.data + off); - /* Read the BLOCK_TYPE and BLOCK_SIZE descriptor */ while (num_blocks > 0) { + array = (struct snd_soc_tplg_vendor_array *) + (manifest->priv.data + off); ret = skl_tplg_get_desc_blocks(dev, array); if (ret < 0) @@ -2789,6 +2786,7 @@ static int skl_tplg_get_manifest_data(struct snd_soc_tplg_manifest *manifest, } else { return -EINVAL; } + off += ret; } return 0; -- cgit v1.1 From ca312fda690e94c704bcb0e21b73b5d5bd1cf1ff Mon Sep 17 00:00:00 2001 From: Shreyas NC Date: Wed, 23 Aug 2017 19:33:50 +0530 Subject: ASoC: Intel: Skylake: Commonize parsing of format tokens Format resource tokens can be a part of either the widget or manifest private data. In the current model, format resources come as a part of widget private data and they come as a part of topology manifest in the newly introduced model. So add a common function that can fill up either of the structures. Signed-off-by: Shreyas NC Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 47 +++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index f14b373..df808fb 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -1948,27 +1948,9 @@ static int skl_tplg_fill_pins_info(struct device *dev, * on the direction */ static int skl_tplg_fill_fmt(struct device *dev, - struct skl_module_cfg *mconfig, u32 tkn, - u32 value, u32 dir, u32 pin_count) + struct skl_module_fmt *dst_fmt, + u32 tkn, u32 value) { - struct skl_module_fmt *dst_fmt; - - switch (dir) { - case SKL_DIR_IN: - dst_fmt = mconfig->in_fmt; - dst_fmt += pin_count; - break; - - case SKL_DIR_OUT: - dst_fmt = mconfig->out_fmt; - dst_fmt += pin_count; - break; - - default: - dev_err(dev, "Invalid direction value\n"); - return -EINVAL; - } - switch (tkn) { case SKL_TKN_U32_FMT_CH: dst_fmt->channels = value; @@ -2010,6 +1992,29 @@ static int skl_tplg_fill_fmt(struct device *dev, return 0; } +static int skl_tplg_widget_fill_fmt(struct device *dev, + struct skl_module_cfg *mconfig, + u32 tkn, u32 val, u32 dir, int fmt_idx) +{ + struct skl_module_fmt *dst_fmt; + + switch (dir) { + case SKL_DIR_IN: + dst_fmt = &mconfig->in_fmt[fmt_idx]; + break; + + case SKL_DIR_OUT: + dst_fmt = &mconfig->out_fmt[fmt_idx]; + break; + + default: + dev_err(dev, "Invalid direction: %d\n", dir); + return -EINVAL; + } + + return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val); +} + static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig, struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn) { @@ -2190,7 +2195,7 @@ static int skl_tplg_get_token(struct device *dev, case SKL_TKN_U32_FMT_INTERLEAVE: case SKL_TKN_U32_FMT_SAMPLE_TYPE: case SKL_TKN_U32_FMT_CH_MAP: - ret = skl_tplg_fill_fmt(dev, mconfig, tkn_elem->token, + ret = skl_tplg_widget_fill_fmt(dev, mconfig, tkn_elem->token, tkn_elem->value, dir, pin_index); if (ret < 0) -- cgit v1.1 From 822c3b044f7fbecc9894fcd3d19fc2ad51232fdb Mon Sep 17 00:00:00 2001 From: Shreyas NC Date: Wed, 23 Aug 2017 19:33:51 +0530 Subject: ASoC: Intel: Skylake: Add driver structures to be filled from topology manifest The topology manifest would include module common data including resource and interface table. The resource table consists of resources required by the dsp module such as buffer size, cycles per second, number of input/output pins. And, the interface table consists of pcm parameters per module which can be referenced later. So define the structures accordingly to represent topology manifest data in the driver. Signed-off-by: Shreyas NC Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.h | 52 ++++++++++++++++++++++++++++++++++ sound/soc/intel/skylake/skl.h | 2 ++ 2 files changed, 54 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index c25e886..93b2ba8 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -44,6 +44,13 @@ #define SKL_DEFAULT_MIC_SEL_GAIN 0x3FF #define SKL_MIC_SEL_SWITCH 0x3 +#define SKL_OUTPUT_PIN 0 +#define SKL_INPUT_PIN 1 +#define SKL_MAX_PATH_CONFIGS 8 +#define SKL_MAX_MODULES_IN_PIPE 8 +#define SKL_MAX_MODULE_FORMATS 32 +#define SKL_MAX_MODULE_RESOURCES 32 + enum skl_channel_index { SKL_CHANNEL_LEFT = 0, SKL_CHANNEL_RIGHT = 1, @@ -292,6 +299,51 @@ enum d0i3_capability { SKL_D0I3_NON_STREAMING = 2, }; +struct skl_module_pin_fmt { + u8 id; + struct skl_module_fmt fmt; +}; + +struct skl_module_iface { + u8 fmt_idx; + u8 nr_in_fmt; + u8 nr_out_fmt; + struct skl_module_pin_fmt inputs[MAX_IN_QUEUE]; + struct skl_module_pin_fmt outputs[MAX_OUT_QUEUE]; +}; + +struct skl_module_pin_resources { + u8 pin_index; + u32 buf_size; +}; + +struct skl_module_res { + u8 id; + u32 is_pages; + u32 cps; + u32 ibs; + u32 obs; + u32 dma_buffer_size; + u32 cpc; + u8 nr_input_pins; + u8 nr_output_pins; + struct skl_module_pin_resources input[MAX_IN_QUEUE]; + struct skl_module_pin_resources output[MAX_OUT_QUEUE]; +}; + +struct skl_module { + uuid_le uuid; + u8 loadable; + u8 input_pin_type; + u8 output_pin_type; + u8 max_input_pins; + u8 max_output_pins; + u8 nr_resources; + u8 nr_interfaces; + struct skl_module_res resources[SKL_MAX_MODULE_RESOURCES]; + struct skl_module_iface formats[SKL_MAX_MODULE_FORMATS]; +}; + struct skl_module_cfg { u8 guid[16]; struct skl_module_inst_id id; diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 20017ee..8d9d689 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -71,6 +71,8 @@ struct skl { struct work_struct probe_work; struct skl_debug *debugfs; + u8 nr_modules; + struct skl_module **modules; }; #define skl_to_ebus(s) (&(s)->ebus) -- cgit v1.1 From db6ed55de6da1125ff349bfe4ef12d18c366e893 Mon Sep 17 00:00:00 2001 From: Shreyas NC Date: Wed, 23 Aug 2017 19:33:52 +0530 Subject: ASoC: Intel: Skylake: Populate module data from topology manifest All the module common data will now be populated in the topology manifest. This includes the resource and interface list supported by the module. With this, driver need not compute the resources required by each dsp module for a particular pcm parameter since it comes as a part of the topology manifest. So, add functions to parse the manifest tokens to populate the module config data structure. Signed-off-by: Shreyas NC Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 320 ++++++++++++++++++++++++++++++++- 1 file changed, 316 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index df808fb..f398830 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -2038,6 +2038,104 @@ static void skl_tplg_fill_pin_dynamic_val( } /* + * Resource table in the manifest has pin specific resources + * like pin and pin buffer size + */ +static int skl_tplg_manifest_pin_res_tkn(struct device *dev, + struct snd_soc_tplg_vendor_value_elem *tkn_elem, + struct skl_module_res *res, int pin_idx, int dir) +{ + struct skl_module_pin_resources *m_pin; + + switch (dir) { + case SKL_DIR_IN: + m_pin = &res->input[pin_idx]; + break; + + case SKL_DIR_OUT: + m_pin = &res->output[pin_idx]; + break; + + default: + dev_err(dev, "Invalid pin direction: %d\n", dir); + return -EINVAL; + } + + switch (tkn_elem->token) { + case SKL_TKN_MM_U32_RES_PIN_ID: + m_pin->pin_index = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_PIN_BUF: + m_pin->buf_size = tkn_elem->value; + break; + + default: + dev_err(dev, "Invalid token: %d\n", tkn_elem->token); + return -EINVAL; + } + + return 0; +} + +/* + * Fill module specific resources from the manifest's resource + * table like CPS, DMA size, mem_pages. + */ +static int skl_tplg_fill_res_tkn(struct device *dev, + struct snd_soc_tplg_vendor_value_elem *tkn_elem, + struct skl_module_res *res, + int pin_idx, int dir) +{ + int ret, tkn_count = 0; + + if (!res) + return -EINVAL; + + switch (tkn_elem->token) { + case SKL_TKN_MM_U32_CPS: + res->cps = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_DMA_SIZE: + res->dma_buffer_size = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_CPC: + res->cpc = tkn_elem->value; + break; + + case SKL_TKN_U32_MEM_PAGES: + res->is_pages = tkn_elem->value; + break; + + case SKL_TKN_U32_OBS: + res->obs = tkn_elem->value; + break; + + case SKL_TKN_U32_IBS: + res->ibs = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_RES_PIN_ID: + case SKL_TKN_MM_U32_PIN_BUF: + ret = skl_tplg_manifest_pin_res_tkn(dev, tkn_elem, res, + pin_idx, dir); + if (ret < 0) + return ret; + break; + + default: + dev_err(dev, "Not a res type token: %d", tkn_elem->token); + return -EINVAL; + + } + tkn_count++; + + return tkn_count; +} + +/* * Parse tokens to fill up the module private data */ static int skl_tplg_get_token(struct device *dev, @@ -2625,13 +2723,13 @@ static int skl_tplg_fill_str_mfest_tkn(struct device *dev, str_elem->string, ARRAY_SIZE(skl->skl_sst->lib_info[ref_count].name)); ref_count++; - tkn_count++; break; default: dev_err(dev, "Not a string token %d\n", str_elem->token); break; } + tkn_count++; return tkn_count; } @@ -2657,26 +2755,236 @@ static int skl_tplg_get_str_tkn(struct device *dev, return tkn_count; } +static int skl_tplg_manifest_fill_fmt(struct device *dev, + struct skl_module_iface *fmt, + struct snd_soc_tplg_vendor_value_elem *tkn_elem, + u32 dir, int fmt_idx) +{ + struct skl_module_pin_fmt *dst_fmt; + struct skl_module_fmt *mod_fmt; + int ret; + + if (!fmt) + return -EINVAL; + + switch (dir) { + case SKL_DIR_IN: + dst_fmt = &fmt->inputs[fmt_idx]; + break; + + case SKL_DIR_OUT: + dst_fmt = &fmt->outputs[fmt_idx]; + break; + + default: + dev_err(dev, "Invalid direction: %d\n", dir); + return -EINVAL; + } + + mod_fmt = &dst_fmt->fmt; + + switch (tkn_elem->token) { + case SKL_TKN_MM_U32_INTF_PIN_ID: + dst_fmt->id = tkn_elem->value; + break; + + default: + ret = skl_tplg_fill_fmt(dev, mod_fmt, tkn_elem->token, + tkn_elem->value); + if (ret < 0) + return ret; + break; + } + + return 0; +} + +static int skl_tplg_fill_mod_info(struct device *dev, + struct snd_soc_tplg_vendor_value_elem *tkn_elem, + struct skl_module *mod) +{ + + if (!mod) + return -EINVAL; + + switch (tkn_elem->token) { + case SKL_TKN_U8_IN_PIN_TYPE: + mod->input_pin_type = tkn_elem->value; + break; + + case SKL_TKN_U8_OUT_PIN_TYPE: + mod->output_pin_type = tkn_elem->value; + break; + + case SKL_TKN_U8_IN_QUEUE_COUNT: + mod->max_input_pins = tkn_elem->value; + break; + + case SKL_TKN_U8_OUT_QUEUE_COUNT: + mod->max_output_pins = tkn_elem->value; + break; + + case SKL_TKN_MM_U8_NUM_RES: + mod->nr_resources = tkn_elem->value; + break; + + case SKL_TKN_MM_U8_NUM_INTF: + mod->nr_interfaces = tkn_elem->value; + break; + + default: + dev_err(dev, "Invalid mod info token %d", tkn_elem->token); + return -EINVAL; + } + + return 0; +} + + static int skl_tplg_get_int_tkn(struct device *dev, struct snd_soc_tplg_vendor_value_elem *tkn_elem, struct skl *skl) { - int tkn_count = 0; + int tkn_count = 0, ret; + static int mod_idx, res_val_idx, intf_val_idx, dir, pin_idx; + struct skl_module_res *res = NULL; + struct skl_module_iface *fmt = NULL; + struct skl_module *mod = NULL; + int i; + + if (skl->modules) { + mod = skl->modules[mod_idx]; + res = &mod->resources[res_val_idx]; + fmt = &mod->formats[intf_val_idx]; + } switch (tkn_elem->token) { case SKL_TKN_U32_LIB_COUNT: skl->skl_sst->lib_count = tkn_elem->value; - tkn_count++; + break; + + case SKL_TKN_U8_NUM_MOD: + skl->nr_modules = tkn_elem->value; + skl->modules = devm_kcalloc(dev, skl->nr_modules, + sizeof(*skl->modules), GFP_KERNEL); + if (!skl->modules) + return -ENOMEM; + + for (i = 0; i < skl->nr_modules; i++) { + skl->modules[i] = devm_kzalloc(dev, + sizeof(struct skl_module), GFP_KERNEL); + if (!skl->modules[i]) + return -ENOMEM; + } + break; + + case SKL_TKN_MM_U8_MOD_IDX: + mod_idx = tkn_elem->value; + break; + + case SKL_TKN_U8_IN_PIN_TYPE: + case SKL_TKN_U8_OUT_PIN_TYPE: + case SKL_TKN_U8_IN_QUEUE_COUNT: + case SKL_TKN_U8_OUT_QUEUE_COUNT: + case SKL_TKN_MM_U8_NUM_RES: + case SKL_TKN_MM_U8_NUM_INTF: + ret = skl_tplg_fill_mod_info(dev, tkn_elem, mod); + if (ret < 0) + return ret; + break; + + case SKL_TKN_U32_DIR_PIN_COUNT: + dir = tkn_elem->value & SKL_IN_DIR_BIT_MASK; + pin_idx = (tkn_elem->value & SKL_PIN_COUNT_MASK) >> 4; + break; + + case SKL_TKN_MM_U32_RES_ID: + if (!res) + return -EINVAL; + + res->id = tkn_elem->value; + res_val_idx = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_FMT_ID: + if (!fmt) + return -EINVAL; + + fmt->fmt_idx = tkn_elem->value; + intf_val_idx = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_CPS: + case SKL_TKN_MM_U32_DMA_SIZE: + case SKL_TKN_MM_U32_CPC: + case SKL_TKN_U32_MEM_PAGES: + case SKL_TKN_U32_OBS: + case SKL_TKN_U32_IBS: + case SKL_TKN_MM_U32_RES_PIN_ID: + case SKL_TKN_MM_U32_PIN_BUF: + ret = skl_tplg_fill_res_tkn(dev, tkn_elem, res, pin_idx, dir); + if (ret < 0) + return ret; + + break; + + case SKL_TKN_MM_U32_NUM_IN_FMT: + if (!fmt) + return -EINVAL; + + res->nr_input_pins = tkn_elem->value; + break; + + case SKL_TKN_MM_U32_NUM_OUT_FMT: + if (!fmt) + return -EINVAL; + + res->nr_output_pins = tkn_elem->value; + break; + + case SKL_TKN_U32_FMT_CH: + case SKL_TKN_U32_FMT_FREQ: + case SKL_TKN_U32_FMT_BIT_DEPTH: + case SKL_TKN_U32_FMT_SAMPLE_SIZE: + case SKL_TKN_U32_FMT_CH_CONFIG: + case SKL_TKN_U32_FMT_INTERLEAVE: + case SKL_TKN_U32_FMT_SAMPLE_TYPE: + case SKL_TKN_U32_FMT_CH_MAP: + case SKL_TKN_MM_U32_INTF_PIN_ID: + ret = skl_tplg_manifest_fill_fmt(dev, fmt, tkn_elem, + dir, pin_idx); + if (ret < 0) + return ret; break; default: dev_err(dev, "Not a manifest token %d\n", tkn_elem->token); return -EINVAL; } + tkn_count++; return tkn_count; } +static int skl_tplg_get_manifest_uuid(struct device *dev, + struct skl *skl, + struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn) +{ + static int ref_count; + struct skl_module *mod; + + if (uuid_tkn->token == SKL_TKN_UUID) { + mod = skl->modules[ref_count]; + memcpy(&mod->uuid, &uuid_tkn->uuid, sizeof(uuid_tkn->uuid)); + ref_count++; + } else { + dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token); + return -EINVAL; + } + + return 0; +} + /* * Fill the manifest structure by parsing the tokens based on the * type. @@ -2709,7 +3017,11 @@ static int skl_tplg_get_manifest_tkn(struct device *dev, continue; case SND_SOC_TPLG_TUPLE_TYPE_UUID: - dev_warn(dev, "no uuid tokens for skl tplf manifest\n"); + ret = skl_tplg_get_manifest_uuid(dev, skl, array->uuid); + if (ret < 0) + return ret; + + tuple_size += sizeof(*array->uuid); continue; default: -- cgit v1.1 From f6fa56e22559ade7287ca7c1b7218a08f516f379 Mon Sep 17 00:00:00 2001 From: Ramesh Babu Date: Wed, 23 Aug 2017 19:33:53 +0530 Subject: ASoC: Intel: Skylake: Parse and update module config structure A dsp path and the modules in the path can support various pcm configurations. The list of supported pcm configurations from topology manifest would be stored and later selected runtime based on the hw pcm params. For legacy, module data is filled in the 0th index of resource and interface table. To accommodate both models, change the relevant structures and populate them by parsing newly defined tokens. This change is backward compatible with the existing model where driver computes the resources required by each dsp module. Signed-off-by: Ramesh Babu Signed-off-by: Shreyas NC Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 59 ++++-- sound/soc/intel/skylake/skl-pcm.c | 3 +- sound/soc/intel/skylake/skl-topology.c | 342 +++++++++++++++++++++++++-------- sound/soc/intel/skylake/skl-topology.h | 25 +++ 4 files changed, 334 insertions(+), 95 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 697d07b..ea83e8b 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -443,9 +443,12 @@ static void skl_set_base_module_format(struct skl_sst *ctx, struct skl_module_cfg *mconfig, struct skl_base_cfg *base_cfg) { - struct skl_module_fmt *format = &mconfig->in_fmt[0]; + struct skl_module *module = mconfig->module; + struct skl_module_res *res = &module->resources[mconfig->res_idx]; + struct skl_module_iface *fmt = &module->formats[mconfig->fmt_idx]; + struct skl_module_fmt *format = &fmt->inputs[0].fmt; - base_cfg->audio_fmt.number_of_channels = (u8)format->channels; + base_cfg->audio_fmt.number_of_channels = format->channels; base_cfg->audio_fmt.s_freq = format->s_freq; base_cfg->audio_fmt.bit_depth = format->bit_depth; @@ -460,10 +463,10 @@ static void skl_set_base_module_format(struct skl_sst *ctx, base_cfg->audio_fmt.interleaving = format->interleaving_style; - base_cfg->cps = mconfig->mcps; - base_cfg->ibs = mconfig->ibs; - base_cfg->obs = mconfig->obs; - base_cfg->is_pages = mconfig->mem_pages; + base_cfg->cps = res->cps; + base_cfg->ibs = res->ibs; + base_cfg->obs = res->obs; + base_cfg->is_pages = res->is_pages; } /* @@ -551,6 +554,9 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, struct skl_cpr_cfg *cpr_mconfig) { u32 dma_io_buf; + struct skl_module_res *res; + int res_idx = mconfig->res_idx; + struct skl *skl = get_skl_ctx(ctx->dev); cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(ctx, mconfig); @@ -559,19 +565,27 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, return; } + if (skl->nr_modules) { + res = &mconfig->module->resources[mconfig->res_idx]; + cpr_mconfig->gtw_cfg.dma_buffer_size = res->dma_buffer_size; + goto skip_buf_size_calc; + } else { + res = &mconfig->module->resources[res_idx]; + } + switch (mconfig->hw_conn_type) { case SKL_CONN_SOURCE: if (mconfig->dev_type == SKL_DEVICE_HDAHOST) - dma_io_buf = mconfig->ibs; + dma_io_buf = res->ibs; else - dma_io_buf = mconfig->obs; + dma_io_buf = res->obs; break; case SKL_CONN_SINK: if (mconfig->dev_type == SKL_DEVICE_HDAHOST) - dma_io_buf = mconfig->obs; + dma_io_buf = res->obs; else - dma_io_buf = mconfig->ibs; + dma_io_buf = res->ibs; break; default: @@ -586,11 +600,12 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, /* fallback to 2ms default value */ if (!cpr_mconfig->gtw_cfg.dma_buffer_size) { if (mconfig->hw_conn_type == SKL_CONN_SOURCE) - cpr_mconfig->gtw_cfg.dma_buffer_size = 2 * mconfig->obs; + cpr_mconfig->gtw_cfg.dma_buffer_size = 2 * res->obs; else - cpr_mconfig->gtw_cfg.dma_buffer_size = 2 * mconfig->ibs; + cpr_mconfig->gtw_cfg.dma_buffer_size = 2 * res->ibs; } +skip_buf_size_calc: cpr_mconfig->cpr_feature_mask = 0; cpr_mconfig->gtw_cfg.config_length = 0; @@ -638,7 +653,9 @@ static void skl_setup_out_format(struct skl_sst *ctx, struct skl_module_cfg *mconfig, struct skl_audio_data_format *out_fmt) { - struct skl_module_fmt *format = &mconfig->out_fmt[0]; + struct skl_module *module = mconfig->module; + struct skl_module_iface *fmt = &module->formats[mconfig->fmt_idx]; + struct skl_module_fmt *format = &fmt->outputs[0].fmt; out_fmt->number_of_channels = (u8)format->channels; out_fmt->s_freq = format->s_freq; @@ -663,7 +680,9 @@ static void skl_set_src_format(struct skl_sst *ctx, struct skl_module_cfg *mconfig, struct skl_src_module_cfg *src_mconfig) { - struct skl_module_fmt *fmt = &mconfig->out_fmt[0]; + struct skl_module *module = mconfig->module; + struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx]; + struct skl_module_fmt *fmt = &iface->outputs[0].fmt; skl_set_base_module_format(ctx, mconfig, (struct skl_base_cfg *)src_mconfig); @@ -680,7 +699,9 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx, struct skl_module_cfg *mconfig, struct skl_up_down_mixer_cfg *mixer_mconfig) { - struct skl_module_fmt *fmt = &mconfig->out_fmt[0]; + struct skl_module *module = mconfig->module; + struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx]; + struct skl_module_fmt *fmt = &iface->outputs[0].fmt; int i = 0; skl_set_base_module_format(ctx, mconfig, @@ -1013,8 +1034,8 @@ int skl_unbind_modules(struct skl_sst *ctx, struct skl_ipc_bind_unbind_msg msg; struct skl_module_inst_id src_id = src_mcfg->id; struct skl_module_inst_id dst_id = dst_mcfg->id; - int in_max = dst_mcfg->max_in_queue; - int out_max = src_mcfg->max_out_queue; + int in_max = dst_mcfg->module->max_input_pins; + int out_max = src_mcfg->module->max_output_pins; int src_index, dst_index, src_pin_state, dst_pin_state; skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); @@ -1075,8 +1096,8 @@ int skl_bind_modules(struct skl_sst *ctx, { int ret; struct skl_ipc_bind_unbind_msg msg; - int in_max = dst_mcfg->max_in_queue; - int out_max = src_mcfg->max_out_queue; + int in_max = dst_mcfg->module->max_input_pins; + int out_max = src_mcfg->module->max_output_pins; int src_index, dst_index; skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index f6c9adb..a756882 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1233,7 +1233,8 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) list_for_each_entry(module, &ctx->uuid_list, list) { if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) { mconfig->id.module_id = module->id; - mconfig->is_loadable = module->is_loadable; + if (mconfig->module) + mconfig->module->loadable = module->is_loadable; return 0; } } diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index f398830..22f768c 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -49,6 +49,9 @@ static const int mic_quatro_list[][SKL_CH_QUATRO] = { {0, 1, 2, 3}, }; +#define CHECK_HW_PARAMS(ch, freq, bps, prm_ch, prm_freq, prm_bps) \ + ((ch == prm_ch) && (bps == prm_bps) && (freq == prm_freq)) + void skl_tplg_d0i3_get(struct skl *skl, enum d0i3_capability caps) { struct skl_d0i3_data *d0i3 = &skl->skl_sst->d0i3; @@ -153,8 +156,10 @@ static bool skl_is_pipe_mcps_avail(struct skl *skl, struct skl_module_cfg *mconfig) { struct skl_sst *ctx = skl->skl_sst; + u8 res_idx = mconfig->res_idx; + struct skl_module_res *res = &mconfig->module->resources[res_idx]; - if (skl->resource.mcps + mconfig->mcps > skl->resource.max_mcps) { + if (skl->resource.mcps + res->cps > skl->resource.max_mcps) { dev_err(ctx->dev, "%s: module_id %d instance %d\n", __func__, mconfig->id.module_id, mconfig->id.instance_id); @@ -170,7 +175,10 @@ static bool skl_is_pipe_mcps_avail(struct skl *skl, static void skl_tplg_alloc_pipe_mcps(struct skl *skl, struct skl_module_cfg *mconfig) { - skl->resource.mcps += mconfig->mcps; + u8 res_idx = mconfig->res_idx; + struct skl_module_res *res = &mconfig->module->resources[res_idx]; + + skl->resource.mcps += res->cps; } /* @@ -179,7 +187,11 @@ static void skl_tplg_alloc_pipe_mcps(struct skl *skl, static void skl_tplg_free_pipe_mcps(struct skl *skl, struct skl_module_cfg *mconfig) { - skl->resource.mcps -= mconfig->mcps; + u8 res_idx = mconfig->res_idx; + struct skl_module_res *res = &mconfig->module->resources[res_idx]; + + res = &mconfig->module->resources[res_idx]; + skl->resource.mcps -= res->cps; } /* @@ -195,17 +207,21 @@ skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig) static void skl_dump_mconfig(struct skl_sst *ctx, struct skl_module_cfg *mcfg) { + struct skl_module_iface *iface = &mcfg->module->formats[0]; + dev_dbg(ctx->dev, "Dumping config\n"); dev_dbg(ctx->dev, "Input Format:\n"); - dev_dbg(ctx->dev, "channels = %d\n", mcfg->in_fmt[0].channels); - dev_dbg(ctx->dev, "s_freq = %d\n", mcfg->in_fmt[0].s_freq); - dev_dbg(ctx->dev, "ch_cfg = %d\n", mcfg->in_fmt[0].ch_cfg); - dev_dbg(ctx->dev, "valid bit depth = %d\n", mcfg->in_fmt[0].valid_bit_depth); + dev_dbg(ctx->dev, "channels = %d\n", iface->inputs[0].fmt.channels); + dev_dbg(ctx->dev, "s_freq = %d\n", iface->inputs[0].fmt.s_freq); + dev_dbg(ctx->dev, "ch_cfg = %d\n", iface->inputs[0].fmt.ch_cfg); + dev_dbg(ctx->dev, "valid bit depth = %d\n", + iface->inputs[0].fmt.valid_bit_depth); dev_dbg(ctx->dev, "Output Format:\n"); - dev_dbg(ctx->dev, "channels = %d\n", mcfg->out_fmt[0].channels); - dev_dbg(ctx->dev, "s_freq = %d\n", mcfg->out_fmt[0].s_freq); - dev_dbg(ctx->dev, "valid bit depth = %d\n", mcfg->out_fmt[0].valid_bit_depth); - dev_dbg(ctx->dev, "ch_cfg = %d\n", mcfg->out_fmt[0].ch_cfg); + dev_dbg(ctx->dev, "channels = %d\n", iface->outputs[0].fmt.channels); + dev_dbg(ctx->dev, "s_freq = %d\n", iface->outputs[0].fmt.s_freq); + dev_dbg(ctx->dev, "valid bit depth = %d\n", + iface->outputs[0].fmt.valid_bit_depth); + dev_dbg(ctx->dev, "ch_cfg = %d\n", iface->outputs[0].fmt.ch_cfg); } static void skl_tplg_update_chmap(struct skl_module_fmt *fmt, int chs) @@ -273,8 +289,8 @@ static void skl_tplg_update_params_fixup(struct skl_module_cfg *m_cfg, struct skl_module_fmt *in_fmt, *out_fmt; /* Fixups will be applied to pin 0 only */ - in_fmt = &m_cfg->in_fmt[0]; - out_fmt = &m_cfg->out_fmt[0]; + in_fmt = &m_cfg->module->formats[0].inputs[0].fmt; + out_fmt = &m_cfg->module->formats[0].outputs[0].fmt; if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (is_fe) { @@ -312,21 +328,23 @@ static void skl_tplg_update_buffer_size(struct skl_sst *ctx, { int multiplier = 1; struct skl_module_fmt *in_fmt, *out_fmt; + struct skl_module_res *res; /* Since fixups is applied to pin 0 only, ibs, obs needs * change for pin 0 only */ - in_fmt = &mcfg->in_fmt[0]; - out_fmt = &mcfg->out_fmt[0]; + res = &mcfg->module->resources[0]; + in_fmt = &mcfg->module->formats[0].inputs[0].fmt; + out_fmt = &mcfg->module->formats[0].outputs[0].fmt; if (mcfg->m_type == SKL_MODULE_TYPE_SRCINT) multiplier = 5; - mcfg->ibs = DIV_ROUND_UP(in_fmt->s_freq, 1000) * + res->ibs = DIV_ROUND_UP(in_fmt->s_freq, 1000) * in_fmt->channels * (in_fmt->bit_depth >> 3) * multiplier; - mcfg->obs = DIV_ROUND_UP(out_fmt->s_freq, 1000) * + res->obs = DIV_ROUND_UP(out_fmt->s_freq, 1000) * out_fmt->channels * (out_fmt->bit_depth >> 3) * multiplier; } @@ -365,6 +383,8 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, struct nhlt_specific_cfg *cfg; struct skl *skl = get_skl_ctx(ctx->dev); u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type); + int fmt_idx = m_cfg->fmt_idx; + struct skl_module_iface *m_iface = &m_cfg->module->formats[fmt_idx]; /* check if we already have blob */ if (m_cfg->formats_config.caps_size > 0) @@ -375,23 +395,23 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, case SKL_DEVICE_DMIC: link_type = NHLT_LINK_DMIC; dir = SNDRV_PCM_STREAM_CAPTURE; - s_freq = m_cfg->in_fmt[0].s_freq; - s_fmt = m_cfg->in_fmt[0].bit_depth; - ch = m_cfg->in_fmt[0].channels; + s_freq = m_iface->inputs[0].fmt.s_freq; + s_fmt = m_iface->inputs[0].fmt.bit_depth; + ch = m_iface->inputs[0].fmt.channels; break; case SKL_DEVICE_I2S: link_type = NHLT_LINK_SSP; if (m_cfg->hw_conn_type == SKL_CONN_SOURCE) { dir = SNDRV_PCM_STREAM_PLAYBACK; - s_freq = m_cfg->out_fmt[0].s_freq; - s_fmt = m_cfg->out_fmt[0].bit_depth; - ch = m_cfg->out_fmt[0].channels; + s_freq = m_iface->outputs[0].fmt.s_freq; + s_fmt = m_iface->outputs[0].fmt.bit_depth; + ch = m_iface->outputs[0].fmt.channels; } else { dir = SNDRV_PCM_STREAM_CAPTURE; - s_freq = m_cfg->in_fmt[0].s_freq; - s_fmt = m_cfg->in_fmt[0].bit_depth; - ch = m_cfg->in_fmt[0].channels; + s_freq = m_iface->inputs[0].fmt.s_freq; + s_fmt = m_iface->inputs[0].fmt.bit_depth; + ch = m_iface->inputs[0].fmt.channels; } break; @@ -549,6 +569,7 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe) struct snd_soc_dapm_widget *w; struct skl_module_cfg *mconfig; struct skl_sst *ctx = skl->skl_sst; + u8 cfg_idx; int ret = 0; list_for_each_entry(w_module, &pipe->w_list, node) { @@ -564,11 +585,15 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe) return -EIO; } + cfg_idx = mconfig->pipe->cur_config_idx; + mconfig->fmt_idx = mconfig->mod_cfg[cfg_idx].fmt_idx; + mconfig->res_idx = mconfig->mod_cfg[cfg_idx].res_idx; + /* check resource available */ if (!skl_is_pipe_mcps_avail(skl, mconfig)) return -ENOMEM; - if (mconfig->is_loadable && ctx->dsp->fw_ops.load_mod) { + if (mconfig->module->loadable && ctx->dsp->fw_ops.load_mod) { ret = ctx->dsp->fw_ops.load_mod(ctx->dsp, mconfig->id.module_id, mconfig->guid); if (ret < 0) @@ -633,7 +658,7 @@ static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx, mconfig = w_module->w->priv; uuid_mod = (uuid_le *)mconfig->guid; - if (mconfig->is_loadable && ctx->dsp->fw_ops.unload_mod && + if (mconfig->module->loadable && ctx->dsp->fw_ops.unload_mod && mconfig->m_state > SKL_MODULE_UNINIT) { ret = ctx->dsp->fw_ops.unload_mod(ctx->dsp, mconfig->id.module_id); @@ -655,6 +680,65 @@ static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx, } /* + * Here, we select pipe format based on the pipe type and pipe + * direction to determine the current config index for the pipeline. + * The config index is then used to select proper module resources. + * Intermediate pipes currently have a fixed format hence we select the + * 0th configuratation by default for such pipes. + */ +static int +skl_tplg_get_pipe_config(struct skl *skl, struct skl_module_cfg *mconfig) +{ + struct skl_sst *ctx = skl->skl_sst; + struct skl_pipe *pipe = mconfig->pipe; + struct skl_pipe_params *params = pipe->p_params; + struct skl_path_config *pconfig = &pipe->configs[0]; + struct skl_pipe_fmt *fmt = NULL; + bool in_fmt = false; + int i; + + if (pipe->nr_cfgs == 0) { + pipe->cur_config_idx = 0; + return 0; + } + + if (pipe->conn_type == SKL_PIPE_CONN_TYPE_NONE) { + dev_dbg(ctx->dev, "No conn_type detected, take 0th config\n"); + pipe->cur_config_idx = 0; + pipe->memory_pages = pconfig->mem_pages; + + return 0; + } + + if ((pipe->conn_type == SKL_PIPE_CONN_TYPE_FE && + pipe->direction == SNDRV_PCM_STREAM_PLAYBACK) || + (pipe->conn_type == SKL_PIPE_CONN_TYPE_BE && + pipe->direction == SNDRV_PCM_STREAM_CAPTURE)) + in_fmt = true; + + for (i = 0; i < pipe->nr_cfgs; i++) { + pconfig = &pipe->configs[i]; + if (in_fmt) + fmt = &pconfig->in_fmt; + else + fmt = &pconfig->out_fmt; + + if (CHECK_HW_PARAMS(params->ch, params->s_freq, params->s_fmt, + fmt->channels, fmt->freq, fmt->bps)) { + pipe->cur_config_idx = i; + pipe->memory_pages = pconfig->mem_pages; + dev_dbg(ctx->dev, "Using pipe config: %d\n", i); + + return 0; + } + } + + dev_err(ctx->dev, "Invalid pipe config: %d %d %d for pipe: %d\n", + params->ch, params->s_freq, params->s_fmt, pipe->ppl_id); + return -EINVAL; +} + +/* * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we * need create the pipeline. So we do following: * - check the resources @@ -673,6 +757,10 @@ static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, struct skl_sst *ctx = skl->skl_sst; struct skl_module_deferred_bind *modules; + ret = skl_tplg_get_pipe_config(skl, mconfig); + if (ret < 0) + return ret; + /* check resource available */ if (!skl_is_pipe_mcps_avail(skl, mconfig)) return -EBUSY; @@ -776,12 +864,12 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w, * check all out/in pins are in bind state. * if so set the module param */ - for (i = 0; i < mcfg->max_out_queue; i++) { + for (i = 0; i < mcfg->module->max_output_pins; i++) { if (mcfg->m_out_pin[i].pin_state != SKL_PIN_BIND_DONE) return 0; } - for (i = 0; i < mcfg->max_in_queue; i++) { + for (i = 0; i < mcfg->module->max_input_pins; i++) { if (mcfg->m_in_pin[i].pin_state != SKL_PIN_BIND_DONE) return 0; } @@ -832,7 +920,7 @@ static int skl_tplg_module_add_deferred_bind(struct skl *skl, int i; /* only supported for module with static pin connection */ - for (i = 0; i < dst->max_in_queue; i++) { + for (i = 0; i < dst->module->max_input_pins; i++) { struct skl_module_pin *pin = &dst->m_in_pin[i]; if (pin->is_dynamic) @@ -1092,7 +1180,7 @@ static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w, if (ret) return ret; - for (i = 0; i < sink_mconfig->max_in_queue; i++) { + for (i = 0; i < sink_mconfig->module->max_input_pins; i++) { if (sink_mconfig->m_in_pin[i].pin_state == SKL_PIN_BIND_DONE) { src_mconfig = sink_mconfig->m_in_pin[i].tgt_mcfg; if (!src_mconfig) @@ -1203,7 +1291,7 @@ static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, if (ret) return ret; - for (i = 0; i < src_mconfig->max_out_queue; i++) { + for (i = 0; i < src_mconfig->module->max_output_pins; i++) { if (src_mconfig->m_out_pin[i].pin_state == SKL_PIN_BIND_DONE) { sink_mconfig = src_mconfig->m_out_pin[i].tgt_mcfg; if (!sink_mconfig) @@ -1497,14 +1585,22 @@ int skl_tplg_update_pipe_params(struct device *dev, struct skl_module_cfg *mconfig, struct skl_pipe_params *params) { + struct skl_module_res *res = &mconfig->module->resources[0]; + struct skl *skl = get_skl_ctx(dev); struct skl_module_fmt *format = NULL; + u8 cfg_idx = mconfig->pipe->cur_config_idx; skl_tplg_fill_dma_id(mconfig, params); + mconfig->fmt_idx = mconfig->mod_cfg[cfg_idx].fmt_idx; + mconfig->res_idx = mconfig->mod_cfg[cfg_idx].res_idx; + + if (skl->nr_modules) + return 0; if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) - format = &mconfig->in_fmt[0]; + format = &mconfig->module->formats[0].inputs[0].fmt; else - format = &mconfig->out_fmt[0]; + format = &mconfig->module->formats[0].outputs[0].fmt; /* set the hw_params */ format->s_freq = params->s_freq; @@ -1532,11 +1628,11 @@ int skl_tplg_update_pipe_params(struct device *dev, } if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { - mconfig->ibs = (format->s_freq / 1000) * + res->ibs = (format->s_freq / 1000) * (format->channels) * (format->bit_depth >> 3); } else { - mconfig->obs = (format->s_freq / 1000) * + res->obs = (format->s_freq / 1000) * (format->channels) * (format->bit_depth >> 3); } @@ -1810,6 +1906,54 @@ static const struct snd_soc_tplg_kcontrol_ops skl_tplg_kcontrol_ops[] = { }, }; +static int skl_tplg_fill_pipe_cfg(struct device *dev, + struct skl_pipe *pipe, u32 tkn, + u32 tkn_val, int conf_idx, int dir) +{ + struct skl_pipe_fmt *fmt; + struct skl_path_config *config; + + switch (dir) { + case SKL_DIR_IN: + fmt = &pipe->configs[conf_idx].in_fmt; + break; + + case SKL_DIR_OUT: + fmt = &pipe->configs[conf_idx].out_fmt; + break; + + default: + dev_err(dev, "Invalid direction: %d\n", dir); + return -EINVAL; + } + + config = &pipe->configs[conf_idx]; + + switch (tkn) { + case SKL_TKN_U32_CFG_FREQ: + fmt->freq = tkn_val; + break; + + case SKL_TKN_U8_CFG_CHAN: + fmt->channels = tkn_val; + break; + + case SKL_TKN_U8_CFG_BPS: + fmt->bps = tkn_val; + break; + + case SKL_TKN_U32_PATH_MEM_PGS: + config->mem_pages = tkn_val; + break; + + default: + dev_err(dev, "Invalid token config: %d\n", tkn); + return -EINVAL; + } + + return 0; +} + static int skl_tplg_fill_pipe_tkn(struct device *dev, struct skl_pipe *pipe, u32 tkn, u32 tkn_val) @@ -1832,6 +1976,14 @@ static int skl_tplg_fill_pipe_tkn(struct device *dev, pipe->lp_mode = tkn_val; break; + case SKL_TKN_U32_PIPE_DIRECTION: + pipe->direction = tkn_val; + break; + + case SKL_TKN_U32_NUM_CONFIGS: + pipe->nr_cfgs = tkn_val; + break; + default: dev_err(dev, "Token not handled %d\n", tkn); return -EINVAL; @@ -1993,18 +2145,21 @@ static int skl_tplg_fill_fmt(struct device *dev, } static int skl_tplg_widget_fill_fmt(struct device *dev, - struct skl_module_cfg *mconfig, + struct skl_module_iface *fmt, u32 tkn, u32 val, u32 dir, int fmt_idx) { struct skl_module_fmt *dst_fmt; + if (!fmt) + return -EINVAL; + switch (dir) { case SKL_DIR_IN: - dst_fmt = &mconfig->in_fmt[fmt_idx]; + dst_fmt = &fmt->inputs[fmt_idx].fmt; break; case SKL_DIR_OUT: - dst_fmt = &mconfig->out_fmt[fmt_idx]; + dst_fmt = &fmt->outputs[fmt_idx].fmt; break; default: @@ -2117,6 +2272,10 @@ static int skl_tplg_fill_res_tkn(struct device *dev, res->ibs = tkn_elem->value; break; + case SKL_TKN_U32_MAX_MCPS: + res->cps = tkn_elem->value; + break; + case SKL_TKN_MM_U32_RES_PIN_ID: case SKL_TKN_MM_U32_PIN_BUF: ret = skl_tplg_manifest_pin_res_tkn(dev, tkn_elem, res, @@ -2145,49 +2304,54 @@ static int skl_tplg_get_token(struct device *dev, int tkn_count = 0; int ret; static int is_pipe_exists; - static int pin_index, dir; + static int pin_index, dir, conf_idx; + struct skl_module_iface *iface = NULL; + struct skl_module_res *res = NULL; + int res_idx = mconfig->res_idx; + int fmt_idx = mconfig->fmt_idx; + + /* + * If the manifest structure contains no modules, fill all + * the module data to 0th index. + * res_idx and fmt_idx are default set to 0. + */ + if (skl->nr_modules == 0) { + res = &mconfig->module->resources[res_idx]; + iface = &mconfig->module->formats[fmt_idx]; + } if (tkn_elem->token > SKL_TKN_MAX) return -EINVAL; switch (tkn_elem->token) { case SKL_TKN_U8_IN_QUEUE_COUNT: - mconfig->max_in_queue = tkn_elem->value; - mconfig->m_in_pin = devm_kzalloc(dev, mconfig->max_in_queue * - sizeof(*mconfig->m_in_pin), - GFP_KERNEL); - if (!mconfig->m_in_pin) - return -ENOMEM; - + mconfig->module->max_input_pins = tkn_elem->value; break; case SKL_TKN_U8_OUT_QUEUE_COUNT: - mconfig->max_out_queue = tkn_elem->value; - mconfig->m_out_pin = devm_kzalloc(dev, mconfig->max_out_queue * - sizeof(*mconfig->m_out_pin), - GFP_KERNEL); - - if (!mconfig->m_out_pin) - return -ENOMEM; - + mconfig->module->max_output_pins = tkn_elem->value; break; case SKL_TKN_U8_DYN_IN_PIN: if (!mconfig->m_in_pin) + mconfig->m_in_pin = devm_kzalloc(dev, MAX_IN_QUEUE * + sizeof(*mconfig->m_in_pin), GFP_KERNEL); + if (!mconfig->m_in_pin) return -ENOMEM; - skl_tplg_fill_pin_dynamic_val(mconfig->m_in_pin, - mconfig->max_in_queue, tkn_elem->value); - + skl_tplg_fill_pin_dynamic_val(mconfig->m_in_pin, MAX_IN_QUEUE, + tkn_elem->value); break; case SKL_TKN_U8_DYN_OUT_PIN: if (!mconfig->m_out_pin) + mconfig->m_out_pin = devm_kzalloc(dev, MAX_IN_QUEUE * + sizeof(*mconfig->m_in_pin), GFP_KERNEL); + if (!mconfig->m_out_pin) return -ENOMEM; - skl_tplg_fill_pin_dynamic_val(mconfig->m_out_pin, - mconfig->max_out_queue, tkn_elem->value); - + skl_tplg_fill_pin_dynamic_val(mconfig->m_out_pin, MAX_OUT_QUEUE, + tkn_elem->value); break; case SKL_TKN_U8_TIME_SLOT: @@ -2215,19 +2379,13 @@ static int skl_tplg_get_token(struct device *dev, break; case SKL_TKN_U32_MEM_PAGES: - mconfig->mem_pages = tkn_elem->value; - break; - case SKL_TKN_U32_MAX_MCPS: - mconfig->mcps = tkn_elem->value; - break; - case SKL_TKN_U32_OBS: - mconfig->obs = tkn_elem->value; - break; - case SKL_TKN_U32_IBS: - mconfig->ibs = tkn_elem->value; + ret = skl_tplg_fill_res_tkn(dev, tkn_elem, res, dir, pin_index); + if (ret < 0) + return ret; + break; case SKL_TKN_U32_VBUS_ID: @@ -2260,10 +2418,16 @@ static int skl_tplg_get_token(struct device *dev, break; + case SKL_TKN_U32_PIPE_CONFIG_ID: + conf_idx = tkn_elem->value; + break; + case SKL_TKN_U32_PIPE_CONN_TYPE: case SKL_TKN_U32_PIPE_PRIORITY: case SKL_TKN_U32_PIPE_MEM_PGS: case SKL_TKN_U32_PMODE: + case SKL_TKN_U32_PIPE_DIRECTION: + case SKL_TKN_U32_NUM_CONFIGS: if (is_pipe_exists) { ret = skl_tplg_fill_pipe_tkn(dev, mconfig->pipe, tkn_elem->token, tkn_elem->value); @@ -2273,6 +2437,27 @@ static int skl_tplg_get_token(struct device *dev, break; + case SKL_TKN_U32_PATH_MEM_PGS: + case SKL_TKN_U32_CFG_FREQ: + case SKL_TKN_U8_CFG_CHAN: + case SKL_TKN_U8_CFG_BPS: + if (mconfig->pipe->nr_cfgs) { + ret = skl_tplg_fill_pipe_cfg(dev, mconfig->pipe, + tkn_elem->token, tkn_elem->value, + conf_idx, dir); + if (ret < 0) + return ret; + } + break; + + case SKL_TKN_CFG_MOD_RES_ID: + mconfig->mod_cfg[conf_idx].res_idx = tkn_elem->value; + break; + + case SKL_TKN_CFG_MOD_FMT_ID: + mconfig->mod_cfg[conf_idx].fmt_idx = tkn_elem->value; + break; + /* * SKL_TKN_U32_DIR_PIN_COUNT token has the value for both * direction and the pin count. The first four bits represent @@ -2293,7 +2478,7 @@ static int skl_tplg_get_token(struct device *dev, case SKL_TKN_U32_FMT_INTERLEAVE: case SKL_TKN_U32_FMT_SAMPLE_TYPE: case SKL_TKN_U32_FMT_CH_MAP: - ret = skl_tplg_widget_fill_fmt(dev, mconfig, tkn_elem->token, + ret = skl_tplg_widget_fill_fmt(dev, iface, tkn_elem->token, tkn_elem->value, dir, pin_index); if (ret < 0) @@ -2518,11 +2703,11 @@ static void skl_clear_pin_config(struct snd_soc_platform *platform, strlen(platform->component.name))) { mconfig = w->priv; pipe = mconfig->pipe; - for (i = 0; i < mconfig->max_in_queue; i++) { + for (i = 0; i < mconfig->module->max_input_pins; i++) { mconfig->m_in_pin[i].in_use = false; mconfig->m_in_pin[i].pin_state = SKL_PIN_UNBIND; } - for (i = 0; i < mconfig->max_out_queue; i++) { + for (i = 0; i < mconfig->module->max_output_pins; i++) { mconfig->m_out_pin[i].in_use = false; mconfig->m_out_pin[i].pin_state = SKL_PIN_UNBIND; } @@ -2581,6 +2766,13 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, if (!mconfig) return -ENOMEM; + if (skl->nr_modules == 0) { + mconfig->module = devm_kzalloc(bus->dev, + sizeof(*mconfig->module), GFP_KERNEL); + if (!mconfig->module) + return -ENOMEM; + } + w->priv = mconfig; /* diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index 93b2ba8..90903a1 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -273,6 +273,23 @@ struct skl_pipe_params { unsigned int link_bps; }; +struct skl_pipe_fmt { + u32 freq; + u8 channels; + u8 bps; +}; + +struct skl_pipe_mcfg { + u8 res_idx; + u8 fmt_idx; +}; + +struct skl_path_config { + u8 mem_pages; + struct skl_pipe_fmt in_fmt; + struct skl_pipe_fmt out_fmt; +}; + struct skl_pipe { u8 ppl_id; u8 pipe_priority; @@ -281,6 +298,10 @@ struct skl_pipe { u8 lp_mode; struct skl_pipe_params *p_params; enum skl_pipe_state state; + u8 direction; + u8 cur_config_idx; + u8 nr_cfgs; + struct skl_path_config configs[SKL_MAX_PATH_CONFIGS]; struct list_head w_list; bool passthru; }; @@ -347,6 +368,9 @@ struct skl_module { struct skl_module_cfg { u8 guid[16]; struct skl_module_inst_id id; + struct skl_module *module; + int res_idx; + int fmt_idx; u8 domain; bool homogenous_inputs; bool homogenous_outputs; @@ -381,6 +405,7 @@ struct skl_module_cfg { enum skl_module_state m_state; struct skl_pipe *pipe; struct skl_specific_cfg formats_config; + struct skl_pipe_mcfg mod_cfg[SKL_MAX_MODULES_IN_PIPE]; }; struct skl_algo_data { -- cgit v1.1 From 91fe0e70dbfb1142e17cebaa9186794b51a28cf7 Mon Sep 17 00:00:00 2001 From: Jeeja KP Date: Wed, 23 Aug 2017 19:33:54 +0530 Subject: ASoC: Intel: Skylake: Update module id in pin connections Each module's id comes from the topology and gets updated in the driver. This patch updates the input and output pin connections of each module by matching the uuid for each module. Signed-off-by: Jeeja KP Signed-off-by: Guneshwor Singh Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 41 +++++++++++++++++++++++++++++++--- sound/soc/intel/skylake/skl-topology.h | 1 + 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index a756882..2b1e513 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1220,8 +1220,11 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd) static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) { struct skl_sst *ctx = skl->skl_sst; + struct skl_module_inst_id *pin_id; + uuid_le *uuid_mod, *uuid_tplg; + struct skl_module *skl_module; struct uuid_module *module; - uuid_le *uuid_mod; + int i, ret = -EIO; uuid_mod = (uuid_le *)mconfig->guid; @@ -1235,11 +1238,43 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) mconfig->id.module_id = module->id; if (mconfig->module) mconfig->module->loadable = module->is_loadable; - return 0; + ret = 0; + break; } } - return -EIO; + if (ret) + return ret; + + uuid_mod = &module->uuid; + ret = -EIO; + for (i = 0; i < skl->nr_modules; i++) { + skl_module = skl->modules[i]; + uuid_tplg = &skl_module->uuid; + if (!uuid_le_cmp(*uuid_mod, *uuid_tplg)) { + mconfig->module = skl_module; + ret = 0; + break; + } + } + if (skl->nr_modules && ret) + return ret; + + list_for_each_entry(module, &ctx->uuid_list, list) { + for (i = 0; i < MAX_IN_QUEUE; i++) { + pin_id = &mconfig->m_in_pin[i].id; + if (!uuid_le_cmp(pin_id->mod_uuid, module->uuid)) + pin_id->module_id = module->id; + } + + for (i = 0; i < MAX_OUT_QUEUE; i++) { + pin_id = &mconfig->m_out_pin[i].id; + if (!uuid_le_cmp(pin_id->mod_uuid, module->uuid)) + pin_id->module_id = module->id; + } + } + + return 0; } static int skl_populate_modules(struct skl *skl) diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index 90903a1..4975904 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -221,6 +221,7 @@ struct skl_kpb_params { }; struct skl_module_inst_id { + uuid_le mod_uuid; int module_id; u32 instance_id; int pvt_id; -- cgit v1.1 From 88c27465dc7e3f11c43de295f623c44f593a0912 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 25 Aug 2017 01:06:04 +0000 Subject: ASoC: use snd_soc_component_get_dapm() Now we have snd_soc_component_get_dapm(), and as soc.h say below, let's use it. /* Don't use these, use snd_soc_component_get_dapm() */ struct snd_soc_dapm_context dapm; Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 74c1706..92e09cb 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3220,7 +3220,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->pcm_new = component->driver->pcm_new; component->pcm_free = component->driver->pcm_free; - dapm = &component->dapm; + dapm = snd_soc_component_get_dapm(component); dapm->dev = dev; dapm->component = component; dapm->bias_level = SND_SOC_BIAS_OFF; -- cgit v1.1 From 3dfcd3468cf05861654b1c7857500da6c8a9fc88 Mon Sep 17 00:00:00 2001 From: John Hsu Date: Fri, 25 Aug 2017 11:35:44 +0800 Subject: ASoC: nau8825: correct typo of semaphore comment There are a lot of typo about semaphore in the comment. Correct it from semaphone to semaphore. Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/codecs/nau8825.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 46a30ea..a97b0b6 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -260,11 +260,11 @@ static int nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) if (timeout) { ret = down_timeout(&nau8825->xtalk_sem, timeout); if (ret < 0) - dev_warn(nau8825->dev, "Acquire semaphone timeout\n"); + dev_warn(nau8825->dev, "Acquire semaphore timeout\n"); } else { ret = down_interruptible(&nau8825->xtalk_sem); if (ret < 0) - dev_warn(nau8825->dev, "Acquire semaphone fail\n"); + dev_warn(nau8825->dev, "Acquire semaphore fail\n"); } return ret; @@ -1299,7 +1299,7 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, NAU8825_I2S_DL_MASK, val_len); - /* Release the semaphone. */ + /* Release the semaphore. */ nau8825_sema_release(nau8825); return 0; @@ -1361,7 +1361,7 @@ static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, NAU8825_I2S_MS_MASK, ctrl2_val); - /* Release the semaphone. */ + /* Release the semaphore. */ nau8825_sema_release(nau8825); return 0; @@ -2140,7 +2140,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, break; case NAU8825_CLK_MCLK: - /* Acquire the semaphone to synchronize the playback and + /* Acquire the semaphore to synchronize the playback and * interrupt handler. In order to avoid the playback inter- * fered by cross talk process, the driver make the playback * preparation halted until cross talk process finish. @@ -2150,7 +2150,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, /* MCLK not changed by clock tree */ regmap_update_bits(regmap, NAU8825_REG_CLK_DIVIDER, NAU8825_CLK_MCLK_SRC_MASK, 0); - /* Release the semaphone. */ + /* Release the semaphore. */ nau8825_sema_release(nau8825); ret = nau8825_mclk_prepare(nau8825, freq); @@ -2188,7 +2188,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, break; case NAU8825_CLK_FLL_MCLK: - /* Acquire the semaphone to synchronize the playback and + /* Acquire the semaphore to synchronize the playback and * interrupt handler. In order to avoid the playback inter- * fered by cross talk process, the driver make the playback * preparation halted until cross talk process finish. @@ -2201,7 +2201,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, regmap_update_bits(regmap, NAU8825_REG_FLL3, NAU8825_FLL_CLK_SRC_MASK | NAU8825_GAIN_ERR_MASK, NAU8825_FLL_CLK_SRC_MCLK | 0); - /* Release the semaphone. */ + /* Release the semaphore. */ nau8825_sema_release(nau8825); ret = nau8825_mclk_prepare(nau8825, freq); @@ -2210,7 +2210,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, break; case NAU8825_CLK_FLL_BLK: - /* Acquire the semaphone to synchronize the playback and + /* Acquire the semaphore to synchronize the playback and * interrupt handler. In order to avoid the playback inter- * fered by cross talk process, the driver make the playback * preparation halted until cross talk process finish. @@ -2226,7 +2226,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, NAU8825_FLL_CLK_SRC_MASK | NAU8825_GAIN_ERR_MASK, NAU8825_FLL_CLK_SRC_BLK | (0xf << NAU8825_GAIN_ERR_SFT)); - /* Release the semaphone. */ + /* Release the semaphore. */ nau8825_sema_release(nau8825); if (nau8825->mclk_freq) { @@ -2236,7 +2236,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, break; case NAU8825_CLK_FLL_FS: - /* Acquire the semaphone to synchronize the playback and + /* Acquire the semaphore to synchronize the playback and * interrupt handler. In order to avoid the playback inter- * fered by cross talk process, the driver make the playback * preparation halted until cross talk process finish. @@ -2252,7 +2252,7 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, NAU8825_FLL_CLK_SRC_MASK | NAU8825_GAIN_ERR_MASK, NAU8825_FLL_CLK_SRC_FS | (0xf << NAU8825_GAIN_ERR_SFT)); - /* Release the semaphone. */ + /* Release the semaphore. */ nau8825_sema_release(nau8825); if (nau8825->mclk_freq) { @@ -2563,7 +2563,7 @@ static int nau8825_i2c_probe(struct i2c_client *i2c, return PTR_ERR(nau8825->regmap); nau8825->dev = dev; nau8825->irq = i2c->irq; - /* Initiate parameters, semaphone and work queue which are needed in + /* Initiate parameters, semaphore and work queue which are needed in * cross talk suppression measurment function. */ nau8825->xtalk_state = NAU8825_XTALK_DONE; -- cgit v1.1 From b8972bf0521ca7ee3c8d27da0fd101fe648acfc2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 25 Aug 2017 00:29:01 +0000 Subject: ASoC: remove duplicate definition of controls/num_controls snd_soc_component and snd_soc_component_driver both have controls/num_controls, but these are duplicated. Let's remove duplicated definition. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3bb8c63..1317706 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1495,9 +1495,10 @@ static int soc_probe_component(struct snd_soc_card *card, } } - if (component->controls) - snd_soc_add_component_controls(component, component->controls, - component->num_controls); + if (component->driver->controls) + snd_soc_add_component_controls(component, + component->driver->controls, + component->driver->num_controls); if (component->dapm_routes) snd_soc_dapm_add_routes(dapm, component->dapm_routes, component->num_dapm_routes); @@ -3184,8 +3185,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, if (driver->stream_event) dapm->stream_event = snd_soc_component_stream_event; - component->controls = driver->controls; - component->num_controls = driver->num_controls; component->dapm_widgets = driver->dapm_widgets; component->num_dapm_widgets = driver->num_dapm_widgets; component->dapm_routes = driver->dapm_routes; -- cgit v1.1 From 688d0ebf49a97aa6959aebec5d177a8b821f27d1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 25 Aug 2017 00:29:20 +0000 Subject: ASoC: remove duplicate definition of dapm_widgets/num_dapm_widgets snd_soc_component and snd_soc_component_driver both have dapm_widgets/num_dapm_widgets, but these are duplicated. Let's remove duplicated definition. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1317706..3a3236d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1451,9 +1451,10 @@ static int soc_probe_component(struct snd_soc_card *card, soc_init_component_debugfs(component); - if (component->dapm_widgets) { - ret = snd_soc_dapm_new_controls(dapm, component->dapm_widgets, - component->num_dapm_widgets); + if (component->driver->dapm_widgets) { + ret = snd_soc_dapm_new_controls(dapm, + component->driver->dapm_widgets, + component->driver->num_dapm_widgets); if (ret != 0) { dev_err(component->dev, @@ -3185,8 +3186,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, if (driver->stream_event) dapm->stream_event = snd_soc_component_stream_event; - component->dapm_widgets = driver->dapm_widgets; - component->num_dapm_widgets = driver->num_dapm_widgets; component->dapm_routes = driver->dapm_routes; component->num_dapm_routes = driver->num_dapm_routes; -- cgit v1.1 From 6969b2bae6dbe7f277a7c018b66d2f3ad662129f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 25 Aug 2017 00:29:41 +0000 Subject: ASoC: remove duplicate definition of dapm_routes/num_dapm_routes snd_soc_component and snd_soc_component_driver both have dapm_routes/num_dapm_routes, but these are duplicated. Let's remove duplicated definition. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3a3236d..b8f96a4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1500,9 +1500,10 @@ static int soc_probe_component(struct snd_soc_card *card, snd_soc_add_component_controls(component, component->driver->controls, component->driver->num_controls); - if (component->dapm_routes) - snd_soc_dapm_add_routes(dapm, component->dapm_routes, - component->num_dapm_routes); + if (component->driver->dapm_routes) + snd_soc_dapm_add_routes(dapm, + component->driver->dapm_routes, + component->driver->num_dapm_routes); list_add(&dapm->list, &card->dapm_list); list_add(&component->card_list, &card->component_dev_list); @@ -3186,9 +3187,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, if (driver->stream_event) dapm->stream_event = snd_soc_component_stream_event; - component->dapm_routes = driver->dapm_routes; - component->num_dapm_routes = driver->num_dapm_routes; - INIT_LIST_HEAD(&component->dai_list); mutex_init(&component->io_mutex); -- cgit v1.1 From 4243e0457c9b1fe5e96fba19296469466eb24b1d Mon Sep 17 00:00:00 2001 From: Christophe Jaillet Date: Sun, 27 Aug 2017 08:46:50 +0200 Subject: ASoC: davinci-mcasp: check memory allocation failure Check memory allocation failures and return -ENOMEM in such cases, as already done above for another memory allocation. This avoids NULL pointers dereference. Signed-off-by: Christophe JAILLET Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index d486908..f395bbc 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1851,6 +1851,10 @@ static int davinci_mcasp_probe(struct platform_device *pdev) mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev, sizeof(u32) * mcasp->num_serializer, GFP_KERNEL); + if (!mcasp->context.xrsr_regs) { + ret = -ENOMEM; + goto err; + } #endif mcasp->serial_dir = pdata->serial_dir; mcasp->version = pdata->version; -- cgit v1.1 From 0be04a695b8ca111bc74efcd395b5b82e29753ae Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 7 Aug 2017 18:29:19 -0500 Subject: ALSA: aoa: Convert to using %pOF instead of full_name Now that we have a custom printf format specifier, convert users of full_name to use %pOF instead. This is preparation to remove storing of the full path string for each node. Signed-off-by: Rob Herring Signed-off-by: Takashi Iwai --- sound/aoa/codecs/tas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c index 733b636..15c0575 100644 --- a/sound/aoa/codecs/tas.c +++ b/sound/aoa/codecs/tas.c @@ -905,8 +905,8 @@ static int tas_i2c_probe(struct i2c_client *client, goto fail; } printk(KERN_DEBUG - "snd-aoa-codec-tas: tas found, addr 0x%02x on %s\n", - (unsigned int)client->addr, node->full_name); + "snd-aoa-codec-tas: tas found, addr 0x%02x on %pOF\n", + (unsigned int)client->addr, node); return 0; fail: mutex_destroy(&tas->mtx); -- cgit v1.1 From c20252cf9230eb7abd8bce9fdb2ce9bdd6743689 Mon Sep 17 00:00:00 2001 From: Naveen M Date: Sat, 26 Aug 2017 04:04:09 +0530 Subject: ASoC: Intel: kbl: Add MST route change to kbl machine drivers To support MST hdmi audio, modify the current routes to be based on port in rt5663_max98927 & rt5663_rt5514_max98927 machine. Signed-off-by: Naveen M Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 8 +++----- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index c144214..941480c 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -74,8 +74,9 @@ static const struct snd_soc_dapm_widget kabylake_widgets[] = { SND_SOC_DAPM_SPK("Left Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL), SND_SOC_DAPM_MIC("SoC DMIC", NULL), - SND_SOC_DAPM_SPK("DP", NULL), - SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SPK("HDMI1", NULL), + SND_SOC_DAPM_SPK("HDMI2", NULL), + SND_SOC_DAPM_SPK("HDMI3", NULL), }; @@ -93,9 +94,6 @@ static const struct snd_soc_dapm_route kabylake_map[] = { { "IN1N", NULL, "Headset Mic" }, { "DMic", NULL, "SoC DMIC" }, - { "HDMI", NULL, "hif5 Output" }, - { "DP", NULL, "hif6 Output" }, - /* CODEC BE connections */ { "Left HiFi Playback", NULL, "ssp0 Tx" }, { "Right HiFi Playback", NULL, "ssp0 Tx" }, diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 69681b0..d042255 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -85,8 +85,8 @@ static const struct snd_soc_dapm_widget kabylake_widgets[] = { SND_SOC_DAPM_SPK("Left Spk", NULL), SND_SOC_DAPM_SPK("Right Spk", NULL), SND_SOC_DAPM_MIC("DMIC", NULL), - SND_SOC_DAPM_SPK("DP", NULL), - SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SPK("HDMI1", NULL), + SND_SOC_DAPM_SPK("HDMI2", NULL), }; @@ -103,9 +103,6 @@ static const struct snd_soc_dapm_route kabylake_map[] = { { "IN1P", NULL, "Headset Mic" }, { "IN1N", NULL, "Headset Mic" }, - { "HDMI", NULL, "hif5 Output" }, - { "DP", NULL, "hif6 Output" }, - /* CODEC BE connections */ { "Left HiFi Playback", NULL, "ssp0 Tx" }, { "Right HiFi Playback", NULL, "ssp0 Tx" }, -- cgit v1.1 From 3a13347f05fdba9d889891245f154816197868f4 Mon Sep 17 00:00:00 2001 From: Naveen M Date: Sat, 26 Aug 2017 04:04:10 +0530 Subject: ASoC: Intel: kbl: Add jack port initialize in kbl machine drivers After the pcm jack is created, create and initialize the pin switch widget for each port. For hdmi audio, invoke hdac_hdmi_jack_port_init func() in rt5663_max98927 & rt5663_rt5514_max98927 to enable the pin, when monitor is connected. Signed-off-by: Naveen M Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 7 ++++++- sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 941480c..3fa85c3 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -767,10 +767,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; + struct snd_soc_codec *codec = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + codec = pcm->codec_dai->codec; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -788,7 +790,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - return 0; + if (!codec) + return -EINVAL; + + return hdac_hdmi_jack_port_init(codec, &card->dapm); } /* kabylake audio machine driver for SPT + RT5663 */ diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index d042255..11bd5ef 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -600,10 +600,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; + struct snd_soc_codec *codec = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + codec = pcm->codec_dai->codec; err = snd_soc_card_jack_new(card, jack_name, SND_JACK_AVOUT, &ctx->kabylake_hdmi[i], NULL, 0); @@ -617,7 +619,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - return 0; + if (!codec) + return -EINVAL; + + return hdac_hdmi_jack_port_init(codec, &card->dapm); } /* -- cgit v1.1 From b1dc00abcf18d27b36de500c150be88022c82270 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Tue, 29 Aug 2017 07:37:55 -0500 Subject: ASoC: fsl_dma: remove dma_object path member dma_object.path is unused, so rather than fix it to work with DT full_name changes, just remove it. Signed-off-by: Rob Herring Cc: Timur Tabi Cc: Nicolin Chen Cc: Xiubo Li Cc: Fabio Estevam Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@alsa-project.org Cc: linuxppc-dev@lists.ozlabs.org Reviewed-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index c173596..0c11f43 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -63,7 +63,6 @@ struct dma_object { struct ccsr_dma_channel __iomem *channel; unsigned int irq; bool assigned; - char path[1]; }; /* @@ -903,13 +902,12 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) return ret; } - dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL); + dma = kzalloc(sizeof(*dma), GFP_KERNEL); if (!dma) { of_node_put(ssi_np); return -ENOMEM; } - strcpy(dma->path, np->full_name); dma->dai.ops = &fsl_dma_ops; dma->dai.pcm_new = fsl_dma_new; dma->dai.pcm_free = fsl_dma_free_dma_buffers; -- cgit v1.1 From eb33869c720656c16e614ea40a175a014f60007b Mon Sep 17 00:00:00 2001 From: Hsin-Yu Chao Date: Mon, 28 Aug 2017 15:13:50 +0800 Subject: ASoC: rt5514: Guard Hotword Model bytes loading If the rt5514-spi driver is not enabled in kernel, hotword model will not be loaded when "DSP Voice Wake Up" is set to turn on DSP mode, and an error is logged instead. Signed-off-by: Hsin-Yu Chao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 0e239e8..23fccdf 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -302,7 +302,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); struct snd_soc_codec *codec = rt5514->codec; const struct firmware *fw = NULL; - int ret = 0; if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled) return 0; @@ -340,6 +339,9 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, } if (rt5514->model_buf && rt5514->model_len) { +#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) + int ret; + ret = rt5514_spi_burst_write(0x4ff80000, rt5514->model_buf, ((rt5514->model_len / 8) + 1) * 8); @@ -348,13 +350,22 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, "Model load failed %d\n", ret); return ret; } +#else + dev_err(codec->dev, + "No SPI driver for loading firmware\n"); +#endif } else { request_firmware(&fw, RT5514_FIRMWARE3, codec->dev); if (fw) { +#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) rt5514_spi_burst_write(0x4ff80000, fw->data, ((fw->size/8)+1)*8); +#else + dev_err(codec->dev, + "No SPI driver to load fw\n"); +#endif release_firmware(fw); fw = NULL; } -- cgit v1.1 From 64220b9d10a5546b6dd1154ccaf43522ae7d02fc Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Sat, 26 Aug 2017 03:21:39 +0530 Subject: ASoC: Intel: kbl: Add map for Maxim IV Feedback MAX98927 provides IV feedback on the capture widget. Here we are connecting the capture widget to SSP0_RX and SSP0_RX to the algorithm running on host. Signed-off-by: Naveen M Signed-off-by: Sathya Prakash M R Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 5 +++++ sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'sound') diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 3fa85c3..7f76074 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -105,6 +105,11 @@ static const struct snd_soc_dapm_route kabylake_map[] = { { "hs_in", NULL, "ssp1 Rx" }, { "ssp1 Rx", NULL, "AIF Capture" }, + /* IV feedback path */ + { "codec0_fb_in", NULL, "ssp0 Rx"}, + { "ssp0 Rx", NULL, "Left HiFi Capture" }, + { "ssp0 Rx", NULL, "Right HiFi Capture" }, + /* DMIC */ { "dmic01_hifi", NULL, "DMIC01 Rx" }, { "DMIC01 Rx", NULL, "DMIC AIF" }, diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 11bd5ef..4689991 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -117,6 +117,11 @@ static const struct snd_soc_dapm_route kabylake_map[] = { { "codec1_in", NULL, "ssp0 Rx" }, { "ssp0 Rx", NULL, "AIF1 Capture" }, + /* IV feedback path */ + { "codec0_fb_in", NULL, "ssp0 Rx"}, + { "ssp0 Rx", NULL, "Left HiFi Capture" }, + { "ssp0 Rx", NULL, "Right HiFi Capture" }, + /* DMIC */ { "DMIC1L", NULL, "DMIC" }, { "DMIC1R", NULL, "DMIC" }, -- cgit v1.1 From 72cfb0f20c75c1e580597c164b9d74426e583f37 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 24 Aug 2017 12:52:21 +0800 Subject: ASoC: rockchip: Use codec of_node and dai_name for rt5514 dsp Currently we are using codec name for rt5514 dsp dai link, use codec of_node instead. Signed-off-by: Jeffy Chen Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3399_gru_sound.c | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 566ccb3..cd2fdba 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -247,8 +247,6 @@ enum { DAILINK_RT5514_DSP, }; -#define DAILINK_ENTITIES (DAILINK_DA7219 + 1) - static struct snd_soc_dai_link rockchip_dailinks[] = { [DAILINK_MAX98357A] = { .name = "MAX98357A", @@ -282,8 +280,7 @@ static struct snd_soc_dai_link rockchip_dailinks[] = { [DAILINK_RT5514_DSP] = { .name = "RT5514 DSP", .stream_name = "Wake on Voice", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", + .codec_dai_name = "rt5514-dsp-cpu-dai", }, }; @@ -300,17 +297,10 @@ static struct snd_soc_card rockchip_sound_card = { .num_controls = ARRAY_SIZE(rockchip_controls), }; -static int rockchip_sound_match_stub(struct device *dev, void *data) -{ - return 1; -} - static int rockchip_sound_probe(struct platform_device *pdev) { struct snd_soc_card *card = &rockchip_sound_card; struct device_node *cpu_node; - struct device *dev; - struct device_driver *drv; int i, ret; cpu_node = of_parse_phandle(pdev->dev.of_node, "rockchip,cpu", 0); @@ -319,7 +309,7 @@ static int rockchip_sound_probe(struct platform_device *pdev) return -EINVAL; } - for (i = 0; i < DAILINK_ENTITIES; i++) { + for (i = 0; i < ARRAY_SIZE(rockchip_dailinks); i++) { rockchip_dailinks[i].platform_of_node = cpu_node; rockchip_dailinks[i].cpu_of_node = cpu_node; @@ -332,22 +322,6 @@ static int rockchip_sound_probe(struct platform_device *pdev) } } - /** - * To acquire the spi driver of the rt5514 and set the dai-links names - * for soc_bind_dai_link - */ - drv = driver_find("rt5514", &spi_bus_type); - if (!drv) { - dev_err(&pdev->dev, "Can not find the rt5514 driver at the spi bus\n"); - return -EINVAL; - } - - dev = driver_find_device(drv, NULL, NULL, rockchip_sound_match_stub); - if (!dev) { - dev_err(&pdev->dev, "Can not find the rt5514 device\n"); - return -ENODEV; - } - /* Set DMIC wakeup delay */ ret = device_property_read_u32(&pdev->dev, "dmic-wakeup-delay-ms", &dmic_wakeup_delay); @@ -357,10 +331,6 @@ static int rockchip_sound_probe(struct platform_device *pdev) "no optional property 'dmic-wakeup-delay-ms' found, default: no delay\n"); } - rockchip_dailinks[DAILINK_RT5514_DSP].cpu_name = kstrdup_const(dev_name(dev), GFP_KERNEL); - rockchip_dailinks[DAILINK_RT5514_DSP].cpu_dai_name = kstrdup_const(dev_name(dev), GFP_KERNEL); - rockchip_dailinks[DAILINK_RT5514_DSP].platform_name = kstrdup_const(dev_name(dev), GFP_KERNEL); - card->dev = &pdev->dev; ret = devm_snd_soc_register_card(&pdev->dev, card); -- cgit v1.1 From 0d52954ffe80b051ab79a105bd801485c4bbe20a Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 24 Aug 2017 12:52:24 +0800 Subject: ASoC: rockchip: Parse dai links from dts Refactor rockchip_sound_probe, parse dai links from dts instead of hard coding them. Signed-off-by: Jeffy Chen Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3399_gru_sound.c | 140 ++++++++++++++++++++++------------ 1 file changed, 91 insertions(+), 49 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index cd2fdba..347c34d 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -240,14 +240,42 @@ static const struct snd_soc_ops rockchip_sound_da7219_ops = { .hw_params = rockchip_sound_da7219_hw_params, }; +static struct snd_soc_card rockchip_sound_card = { + .name = "rk3399-gru-sound", + .owner = THIS_MODULE, + .dapm_widgets = rockchip_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rockchip_dapm_widgets), + .dapm_routes = rockchip_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rockchip_dapm_routes), + .controls = rockchip_controls, + .num_controls = ARRAY_SIZE(rockchip_controls), +}; + enum { + DAILINK_DA7219, DAILINK_MAX98357A, DAILINK_RT5514, - DAILINK_DA7219, DAILINK_RT5514_DSP, }; -static struct snd_soc_dai_link rockchip_dailinks[] = { +static const char * const dailink_compat[] = { + [DAILINK_DA7219] = "dlg,da7219", + [DAILINK_MAX98357A] = "maxim,max98357a", + [DAILINK_RT5514] = "realtek,rt5514-i2c", + [DAILINK_RT5514_DSP] = "realtek,rt5514-spi", +}; + +static const struct snd_soc_dai_link rockchip_dais[] = { + [DAILINK_DA7219] = { + .name = "DA7219", + .stream_name = "DA7219 PCM", + .codec_dai_name = "da7219-hifi", + .init = rockchip_sound_da7219_init, + .ops = &rockchip_sound_da7219_ops, + /* set da7219 as slave */ + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + }, [DAILINK_MAX98357A] = { .name = "MAX98357A", .stream_name = "MAX98357A PCM", @@ -266,16 +294,6 @@ static struct snd_soc_dai_link rockchip_dailinks[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, }, - [DAILINK_DA7219] = { - .name = "DA7219", - .stream_name = "DA7219 PCM", - .codec_dai_name = "da7219-hifi", - .init = rockchip_sound_da7219_init, - .ops = &rockchip_sound_da7219_ops, - /* set da7219 as slave */ - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS, - }, /* RT5514 DSP for voice wakeup via spi bus */ [DAILINK_RT5514_DSP] = { .name = "RT5514 DSP", @@ -284,42 +302,72 @@ static struct snd_soc_dai_link rockchip_dailinks[] = { }, }; -static struct snd_soc_card rockchip_sound_card = { - .name = "rk3399-gru-sound", - .owner = THIS_MODULE, - .dai_link = rockchip_dailinks, - .num_links = ARRAY_SIZE(rockchip_dailinks), - .dapm_widgets = rockchip_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rockchip_dapm_widgets), - .dapm_routes = rockchip_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rockchip_dapm_routes), - .controls = rockchip_controls, - .num_controls = ARRAY_SIZE(rockchip_controls), -}; - -static int rockchip_sound_probe(struct platform_device *pdev) +static int rockchip_sound_codec_node_match(struct device_node *np_codec) { - struct snd_soc_card *card = &rockchip_sound_card; - struct device_node *cpu_node; - int i, ret; + int i; - cpu_node = of_parse_phandle(pdev->dev.of_node, "rockchip,cpu", 0); - if (!cpu_node) { - dev_err(&pdev->dev, "Property 'rockchip,cpu' missing or invalid\n"); - return -EINVAL; + for (i = 0; i < ARRAY_SIZE(dailink_compat); i++) { + if (of_device_is_compatible(np_codec, dailink_compat[i])) + return i; } + return -1; +} - for (i = 0; i < ARRAY_SIZE(rockchip_dailinks); i++) { - rockchip_dailinks[i].platform_of_node = cpu_node; - rockchip_dailinks[i].cpu_of_node = cpu_node; - - rockchip_dailinks[i].codec_of_node = - of_parse_phandle(pdev->dev.of_node, "rockchip,codec", i); - if (!rockchip_dailinks[i].codec_of_node) { - dev_err(&pdev->dev, - "Property[%d] 'rockchip,codec' missing or invalid\n", i); +static int rockchip_sound_of_parse_dais(struct device *dev, + struct snd_soc_card *card) +{ + struct device_node *np_cpu; + struct device_node *np_codec; + struct snd_soc_dai_link *dai; + int i, index; + + card->dai_link = devm_kzalloc(dev, sizeof(rockchip_dais), + GFP_KERNEL); + if (!card->dai_link) + return -ENOMEM; + + np_cpu = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); + + card->num_links = 0; + for (i = 0; i < ARRAY_SIZE(rockchip_dais); i++) { + np_codec = of_parse_phandle(dev->of_node, + "rockchip,codec", i); + if (!np_codec) + break; + + if (!of_device_is_available(np_codec)) + continue; + + index = rockchip_sound_codec_node_match(np_codec); + if (index < 0) + continue; + + if (!np_cpu) { + dev_err(dev, "Missing 'rockchip,cpu' for %s\n", + rockchip_dais[index].name); return -EINVAL; } + + dai = &card->dai_link[card->num_links++]; + *dai = rockchip_dais[index]; + + dai->codec_of_node = np_codec; + dai->platform_of_node = np_cpu; + dai->cpu_of_node = np_cpu; + } + + return 0; +} + +static int rockchip_sound_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card = &rockchip_sound_card; + int ret; + + ret = rockchip_sound_of_parse_dais(&pdev->dev, card); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to parse dais: %d\n", ret); + return ret; } /* Set DMIC wakeup delay */ @@ -332,13 +380,7 @@ static int rockchip_sound_probe(struct platform_device *pdev) } card->dev = &pdev->dev; - - ret = devm_snd_soc_register_card(&pdev->dev, card); - if (ret) - dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n", - __func__, ret); - - return ret; + return devm_snd_soc_register_card(&pdev->dev, card); } static const struct of_device_id rockchip_sound_of_match[] = { -- cgit v1.1 From 3313faf1053ee6cb90045f6877f11e2f61ead63a Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 24 Aug 2017 12:52:25 +0800 Subject: ASoC: rockchip: Add support for DP codec Add support for optional cdn dp codec. Signed-off-by: Jeffy Chen Signed-off-by: Mark Brown --- sound/soc/rockchip/Kconfig | 1 + sound/soc/rockchip/rk3399_gru_sound.c | 59 +++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index c844878..8f0d0d8 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig @@ -68,6 +68,7 @@ config SND_SOC_RK3399_GRU_SOUND select SND_SOC_RT5514 select SND_SOC_DA7219 select SND_SOC_RT5514_SPI + select SND_SOC_HDMI_CODEC help Say Y or M here if you want to add support multiple codecs for SoC audio on Rockchip RK3399 GRU boards. diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 347c34d..91aab5c 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -228,6 +228,45 @@ static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) return 0; } +static int rockchip_sound_cdndp_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int mclk, ret; + + /* in bypass mode, the mclk has to be one of the frequencies below */ + switch (params_rate(params)) { + case 8000: + case 16000: + case 24000: + case 32000: + case 48000: + case 64000: + case 96000: + mclk = 12288000; + break; + case 11025: + case 22050: + case 44100: + case 88200: + mclk = 11289600; + break; + default: + return -EINVAL; + } + + ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, + SND_SOC_CLOCK_OUT); + if (ret < 0) { + dev_err(codec_dai->dev, "Can't set cpu clock out %d\n", ret); + return ret; + } + + return 0; +} + static const struct snd_soc_ops rockchip_sound_max98357a_ops = { .hw_params = rockchip_sound_max98357a_hw_params, }; @@ -240,6 +279,10 @@ static const struct snd_soc_ops rockchip_sound_da7219_ops = { .hw_params = rockchip_sound_da7219_hw_params, }; +static struct snd_soc_ops rockchip_sound_cdndp_ops = { + .hw_params = rockchip_sound_cdndp_hw_params, +}; + static struct snd_soc_card rockchip_sound_card = { .name = "rk3399-gru-sound", .owner = THIS_MODULE, @@ -252,6 +295,7 @@ static struct snd_soc_card rockchip_sound_card = { }; enum { + DAILINK_CDNDP, DAILINK_DA7219, DAILINK_MAX98357A, DAILINK_RT5514, @@ -259,6 +303,7 @@ enum { }; static const char * const dailink_compat[] = { + [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", [DAILINK_DA7219] = "dlg,da7219", [DAILINK_MAX98357A] = "maxim,max98357a", [DAILINK_RT5514] = "realtek,rt5514-i2c", @@ -266,6 +311,14 @@ static const char * const dailink_compat[] = { }; static const struct snd_soc_dai_link rockchip_dais[] = { + [DAILINK_CDNDP] = { + .name = "DP", + .stream_name = "DP PCM", + .codec_dai_name = "i2s-hifi", + .ops = &rockchip_sound_cdndp_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + }, [DAILINK_DA7219] = { .name = "DA7219", .stream_name = "DA7219 PCM", @@ -316,7 +369,7 @@ static int rockchip_sound_codec_node_match(struct device_node *np_codec) static int rockchip_sound_of_parse_dais(struct device *dev, struct snd_soc_card *card) { - struct device_node *np_cpu; + struct device_node *np_cpu, *np_cpu0, *np_cpu1; struct device_node *np_codec; struct snd_soc_dai_link *dai; int i, index; @@ -326,7 +379,8 @@ static int rockchip_sound_of_parse_dais(struct device *dev, if (!card->dai_link) return -ENOMEM; - np_cpu = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); + np_cpu0 = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); + np_cpu1 = of_parse_phandle(dev->of_node, "rockchip,cpu", 1); card->num_links = 0; for (i = 0; i < ARRAY_SIZE(rockchip_dais); i++) { @@ -342,6 +396,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev, if (index < 0) continue; + np_cpu = (index == DAILINK_CDNDP) ? np_cpu1 : np_cpu0; if (!np_cpu) { dev_err(dev, "Missing 'rockchip,cpu' for %s\n", rockchip_dais[index].name); -- cgit v1.1 From 626d84db64d746f63eadf5e241fc2211419e11b8 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Thu, 24 Aug 2017 12:52:26 +0800 Subject: ASoC: rockchip: Add support for DMIC codec Add support for optional dmic codec. Signed-off-by: Jeffy Chen Signed-off-by: Mark Brown --- sound/soc/rockchip/Kconfig | 1 + sound/soc/rockchip/rk3399_gru_sound.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'sound') diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index 8f0d0d8..b082537 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig @@ -69,6 +69,7 @@ config SND_SOC_RK3399_GRU_SOUND select SND_SOC_DA7219 select SND_SOC_RT5514_SPI select SND_SOC_HDMI_CODEC + select SND_SOC_DMIC help Say Y or M here if you want to add support multiple codecs for SoC audio on Rockchip RK3399 GRU boards. diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 91aab5c..5ab2596 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -267,6 +267,28 @@ static int rockchip_sound_cdndp_hw_params(struct snd_pcm_substream *substream, return 0; } +static int rockchip_sound_dmic_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + unsigned int mclk; + int ret; + + mclk = params_rate(params) * SOUND_FS; + + ret = snd_soc_dai_set_sysclk(rtd->cpu_dai, 0, mclk, 0); + if (ret) { + dev_err(rtd->card->dev, "%s() error setting sysclk to %u: %d\n", + __func__, mclk, ret); + return ret; + } + + /* Wait for DMIC stable */ + msleep(dmic_wakeup_delay); + + return 0; +} + static const struct snd_soc_ops rockchip_sound_max98357a_ops = { .hw_params = rockchip_sound_max98357a_hw_params, }; @@ -283,6 +305,10 @@ static struct snd_soc_ops rockchip_sound_cdndp_ops = { .hw_params = rockchip_sound_cdndp_hw_params, }; +static struct snd_soc_ops rockchip_sound_dmic_ops = { + .hw_params = rockchip_sound_dmic_hw_params, +}; + static struct snd_soc_card rockchip_sound_card = { .name = "rk3399-gru-sound", .owner = THIS_MODULE, @@ -297,6 +323,7 @@ static struct snd_soc_card rockchip_sound_card = { enum { DAILINK_CDNDP, DAILINK_DA7219, + DAILINK_DMIC, DAILINK_MAX98357A, DAILINK_RT5514, DAILINK_RT5514_DSP, @@ -305,6 +332,7 @@ enum { static const char * const dailink_compat[] = { [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", [DAILINK_DA7219] = "dlg,da7219", + [DAILINK_DMIC] = "dmic-codec", [DAILINK_MAX98357A] = "maxim,max98357a", [DAILINK_RT5514] = "realtek,rt5514-i2c", [DAILINK_RT5514_DSP] = "realtek,rt5514-spi", @@ -329,6 +357,14 @@ static const struct snd_soc_dai_link rockchip_dais[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, }, + [DAILINK_DMIC] = { + .name = "DMIC", + .stream_name = "DMIC PCM", + .codec_dai_name = "dmic-hifi", + .ops = &rockchip_sound_dmic_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + }, [DAILINK_MAX98357A] = { .name = "MAX98357A", .stream_name = "MAX98357A PCM", -- cgit v1.1 From 1bb7cb68feb73a8106546cbd3379590297b0a950 Mon Sep 17 00:00:00 2001 From: Oskar Schirmer Date: Fri, 25 Aug 2017 21:36:56 +0000 Subject: ASoC: tas2552: Fix fraction overflow in PLL calculation Setting the PLL involves the calculation of a fixed point ratio with 4 decimal digits fraction, referred to as "J.D". The fraction "D" is stored separately from the integer part "J" and is limited to 0..9999. The current algorithm uses integer registers to calculate the fraction part, but failed to compensate for rounding errors, resulting in values larger than 9999 for the fraction part occasionally, e.g. for 44.1kHz audio rate and pll_clkin = 3763400 it would set J to 11 and D to 10002, which will at best result in wrong pitch. The critical part is the "pll_clkin / 10000", which would be ok with real numbers, but using integer arithmetic the rounding decreases the divisor, thus increasing the final quotient. The issue is solved by linear interpolation over the reciprocal function between the two adjacent points with integer divisor, i.e. pll_clkin / 10000 and pll_clkin / 10000 + 1, and doing all rounding to the lower result. As a side effect to the bug fix, the approximation to the desired frequency is much better, for the above mentioned example we get 11.9993, while the true ratio is 11.9993623. Signed-off-by: Oskar Schirmer Signed-off-by: Mark Brown --- sound/soc/codecs/tas2552.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c index 8840f72..1011616 100644 --- a/sound/soc/codecs/tas2552.c +++ b/sound/soc/codecs/tas2552.c @@ -192,7 +192,7 @@ static int tas2552_setup_pll(struct snd_soc_codec *codec, * pll_clk = (.5 * pll_clkin * J.D) / 2^p * Need to fill in J and D here based on incoming freq */ - unsigned int d; + unsigned int d, q, t; u8 j; u8 pll_sel = (tas2552->pll_clk_id << 3) & TAS2552_PLL_SRC_MASK; u8 p = snd_soc_read(codec, TAS2552_PLL_CTRL_1); @@ -200,9 +200,12 @@ static int tas2552_setup_pll(struct snd_soc_codec *codec, p = (p >> 7); recalc: - j = (pll_clk * 2 * (1 << p)) / pll_clkin; - d = (pll_clk * 2 * (1 << p)) % pll_clkin; - d /= (pll_clkin / 10000); + t = (pll_clk * 2) << p; + j = t / pll_clkin; + d = t % pll_clkin; + t = pll_clkin / 10000; + q = d / (t + 1); + d = q + ((9999 - pll_clkin % 10000) * (d / t - q)) / 10000; if (d && (pll_clkin < 512000 || pll_clkin > 9200000)) { if (tas2552->pll_clk_id == TAS2552_PLL_CLKIN_BCLK) { -- cgit v1.1 From 60b0fdeac19945107b956a8a2a0ba3a14827db60 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 30 Aug 2017 12:28:31 +0800 Subject: ASoC: rt274: add acpi id Add ACPI id for Intel platform. Signed-off-by: Guneshwor Singh Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt274.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index fb683ff..0be69c1 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -1102,6 +1102,7 @@ MODULE_DEVICE_TABLE(i2c, rt274_i2c_id); static const struct acpi_device_id rt274_acpi_match[] = { { "10EC0274", 0 }, + { "INT34C2", 0 }, {}, }; MODULE_DEVICE_TABLE(acpi, rt274_acpi_match); -- cgit v1.1 From 9c324afe3b90e406b15938acafaa2636a7e85ff3 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Wed, 30 Aug 2017 13:08:31 +0800 Subject: ASoC: rt5663: Add delay for jack plug in Codec initialize takes some time when 3.5mm jack plugged in. Add a delay to report jack plugged event to user space to avoid pop noise. Signed-off-by: Hsinyu Chao Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5663.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index fdc2bbc..14716d2 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -1705,6 +1705,9 @@ static void rt5663_jack_detect_work(struct work_struct *work) default: dev_err(codec->dev, "Unknown CODEC Version\n"); } + + /* Delay the jack insert report to avoid pop noise */ + msleep(30); } else { /* jack is already in, report button event */ report = SND_JACK_HEADSET; -- cgit v1.1 From 1fe165b7e9c3e1b1cfa98310979db0814c7445ea Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Wed, 30 Aug 2017 17:58:14 +0800 Subject: ASoC: rockchip: constify snd_soc_ops structures Add const to dp/dmic snd_soc_ops. Fixes: 626d84db64d7 (ASoC: rockchip: Add support for DMIC codec) Fixes: 3313faf1053e (ASoC: rockchip: Add support for DP codec) Signed-off-by: Jeffy Chen Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3399_gru_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 5ab2596..0513fe4 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -301,11 +301,11 @@ static const struct snd_soc_ops rockchip_sound_da7219_ops = { .hw_params = rockchip_sound_da7219_hw_params, }; -static struct snd_soc_ops rockchip_sound_cdndp_ops = { +static const struct snd_soc_ops rockchip_sound_cdndp_ops = { .hw_params = rockchip_sound_cdndp_hw_params, }; -static struct snd_soc_ops rockchip_sound_dmic_ops = { +static const struct snd_soc_ops rockchip_sound_dmic_ops = { .hw_params = rockchip_sound_dmic_hw_params, }; -- cgit v1.1 From 943fa0228252320de503b923dfe46334f755aaae Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Sat, 12 Aug 2017 08:40:38 +0800 Subject: ASoC: hdmi-codec: Use different name for playback streams Currently the hdmi i2s playback stream and hdmi spdif playback stream are using the same name. So when they are enabled at the same time, kernel will print this warning: [ 2.201835] hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: Failed to create Playback debugfs file Assign different names to them to avoid that. Signed-off-by: Jeffy Chen Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index f752041..189af06 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -696,7 +696,7 @@ static struct snd_soc_dai_driver hdmi_i2s_dai = { .name = "i2s-hifi", .id = DAI_ID_I2S, .playback = { - .stream_name = "Playback", + .stream_name = "I2S Playback", .channels_min = 2, .channels_max = 8, .rates = HDMI_RATES, @@ -711,7 +711,7 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = { .name = "spdif-hifi", .id = DAI_ID_SPDIF, .playback = { - .stream_name = "Playback", + .stream_name = "SPDIF Playback", .channels_min = 2, .channels_max = 2, .rates = HDMI_RATES, -- cgit v1.1 From 7d8e8292013ab72ae1f1500cbc91f198ccb1826d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 30 Aug 2017 16:13:25 +0200 Subject: ALSA: Get rid of card power_lock Currently we're taking power_lock at each card component for assuring the power-up sequence, but it doesn't help anything in the implementation at the moment: it just serializes unnecessarily the callers, but it doesn't protect about the power state change itself. It used to have some usefulness in the early days where we managed the PM manually. But now the suspend/resume core procedure is beyond our hands, and power_lock lost its meaning. This patch drops the power_lock from allover the places. There shouldn't be any issues by this change, as it's no helper regarding the power state change. Rather we'll get better performance by removing the serialization; which is the only slight concern of any behavior change, but it can't be a showstopper, after all. Signed-off-by: Takashi Iwai --- sound/core/control.c | 58 ++++++++++++++++++++++++--------------------- sound/core/control_compat.c | 34 ++++++++++++-------------- sound/core/init.c | 5 ---- sound/core/pcm_native.c | 30 ++++++----------------- sound/soc/soc-core.c | 2 -- 5 files changed, 53 insertions(+), 76 deletions(-) (limited to 'sound') diff --git a/sound/core/control.c b/sound/core/control.c index 51d4b4a..56b3e2d 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -864,14 +864,14 @@ static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl, if (copy_from_user(&info, _info, sizeof(info))) return -EFAULT; - snd_power_lock(ctl->card); result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0); - if (result >= 0) - result = snd_ctl_elem_info(ctl, &info); - snd_power_unlock(ctl->card); - if (result >= 0) - if (copy_to_user(_info, &info, sizeof(info))) - return -EFAULT; + if (result < 0) + return result; + result = snd_ctl_elem_info(ctl, &info); + if (result < 0) + return result; + if (copy_to_user(_info, &info, sizeof(info))) + return -EFAULT; return result; } @@ -905,17 +905,19 @@ static int snd_ctl_elem_read_user(struct snd_card *card, if (IS_ERR(control)) return PTR_ERR(control); - snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (result >= 0) { - down_read(&card->controls_rwsem); - result = snd_ctl_elem_read(card, control); - up_read(&card->controls_rwsem); - } - snd_power_unlock(card); - if (result >= 0) - if (copy_to_user(_control, control, sizeof(*control))) - result = -EFAULT; + if (result < 0) + goto error; + + down_read(&card->controls_rwsem); + result = snd_ctl_elem_read(card, control); + up_read(&card->controls_rwsem); + if (result < 0) + goto error; + + if (copy_to_user(_control, control, sizeof(*control))) + result = -EFAULT; + error: kfree(control); return result; } @@ -964,17 +966,19 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, return PTR_ERR(control); card = file->card; - snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (result >= 0) { - down_write(&card->controls_rwsem); - result = snd_ctl_elem_write(card, file, control); - up_write(&card->controls_rwsem); - } - snd_power_unlock(card); - if (result >= 0) - if (copy_to_user(_control, control, sizeof(*control))) - result = -EFAULT; + if (result < 0) + goto error; + + down_write(&card->controls_rwsem); + result = snd_ctl_elem_write(card, file, control); + up_write(&card->controls_rwsem); + if (result < 0) + goto error; + + if (copy_to_user(_control, control, sizeof(*control))) + result = -EFAULT; + error: kfree(control); return result; } diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 1fa7076..a848836 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -111,12 +111,10 @@ static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl, if (get_user(data->value.enumerated.item, &data32->value.enumerated.item)) goto error; - snd_power_lock(ctl->card); err = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0); - if (err >= 0) - err = snd_ctl_elem_info(ctl, data); - snd_power_unlock(ctl->card); - + if (err < 0) + goto error; + err = snd_ctl_elem_info(ctl, data); if (err < 0) goto error; /* restore info to 32bit */ @@ -315,14 +313,13 @@ static int ctl_elem_read_user(struct snd_card *card, if (err < 0) goto error; - snd_power_lock(card); err = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (err >= 0) - err = snd_ctl_elem_read(card, data); - snd_power_unlock(card); - if (err >= 0) - err = copy_ctl_value_to_user(userdata, valuep, data, - type, count); + if (err < 0) + goto error; + err = snd_ctl_elem_read(card, data); + if (err < 0) + goto error; + err = copy_ctl_value_to_user(userdata, valuep, data, type, count); error: kfree(data); return err; @@ -344,14 +341,13 @@ static int ctl_elem_write_user(struct snd_ctl_file *file, if (err < 0) goto error; - snd_power_lock(card); err = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (err >= 0) - err = snd_ctl_elem_write(card, file, data); - snd_power_unlock(card); - if (err >= 0) - err = copy_ctl_value_to_user(userdata, valuep, data, - type, count); + if (err < 0) + goto error; + err = snd_ctl_elem_write(card, file, data); + if (err < 0) + goto error; + err = copy_ctl_value_to_user(userdata, valuep, data, type, count); error: kfree(data); return err; diff --git a/sound/core/init.c b/sound/core/init.c index 6e219dc..32ebe2f 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -253,7 +253,6 @@ int snd_card_new(struct device *parent, int idx, const char *xid, spin_lock_init(&card->files_lock); INIT_LIST_HEAD(&card->files_list); #ifdef CONFIG_PM - mutex_init(&card->power_lock); init_waitqueue_head(&card->power_sleep); #endif @@ -978,8 +977,6 @@ EXPORT_SYMBOL(snd_card_file_remove); * Waits until the power-state is changed. * * Return: Zero if successful, or a negative error code. - * - * Note: the power lock must be active before call. */ int snd_power_wait(struct snd_card *card, unsigned int power_state) { @@ -999,9 +996,7 @@ int snd_power_wait(struct snd_card *card, unsigned int power_state) if (snd_power_get_state(card) == power_state) break; set_current_state(TASK_UNINTERRUPTIBLE); - snd_power_unlock(card); schedule_timeout(30 * HZ); - snd_power_lock(card); } remove_wait_queue(&card->power_sleep, &wait); return result; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index cf0433f..621142e 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1830,7 +1830,6 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream, add_wait_queue(&to_check->sleep, &wait); snd_pcm_stream_unlock_irq(substream); up_read(&snd_pcm_link_rwsem); - snd_power_unlock(card); if (runtime->no_period_wakeup) tout = MAX_SCHEDULE_TIMEOUT; else { @@ -1842,7 +1841,6 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream, tout = msecs_to_jiffies(tout * 1000); } tout = schedule_timeout_interruptible(tout); - snd_power_lock(card); down_read(&snd_pcm_link_rwsem); snd_pcm_stream_lock_irq(substream); remove_wait_queue(&to_check->sleep, &wait); @@ -2764,11 +2762,16 @@ static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) return 0; } -static int snd_pcm_common_ioctl(struct file *file, +static int snd_pcm_common_ioctl1(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { struct snd_pcm_file *pcm_file = file->private_data; + int res; + + res = snd_power_wait(substream->pcm->card, SNDRV_CTL_POWER_D0); + if (res < 0) + return res; switch (cmd) { case SNDRV_PCM_IOCTL_PVERSION: @@ -2846,21 +2849,6 @@ static int snd_pcm_common_ioctl(struct file *file, return -ENOTTY; } -static int snd_pcm_common_ioctl1(struct file *file, - struct snd_pcm_substream *substream, - unsigned int cmd, void __user *arg) -{ - struct snd_card *card = substream->pcm->card; - int res; - - snd_power_lock(card); - res = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (res >= 0) - res = snd_pcm_common_ioctl(file, substream, cmd, arg); - snd_power_unlock(card); - return res; -} - static int snd_pcm_playback_ioctl1(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) @@ -3064,7 +3052,6 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, { snd_pcm_uframes_t *frames = arg; snd_pcm_sframes_t result; - int err; switch (cmd) { case SNDRV_PCM_IOCTL_FORWARD: @@ -3084,10 +3071,7 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, case SNDRV_PCM_IOCTL_START: return snd_pcm_start_lock_irq(substream); case SNDRV_PCM_IOCTL_DRAIN: - snd_power_lock(substream->pcm->card); - err = snd_pcm_drain(substream, NULL); - snd_power_unlock(substream->pcm->card); - return err; + return snd_pcm_drain(substream, NULL); case SNDRV_PCM_IOCTL_DROP: return snd_pcm_drop(substream); case SNDRV_PCM_IOCTL_DELAY: diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 13c875e..62c11e2 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -653,9 +653,7 @@ int snd_soc_suspend(struct device *dev) /* Due to the resume being scheduled into a workqueue we could * suspend before that's finished - wait for it to complete. */ - snd_power_lock(card->snd_card); snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0); - snd_power_unlock(card->snd_card); /* we're going to block userspace touching us until resume completes */ snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot); -- cgit v1.1 From 67616feda99e32cb676b0907284bbb6957e45480 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 30 Aug 2017 15:39:32 +0200 Subject: ALSA: pcm: Unify ioctl functions for playback and capture streams Some ioctl functions are implemented individually for both playback and capture streams although most of the codes are identical with just a few different stream-specific function calls. This patch unifies these places, removes the superfluous trivial check and flattens the call paths as a cleanup. Meanwhile, for better readability, some codes (e.g. xfer ioctls or forward/rewind ioctls) are factored out as functions. Signed-off-by: Takashi Iwai --- sound/core/pcm_compat.c | 5 +- sound/core/pcm_native.c | 283 ++++++++++++++++++------------------------------ 2 files changed, 105 insertions(+), 183 deletions(-) (limited to 'sound') diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 10f537f..3a1cc7b 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -689,10 +689,7 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l case SNDRV_PCM_IOCTL_XRUN: case SNDRV_PCM_IOCTL_LINK: case SNDRV_PCM_IOCTL_UNLINK: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - return snd_pcm_playback_ioctl1(file, substream, cmd, argp); - else - return snd_pcm_capture_ioctl1(file, substream, cmd, argp); + return snd_pcm_common_ioctl(file, substream, cmd, argp); case SNDRV_PCM_IOCTL_HW_REFINE32: return snd_pcm_ioctl_hw_params_compat(substream, 1, argp); case SNDRV_PCM_IOCTL_HW_PARAMS32: diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 621142e..2fec2fe 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2761,14 +2761,103 @@ static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) runtime->tstamp_type = arg; return 0; } - -static int snd_pcm_common_ioctl1(struct file *file, + +static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, + struct snd_xferi __user *_xferi) +{ + struct snd_xferi xferi; + struct snd_pcm_runtime *runtime = substream->runtime; + snd_pcm_sframes_t result; + + if (runtime->status->state == SNDRV_PCM_STATE_OPEN) + return -EBADFD; + if (put_user(0, &_xferi->result)) + return -EFAULT; + if (copy_from_user(&xferi, _xferi, sizeof(xferi))) + return -EFAULT; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); + else + result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); + __put_user(result, &_xferi->result); + return result < 0 ? result : 0; +} + +static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, + struct snd_xfern __user *_xfern) +{ + struct snd_xfern xfern; + struct snd_pcm_runtime *runtime = substream->runtime; + void *bufs; + snd_pcm_sframes_t result; + + if (runtime->status->state == SNDRV_PCM_STATE_OPEN) + return -EBADFD; + if (runtime->channels > 128) + return -EINVAL; + if (put_user(0, &_xfern->result)) + return -EFAULT; + if (copy_from_user(&xfern, _xfern, sizeof(xfern))) + return -EFAULT; + + bufs = memdup_user(xfern.bufs, sizeof(void *) * runtime->channels); + if (IS_ERR(bufs)) + return PTR_ERR(bufs); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + result = snd_pcm_lib_writev(substream, bufs, xfern.frames); + else + result = snd_pcm_lib_readv(substream, bufs, xfern.frames); + kfree(bufs); + __put_user(result, &_xfern->result); + return result < 0 ? result : 0; +} + +static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, + snd_pcm_uframes_t __user *_frames) +{ + snd_pcm_uframes_t frames; + snd_pcm_sframes_t result; + + if (get_user(frames, _frames)) + return -EFAULT; + if (put_user(0, _frames)) + return -EFAULT; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + result = snd_pcm_playback_rewind(substream, frames); + else + result = snd_pcm_capture_rewind(substream, frames); + __put_user(result, _frames); + return result < 0 ? result : 0; +} + +static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, + snd_pcm_uframes_t __user *_frames) +{ + snd_pcm_uframes_t frames; + snd_pcm_sframes_t result; + + if (get_user(frames, _frames)) + return -EFAULT; + if (put_user(0, _frames)) + return -EFAULT; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + result = snd_pcm_playback_forward(substream, frames); + else + result = snd_pcm_capture_forward(substream, frames); + __put_user(result, _frames); + return result < 0 ? result : 0; +} + +static int snd_pcm_common_ioctl(struct file *file, struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { struct snd_pcm_file *pcm_file = file->private_data; int res; + if (PCM_RUNTIME_CHECK(substream)) + return -ENXIO; + res = snd_power_wait(substream->pcm->card, SNDRV_CTL_POWER_D0); if (res < 0) return res; @@ -2844,187 +2933,23 @@ static int snd_pcm_common_ioctl1(struct file *file, return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, (int)(unsigned long)arg); - } - pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); - return -ENOTTY; -} - -static int snd_pcm_playback_ioctl1(struct file *file, - struct snd_pcm_substream *substream, - unsigned int cmd, void __user *arg) -{ - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) - return -EINVAL; - switch (cmd) { case SNDRV_PCM_IOCTL_WRITEI_FRAMES: - { - struct snd_xferi xferi; - struct snd_xferi __user *_xferi = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (put_user(0, &_xferi->result)) - return -EFAULT; - if (copy_from_user(&xferi, _xferi, sizeof(xferi))) - return -EFAULT; - result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); - __put_user(result, &_xferi->result); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_WRITEN_FRAMES: - { - struct snd_xfern xfern; - struct snd_xfern __user *_xfern = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - void __user **bufs; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (runtime->channels > 128) - return -EINVAL; - if (put_user(0, &_xfern->result)) - return -EFAULT; - if (copy_from_user(&xfern, _xfern, sizeof(xfern))) - return -EFAULT; - - bufs = memdup_user(xfern.bufs, - sizeof(void *) * runtime->channels); - if (IS_ERR(bufs)) - return PTR_ERR(bufs); - result = snd_pcm_lib_writev(substream, bufs, xfern.frames); - kfree(bufs); - __put_user(result, &_xfern->result); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_REWIND: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_playback_rewind(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_FORWARD: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_playback_forward(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } - } - return snd_pcm_common_ioctl1(file, substream, cmd, arg); -} - -static int snd_pcm_capture_ioctl1(struct file *file, - struct snd_pcm_substream *substream, - unsigned int cmd, void __user *arg) -{ - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) - return -EINVAL; - switch (cmd) { case SNDRV_PCM_IOCTL_READI_FRAMES: - { - struct snd_xferi xferi; - struct snd_xferi __user *_xferi = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (put_user(0, &_xferi->result)) - return -EFAULT; - if (copy_from_user(&xferi, _xferi, sizeof(xferi))) - return -EFAULT; - result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); - __put_user(result, &_xferi->result); - return result < 0 ? result : 0; - } + return snd_pcm_xferi_frames_ioctl(substream, arg); + case SNDRV_PCM_IOCTL_WRITEN_FRAMES: case SNDRV_PCM_IOCTL_READN_FRAMES: - { - struct snd_xfern xfern; - struct snd_xfern __user *_xfern = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - void *bufs; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (runtime->channels > 128) - return -EINVAL; - if (put_user(0, &_xfern->result)) - return -EFAULT; - if (copy_from_user(&xfern, _xfern, sizeof(xfern))) - return -EFAULT; - - bufs = memdup_user(xfern.bufs, - sizeof(void *) * runtime->channels); - if (IS_ERR(bufs)) - return PTR_ERR(bufs); - result = snd_pcm_lib_readv(substream, bufs, xfern.frames); - kfree(bufs); - __put_user(result, &_xfern->result); - return result < 0 ? result : 0; - } + return snd_pcm_xfern_frames_ioctl(substream, arg); case SNDRV_PCM_IOCTL_REWIND: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_capture_rewind(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } + return snd_pcm_rewind_ioctl(substream, arg); case SNDRV_PCM_IOCTL_FORWARD: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_capture_forward(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; + return snd_pcm_forward_ioctl(substream, arg); } - } - return snd_pcm_common_ioctl1(file, substream, cmd, arg); -} - -static long snd_pcm_playback_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct snd_pcm_file *pcm_file; - - pcm_file = file->private_data; - - if (((cmd >> 8) & 0xff) != 'A') - return -ENOTTY; - - return snd_pcm_playback_ioctl1(file, pcm_file->substream, cmd, - (void __user *)arg); + pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); + return -ENOTTY; } -static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) +static long snd_pcm_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) { struct snd_pcm_file *pcm_file; @@ -3033,8 +2958,8 @@ static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd, if (((cmd >> 8) & 0xff) != 'A') return -ENOTTY; - return snd_pcm_capture_ioctl1(file, pcm_file->substream, cmd, - (void __user *)arg); + return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, + (void __user *)arg); } /** @@ -3775,7 +3700,7 @@ const struct file_operations snd_pcm_f_ops[2] = { .release = snd_pcm_release, .llseek = no_llseek, .poll = snd_pcm_playback_poll, - .unlocked_ioctl = snd_pcm_playback_ioctl, + .unlocked_ioctl = snd_pcm_ioctl, .compat_ioctl = snd_pcm_ioctl_compat, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, @@ -3789,7 +3714,7 @@ const struct file_operations snd_pcm_f_ops[2] = { .release = snd_pcm_release, .llseek = no_llseek, .poll = snd_pcm_capture_poll, - .unlocked_ioctl = snd_pcm_capture_ioctl, + .unlocked_ioctl = snd_pcm_ioctl, .compat_ioctl = snd_pcm_ioctl_compat, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, -- cgit v1.1 From 71ccef0df533cd9c8c6cbf1483a636a092088ab9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 24 Aug 2017 00:57:35 +0000 Subject: ASoC: add Component level set_sysclk In current ALSA SoC, Codec only has set_sysclk feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 10efd15..654db55 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2590,11 +2590,9 @@ int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, { if (dai->driver && dai->driver->ops->set_sysclk) return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir); - else if (dai->codec && dai->codec->driver->set_sysclk) - return dai->codec->driver->set_sysclk(dai->codec, clk_id, 0, - freq, dir); - else - return -ENOTSUPP; + + return snd_soc_component_set_sysclk(dai->component, clk_id, 0, + freq, dir); } EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk); @@ -2620,6 +2618,32 @@ int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id, EXPORT_SYMBOL_GPL(snd_soc_codec_set_sysclk); /** + * snd_soc_component_set_sysclk - configure COMPONENT system or master clock. + * @component: COMPONENT + * @clk_id: DAI specific clock ID + * @source: Source for the clock + * @freq: new clock frequency in Hz + * @dir: new clock direction - input/output. + * + * Configures the CODEC master (MCLK) or system (SYSCLK) clocking. + */ +int snd_soc_component_set_sysclk(struct snd_soc_component *component, int clk_id, + int source, unsigned int freq, int dir) +{ + /* will be removed */ + if (component->set_sysclk) + return component->set_sysclk(component, clk_id, source, + freq, dir); + + if (component->driver->set_sysclk) + return component->driver->set_sysclk(component, clk_id, source, + freq, dir); + + return -ENOTSUPP; +} +EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk); + +/** * snd_soc_dai_set_clkdiv - configure DAI clock dividers. * @dai: DAI * @div_id: DAI specific clock divider ID @@ -3174,6 +3198,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->remove = component->driver->remove; component->suspend = component->driver->suspend; component->resume = component->driver->resume; + component->set_sysclk = component->driver->set_sysclk; dapm = &component->dapm; dapm->dev = dev; @@ -3557,6 +3582,14 @@ static int snd_soc_codec_drv_read(struct snd_soc_component *component, return 0; } +static int snd_soc_codec_set_sysclk_(struct snd_soc_component *component, + int clk_id, int source, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); + + return snd_soc_codec_set_sysclk(codec, clk_id, source, freq, dir); +} + static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { @@ -3608,6 +3641,8 @@ int snd_soc_register_codec(struct device *dev, codec->component.write = snd_soc_codec_drv_write; if (codec_drv->read) codec->component.read = snd_soc_codec_drv_read; + if (codec_drv->set_sysclk) + codec->component.set_sysclk = snd_soc_codec_set_sysclk_; codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; dapm = snd_soc_codec_get_dapm(codec); -- cgit v1.1 From ef641e5d5e6c7a07748239036b786a90ba9b9a95 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 24 Aug 2017 00:57:51 +0000 Subject: ASoC: add Component level set_pll In current ALSA SoC, Codec only has set_pll feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 654db55..ee641cd 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2679,11 +2679,9 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, if (dai->driver && dai->driver->ops->set_pll) return dai->driver->ops->set_pll(dai, pll_id, source, freq_in, freq_out); - else if (dai->codec && dai->codec->driver->set_pll) - return dai->codec->driver->set_pll(dai->codec, pll_id, source, - freq_in, freq_out); - else - return -EINVAL; + + return snd_soc_component_set_pll(dai->component, pll_id, source, + freq_in, freq_out); } EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll); @@ -2708,6 +2706,33 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, } EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); +/* + * snd_soc_component_set_pll - configure component PLL. + * @component: COMPONENT + * @pll_id: DAI specific PLL ID + * @source: DAI specific source for the PLL + * @freq_in: PLL input clock frequency in Hz + * @freq_out: requested PLL output clock frequency in Hz + * + * Configures and enables PLL to generate output clock based on input clock. + */ +int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, + int source, unsigned int freq_in, + unsigned int freq_out) +{ + /* will be removed */ + if (component->set_pll) + return component->set_pll(component, pll_id, source, + freq_in, freq_out); + + if (component->driver->set_pll) + return component->driver->set_pll(component, pll_id, source, + freq_in, freq_out); + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(snd_soc_component_set_pll); + /** * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio. * @dai: DAI @@ -3199,6 +3224,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->suspend = component->driver->suspend; component->resume = component->driver->resume; component->set_sysclk = component->driver->set_sysclk; + component->set_pll = component->driver->set_pll; dapm = &component->dapm; dapm->dev = dev; @@ -3590,6 +3616,15 @@ static int snd_soc_codec_set_sysclk_(struct snd_soc_component *component, return snd_soc_codec_set_sysclk(codec, clk_id, source, freq, dir); } +static int snd_soc_codec_set_pll_(struct snd_soc_component *component, + int pll_id, int source, unsigned int freq_in, + unsigned int freq_out) +{ + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); + + return snd_soc_codec_set_pll(codec, pll_id, source, freq_in, freq_out); +} + static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { @@ -3643,6 +3678,8 @@ int snd_soc_register_codec(struct device *dev, codec->component.read = snd_soc_codec_drv_read; if (codec_drv->set_sysclk) codec->component.set_sysclk = snd_soc_codec_set_sysclk_; + if (codec_drv->set_pll) + codec->component.set_pll = snd_soc_codec_set_pll_; codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; dapm = snd_soc_codec_get_dapm(codec); -- cgit v1.1 From 44c07365e9e2c87c7e04d63293618c391d1480ec Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 24 Aug 2017 00:58:07 +0000 Subject: ASoC: add Component level set_jack In current ALSA SoC, Codec only has set_jack feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 11 +++++++++++ sound/soc/soc-jack.c | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ee641cd..3d72878 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3225,6 +3225,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, component->resume = component->driver->resume; component->set_sysclk = component->driver->set_sysclk; component->set_pll = component->driver->set_pll; + component->set_jack = component->driver->set_jack; dapm = &component->dapm; dapm->dev = dev; @@ -3625,6 +3626,14 @@ static int snd_soc_codec_set_pll_(struct snd_soc_component *component, return snd_soc_codec_set_pll(codec, pll_id, source, freq_in, freq_out); } +static int snd_soc_codec_set_jack_(struct snd_soc_component *component, + struct snd_soc_jack *jack, void *data) +{ + struct snd_soc_codec *codec = snd_soc_component_to_codec(component); + + return snd_soc_codec_set_jack(codec, jack, data); +} + static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level) { @@ -3680,6 +3689,8 @@ int snd_soc_register_codec(struct device *dev, codec->component.set_sysclk = snd_soc_codec_set_sysclk_; if (codec_drv->set_pll) codec->component.set_pll = snd_soc_codec_set_pll_; + if (codec_drv->set_jack) + codec->component.set_jack = snd_soc_codec_set_jack_; codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; dapm = snd_soc_codec_get_dapm(codec); diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 7daf21f..2f9f496 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -41,6 +41,28 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec, EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack); /** + * snd_soc_component_set_jack - configure component jack. + * @component: COMPONENTs + * @jack: structure to use for the jack + * @data: can be used if codec driver need extra data for configuring jack + * + * Configures and enables jack detection function. + */ +int snd_soc_component_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *jack, void *data) +{ + /* will be removed */ + if (component->set_jack) + return component->set_jack(component, jack, data); + + if (component->driver->set_jack) + return component->driver->set_jack(component, jack, data); + + return -ENOTSUPP; +} +EXPORT_SYMBOL_GPL(snd_soc_component_set_jack); + +/** * snd_soc_card_jack_new - Create a new jack * @card: ASoC card * @id: an identifying string for this jack -- cgit v1.1 From 53cfa99e37010c9d270dc9f16054928d4e0716e6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 31 Aug 2017 10:53:35 +0200 Subject: ALSA: opl3: Put missing KERN_CONT prefix The opl3 driver has a debug printk code without proper KERN_ prefix. On recent kernels, KERN_CONT prefix is mandatory for continued output lines. Put it properly. Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_midi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 7821b07..13c0a7e 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -131,8 +131,8 @@ static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) { printk(KERN_DEBUG "time %.5i: %s [%.2i]: ", opl3->use_time, s, voice); for (i = 0; i < opl3->max_voices; i++) - printk("%c", *(str + opl3->voices[i].state + 1)); - printk("\n"); + printk(KERN_CONT "%c", *(str + opl3->voices[i].state + 1)); + printk(KERN_CONT "\n"); } #endif -- cgit v1.1 From 07f070dda48c3c5b0a81d6b48b4d7c7de7341b12 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 31 Aug 2017 10:56:12 +0200 Subject: ALSA: vx: Put missing KERN_CONT prefix The vx driver has a debug printk code without proper KERN_ prefix. On recent kernels, KERN_CONT prefix is mandatory for continued output lines. Put it properly. Signed-off-by: Takashi Iwai --- sound/drivers/vx/vx_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index f684fff..1213573 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -256,8 +256,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh) if (rmh->LgCmd > 1) { printk(KERN_DEBUG " "); for (i = 1; i < rmh->LgCmd; i++) - printk("0x%06x ", rmh->Cmd[i]); - printk("\n"); + printk(KERN_CONT "0x%06x ", rmh->Cmd[i]); + printk(KERN_CONT "\n"); } #endif /* Check bit M is set according to length of the command */ -- cgit v1.1 From 874b83d396bb41886e70876afe783a0d81d79583 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 31 Aug 2017 10:56:50 +0200 Subject: ALSA: asihpi: Put missing KERN_CONT prefix The asihpi driver has a debug printk code without proper KERN_ prefix. On recent kernels, KERN_CONT prefix is mandatory for continued output lines. Put it properly. Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpidebug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c index ac86a1f..9e12232 100644 --- a/sound/pci/asihpi/hpidebug.c +++ b/sound/pci/asihpi/hpidebug.c @@ -71,8 +71,8 @@ void hpi_debug_data(u16 *pdata, u32 len) printk(KERN_DEBUG "%p:", (pdata + i)); for (k = 0; k < cols && i < len; i++, k++) - printk("%s%04x", k == 0 ? "" : " ", pdata[i]); + printk(KERN_CONT "%s%04x", k == 0 ? "" : " ", pdata[i]); - printk("\n"); + printk(KERN_CONT "\n"); } } -- cgit v1.1 From 5659f244584cf414aa08c2bcf4dfa52fd972df64 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 31 Aug 2017 10:59:12 +0200 Subject: ALSA: usb-audio: Put missing KERN_CONT prefix The usb-audio driver has a debug printk code without proper KERN_ prefix. On recent kernels, KERN_CONT prefix is mandatory for continued output lines. Put it properly. Signed-off-by: Takashi Iwai --- sound/usb/midi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/midi.c b/sound/usb/midi.c index bd9d022..a92e2b2 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -242,8 +242,8 @@ static void dump_urb(const char *type, const u8 *data, int length) { snd_printk(KERN_DEBUG "%s packet: [", type); for (; length > 0; ++data, --length) - printk(" %02x", *data); - printk(" ]\n"); + printk(KERN_CONT " %02x", *data); + printk(KERN_CONT " ]\n"); } #else #define dump_urb(type, data, length) /* nothing */ -- cgit v1.1 From 10304d71cbe19ccb47c6ad524405c8d9587b646c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 31 Aug 2017 11:00:20 +0200 Subject: ALSA: usx2y: Put missing KERN_CONT prefix The usx2y driver has a debug printk code without proper KERN_ prefix. On recent kernels, KERN_CONT prefix is mandatory for continued output lines. Put it properly. Signed-off-by: Takashi Iwai --- sound/usb/usx2y/usb_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c index bf618e1..fe926cb 100644 --- a/sound/usb/usx2y/usb_stream.c +++ b/sound/usb/usx2y/usb_stream.c @@ -625,9 +625,9 @@ static void i_capture_start(struct urb *urb) urb->iso_frame_desc[0].actual_length); for (pack = 1; pack < urb->number_of_packets; ++pack) { int l = urb->iso_frame_desc[pack].actual_length; - printk(" %i", l); + printk(KERN_CONT " %i", l); } - printk("\n"); + printk(KERN_CONT "\n"); } #endif if (!empty && s->state < usb_stream_sync1) -- cgit v1.1 From c054c8a0c3a8a7e2ec2d6d5a628821f3cb832538 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 31 Aug 2017 10:57:36 +0200 Subject: ALSA: sh: Put missing KERN_* prefix sh audio driver prints its presence at probe function but a proper KERN_ prefix is missing. Put KERN_INFO there as it's merely an advertisement. Signed-off-by: Takashi Iwai --- sound/sh/sh_dac_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c index e71e6a7..834b257 100644 --- a/sound/sh/sh_dac_audio.c +++ b/sound/sh/sh_dac_audio.c @@ -424,7 +424,7 @@ static int snd_sh_dac_probe(struct platform_device *devptr) if (err < 0) goto probe_error; - snd_printk("ALSA driver for SuperH DAC audio"); + snd_printk(KERN_INFO "ALSA driver for SuperH DAC audio"); platform_set_drvdata(devptr, card); return 0; -- cgit v1.1 From 19b0fa11bb1c0c24296c9f670a37c091bd3c815d Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Thu, 31 Aug 2017 11:49:47 +0300 Subject: ASoC: tlv320aic3x: Support for OCMV configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In aic3x class of devices Output Common-Mode Voltage can be configured for better analog performance. The OCMV value depends on the Analog and digital domain power supply voltage configuration. The default OCMV of 1.35V gives best performance when AVDD is around 2.7V and DVDD is 1.525V, but for higher AVDD/DVDD higher OCMV setting is recommended. The patch gives an automatic way of guessing the best OCMV which can be overwritten by a DT parameter if needed. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 45 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/tlv320aic3x.h | 8 ++++++++ 2 files changed, 53 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 29bf8c8..ca88085 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -93,6 +93,8 @@ struct aic3x_priv { /* Selects the micbias voltage */ enum aic3x_micbias_voltage micbias_vg; + /* Output Common-Mode Voltage */ + u8 ocmv; }; static const struct reg_default aic3x_reg[] = { @@ -1572,6 +1574,10 @@ static int aic3x_init(struct snd_soc_codec *codec) break; } + /* Output common-mode voltage = 1.5 V */ + snd_soc_update_bits(codec, HPOUT_SC, HPOUT_SC_OCMV_MASK, + aic3x->ocmv << HPOUT_SC_OCMV_SHIFT); + return 0; } @@ -1699,6 +1705,43 @@ static struct snd_soc_codec_driver soc_codec_dev_aic3x = { }, }; +static void aic3x_configure_ocmv(struct i2c_client *client) +{ + struct device_node *np = client->dev.of_node; + struct aic3x_priv *aic3x = i2c_get_clientdata(client); + u32 value; + int dvdd, avdd; + + if (np && !of_property_read_u32(np, "ai3x-ocmv", &value)) { + /* OCMV setting is forced by DT */ + if (value <= 3) { + aic3x->ocmv = value; + return; + } + } + + dvdd = regulator_get_voltage(aic3x->supplies[1].consumer); + avdd = regulator_get_voltage(aic3x->supplies[2].consumer); + + if (avdd > 3600000 || dvdd > 1950000) { + dev_warn(&client->dev, + "Too high supply voltage(s) AVDD: %d, DVDD: %d\n", + avdd, dvdd); + } else if (avdd == 3600000 && dvdd == 1950000) { + aic3x->ocmv = HPOUT_SC_OCMV_1_8V; + } else if (avdd > 3300000 && dvdd > 1800000) { + aic3x->ocmv = HPOUT_SC_OCMV_1_65V; + } else if (avdd > 3000000 && dvdd > 1650000) { + aic3x->ocmv = HPOUT_SC_OCMV_1_5V; + } else if (avdd >= 2700000 && dvdd >= 1525000) { + aic3x->ocmv = HPOUT_SC_OCMV_1_35V; + } else { + dev_warn(&client->dev, + "Invalid supply voltage(s) AVDD: %d, DVDD: %d\n", + avdd, dvdd); + } +} + /* * AIC3X 2 wire address can be up to 4 devices with device addresses * 0x18, 0x19, 0x1A, 0x1B @@ -1816,6 +1859,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, goto err_gpio; } + aic3x_configure_ocmv(i2c); + if (aic3x->model == AIC3X_MODEL_3007) { ret = regmap_register_patch(aic3x->regmap, aic3007_class_d, ARRAY_SIZE(aic3007_class_d)); diff --git a/sound/soc/codecs/tlv320aic3x.h b/sound/soc/codecs/tlv320aic3x.h index 89fa692..34c3519 100644 --- a/sound/soc/codecs/tlv320aic3x.h +++ b/sound/soc/codecs/tlv320aic3x.h @@ -243,6 +243,14 @@ #define MICBIAS_LEVEL_SHIFT (6) #define MICBIAS_LEVEL_MASK (3 << 6) +/* HPOUT_SC */ +#define HPOUT_SC_OCMV_MASK (3 << 6) +#define HPOUT_SC_OCMV_SHIFT (6) +#define HPOUT_SC_OCMV_1_35V 0 +#define HPOUT_SC_OCMV_1_5V 1 +#define HPOUT_SC_OCMV_1_65V 2 +#define HPOUT_SC_OCMV_1_8V 3 + /* headset detection / button API */ /* The AIC3x supports detection of stereo headsets (GND + left + right signal) -- cgit v1.1 From 88faae2c2e35c88a806c052a7fc20948211b0895 Mon Sep 17 00:00:00 2001 From: Ian W MORRISON Date: Thu, 31 Aug 2017 08:35:47 +1000 Subject: ASoC: rt5645: Add jack detection workaround for MINIX Z83-4 based devices The MINIX NEO Z83-4 and MINIX NEO Z83-4 Pro devices requires jd_mode=3 to make the jack detection work. Using a BIOS DMI product of "Z83-4" will match both devices of 'NEO Z83-4' and 'Z83-4 Pro'. Signed-off-by: Ian W Morrison Signed-off-by: Mark Brown --- sound/soc/codecs/rt5645.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index d2f0380..2e145f08 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3655,6 +3655,21 @@ static struct dmi_system_id dmi_platform_asus_t100ha[] = { { } }; +static struct rt5645_platform_data minix_z83_4_platform_data = { + .jd_mode = 3, +}; + +static struct dmi_system_id dmi_platform_minix_z83_4[] = { + { + .ident = "MINIX Z83-4", + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MINIX"), + DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"), + }, + }, + { } +}; + static bool rt5645_check_dp(struct device *dev) { if (device_property_present(dev, "realtek,in2-differential") || @@ -3709,6 +3724,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, rt5645->pdata = gpd_win_platform_data; else if (dmi_check_system(dmi_platform_asus_t100ha)) rt5645->pdata = general_platform_data2; + else if (dmi_check_system(dmi_platform_minix_z83_4)) + rt5645->pdata = minix_z83_4_platform_data; if (quirk != -1) { rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk); -- cgit v1.1 From 0515760fa1159ffa863c7b2b73466aaff7d11a80 Mon Sep 17 00:00:00 2001 From: Christophe Jaillet Date: Thu, 31 Aug 2017 06:40:42 +0200 Subject: ALSA: ac97c: Fix an error handling path in 'atmel_ac97c_probe()' If 'clk_prepare_enable()' fails, we must release some resources before returning. Add a new label in the existing error handling path and 'goto' there. Fixes: 260ea95cc027 ("ASoC: atmel: ac97c: Handle return value of clk_prepare_enable.") Signed-off-by: Christophe JAILLET Acked-by: Alexandre Belloni Signed-off-by: Mark Brown --- sound/atmel/ac97c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 52b0522..d784053 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -785,7 +785,7 @@ static int atmel_ac97c_probe(struct platform_device *pdev) } retval = clk_prepare_enable(pclk); if (retval) - return retval; + goto err_prepare_enable; retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, THIS_MODULE, @@ -881,6 +881,7 @@ err_request_irq: snd_card_free(card); err_snd_card_new: clk_disable_unprepare(pclk); +err_prepare_enable: clk_put(pclk); return retval; } -- cgit v1.1 From 9c1743ebe0da614517a1b94f171924d5fd758df4 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Mon, 28 Aug 2017 16:30:55 -0700 Subject: ASoC: max98927: Updated volatile register list Signed-off-by: Ryan Lee Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index b5ee294..768e84d 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -495,6 +495,13 @@ static bool max98927_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { case MAX98927_R0001_INT_RAW1 ... MAX98927_R0009_INT_FLAG3: + case MAX98927_R004C_MEAS_ADC_CH0_READ: + case MAX98927_R004D_MEAS_ADC_CH1_READ: + case MAX98927_R004E_MEAS_ADC_CH2_READ: + case MAX98927_R0051_BROWNOUT_STATUS: + case MAX98927_R0087_ENV_TRACK_BOOST_VOUT_READ: + case MAX98927_R01FF_REV_ID: + case MAX98927_R0100_SOFT_RESET: return true; default: return false; -- cgit v1.1 From 01c6f1b5c832b75af5d34555201050db896285a8 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Mon, 28 Aug 2017 16:30:56 -0700 Subject: ASoC: max98927: Added missing \n to end of dev_err messages Signed-off-by: Ryan Lee Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index 768e84d..f74cdb0 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -159,7 +159,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) mode = MAX98927_PCM_MASTER_MODE_MASTER; break; default: - dev_err(codec->dev, "DAI clock mode unsupported"); + dev_err(codec->dev, "DAI clock mode unsupported\n"); return -EINVAL; } @@ -175,7 +175,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) invert = MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE; break; default: - dev_err(codec->dev, "DAI invert mode unsupported"); + dev_err(codec->dev, "DAI invert mode unsupported\n"); return -EINVAL; } @@ -311,7 +311,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d", + dev_err(codec->dev, "format unsupported %d\n", params_format(params)); goto err; } -- cgit v1.1 From 848844b87a26265019215dbb7fb588a5fac0a110 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Mon, 28 Aug 2017 16:30:58 -0700 Subject: ASoC: max98927: Modified chip default register values Signed-off-by: Ryan Lee Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index f74cdb0..5b85360 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -44,9 +44,9 @@ static struct reg_default max98927_reg[] = { {MAX98927_R0011_CLK_MON, 0x00}, {MAX98927_R0012_WDOG_CTRL, 0x00}, {MAX98927_R0013_WDOG_RST, 0x00}, - {MAX98927_R0014_MEAS_ADC_THERM_WARN_THRESH, 0x00}, - {MAX98927_R0015_MEAS_ADC_THERM_SHDN_THRESH, 0x00}, - {MAX98927_R0016_MEAS_ADC_THERM_HYSTERESIS, 0x00}, + {MAX98927_R0014_MEAS_ADC_THERM_WARN_THRESH, 0x75}, + {MAX98927_R0015_MEAS_ADC_THERM_SHDN_THRESH, 0x8c}, + {MAX98927_R0016_MEAS_ADC_THERM_HYSTERESIS, 0x08}, {MAX98927_R0017_PIN_CFG, 0x55}, {MAX98927_R0018_PCM_RX_EN_A, 0x00}, {MAX98927_R0019_PCM_RX_EN_B, 0x00}, @@ -82,14 +82,14 @@ static struct reg_default max98927_reg[] = { {MAX98927_R003A_AMP_EN, 0x00}, {MAX98927_R003B_SPK_SRC_SEL, 0x00}, {MAX98927_R003C_SPK_GAIN, 0x00}, - {MAX98927_R003D_SSM_CFG, 0x01}, + {MAX98927_R003D_SSM_CFG, 0x04}, {MAX98927_R003E_MEAS_EN, 0x00}, {MAX98927_R003F_MEAS_DSP_CFG, 0x04}, {MAX98927_R0040_BOOST_CTRL0, 0x00}, {MAX98927_R0041_BOOST_CTRL3, 0x00}, {MAX98927_R0042_BOOST_CTRL1, 0x00}, {MAX98927_R0043_MEAS_ADC_CFG, 0x00}, - {MAX98927_R0044_MEAS_ADC_BASE_MSB, 0x00}, + {MAX98927_R0044_MEAS_ADC_BASE_MSB, 0x01}, {MAX98927_R0045_MEAS_ADC_BASE_LSB, 0x00}, {MAX98927_R0046_ADC_CH0_DIVIDE, 0x00}, {MAX98927_R0047_ADC_CH1_DIVIDE, 0x00}, -- cgit v1.1 From f81991ddd001981bbe4ea0d25f88a4f95fb018be Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Mon, 28 Aug 2017 16:30:59 -0700 Subject: ASoC: max98927: Added PM suspend and resume function Signed-off-by: Ryan Lee Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index 5b85360..caf5340 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -701,6 +701,31 @@ static int max98927_probe(struct snd_soc_codec *codec) return 0; } +#ifdef CONFIG_PM_SLEEP +static int max98927_suspend(struct device *dev) +{ + struct max98927_priv *max98927 = dev_get_drvdata(dev); + + regcache_cache_only(max98927->regmap, true); + regcache_mark_dirty(max98927->regmap); + return 0; +} +static int max98927_resume(struct device *dev) +{ + struct max98927_priv *max98927 = dev_get_drvdata(dev); + + regmap_write(max98927->regmap, + MAX98927_R0100_SOFT_RESET, MAX98927_SOFT_RESET); + regcache_cache_only(max98927->regmap, false); + regcache_sync(max98927->regmap); + return 0; +} +#endif + +static const struct dev_pm_ops max98927_pm = { + SET_SYSTEM_SLEEP_PM_OPS(max98927_suspend, max98927_resume) +}; + static const struct snd_soc_codec_driver soc_codec_dev_max98927 = { .probe = max98927_probe, .component_driver = { @@ -834,7 +859,7 @@ static struct i2c_driver max98927_i2c_driver = { .name = "max98927", .of_match_table = of_match_ptr(max98927_of_match), .acpi_match_table = ACPI_PTR(max98927_acpi_match), - .pm = NULL, + .pm = &max98927_pm, }, .probe = max98927_i2c_probe, .remove = max98927_i2c_remove, -- cgit v1.1 From 607f7777bf0c0224bfadd31a37acc8d1fd25324d Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Mon, 28 Aug 2017 16:31:00 -0700 Subject: ASoC: max98927: Modified DAPM widget and map to enable/disable VI sense path Signed-off-by: Ryan Lee Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index caf5340..4bbf209 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -418,11 +418,6 @@ static int max98927_dac_event(struct snd_soc_dapm_widget *w, regmap_update_bits(max98927->regmap, MAX98927_R003A_AMP_EN, MAX98927_AMP_EN_MASK, 1); - /* enable VMON and IMON */ - regmap_update_bits(max98927->regmap, - MAX98927_R003E_MEAS_EN, - MAX98927_MEAS_V_EN | MAX98927_MEAS_I_EN, - MAX98927_MEAS_V_EN | MAX98927_MEAS_I_EN); regmap_update_bits(max98927->regmap, MAX98927_R00FF_GLOBAL_SHDN, MAX98927_GLOBAL_EN_MASK, 1); @@ -434,10 +429,6 @@ static int max98927_dac_event(struct snd_soc_dapm_widget *w, regmap_update_bits(max98927->regmap, MAX98927_R003A_AMP_EN, MAX98927_AMP_EN_MASK, 0); - /* disable VMON and IMON */ - regmap_update_bits(max98927->regmap, - MAX98927_R003E_MEAS_EN, - MAX98927_MEAS_V_EN | MAX98927_MEAS_I_EN, 0); break; default: return 0; @@ -456,14 +447,24 @@ static const struct soc_enum dai_sel_enum = static const struct snd_kcontrol_new max98927_dai_controls = SOC_DAPM_ENUM("DAI Sel", dai_sel_enum); +static const struct snd_kcontrol_new max98927_vi_control = + SOC_DAPM_SINGLE("Switch", MAX98927_R003F_MEAS_DSP_CFG, 2, 1, 0); + static const struct snd_soc_dapm_widget max98927_dapm_widgets[] = { - SND_SOC_DAPM_AIF_IN("DAI_OUT", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback", MAX98927_R003A_AMP_EN, 0, 0, max98927_dac_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0, &max98927_dai_controls), SND_SOC_DAPM_OUTPUT("BE_OUT"), + SND_SOC_DAPM_AIF_OUT("Voltage Sense", "HiFi Capture", 0, + MAX98927_R003E_MEAS_EN, 0, 0), + SND_SOC_DAPM_AIF_OUT("Current Sense", "HiFi Capture", 0, + MAX98927_R003E_MEAS_EN, 1, 0), + SND_SOC_DAPM_SWITCH("VI Sense", SND_SOC_NOPM, 0, 0, + &max98927_vi_control), + SND_SOC_DAPM_SIGGEN("VMON"), + SND_SOC_DAPM_SIGGEN("IMON"), }; static DECLARE_TLV_DB_SCALE(max98927_spk_tlv, 300, 300, 0); @@ -550,11 +551,16 @@ static const struct snd_kcontrol_new max98927_snd_controls[] = { }; static const struct snd_soc_dapm_route max98927_audio_map[] = { - {"Amp Enable", NULL, "DAI_OUT"}, + /* Plabyack */ {"DAI Sel Mux", "Left", "Amp Enable"}, {"DAI Sel Mux", "Right", "Amp Enable"}, {"DAI Sel Mux", "LeftRight", "Amp Enable"}, {"BE_OUT", NULL, "DAI Sel Mux"}, + /* Capture */ + { "VI Sense", "Switch", "VMON" }, + { "VI Sense", "Switch", "IMON" }, + { "Voltage Sense", NULL, "VI Sense" }, + { "Current Sense", NULL, "VI Sense" }, }; static struct snd_soc_dai_driver max98927_dai[] = { -- cgit v1.1 From dea110501745734baf7a90dc1e1b50481ade6191 Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Mon, 28 Aug 2017 16:31:01 -0700 Subject: ASoC: max98927: Changed device property read function Signed-off-by: Ryan Lee Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index 4bbf209..926871e 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -759,14 +759,14 @@ static void max98927_slot_config(struct i2c_client *i2c, struct max98927_priv *max98927) { int value; + struct device *dev = &i2c->dev; - if (!of_property_read_u32(i2c->dev.of_node, - "vmon-slot-no", &value)) + if (!device_property_read_u32(dev, "vmon-slot-no", &value)) max98927->v_l_slot = value & 0xF; else max98927->v_l_slot = 0; - if (!of_property_read_u32(i2c->dev.of_node, - "imon-slot-no", &value)) + + if (!device_property_read_u32(dev, "imon-slot-no", &value)) max98927->i_l_slot = value & 0xF; else max98927->i_l_slot = 1; -- cgit v1.1 From 39cdc62b1b4efa39831d4de22f990043b0304fff Mon Sep 17 00:00:00 2001 From: Himanshu Jha Date: Thu, 31 Aug 2017 20:36:42 +0530 Subject: ALSA: ctxfi: Remove null check before kfree kfree on NULL pointer is a no-op and therefore checking is redundant. Signed-off-by: Himanshu Jha Signed-off-by: Takashi Iwai --- sound/pci/ctxfi/ctresource.c | 6 ++---- sound/pci/ctxfi/ctsrc.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/ctxfi/ctresource.c b/sound/pci/ctxfi/ctresource.c index c5124c3..80c4d84 100644 --- a/sound/pci/ctxfi/ctresource.c +++ b/sound/pci/ctxfi/ctresource.c @@ -258,10 +258,8 @@ error: int rsc_mgr_uninit(struct rsc_mgr *mgr) { - if (NULL != mgr->rscs) { - kfree(mgr->rscs); - mgr->rscs = NULL; - } + kfree(mgr->rscs); + mgr->rscs = NULL; if ((NULL != mgr->hw) && (NULL != mgr->ctrl_blk)) { switch (mgr->type) { diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c index a5a72df..bb4c9c3 100644 --- a/sound/pci/ctxfi/ctsrc.c +++ b/sound/pci/ctxfi/ctsrc.c @@ -702,10 +702,8 @@ error1: static int srcimp_rsc_uninit(struct srcimp *srcimp) { - if (NULL != srcimp->imappers) { - kfree(srcimp->imappers); - srcimp->imappers = NULL; - } + kfree(srcimp->imappers); + srcimp->imappers = NULL; srcimp->ops = NULL; srcimp->mgr = NULL; rsc_uninit(&srcimp->rsc); -- cgit v1.1 From a728f56094e7cf60a1dc0642fe86901d1a4dfb4e Mon Sep 17 00:00:00 2001 From: Vitaly Wool Date: Thu, 17 Aug 2017 13:42:36 +0200 Subject: ASoC: make clock direction configurable in asoc-simple Some CPU drivers (e. g. davinci-mcasp) may require the system clock to be configured as OUT, while there's no good way currently to set SND_SOC_CLK_OUT in simple-soc driver if the clock is fixed-rate. This patch makes asoc_simple_card_init_dai() initialize clock to SND_SOCK_CLK_OUT if explicitly stated in the relevant dts file. This change is transparent and doesn't change the default behavior. Signed-off-by: Vitaly Wool Signed-off-by: Mark Brown --- sound/soc/generic/simple-card-utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 26d64fa..af44c8c 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -196,7 +196,11 @@ int asoc_simple_card_parse_clk(struct device *dev, simple_dai->sysclk = clk_get_rate(clk); } - dev_dbg(dev, "%s : sysclk = %d\n", name, simple_dai->sysclk); + if (of_property_read_bool(node, "system-clock-direction-out")) + simple_dai->clk_direction = SND_SOC_CLOCK_OUT; + + dev_dbg(dev, "%s : sysclk = %d, direction %d\n", name, + simple_dai->sysclk, simple_dai->clk_direction); return 0; } @@ -310,7 +314,8 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai, int ret; if (simple_dai->sysclk) { - ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, 0); + ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk, + simple_dai->clk_direction); if (ret && ret != -ENOTSUPP) { dev_err(dai->dev, "simple-card: set_sysclk error\n"); return ret; -- cgit v1.1 From 8f1e5bf9b4408e91942b94c76583eaf098f19382 Mon Sep 17 00:00:00 2001 From: Li Xu Date: Fri, 18 Aug 2017 11:00:19 -0500 Subject: ASoC: cs43130: Add support for CS43130 codec Add support for Cirrus Logic CS43130 codec. Support: I2S/DSP PCM playback. DoP/DSD playback. HP detection and DC/AC impedance measurement. Signed-off-by: Li Xu Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cs43130.c | 2690 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/cs43130.h | 546 +++++++++ 4 files changed, 3244 insertions(+) create mode 100644 sound/soc/codecs/cs43130.c create mode 100644 sound/soc/codecs/cs43130.h (limited to 'sound') diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 6c78b0b..ea7a2d5 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -60,6 +60,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_CS4271_I2C if I2C select SND_SOC_CS4271_SPI if SPI_MASTER select SND_SOC_CS42XX8_I2C if I2C + select SND_SOC_CS43130 if I2C select SND_SOC_CS4349 if I2C select SND_SOC_CS47L24 if MFD_CS47L24 select SND_SOC_CS53L30 if I2C @@ -486,6 +487,11 @@ config SND_SOC_CS42XX8_I2C select SND_SOC_CS42XX8 select REGMAP_I2C +# Cirrus Logic CS43130 HiFi DAC +config SND_SOC_CS43130 + tristate "Cirrus Logic CS43130 CODEC" + depends on I2C + # Cirrus Logic CS4349 HiFi DAC config SND_SOC_CS4349 tristate "Cirrus Logic CS4349 CODEC" diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1755a54..5030e1f 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -53,6 +53,7 @@ snd-soc-cs4271-i2c-objs := cs4271-i2c.o snd-soc-cs4271-spi-objs := cs4271-spi.o snd-soc-cs42xx8-objs := cs42xx8.o snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o +snd-soc-cs43130-objs := cs43130.o snd-soc-cs4349-objs := cs4349.o snd-soc-cs47l24-objs := cs47l24.o snd-soc-cs53l30-objs := cs53l30.o @@ -290,6 +291,7 @@ obj-$(CONFIG_SND_SOC_CS4271_I2C) += snd-soc-cs4271-i2c.o obj-$(CONFIG_SND_SOC_CS4271_SPI) += snd-soc-cs4271-spi.o obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o +obj-$(CONFIG_SND_SOC_CS43130) += snd-soc-cs43130.o obj-$(CONFIG_SND_SOC_CS4349) += snd-soc-cs4349.o obj-$(CONFIG_SND_SOC_CS47L24) += snd-soc-cs47l24.o obj-$(CONFIG_SND_SOC_CS53L30) += snd-soc-cs53l30.o diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c new file mode 100644 index 0000000..220e301 --- /dev/null +++ b/sound/soc/codecs/cs43130.c @@ -0,0 +1,2690 @@ +/* + * cs43130.c -- CS43130 ALSA Soc Audio driver + * + * Copyright 2017 Cirrus Logic, Inc. + * + * Authors: Li Xu + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cs43130.h" + +static const struct reg_default cs43130_reg_defaults[] = { + {CS43130_SYS_CLK_CTL_1, 0x06}, + {CS43130_SP_SRATE, 0x01}, + {CS43130_SP_BITSIZE, 0x05}, + {CS43130_PAD_INT_CFG, 0x03}, + {CS43130_PWDN_CTL, 0xFE}, + {CS43130_CRYSTAL_SET, 0x04}, + {CS43130_PLL_SET_1, 0x00}, + {CS43130_PLL_SET_2, 0x00}, + {CS43130_PLL_SET_3, 0x00}, + {CS43130_PLL_SET_4, 0x00}, + {CS43130_PLL_SET_5, 0x40}, + {CS43130_PLL_SET_6, 0x10}, + {CS43130_PLL_SET_7, 0x80}, + {CS43130_PLL_SET_8, 0x03}, + {CS43130_PLL_SET_9, 0x02}, + {CS43130_PLL_SET_10, 0x02}, + {CS43130_CLKOUT_CTL, 0x00}, + {CS43130_ASP_NUM_1, 0x01}, + {CS43130_ASP_NUM_2, 0x00}, + {CS43130_ASP_DEN_1, 0x08}, + {CS43130_ASP_DEN_2, 0x00}, + {CS43130_ASP_LRCK_HI_TIME_1, 0x1F}, + {CS43130_ASP_LRCK_HI_TIME_2, 0x00}, + {CS43130_ASP_LRCK_PERIOD_1, 0x3F}, + {CS43130_ASP_LRCK_PERIOD_2, 0x00}, + {CS43130_ASP_CLOCK_CONF, 0x0C}, + {CS43130_ASP_FRAME_CONF, 0x0A}, + {CS43130_XSP_NUM_1, 0x01}, + {CS43130_XSP_NUM_2, 0x00}, + {CS43130_XSP_DEN_1, 0x02}, + {CS43130_XSP_DEN_2, 0x00}, + {CS43130_XSP_LRCK_HI_TIME_1, 0x1F}, + {CS43130_XSP_LRCK_HI_TIME_2, 0x00}, + {CS43130_XSP_LRCK_PERIOD_1, 0x3F}, + {CS43130_XSP_LRCK_PERIOD_2, 0x00}, + {CS43130_XSP_CLOCK_CONF, 0x0C}, + {CS43130_XSP_FRAME_CONF, 0x0A}, + {CS43130_ASP_CH_1_LOC, 0x00}, + {CS43130_ASP_CH_2_LOC, 0x00}, + {CS43130_ASP_CH_1_SZ_EN, 0x06}, + {CS43130_ASP_CH_2_SZ_EN, 0x0E}, + {CS43130_XSP_CH_1_LOC, 0x00}, + {CS43130_XSP_CH_2_LOC, 0x00}, + {CS43130_XSP_CH_1_SZ_EN, 0x06}, + {CS43130_XSP_CH_2_SZ_EN, 0x0E}, + {CS43130_DSD_VOL_B, 0x78}, + {CS43130_DSD_VOL_A, 0x78}, + {CS43130_DSD_PATH_CTL_1, 0xA8}, + {CS43130_DSD_INT_CFG, 0x00}, + {CS43130_DSD_PATH_CTL_2, 0x02}, + {CS43130_DSD_PCM_MIX_CTL, 0x00}, + {CS43130_DSD_PATH_CTL_3, 0x40}, + {CS43130_HP_OUT_CTL_1, 0x30}, + {CS43130_PCM_FILT_OPT, 0x02}, + {CS43130_PCM_VOL_B, 0x78}, + {CS43130_PCM_VOL_A, 0x78}, + {CS43130_PCM_PATH_CTL_1, 0xA8}, + {CS43130_PCM_PATH_CTL_2, 0x00}, + {CS43130_CLASS_H_CTL, 0x1E}, + {CS43130_HP_DETECT, 0x04}, + {CS43130_HP_LOAD_1, 0x00}, + {CS43130_HP_MEAS_LOAD_1, 0x00}, + {CS43130_HP_MEAS_LOAD_2, 0x00}, + {CS43130_INT_MASK_1, 0xFF}, + {CS43130_INT_MASK_2, 0xFF}, + {CS43130_INT_MASK_3, 0xFF}, + {CS43130_INT_MASK_4, 0xFF}, + {CS43130_INT_MASK_5, 0xFF}, +}; + +static bool cs43130_volatile_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case CS43130_INT_STATUS_1 ... CS43130_INT_STATUS_5: + case CS43130_HP_DC_STAT_1 ... CS43130_HP_DC_STAT_2: + case CS43130_HP_AC_STAT_1 ... CS43130_HP_AC_STAT_2: + return true; + default: + return false; + } +} + +static bool cs43130_readable_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case CS43130_DEVID_AB ... CS43130_SYS_CLK_CTL_1: + case CS43130_SP_SRATE ... CS43130_PAD_INT_CFG: + case CS43130_PWDN_CTL: + case CS43130_CRYSTAL_SET: + case CS43130_PLL_SET_1 ... CS43130_PLL_SET_5: + case CS43130_PLL_SET_6: + case CS43130_PLL_SET_7: + case CS43130_PLL_SET_8: + case CS43130_PLL_SET_9: + case CS43130_PLL_SET_10: + case CS43130_CLKOUT_CTL: + case CS43130_ASP_NUM_1 ... CS43130_ASP_FRAME_CONF: + case CS43130_XSP_NUM_1 ... CS43130_XSP_FRAME_CONF: + case CS43130_ASP_CH_1_LOC: + case CS43130_ASP_CH_2_LOC: + case CS43130_ASP_CH_1_SZ_EN: + case CS43130_ASP_CH_2_SZ_EN: + case CS43130_XSP_CH_1_LOC: + case CS43130_XSP_CH_2_LOC: + case CS43130_XSP_CH_1_SZ_EN: + case CS43130_XSP_CH_2_SZ_EN: + case CS43130_DSD_VOL_B ... CS43130_DSD_PATH_CTL_3: + case CS43130_HP_OUT_CTL_1: + case CS43130_PCM_FILT_OPT ... CS43130_PCM_PATH_CTL_2: + case CS43130_CLASS_H_CTL: + case CS43130_HP_DETECT: + case CS43130_HP_STATUS: + case CS43130_HP_LOAD_1: + case CS43130_HP_MEAS_LOAD_1: + case CS43130_HP_MEAS_LOAD_2: + case CS43130_HP_DC_STAT_1: + case CS43130_HP_DC_STAT_2: + case CS43130_HP_AC_STAT_1: + case CS43130_HP_AC_STAT_2: + case CS43130_HP_LOAD_STAT: + case CS43130_INT_STATUS_1 ... CS43130_INT_STATUS_5: + case CS43130_INT_MASK_1 ... CS43130_INT_MASK_5: + return true; + default: + return false; + } +} + +static bool cs43130_precious_register(struct device *dev, unsigned int reg) +{ + switch (reg) { + case CS43130_INT_STATUS_1 ... CS43130_INT_STATUS_5: + return true; + default: + return false; + } +} + +struct cs43130_pll_params { + unsigned int pll_in; + u8 sclk_prediv; + u8 pll_div_int; + u32 pll_div_frac; + u8 pll_mode; + u8 pll_divout; + unsigned int pll_out; + u8 pll_cal_ratio; +}; + +static const struct cs43130_pll_params pll_ratio_table[] = { + {9600000, 0x02, 0x49, 0x800000, 0x00, 0x08, 22579200, 151}, + {9600000, 0x02, 0x50, 0x000000, 0x00, 0x08, 24576000, 164}, + + {11289600, 0x02, 0X40, 0, 0x01, 0x08, 22579200, 128}, + {11289600, 0x02, 0x44, 0x06F700, 0x0, 0x08, 24576000, 139}, + + {12000000, 0x02, 0x49, 0x800000, 0x00, 0x0A, 22579200, 120}, + {12000000, 0x02, 0x40, 0x000000, 0x00, 0x08, 24576000, 131}, + + {12288000, 0x02, 0x49, 0x800000, 0x01, 0x0A, 22579200, 118}, + {12288000, 0x02, 0x40, 0x000000, 0x01, 0x08, 24576000, 128}, + + {13000000, 0x02, 0x45, 0x797680, 0x01, 0x0A, 22579200, 111}, + {13000000, 0x02, 0x3C, 0x7EA940, 0x01, 0x08, 24576000, 121}, + + {19200000, 0x03, 0x49, 0x800000, 0x00, 0x08, 22579200, 151}, + {19200000, 0x03, 0x50, 0x000000, 0x00, 0x08, 24576000, 164}, + + {22579200, 0, 0, 0, 0, 0, 22579200, 0}, + {22579200, 0x03, 0x44, 0x06F700, 0x00, 0x08, 24576000, 139}, + + {24000000, 0x03, 0x49, 0x800000, 0x00, 0x0A, 22579200, 120}, + {24000000, 0x03, 0x40, 0x000000, 0x00, 0x08, 24576000, 131}, + + {24576000, 0x03, 0x49, 0x800000, 0x01, 0x0A, 22579200, 118}, + {24576000, 0, 0, 0, 0, 0, 24576000, 0}, + + {26000000, 0x03, 0x45, 0x797680, 0x01, 0x0A, 22579200, 111}, + {26000000, 0x03, 0x3C, 0x7EA940, 0x01, 0x08, 24576000, 121}, +}; + +static const struct cs43130_pll_params *cs43130_get_pll_table( + unsigned int freq_in, unsigned int freq_out) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(pll_ratio_table); i++) { + if (pll_ratio_table[i].pll_in == freq_in && + pll_ratio_table[i].pll_out == freq_out) + return &pll_ratio_table[i]; + } + + return NULL; +} + +static int cs43130_pll_config(struct snd_soc_codec *codec) +{ + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + const struct cs43130_pll_params *pll_entry; + + dev_dbg(codec->dev, "cs43130->mclk = %u, cs43130->mclk_int = %u\n", + cs43130->mclk, cs43130->mclk_int); + + pll_entry = cs43130_get_pll_table(cs43130->mclk, cs43130->mclk_int); + if (!pll_entry) + return -EINVAL; + + if (pll_entry->pll_cal_ratio == 0) { + regmap_update_bits(cs43130->regmap, CS43130_PLL_SET_1, + CS43130_PLL_START_MASK, 0); + + cs43130->pll_bypass = true; + return 0; + } + + cs43130->pll_bypass = false; + + regmap_update_bits(cs43130->regmap, CS43130_PLL_SET_2, + CS43130_PLL_DIV_DATA_MASK, + pll_entry->pll_div_frac >> + CS43130_PLL_DIV_FRAC_0_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_PLL_SET_3, + CS43130_PLL_DIV_DATA_MASK, + pll_entry->pll_div_frac >> + CS43130_PLL_DIV_FRAC_1_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_PLL_SET_4, + CS43130_PLL_DIV_DATA_MASK, + pll_entry->pll_div_frac >> + CS43130_PLL_DIV_FRAC_2_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_PLL_SET_5, + pll_entry->pll_div_int); + regmap_write(cs43130->regmap, CS43130_PLL_SET_6, pll_entry->pll_divout); + regmap_write(cs43130->regmap, CS43130_PLL_SET_7, + pll_entry->pll_cal_ratio); + regmap_update_bits(cs43130->regmap, CS43130_PLL_SET_8, + CS43130_PLL_MODE_MASK, + pll_entry->pll_mode << CS43130_PLL_MODE_SHIFT); + regmap_write(cs43130->regmap, CS43130_PLL_SET_9, + pll_entry->sclk_prediv); + regmap_update_bits(cs43130->regmap, CS43130_PLL_SET_1, + CS43130_PLL_START_MASK, 1); + + return 0; +} + +static int cs43130_set_pll(struct snd_soc_codec *codec, int pll_id, int source, + unsigned int freq_in, unsigned int freq_out) +{ + int ret = 0; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (freq_in) { + case 9600000: + case 11289600: + case 12000000: + case 12288000: + case 13000000: + case 19200000: + case 22579200: + case 24000000: + case 24576000: + case 26000000: + cs43130->mclk = freq_in; + break; + default: + dev_err(codec->dev, + "unsupported pll input reference clock:%d\n", freq_in); + return -EINVAL; + } + + switch (freq_out) { + case 22579200: + cs43130->mclk_int = freq_out; + break; + case 24576000: + cs43130->mclk_int = freq_out; + break; + default: + dev_err(codec->dev, + "unsupported pll output ref clock: %u\n", freq_out); + return -EINVAL; + } + + ret = cs43130_pll_config(codec); + dev_dbg(codec->dev, "cs43130->pll_bypass = %d", cs43130->pll_bypass); + return ret; +} + +static int cs43130_change_clksrc(struct snd_soc_codec *codec, + enum cs43130_mclk_src_sel src) +{ + int ret; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + int mclk_int_decoded; + + if (src == cs43130->mclk_int_src) { + /* clk source has not changed */ + return 0; + } + + switch (cs43130->mclk_int) { + case CS43130_MCLK_22M: + mclk_int_decoded = CS43130_MCLK_22P5; + break; + case CS43130_MCLK_24M: + mclk_int_decoded = CS43130_MCLK_24P5; + break; + default: + dev_err(codec->dev, "Invalid MCLK INT freq: %u\n", cs43130->mclk_int); + return -EINVAL; + } + + switch (src) { + case CS43130_MCLK_SRC_EXT: + cs43130->pll_bypass = true; + cs43130->mclk_int_src = CS43130_MCLK_SRC_EXT; + if (cs43130->xtal_ibias == CS43130_XTAL_UNUSED) { + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_XTAL_MASK, + 1 << CS43130_PDN_XTAL_SHIFT); + } else { + reinit_completion(&cs43130->xtal_rdy); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_RDY_INT_MASK, 0); + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_XTAL_MASK, 0); + ret = wait_for_completion_timeout(&cs43130->xtal_rdy, + msecs_to_jiffies(100)); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_RDY_INT_MASK, + 1 << CS43130_XTAL_RDY_INT_SHIFT); + if (ret == 0) { + dev_err(codec->dev, "Timeout waiting for XTAL_READY interrupt\n"); + return -ETIMEDOUT; + } + } + + regmap_update_bits(cs43130->regmap, CS43130_SYS_CLK_CTL_1, + CS43130_MCLK_SRC_SEL_MASK, + src << CS43130_MCLK_SRC_SEL_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_SYS_CLK_CTL_1, + CS43130_MCLK_INT_MASK, + mclk_int_decoded << CS43130_MCLK_INT_SHIFT); + usleep_range(150, 200); + + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_PLL_MASK, + 1 << CS43130_PDN_PLL_SHIFT); + break; + case CS43130_MCLK_SRC_PLL: + cs43130->pll_bypass = false; + cs43130->mclk_int_src = CS43130_MCLK_SRC_PLL; + if (cs43130->xtal_ibias == CS43130_XTAL_UNUSED) { + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_XTAL_MASK, + 1 << CS43130_PDN_XTAL_SHIFT); + } else { + reinit_completion(&cs43130->xtal_rdy); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_RDY_INT_MASK, 0); + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_XTAL_MASK, 0); + ret = wait_for_completion_timeout(&cs43130->xtal_rdy, + msecs_to_jiffies(100)); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_RDY_INT_MASK, + 1 << CS43130_XTAL_RDY_INT_SHIFT); + if (ret == 0) { + dev_err(codec->dev, "Timeout waiting for XTAL_READY interrupt\n"); + return -ETIMEDOUT; + } + } + + reinit_completion(&cs43130->pll_rdy); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_PLL_RDY_INT_MASK, 0); + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_PLL_MASK, 0); + ret = wait_for_completion_timeout(&cs43130->pll_rdy, + msecs_to_jiffies(100)); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_PLL_RDY_INT_MASK, + 1 << CS43130_PLL_RDY_INT_SHIFT); + if (ret == 0) { + dev_err(codec->dev, "Timeout waiting for PLL_READY interrupt\n"); + return -ETIMEDOUT; + } + + regmap_update_bits(cs43130->regmap, CS43130_SYS_CLK_CTL_1, + CS43130_MCLK_SRC_SEL_MASK, + src << CS43130_MCLK_SRC_SEL_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_SYS_CLK_CTL_1, + CS43130_MCLK_INT_MASK, + mclk_int_decoded << CS43130_MCLK_INT_SHIFT); + usleep_range(150, 200); + break; + case CS43130_MCLK_SRC_RCO: + cs43130->mclk_int_src = CS43130_MCLK_SRC_RCO; + + regmap_update_bits(cs43130->regmap, CS43130_SYS_CLK_CTL_1, + CS43130_MCLK_SRC_SEL_MASK, + src << CS43130_MCLK_SRC_SEL_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_SYS_CLK_CTL_1, + CS43130_MCLK_INT_MASK, + CS43130_MCLK_22P5 << CS43130_MCLK_INT_SHIFT); + usleep_range(150, 200); + + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_XTAL_MASK, + 1 << CS43130_PDN_XTAL_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_PWDN_CTL, + CS43130_PDN_PLL_MASK, + 1 << CS43130_PDN_PLL_SHIFT); + break; + default: + dev_err(codec->dev, "Invalid MCLK source value\n"); + return -EINVAL; + } + + return 0; +} + +static const struct cs43130_bitwidth_map cs43130_bitwidth_table[] = { + {8, CS43130_SP_BIT_SIZE_8, CS43130_CH_BIT_SIZE_8}, + {16, CS43130_SP_BIT_SIZE_16, CS43130_CH_BIT_SIZE_16}, + {24, CS43130_SP_BIT_SIZE_24, CS43130_CH_BIT_SIZE_24}, + {32, CS43130_SP_BIT_SIZE_32, CS43130_CH_BIT_SIZE_32}, +}; + +static const struct cs43130_bitwidth_map *cs43130_get_bitwidth_table( + unsigned int bitwidth) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(cs43130_bitwidth_table); i++) { + if (cs43130_bitwidth_table[i].bitwidth == bitwidth) + return &cs43130_bitwidth_table[i]; + } + + return NULL; +} + +static int cs43130_set_bitwidth(int dai_id, unsigned int bitwidth_dai, + struct regmap *regmap) +{ + const struct cs43130_bitwidth_map *bw_map; + + bw_map = cs43130_get_bitwidth_table(bitwidth_dai); + if (!bw_map) + return -EINVAL; + + switch (dai_id) { + case CS43130_ASP_PCM_DAI: + case CS43130_ASP_DOP_DAI: + regmap_update_bits(regmap, CS43130_ASP_CH_1_SZ_EN, + CS43130_CH_BITSIZE_MASK, bw_map->ch_bit); + regmap_update_bits(regmap, CS43130_ASP_CH_2_SZ_EN, + CS43130_CH_BITSIZE_MASK, bw_map->ch_bit); + regmap_update_bits(regmap, CS43130_SP_BITSIZE, + CS43130_ASP_BITSIZE_MASK, bw_map->sp_bit); + break; + case CS43130_XSP_DOP_DAI: + regmap_update_bits(regmap, CS43130_XSP_CH_1_SZ_EN, + CS43130_CH_BITSIZE_MASK, bw_map->ch_bit); + regmap_update_bits(regmap, CS43130_XSP_CH_2_SZ_EN, + CS43130_CH_BITSIZE_MASK, bw_map->ch_bit); + regmap_update_bits(regmap, CS43130_SP_BITSIZE, + CS43130_XSP_BITSIZE_MASK, bw_map->sp_bit << + CS43130_XSP_BITSIZE_SHIFT); + break; + default: + return -EINVAL; + } + + return 0; +} + +static const struct cs43130_rate_map cs43130_rate_table[] = { + {32000, CS43130_ASP_SPRATE_32K}, + {44100, CS43130_ASP_SPRATE_44_1K}, + {48000, CS43130_ASP_SPRATE_48K}, + {88200, CS43130_ASP_SPRATE_88_2K}, + {96000, CS43130_ASP_SPRATE_96K}, + {176400, CS43130_ASP_SPRATE_176_4K}, + {192000, CS43130_ASP_SPRATE_192K}, + {352800, CS43130_ASP_SPRATE_352_8K}, + {384000, CS43130_ASP_SPRATE_384K}, +}; + +static const struct cs43130_rate_map *cs43130_get_rate_table(int fs) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(cs43130_rate_table); i++) { + if (cs43130_rate_table[i].fs == fs) + return &cs43130_rate_table[i]; + } + + return NULL; +} + +static const struct cs43130_clk_gen *cs43130_get_clk_gen(int mclk_int, int fs, + const struct cs43130_clk_gen *clk_gen_table, int len_clk_gen_table) +{ + int i; + + for (i = 0; i < len_clk_gen_table; i++) { + if (clk_gen_table[i].mclk_int == mclk_int && + clk_gen_table[i].fs == fs) + return &clk_gen_table[i]; + } + + return NULL; +} + +static int cs43130_set_sp_fmt(int dai_id, unsigned int bitwidth_sclk, + struct snd_pcm_hw_params *params, + struct cs43130_private *cs43130) +{ + u16 frm_size; + u16 hi_size; + u8 frm_delay; + u8 frm_phase; + u8 frm_data; + u8 sclk_edge; + u8 lrck_edge; + u8 clk_data; + u8 loc_ch1; + u8 loc_ch2; + u8 dai_mode_val; + const struct cs43130_clk_gen *clk_gen; + + switch (cs43130->dais[dai_id].dai_format) { + case SND_SOC_DAIFMT_I2S: + hi_size = bitwidth_sclk; + frm_delay = 2; + frm_phase = 0; + break; + case SND_SOC_DAIFMT_LEFT_J: + hi_size = bitwidth_sclk; + frm_delay = 2; + frm_phase = 1; + break; + case SND_SOC_DAIFMT_DSP_A: + hi_size = 1; + frm_delay = 2; + frm_phase = 1; + break; + case SND_SOC_DAIFMT_DSP_B: + hi_size = 1; + frm_delay = 0; + frm_phase = 1; + break; + default: + return -EINVAL; + } + + switch (cs43130->dais[dai_id].dai_mode) { + case SND_SOC_DAIFMT_CBS_CFS: + dai_mode_val = 0; + break; + case SND_SOC_DAIFMT_CBM_CFM: + dai_mode_val = 1; + break; + default: + return -EINVAL; + } + + frm_size = bitwidth_sclk * params_channels(params); + sclk_edge = 1; + lrck_edge = 0; + loc_ch1 = 0; + loc_ch2 = bitwidth_sclk * (params_channels(params) - 1); + + frm_data = frm_delay & CS43130_SP_FSD_MASK; + frm_data |= (frm_phase << CS43130_SP_STP_SHIFT) & CS43130_SP_STP_MASK; + + clk_data = lrck_edge & CS43130_SP_LCPOL_IN_MASK; + clk_data |= (lrck_edge << CS43130_SP_LCPOL_OUT_SHIFT) & + CS43130_SP_LCPOL_OUT_MASK; + clk_data |= (sclk_edge << CS43130_SP_SCPOL_IN_SHIFT) & + CS43130_SP_SCPOL_IN_MASK; + clk_data |= (sclk_edge << CS43130_SP_SCPOL_OUT_SHIFT) & + CS43130_SP_SCPOL_OUT_MASK; + clk_data |= (dai_mode_val << CS43130_SP_MODE_SHIFT) & + CS43130_SP_MODE_MASK; + + switch (dai_id) { + case CS43130_ASP_PCM_DAI: + case CS43130_ASP_DOP_DAI: + regmap_update_bits(cs43130->regmap, CS43130_ASP_LRCK_PERIOD_1, + CS43130_SP_LCPR_DATA_MASK, (frm_size - 1) >> + CS43130_SP_LCPR_LSB_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_ASP_LRCK_PERIOD_2, + CS43130_SP_LCPR_DATA_MASK, (frm_size - 1) >> + CS43130_SP_LCPR_MSB_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_ASP_LRCK_HI_TIME_1, + CS43130_SP_LCHI_DATA_MASK, (hi_size - 1) >> + CS43130_SP_LCHI_LSB_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_ASP_LRCK_HI_TIME_2, + CS43130_SP_LCHI_DATA_MASK, (hi_size - 1) >> + CS43130_SP_LCHI_MSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_ASP_FRAME_CONF, frm_data); + regmap_write(cs43130->regmap, CS43130_ASP_CH_1_LOC, loc_ch1); + regmap_write(cs43130->regmap, CS43130_ASP_CH_2_LOC, loc_ch2); + regmap_update_bits(cs43130->regmap, CS43130_ASP_CH_1_SZ_EN, + CS43130_CH_EN_MASK, 1 << CS43130_CH_EN_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_ASP_CH_2_SZ_EN, + CS43130_CH_EN_MASK, 1 << CS43130_CH_EN_SHIFT); + regmap_write(cs43130->regmap, CS43130_ASP_CLOCK_CONF, clk_data); + break; + case CS43130_XSP_DOP_DAI: + regmap_update_bits(cs43130->regmap, CS43130_XSP_LRCK_PERIOD_1, + CS43130_SP_LCPR_DATA_MASK, (frm_size - 1) >> + CS43130_SP_LCPR_LSB_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_XSP_LRCK_PERIOD_2, + CS43130_SP_LCPR_DATA_MASK, (frm_size - 1) >> + CS43130_SP_LCPR_MSB_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_XSP_LRCK_HI_TIME_1, + CS43130_SP_LCHI_DATA_MASK, (hi_size - 1) >> + CS43130_SP_LCHI_LSB_DATA_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_XSP_LRCK_HI_TIME_2, + CS43130_SP_LCHI_DATA_MASK, (hi_size - 1) >> + CS43130_SP_LCHI_MSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_XSP_FRAME_CONF, frm_data); + regmap_write(cs43130->regmap, CS43130_XSP_CH_1_LOC, loc_ch1); + regmap_write(cs43130->regmap, CS43130_XSP_CH_2_LOC, loc_ch2); + regmap_update_bits(cs43130->regmap, CS43130_XSP_CH_1_SZ_EN, + CS43130_CH_EN_MASK, 1 << CS43130_CH_EN_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_XSP_CH_2_SZ_EN, + CS43130_CH_EN_MASK, 1 << CS43130_CH_EN_SHIFT); + regmap_write(cs43130->regmap, CS43130_XSP_CLOCK_CONF, clk_data); + break; + default: + return -EINVAL; + } + + switch (frm_size) { + case 16: + clk_gen = cs43130_get_clk_gen(cs43130->mclk_int, + params_rate(params), + cs43130_16_clk_gen, + ARRAY_SIZE(cs43130_16_clk_gen)); + break; + case 32: + clk_gen = cs43130_get_clk_gen(cs43130->mclk_int, + params_rate(params), + cs43130_32_clk_gen, + ARRAY_SIZE(cs43130_32_clk_gen)); + break; + case 48: + clk_gen = cs43130_get_clk_gen(cs43130->mclk_int, + params_rate(params), + cs43130_48_clk_gen, + ARRAY_SIZE(cs43130_48_clk_gen)); + break; + case 64: + clk_gen = cs43130_get_clk_gen(cs43130->mclk_int, + params_rate(params), + cs43130_64_clk_gen, + ARRAY_SIZE(cs43130_64_clk_gen)); + break; + default: + return -EINVAL; + } + + if (!clk_gen) + return -EINVAL; + + switch (dai_id) { + case CS43130_ASP_PCM_DAI: + case CS43130_ASP_DOP_DAI: + regmap_write(cs43130->regmap, CS43130_ASP_DEN_1, + (clk_gen->den & CS43130_SP_M_LSB_DATA_MASK) >> + CS43130_SP_M_LSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_ASP_DEN_2, + (clk_gen->den & CS43130_SP_M_MSB_DATA_MASK) >> + CS43130_SP_M_MSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_ASP_NUM_1, + (clk_gen->num & CS43130_SP_N_LSB_DATA_MASK) >> + CS43130_SP_N_LSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_ASP_NUM_2, + (clk_gen->num & CS43130_SP_N_MSB_DATA_MASK) >> + CS43130_SP_N_MSB_DATA_SHIFT); + break; + case CS43130_XSP_DOP_DAI: + regmap_write(cs43130->regmap, CS43130_XSP_DEN_1, + (clk_gen->den & CS43130_SP_M_LSB_DATA_MASK) >> + CS43130_SP_M_LSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_XSP_DEN_2, + (clk_gen->den & CS43130_SP_M_MSB_DATA_MASK) >> + CS43130_SP_M_MSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_XSP_NUM_1, + (clk_gen->num & CS43130_SP_N_LSB_DATA_MASK) >> + CS43130_SP_N_LSB_DATA_SHIFT); + regmap_write(cs43130->regmap, CS43130_XSP_NUM_2, + (clk_gen->num & CS43130_SP_N_MSB_DATA_MASK) >> + CS43130_SP_N_MSB_DATA_SHIFT); + break; + default: + return -EINVAL; + } + + return 0; +} + +static int cs43130_pcm_dsd_mix(bool en, struct regmap *regmap) +{ + if (en) { + regmap_update_bits(regmap, CS43130_DSD_PCM_MIX_CTL, + CS43130_MIX_PCM_PREP_MASK, + 1 << CS43130_MIX_PCM_PREP_SHIFT); + usleep_range(6000, 6050); + regmap_update_bits(regmap, CS43130_DSD_PCM_MIX_CTL, + CS43130_MIX_PCM_DSD_MASK, + 1 << CS43130_MIX_PCM_DSD_SHIFT); + } else { + regmap_update_bits(regmap, CS43130_DSD_PCM_MIX_CTL, + CS43130_MIX_PCM_DSD_MASK, + 0 << CS43130_MIX_PCM_DSD_SHIFT); + usleep_range(1600, 1650); + regmap_update_bits(regmap, CS43130_DSD_PCM_MIX_CTL, + CS43130_MIX_PCM_PREP_MASK, + 0 << CS43130_MIX_PCM_PREP_SHIFT); + } + + return 0; +} + +static int cs43130_dsd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + unsigned int required_clk; + u8 dsd_speed; + + mutex_lock(&cs43130->clk_mutex); + if (!cs43130->clk_req) { + /* no DAI is currently using clk */ + if (!(CS43130_MCLK_22M % params_rate(params))) + required_clk = CS43130_MCLK_22M; + else + required_clk = CS43130_MCLK_24M; + + cs43130_set_pll(codec, 0, 0, cs43130->mclk, required_clk); + if (cs43130->pll_bypass) + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_EXT); + else + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_PLL); + } + + cs43130->clk_req++; + if (cs43130->clk_req == 2) + cs43130_pcm_dsd_mix(true, cs43130->regmap); + mutex_unlock(&cs43130->clk_mutex); + + switch (params_rate(params)) { + case 176400: + dsd_speed = 0; + break; + case 352800: + dsd_speed = 1; + break; + default: + dev_err(codec->dev, "Rate(%u) not supported\n", + params_rate(params)); + return -EINVAL; + } + + if (cs43130->dais[dai->id].dai_mode == SND_SOC_DAIFMT_CBM_CFM) + regmap_update_bits(cs43130->regmap, CS43130_DSD_INT_CFG, + CS43130_DSD_MASTER, CS43130_DSD_MASTER); + else + regmap_update_bits(cs43130->regmap, CS43130_DSD_INT_CFG, + CS43130_DSD_MASTER, 0); + + regmap_update_bits(cs43130->regmap, CS43130_DSD_PATH_CTL_2, + CS43130_DSD_SPEED_MASK, + dsd_speed << CS43130_DSD_SPEED_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_DSD_PATH_CTL_2, + CS43130_DSD_SRC_MASK, CS43130_DSD_SRC_DSD << + CS43130_DSD_SRC_SHIFT); + + return 0; +} + +static int cs43130_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + const struct cs43130_rate_map *rate_map; + unsigned int sclk = cs43130->dais[dai->id].sclk; + unsigned int bitwidth_sclk; + unsigned int bitwidth_dai = (unsigned int)(params_width(params)); + unsigned int required_clk; + u8 dsd_speed; + + mutex_lock(&cs43130->clk_mutex); + if (!cs43130->clk_req) { + /* no DAI is currently using clk */ + if (!(CS43130_MCLK_22M % params_rate(params))) + required_clk = CS43130_MCLK_22M; + else + required_clk = CS43130_MCLK_24M; + + cs43130_set_pll(codec, 0, 0, cs43130->mclk, required_clk); + if (cs43130->pll_bypass) + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_EXT); + else + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_PLL); + } + + cs43130->clk_req++; + if (cs43130->clk_req == 2) + cs43130_pcm_dsd_mix(true, cs43130->regmap); + mutex_unlock(&cs43130->clk_mutex); + + switch (dai->id) { + case CS43130_ASP_DOP_DAI: + case CS43130_XSP_DOP_DAI: + /* DoP bitwidth is always 24-bit */ + bitwidth_dai = 24; + sclk = params_rate(params) * bitwidth_dai * + params_channels(params); + + switch (params_rate(params)) { + case 176400: + dsd_speed = 0; + break; + case 352800: + dsd_speed = 1; + break; + default: + dev_err(codec->dev, "Rate(%u) not supported\n", + params_rate(params)); + return -EINVAL; + } + + regmap_update_bits(cs43130->regmap, CS43130_DSD_PATH_CTL_2, + CS43130_DSD_SPEED_MASK, + dsd_speed << CS43130_DSD_SPEED_SHIFT); + break; + case CS43130_ASP_PCM_DAI: + rate_map = cs43130_get_rate_table(params_rate(params)); + if (!rate_map) + return -EINVAL; + + regmap_write(cs43130->regmap, CS43130_SP_SRATE, rate_map->val); + break; + default: + dev_err(codec->dev, "Invalid DAI (%d)\n", dai->id); + return -EINVAL; + } + + switch (dai->id) { + case CS43130_ASP_DOP_DAI: + regmap_update_bits(cs43130->regmap, CS43130_DSD_PATH_CTL_2, + CS43130_DSD_SRC_MASK, CS43130_DSD_SRC_ASP << + CS43130_DSD_SRC_SHIFT); + break; + case CS43130_XSP_DOP_DAI: + regmap_update_bits(cs43130->regmap, CS43130_DSD_PATH_CTL_2, + CS43130_DSD_SRC_MASK, CS43130_DSD_SRC_XSP << + CS43130_DSD_SRC_SHIFT); + } + + if (!sclk && cs43130->dais[dai->id].dai_mode == SND_SOC_DAIFMT_CBM_CFM) + /* Calculate SCLK in master mode if unassigned */ + sclk = params_rate(params) * bitwidth_dai * + params_channels(params); + + if (!sclk) { + /* at this point, SCLK must be set */ + dev_err(codec->dev, "SCLK freq is not set\n"); + return -EINVAL; + } + + bitwidth_sclk = (sclk / params_rate(params)) / params_channels(params); + if (bitwidth_sclk < bitwidth_dai) { + dev_err(codec->dev, "Format not supported: SCLK freq is too low\n"); + return -EINVAL; + } + + dev_dbg(codec->dev, + "sclk = %u, fs = %d, bitwidth_dai = %u\n", + sclk, params_rate(params), bitwidth_dai); + + dev_dbg(codec->dev, + "bitwidth_sclk = %u, num_ch = %u\n", + bitwidth_sclk, params_channels(params)); + + cs43130_set_bitwidth(dai->id, bitwidth_dai, cs43130->regmap); + cs43130_set_sp_fmt(dai->id, bitwidth_sclk, params, cs43130); + + return 0; +} + +static int cs43130_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + mutex_lock(&cs43130->clk_mutex); + cs43130->clk_req--; + if (!cs43130->clk_req) { + /* no DAI is currently using clk */ + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_RCO); + cs43130_pcm_dsd_mix(false, cs43130->regmap); + } + mutex_unlock(&cs43130->clk_mutex); + + return 0; +} + +static const DECLARE_TLV_DB_SCALE(pcm_vol_tlv, -12750, 50, 1); + +static const char * const pcm_ch_text[] = { + "Left-Right Ch", + "Left-Left Ch", + "Right-Left Ch", + "Right-Right Ch", +}; + +static const struct reg_sequence pcm_ch_en_seq[] = { + {CS43130_DXD1, 0x99}, + {0x180005, 0x8C}, + {0x180007, 0xAB}, + {0x180015, 0x31}, + {0x180017, 0xB2}, + {0x180025, 0x30}, + {0x180027, 0x84}, + {0x180035, 0x9C}, + {0x180037, 0xAE}, + {0x18000D, 0x24}, + {0x18000F, 0xA3}, + {0x18001D, 0x05}, + {0x18001F, 0xD4}, + {0x18002D, 0x0B}, + {0x18002F, 0xC7}, + {0x18003D, 0x71}, + {0x18003F, 0xE7}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence pcm_ch_dis_seq[] = { + {CS43130_DXD1, 0x99}, + {0x180005, 0x24}, + {0x180007, 0xA3}, + {0x180015, 0x05}, + {0x180017, 0xD4}, + {0x180025, 0x0B}, + {0x180027, 0xC7}, + {0x180035, 0x71}, + {0x180037, 0xE7}, + {0x18000D, 0x8C}, + {0x18000F, 0xAB}, + {0x18001D, 0x31}, + {0x18001F, 0xB2}, + {0x18002D, 0x30}, + {0x18002F, 0x84}, + {0x18003D, 0x9C}, + {0x18003F, 0xAE}, + {CS43130_DXD1, 0}, +}; + +static int cs43130_pcm_ch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return snd_soc_get_enum_double(kcontrol, ucontrol); +} + +static int cs43130_pcm_ch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int *item = ucontrol->value.enumerated.item; + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + unsigned int val; + + if (item[0] >= e->items) + return -EINVAL; + val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; + + switch (cs43130->dev_id) { + case CS43131_CHIP_ID: + case CS43198_CHIP_ID: + if (val >= 2) + regmap_multi_reg_write(cs43130->regmap, pcm_ch_en_seq, + ARRAY_SIZE(pcm_ch_en_seq)); + else + regmap_multi_reg_write(cs43130->regmap, pcm_ch_dis_seq, + ARRAY_SIZE(pcm_ch_dis_seq)); + } + + return snd_soc_put_enum_double(kcontrol, ucontrol); +} + +static SOC_ENUM_SINGLE_DECL(pcm_ch_enum, CS43130_PCM_PATH_CTL_2, 0, + pcm_ch_text); + +static const char * const pcm_spd_texts[] = { + "Fast", + "Slow", +}; + +static SOC_ENUM_SINGLE_DECL(pcm_spd_enum, CS43130_PCM_FILT_OPT, 7, + pcm_spd_texts); + +static const char * const dsd_texts[] = { + "Off", + "BCKA Mode", + "BCKD Mode", +}; + +static const unsigned int dsd_values[] = { + CS43130_DSD_SRC_DSD, + CS43130_DSD_SRC_ASP, + CS43130_DSD_SRC_XSP, +}; + +static SOC_VALUE_ENUM_SINGLE_DECL(dsd_enum, CS43130_DSD_INT_CFG, 0, 0x03, + dsd_texts, dsd_values); + +static const struct snd_kcontrol_new cs43130_snd_controls[] = { + SOC_DOUBLE_R_TLV("Master Playback Volume", + CS43130_PCM_VOL_A, CS43130_PCM_VOL_B, 0, 0xFF, 1, + pcm_vol_tlv), + SOC_DOUBLE_R_TLV("Master DSD Playback Volume", + CS43130_DSD_VOL_A, CS43130_DSD_VOL_B, 0, 0xFF, 1, + pcm_vol_tlv), + SOC_ENUM_EXT("PCM Ch Select", pcm_ch_enum, cs43130_pcm_ch_get, + cs43130_pcm_ch_put), + SOC_ENUM("PCM Filter Speed", pcm_spd_enum), + SOC_SINGLE("PCM Phase Compensation", CS43130_PCM_FILT_OPT, 6, 1, 0), + SOC_SINGLE("PCM Nonoversample Emulate", CS43130_PCM_FILT_OPT, 5, 1, 0), + SOC_SINGLE("PCM High-pass Filter", CS43130_PCM_FILT_OPT, 1, 1, 0), + SOC_SINGLE("PCM De-emphasis Filter", CS43130_PCM_FILT_OPT, 0, 1, 0), + SOC_ENUM("DSD Phase Modulation", dsd_enum), +}; + +static const struct reg_sequence pcm_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD7, 0x01}, + {CS43130_DXD8, 0}, + {CS43130_DXD9, 0x01}, + {CS43130_DXD3, 0x12}, + {CS43130_DXD4, 0}, + {CS43130_DXD10, 0x28}, + {CS43130_DXD11, 0x28}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence dsd_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD7, 0x01}, + {CS43130_DXD8, 0}, + {CS43130_DXD9, 0x01}, + {CS43130_DXD3, 0x12}, + {CS43130_DXD4, 0}, + {CS43130_DXD10, 0x1E}, + {CS43130_DXD11, 0x20}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence pop_free_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD12, 0x0A}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence pop_free_seq2[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD13, 0x20}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence mute_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD3, 0x12}, + {CS43130_DXD5, 0x02}, + {CS43130_DXD4, 0x12}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence unmute_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD3, 0x10}, + {CS43130_DXD5, 0}, + {CS43130_DXD4, 0x16}, + {CS43130_DXD1, 0}, +}; + +static int cs43130_dsd_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, dsd_seq, + ARRAY_SIZE(dsd_seq)); + } + break; + case SND_SOC_DAPM_POST_PMU: + regmap_update_bits(cs43130->regmap, CS43130_DSD_PATH_CTL_1, + CS43130_MUTE_MASK, 0); + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, unmute_seq, + ARRAY_SIZE(unmute_seq)); + } + break; + case SND_SOC_DAPM_PRE_PMD: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, mute_seq, + ARRAY_SIZE(mute_seq)); + regmap_update_bits(cs43130->regmap, + CS43130_DSD_PATH_CTL_1, + CS43130_MUTE_MASK, CS43130_MUTE_EN); + /* + * DSD Power Down Sequence + * According to Design, 130ms is preferred. + */ + msleep(130); + break; + case CS43131_CHIP_ID: + case CS43198_CHIP_ID: + regmap_update_bits(cs43130->regmap, + CS43130_DSD_PATH_CTL_1, + CS43130_MUTE_MASK, CS43130_MUTE_EN); + } + break; + default: + dev_err(codec->dev, "Invalid event = 0x%x\n", event); + return -EINVAL; + } + return 0; +} + +static int cs43130_pcm_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, pcm_seq, + ARRAY_SIZE(pcm_seq)); + } + break; + case SND_SOC_DAPM_POST_PMU: + regmap_update_bits(cs43130->regmap, CS43130_PCM_PATH_CTL_1, + CS43130_MUTE_MASK, 0); + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, unmute_seq, + ARRAY_SIZE(unmute_seq)); + } + break; + case SND_SOC_DAPM_PRE_PMD: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, mute_seq, + ARRAY_SIZE(mute_seq)); + regmap_update_bits(cs43130->regmap, + CS43130_PCM_PATH_CTL_1, + CS43130_MUTE_MASK, CS43130_MUTE_EN); + /* + * PCM Power Down Sequence + * According to Design, 130ms is preferred. + */ + msleep(130); + break; + case CS43131_CHIP_ID: + case CS43198_CHIP_ID: + regmap_update_bits(cs43130->regmap, + CS43130_PCM_PATH_CTL_1, + CS43130_MUTE_MASK, CS43130_MUTE_EN); + } + break; + default: + dev_err(codec->dev, "Invalid event = 0x%x\n", event); + return -EINVAL; + } + return 0; +} + +static const struct reg_sequence dac_postpmu_seq[] = { + {CS43130_DXD9, 0x0C}, + {CS43130_DXD3, 0x10}, + {CS43130_DXD4, 0x20}, +}; + +static const struct reg_sequence dac_postpmd_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD6, 0x01}, + {CS43130_DXD1, 0}, +}; + +static int cs43130_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, pop_free_seq, + ARRAY_SIZE(pop_free_seq)); + break; + case CS43131_CHIP_ID: + case CS43198_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, pop_free_seq2, + ARRAY_SIZE(pop_free_seq2)); + } + break; + case SND_SOC_DAPM_POST_PMU: + usleep_range(10000, 10050); + + regmap_write(cs43130->regmap, CS43130_DXD1, 0x99); + + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, dac_postpmu_seq, + ARRAY_SIZE(dac_postpmu_seq)); + /* + * Per datasheet, Sec. PCM Power-Up Sequence. + * According to Design, CS43130_DXD12 must be 0 to meet + * THDN and Dynamic Range spec. + */ + msleep(1000); + regmap_write(cs43130->regmap, CS43130_DXD12, 0); + break; + case CS43131_CHIP_ID: + case CS43198_CHIP_ID: + usleep_range(12000, 12010); + regmap_write(cs43130->regmap, CS43130_DXD13, 0); + } + + regmap_write(cs43130->regmap, CS43130_DXD1, 0); + break; + case SND_SOC_DAPM_POST_PMD: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + regmap_multi_reg_write(cs43130->regmap, dac_postpmd_seq, + ARRAY_SIZE(dac_postpmd_seq)); + } + break; + default: + dev_err(codec->dev, "Invalid DAC event = 0x%x\n", event); + return -EINVAL; + } + return 0; +} + +static const struct reg_sequence hpin_prepmd_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD15, 0x64}, + {CS43130_DXD14, 0}, + {CS43130_DXD2, 0}, + {CS43130_DXD1, 0}, +}; + +static const struct reg_sequence hpin_postpmu_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD2, 1}, + {CS43130_DXD14, 0xDC}, + {CS43130_DXD15, 0xE4}, + {CS43130_DXD1, 0}, +}; + +static int cs43130_hpin_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (event) { + case SND_SOC_DAPM_POST_PMD: + regmap_multi_reg_write(cs43130->regmap, hpin_prepmd_seq, + ARRAY_SIZE(hpin_prepmd_seq)); + break; + case SND_SOC_DAPM_PRE_PMU: + regmap_multi_reg_write(cs43130->regmap, hpin_postpmu_seq, + ARRAY_SIZE(hpin_postpmu_seq)); + break; + default: + dev_err(codec->dev, "Invalid HPIN event = 0x%x\n", event); + return -EINVAL; + } + return 0; +} + +static const struct snd_soc_dapm_widget digital_hp_widgets[] = { + SND_SOC_DAPM_OUTPUT("HPOUTA"), + SND_SOC_DAPM_OUTPUT("HPOUTB"), + + SND_SOC_DAPM_AIF_IN_E("ASPIN PCM", NULL, 0, CS43130_PWDN_CTL, + CS43130_PDN_ASP_SHIFT, 1, cs43130_pcm_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD)), + + SND_SOC_DAPM_AIF_IN_E("ASPIN DoP", NULL, 0, CS43130_PWDN_CTL, + CS43130_PDN_ASP_SHIFT, 1, cs43130_dsd_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD)), + + SND_SOC_DAPM_AIF_IN_E("XSPIN DoP", NULL, 0, CS43130_PWDN_CTL, + CS43130_PDN_XSP_SHIFT, 1, cs43130_dsd_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD)), + + SND_SOC_DAPM_AIF_IN_E("XSPIN DSD", NULL, 0, CS43130_PWDN_CTL, + CS43130_PDN_DSDIF_SHIFT, 1, cs43130_dsd_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD)), + + SND_SOC_DAPM_DAC("DSD", NULL, CS43130_DSD_PATH_CTL_2, + CS43130_DSD_EN_SHIFT, 0), + + SND_SOC_DAPM_DAC_E("HiFi DAC", NULL, CS43130_PWDN_CTL, + CS43130_PDN_HP_SHIFT, 1, cs43130_dac_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_POST_PMD)), +}; + +static const struct snd_soc_dapm_widget analog_hp_widgets[] = { + SND_SOC_DAPM_DAC_E("Analog Playback", NULL, CS43130_HP_OUT_CTL_1, + CS43130_HP_IN_EN_SHIFT, 0, cs43130_hpin_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD)), +}; + +static struct snd_soc_dapm_widget all_hp_widgets[ + ARRAY_SIZE(digital_hp_widgets) + + ARRAY_SIZE(analog_hp_widgets)]; + +static const struct snd_soc_dapm_route digital_hp_routes[] = { + {"ASPIN PCM", NULL, "ASP PCM Playback"}, + {"ASPIN DoP", NULL, "ASP DoP Playback"}, + {"XSPIN DoP", NULL, "XSP DoP Playback"}, + {"XSPIN DSD", NULL, "XSP DSD Playback"}, + {"DSD", NULL, "ASPIN DoP"}, + {"DSD", NULL, "XSPIN DoP"}, + {"DSD", NULL, "XSPIN DSD"}, + {"HiFi DAC", NULL, "ASPIN PCM"}, + {"HiFi DAC", NULL, "DSD"}, + {"HPOUTA", NULL, "HiFi DAC"}, + {"HPOUTB", NULL, "HiFi DAC"}, +}; + +static const struct snd_soc_dapm_route analog_hp_routes[] = { + {"HPOUTA", NULL, "Analog Playback"}, + {"HPOUTB", NULL, "Analog Playback"}, +}; + +static struct snd_soc_dapm_route all_hp_routes[ + ARRAY_SIZE(digital_hp_routes) + + ARRAY_SIZE(analog_hp_routes)]; + +static const unsigned int cs43130_asp_src_rates[] = { + 32000, 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 +}; + +static const struct snd_pcm_hw_constraint_list cs43130_asp_constraints = { + .count = ARRAY_SIZE(cs43130_asp_src_rates), + .list = cs43130_asp_src_rates, +}; + +static int cs43130_pcm_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &cs43130_asp_constraints); +} + +static const unsigned int cs43130_dop_src_rates[] = { + 176400, 352800, +}; + +static const struct snd_pcm_hw_constraint_list cs43130_dop_constraints = { + .count = ARRAY_SIZE(cs43130_dop_src_rates), + .list = cs43130_dop_src_rates, +}; + +static int cs43130_dop_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &cs43130_dop_constraints); +} + +static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + cs43130->dais[codec_dai->id].dai_mode = SND_SOC_DAIFMT_CBS_CFS; + break; + case SND_SOC_DAIFMT_CBM_CFM: + cs43130->dais[codec_dai->id].dai_mode = SND_SOC_DAIFMT_CBM_CFM; + break; + default: + dev_err(codec->dev, "unsupported mode\n"); + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_I2S; + break; + case SND_SOC_DAIFMT_LEFT_J: + cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_LEFT_J; + break; + case SND_SOC_DAIFMT_DSP_A: + cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_DSP_A; + break; + case SND_SOC_DAIFMT_DSP_B: + cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_DSP_B; + break; + default: + dev_err(codec->dev, + "unsupported audio format\n"); + return -EINVAL; + } + + dev_dbg(codec->dev, "dai_id = %d, dai_mode = %u, dai_format = %u\n", + codec_dai->id, + cs43130->dais[codec_dai->id].dai_mode, + cs43130->dais[codec_dai->id].dai_format); + + return 0; +} + +static int cs43130_dsd_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + cs43130->dais[codec_dai->id].dai_mode = SND_SOC_DAIFMT_CBS_CFS; + break; + case SND_SOC_DAIFMT_CBM_CFM: + cs43130->dais[codec_dai->id].dai_mode = SND_SOC_DAIFMT_CBM_CFM; + break; + default: + dev_err(codec->dev, "Unsupported DAI format.\n"); + return -EINVAL; + } + + dev_dbg(codec->dev, "dai_mode = 0x%x\n", + cs43130->dais[codec_dai->id].dai_mode); + + return 0; +} + +static int cs43130_set_sysclk(struct snd_soc_dai *codec_dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + cs43130->dais[codec_dai->id].sclk = freq; + dev_dbg(codec->dev, "dai_id = %d, sclk = %u\n", codec_dai->id, + cs43130->dais[codec_dai->id].sclk); + + return 0; +} + +static const struct snd_soc_dai_ops cs43130_pcm_ops = { + .startup = cs43130_pcm_startup, + .hw_params = cs43130_hw_params, + .hw_free = cs43130_hw_free, + .set_sysclk = cs43130_set_sysclk, + .set_fmt = cs43130_pcm_set_fmt, +}; + +static const struct snd_soc_dai_ops cs43130_dop_ops = { + .startup = cs43130_dop_startup, + .hw_params = cs43130_hw_params, + .hw_free = cs43130_hw_free, + .set_sysclk = cs43130_set_sysclk, + .set_fmt = cs43130_pcm_set_fmt, +}; + +static const struct snd_soc_dai_ops cs43130_dsd_ops = { + .startup = cs43130_dop_startup, + .hw_params = cs43130_dsd_hw_params, + .hw_free = cs43130_hw_free, + .set_fmt = cs43130_dsd_set_fmt, +}; + +static struct snd_soc_dai_driver cs43130_dai[] = { + { + .name = "cs43130-asp-pcm", + .id = CS43130_ASP_PCM_DAI, + .playback = { + .stream_name = "ASP PCM Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = CS43130_PCM_FORMATS, + }, + .ops = &cs43130_pcm_ops, + .symmetric_rates = 1, + }, + { + .name = "cs43130-asp-dop", + .id = CS43130_ASP_DOP_DAI, + .playback = { + .stream_name = "ASP DoP Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = CS43130_DOP_FORMATS, + }, + .ops = &cs43130_dop_ops, + .symmetric_rates = 1, + }, + { + .name = "cs43130-xsp-dop", + .id = CS43130_XSP_DOP_DAI, + .playback = { + .stream_name = "XSP DoP Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = CS43130_DOP_FORMATS, + }, + .ops = &cs43130_dop_ops, + .symmetric_rates = 1, + }, + { + .name = "cs43130-xsp-dsd", + .id = CS43130_XSP_DSD_DAI, + .playback = { + .stream_name = "XSP DSD Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = CS43130_DOP_FORMATS, + }, + .ops = &cs43130_dsd_ops, + }, + +}; + +static int cs43130_codec_set_sysclk(struct snd_soc_codec *codec, + int clk_id, int source, unsigned int freq, + int dir) +{ + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + + dev_dbg(codec->dev, "clk_id = %d, source = %d, freq = %d, dir = %d\n", + clk_id, source, freq, dir); + + switch (freq) { + case CS43130_MCLK_22M: + case CS43130_MCLK_24M: + cs43130->mclk = freq; + break; + default: + dev_err(codec->dev, "Invalid MCLK INT freq: %u\n", freq); + return -EINVAL; + } + + if (source == CS43130_MCLK_SRC_EXT) { + cs43130->pll_bypass = true; + } else { + dev_err(codec->dev, "Invalid MCLK source\n"); + return -EINVAL; + } + + return 0; +} + +static inline u16 cs43130_get_ac_reg_val(u16 ac_freq) +{ + /* AC freq is counted in 5.94Hz step. */ + return ac_freq / 6; +} + +static int cs43130_show_dc(struct device *dev, char *buf, u8 ch) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cs43130_private *cs43130 = i2c_get_clientdata(client); + + if (!cs43130->hpload_done) + return scnprintf(buf, PAGE_SIZE, "NO_HPLOAD\n"); + else + return scnprintf(buf, PAGE_SIZE, "%u\n", + cs43130->hpload_dc[ch]); +} + +static ssize_t cs43130_show_dc_l(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cs43130_show_dc(dev, buf, HP_LEFT); +} + +static ssize_t cs43130_show_dc_r(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cs43130_show_dc(dev, buf, HP_RIGHT); +} + +static u16 const cs43130_ac_freq[CS43130_AC_FREQ] = { + 24, + 43, + 93, + 200, + 431, + 928, + 2000, + 4309, + 9283, + 20000, +}; + +static int cs43130_show_ac(struct device *dev, char *buf, u8 ch) +{ + int i, j = 0, tmp; + struct i2c_client *client = to_i2c_client(dev); + struct cs43130_private *cs43130 = i2c_get_clientdata(client); + + if (cs43130->hpload_done && cs43130->ac_meas) { + for (i = 0; i < ARRAY_SIZE(cs43130_ac_freq); i++) { + tmp = scnprintf(buf + j, PAGE_SIZE - j, "%u\n", + cs43130->hpload_ac[i][ch]); + if (!tmp) + break; + + j += tmp; + } + + return j; + } else { + return scnprintf(buf, PAGE_SIZE, "NO_HPLOAD\n"); + } +} + +static ssize_t cs43130_show_ac_l(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cs43130_show_ac(dev, buf, HP_LEFT); +} + +static ssize_t cs43130_show_ac_r(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cs43130_show_ac(dev, buf, HP_RIGHT); +} + +static DEVICE_ATTR(hpload_dc_l, S_IRUGO, cs43130_show_dc_l, NULL); +static DEVICE_ATTR(hpload_dc_r, S_IRUGO, cs43130_show_dc_r, NULL); +static DEVICE_ATTR(hpload_ac_l, S_IRUGO, cs43130_show_ac_l, NULL); +static DEVICE_ATTR(hpload_ac_r, S_IRUGO, cs43130_show_ac_r, NULL); + +static struct reg_sequence hp_en_cal_seq[] = { + {CS43130_INT_MASK_4, CS43130_INT_MASK_ALL}, + {CS43130_HP_MEAS_LOAD_1, 0}, + {CS43130_HP_MEAS_LOAD_2, 0}, + {CS43130_INT_MASK_4, 0}, + {CS43130_DXD1, 0x99}, + {CS43130_DXD16, 0xBB}, + {CS43130_DXD12, 0x01}, + {CS43130_DXD19, 0xCB}, + {CS43130_DXD17, 0x95}, + {CS43130_DXD18, 0x0B}, + {CS43130_DXD1, 0}, + {CS43130_HP_LOAD_1, 0x80}, +}; + +static struct reg_sequence hp_en_cal_seq2[] = { + {CS43130_INT_MASK_4, CS43130_INT_MASK_ALL}, + {CS43130_HP_MEAS_LOAD_1, 0}, + {CS43130_HP_MEAS_LOAD_2, 0}, + {CS43130_INT_MASK_4, 0}, + {CS43130_HP_LOAD_1, 0x80}, +}; + +static struct reg_sequence hp_dis_cal_seq[] = { + {CS43130_HP_LOAD_1, 0x80}, + {CS43130_DXD1, 0x99}, + {CS43130_DXD12, 0}, + {CS43130_DXD1, 0}, + {CS43130_HP_LOAD_1, 0}, +}; + +static struct reg_sequence hp_dis_cal_seq2[] = { + {CS43130_HP_LOAD_1, 0x80}, + {CS43130_HP_LOAD_1, 0}, +}; + +static struct reg_sequence hp_dc_ch_l_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD19, 0x0A}, + {CS43130_DXD17, 0x93}, + {CS43130_DXD18, 0x0A}, + {CS43130_DXD1, 0}, + {CS43130_HP_LOAD_1, 0x80}, + {CS43130_HP_LOAD_1, 0x81}, +}; + +static struct reg_sequence hp_dc_ch_l_seq2[] = { + {CS43130_HP_LOAD_1, 0x80}, + {CS43130_HP_LOAD_1, 0x81}, +}; + +static struct reg_sequence hp_dc_ch_r_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD19, 0x8A}, + {CS43130_DXD17, 0x15}, + {CS43130_DXD18, 0x06}, + {CS43130_DXD1, 0}, + {CS43130_HP_LOAD_1, 0x90}, + {CS43130_HP_LOAD_1, 0x91}, +}; + +static struct reg_sequence hp_dc_ch_r_seq2[] = { + {CS43130_HP_LOAD_1, 0x90}, + {CS43130_HP_LOAD_1, 0x91}, +}; + +static struct reg_sequence hp_ac_ch_l_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD19, 0x0A}, + {CS43130_DXD17, 0x93}, + {CS43130_DXD18, 0x0A}, + {CS43130_DXD1, 0}, + {CS43130_HP_LOAD_1, 0x80}, + {CS43130_HP_LOAD_1, 0x82}, +}; + +static struct reg_sequence hp_ac_ch_l_seq2[] = { + {CS43130_HP_LOAD_1, 0x80}, + {CS43130_HP_LOAD_1, 0x82}, +}; + +static struct reg_sequence hp_ac_ch_r_seq[] = { + {CS43130_DXD1, 0x99}, + {CS43130_DXD19, 0x8A}, + {CS43130_DXD17, 0x15}, + {CS43130_DXD18, 0x06}, + {CS43130_DXD1, 0}, + {CS43130_HP_LOAD_1, 0x90}, + {CS43130_HP_LOAD_1, 0x92}, +}; + +static struct reg_sequence hp_ac_ch_r_seq2[] = { + {CS43130_HP_LOAD_1, 0x90}, + {CS43130_HP_LOAD_1, 0x92}, +}; + +static struct reg_sequence hp_cln_seq[] = { + {CS43130_INT_MASK_4, CS43130_INT_MASK_ALL}, + {CS43130_HP_MEAS_LOAD_1, 0}, + {CS43130_HP_MEAS_LOAD_2, 0}, +}; + +struct reg_sequences { + struct reg_sequence *seq; + int size; + unsigned int msk; +}; + +static struct reg_sequences hpload_seq1[] = { + { + .seq = hp_en_cal_seq, + .size = ARRAY_SIZE(hp_en_cal_seq), + .msk = CS43130_HPLOAD_ON_INT, + }, + { + .seq = hp_dc_ch_l_seq, + .size = ARRAY_SIZE(hp_dc_ch_l_seq), + .msk = CS43130_HPLOAD_DC_INT, + }, + { + .seq = hp_ac_ch_l_seq, + .size = ARRAY_SIZE(hp_ac_ch_l_seq), + .msk = CS43130_HPLOAD_AC_INT, + }, + { + .seq = hp_dis_cal_seq, + .size = ARRAY_SIZE(hp_dis_cal_seq), + .msk = CS43130_HPLOAD_OFF_INT, + }, + { + .seq = hp_en_cal_seq, + .size = ARRAY_SIZE(hp_en_cal_seq), + .msk = CS43130_HPLOAD_ON_INT, + }, + { + .seq = hp_dc_ch_r_seq, + .size = ARRAY_SIZE(hp_dc_ch_r_seq), + .msk = CS43130_HPLOAD_DC_INT, + }, + { + .seq = hp_ac_ch_r_seq, + .size = ARRAY_SIZE(hp_ac_ch_r_seq), + .msk = CS43130_HPLOAD_AC_INT, + }, +}; + +static struct reg_sequences hpload_seq2[] = { + { + .seq = hp_en_cal_seq2, + .size = ARRAY_SIZE(hp_en_cal_seq2), + .msk = CS43130_HPLOAD_ON_INT, + }, + { + .seq = hp_dc_ch_l_seq2, + .size = ARRAY_SIZE(hp_dc_ch_l_seq2), + .msk = CS43130_HPLOAD_DC_INT, + }, + { + .seq = hp_ac_ch_l_seq2, + .size = ARRAY_SIZE(hp_ac_ch_l_seq2), + .msk = CS43130_HPLOAD_AC_INT, + }, + { + .seq = hp_dis_cal_seq2, + .size = ARRAY_SIZE(hp_dis_cal_seq2), + .msk = CS43130_HPLOAD_OFF_INT, + }, + { + .seq = hp_en_cal_seq2, + .size = ARRAY_SIZE(hp_en_cal_seq2), + .msk = CS43130_HPLOAD_ON_INT, + }, + { + .seq = hp_dc_ch_r_seq2, + .size = ARRAY_SIZE(hp_dc_ch_r_seq2), + .msk = CS43130_HPLOAD_DC_INT, + }, + { + .seq = hp_ac_ch_r_seq2, + .size = ARRAY_SIZE(hp_ac_ch_r_seq2), + .msk = CS43130_HPLOAD_AC_INT, + }, +}; + +static int cs43130_update_hpload(unsigned int msk, int ac_idx, + struct cs43130_private *cs43130) +{ + bool left_ch = true; + unsigned int reg; + u32 addr; + u16 impedance; + struct snd_soc_codec *codec = cs43130->codec; + + switch (msk) { + case CS43130_HPLOAD_DC_INT: + case CS43130_HPLOAD_AC_INT: + break; + default: + return 0; + } + + regmap_read(cs43130->regmap, CS43130_HP_LOAD_1, ®); + if (reg & CS43130_HPLOAD_CHN_SEL) + left_ch = false; + + if (msk == CS43130_HPLOAD_DC_INT) + addr = CS43130_HP_DC_STAT_1; + else + addr = CS43130_HP_AC_STAT_1; + + regmap_read(cs43130->regmap, addr, ®); + impedance = reg >> 3; + regmap_read(cs43130->regmap, addr + 1, ®); + impedance |= reg << 5; + + if (msk == CS43130_HPLOAD_DC_INT) { + if (left_ch) + cs43130->hpload_dc[HP_LEFT] = impedance; + else + cs43130->hpload_dc[HP_RIGHT] = impedance; + + dev_dbg(codec->dev, "HP DC impedance (Ch %u): %u\n", !left_ch, + impedance); + } else { + if (left_ch) + cs43130->hpload_ac[ac_idx][HP_LEFT] = impedance; + else + cs43130->hpload_ac[ac_idx][HP_RIGHT] = impedance; + + dev_dbg(codec->dev, "HP AC (%u Hz) impedance (Ch %u): %u\n", + cs43130->ac_freq[ac_idx], !left_ch, impedance); + } + + return 0; +} + +static int cs43130_hpload_proc(struct cs43130_private *cs43130, + struct reg_sequence *seq, int seq_size, + unsigned int rslt_msk, int ac_idx) +{ + int ret; + unsigned int msk; + u16 ac_reg_val; + struct snd_soc_codec *codec = cs43130->codec; + + reinit_completion(&cs43130->hpload_evt); + + if (rslt_msk == CS43130_HPLOAD_AC_INT) { + ac_reg_val = cs43130_get_ac_reg_val(cs43130->ac_freq[ac_idx]); + regmap_update_bits(cs43130->regmap, CS43130_HP_LOAD_1, + CS43130_HPLOAD_AC_START, 0); + regmap_update_bits(cs43130->regmap, CS43130_HP_MEAS_LOAD_1, + CS43130_HP_MEAS_LOAD_MASK, + ac_reg_val >> CS43130_HP_MEAS_LOAD_1_SHIFT); + regmap_update_bits(cs43130->regmap, CS43130_HP_MEAS_LOAD_2, + CS43130_HP_MEAS_LOAD_MASK, + ac_reg_val >> CS43130_HP_MEAS_LOAD_2_SHIFT); + } + + regmap_multi_reg_write(cs43130->regmap, seq, + seq_size); + + ret = wait_for_completion_timeout(&cs43130->hpload_evt, + msecs_to_jiffies(1000)); + regmap_read(cs43130->regmap, CS43130_INT_MASK_4, &msk); + if (!ret) { + dev_err(codec->dev, "Timeout waiting for HPLOAD interrupt\n"); + return -1; + } + + dev_dbg(codec->dev, "HP load stat: %x, INT_MASK_4: %x\n", + cs43130->hpload_stat, msk); + if ((cs43130->hpload_stat & (CS43130_HPLOAD_NO_DC_INT | + CS43130_HPLOAD_UNPLUG_INT | + CS43130_HPLOAD_OOR_INT)) || + !(cs43130->hpload_stat & rslt_msk)) { + dev_dbg(codec->dev, "HP load measure failed\n"); + return -1; + } + + return 0; +} + +static const struct reg_sequence hv_seq[][2] = { + { + {CS43130_CLASS_H_CTL, 0x1C}, + {CS43130_HP_OUT_CTL_1, 0x10}, + }, + { + {CS43130_CLASS_H_CTL, 0x1E}, + {CS43130_HP_OUT_CTL_1, 0x20}, + }, + { + {CS43130_CLASS_H_CTL, 0x1E}, + {CS43130_HP_OUT_CTL_1, 0x30}, + }, +}; + +static int cs43130_set_hv(struct regmap *regmap, u16 hpload_dc, + const u16 *dc_threshold) +{ + int i; + + for (i = 0; i < CS43130_DC_THRESHOLD; i++) { + if (hpload_dc <= dc_threshold[i]) + break; + } + + regmap_multi_reg_write(regmap, hv_seq[i], ARRAY_SIZE(hv_seq[i])); + + return 0; +} + +static void cs43130_imp_meas(struct work_struct *wk) +{ + unsigned int reg, seq_size; + int i, ret, ac_idx; + struct cs43130_private *cs43130; + struct snd_soc_codec *codec; + struct reg_sequences *hpload_seq; + + cs43130 = container_of(wk, struct cs43130_private, work); + codec = cs43130->codec; + + if (!cs43130->mclk) + return; + + cs43130->hpload_done = false; + + mutex_lock(&cs43130->clk_mutex); + if (!cs43130->clk_req) { + /* clk not in use */ + cs43130_set_pll(codec, 0, 0, cs43130->mclk, CS43130_MCLK_22M); + if (cs43130->pll_bypass) + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_EXT); + else + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_PLL); + } + + cs43130->clk_req++; + mutex_unlock(&cs43130->clk_mutex); + + regmap_read(cs43130->regmap, CS43130_INT_STATUS_4, ®); + + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + hpload_seq = hpload_seq1; + seq_size = ARRAY_SIZE(hpload_seq1); + break; + case CS43131_CHIP_ID: + hpload_seq = hpload_seq2; + seq_size = ARRAY_SIZE(hpload_seq2); + } + + i = 0; + ac_idx = 0; + while (i < seq_size) { + ret = cs43130_hpload_proc(cs43130, hpload_seq[i].seq, + hpload_seq[i].size, + hpload_seq[i].msk, ac_idx); + if (ret < 0) + goto exit; + + cs43130_update_hpload(hpload_seq[i].msk, ac_idx, cs43130); + + if (cs43130->ac_meas && + hpload_seq[i].msk == CS43130_HPLOAD_AC_INT && + ac_idx < CS43130_AC_FREQ - 1) { + ac_idx++; + } else { + ac_idx = 0; + i++; + } + } + cs43130->hpload_done = true; + + if (cs43130->hpload_dc[HP_LEFT] >= CS43130_LINEOUT_LOAD) + snd_soc_jack_report(&cs43130->jack, CS43130_JACK_LINEOUT, + CS43130_JACK_MASK); + else + snd_soc_jack_report(&cs43130->jack, CS43130_JACK_HEADPHONE, + CS43130_JACK_MASK); + + dev_dbg(codec->dev, "Set HP output control. DC threshold\n"); + for (i = 0; i < CS43130_DC_THRESHOLD; i++) + dev_dbg(codec->dev, "DC threshold[%d]: %u.\n", i, + cs43130->dc_threshold[i]); + + cs43130_set_hv(cs43130->regmap, cs43130->hpload_dc[HP_LEFT], + cs43130->dc_threshold); + +exit: + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + cs43130_hpload_proc(cs43130, hp_dis_cal_seq, + ARRAY_SIZE(hp_dis_cal_seq), + CS43130_HPLOAD_OFF_INT, ac_idx); + break; + case CS43131_CHIP_ID: + cs43130_hpload_proc(cs43130, hp_dis_cal_seq2, + ARRAY_SIZE(hp_dis_cal_seq2), + CS43130_HPLOAD_OFF_INT, ac_idx); + } + + regmap_multi_reg_write(cs43130->regmap, hp_cln_seq, + ARRAY_SIZE(hp_cln_seq)); + + mutex_lock(&cs43130->clk_mutex); + cs43130->clk_req--; + /* clk not in use */ + if (!cs43130->clk_req) + cs43130_change_clksrc(codec, CS43130_MCLK_SRC_RCO); + mutex_unlock(&cs43130->clk_mutex); +} + +static irqreturn_t cs43130_irq_thread(int irq, void *data) +{ + struct cs43130_private *cs43130 = (struct cs43130_private *)data; + struct snd_soc_codec *codec = cs43130->codec; + unsigned int stickies[CS43130_NUM_INT]; + unsigned int irq_occurrance = 0; + unsigned int masks[CS43130_NUM_INT]; + int i, j; + + for (i = 0; i < ARRAY_SIZE(stickies); i++) { + regmap_read(cs43130->regmap, CS43130_INT_STATUS_1 + i, + &stickies[i]); + regmap_read(cs43130->regmap, CS43130_INT_MASK_1 + i, + &masks[i]); + } + + for (i = 0; i < ARRAY_SIZE(stickies); i++) { + stickies[i] = stickies[i] & (~masks[i]); + for (j = 0; j < 8; j++) + irq_occurrance += (stickies[i] >> j) & 1; + } + dev_dbg(codec->dev, "number of interrupts occurred (%u)\n", + irq_occurrance); + + if (!irq_occurrance) + return IRQ_NONE; + + if (stickies[0] & CS43130_XTAL_RDY_INT) { + complete(&cs43130->xtal_rdy); + return IRQ_HANDLED; + } + + if (stickies[0] & CS43130_PLL_RDY_INT) { + complete(&cs43130->pll_rdy); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_NO_DC_INT) { + cs43130->hpload_stat = stickies[3]; + dev_err(codec->dev, + "DC load has not completed before AC load (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_UNPLUG_INT) { + cs43130->hpload_stat = stickies[3]; + dev_err(codec->dev, "HP unplugged during measurement (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_OOR_INT) { + cs43130->hpload_stat = stickies[3]; + dev_err(codec->dev, "HP load out of range (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_AC_INT) { + cs43130->hpload_stat = stickies[3]; + dev_dbg(codec->dev, "HP AC load measurement done (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_DC_INT) { + cs43130->hpload_stat = stickies[3]; + dev_dbg(codec->dev, "HP DC load measurement done (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_ON_INT) { + cs43130->hpload_stat = stickies[3]; + dev_dbg(codec->dev, "HP load state machine on done (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[3] & CS43130_HPLOAD_OFF_INT) { + cs43130->hpload_stat = stickies[3]; + dev_dbg(codec->dev, "HP load state machine off done (%x)\n", + cs43130->hpload_stat); + complete(&cs43130->hpload_evt); + return IRQ_HANDLED; + } + + if (stickies[0] & CS43130_XTAL_ERR_INT) { + dev_err(codec->dev, "Crystal err: clock is not running\n"); + return IRQ_HANDLED; + } + + if (stickies[0] & CS43130_HP_UNPLUG_INT) { + dev_dbg(codec->dev, "HP unplugged\n"); + cs43130->hpload_done = false; + snd_soc_jack_report(&cs43130->jack, 0, CS43130_JACK_MASK); + return IRQ_HANDLED; + } + + if (stickies[0] & CS43130_HP_PLUG_INT) { + if (cs43130->dc_meas && !cs43130->hpload_done && + !work_busy(&cs43130->work)) { + dev_dbg(codec->dev, "HP load queue work\n"); + queue_work(cs43130->wq, &cs43130->work); + } + + snd_soc_jack_report(&cs43130->jack, SND_JACK_MECHANICAL, + CS43130_JACK_MASK); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int cs43130_probe(struct snd_soc_codec *codec) +{ + int ret; + struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_card *card = codec->component.card; + unsigned int reg; + + cs43130->codec = codec; + + if (cs43130->xtal_ibias != CS43130_XTAL_UNUSED) { + regmap_update_bits(cs43130->regmap, CS43130_CRYSTAL_SET, + CS43130_XTAL_IBIAS_MASK, + cs43130->xtal_ibias); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_ERR_INT, 0); + } + + ret = snd_soc_card_jack_new(card, "Headphone", CS43130_JACK_MASK, + &cs43130->jack, NULL, 0); + if (ret < 0) { + dev_err(codec->dev, "Cannot create jack\n"); + return ret; + } + + cs43130->hpload_done = false; + if (cs43130->dc_meas) { + ret = device_create_file(codec->dev, &dev_attr_hpload_dc_l); + if (ret < 0) + return ret; + + ret = device_create_file(codec->dev, &dev_attr_hpload_dc_r); + if (ret < 0) + return ret; + + ret = device_create_file(codec->dev, &dev_attr_hpload_ac_l); + if (ret < 0) + return ret; + + ret = device_create_file(codec->dev, &dev_attr_hpload_ac_r); + if (ret < 0) + return ret; + + cs43130->wq = create_singlethread_workqueue("cs43130_hp"); + INIT_WORK(&cs43130->work, cs43130_imp_meas); + } + + regmap_read(cs43130->regmap, CS43130_INT_STATUS_1, ®); + regmap_read(cs43130->regmap, CS43130_HP_STATUS, ®); + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_HP_PLUG_INT | CS43130_HP_UNPLUG_INT, 0); + regmap_update_bits(cs43130->regmap, CS43130_HP_DETECT, + CS43130_HP_DETECT_CTRL_MASK, 0); + regmap_update_bits(cs43130->regmap, CS43130_HP_DETECT, + CS43130_HP_DETECT_CTRL_MASK, + CS43130_HP_DETECT_CTRL_MASK); + + return 0; +} + +static struct snd_soc_codec_driver soc_codec_dev_cs43130 = { + .probe = cs43130_probe, + .component_driver = { + .controls = cs43130_snd_controls, + .num_controls = ARRAY_SIZE(cs43130_snd_controls), + }, + .set_sysclk = cs43130_codec_set_sysclk, + .set_pll = cs43130_set_pll, +}; + +static const struct regmap_config cs43130_regmap = { + .reg_bits = 24, + .pad_bits = 8, + .val_bits = 8, + + .max_register = CS43130_LASTREG, + .reg_defaults = cs43130_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(cs43130_reg_defaults), + .readable_reg = cs43130_readable_register, + .precious_reg = cs43130_precious_register, + .volatile_reg = cs43130_volatile_register, + .cache_type = REGCACHE_RBTREE, + .use_single_rw = true, /* needed for regcache_sync */ +}; + +static u16 const cs43130_dc_threshold[CS43130_DC_THRESHOLD] = { + 50, + 120, +}; + +static int cs43130_handle_device_data(struct i2c_client *i2c_client, + struct cs43130_private *cs43130) +{ + struct device_node *np = i2c_client->dev.of_node; + unsigned int val; + int i; + + if (of_property_read_u32(np, "cirrus,xtal-ibias", &val) < 0) { + /* Crystal is unused. System clock is used for external MCLK */ + cs43130->xtal_ibias = CS43130_XTAL_UNUSED; + return 0; + } + + switch (val) { + case 1: + cs43130->xtal_ibias = CS43130_XTAL_IBIAS_7_5UA; + break; + case 2: + cs43130->xtal_ibias = CS43130_XTAL_IBIAS_12_5UA; + break; + case 3: + cs43130->xtal_ibias = CS43130_XTAL_IBIAS_15UA; + break; + default: + dev_err(&i2c_client->dev, + "Invalid cirrus,xtal-ibias value: %d\n", val); + return -EINVAL; + } + + cs43130->dc_meas = of_property_read_bool(np, "cirrus,dc-measure"); + cs43130->ac_meas = of_property_read_bool(np, "cirrus,ac-measure"); + + if (of_property_read_u16_array(np, "cirrus,ac-freq", cs43130->ac_freq, + CS43130_AC_FREQ) < 0) { + for (i = 0; i < CS43130_AC_FREQ; i++) + cs43130->ac_freq[i] = cs43130_ac_freq[i]; + } + + if (of_property_read_u16_array(np, "cirrus,dc-threshold", + cs43130->dc_threshold, + CS43130_DC_THRESHOLD) < 0) { + for (i = 0; i < CS43130_DC_THRESHOLD; i++) + cs43130->dc_threshold[i] = cs43130_dc_threshold[i]; + } + + return 0; +} + +static int cs43130_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct cs43130_private *cs43130; + int ret; + unsigned int devid = 0; + unsigned int reg; + int i; + + cs43130 = devm_kzalloc(&client->dev, sizeof(*cs43130), GFP_KERNEL); + if (!cs43130) + return -ENOMEM; + + i2c_set_clientdata(client, cs43130); + + cs43130->regmap = devm_regmap_init_i2c(client, &cs43130_regmap); + if (IS_ERR(cs43130->regmap)) { + ret = PTR_ERR(cs43130->regmap); + return ret; + } + + if (client->dev.of_node) { + ret = cs43130_handle_device_data(client, cs43130); + if (ret != 0) + return ret; + } + for (i = 0; i < ARRAY_SIZE(cs43130->supplies); i++) + cs43130->supplies[i].supply = cs43130_supply_names[i]; + + ret = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(cs43130->supplies), + cs43130->supplies); + if (ret != 0) { + dev_err(&client->dev, "Failed to request supplies: %d\n", ret); + return ret; + } + ret = regulator_bulk_enable(ARRAY_SIZE(cs43130->supplies), + cs43130->supplies); + if (ret != 0) { + dev_err(&client->dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + + cs43130->reset_gpio = devm_gpiod_get_optional(&client->dev, + "reset", GPIOD_OUT_LOW); + if (IS_ERR(cs43130->reset_gpio)) + return PTR_ERR(cs43130->reset_gpio); + + gpiod_set_value_cansleep(cs43130->reset_gpio, 1); + + usleep_range(2000, 2050); + + ret = regmap_read(cs43130->regmap, CS43130_DEVID_AB, ®); + + devid = (reg & 0xFF) << 12; + ret = regmap_read(cs43130->regmap, CS43130_DEVID_CD, ®); + devid |= (reg & 0xFF) << 4; + ret = regmap_read(cs43130->regmap, CS43130_DEVID_E, ®); + devid |= (reg & 0xF0) >> 4; + + switch (devid) { + case CS43130_CHIP_ID: + case CS4399_CHIP_ID: + case CS43131_CHIP_ID: + case CS43198_CHIP_ID: + break; + default: + dev_err(&client->dev, + "CS43130 Device ID %X. Expected ID %X, %X, %X or %X\n", + devid, CS43130_CHIP_ID, CS4399_CHIP_ID, + CS43131_CHIP_ID, CS43198_CHIP_ID); + ret = -ENODEV; + goto err; + } + + cs43130->dev_id = devid; + ret = regmap_read(cs43130->regmap, CS43130_REV_ID, ®); + if (ret < 0) { + dev_err(&client->dev, "Get Revision ID failed\n"); + goto err; + } + + dev_info(&client->dev, + "Cirrus Logic CS43130 (%x), Revision: %02X\n", devid, + reg & 0xFF); + + mutex_init(&cs43130->clk_mutex); + + init_completion(&cs43130->xtal_rdy); + init_completion(&cs43130->pll_rdy); + init_completion(&cs43130->hpload_evt); + + ret = devm_request_threaded_irq(&client->dev, client->irq, + NULL, cs43130_irq_thread, + IRQF_ONESHOT | IRQF_TRIGGER_LOW, + "cs43130", cs43130); + if (ret != 0) { + dev_err(&client->dev, "Failed to request IRQ: %d\n", ret); + return ret; + } + + cs43130->mclk_int_src = CS43130_MCLK_SRC_RCO; + + pm_runtime_set_autosuspend_delay(&client->dev, 100); + pm_runtime_use_autosuspend(&client->dev); + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + + switch (cs43130->dev_id) { + case CS43130_CHIP_ID: + case CS43131_CHIP_ID: + memcpy(all_hp_widgets, digital_hp_widgets, + sizeof(digital_hp_widgets)); + memcpy(all_hp_widgets + ARRAY_SIZE(digital_hp_widgets), + analog_hp_widgets, sizeof(analog_hp_widgets)); + memcpy(all_hp_routes, digital_hp_routes, + sizeof(digital_hp_routes)); + memcpy(all_hp_routes + ARRAY_SIZE(digital_hp_routes), + analog_hp_routes, sizeof(analog_hp_routes)); + + soc_codec_dev_cs43130.component_driver.dapm_widgets = + all_hp_widgets; + soc_codec_dev_cs43130.component_driver.num_dapm_widgets = + ARRAY_SIZE(all_hp_widgets); + soc_codec_dev_cs43130.component_driver.dapm_routes = + all_hp_routes; + soc_codec_dev_cs43130.component_driver.num_dapm_routes = + ARRAY_SIZE(all_hp_routes); + break; + case CS43198_CHIP_ID: + case CS4399_CHIP_ID: + soc_codec_dev_cs43130.component_driver.dapm_widgets = + digital_hp_widgets; + soc_codec_dev_cs43130.component_driver.num_dapm_widgets = + ARRAY_SIZE(digital_hp_widgets); + soc_codec_dev_cs43130.component_driver.dapm_routes = + digital_hp_routes; + soc_codec_dev_cs43130.component_driver.num_dapm_routes = + ARRAY_SIZE(digital_hp_routes); + } + + ret = snd_soc_register_codec(&client->dev, &soc_codec_dev_cs43130, + cs43130_dai, ARRAY_SIZE(cs43130_dai)); + if (ret < 0) { + dev_err(&client->dev, + "snd_soc_register_codec failed with ret = %d\n", ret); + goto err; + } + + regmap_update_bits(cs43130->regmap, CS43130_PAD_INT_CFG, + CS43130_ASP_3ST_MASK, 0); + regmap_update_bits(cs43130->regmap, CS43130_PAD_INT_CFG, + CS43130_XSP_3ST_MASK, 0); + + return 0; +err: + return ret; +} + +static int cs43130_i2c_remove(struct i2c_client *client) +{ + struct cs43130_private *cs43130 = i2c_get_clientdata(client); + + if (cs43130->xtal_ibias != CS43130_XTAL_UNUSED) + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_ERR_INT, + 1 << CS43130_XTAL_ERR_INT_SHIFT); + + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_HP_PLUG_INT | CS43130_HP_UNPLUG_INT, + CS43130_HP_PLUG_INT | CS43130_HP_UNPLUG_INT); + + if (cs43130->dc_meas) { + cancel_work_sync(&cs43130->work); + flush_workqueue(cs43130->wq); + + device_remove_file(&client->dev, &dev_attr_hpload_dc_l); + device_remove_file(&client->dev, &dev_attr_hpload_dc_r); + device_remove_file(&client->dev, &dev_attr_hpload_ac_l); + device_remove_file(&client->dev, &dev_attr_hpload_ac_r); + } + + if (cs43130->reset_gpio) + gpiod_set_value_cansleep(cs43130->reset_gpio, 0); + + pm_runtime_disable(&client->dev); + regulator_bulk_disable(CS43130_NUM_SUPPLIES, cs43130->supplies); + + snd_soc_unregister_codec(&client->dev); + + return 0; +} + +static int cs43130_runtime_suspend(struct device *dev) +{ + struct cs43130_private *cs43130 = dev_get_drvdata(dev); + + if (cs43130->xtal_ibias != CS43130_XTAL_UNUSED) + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_ERR_INT, + 1 << CS43130_XTAL_ERR_INT_SHIFT); + + regcache_cache_only(cs43130->regmap, true); + regcache_mark_dirty(cs43130->regmap); + + gpiod_set_value_cansleep(cs43130->reset_gpio, 0); + + regulator_bulk_disable(CS43130_NUM_SUPPLIES, cs43130->supplies); + + return 0; +} + +static int cs43130_runtime_resume(struct device *dev) +{ + struct cs43130_private *cs43130 = dev_get_drvdata(dev); + int ret; + + ret = regulator_bulk_enable(CS43130_NUM_SUPPLIES, cs43130->supplies); + if (ret != 0) { + dev_err(dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + + regcache_cache_only(cs43130->regmap, false); + + gpiod_set_value_cansleep(cs43130->reset_gpio, 1); + + usleep_range(2000, 2050); + + ret = regcache_sync(cs43130->regmap); + if (ret != 0) { + dev_err(dev, "Failed to restore register cache\n"); + goto err; + } + + if (cs43130->xtal_ibias != CS43130_XTAL_UNUSED) + regmap_update_bits(cs43130->regmap, CS43130_INT_MASK_1, + CS43130_XTAL_ERR_INT, 0); + + return 0; +err: + regcache_cache_only(cs43130->regmap, true); + regulator_bulk_disable(CS43130_NUM_SUPPLIES, cs43130->supplies); + + return ret; +} + +static const struct dev_pm_ops cs43130_runtime_pm = { + SET_RUNTIME_PM_OPS(cs43130_runtime_suspend, cs43130_runtime_resume, + NULL) +}; + +static const struct of_device_id cs43130_of_match[] = { + {.compatible = "cirrus,cs43130",}, + {.compatible = "cirrus,cs4399",}, + {.compatible = "cirrus,cs43131",}, + {.compatible = "cirrus,cs43198",}, + {}, +}; + +MODULE_DEVICE_TABLE(of, cs43130_of_match); + +static const struct i2c_device_id cs43130_i2c_id[] = { + {"cs43130", 0}, + {"cs4399", 0}, + {"cs43131", 0}, + {"cs43198", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, cs43130_i2c_id); + +static struct i2c_driver cs43130_i2c_driver = { + .driver = { + .name = "cs43130", + .of_match_table = cs43130_of_match, + .pm = &cs43130_runtime_pm, + }, + .id_table = cs43130_i2c_id, + .probe = cs43130_i2c_probe, + .remove = cs43130_i2c_remove, +}; + +module_i2c_driver(cs43130_i2c_driver); + +MODULE_AUTHOR("Li Xu "); +MODULE_DESCRIPTION("Cirrus Logic CS43130 ALSA SoC Codec Driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/cs43130.h b/sound/soc/codecs/cs43130.h new file mode 100644 index 0000000..7812584 --- /dev/null +++ b/sound/soc/codecs/cs43130.h @@ -0,0 +1,546 @@ +/* + * ALSA SoC CS43130 codec driver + * + * Copyright 2017 Cirrus Logic, Inc. + * + * Author: Li Xu + * + * 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. + * + * 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 __CS43130_H__ +#define __CS43130_H__ + +/* CS43130 registers addresses */ +/* all reg address is shifted by a byte for control byte to be LSB */ +#define CS43130_FIRSTREG 0x010000 +#define CS43130_LASTREG 0x190000 +#define CS43130_CHIP_ID 0x00043130 +#define CS4399_CHIP_ID 0x00043990 +#define CS43131_CHIP_ID 0x00043131 +#define CS43198_CHIP_ID 0x00043198 +#define CS43130_DEVID_AB 0x010000 /* Device ID A & B [RO] */ +#define CS43130_DEVID_CD 0x010001 /* Device ID C & D [RO] */ +#define CS43130_DEVID_E 0x010002 /* Device ID E [RO] */ +#define CS43130_FAB_ID 0x010003 /* Fab ID [RO] */ +#define CS43130_REV_ID 0x010004 /* Revision ID [RO] */ +#define CS43130_SUBREV_ID 0x010005 /* Subrevision ID */ +#define CS43130_SYS_CLK_CTL_1 0x010006 /* System Clocking Ctl 1 */ +#define CS43130_SP_SRATE 0x01000B /* Serial Port Sample Rate */ +#define CS43130_SP_BITSIZE 0x01000C /* Serial Port Bit Size */ +#define CS43130_PAD_INT_CFG 0x01000D /* Pad Interface Config */ +#define CS43130_DXD1 0x010010 /* DXD1 */ +#define CS43130_DXD7 0x010025 /* DXD7 */ +#define CS43130_DXD19 0x010026 /* DXD19 */ +#define CS43130_DXD17 0x010027 /* DXD17 */ +#define CS43130_DXD18 0x010028 /* DXD18 */ +#define CS43130_DXD12 0x01002C /* DXD12 */ +#define CS43130_DXD8 0x01002E /* DXD8 */ +#define CS43130_PWDN_CTL 0x020000 /* Power Down Ctl */ +#define CS43130_DXD2 0x020019 /* DXD2 */ +#define CS43130_CRYSTAL_SET 0x020052 /* Crystal Setting */ +#define CS43130_PLL_SET_1 0x030001 /* PLL Setting 1 */ +#define CS43130_PLL_SET_2 0x030002 /* PLL Setting 2 */ +#define CS43130_PLL_SET_3 0x030003 /* PLL Setting 3 */ +#define CS43130_PLL_SET_4 0x030004 /* PLL Setting 4 */ +#define CS43130_PLL_SET_5 0x030005 /* PLL Setting 5 */ +#define CS43130_PLL_SET_6 0x030008 /* PLL Setting 6 */ +#define CS43130_PLL_SET_7 0x03000A /* PLL Setting 7 */ +#define CS43130_PLL_SET_8 0x03001B /* PLL Setting 8 */ +#define CS43130_PLL_SET_9 0x040002 /* PLL Setting 9 */ +#define CS43130_PLL_SET_10 0x040003 /* PLL Setting 10 */ +#define CS43130_CLKOUT_CTL 0x040004 /* CLKOUT Ctl */ +#define CS43130_ASP_NUM_1 0x040010 /* ASP Numerator 1 */ +#define CS43130_ASP_NUM_2 0x040011 /* ASP Numerator 2 */ +#define CS43130_ASP_DEN_1 0x040012 /* ASP Denominator 1 */ +#define CS43130_ASP_DEN_2 0x040013 /* ASP Denominator 2 */ +#define CS43130_ASP_LRCK_HI_TIME_1 0x040014 /* ASP LRCK High Time 1 */ +#define CS43130_ASP_LRCK_HI_TIME_2 0x040015 /* ASP LRCK High Time 2 */ +#define CS43130_ASP_LRCK_PERIOD_1 0x040016 /* ASP LRCK Period 1 */ +#define CS43130_ASP_LRCK_PERIOD_2 0x040017 /* ASP LRCK Period 2 */ +#define CS43130_ASP_CLOCK_CONF 0x040018 /* ASP Clock Config */ +#define CS43130_ASP_FRAME_CONF 0x040019 /* ASP Frame Config */ +#define CS43130_XSP_NUM_1 0x040020 /* XSP Numerator 1 */ +#define CS43130_XSP_NUM_2 0x040021 /* XSP Numerator 2 */ +#define CS43130_XSP_DEN_1 0x040022 /* XSP Denominator 1 */ +#define CS43130_XSP_DEN_2 0x040023 /* XSP Denominator 2 */ +#define CS43130_XSP_LRCK_HI_TIME_1 0x040024 /* XSP LRCK High Time 1 */ +#define CS43130_XSP_LRCK_HI_TIME_2 0x040025 /* XSP LRCK High Time 2 */ +#define CS43130_XSP_LRCK_PERIOD_1 0x040026 /* XSP LRCK Period 1 */ +#define CS43130_XSP_LRCK_PERIOD_2 0x040027 /* XSP LRCK Period 2 */ +#define CS43130_XSP_CLOCK_CONF 0x040028 /* XSP Clock Config */ +#define CS43130_XSP_FRAME_CONF 0x040029 /* XSP Frame Config */ +#define CS43130_ASP_CH_1_LOC 0x050000 /* ASP Chan 1 Location */ +#define CS43130_ASP_CH_2_LOC 0x050001 /* ASP Chan 2 Location */ +#define CS43130_ASP_CH_1_SZ_EN 0x05000A /* ASP Chan 1 Size, Enable */ +#define CS43130_ASP_CH_2_SZ_EN 0x05000B /* ASP Chan 2 Size, Enable */ +#define CS43130_XSP_CH_1_LOC 0x060000 /* XSP Chan 1 Location */ +#define CS43130_XSP_CH_2_LOC 0x060001 /* XSP Chan 2 Location */ +#define CS43130_XSP_CH_1_SZ_EN 0x06000A /* XSP Chan 1 Size, Enable */ +#define CS43130_XSP_CH_2_SZ_EN 0x06000B /* XSP Chan 2 Size, Enable */ +#define CS43130_DSD_VOL_B 0x070000 /* DSD Volume B */ +#define CS43130_DSD_VOL_A 0x070001 /* DSD Volume A */ +#define CS43130_DSD_PATH_CTL_1 0x070002 /* DSD Proc Path Sig Ctl 1 */ +#define CS43130_DSD_INT_CFG 0x070003 /* DSD Interface Config */ +#define CS43130_DSD_PATH_CTL_2 0x070004 /* DSD Proc Path Sig Ctl 2 */ +#define CS43130_DSD_PCM_MIX_CTL 0x070005 /* DSD and PCM Mixing Ctl */ +#define CS43130_DSD_PATH_CTL_3 0x070006 /* DSD Proc Path Sig Ctl 3 */ +#define CS43130_HP_OUT_CTL_1 0x080000 /* HP Output Ctl 1 */ +#define CS43130_DXD16 0x080024 /* DXD16 */ +#define CS43130_DXD13 0x080032 /* DXD13 */ +#define CS43130_PCM_FILT_OPT 0x090000 /* PCM Filter Option */ +#define CS43130_PCM_VOL_B 0x090001 /* PCM Volume B */ +#define CS43130_PCM_VOL_A 0x090002 /* PCM Volume A */ +#define CS43130_PCM_PATH_CTL_1 0x090003 /* PCM Path Signal Ctl 1 */ +#define CS43130_PCM_PATH_CTL_2 0x090004 /* PCM Path Signal Ctl 2 */ +#define CS43130_DXD6 0x090097 /* DXD6 */ +#define CS43130_CLASS_H_CTL 0x0B0000 /* Class H Ctl */ +#define CS43130_DXD15 0x0B0005 /* DXD15 */ +#define CS43130_DXD14 0x0B0006 /* DXD14 */ +#define CS43130_DXD3 0x0C0002 /* DXD3 */ +#define CS43130_DXD10 0x0C0003 /* DXD10 */ +#define CS43130_DXD11 0x0C0005 /* DXD11 */ +#define CS43130_DXD9 0x0C0006 /* DXD9 */ +#define CS43130_DXD4 0x0C0009 /* DXD4 */ +#define CS43130_DXD5 0x0C000E /* DXD5 */ +#define CS43130_HP_DETECT 0x0D0000 /* HP Detect */ +#define CS43130_HP_STATUS 0x0D0001 /* HP Status [RO] */ +#define CS43130_HP_LOAD_1 0x0E0000 /* HP Load 1 */ +#define CS43130_HP_MEAS_LOAD_1 0x0E0003 /* HP Load Measurement 1 */ +#define CS43130_HP_MEAS_LOAD_2 0x0E0004 /* HP Load Measurement 2 */ +#define CS43130_HP_DC_STAT_1 0x0E000D /* HP DC Load Status 0 [RO] */ +#define CS43130_HP_DC_STAT_2 0x0E000E /* HP DC Load Status 1 [RO] */ +#define CS43130_HP_AC_STAT_1 0x0E0010 /* HP AC Load Status 0 [RO] */ +#define CS43130_HP_AC_STAT_2 0x0E0011 /* HP AC Load Status 1 [RO] */ +#define CS43130_HP_LOAD_STAT 0x0E001A /* HP Load Status [RO] */ +#define CS43130_INT_STATUS_1 0x0F0000 /* Interrupt Status 1 */ +#define CS43130_INT_STATUS_2 0x0F0001 /* Interrupt Status 2 */ +#define CS43130_INT_STATUS_3 0x0F0002 /* Interrupt Status 3 */ +#define CS43130_INT_STATUS_4 0x0F0003 /* Interrupt Status 4 */ +#define CS43130_INT_STATUS_5 0x0F0004 /* Interrupt Status 5 */ +#define CS43130_INT_MASK_1 0x0F0010 /* Interrupt Mask 1 */ +#define CS43130_INT_MASK_2 0x0F0011 /* Interrupt Mask 2 */ +#define CS43130_INT_MASK_3 0x0F0012 /* Interrupt Mask 3 */ +#define CS43130_INT_MASK_4 0x0F0013 /* Interrupt Mask 4 */ +#define CS43130_INT_MASK_5 0x0F0014 /* Interrupt Mask 5 */ + +#define CS43130_MCLK_SRC_SEL_MASK 0x03 +#define CS43130_MCLK_SRC_SEL_SHIFT 0 +#define CS43130_MCLK_INT_MASK 0x04 +#define CS43130_MCLK_INT_SHIFT 2 +#define CS43130_CH_BITSIZE_MASK 0x03 +#define CS43130_CH_EN_MASK 0x04 +#define CS43130_CH_EN_SHIFT 2 +#define CS43130_ASP_BITSIZE_MASK 0x03 +#define CS43130_XSP_BITSIZE_MASK 0x0C +#define CS43130_XSP_BITSIZE_SHIFT 2 +#define CS43130_SP_BITSIZE_ASP_SHIFT 0 +#define CS43130_HP_DETECT_CTRL_SHIFT 6 +#define CS43130_HP_DETECT_CTRL_MASK (0x03 << CS43130_HP_DETECT_CTRL_SHIFT) +#define CS43130_HP_DETECT_INV_SHIFT 5 +#define CS43130_HP_DETECT_INV_MASK (1 << CS43130_HP_DETECT_INV_SHIFT) + +/* CS43130_INT_MASK_1 */ +#define CS43130_HP_PLUG_INT_SHIFT 6 +#define CS43130_HP_PLUG_INT (1 << CS43130_HP_PLUG_INT_SHIFT) +#define CS43130_HP_UNPLUG_INT_SHIFT 5 +#define CS43130_HP_UNPLUG_INT (1 << CS43130_HP_UNPLUG_INT_SHIFT) +#define CS43130_XTAL_RDY_INT_SHIFT 4 +#define CS43130_XTAL_RDY_INT_MASK 0x10 +#define CS43130_XTAL_RDY_INT (1 << CS43130_XTAL_RDY_INT_SHIFT) +#define CS43130_XTAL_ERR_INT_SHIFT 3 +#define CS43130_XTAL_ERR_INT (1 << CS43130_XTAL_ERR_INT_SHIFT) +#define CS43130_PLL_RDY_INT_MASK 0x04 +#define CS43130_PLL_RDY_INT_SHIFT 2 +#define CS43130_PLL_RDY_INT (1 << CS43130_PLL_RDY_INT_SHIFT) + +/* CS43130_INT_MASK_4 */ +#define CS43130_INT_MASK_ALL 0xFF +#define CS43130_HPLOAD_NO_DC_INT_SHIFT 7 +#define CS43130_HPLOAD_NO_DC_INT (1 << CS43130_HPLOAD_NO_DC_INT_SHIFT) +#define CS43130_HPLOAD_UNPLUG_INT_SHIFT 6 +#define CS43130_HPLOAD_UNPLUG_INT (1 << CS43130_HPLOAD_UNPLUG_INT_SHIFT) +#define CS43130_HPLOAD_OOR_INT_SHIFT 4 +#define CS43130_HPLOAD_OOR_INT (1 << CS43130_HPLOAD_OOR_INT_SHIFT) +#define CS43130_HPLOAD_AC_INT_SHIFT 3 +#define CS43130_HPLOAD_AC_INT (1 << CS43130_HPLOAD_AC_INT_SHIFT) +#define CS43130_HPLOAD_DC_INT_SHIFT 2 +#define CS43130_HPLOAD_DC_INT (1 << CS43130_HPLOAD_DC_INT_SHIFT) +#define CS43130_HPLOAD_OFF_INT_SHIFT 1 +#define CS43130_HPLOAD_OFF_INT (1 << CS43130_HPLOAD_OFF_INT_SHIFT) +#define CS43130_HPLOAD_ON_INT 1 + +/* CS43130_HP_LOAD_1 */ +#define CS43130_HPLOAD_EN_SHIFT 7 +#define CS43130_HPLOAD_EN (1 << CS43130_HPLOAD_EN_SHIFT) +#define CS43130_HPLOAD_CHN_SEL_SHIFT 4 +#define CS43130_HPLOAD_CHN_SEL (1 << CS43130_HPLOAD_CHN_SEL_SHIFT) +#define CS43130_HPLOAD_AC_START_SHIFT 1 +#define CS43130_HPLOAD_AC_START (1 << CS43130_HPLOAD_AC_START_SHIFT) +#define CS43130_HPLOAD_DC_START 1 + +/* Reg CS43130_SP_BITSIZE */ +#define CS43130_SP_BIT_SIZE_8 0x03 +#define CS43130_SP_BIT_SIZE_16 0x02 +#define CS43130_SP_BIT_SIZE_24 0x01 +#define CS43130_SP_BIT_SIZE_32 0x00 + +/* Reg CS43130_SP_CH_SZ_EN */ +#define CS43130_CH_BIT_SIZE_8 0x00 +#define CS43130_CH_BIT_SIZE_16 0x01 +#define CS43130_CH_BIT_SIZE_24 0x02 +#define CS43130_CH_BIT_SIZE_32 0x03 + +/* PLL */ +#define CS43130_PLL_START_MASK 0x01 +#define CS43130_PLL_MODE_MASK 0x02 +#define CS43130_PLL_MODE_SHIFT 1 + +#define CS43130_PLL_REF_PREDIV_MASK 0x3 + +#define CS43130_SP_STP_MASK 0x10 +#define CS43130_SP_STP_SHIFT 4 +#define CS43130_SP_5050_MASK 0x08 +#define CS43130_SP_5050_SHIFT 3 +#define CS43130_SP_FSD_MASK 0x07 + +#define CS43130_SP_MODE_MASK 0x10 +#define CS43130_SP_MODE_SHIFT 4 +#define CS43130_SP_SCPOL_OUT_MASK 0x08 +#define CS43130_SP_SCPOL_OUT_SHIFT 3 +#define CS43130_SP_SCPOL_IN_MASK 0x04 +#define CS43130_SP_SCPOL_IN_SHIFT 2 +#define CS43130_SP_LCPOL_OUT_MASK 0x02 +#define CS43130_SP_LCPOL_OUT_SHIFT 1 +#define CS43130_SP_LCPOL_IN_MASK 0x01 +#define CS43130_SP_LCPOL_IN_SHIFT 0 + +/* Reg CS43130_PWDN_CTL */ +#define CS43130_PDN_XSP_MASK 0x80 +#define CS43130_PDN_XSP_SHIFT 7 +#define CS43130_PDN_ASP_MASK 0x40 +#define CS43130_PDN_ASP_SHIFT 6 +#define CS43130_PDN_DSPIF_MASK 0x20 +#define CS43130_PDN_DSDIF_SHIFT 5 +#define CS43130_PDN_HP_MASK 0x10 +#define CS43130_PDN_HP_SHIFT 4 +#define CS43130_PDN_XTAL_MASK 0x08 +#define CS43130_PDN_XTAL_SHIFT 3 +#define CS43130_PDN_PLL_MASK 0x04 +#define CS43130_PDN_PLL_SHIFT 2 +#define CS43130_PDN_CLKOUT_MASK 0x02 +#define CS43130_PDN_CLKOUT_SHIFT 1 + +/* Reg CS43130_HP_OUT_CTL_1 */ +#define CS43130_HP_IN_EN_SHIFT 3 +#define CS43130_HP_IN_EN_MASK 0x08 + +/* Reg CS43130_PAD_INT_CFG */ +#define CS43130_ASP_3ST_MASK 0x01 +#define CS43130_XSP_3ST_MASK 0x02 + +/* Reg CS43130_PLL_SET_2 */ +#define CS43130_PLL_DIV_DATA_MASK 0x000000FF +#define CS43130_PLL_DIV_FRAC_0_DATA_SHIFT 0 + +/* Reg CS43130_PLL_SET_3 */ +#define CS43130_PLL_DIV_FRAC_1_DATA_SHIFT 8 + +/* Reg CS43130_PLL_SET_4 */ +#define CS43130_PLL_DIV_FRAC_2_DATA_SHIFT 16 + +/* Reg CS43130_SP_DEN_1 */ +#define CS43130_SP_M_LSB_DATA_MASK 0x00FF +#define CS43130_SP_M_LSB_DATA_SHIFT 0 + +/* Reg CS43130_SP_DEN_2 */ +#define CS43130_SP_M_MSB_DATA_MASK 0xFF00 +#define CS43130_SP_M_MSB_DATA_SHIFT 8 + +/* Reg CS43130_SP_NUM_1 */ +#define CS43130_SP_N_LSB_DATA_MASK 0x00FF +#define CS43130_SP_N_LSB_DATA_SHIFT 0 + +/* Reg CS43130_SP_NUM_2 */ +#define CS43130_SP_N_MSB_DATA_MASK 0xFF00 +#define CS43130_SP_N_MSB_DATA_SHIFT 8 + +/* Reg CS43130_SP_LRCK_HI_TIME_1 */ +#define CS43130_SP_LCHI_DATA_MASK 0x00FF +#define CS43130_SP_LCHI_LSB_DATA_SHIFT 0 + +/* Reg CS43130_SP_LRCK_HI_TIME_2 */ +#define CS43130_SP_LCHI_MSB_DATA_SHIFT 8 + +/* Reg CS43130_SP_LRCK_PERIOD_1 */ +#define CS43130_SP_LCPR_DATA_MASK 0x00FF +#define CS43130_SP_LCPR_LSB_DATA_SHIFT 0 + +/* Reg CS43130_SP_LRCK_PERIOD_2 */ +#define CS43130_SP_LCPR_MSB_DATA_SHIFT 8 + +#define CS43130_PCM_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ + SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S32_LE) + +#define CS43130_DOP_FORMATS (SNDRV_PCM_FMTBIT_DSD_U16_LE | \ + SNDRV_PCM_FMTBIT_DSD_U16_BE | \ + SNDRV_PCM_FMTBIT_S24_LE) + +/* Reg CS43130_CRYSTAL_SET */ +#define CS43130_XTAL_IBIAS_MASK 0x07 + +/* Reg CS43130_PATH_CTL_1 */ +#define CS43130_MUTE_MASK 0x03 +#define CS43130_MUTE_EN 0x03 + +/* Reg CS43130_DSD_INT_CFG */ +#define CS43130_DSD_MASTER 0x04 + +/* Reg CS43130_DSD_PATH_CTL_2 */ +#define CS43130_DSD_SRC_MASK 0x60 +#define CS43130_DSD_SRC_SHIFT 5 +#define CS43130_DSD_EN_SHIFT 4 +#define CS43130_DSD_SPEED_MASK 0x04 +#define CS43130_DSD_SPEED_SHIFT 2 + +/* Reg CS43130_DSD_PCM_MIX_CTL */ +#define CS43130_MIX_PCM_PREP_SHIFT 1 +#define CS43130_MIX_PCM_PREP_MASK 0x02 + +#define CS43130_MIX_PCM_DSD_SHIFT 0 +#define CS43130_MIX_PCM_DSD_MASK 0x01 + +/* Reg CS43130_HP_MEAS_LOAD */ +#define CS43130_HP_MEAS_LOAD_MASK 0x000000FF +#define CS43130_HP_MEAS_LOAD_1_SHIFT 0 +#define CS43130_HP_MEAS_LOAD_2_SHIFT 8 + +#define CS43130_MCLK_22M 22579200 +#define CS43130_MCLK_24M 24576000 + +#define CS43130_LINEOUT_LOAD 5000 +#define CS43130_JACK_LINEOUT (SND_JACK_MECHANICAL | SND_JACK_LINEOUT) +#define CS43130_JACK_HEADPHONE (SND_JACK_MECHANICAL | \ + SND_JACK_HEADPHONE) +#define CS43130_JACK_MASK (SND_JACK_MECHANICAL | \ + SND_JACK_LINEOUT | \ + SND_JACK_HEADPHONE) + +enum cs43130_dsd_src { + CS43130_DSD_SRC_DSD = 0, + CS43130_DSD_SRC_ASP = 2, + CS43130_DSD_SRC_XSP = 3, +}; + +enum cs43130_asp_rate { + CS43130_ASP_SPRATE_32K = 0, + CS43130_ASP_SPRATE_44_1K, + CS43130_ASP_SPRATE_48K, + CS43130_ASP_SPRATE_88_2K, + CS43130_ASP_SPRATE_96K, + CS43130_ASP_SPRATE_176_4K, + CS43130_ASP_SPRATE_192K, + CS43130_ASP_SPRATE_352_8K, + CS43130_ASP_SPRATE_384K, +}; + +enum cs43130_mclk_src_sel { + CS43130_MCLK_SRC_EXT = 0, + CS43130_MCLK_SRC_PLL, + CS43130_MCLK_SRC_RCO +}; + +enum cs43130_mclk_int_freq { + CS43130_MCLK_24P5 = 0, + CS43130_MCLK_22P5, +}; + +enum cs43130_xtal_ibias { + CS43130_XTAL_UNUSED = -1, + CS43130_XTAL_IBIAS_15UA = 2, + CS43130_XTAL_IBIAS_12_5UA = 4, + CS43130_XTAL_IBIAS_7_5UA = 6, +}; + +enum cs43130_dai_id { + CS43130_ASP_PCM_DAI = 0, + CS43130_ASP_DOP_DAI, + CS43130_XSP_DOP_DAI, + CS43130_XSP_DSD_DAI, + CS43130_DAI_ID_MAX, +}; + +struct cs43130_clk_gen { + unsigned int mclk_int; + int fs; + u16 den; + u16 num; +}; + +/* frm_size = 16 */ +static const struct cs43130_clk_gen cs43130_16_clk_gen[] = { + {22579200, 32000, 441, 10,}, + {22579200, 44100, 32, 1,}, + {22579200, 48000, 147, 5,}, + {22579200, 88200, 16, 1,}, + {22579200, 96000, 147, 10,}, + {22579200, 176400, 8, 1,}, + {22579200, 192000, 147, 20,}, + {22579200, 352800, 4, 1,}, + {22579200, 384000, 147, 40,}, + {24576000, 32000, 48, 1,}, + {24576000, 44100, 5120, 147,}, + {24576000, 48000, 32, 1,}, + {24576000, 88200, 2560, 147,}, + {24576000, 96000, 16, 1,}, + {24576000, 176400, 1280, 147,}, + {24576000, 192000, 8, 1,}, + {24576000, 352800, 640, 147,}, + {24576000, 384000, 4, 1,}, +}; + +/* frm_size = 32 */ +static const struct cs43130_clk_gen cs43130_32_clk_gen[] = { + {22579200, 32000, 441, 20,}, + {22579200, 44100, 16, 1,}, + {22579200, 48000, 147, 10,}, + {22579200, 88200, 8, 1,}, + {22579200, 96000, 147, 20,}, + {22579200, 176400, 4, 1,}, + {22579200, 192000, 147, 40,}, + {22579200, 352800, 2, 1,}, + {22579200, 384000, 147, 80,}, + {24576000, 32000, 24, 1,}, + {24576000, 44100, 2560, 147,}, + {24576000, 48000, 16, 1,}, + {24576000, 88200, 1280, 147,}, + {24576000, 96000, 8, 1,}, + {24576000, 176400, 640, 147,}, + {24576000, 192000, 4, 1,}, + {24576000, 352800, 320, 147,}, + {24576000, 384000, 2, 1,}, +}; + +/* frm_size = 48 */ +static const struct cs43130_clk_gen cs43130_48_clk_gen[] = { + {22579200, 32000, 147, 100,}, + {22579200, 44100, 32, 3,}, + {22579200, 48000, 49, 5,}, + {22579200, 88200, 16, 3,}, + {22579200, 96000, 49, 10,}, + {22579200, 176400, 8, 3,}, + {22579200, 192000, 49, 20,}, + {22579200, 352800, 4, 3,}, + {22579200, 384000, 49, 40,}, + {24576000, 32000, 16, 1,}, + {24576000, 44100, 5120, 441,}, + {24576000, 48000, 32, 3,}, + {24576000, 88200, 2560, 441,}, + {24576000, 96000, 16, 3,}, + {24576000, 176400, 1280, 441,}, + {24576000, 192000, 8, 3,}, + {24576000, 352800, 640, 441,}, + {24576000, 384000, 4, 3,}, +}; + +/* frm_size = 64 */ +static const struct cs43130_clk_gen cs43130_64_clk_gen[] = { + {22579200, 32000, 441, 40,}, + {22579200, 44100, 8, 1,}, + {22579200, 48000, 147, 20,}, + {22579200, 88200, 4, 1,}, + {22579200, 96000, 147, 40,}, + {22579200, 176400, 2, 1,}, + {22579200, 192000, 147, 80,}, + {22579200, 352800, 1, 1,}, + {24576000, 32000, 12, 1,}, + {24576000, 44100, 1280, 147,}, + {24576000, 48000, 8, 1,}, + {24576000, 88200, 640, 147,}, + {24576000, 96000, 4, 1,}, + {24576000, 176400, 320, 147,}, + {24576000, 192000, 2, 1,}, + {24576000, 352800, 160, 147,}, + {24576000, 384000, 1, 1,}, +}; + +struct cs43130_bitwidth_map { + unsigned int bitwidth; + u8 sp_bit; + u8 ch_bit; +}; + +struct cs43130_rate_map { + int fs; + int val; +}; + +#define HP_LEFT 0 +#define HP_RIGHT 1 +#define CS43130_AC_FREQ 10 +#define CS43130_DC_THRESHOLD 2 + +#define CS43130_NUM_SUPPLIES 5 +static const char *const cs43130_supply_names[CS43130_NUM_SUPPLIES] = { + "VA", + "VP", + "VCP", + "VD", + "VL", +}; + +#define CS43130_NUM_INT 5 /* number of interrupt status reg */ + +struct cs43130_dai { + unsigned int sclk; + unsigned int dai_format; + unsigned int dai_mode; +}; + +struct cs43130_private { + struct snd_soc_codec *codec; + struct regmap *regmap; + struct regulator_bulk_data supplies[CS43130_NUM_SUPPLIES]; + struct gpio_desc *reset_gpio; + unsigned int dev_id; /* codec device ID */ + int xtal_ibias; + + /* shared by both DAIs */ + struct mutex clk_mutex; + int clk_req; + bool pll_bypass; + struct completion xtal_rdy; + struct completion pll_rdy; + unsigned int mclk; + unsigned int mclk_int; + int mclk_int_src; + + /* DAI specific */ + struct cs43130_dai dais[CS43130_DAI_ID_MAX]; + + /* HP load specific */ + bool dc_meas; + bool ac_meas; + bool hpload_done; + struct completion hpload_evt; + unsigned int hpload_stat; + u16 hpload_dc[2]; + u16 dc_threshold[CS43130_DC_THRESHOLD]; + u16 ac_freq[CS43130_AC_FREQ]; + u16 hpload_ac[CS43130_AC_FREQ][2]; + struct workqueue_struct *wq; + struct work_struct work; + struct snd_soc_jack jack; +}; + +#endif /* __CS43130_H__ */ -- cgit v1.1 From a3dcadd220b4572f9baaad5f3c0c00044273c961 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 1 Sep 2017 04:33:01 +0000 Subject: ASoC: add missing compile rule for max98371 It is still using old driver style, this patch also fixup it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/Makefile | 1 + sound/soc/codecs/max98371.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1755a54..b4d576d 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -320,6 +320,7 @@ obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o obj-$(CONFIG_SND_SOC_MAX98095) += snd-soc-max98095.o obj-$(CONFIG_SND_SOC_MAX98357A) += snd-soc-max98357a.o +obj-$(CONFIG_SND_SOC_MAX98371) += snd-soc-max98371.o obj-$(CONFIG_SND_SOC_MAX9867) += snd-soc-max9867.o obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o obj-$(CONFIG_SND_SOC_MAX98926) += snd-soc-max98926.o diff --git a/sound/soc/codecs/max98371.c b/sound/soc/codecs/max98371.c index 781be9ba..7bc2a17 100644 --- a/sound/soc/codecs/max98371.c +++ b/sound/soc/codecs/max98371.c @@ -349,12 +349,14 @@ static struct snd_soc_dai_driver max98371_dai[] = { }; static const struct snd_soc_codec_driver max98371_codec = { - .controls = max98371_snd_controls, - .num_controls = ARRAY_SIZE(max98371_snd_controls), - .dapm_routes = max98371_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98371_audio_map), - .dapm_widgets = max98371_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets), + .component_driver = { + .controls = max98371_snd_controls, + .num_controls = ARRAY_SIZE(max98371_snd_controls), + .dapm_routes = max98371_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98371_audio_map), + .dapm_widgets = max98371_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets), + }, }; static const struct regmap_config max98371_regmap = { -- cgit v1.1 From 2dc3b7b06bace6d8986a5fae6569ef30276cdd73 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 1 Sep 2017 04:33:27 +0000 Subject: ASoC: add missing compile rule for sirf-audio-codec It is still using old driver style, this patch also fixup it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/Makefile | 1 + sound/soc/codecs/sirf-audio-codec.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index b4d576d..8ed3c92 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -373,6 +373,7 @@ obj-$(CONFIG_SND_SOC_SIGMADSP_REGMAP) += snd-soc-sigmadsp-regmap.o obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o +obj-$(CONFIG_SND_SOC_SIRF_AUDIO_CODEC) += sirf-audio-codec.o obj-$(CONFIG_SND_SOC_SSM2518) += snd-soc-ssm2518.o obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o obj-$(CONFIG_SND_SOC_SSM2602_SPI) += snd-soc-ssm2602-spi.o diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index 6bfd25c..01d7690 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c @@ -432,10 +432,12 @@ static int sirf_audio_codec_remove(struct snd_soc_codec *codec) static struct snd_soc_codec_driver soc_codec_device_sirf_audio_codec = { .probe = sirf_audio_codec_probe, .remove = sirf_audio_codec_remove, - .dapm_widgets = sirf_audio_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sirf_audio_codec_dapm_widgets), - .dapm_routes = sirf_audio_codec_map, - .num_dapm_routes = ARRAY_SIZE(sirf_audio_codec_map), + .component_driver = { + .dapm_widgets = sirf_audio_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sirf_audio_codec_dapm_widgets), + .dapm_routes = sirf_audio_codec_map, + .num_dapm_routes = ARRAY_SIZE(sirf_audio_codec_map), + }, .idle_bias_off = true, }; -- cgit v1.1 From b21f0522ee376ddbea54fab47ff36f687f2a438b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 1 Sep 2017 04:33:01 +0000 Subject: ASoC: add missing compile rule for max98371 It is still using old driver style, this patch also fixup it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/Makefile | 1 + sound/soc/codecs/max98371.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1755a54..b4d576d 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -320,6 +320,7 @@ obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o obj-$(CONFIG_SND_SOC_MAX98095) += snd-soc-max98095.o obj-$(CONFIG_SND_SOC_MAX98357A) += snd-soc-max98357a.o +obj-$(CONFIG_SND_SOC_MAX98371) += snd-soc-max98371.o obj-$(CONFIG_SND_SOC_MAX9867) += snd-soc-max9867.o obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o obj-$(CONFIG_SND_SOC_MAX98926) += snd-soc-max98926.o diff --git a/sound/soc/codecs/max98371.c b/sound/soc/codecs/max98371.c index 781be9ba..7bc2a17 100644 --- a/sound/soc/codecs/max98371.c +++ b/sound/soc/codecs/max98371.c @@ -349,12 +349,14 @@ static struct snd_soc_dai_driver max98371_dai[] = { }; static const struct snd_soc_codec_driver max98371_codec = { - .controls = max98371_snd_controls, - .num_controls = ARRAY_SIZE(max98371_snd_controls), - .dapm_routes = max98371_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98371_audio_map), - .dapm_widgets = max98371_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets), + .component_driver = { + .controls = max98371_snd_controls, + .num_controls = ARRAY_SIZE(max98371_snd_controls), + .dapm_routes = max98371_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98371_audio_map), + .dapm_widgets = max98371_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets), + }, }; static const struct regmap_config max98371_regmap = { -- cgit v1.1 From 38a770859e10f566c434ae0d3f380954280f262b Mon Sep 17 00:00:00 2001 From: Pradeep Tewani Date: Fri, 1 Sep 2017 13:36:13 +0530 Subject: ASoC: Intel: Skylake: Add IPC to configure the copier secondary pins Copier can support upto 4 output pins. However, only pin 0 is configured as a part of copier initialization. Configuring rest of pins require the separate IPC to be sent to fw. Signed-off-by: Pradeep Tewani Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 53 ++++++++++++++++++++++++++++++---- sound/soc/intel/skylake/skl-topology.h | 5 ++++ 2 files changed, 53 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index ea83e8b..89f7013 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -1083,6 +1083,21 @@ int skl_unbind_modules(struct skl_sst *ctx, return ret; } +static void fill_pin_params(struct skl_audio_data_format *pin_fmt, + struct skl_module_fmt *format) +{ + pin_fmt->number_of_channels = format->channels; + pin_fmt->s_freq = format->s_freq; + pin_fmt->bit_depth = format->bit_depth; + pin_fmt->valid_bit_depth = format->valid_bit_depth; + pin_fmt->ch_cfg = format->ch_cfg; + pin_fmt->sample_type = format->sample_type; + pin_fmt->channel_map = format->ch_map; + pin_fmt->interleaving = format->interleaving_style; +} + +#define CPR_SINK_FMT_PARAM_ID 2 + /* * Once a module is instantiated it need to be 'bind' with other modules in * the pipeline. For binding we need to find the module pins which are bind @@ -1094,11 +1109,15 @@ int skl_bind_modules(struct skl_sst *ctx, struct skl_module_cfg *src_mcfg, struct skl_module_cfg *dst_mcfg) { - int ret; + int ret = 0; struct skl_ipc_bind_unbind_msg msg; int in_max = dst_mcfg->module->max_input_pins; int out_max = src_mcfg->module->max_output_pins; int src_index, dst_index; + struct skl_module_fmt *format; + struct skl_cpr_pin_fmt pin_fmt; + struct skl_module *module; + struct skl_module_iface *fmt; skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); @@ -1117,6 +1136,29 @@ int skl_bind_modules(struct skl_sst *ctx, return -EINVAL; } + /* + * Copier module requires the separate large_config_set_ipc to + * configure the pins other than 0 + */ + if (src_mcfg->m_type == SKL_MODULE_TYPE_COPIER && src_index > 0) { + pin_fmt.sink_id = src_index; + module = src_mcfg->module; + fmt = &module->formats[src_mcfg->fmt_idx]; + + /* Input fmt is same as that of src module input cfg */ + format = &fmt->inputs[0].fmt; + fill_pin_params(&(pin_fmt.src_fmt), format); + + format = &fmt->outputs[src_index].fmt; + fill_pin_params(&(pin_fmt.dst_fmt), format); + ret = skl_set_module_params(ctx, (void *)&pin_fmt, + sizeof(struct skl_cpr_pin_fmt), + CPR_SINK_FMT_PARAM_ID, src_mcfg); + + if (ret < 0) + goto out; + } + msg.dst_queue = dst_index; dev_dbg(ctx->dev, "src queue = %d dst queue =%d\n", @@ -1134,11 +1176,12 @@ int skl_bind_modules(struct skl_sst *ctx, src_mcfg->m_state = SKL_MODULE_BIND_DONE; src_mcfg->m_out_pin[src_index].pin_state = SKL_PIN_BIND_DONE; dst_mcfg->m_in_pin[dst_index].pin_state = SKL_PIN_BIND_DONE; - } else { - /* error case , if IPC fails, clear the queue index */ - skl_free_queue(src_mcfg->m_out_pin, src_index); - skl_free_queue(dst_mcfg->m_in_pin, dst_index); + return ret; } +out: + /* error case , if IPC fails, clear the queue index */ + skl_free_queue(src_mcfg->m_out_pin, src_index); + skl_free_queue(dst_mcfg->m_in_pin, dst_index); return ret; } diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index 4975904..2717db9 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -138,6 +138,11 @@ struct skl_cpr_cfg { struct skl_cpr_gtw_cfg gtw_cfg; } __packed; +struct skl_cpr_pin_fmt { + u32 sink_id; + struct skl_audio_data_format src_fmt; + struct skl_audio_data_format dst_fmt; +} __packed; struct skl_src_module_cfg { struct skl_base_cfg base_cfg; -- cgit v1.1 From 1f7f51a63114bab3a05920f4b1343154e95e2cb6 Mon Sep 17 00:00:00 2001 From: Wang YanQing Date: Sun, 3 Sep 2017 21:18:49 +0800 Subject: ALSA: hda: Fix regression of hdmi eld control created based on invalid pcm Commit fb087eaaef72 ("ALSA: hda - hdmi eld control created based on pcm") forget to filter out invalid pcm numbers, if there is only one invalid pcm number, then this issue causes we create eld control for invalid pcm silently, but when there are more than one invalid pcm numbers, then this issue bring probe error looks like below dmesg: " kernel: [ 1.647283] snd_hda_intel 0000:00:03.0: bound 0000:00:02.0 (ops 0xc2967540) kernel: [ 1.651192] snd_hda_intel 0000:00:03.0: Too many HDMI devices kernel: [ 1.651195] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y kernel: [ 1.651197] snd_hda_intel 0000:00:03.0: Too many HDMI devices kernel: [ 1.651199] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y kernel: [ 1.651201] snd_hda_intel 0000:00:03.0: Too many HDMI devices kernel: [ 1.651203] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y kernel: [ 1.651676] snd_hda_intel 0000:00:03.0: control 3:0:0:ELD:0 is already present kernel: [ 1.651787] snd_hda_codec_hdmi: probe of hdaudioC0D0 failed with error -16 " This patch add invalid pcm number filter before calling hdmi_create_eld_ctl. Fixes: fb087eaaef72 ("ALSA: hda - hdmi eld control created based on pcm") Signed-off-by: Wang YanQing Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 4 +++- sound/pci/hda/hda_codec.h | 1 + sound/pci/hda/patch_hdmi.c | 14 ++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 821aad3..3db26c4 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3213,8 +3213,10 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec) continue; /* no substreams assigned */ dev = get_empty_pcm_device(bus, cpcm->pcm_type); - if (dev < 0) + if (dev < 0) { + cpcm->device = SNDRV_PCM_INVALID_DEVICE; continue; /* no fatal error */ + } cpcm->device = dev; err = snd_hda_attach_pcm_stream(bus, codec, cpcm); if (err < 0) { diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 60ce1cf..681c360 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -164,6 +164,7 @@ enum { HDA_PCM_NTYPES }; +#define SNDRV_PCM_INVALID_DEVICE (-1) /* for PCM creation */ struct hda_pcm { char *name; diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 53f9311..2b64fab 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -2126,7 +2126,7 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) static int generic_hdmi_build_controls(struct hda_codec *codec) { struct hdmi_spec *spec = codec->spec; - int err; + int dev, err; int pin_idx, pcm_idx; @@ -2154,11 +2154,13 @@ static int generic_hdmi_build_controls(struct hda_codec *codec) return err; snd_hda_spdif_ctls_unassign(codec, pcm_idx); - /* add control for ELD Bytes */ - err = hdmi_create_eld_ctl(codec, pcm_idx, - get_pcm_rec(spec, pcm_idx)->device); - if (err < 0) - return err; + dev = get_pcm_rec(spec, pcm_idx)->device; + if (dev != SNDRV_PCM_INVALID_DEVICE) { + /* add control for ELD Bytes */ + err = hdmi_create_eld_ctl(codec, pcm_idx, dev); + if (err < 0) + return err; + } } for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { -- cgit v1.1 From b84e843644f211dbddcd65ba80732bdc3acf5380 Mon Sep 17 00:00:00 2001 From: PeiSen Hou Date: Fri, 1 Sep 2017 15:11:56 +0800 Subject: ALSA: hda/realtek - Enable jack detection function for Intel ALC700 Intel ALC 700 needs this patch for jack detection function. Because ALC700's jack detect function defaults is disable. So alc700 needs pathc to enable jack detection function. Signed-off-by: PeiSen Hou Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 217bb58..0ce7111 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -5263,6 +5263,7 @@ enum { ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, ALC233_FIXUP_LENOVO_MULTI_CODECS, ALC294_FIXUP_LENOVO_MIC_LOCATION, + ALC700_FIXUP_INTEL_REFERENCE, }; static const struct hda_fixup alc269_fixups[] = { @@ -6058,6 +6059,21 @@ static const struct hda_fixup alc269_fixups[] = { { } }, }, + [ALC700_FIXUP_INTEL_REFERENCE] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = (const struct hda_verb[]) { + /* Enables internal speaker */ + {0x20, AC_VERB_SET_COEF_INDEX, 0x45}, + {0x20, AC_VERB_SET_PROC_COEF, 0x5289}, + {0x20, AC_VERB_SET_COEF_INDEX, 0x4A}, + {0x20, AC_VERB_SET_PROC_COEF, 0x001b}, + {0x58, AC_VERB_SET_COEF_INDEX, 0x00}, + {0x58, AC_VERB_SET_PROC_COEF, 0x3888}, + {0x20, AC_VERB_SET_COEF_INDEX, 0x6f}, + {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b}, + {} + } + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -6209,6 +6225,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN), SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), + SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8), SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC), -- cgit v1.1 From 5f10e84934e4ef2289d1335087529685e5e679cc Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 1 Sep 2017 19:15:06 +0300 Subject: ALSA: atmel: convert AC97c driver to GPIO descriptor API Convert the driver to use GPIO descriptor API. Signed-off-by: Andy Shevchenko Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 70 ++++++++--------------------------------------------- 1 file changed, 10 insertions(+), 60 deletions(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 24623c7..3191491 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -12,16 +12,15 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include -#include #include #include @@ -29,7 +28,6 @@ #include #include #include -#include #include #include "ac97c.h" @@ -56,7 +54,7 @@ struct atmel_ac97c { void __iomem *regs; int irq; int opened; - int reset_pin; + struct gpio_desc *reset_pin; }; #define get_chip(card) ((struct atmel_ac97c *)(card)->private_data) @@ -700,11 +698,11 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip) ac97c_writel(chip, CAMR, 0); ac97c_writel(chip, COMR, 0); - if (gpio_is_valid(chip->reset_pin)) { - gpio_set_value(chip->reset_pin, 0); + if (!IS_ERR(chip->reset_pin)) { + gpiod_set_value(chip->reset_pin, 0); /* AC97 v2.2 specifications says minimum 1 us. */ udelay(2); - gpio_set_value(chip->reset_pin, 1); + gpiod_set_value(chip->reset_pin, 1); } else { ac97c_writel(chip, MR, AC97C_MR_WRST | AC97C_MR_ENA); udelay(2); @@ -712,45 +710,18 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip) } } -#ifdef CONFIG_OF static const struct of_device_id atmel_ac97c_dt_ids[] = { { .compatible = "atmel,at91sam9263-ac97c", }, { } }; MODULE_DEVICE_TABLE(of, atmel_ac97c_dt_ids); -static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) -{ - struct ac97c_platform_data *pdata; - struct device_node *node = dev->of_node; - - if (!node) { - dev_err(dev, "Device does not have associated DT data\n"); - return ERR_PTR(-EINVAL); - } - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - pdata->reset_pin = of_get_named_gpio(dev->of_node, "ac97-gpios", 2); - - return pdata; -} -#else -static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) -{ - dev_err(dev, "no platform data defined\n"); - return ERR_PTR(-ENXIO); -} -#endif - static int atmel_ac97c_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct snd_card *card; struct atmel_ac97c *chip; struct resource *regs; - struct ac97c_platform_data *pdata; struct clk *pclk; static struct snd_ac97_bus_ops ops = { .write = atmel_ac97c_write, @@ -765,13 +736,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev) return -ENXIO; } - pdata = dev_get_platdata(&pdev->dev); - if (!pdata) { - pdata = atmel_ac97c_probe_dt(&pdev->dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - } - irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_dbg(&pdev->dev, "could not get irq: %d\n", irq); @@ -819,17 +783,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev) goto err_ioremap; } - if (gpio_is_valid(pdata->reset_pin)) { - if (gpio_request(pdata->reset_pin, "reset_pin")) { - dev_dbg(&pdev->dev, "reset pin not available\n"); - chip->reset_pin = -ENODEV; - } else { - gpio_direction_output(pdata->reset_pin, 1); - chip->reset_pin = pdata->reset_pin; - } - } else { - chip->reset_pin = -EINVAL; - } + chip->reset_pin = devm_gpiod_get_index(dev, "ac97", 2, GPIOD_OUT_HIGH); + if (IS_ERR(chip->reset_pin)) + dev_dbg(dev, "reset pin not available\n"); atmel_ac97c_reset(chip); @@ -869,9 +825,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev) return 0; err_ac97_bus: - if (gpio_is_valid(chip->reset_pin)) - gpio_free(chip->reset_pin); - iounmap(chip->regs); err_ioremap: free_irq(irq, chip); @@ -913,9 +866,6 @@ static int atmel_ac97c_remove(struct platform_device *pdev) struct snd_card *card = platform_get_drvdata(pdev); struct atmel_ac97c *chip = get_chip(card); - if (gpio_is_valid(chip->reset_pin)) - gpio_free(chip->reset_pin); - ac97c_writel(chip, CAMR, 0); ac97c_writel(chip, COMR, 0); ac97c_writel(chip, MR, 0); @@ -936,7 +886,7 @@ static struct platform_driver atmel_ac97c_driver = { .driver = { .name = "atmel_ac97c", .pm = ATMEL_AC97C_PM_OPS, - .of_match_table = of_match_ptr(atmel_ac97c_dt_ids), + .of_match_table = atmel_ac97c_dt_ids, }, }; module_platform_driver(atmel_ac97c_driver); -- cgit v1.1 From 83ef26ac1326fdd2fc8d160967cdca2e8b46ccd4 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 4 Sep 2017 11:12:32 +0100 Subject: ASoC: cs43130: fix spelling mistake: "irq_occurrance" -> "irq_occurrence" Trivial fix to spelling mistake in variable name Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/cs43130.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index 220e301..9f1aa05 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -2147,7 +2147,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) struct cs43130_private *cs43130 = (struct cs43130_private *)data; struct snd_soc_codec *codec = cs43130->codec; unsigned int stickies[CS43130_NUM_INT]; - unsigned int irq_occurrance = 0; + unsigned int irq_occurrence = 0; unsigned int masks[CS43130_NUM_INT]; int i, j; @@ -2161,12 +2161,12 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) for (i = 0; i < ARRAY_SIZE(stickies); i++) { stickies[i] = stickies[i] & (~masks[i]); for (j = 0; j < 8; j++) - irq_occurrance += (stickies[i] >> j) & 1; + irq_occurrence += (stickies[i] >> j) & 1; } dev_dbg(codec->dev, "number of interrupts occurred (%u)\n", - irq_occurrance); + irq_occurrence); - if (!irq_occurrance) + if (!irq_occurrence) return IRQ_NONE; if (stickies[0] & CS43130_XTAL_RDY_INT) { -- cgit v1.1 From f31877a16b0926dea4d1d9b72917a3eca9be19b6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 4 Sep 2017 15:54:47 +0200 Subject: ASoC: cs43130: Fix possible Oops with invalid dev_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As compiler spotted out, there is the potential NULL-dereference in the code when dc-measure OF is given for other than 43130/43131: sound/soc/codecs/cs43130.c:2089:18: warning: ‘hpload_seq’ may be used uninitialized in this function [-Wmaybe-uninitialized] Warn it and return before triggering Oops. Fixes: 8f1e5bf9b440 ("ASoC: cs43130: Add support for CS43130 codec") Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/codecs/cs43130.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index 9f1aa05..4229a95 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -2079,6 +2079,10 @@ static void cs43130_imp_meas(struct work_struct *wk) case CS43131_CHIP_ID: hpload_seq = hpload_seq2; seq_size = ARRAY_SIZE(hpload_seq2); + break; + default: + WARN(1, "Invalid dev_id for meas: %d", cs43130->dev_id); + return; } i = 0; -- cgit v1.1 From 7051334672e54fae67e02d5d3296fb62b3343be7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 4 Sep 2017 15:54:48 +0200 Subject: ASoC: cs43130: Fix unused compiler warnings for PM runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add __maybe_unused prefix for addressing the following warnings: sound/soc/codecs/cs43130.c:2615:12: warning: ‘cs43130_runtime_resume’ defined but not used [-Wunused-function] sound/soc/codecs/cs43130.c:2596:12: warning: ‘cs43130_runtime_suspend’ defined but not used [-Wunused-function] Fixes: 8f1e5bf9b440 ("ASoC: cs43130: Add support for CS43130 codec") Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/codecs/cs43130.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index 4229a95..643e37fc 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -2597,7 +2597,7 @@ static int cs43130_i2c_remove(struct i2c_client *client) return 0; } -static int cs43130_runtime_suspend(struct device *dev) +static int __maybe_unused cs43130_runtime_suspend(struct device *dev) { struct cs43130_private *cs43130 = dev_get_drvdata(dev); @@ -2616,7 +2616,7 @@ static int cs43130_runtime_suspend(struct device *dev) return 0; } -static int cs43130_runtime_resume(struct device *dev) +static int __maybe_unused cs43130_runtime_resume(struct device *dev) { struct cs43130_private *cs43130 = dev_get_drvdata(dev); int ret; -- cgit v1.1 From 284b4c9289766c6294d4c6292aea565f78215b0e Mon Sep 17 00:00:00 2001 From: Wang YanQing Date: Mon, 4 Sep 2017 23:17:09 +0800 Subject: ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe When hda_codec_driver_probe meet error and return failure, we need to free resource with patch_ops.free, or we will get resource leak. Signed-off-by: Wang YanQing Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_bind.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c index 6efadbf..d361bb7 100644 --- a/sound/pci/hda/hda_bind.c +++ b/sound/pci/hda/hda_bind.c @@ -100,7 +100,7 @@ static int hda_codec_driver_probe(struct device *dev) if (patch) { err = patch(codec); if (err < 0) - goto error_module; + goto error_module_put; } err = snd_hda_codec_build_pcms(codec); @@ -120,6 +120,9 @@ static int hda_codec_driver_probe(struct device *dev) return 0; error_module: + if (codec->patch_ops.free) + codec->patch_ops.free(codec); + error_module_put: module_put(owner); error: -- cgit v1.1 From cc91ceaf3efd9a2364463b5f85d9f391f1ddaa9d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 4 Sep 2017 17:38:36 +0200 Subject: ALSA: hda/ca0132 - Fix memory leak at error path The CA0132 codec driver doesn't call the free function at its error path of the probe, which leaves the allocated memory. Call ca0132_free() properly at the error handling. Fixes: a73d511c4867 ("ALSA: hda/ca0132: Add unsol handler for DSP and jack detection") Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_ca0132.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index a148176..3e73d5c 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -4774,13 +4774,17 @@ static int patch_ca0132(struct hda_codec *codec) err = ca0132_prepare_verbs(codec); if (err < 0) - return err; + goto error; err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); if (err < 0) - return err; + goto error; return 0; + + error: + ca0132_free(codec); + return err; } /* -- cgit v1.1