From 89d051300b845e1001a9d9e9ce94da4250c21613 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 13 Sep 2013 15:22:18 +0530 Subject: [PATCH 1/7] ASoC: rt5640: Staticize hp_amp_power_on 'hp_amp_power_on' is used only in this file. Make it static. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index c26a8f814b18..2f6bb161e64c 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -926,7 +926,7 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w, return 0; } -void hp_amp_power_on(struct snd_soc_codec *codec) +static void hp_amp_power_on(struct snd_soc_codec *codec) { struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); From 9e9cb9b99615180b94d743f1d6ca0f82539c8754 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 13 Sep 2013 17:57:35 +0100 Subject: [PATCH 2/7] ASoC: rt5640: Provide more useful hw_params error reasons. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 2f6bb161e64c..de40bd9f6ac2 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1609,7 +1609,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, rt5640->lrck[dai->id] = params_rate(params); pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting\n"); + dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + rt5640->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); From 02b80773de3732dae11c1cf0c1ce40378901bd0e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 13 Sep 2013 17:57:36 +0100 Subject: [PATCH 3/7] ASoC: rt5640: Add ACPI probing support. Allow the RT5640 to be probed as an ACPI I2C device. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index de40bd9f6ac2..0bfb960e90f8 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -2081,6 +2082,12 @@ static const struct i2c_device_id rt5640_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); +static struct acpi_device_id rt5640_acpi_match[] = { + { "INT33CA", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); + static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) { rt5640->pdata.in1_diff = of_property_read_bool(np, @@ -2200,6 +2207,7 @@ static struct i2c_driver rt5640_i2c_driver = { .driver = { .name = "rt5640", .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(rt5640_acpi_match), }, .probe = rt5640_i2c_probe, .remove = rt5640_i2c_remove, From 32fcb97b9f699f63742bcaadca6e0beede86e8e8 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 19 Sep 2013 11:18:06 +0200 Subject: [PATCH 4/7] ASoC: rt5640: Omit ACPI match table only if !ACPI The ACPI_PTR() macro evaluates to NULL if ACPI is disabled and hence the ACPI match table won't be used, causing the compiler to complain. Avoid this by protecting the table using an #ifdef CONFIG_ACPI. Signed-off-by: Thierry Reding Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 0bfb960e90f8..641eeeb00c5c 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2082,11 +2082,13 @@ static const struct i2c_device_id rt5640_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); +#ifdef CONFIG_ACPI static struct acpi_device_id rt5640_acpi_match[] = { { "INT33CA", 0 }, { }, }; MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); +#endif static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) { From e58f301ec969430cdafd7fa872660458f4939507 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 16 Oct 2013 17:26:22 +0100 Subject: [PATCH 5/7] ASoC: rt5640: Power down LDO while suspended If we have control over the LDO then disable it during suspend; the device is already being put into reset so will be non-functional over suspend anyway and this will save a small amount of power. Signed-off-by: Mark Brown Tested-by: Stephen Warren --- sound/soc/codecs/rt5640.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 641eeeb00c5c..b0cde92be7eb 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1979,12 +1979,20 @@ static int rt5640_suspend(struct snd_soc_codec *codec) rt5640_reset(codec); regcache_cache_only(rt5640->regmap, true); regcache_mark_dirty(rt5640->regmap); + if (gpio_is_valid(rt5640->pdata.ldo1_en)) + gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 0); return 0; } static int rt5640_resume(struct snd_soc_codec *codec) { + struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + + if (gpio_is_valid(rt5640->pdata.ldo1_en)) { + gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1); + msleep(400); + } rt5640_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return 0; From ebce31140c2ddfda005e88957ac1ee1eacaa8dc5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 16 Oct 2013 17:30:44 +0100 Subject: [PATCH 6/7] ASoC: rt5640: Don't go to standby on resume There is no need for the CODEC to go to standby on resume since the core will power it up as needed and in any case it is an idle_bias_off CODEC so would normally sit with bias off while idle. Signed-off-by: Mark Brown Tested-by: Stephen Warren --- sound/soc/codecs/rt5640.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index b0cde92be7eb..4d041d376f31 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1993,7 +1993,6 @@ static int rt5640_resume(struct snd_soc_codec *codec) gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1); msleep(400); } - rt5640_set_bias_level(codec, SND_SOC_BIAS_STANDBY); return 0; } From 5a7615cf1fcaaf1598b5689e54915d88c2344788 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 30 Oct 2013 08:35:06 +0100 Subject: [PATCH 7/7] ASoC: rt5640: Fix ignored error checks The negative error value returned from get_sdp_info() is ignored because it's assigned to unsigned variables. Spotted by coverity CIDs 1042657, 1042658. Signed-off-by: Takashi Iwai Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 4d041d376f31..a3fb41179636 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1604,8 +1604,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_codec *codec = rtd->codec; struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); - unsigned int val_len = 0, val_clk, mask_clk, dai_sel; - int pre_div, bclk_ms, frame_size; + unsigned int val_len = 0, val_clk, mask_clk; + int dai_sel, pre_div, bclk_ms, frame_size; rt5640->lrck[dai->id] = params_rate(params); pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); @@ -1675,7 +1675,8 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { struct snd_soc_codec *codec = dai->codec; struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); - unsigned int reg_val = 0, dai_sel; + unsigned int reg_val = 0; + int dai_sel; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: