diff options
-rw-r--r-- | sound/soc/codecs/cs4271.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index 237ece3f1046..5357ec5f5d7c 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c | |||
@@ -209,6 +209,7 @@ static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
209 | struct snd_soc_codec *codec = codec_dai->codec; | 209 | struct snd_soc_codec *codec = codec_dai->codec; |
210 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); | 210 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); |
211 | unsigned int val = 0; | 211 | unsigned int val = 0; |
212 | int ret; | ||
212 | 213 | ||
213 | switch (format & SND_SOC_DAIFMT_MASTER_MASK) { | 214 | switch (format & SND_SOC_DAIFMT_MASTER_MASK) { |
214 | case SND_SOC_DAIFMT_CBS_CFS: | 215 | case SND_SOC_DAIFMT_CBS_CFS: |
@@ -226,22 +227,27 @@ static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
226 | switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { | 227 | switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { |
227 | case SND_SOC_DAIFMT_LEFT_J: | 228 | case SND_SOC_DAIFMT_LEFT_J: |
228 | val |= CS4271_MODE1_DAC_DIF_LJ; | 229 | val |= CS4271_MODE1_DAC_DIF_LJ; |
229 | snd_soc_update_bits(codec, CS4271_ADCCTL, | 230 | ret = snd_soc_update_bits(codec, CS4271_ADCCTL, |
230 | CS4271_ADCCTL_ADC_DIF_MASK, CS4271_ADCCTL_ADC_DIF_LJ); | 231 | CS4271_ADCCTL_ADC_DIF_MASK, CS4271_ADCCTL_ADC_DIF_LJ); |
232 | if (ret < 0) | ||
233 | return ret; | ||
231 | break; | 234 | break; |
232 | case SND_SOC_DAIFMT_I2S: | 235 | case SND_SOC_DAIFMT_I2S: |
233 | val |= CS4271_MODE1_DAC_DIF_I2S; | 236 | val |= CS4271_MODE1_DAC_DIF_I2S; |
234 | snd_soc_update_bits(codec, CS4271_ADCCTL, | 237 | ret = snd_soc_update_bits(codec, CS4271_ADCCTL, |
235 | CS4271_ADCCTL_ADC_DIF_MASK, CS4271_ADCCTL_ADC_DIF_I2S); | 238 | CS4271_ADCCTL_ADC_DIF_MASK, CS4271_ADCCTL_ADC_DIF_I2S); |
239 | if (ret < 0) | ||
240 | return ret; | ||
236 | break; | 241 | break; |
237 | default: | 242 | default: |
238 | dev_err(codec->dev, "Invalid DAI format\n"); | 243 | dev_err(codec->dev, "Invalid DAI format\n"); |
239 | return -EINVAL; | 244 | return -EINVAL; |
240 | } | 245 | } |
241 | 246 | ||
242 | snd_soc_update_bits(codec, CS4271_MODE1, | 247 | ret = snd_soc_update_bits(codec, CS4271_MODE1, |
243 | CS4271_MODE1_DAC_DIF_MASK | CS4271_MODE1_MASTER, val); | 248 | CS4271_MODE1_DAC_DIF_MASK | CS4271_MODE1_MASTER, val); |
244 | 249 | if (ret < 0) | |
250 | return ret; | ||
245 | return 0; | 251 | return 0; |
246 | } | 252 | } |
247 | 253 | ||
@@ -250,7 +256,7 @@ static int cs4271_deemph[] = {0, 44100, 48000, 32000}; | |||
250 | static int cs4271_set_deemph(struct snd_soc_codec *codec) | 256 | static int cs4271_set_deemph(struct snd_soc_codec *codec) |
251 | { | 257 | { |
252 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); | 258 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); |
253 | int i; | 259 | int i, ret; |
254 | int val = CS4271_DACCTL_DEM_DIS; | 260 | int val = CS4271_DACCTL_DEM_DIS; |
255 | 261 | ||
256 | if (cs4271->deemph) { | 262 | if (cs4271->deemph) { |
@@ -263,8 +269,11 @@ static int cs4271_set_deemph(struct snd_soc_codec *codec) | |||
263 | val <<= 4; | 269 | val <<= 4; |
264 | } | 270 | } |
265 | 271 | ||
266 | return snd_soc_update_bits(codec, CS4271_DACCTL, | 272 | ret = snd_soc_update_bits(codec, CS4271_DACCTL, |
267 | CS4271_DACCTL_DEM_MASK, val); | 273 | CS4271_DACCTL_DEM_MASK, val); |
274 | if (ret < 0) | ||
275 | return ret; | ||
276 | return 0; | ||
268 | } | 277 | } |
269 | 278 | ||
270 | static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, | 279 | static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, |
@@ -294,7 +303,8 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream, | |||
294 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 303 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
295 | struct snd_soc_codec *codec = rtd->codec; | 304 | struct snd_soc_codec *codec = rtd->codec; |
296 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); | 305 | struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); |
297 | unsigned int i, ratio, val; | 306 | int i, ret; |
307 | unsigned int ratio, val; | ||
298 | 308 | ||
299 | cs4271->rate = params_rate(params); | 309 | cs4271->rate = params_rate(params); |
300 | ratio = cs4271->mclk / cs4271->rate; | 310 | ratio = cs4271->mclk / cs4271->rate; |
@@ -315,8 +325,10 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream, | |||
315 | else | 325 | else |
316 | val |= cs4271_clk_tab[i].mclk_slave; | 326 | val |= cs4271_clk_tab[i].mclk_slave; |
317 | 327 | ||
318 | snd_soc_update_bits(codec, CS4271_MODE1, | 328 | ret = snd_soc_update_bits(codec, CS4271_MODE1, |
319 | CS4271_MODE1_MODE_MASK | CS4271_MODE1_DIV_MASK, val); | 329 | CS4271_MODE1_MODE_MASK | CS4271_MODE1_DIV_MASK, val); |
330 | if (ret < 0) | ||
331 | return ret; | ||
320 | 332 | ||
321 | return cs4271_set_deemph(codec); | 333 | return cs4271_set_deemph(codec); |
322 | } | 334 | } |
@@ -324,6 +336,7 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream, | |||
324 | static int cs4271_digital_mute(struct snd_soc_dai *dai, int mute) | 336 | static int cs4271_digital_mute(struct snd_soc_dai *dai, int mute) |
325 | { | 337 | { |
326 | struct snd_soc_codec *codec = dai->codec; | 338 | struct snd_soc_codec *codec = dai->codec; |
339 | int ret; | ||
327 | int val_a = 0; | 340 | int val_a = 0; |
328 | int val_b = 0; | 341 | int val_b = 0; |
329 | 342 | ||
@@ -332,8 +345,12 @@ static int cs4271_digital_mute(struct snd_soc_dai *dai, int mute) | |||
332 | val_b = CS4271_VOLB_MUTE; | 345 | val_b = CS4271_VOLB_MUTE; |
333 | } | 346 | } |
334 | 347 | ||
335 | snd_soc_update_bits(codec, CS4271_VOLA, CS4271_VOLA_MUTE, val_a); | 348 | ret = snd_soc_update_bits(codec, CS4271_VOLA, CS4271_VOLA_MUTE, val_a); |
336 | snd_soc_update_bits(codec, CS4271_VOLB, CS4271_VOLB_MUTE, val_b); | 349 | if (ret < 0) |
350 | return ret; | ||
351 | ret = snd_soc_update_bits(codec, CS4271_VOLB, CS4271_VOLB_MUTE, val_b); | ||
352 | if (ret < 0) | ||
353 | return ret; | ||
337 | 354 | ||
338 | return 0; | 355 | return 0; |
339 | } | 356 | } |
@@ -392,17 +409,25 @@ struct snd_soc_dai_driver cs4271_dai = { | |||
392 | #ifdef CONFIG_PM | 409 | #ifdef CONFIG_PM |
393 | static int cs4271_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg) | 410 | static int cs4271_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg) |
394 | { | 411 | { |
412 | int ret; | ||
395 | /* Set power-down bit */ | 413 | /* Set power-down bit */ |
396 | snd_soc_update_bits(codec, CS4271_MODE2, 0, CS4271_MODE2_PDN); | 414 | ret = snd_soc_update_bits(codec, CS4271_MODE2, 0, CS4271_MODE2_PDN); |
415 | if (ret < 0) | ||
416 | return ret; | ||
397 | return 0; | 417 | return 0; |
398 | } | 418 | } |
399 | 419 | ||
400 | static int cs4271_soc_resume(struct snd_soc_codec *codec) | 420 | static int cs4271_soc_resume(struct snd_soc_codec *codec) |
401 | { | 421 | { |
422 | int ret; | ||
402 | /* Restore codec state */ | 423 | /* Restore codec state */ |
403 | snd_soc_cache_sync(codec); | 424 | ret = snd_soc_cache_sync(codec); |
425 | if (ret < 0) | ||
426 | return ret; | ||
404 | /* then disable the power-down bit */ | 427 | /* then disable the power-down bit */ |
405 | snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0); | 428 | ret = snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0); |
429 | if (ret < 0) | ||
430 | return ret; | ||
406 | return 0; | 431 | return 0; |
407 | } | 432 | } |
408 | #else | 433 | #else |
@@ -467,9 +492,13 @@ static int cs4271_probe(struct snd_soc_codec *codec) | |||
467 | return ret; | 492 | return ret; |
468 | } | 493 | } |
469 | 494 | ||
470 | snd_soc_update_bits(codec, CS4271_MODE2, 0, | 495 | ret = snd_soc_update_bits(codec, CS4271_MODE2, 0, |
471 | CS4271_MODE2_PDN | CS4271_MODE2_CPEN); | 496 | CS4271_MODE2_PDN | CS4271_MODE2_CPEN); |
472 | snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0); | 497 | if (ret < 0) |
498 | return ret; | ||
499 | ret = snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0); | ||
500 | if (ret < 0) | ||
501 | return ret; | ||
473 | /* Power-up sequence requires 85 uS */ | 502 | /* Power-up sequence requires 85 uS */ |
474 | udelay(85); | 503 | udelay(85); |
475 | 504 | ||