diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-04-26 23:14:31 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-04-26 23:14:31 +0000 |
commit | 7d8069d2e75a9c0d3150377d095f41476277abc3 (patch) | |
tree | 333fb9343295673d74805b785b4dd1e45e92e0e8 | |
parent | 9bf33e9458183ff93dcaf2ff25d4c058014afdc2 (diff) | |
download | rockbox-7d8069d2e75a9c0d3150377d095f41476277abc3.tar.gz rockbox-7d8069d2e75a9c0d3150377d095f41476277abc3.zip |
as3514: no need to cache volume
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25730 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/audio/as3514.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index 04acaf27d2..a996610899 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c | |||
@@ -79,16 +79,11 @@ const struct sound_settings_info audiohw_settings[] = { | |||
79 | }; | 79 | }; |
80 | 80 | ||
81 | /* Shadow registers */ | 81 | /* Shadow registers */ |
82 | static struct as3514_info | 82 | static uint8_t as3514_regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */ |
83 | { | ||
84 | int vol_r; /* Cached volume level (R) */ | ||
85 | int vol_l; /* Cached volume level (L) */ | ||
86 | uint8_t regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */ | ||
87 | } as3514; | ||
88 | 83 | ||
89 | /* | 84 | /* |
90 | * little helper method to set register values. | 85 | * little helper method to set register values. |
91 | * With the help of as3514.regs, we minimize i2c | 86 | * With the help of as3514_regs, we minimize i2c |
92 | * traffic. | 87 | * traffic. |
93 | */ | 88 | */ |
94 | static void as3514_write(unsigned int reg, unsigned int value) | 89 | static void as3514_write(unsigned int reg, unsigned int value) |
@@ -98,9 +93,9 @@ static void as3514_write(unsigned int reg, unsigned int value) | |||
98 | DEBUGF("as3514 error reg=0x%02x", reg); | 93 | DEBUGF("as3514 error reg=0x%02x", reg); |
99 | } | 94 | } |
100 | 95 | ||
101 | if (reg < ARRAYLEN(as3514.regs)) | 96 | if (reg < ARRAYLEN(as3514_regs)) |
102 | { | 97 | { |
103 | as3514.regs[reg] = value; | 98 | as3514_regs[reg] = value; |
104 | } | 99 | } |
105 | else | 100 | else |
106 | { | 101 | { |
@@ -111,18 +106,18 @@ static void as3514_write(unsigned int reg, unsigned int value) | |||
111 | /* Helpers to set/clear bits */ | 106 | /* Helpers to set/clear bits */ |
112 | static void as3514_set(unsigned int reg, unsigned int bits) | 107 | static void as3514_set(unsigned int reg, unsigned int bits) |
113 | { | 108 | { |
114 | as3514_write(reg, as3514.regs[reg] | bits); | 109 | as3514_write(reg, as3514_regs[reg] | bits); |
115 | } | 110 | } |
116 | 111 | ||
117 | static void as3514_clear(unsigned int reg, unsigned int bits) | 112 | static void as3514_clear(unsigned int reg, unsigned int bits) |
118 | { | 113 | { |
119 | as3514_write(reg, as3514.regs[reg] & ~bits); | 114 | as3514_write(reg, as3514_regs[reg] & ~bits); |
120 | } | 115 | } |
121 | 116 | ||
122 | static void as3514_write_masked(unsigned int reg, unsigned int bits, | 117 | static void as3514_write_masked(unsigned int reg, unsigned int bits, |
123 | unsigned int mask) | 118 | unsigned int mask) |
124 | { | 119 | { |
125 | as3514_write(reg, (as3514.regs[reg] & ~mask) | (bits & mask)); | 120 | as3514_write(reg, (as3514_regs[reg] & ~mask) | (bits & mask)); |
126 | } | 121 | } |
127 | 122 | ||
128 | /* convert tenth of dB volume to master volume register value */ | 123 | /* convert tenth of dB volume to master volume register value */ |
@@ -168,9 +163,9 @@ void audiohw_preinit(void) | |||
168 | unsigned int i; | 163 | unsigned int i; |
169 | 164 | ||
170 | /* read all reg values */ | 165 | /* read all reg values */ |
171 | for (i = 0; i < ARRAYLEN(as3514.regs); i++) | 166 | for (i = 0; i < ARRAYLEN(as3514_regs); i++) |
172 | { | 167 | { |
173 | as3514.regs[i] = ascodec_read(i); | 168 | as3514_regs[i] = ascodec_read(i); |
174 | } | 169 | } |
175 | 170 | ||
176 | /* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */ | 171 | /* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */ |
@@ -251,10 +246,6 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
251 | unsigned int hph_r, hph_l; | 246 | unsigned int hph_r, hph_l; |
252 | unsigned int mix_l, mix_r; | 247 | unsigned int mix_l, mix_r; |
253 | 248 | ||
254 | /* keep track of current setting */ | ||
255 | as3514.vol_l = vol_l; | ||
256 | as3514.vol_r = vol_r; | ||
257 | |||
258 | /* We combine the mixer channel volume range with the headphone volume | 249 | /* We combine the mixer channel volume range with the headphone volume |
259 | range - keep first stage as loud as possible */ | 250 | range - keep first stage as loud as possible */ |
260 | if (vol_r <= 0x16) { | 251 | if (vol_r <= 0x16) { |