1bc16babdda2c29e17fc9c30f9806ac7fb6f5087
[kugel-rb.git] / firmware / target / arm / as3525 / sansa-fuzev2 / backlight-fuzev2.c
blob1bc16babdda2c29e17fc9c30f9806ac7fb6f5087
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 by Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "config.h"
22 #include "backlight-target.h"
23 #include "system.h"
24 #include "lcd.h"
25 #include "backlight.h"
26 #include "ascodec-target.h"
27 #include "as3514.h"
29 int buttonlight_is_on = 0;
31 void _backlight_set_brightness(int brightness)
33 ascodec_write_pmu(AS3543_BACKLIGHT, 2, brightness * 10);
36 bool _backlight_init(void)
38 GPIOB_DIR |= 1<<5; /* for buttonlight, stuff below seems to be needed
39 for buttonlight as well*/
41 ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x80);
42 ascodec_write_pmu(AS3543_BACKLIGHT, 2, backlight_brightness * 10);
44 return true;
47 void _backlight_on(void)
49 #ifdef HAVE_LCD_ENABLE
50 lcd_enable(true); /* power on lcd + visible display */
51 #endif
52 ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x80);
55 void _backlight_off(void)
57 ascodec_write_pmu(AS3543_BACKLIGHT, 1, 0x0);
58 #ifdef HAVE_LCD_ENABLE
59 lcd_enable(false); /* power off visible display */
60 #endif
63 void _buttonlight_on(void)
65 GPIOB_PIN(5) = (1<<5);
66 buttonlight_is_on = 1;
69 void _buttonlight_off(void)
71 GPIOB_PIN(5) = 0;
72 buttonlight_is_on = 0;