summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/ypr0/backlight-ypr0.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/ypr0/backlight-ypr0.c')
-rw-r--r--firmware/target/hosted/ypr0/backlight-ypr0.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/firmware/target/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/ypr0/backlight-ypr0.c
new file mode 100644
index 0000000000..930b56be2e
--- /dev/null
+++ b/firmware/target/hosted/ypr0/backlight-ypr0.c
@@ -0,0 +1,89 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: backlight-gigabeat-s.c 25800 2010-05-04 10:07:53Z jethead71 $
9 *
10 * Copyright (C) 2011 by Lorenzo Miori
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "system.h"
23#include "backlight.h"
24#include "backlight-target.h"
25#include "lcd.h"
26#include "as3514.h"
27#include "ascodec-target.h"
28#include <fcntl.h>
29#include "unistd.h"
30
31static bool backlight_on_status = true; /* Is on or off? */
32
33/*TODO: see if LCD sleep could be implemented in a better way -> ie using a rockbox feature */
34/* Turn off LCD power supply */
35static void _backlight_lcd_sleep(void)
36{
37 int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
38 write(fp, "1", 1);
39 close(fp);
40}
41/* Turn on LCD screen */
42static void _backlight_lcd_power(void)
43{
44 int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
45 write(fp, "0", 1);
46 close(fp);
47}
48
49bool _backlight_init(void)
50{
51 /* We have nothing to do */
52 return true;
53}
54
55void _backlight_on(void)
56{
57 if (!backlight_on_status)
58 {
59 /* Turn on lcd power before backlight */
60 _backlight_lcd_power();
61 /* Original app sets this to 0xb1 when backlight is on... */
62 ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1);
63 }
64
65 backlight_on_status = true;
66
67}
68
69void _backlight_off(void)
70{
71 if (backlight_on_status) {
72 /* Disabling the DCDC15 completely, keeps brightness register value */
73 ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00);
74 /* Turn off lcd power then */
75 _backlight_lcd_sleep();
76 }
77
78 backlight_on_status = false;
79}
80
81void _backlight_set_brightness(int brightness)
82{
83 /* Just another check... */
84 if (brightness > MAX_BRIGHTNESS_SETTING)
85 brightness = MAX_BRIGHTNESS_SETTING;
86 if (brightness < MIN_BRIGHTNESS_SETTING)
87 brightness = MIN_BRIGHTNESS_SETTING;
88 ascodec_write_pmu(AS3543_BACKLIGHT, 0x3, brightness << 3 & 0xf8);
89}