summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/backlight-gigabeat-s.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/backlight-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/backlight-gigabeat-s.c
index ec7bf7e8a9..ab14a3c025 100644
--- a/firmware/target/arm/imx31/gigabeat-s/backlight-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/backlight-gigabeat-s.c
@@ -71,8 +71,6 @@ static const struct
71 (MC13783_BOOSTEN | MC13783_ABMODE_MONCH_LEDMD1234 | \ 71 (MC13783_BOOSTEN | MC13783_ABMODE_MONCH_LEDMD1234 | \
72 MC13783_ABREF_400MV) 72 MC13783_ABREF_400MV)
73 73
74static struct mutex backlight_mutex; /* Block brightness change while
75 * setting up fading */
76static bool backlight_on_status = true; /* Is on or off? */ 74static bool backlight_on_status = true; /* Is on or off? */
77static uint32_t backlight_pwm_bits; /* Final PWM setting for fade-in */ 75static uint32_t backlight_pwm_bits; /* Final PWM setting for fade-in */
78 76
@@ -81,8 +79,6 @@ static uint32_t led_ramp_mask = MC13783_LEDMDRAMPDOWN | MC13783_LEDMDRAMPUP;
81 79
82bool _backlight_init(void) 80bool _backlight_init(void)
83{ 81{
84 mutex_init(&backlight_mutex);
85
86 /* Set default LED register value */ 82 /* Set default LED register value */
87 mc13783_write(MC13783_LED_CONTROL0, 83 mc13783_write(MC13783_LED_CONTROL0,
88 MC13783_LED_CONTROL0_BITS | MC13783_LEDEN); 84 MC13783_LED_CONTROL0_BITS | MC13783_LEDEN);
@@ -125,8 +121,6 @@ void _backlight_on(void)
125 121
126 uint32_t data[2]; 122 uint32_t data[2];
127 123
128 mutex_lock(&backlight_mutex);
129
130#ifdef HAVE_LCD_ENABLE 124#ifdef HAVE_LCD_ENABLE
131 lcd_enable(true); 125 lcd_enable(true);
132#endif 126#endif
@@ -151,16 +145,12 @@ void _backlight_on(void)
151 /* Write regs within 30us of each other (requires single xfer) */ 145 /* Write regs within 30us of each other (requires single xfer) */
152 mc13783_write_regset(regs, data, 2); 146 mc13783_write_regset(regs, data, 2);
153 } 147 }
154
155 mutex_unlock(&backlight_mutex);
156} 148}
157 149
158void _backlight_off(void) 150void _backlight_off(void)
159{ 151{
160 uint32_t ctrl0 = MC13783_LED_CONTROL0_BITS | MC13783_LEDEN; 152 uint32_t ctrl0 = MC13783_LED_CONTROL0_BITS | MC13783_LEDEN;
161 153
162 mutex_lock(&backlight_mutex);
163
164 if (backlight_on_status) 154 if (backlight_on_status)
165 ctrl0 |= led_ramp_mask & MC13783_LEDMDRAMPDOWN; 155 ctrl0 |= led_ramp_mask & MC13783_LEDMDRAMPDOWN;
166 156
@@ -176,8 +166,6 @@ void _backlight_off(void)
176 mc13783_write_masked(MC13783_LED_CONTROL2, 166 mc13783_write_masked(MC13783_LED_CONTROL2,
177 0 << MC13783_LEDMDDC_POS, 167 0 << MC13783_LEDMDDC_POS,
178 MC13783_LEDMDDC); 168 MC13783_LEDMDDC);
179
180 mutex_unlock(&backlight_mutex);
181} 169}
182 170
183#ifdef HAVE_BACKLIGHT_BRIGHTNESS 171#ifdef HAVE_BACKLIGHT_BRIGHTNESS
@@ -185,19 +173,13 @@ void _backlight_off(void)
185 * already be range-checked in public interface. */ 173 * already be range-checked in public interface. */
186void _backlight_set_brightness(int brightness) 174void _backlight_set_brightness(int brightness)
187{ 175{
188 uint32_t md; 176 uint32_t md = led_md_pwm_table[brightness].md;
189
190 mutex_lock(&backlight_mutex);
191
192 md = led_md_pwm_table[brightness].md;
193 backlight_pwm_bits = backlight_on_status ? 177 backlight_pwm_bits = backlight_on_status ?
194 (led_md_pwm_table[brightness].pwm << MC13783_LEDMDDC_POS) : 0; 178 (led_md_pwm_table[brightness].pwm << MC13783_LEDMDDC_POS) : 0;
195 179
196 mc13783_write_masked(MC13783_LED_CONTROL2, 180 mc13783_write_masked(MC13783_LED_CONTROL2,
197 (md << MC13783_LEDMD_POS) | backlight_pwm_bits, 181 (md << MC13783_LEDMD_POS) | backlight_pwm_bits,
198 MC13783_LEDMD | MC13783_LEDMDDC); 182 MC13783_LEDMD | MC13783_LEDMDDC);
199
200 mutex_unlock(&backlight_mutex);
201} 183}
202#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 184#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
203 185
@@ -205,10 +187,6 @@ void _backlight_set_brightness(int brightness)
205/* Turn off LED supply */ 187/* Turn off LED supply */
206void _backlight_lcd_sleep(void) 188void _backlight_lcd_sleep(void)
207{ 189{
208 mutex_lock(&backlight_mutex);
209
210 mc13783_clear(MC13783_LED_CONTROL0, MC13783_LEDEN); 190 mc13783_clear(MC13783_LED_CONTROL0, MC13783_LEDEN);
211
212 mutex_unlock(&backlight_mutex);
213} 191}
214#endif 192#endif