diff options
Diffstat (limited to 'sound/soc/codecs/max98088.c')
-rw-r--r-- | sound/soc/codecs/max98088.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index ac65a2d3640..ebbf63c79c3 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c | |||
@@ -40,7 +40,6 @@ struct max98088_cdata { | |||
40 | 40 | ||
41 | struct max98088_priv { | 41 | struct max98088_priv { |
42 | enum max98088_type devtype; | 42 | enum max98088_type devtype; |
43 | void *control_data; | ||
44 | struct max98088_pdata *pdata; | 43 | struct max98088_pdata *pdata; |
45 | unsigned int sysclk; | 44 | unsigned int sysclk; |
46 | struct max98088_cdata dai[2]; | 45 | struct max98088_cdata dai[2]; |
@@ -1697,13 +1696,19 @@ static struct snd_soc_dai_driver max98088_dai[] = { | |||
1697 | } | 1696 | } |
1698 | }; | 1697 | }; |
1699 | 1698 | ||
1700 | static int max98088_get_channel(const char *name) | 1699 | static const char *eq_mode_name[] = {"EQ1 Mode", "EQ2 Mode"}; |
1700 | |||
1701 | static int max98088_get_channel(struct snd_soc_codec *codec, const char *name) | ||
1701 | { | 1702 | { |
1702 | if (strcmp(name, "EQ1 Mode") == 0) | 1703 | int i; |
1703 | return 0; | 1704 | |
1704 | if (strcmp(name, "EQ2 Mode") == 0) | 1705 | for (i = 0; i < ARRAY_SIZE(eq_mode_name); i++) |
1705 | return 1; | 1706 | if (strcmp(name, eq_mode_name[i]) == 0) |
1706 | return -EINVAL; | 1707 | return i; |
1708 | |||
1709 | /* Shouldn't happen */ | ||
1710 | dev_err(codec->dev, "Bad EQ channel name '%s'\n", name); | ||
1711 | return -EINVAL; | ||
1707 | } | 1712 | } |
1708 | 1713 | ||
1709 | static void max98088_setup_eq1(struct snd_soc_codec *codec) | 1714 | static void max98088_setup_eq1(struct snd_soc_codec *codec) |
@@ -1807,10 +1812,13 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, | |||
1807 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1812 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
1808 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 1813 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
1809 | struct max98088_pdata *pdata = max98088->pdata; | 1814 | struct max98088_pdata *pdata = max98088->pdata; |
1810 | int channel = max98088_get_channel(kcontrol->id.name); | 1815 | int channel = max98088_get_channel(codec, kcontrol->id.name); |
1811 | struct max98088_cdata *cdata; | 1816 | struct max98088_cdata *cdata; |
1812 | int sel = ucontrol->value.integer.value[0]; | 1817 | int sel = ucontrol->value.integer.value[0]; |
1813 | 1818 | ||
1819 | if (channel < 0) | ||
1820 | return channel; | ||
1821 | |||
1814 | cdata = &max98088->dai[channel]; | 1822 | cdata = &max98088->dai[channel]; |
1815 | 1823 | ||
1816 | if (sel >= pdata->eq_cfgcnt) | 1824 | if (sel >= pdata->eq_cfgcnt) |
@@ -1835,9 +1843,12 @@ static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, | |||
1835 | { | 1843 | { |
1836 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | 1844 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
1837 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); | 1845 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
1838 | int channel = max98088_get_channel(kcontrol->id.name); | 1846 | int channel = max98088_get_channel(codec, kcontrol->id.name); |
1839 | struct max98088_cdata *cdata; | 1847 | struct max98088_cdata *cdata; |
1840 | 1848 | ||
1849 | if (channel < 0) | ||
1850 | return channel; | ||
1851 | |||
1841 | cdata = &max98088->dai[channel]; | 1852 | cdata = &max98088->dai[channel]; |
1842 | ucontrol->value.enumerated.item[0] = cdata->eq_sel; | 1853 | ucontrol->value.enumerated.item[0] = cdata->eq_sel; |
1843 | return 0; | 1854 | return 0; |
@@ -1852,17 +1863,17 @@ static void max98088_handle_eq_pdata(struct snd_soc_codec *codec) | |||
1852 | int i, j; | 1863 | int i, j; |
1853 | const char **t; | 1864 | const char **t; |
1854 | int ret; | 1865 | int ret; |
1855 | |||
1856 | struct snd_kcontrol_new controls[] = { | 1866 | struct snd_kcontrol_new controls[] = { |
1857 | SOC_ENUM_EXT("EQ1 Mode", | 1867 | SOC_ENUM_EXT((char *)eq_mode_name[0], |
1858 | max98088->eq_enum, | 1868 | max98088->eq_enum, |
1859 | max98088_get_eq_enum, | 1869 | max98088_get_eq_enum, |
1860 | max98088_put_eq_enum), | 1870 | max98088_put_eq_enum), |
1861 | SOC_ENUM_EXT("EQ2 Mode", | 1871 | SOC_ENUM_EXT((char *)eq_mode_name[1], |
1862 | max98088->eq_enum, | 1872 | max98088->eq_enum, |
1863 | max98088_get_eq_enum, | 1873 | max98088_get_eq_enum, |
1864 | max98088_put_eq_enum), | 1874 | max98088_put_eq_enum), |
1865 | }; | 1875 | }; |
1876 | BUILD_BUG_ON(ARRAY_SIZE(controls) != ARRAY_SIZE(eq_mode_name)); | ||
1866 | 1877 | ||
1867 | cfg = pdata->eq_cfg; | 1878 | cfg = pdata->eq_cfg; |
1868 | cfgcnt = pdata->eq_cfgcnt; | 1879 | cfgcnt = pdata->eq_cfgcnt; |
@@ -2066,7 +2077,6 @@ static int max98088_i2c_probe(struct i2c_client *i2c, | |||
2066 | max98088->devtype = id->driver_data; | 2077 | max98088->devtype = id->driver_data; |
2067 | 2078 | ||
2068 | i2c_set_clientdata(i2c, max98088); | 2079 | i2c_set_clientdata(i2c, max98088); |
2069 | max98088->control_data = i2c; | ||
2070 | max98088->pdata = i2c->dev.platform_data; | 2080 | max98088->pdata = i2c->dev.platform_data; |
2071 | 2081 | ||
2072 | ret = snd_soc_register_codec(&i2c->dev, | 2082 | ret = snd_soc_register_codec(&i2c->dev, |