Fuzev2: cleanup backlight code (still not working correctly)
[kugel-rb.git] / firmware / target / arm / as3525 / sansa-fuzev2 / backlight-fuzev2.c
blobb1ec9b79e46097908c7a91494cdbdfe9bd151d8b
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 static int brightness_internal = 0;
33 /* not functional */
34 void _backlight_set_brightness(int brightness)
36 //ascodec_write(AS3514_DCDC15, brightness);
37 brightness_internal = brightness << 2;
38 brightness_internal += brightness + 5;
39 brightness_internal <<= 25;
40 brightness_internal >>= 24;
41 ascodec_write(0x1c, 2); // sub register
42 ascodec_write(0x1b, brightness_internal|0xff);
45 bool _backlight_init(void)
47 GPIOB_DIR |= 1<<5; /* for buttonlight, stuff below seems to be needed
48 for buttonlight as well*/
49 ascodec_write(0x1c, 1); // sub register
50 ascodec_write(0x1b, ascodec_read(0x1b)|0x80);
51 return true;
54 /* not functional */
55 void _backlight_on(void)
57 #ifdef HAVE_LCD_ENABLE
58 lcd_enable(true); /* power on lcd + visible display */
59 #endif
60 #if (CONFIG_BACKLIGHT_FADING != BACKLIGHT_FADING_SW_SETTING) /* in bootloader/sim */
61 /* if we set the brightness to the settings value, then fading up
62 * is glitchy */
63 ascodec_write(0x1c, 2); // sub register
64 ascodec_write(0x1b, brightness_internal);
65 #endif
68 /* not functional */
69 void _backlight_off(void)
71 ascodec_write(0x1c, 1); // sub register
72 ascodec_write(0x1b, ascodec_read(0x1b) & ~0x80);
73 #ifdef HAVE_LCD_ENABLE
74 lcd_enable(false); /* power off visible display */
75 #endif
78 void _buttonlight_on(void)
80 GPIOB_PIN(5) = (1<<5);
81 buttonlight_is_on = 1;
84 void _buttonlight_off(void)
86 GPIOB_PIN(5) = 0;
87 buttonlight_is_on = 0;