1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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 ****************************************************************************/
34 #include "backlight.h"
35 #include "backlight-target.h"
37 /* Index 0 is a dummy, 1..31 are used */
38 static unsigned char log_brightness
[32] = {
39 0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36,
40 42, 49, 56, 64, 72, 81, 90, 100, 110, 121, 132, 144,
41 156, 169, 182, 196, 210, 225, 240, 255
44 static unsigned brightness
= 100; /* 1 to 255 */
45 static bool enabled
= false;
47 /* Handling B03 in _backlight_on() and _backlight_off() makes backlight go off
48 * without delay. Not doing that does a short (fixed) fade out. Opt for the
51 void _backlight_on(void)
54 outl(0x80000000 | (brightness
<< 16), 0x7000a010);
55 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL
, 0x08);
59 void _backlight_off(void)
61 outl(0x80000000, 0x7000a010);
62 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL
, 0x08);
66 void _backlight_set_brightness(int val
)
68 brightness
= log_brightness
[val
];
70 outl(0x80000000 | (brightness
<< 16), 0x7000a010);
73 bool _backlight_init(void)
75 GPIO_SET_BITWISE(GPIOB_ENABLE
, 0x0c); /* B02 and B03 enable */
76 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL
, 0x08); /* B03 = 1 */
77 GPO32_ENABLE
&= ~0x2000000; /* D01 disable, so pwm takes over */
78 DEV_EN
|= DEV_PWM
; /* PWM enable */