wm8731.c (af1910a817c5ad52c32dddacc1744cfa1b35889e) wm8731.c (9bf311fe17f16effaf264af76cb3aaaf384556b3)
1/*
2 * wm8731.c -- WM8731 ALSA SoC Audio driver
3 *
4 * Copyright 2005 Openedhand Ltd.
5 *
6 * Author: Richard Purdie <richard@openedhand.com>
7 *
8 * Based on wm8753.c by Liam Girdwood

--- 413 unchanged lines hidden (view full) ---

422 snd_soc_write(codec, WM8731_IFACE, iface);
423 return 0;
424}
425
426static int wm8731_set_bias_level(struct snd_soc_codec *codec,
427 enum snd_soc_bias_level level)
428{
429 struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
1/*
2 * wm8731.c -- WM8731 ALSA SoC Audio driver
3 *
4 * Copyright 2005 Openedhand Ltd.
5 *
6 * Author: Richard Purdie <richard@openedhand.com>
7 *
8 * Based on wm8753.c by Liam Girdwood

--- 413 unchanged lines hidden (view full) ---

422 snd_soc_write(codec, WM8731_IFACE, iface);
423 return 0;
424}
425
426static int wm8731_set_bias_level(struct snd_soc_codec *codec,
427 enum snd_soc_bias_level level)
428{
429 struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
430 int i, ret;
431 u8 data[2];
432 u16 *cache = codec->reg_cache;
430 int ret;
433 u16 reg;
434
435 switch (level) {
436 case SND_SOC_BIAS_ON:
437 break;
438 case SND_SOC_BIAS_PREPARE:
439 break;
440 case SND_SOC_BIAS_STANDBY:
441 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
442 ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies),
443 wm8731->supplies);
444 if (ret != 0)
445 return ret;
446
431 u16 reg;
432
433 switch (level) {
434 case SND_SOC_BIAS_ON:
435 break;
436 case SND_SOC_BIAS_PREPARE:
437 break;
438 case SND_SOC_BIAS_STANDBY:
439 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
440 ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies),
441 wm8731->supplies);
442 if (ret != 0)
443 return ret;
444
447 /* Sync reg_cache with the hardware */
448 for (i = 0; i < ARRAY_SIZE(wm8731_reg); i++) {
449 if (cache[i] == wm8731_reg[i])
450 continue;
451
452 data[0] = (i << 1) | ((cache[i] >> 8)
453 & 0x0001);
454 data[1] = cache[i] & 0x00ff;
455 codec->hw_write(codec->control_data, data, 2);
456 }
445 snd_soc_cache_sync(codec);
457 }
458
459 /* Clear PWROFF, gate CLKOUT, everything else as-is */
460 reg = snd_soc_read(codec, WM8731_PWR) & 0xff7f;
461 snd_soc_write(codec, WM8731_PWR, reg | 0x0040);
462 break;
463 case SND_SOC_BIAS_OFF:
464 snd_soc_write(codec, WM8731_PWR, 0xffff);

--- 272 unchanged lines hidden ---
446 }
447
448 /* Clear PWROFF, gate CLKOUT, everything else as-is */
449 reg = snd_soc_read(codec, WM8731_PWR) & 0xff7f;
450 snd_soc_write(codec, WM8731_PWR, reg | 0x0040);
451 break;
452 case SND_SOC_BIAS_OFF:
453 snd_soc_write(codec, WM8731_PWR, 0xffff);

--- 272 unchanged lines hidden ---