diff options
Diffstat (limited to 'sound/soc/codecs/ak4104.c')
-rw-r--r-- | sound/soc/codecs/ak4104.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index 6f6c335a5baa..c7cfdf957e4d 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c | |||
@@ -55,6 +55,7 @@ static int ak4104_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
55 | unsigned int format) | 55 | unsigned int format) |
56 | { | 56 | { |
57 | struct snd_soc_codec *codec = codec_dai->codec; | 57 | struct snd_soc_codec *codec = codec_dai->codec; |
58 | struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); | ||
58 | int val = 0; | 59 | int val = 0; |
59 | int ret; | 60 | int ret; |
60 | 61 | ||
@@ -77,9 +78,9 @@ static int ak4104_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
77 | if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) | 78 | if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) |
78 | return -EINVAL; | 79 | return -EINVAL; |
79 | 80 | ||
80 | ret = snd_soc_update_bits(codec, AK4104_REG_CONTROL1, | 81 | ret = regmap_update_bits(ak4104->regmap, AK4104_REG_CONTROL1, |
81 | AK4104_CONTROL1_DIF0 | AK4104_CONTROL1_DIF1, | 82 | AK4104_CONTROL1_DIF0 | AK4104_CONTROL1_DIF1, |
82 | val); | 83 | val); |
83 | if (ret < 0) | 84 | if (ret < 0) |
84 | return ret; | 85 | return ret; |
85 | 86 | ||
@@ -91,11 +92,12 @@ static int ak4104_hw_params(struct snd_pcm_substream *substream, | |||
91 | struct snd_soc_dai *dai) | 92 | struct snd_soc_dai *dai) |
92 | { | 93 | { |
93 | struct snd_soc_codec *codec = dai->codec; | 94 | struct snd_soc_codec *codec = dai->codec; |
94 | int val = 0; | 95 | struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); |
96 | int ret, val = 0; | ||
95 | 97 | ||
96 | /* set the IEC958 bits: consumer mode, no copyright bit */ | 98 | /* set the IEC958 bits: consumer mode, no copyright bit */ |
97 | val |= IEC958_AES0_CON_NOT_COPYRIGHT; | 99 | val |= IEC958_AES0_CON_NOT_COPYRIGHT; |
98 | snd_soc_write(codec, AK4104_REG_CHN_STATUS(0), val); | 100 | regmap_write(ak4104->regmap, AK4104_REG_CHN_STATUS(0), val); |
99 | 101 | ||
100 | val = 0; | 102 | val = 0; |
101 | 103 | ||
@@ -132,11 +134,33 @@ static int ak4104_hw_params(struct snd_pcm_substream *substream, | |||
132 | return -EINVAL; | 134 | return -EINVAL; |
133 | } | 135 | } |
134 | 136 | ||
135 | return snd_soc_write(codec, AK4104_REG_CHN_STATUS(3), val); | 137 | ret = regmap_write(ak4104->regmap, AK4104_REG_CHN_STATUS(3), val); |
138 | if (ret < 0) | ||
139 | return ret; | ||
140 | |||
141 | /* enable transmitter */ | ||
142 | ret = regmap_update_bits(ak4104->regmap, AK4104_REG_TX, | ||
143 | AK4104_TX_TXE, AK4104_TX_TXE); | ||
144 | if (ret < 0) | ||
145 | return ret; | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | static int ak4104_hw_free(struct snd_pcm_substream *substream, | ||
151 | struct snd_soc_dai *dai) | ||
152 | { | ||
153 | struct snd_soc_codec *codec = dai->codec; | ||
154 | struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); | ||
155 | |||
156 | /* disable transmitter */ | ||
157 | return regmap_update_bits(ak4104->regmap, AK4104_REG_TX, | ||
158 | AK4104_TX_TXE, 0); | ||
136 | } | 159 | } |
137 | 160 | ||
138 | static const struct snd_soc_dai_ops ak4101_dai_ops = { | 161 | static const struct snd_soc_dai_ops ak4101_dai_ops = { |
139 | .hw_params = ak4104_hw_params, | 162 | .hw_params = ak4104_hw_params, |
163 | .hw_free = ak4104_hw_free, | ||
140 | .set_fmt = ak4104_set_dai_fmt, | 164 | .set_fmt = ak4104_set_dai_fmt, |
141 | }; | 165 | }; |
142 | 166 | ||
@@ -160,20 +184,17 @@ static int ak4104_probe(struct snd_soc_codec *codec) | |||
160 | int ret; | 184 | int ret; |
161 | 185 | ||
162 | codec->control_data = ak4104->regmap; | 186 | codec->control_data = ak4104->regmap; |
163 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); | ||
164 | if (ret != 0) | ||
165 | return ret; | ||
166 | 187 | ||
167 | /* set power-up and non-reset bits */ | 188 | /* set power-up and non-reset bits */ |
168 | ret = snd_soc_update_bits(codec, AK4104_REG_CONTROL1, | 189 | ret = regmap_update_bits(ak4104->regmap, AK4104_REG_CONTROL1, |
169 | AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, | 190 | AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, |
170 | AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN); | 191 | AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN); |
171 | if (ret < 0) | 192 | if (ret < 0) |
172 | return ret; | 193 | return ret; |
173 | 194 | ||
174 | /* enable transmitter */ | 195 | /* enable transmitter */ |
175 | ret = snd_soc_update_bits(codec, AK4104_REG_TX, | 196 | ret = regmap_update_bits(ak4104->regmap, AK4104_REG_TX, |
176 | AK4104_TX_TXE, AK4104_TX_TXE); | 197 | AK4104_TX_TXE, AK4104_TX_TXE); |
177 | if (ret < 0) | 198 | if (ret < 0) |
178 | return ret; | 199 | return ret; |
179 | 200 | ||
@@ -182,8 +203,10 @@ static int ak4104_probe(struct snd_soc_codec *codec) | |||
182 | 203 | ||
183 | static int ak4104_remove(struct snd_soc_codec *codec) | 204 | static int ak4104_remove(struct snd_soc_codec *codec) |
184 | { | 205 | { |
185 | snd_soc_update_bits(codec, AK4104_REG_CONTROL1, | 206 | struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); |
186 | AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, 0); | 207 | |
208 | regmap_update_bits(ak4104->regmap, AK4104_REG_CONTROL1, | ||
209 | AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, 0); | ||
187 | 210 | ||
188 | return 0; | 211 | return 0; |
189 | } | 212 | } |