aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/max98095.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/max98095.c')
-rw-r--r--sound/soc/codecs/max98095.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index e1d282d477d..3f873b6d75a 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -618,14 +618,13 @@ static int max98095_volatile(struct snd_soc_codec *codec, unsigned int reg)
618static int max98095_hw_write(struct snd_soc_codec *codec, unsigned int reg, 618static int max98095_hw_write(struct snd_soc_codec *codec, unsigned int reg,
619 unsigned int value) 619 unsigned int value)
620{ 620{
621 u8 data[2]; 621 int ret;
622 622
623 data[0] = reg; 623 codec->cache_bypass = 1;
624 data[1] = value; 624 ret = snd_soc_write(codec, reg, value);
625 if (codec->hw_write(codec->control_data, data, 2) == 2) 625 codec->cache_bypass = 0;
626 return 0; 626
627 else 627 return ret ? -EIO : 0;
628 return -EIO;
629} 628}
630 629
631/* 630/*
@@ -1517,8 +1516,6 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai,
1517 if (freq == max98095->sysclk) 1516 if (freq == max98095->sysclk)
1518 return 0; 1517 return 0;
1519 1518
1520 max98095->sysclk = freq; /* remember current sysclk */
1521
1522 /* Setup clocks for slave mode, and using the PLL 1519 /* Setup clocks for slave mode, and using the PLL
1523 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz) 1520 * PSCLK = 0x01 (when master clk is 10MHz to 20MHz)
1524 * 0x02 (when master clk is 20MHz to 40MHz).. 1521 * 0x02 (when master clk is 20MHz to 40MHz)..
@@ -1994,12 +1991,19 @@ static void max98095_handle_eq_pdata(struct snd_soc_codec *codec)
1994 dev_err(codec->dev, "Failed to add EQ control: %d\n", ret); 1991 dev_err(codec->dev, "Failed to add EQ control: %d\n", ret);
1995} 1992}
1996 1993
1997static int max98095_get_bq_channel(const char *name) 1994static const char *bq_mode_name[] = {"Biquad1 Mode", "Biquad2 Mode"};
1995
1996static int max98095_get_bq_channel(struct snd_soc_codec *codec,
1997 const char *name)
1998{ 1998{
1999 if (strcmp(name, "Biquad1 Mode") == 0) 1999 int i;
2000 return 0; 2000
2001 if (strcmp(name, "Biquad2 Mode") == 0) 2001 for (i = 0; i < ARRAY_SIZE(bq_mode_name); i++)
2002 return 1; 2002 if (strcmp(name, bq_mode_name[i]) == 0)
2003 return i;
2004
2005 /* Shouldn't happen */
2006 dev_err(codec->dev, "Bad biquad channel name '%s'\n", name);
2003 return -EINVAL; 2007 return -EINVAL;
2004} 2008}
2005 2009
@@ -2009,14 +2013,15 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
2009 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 2013 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2010 struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); 2014 struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
2011 struct max98095_pdata *pdata = max98095->pdata; 2015 struct max98095_pdata *pdata = max98095->pdata;
2012 int channel = max98095_get_bq_channel(kcontrol->id.name); 2016 int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
2013 struct max98095_cdata *cdata; 2017 struct max98095_cdata *cdata;
2014 int sel = ucontrol->value.integer.value[0]; 2018 int sel = ucontrol->value.integer.value[0];
2015 struct max98095_biquad_cfg *coef_set; 2019 struct max98095_biquad_cfg *coef_set;
2016 int fs, best, best_val, i; 2020 int fs, best, best_val, i;
2017 int regmask, regsave; 2021 int regmask, regsave;
2018 2022
2019 BUG_ON(channel > 1); 2023 if (channel < 0)
2024 return channel;
2020 2025
2021 if (!pdata || !max98095->bq_textcnt) 2026 if (!pdata || !max98095->bq_textcnt)
2022 return 0; 2027 return 0;
@@ -2068,9 +2073,12 @@ static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol,
2068{ 2073{
2069 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 2074 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
2070 struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); 2075 struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
2071 int channel = max98095_get_bq_channel(kcontrol->id.name); 2076 int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
2072 struct max98095_cdata *cdata; 2077 struct max98095_cdata *cdata;
2073 2078
2079 if (channel < 0)
2080 return channel;
2081
2074 cdata = &max98095->dai[channel]; 2082 cdata = &max98095->dai[channel];
2075 ucontrol->value.enumerated.item[0] = cdata->bq_sel; 2083 ucontrol->value.enumerated.item[0] = cdata->bq_sel;
2076 2084
@@ -2088,15 +2096,16 @@ static void max98095_handle_bq_pdata(struct snd_soc_codec *codec)
2088 int ret; 2096 int ret;
2089 2097
2090 struct snd_kcontrol_new controls[] = { 2098 struct snd_kcontrol_new controls[] = {
2091 SOC_ENUM_EXT("Biquad1 Mode", 2099 SOC_ENUM_EXT((char *)bq_mode_name[0],
2092 max98095->bq_enum, 2100 max98095->bq_enum,
2093 max98095_get_bq_enum, 2101 max98095_get_bq_enum,
2094 max98095_put_bq_enum), 2102 max98095_put_bq_enum),
2095 SOC_ENUM_EXT("Biquad2 Mode", 2103 SOC_ENUM_EXT((char *)bq_mode_name[1],
2096 max98095->bq_enum, 2104 max98095->bq_enum,
2097 max98095_get_bq_enum, 2105 max98095_get_bq_enum,
2098 max98095_put_bq_enum), 2106 max98095_put_bq_enum),
2099 }; 2107 };
2108 BUILD_BUG_ON(ARRAY_SIZE(controls) != ARRAY_SIZE(bq_mode_name));
2100 2109
2101 cfg = pdata->bq_cfg; 2110 cfg = pdata->bq_cfg;
2102 cfgcnt = pdata->bq_cfgcnt; 2111 cfgcnt = pdata->bq_cfgcnt;
@@ -2261,11 +2270,11 @@ static int max98095_probe(struct snd_soc_codec *codec)
2261 2270
2262 ret = snd_soc_read(codec, M98095_0FF_REV_ID); 2271 ret = snd_soc_read(codec, M98095_0FF_REV_ID);
2263 if (ret < 0) { 2272 if (ret < 0) {
2264 dev_err(codec->dev, "Failed to read device revision: %d\n", 2273 dev_err(codec->dev, "Failure reading hardware revision: %d\n",
2265 ret); 2274 ret);
2266 goto err_access; 2275 goto err_access;
2267 } 2276 }
2268 dev_info(codec->dev, "revision %c\n", ret + 'A'); 2277 dev_info(codec->dev, "Hardware revision: %c\n", ret - 0x40 + 'A');
2269 2278
2270 snd_soc_write(codec, M98095_097_PWR_SYS, M98095_PWRSV); 2279 snd_soc_write(codec, M98095_097_PWR_SYS, M98095_PWRSV);
2271 2280
@@ -2342,8 +2351,8 @@ static int max98095_i2c_probe(struct i2c_client *i2c,
2342 max98095->control_data = i2c; 2351 max98095->control_data = i2c;
2343 max98095->pdata = i2c->dev.platform_data; 2352 max98095->pdata = i2c->dev.platform_data;
2344 2353
2345 ret = snd_soc_register_codec(&i2c->dev, 2354 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98095,
2346 &soc_codec_dev_max98095, &max98095_dai[0], 3); 2355 max98095_dai, ARRAY_SIZE(max98095_dai));
2347 if (ret < 0) 2356 if (ret < 0)
2348 kfree(max98095); 2357 kfree(max98095);
2349 return ret; 2358 return ret;