diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-12-07 22:09:15 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-12-07 22:37:31 -0500 |
commit | 16b24881a031a653cd76b83bfd96ef2d30b2491b (patch) | |
tree | 2c290e01491187ffb4a8dfbe65f093e396a11cfc /sound/soc | |
parent | 4105ab846ca795f03e63fb7bfacafc4217f48ca8 (diff) |
ASoC: wm8960: Use snd_soc_update_bits for read-modify-write
Use snd_soc_update_bits for read-modify-write register access instead of
open-coding it using snd_soc_read and snd_soc_write
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/codecs/wm8960.c | 67 |
1 files changed, 21 insertions, 46 deletions
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 6a9c41d351de..2315b866d002 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c | |||
@@ -543,30 +543,24 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, | |||
543 | static int wm8960_mute(struct snd_soc_dai *dai, int mute) | 543 | static int wm8960_mute(struct snd_soc_dai *dai, int mute) |
544 | { | 544 | { |
545 | struct snd_soc_codec *codec = dai->codec; | 545 | struct snd_soc_codec *codec = dai->codec; |
546 | u16 mute_reg = snd_soc_read(codec, WM8960_DACCTL1) & 0xfff7; | ||
547 | 546 | ||
548 | if (mute) | 547 | if (mute) |
549 | snd_soc_write(codec, WM8960_DACCTL1, mute_reg | 0x8); | 548 | snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0x8); |
550 | else | 549 | else |
551 | snd_soc_write(codec, WM8960_DACCTL1, mute_reg); | 550 | snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0); |
552 | return 0; | 551 | return 0; |
553 | } | 552 | } |
554 | 553 | ||
555 | static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, | 554 | static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, |
556 | enum snd_soc_bias_level level) | 555 | enum snd_soc_bias_level level) |
557 | { | 556 | { |
558 | u16 reg; | ||
559 | |||
560 | switch (level) { | 557 | switch (level) { |
561 | case SND_SOC_BIAS_ON: | 558 | case SND_SOC_BIAS_ON: |
562 | break; | 559 | break; |
563 | 560 | ||
564 | case SND_SOC_BIAS_PREPARE: | 561 | case SND_SOC_BIAS_PREPARE: |
565 | /* Set VMID to 2x50k */ | 562 | /* Set VMID to 2x50k */ |
566 | reg = snd_soc_read(codec, WM8960_POWER1); | 563 | snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); |
567 | reg &= ~0x180; | ||
568 | reg |= 0x80; | ||
569 | snd_soc_write(codec, WM8960_POWER1, reg); | ||
570 | break; | 564 | break; |
571 | 565 | ||
572 | case SND_SOC_BIAS_STANDBY: | 566 | case SND_SOC_BIAS_STANDBY: |
@@ -579,23 +573,19 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, | |||
579 | WM8960_BUFDCOPEN | WM8960_BUFIOEN); | 573 | WM8960_BUFDCOPEN | WM8960_BUFIOEN); |
580 | 574 | ||
581 | /* Enable & ramp VMID at 2x50k */ | 575 | /* Enable & ramp VMID at 2x50k */ |
582 | reg = snd_soc_read(codec, WM8960_POWER1); | 576 | snd_soc_update_bits(codec, WM8960_POWER1, 0x80, 0x80); |
583 | reg |= 0x80; | ||
584 | snd_soc_write(codec, WM8960_POWER1, reg); | ||
585 | msleep(100); | 577 | msleep(100); |
586 | 578 | ||
587 | /* Enable VREF */ | 579 | /* Enable VREF */ |
588 | snd_soc_write(codec, WM8960_POWER1, reg | WM8960_VREF); | 580 | snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VREF, |
581 | WM8960_VREF); | ||
589 | 582 | ||
590 | /* Disable anti-pop features */ | 583 | /* Disable anti-pop features */ |
591 | snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN); | 584 | snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN); |
592 | } | 585 | } |
593 | 586 | ||
594 | /* Set VMID to 2x250k */ | 587 | /* Set VMID to 2x250k */ |
595 | reg = snd_soc_read(codec, WM8960_POWER1); | 588 | snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x100); |
596 | reg &= ~0x180; | ||
597 | reg |= 0x100; | ||
598 | snd_soc_write(codec, WM8960_POWER1, reg); | ||
599 | break; | 589 | break; |
600 | 590 | ||
601 | case SND_SOC_BIAS_OFF: | 591 | case SND_SOC_BIAS_OFF: |
@@ -787,10 +777,8 @@ static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
787 | 777 | ||
788 | /* Disable the PLL: even if we are changing the frequency the | 778 | /* Disable the PLL: even if we are changing the frequency the |
789 | * PLL needs to be disabled while we do so. */ | 779 | * PLL needs to be disabled while we do so. */ |
790 | snd_soc_write(codec, WM8960_CLOCK1, | 780 | snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0); |
791 | snd_soc_read(codec, WM8960_CLOCK1) & ~1); | 781 | snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0); |
792 | snd_soc_write(codec, WM8960_POWER2, | ||
793 | snd_soc_read(codec, WM8960_POWER2) & ~1); | ||
794 | 782 | ||
795 | if (!freq_in || !freq_out) | 783 | if (!freq_in || !freq_out) |
796 | return 0; | 784 | return 0; |
@@ -809,11 +797,9 @@ static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
809 | snd_soc_write(codec, WM8960_PLL1, reg); | 797 | snd_soc_write(codec, WM8960_PLL1, reg); |
810 | 798 | ||
811 | /* Turn it on */ | 799 | /* Turn it on */ |
812 | snd_soc_write(codec, WM8960_POWER2, | 800 | snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0x1); |
813 | snd_soc_read(codec, WM8960_POWER2) | 1); | ||
814 | msleep(250); | 801 | msleep(250); |
815 | snd_soc_write(codec, WM8960_CLOCK1, | 802 | snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0x1); |
816 | snd_soc_read(codec, WM8960_CLOCK1) | 1); | ||
817 | 803 | ||
818 | return 0; | 804 | return 0; |
819 | } | 805 | } |
@@ -913,7 +899,6 @@ static int wm8960_probe(struct snd_soc_codec *codec) | |||
913 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); | 899 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); |
914 | struct wm8960_data *pdata = dev_get_platdata(codec->dev); | 900 | struct wm8960_data *pdata = dev_get_platdata(codec->dev); |
915 | int ret; | 901 | int ret; |
916 | u16 reg; | ||
917 | 902 | ||
918 | wm8960->set_bias_level = wm8960_set_bias_level_out3; | 903 | wm8960->set_bias_level = wm8960_set_bias_level_out3; |
919 | 904 | ||
@@ -944,26 +929,16 @@ static int wm8960_probe(struct snd_soc_codec *codec) | |||
944 | wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 929 | wm8960->set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
945 | 930 | ||
946 | /* Latch the update bits */ | 931 | /* Latch the update bits */ |
947 | reg = snd_soc_read(codec, WM8960_LINVOL); | 932 | snd_soc_update_bits(codec, WM8960_LINVOL, 0x100, 0x100); |
948 | snd_soc_write(codec, WM8960_LINVOL, reg | 0x100); | 933 | snd_soc_update_bits(codec, WM8960_RINVOL, 0x100, 0x100); |
949 | reg = snd_soc_read(codec, WM8960_RINVOL); | 934 | snd_soc_update_bits(codec, WM8960_LADC, 0x100, 0x100); |
950 | snd_soc_write(codec, WM8960_RINVOL, reg | 0x100); | 935 | snd_soc_update_bits(codec, WM8960_RADC, 0x100, 0x100); |
951 | reg = snd_soc_read(codec, WM8960_LADC); | 936 | snd_soc_update_bits(codec, WM8960_LDAC, 0x100, 0x100); |
952 | snd_soc_write(codec, WM8960_LADC, reg | 0x100); | 937 | snd_soc_update_bits(codec, WM8960_RDAC, 0x100, 0x100); |
953 | reg = snd_soc_read(codec, WM8960_RADC); | 938 | snd_soc_update_bits(codec, WM8960_LOUT1, 0x100, 0x100); |
954 | snd_soc_write(codec, WM8960_RADC, reg | 0x100); | 939 | snd_soc_update_bits(codec, WM8960_ROUT1, 0x100, 0x100); |
955 | reg = snd_soc_read(codec, WM8960_LDAC); | 940 | snd_soc_update_bits(codec, WM8960_LOUT2, 0x100, 0x100); |
956 | snd_soc_write(codec, WM8960_LDAC, reg | 0x100); | 941 | snd_soc_update_bits(codec, WM8960_ROUT2, 0x100, 0x100); |
957 | reg = snd_soc_read(codec, WM8960_RDAC); | ||
958 | snd_soc_write(codec, WM8960_RDAC, reg | 0x100); | ||
959 | reg = snd_soc_read(codec, WM8960_LOUT1); | ||
960 | snd_soc_write(codec, WM8960_LOUT1, reg | 0x100); | ||
961 | reg = snd_soc_read(codec, WM8960_ROUT1); | ||
962 | snd_soc_write(codec, WM8960_ROUT1, reg | 0x100); | ||
963 | reg = snd_soc_read(codec, WM8960_LOUT2); | ||
964 | snd_soc_write(codec, WM8960_LOUT2, reg | 0x100); | ||
965 | reg = snd_soc_read(codec, WM8960_ROUT2); | ||
966 | snd_soc_write(codec, WM8960_ROUT2, reg | 0x100); | ||
967 | 942 | ||
968 | snd_soc_add_controls(codec, wm8960_snd_controls, | 943 | snd_soc_add_controls(codec, wm8960_snd_controls, |
969 | ARRAY_SIZE(wm8960_snd_controls)); | 944 | ARRAY_SIZE(wm8960_snd_controls)); |