diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-11-10 16:41:53 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-11-18 10:38:03 -0500 |
commit | 358a8bb5628420529e4f0b77068155ca8fa8973b (patch) | |
tree | 864f2cc85356c306157d6ce65d24be1914bbb21e /sound/soc/codecs/wm9713.c | |
parent | bc2632140435cc84f9817f1c362479b23dbdfebc (diff) |
ASoC: ac97: Push snd_ac97 pointer to the driver level
Now that the ASoC core no longer needs a handle to the AC'97 device that is
associated with a CODEC we can remove it from the snd_soc_codec struct and
push it into the individual driver state structs like we do for other
communication buses. Doing so creates a clean separation between the AC'97
bus support and the ASoC core.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/wm9713.c')
-rw-r--r-- | sound/soc/codecs/wm9713.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index cd1b266d3af3..6c95d98b0eb1 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "wm9713.h" | 30 | #include "wm9713.h" |
31 | 31 | ||
32 | struct wm9713_priv { | 32 | struct wm9713_priv { |
33 | struct snd_ac97 *ac97; | ||
33 | u32 pll_in; /* PLL input frequency */ | 34 | u32 pll_in; /* PLL input frequency */ |
34 | unsigned int hp_mixer[2]; | 35 | unsigned int hp_mixer[2]; |
35 | struct mutex lock; | 36 | struct mutex lock; |
@@ -674,12 +675,13 @@ static const struct snd_soc_dapm_route wm9713_audio_map[] = { | |||
674 | static unsigned int ac97_read(struct snd_soc_codec *codec, | 675 | static unsigned int ac97_read(struct snd_soc_codec *codec, |
675 | unsigned int reg) | 676 | unsigned int reg) |
676 | { | 677 | { |
678 | struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); | ||
677 | u16 *cache = codec->reg_cache; | 679 | u16 *cache = codec->reg_cache; |
678 | 680 | ||
679 | if (reg == AC97_RESET || reg == AC97_GPIO_STATUS || | 681 | if (reg == AC97_RESET || reg == AC97_GPIO_STATUS || |
680 | reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 || | 682 | reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 || |
681 | reg == AC97_CD) | 683 | reg == AC97_CD) |
682 | return soc_ac97_ops->read(codec->ac97, reg); | 684 | return soc_ac97_ops->read(wm9713->ac97, reg); |
683 | else { | 685 | else { |
684 | reg = reg >> 1; | 686 | reg = reg >> 1; |
685 | 687 | ||
@@ -693,8 +695,10 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, | |||
693 | static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, | 695 | static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, |
694 | unsigned int val) | 696 | unsigned int val) |
695 | { | 697 | { |
698 | struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); | ||
699 | |||
696 | u16 *cache = codec->reg_cache; | 700 | u16 *cache = codec->reg_cache; |
697 | soc_ac97_ops->write(codec->ac97, reg, val); | 701 | soc_ac97_ops->write(wm9713->ac97, reg, val); |
698 | reg = reg >> 1; | 702 | reg = reg >> 1; |
699 | if (reg < (ARRAY_SIZE(wm9713_reg))) | 703 | if (reg < (ARRAY_SIZE(wm9713_reg))) |
700 | cache[reg] = val; | 704 | cache[reg] = val; |
@@ -1121,15 +1125,17 @@ static struct snd_soc_dai_driver wm9713_dai[] = { | |||
1121 | 1125 | ||
1122 | int wm9713_reset(struct snd_soc_codec *codec, int try_warm) | 1126 | int wm9713_reset(struct snd_soc_codec *codec, int try_warm) |
1123 | { | 1127 | { |
1128 | struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); | ||
1129 | |||
1124 | if (try_warm && soc_ac97_ops->warm_reset) { | 1130 | if (try_warm && soc_ac97_ops->warm_reset) { |
1125 | soc_ac97_ops->warm_reset(codec->ac97); | 1131 | soc_ac97_ops->warm_reset(wm9713->ac97); |
1126 | if (ac97_read(codec, 0) == wm9713_reg[0]) | 1132 | if (ac97_read(codec, 0) == wm9713_reg[0]) |
1127 | return 1; | 1133 | return 1; |
1128 | } | 1134 | } |
1129 | 1135 | ||
1130 | soc_ac97_ops->reset(codec->ac97); | 1136 | soc_ac97_ops->reset(wm9713->ac97); |
1131 | if (soc_ac97_ops->warm_reset) | 1137 | if (soc_ac97_ops->warm_reset) |
1132 | soc_ac97_ops->warm_reset(codec->ac97); | 1138 | soc_ac97_ops->warm_reset(wm9713->ac97); |
1133 | if (ac97_read(codec, 0) != wm9713_reg[0]) { | 1139 | if (ac97_read(codec, 0) != wm9713_reg[0]) { |
1134 | dev_err(codec->dev, "Failed to reset: AC97 link error\n"); | 1140 | dev_err(codec->dev, "Failed to reset: AC97 link error\n"); |
1135 | return -EIO; | 1141 | return -EIO; |
@@ -1207,7 +1213,7 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec) | |||
1207 | if (i == AC97_POWERDOWN || i == AC97_EXTENDED_MID || | 1213 | if (i == AC97_POWERDOWN || i == AC97_EXTENDED_MID || |
1208 | i == AC97_EXTENDED_MSTATUS || i > 0x66) | 1214 | i == AC97_EXTENDED_MSTATUS || i > 0x66) |
1209 | continue; | 1215 | continue; |
1210 | soc_ac97_ops->write(codec->ac97, i, cache[i>>1]); | 1216 | soc_ac97_ops->write(wm9713->ac97, i, cache[i>>1]); |
1211 | } | 1217 | } |
1212 | } | 1218 | } |
1213 | 1219 | ||
@@ -1216,11 +1222,12 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec) | |||
1216 | 1222 | ||
1217 | static int wm9713_soc_probe(struct snd_soc_codec *codec) | 1223 | static int wm9713_soc_probe(struct snd_soc_codec *codec) |
1218 | { | 1224 | { |
1225 | struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); | ||
1219 | int ret = 0, reg; | 1226 | int ret = 0, reg; |
1220 | 1227 | ||
1221 | ret = snd_soc_new_ac97_codec(codec); | 1228 | wm9713->ac97 = snd_soc_new_ac97_codec(codec); |
1222 | if (ret < 0) | 1229 | if (IS_ERR(wm9713->ac97)) |
1223 | return ret; | 1230 | return PTR_ERR(wm9713->ac97); |
1224 | 1231 | ||
1225 | /* do a cold reset for the controller and then try | 1232 | /* do a cold reset for the controller and then try |
1226 | * a warm reset followed by an optional cold reset for codec */ | 1233 | * a warm reset followed by an optional cold reset for codec */ |
@@ -1238,13 +1245,15 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) | |||
1238 | return 0; | 1245 | return 0; |
1239 | 1246 | ||
1240 | reset_err: | 1247 | reset_err: |
1241 | snd_soc_free_ac97_codec(codec); | 1248 | snd_soc_free_ac97_codec(wm9713->ac97); |
1242 | return ret; | 1249 | return ret; |
1243 | } | 1250 | } |
1244 | 1251 | ||
1245 | static int wm9713_soc_remove(struct snd_soc_codec *codec) | 1252 | static int wm9713_soc_remove(struct snd_soc_codec *codec) |
1246 | { | 1253 | { |
1247 | snd_soc_free_ac97_codec(codec); | 1254 | struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); |
1255 | |||
1256 | snd_soc_free_ac97_codec(wm9713->ac97); | ||
1248 | return 0; | 1257 | return 0; |
1249 | } | 1258 | } |
1250 | 1259 | ||