summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted
diff options
context:
space:
mode:
authorLorenzo Miori <memorys60@gmail.com>2013-03-06 22:24:40 +0100
committerThomas Martitz <kugel@rockbox.org>2013-03-06 23:23:52 +0100
commit2f9e3cae2c567185a501f4e2a301665452a83350 (patch)
treed7f13e767bd794d6157d50aeb3d68383dc25a137 /firmware/target/hosted
parent8ef8ea2da2fb800832293054dd41be342f77764d (diff)
downloadrockbox-2f9e3cae2c567185a501f4e2a301665452a83350.tar.gz
rockbox-2f9e3cae2c567185a501f4e2a301665452a83350.zip
Samsung YP-R0 LCD improvements
This patch adds to YP-R0 (and other future targets using Linux framebuffer) the ability to use LCD_ENABLE to save some CPU cycles while display is powered off. This patch also changes the way to toggle LCD power: now using a proper ioctl call, slightly more efficient. Change-Id: I544de77f5abd4ac1c13d3fe3a6e40a30f7c0bece Reviewed-on: http://gerrit.rockbox.org/410 Reviewed-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r--firmware/target/hosted/samsungypr/lcd-target.h5
-rw-r--r--firmware/target/hosted/samsungypr/lcd-ypr.c34
-rw-r--r--firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c27
3 files changed, 41 insertions, 25 deletions
diff --git a/firmware/target/hosted/samsungypr/lcd-target.h b/firmware/target/hosted/samsungypr/lcd-target.h
index c8a6de74f9..900350eca2 100644
--- a/firmware/target/hosted/samsungypr/lcd-target.h
+++ b/firmware/target/hosted/samsungypr/lcd-target.h
@@ -22,5 +22,8 @@
extern fb_data *dev_fb;
#define LCD_FRAMEBUF_ADDR(col, row) (dev_fb + row*LCD_WIDTH + col)
-
+#ifdef HAVE_LCD_ENABLE
+extern void lcd_set_active(bool active);
+extern void lcd_enable(bool enable);
+#endif
#endif
diff --git a/firmware/target/hosted/samsungypr/lcd-ypr.c b/firmware/target/hosted/samsungypr/lcd-ypr.c
index 40528c298a..8d9bfefbec 100644
--- a/firmware/target/hosted/samsungypr/lcd-ypr.c
+++ b/firmware/target/hosted/samsungypr/lcd-ypr.c
@@ -8,6 +8,7 @@
* $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $
*
* Copyright (C) 2011 Lorenzo Miori, Thomas Martitz
+ * Copyright (C) 2013 Lorenzo Miori
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -22,26 +23,28 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
-#include "string.h"
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
-
+#include "config.h"
#include "file.h"
#include "debug.h"
#include "system.h"
#include "screendump.h"
#include "lcd.h"
+#include "lcd-target.h"
static int dev_fd = 0;
fb_data *dev_fb = 0;
+#ifdef HAVE_LCD_SHUTDOWN
void lcd_shutdown(void)
{
printf("FB closed.");
munmap(dev_fb, FRAMEBUFFER_SIZE);
close(dev_fd);
}
+#endif
void lcd_init_device(void)
{
@@ -69,7 +72,7 @@ void lcd_init_device(void)
exit(3);
}
- vinfo.bits_per_pixel = 16;
+ vinfo.bits_per_pixel = LCD_DEPTH;
if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) {
perror("fbset(ioctl)");
@@ -80,8 +83,7 @@ void lcd_init_device(void)
/* Figure out the size of the screen in bytes */
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
- if (screensize != FRAMEBUFFER_SIZE)
- {
+ if (screensize != FRAMEBUFFER_SIZE) {
exit(4);
perror("Display and framebuffer mismatch!\n");
}
@@ -93,4 +95,26 @@ void lcd_init_device(void)
exit(4);
}
printf("The framebuffer device was mapped to memory successfully.\n");
+
+ /* Be sure to turn on display at startup */
+ ioctl(dev_fd, FBIOBLANK, VESA_NO_BLANKING);
+#ifdef HAVE_LCD_ENABLE
+ lcd_set_active(true);
+#endif
+}
+
+#ifdef HAVE_LCD_ENABLE
+void lcd_enable(bool enable)
+ {
+ if (lcd_active() == enable)
+ return;
+
+ lcd_set_active(enable);
+
+ /* Turn on or off the display using Linux interface */
+ ioctl(dev_fd, FBIOBLANK, enable ? VESA_NO_BLANKING : VESA_POWERDOWN);
+
+ if (enable)
+ send_event(LCD_EVENT_ACTIVATION, NULL);
}
+#endif \ No newline at end of file
diff --git a/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c
index 551b386f19..5555b30473 100644
--- a/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c
+++ b/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c
@@ -29,22 +29,6 @@
static bool backlight_on_status = true; /* Is on or off? */
-/*TODO: see if LCD sleep could be implemented in a better way -> ie using a rockbox feature */
-/* Turn off LCD power supply */
-static void _backlight_lcd_sleep(void)
-{
- int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
- write(fp, "1", 1);
- close(fp);
-}
-/* Turn on LCD screen */
-static void _backlight_lcd_power(void)
-{
- int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
- write(fp, "0", 1);
- close(fp);
-}
-
bool _backlight_init(void)
{
/* We have nothing to do */
@@ -56,7 +40,9 @@ void _backlight_on(void)
if (!backlight_on_status)
{
/* Turn on lcd power before backlight */
- _backlight_lcd_power();
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(true);
+#endif
/* Original app sets this to 0xb1 when backlight is on... */
ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1);
}
@@ -67,11 +53,14 @@ void _backlight_on(void)
void _backlight_off(void)
{
- if (backlight_on_status) {
+ if (backlight_on_status)
+ {
/* Disabling the DCDC15 completely, keeps brightness register value */
ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00);
/* Turn off lcd power then */
- _backlight_lcd_sleep();
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(false);
+#endif
}
backlight_on_status = false;