diff options
Diffstat (limited to 'firmware/drivers/audio')
-rw-r--r-- | firmware/drivers/audio/cs42l55.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/firmware/drivers/audio/cs42l55.c b/firmware/drivers/audio/cs42l55.c index e6ff771190..4d922d77d2 100644 --- a/firmware/drivers/audio/cs42l55.c +++ b/firmware/drivers/audio/cs42l55.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "cs42l55.h" | 30 | #include "cs42l55.h" |
31 | 31 | ||
32 | const struct sound_settings_info audiohw_settings[] = { | 32 | const struct sound_settings_info audiohw_settings[] = { |
33 | [SOUND_VOLUME] = {"dB", 0, 1, -58, 12, -25}, | 33 | [SOUND_VOLUME] = {"dB", 0, 1, -60, 12, -25}, |
34 | [SOUND_BASS] = {"dB", 1, 15,-105, 120, 0}, | 34 | [SOUND_BASS] = {"dB", 1, 15,-105, 120, 0}, |
35 | [SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0}, | 35 | [SOUND_TREBLE] = {"dB", 1, 15,-105, 120, 0}, |
36 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | 36 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, |
@@ -40,21 +40,22 @@ const struct sound_settings_info audiohw_settings[] = { | |||
40 | 40 | ||
41 | static int bass, treble; | 41 | static int bass, treble; |
42 | 42 | ||
43 | /* convert tenth of dB volume (-580..120) to master volume register value */ | 43 | /* convert tenth of dB volume (-600..120) to master volume register value */ |
44 | int tenthdb2master(int db) | 44 | int tenthdb2master(int db) |
45 | { | 45 | { |
46 | /* +12 to -58dB 1dB steps */ | 46 | /* -60dB to +12dB in 1dB steps */ |
47 | /* 0001100 == +12dB (0xc) */ | 47 | /* 0001100 == +12dB (0xc) */ |
48 | /* 0000000 == 0dB (0x0) */ | 48 | /* 0000000 == 0dB (0x0) */ |
49 | /* 1000100 == -58dB (0x44) */ | 49 | /* 1000100 == -60dB (0x44, this is actually -58dB) */ |
50 | 50 | ||
51 | if (db < VOLUME_MIN) return HPACTL_HPAMUTE; | 51 | if (db < VOLUME_MIN) return HPACTL_HPAMUTE; |
52 | return db & HPACTL_HPAVOL_MASK; | 52 | return (db / 10) & HPACTL_HPAVOL_MASK; |
53 | } | 53 | } |
54 | 54 | ||
55 | static void cscodec_setbits(int reg, unsigned char off, unsigned char on) | 55 | static void cscodec_setbits(int reg, unsigned char off, unsigned char on) |
56 | { | 56 | { |
57 | cscodec_write(reg, (cscodec_read(reg) & ~off) | on); | 57 | unsigned char data = (cscodec_read(reg) & ~off) | on; |
58 | cscodec_write(reg, data); | ||
58 | } | 59 | } |
59 | 60 | ||
60 | static void audiohw_mute(bool mute) | 61 | static void audiohw_mute(bool mute) |
@@ -122,10 +123,10 @@ void audiohw_postinit(void) | |||
122 | 123 | ||
123 | void audiohw_set_master_vol(int vol_l, int vol_r) | 124 | void audiohw_set_master_vol(int vol_l, int vol_r) |
124 | { | 125 | { |
125 | /* +12 to -58dB 1dB steps */ | 126 | /* -60dB to +12dB in 1dB steps */ |
126 | /* 0001100 == +12dB (0xc) */ | 127 | /* 0001100 == +12dB (0xc) */ |
127 | /* 0000000 == 0dB (0x0) */ | 128 | /* 0000000 == 0dB (0x0) */ |
128 | /* 1000100 == -58dB (0x44) */ | 129 | /* 1000100 == -60dB (0x44, this is actually -58dB) */ |
129 | 130 | ||
130 | cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK, vol_l << HPACTL_HPAVOL_SHIFT); | 131 | cscodec_setbits(HPACTL, HPACTL_HPAVOL_MASK, vol_l << HPACTL_HPAVOL_SHIFT); |
131 | cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK, vol_r << HPBCTL_HPBVOL_SHIFT); | 132 | cscodec_setbits(HPBCTL, HPBCTL_HPBVOL_MASK, vol_r << HPBCTL_HPBVOL_SHIFT); |
@@ -133,10 +134,10 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
133 | 134 | ||
134 | void audiohw_set_lineout_vol(int vol_l, int vol_r) | 135 | void audiohw_set_lineout_vol(int vol_l, int vol_r) |
135 | { | 136 | { |
136 | /* +12 to -58dB 1dB steps */ | 137 | /* -60dB to +12dB in 1dB steps */ |
137 | /* 0001100 == +12dB (0xc) */ | 138 | /* 0001100 == +12dB (0xc) */ |
138 | /* 0000000 == 0dB (0x0) */ | 139 | /* 0000000 == 0dB (0x0) */ |
139 | /* 1000100 == -58dB (0x44) */ | 140 | /* 1000100 == -60dB (0x44, this is actually -58dB) */ |
140 | 141 | ||
141 | cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK, | 142 | cscodec_setbits(LINEACTL, LINEACTL_LINEAVOL_MASK, |
142 | vol_l << LINEACTL_LINEAVOL_SHIFT); | 143 | vol_l << LINEACTL_LINEAVOL_SHIFT); |