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>
This commit is contained in:
parent
8ef8ea2da2
commit
2f9e3cae2c
|
@ -21,9 +21,12 @@
|
||||||
/* define this if you have a colour LCD */
|
/* define this if you have a colour LCD */
|
||||||
#define HAVE_LCD_COLOR
|
#define HAVE_LCD_COLOR
|
||||||
|
|
||||||
/* define this if the LCD needs to be shutdown */
|
/* Define this if the LCD can shut down */
|
||||||
#define HAVE_LCD_SHUTDOWN
|
#define HAVE_LCD_SHUTDOWN
|
||||||
|
|
||||||
|
/* define this if you have LCD enable function */
|
||||||
|
#define HAVE_LCD_ENABLE
|
||||||
|
|
||||||
/* define this if you want album art for this target */
|
/* define this if you want album art for this target */
|
||||||
#define HAVE_ALBUMART
|
#define HAVE_ALBUMART
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,8 @@
|
||||||
|
|
||||||
extern fb_data *dev_fb;
|
extern fb_data *dev_fb;
|
||||||
#define LCD_FRAMEBUF_ADDR(col, row) (dev_fb + row*LCD_WIDTH + col)
|
#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
|
#endif
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $
|
* $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Lorenzo Miori, Thomas Martitz
|
* Copyright (C) 2011 Lorenzo Miori, Thomas Martitz
|
||||||
|
* Copyright (C) 2013 Lorenzo Miori
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -22,26 +23,28 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "string.h"
|
|
||||||
#include <linux/fb.h>
|
#include <linux/fb.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include "config.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "screendump.h"
|
#include "screendump.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
#include "lcd-target.h"
|
||||||
|
|
||||||
static int dev_fd = 0;
|
static int dev_fd = 0;
|
||||||
fb_data *dev_fb = 0;
|
fb_data *dev_fb = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_SHUTDOWN
|
||||||
void lcd_shutdown(void)
|
void lcd_shutdown(void)
|
||||||
{
|
{
|
||||||
printf("FB closed.");
|
printf("FB closed.");
|
||||||
munmap(dev_fb, FRAMEBUFFER_SIZE);
|
munmap(dev_fb, FRAMEBUFFER_SIZE);
|
||||||
close(dev_fd);
|
close(dev_fd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void lcd_init_device(void)
|
void lcd_init_device(void)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +72,7 @@ void lcd_init_device(void)
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
vinfo.bits_per_pixel = 16;
|
vinfo.bits_per_pixel = LCD_DEPTH;
|
||||||
|
|
||||||
if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) {
|
if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) {
|
||||||
perror("fbset(ioctl)");
|
perror("fbset(ioctl)");
|
||||||
|
@ -80,8 +83,7 @@ void lcd_init_device(void)
|
||||||
|
|
||||||
/* Figure out the size of the screen in bytes */
|
/* Figure out the size of the screen in bytes */
|
||||||
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
|
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
|
||||||
if (screensize != FRAMEBUFFER_SIZE)
|
if (screensize != FRAMEBUFFER_SIZE) {
|
||||||
{
|
|
||||||
exit(4);
|
exit(4);
|
||||||
perror("Display and framebuffer mismatch!\n");
|
perror("Display and framebuffer mismatch!\n");
|
||||||
}
|
}
|
||||||
|
@ -93,4 +95,26 @@ void lcd_init_device(void)
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
printf("The framebuffer device was mapped to memory successfully.\n");
|
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
|
|
@ -29,22 +29,6 @@
|
||||||
|
|
||||||
static bool backlight_on_status = true; /* Is on or off? */
|
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)
|
bool _backlight_init(void)
|
||||||
{
|
{
|
||||||
/* We have nothing to do */
|
/* We have nothing to do */
|
||||||
|
@ -56,7 +40,9 @@ void _backlight_on(void)
|
||||||
if (!backlight_on_status)
|
if (!backlight_on_status)
|
||||||
{
|
{
|
||||||
/* Turn on lcd power before backlight */
|
/* 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... */
|
/* Original app sets this to 0xb1 when backlight is on... */
|
||||||
ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1);
|
ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1);
|
||||||
}
|
}
|
||||||
|
@ -67,11 +53,14 @@ void _backlight_on(void)
|
||||||
|
|
||||||
void _backlight_off(void)
|
void _backlight_off(void)
|
||||||
{
|
{
|
||||||
if (backlight_on_status) {
|
if (backlight_on_status)
|
||||||
|
{
|
||||||
/* Disabling the DCDC15 completely, keeps brightness register value */
|
/* Disabling the DCDC15 completely, keeps brightness register value */
|
||||||
ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00);
|
ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00);
|
||||||
/* Turn off lcd power then */
|
/* Turn off lcd power then */
|
||||||
_backlight_lcd_sleep();
|
#ifdef HAVE_LCD_ENABLE
|
||||||
|
lcd_enable(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
backlight_on_status = false;
|
backlight_on_status = false;
|
||||||
|
|
Loading…
Reference in New Issue