summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/config/samsungypr0.h5
-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
4 files changed, 45 insertions, 26 deletions
diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h
index c81fc645bb..970879772f 100644
--- a/firmware/export/config/samsungypr0.h
+++ b/firmware/export/config/samsungypr0.h
@@ -21,9 +21,12 @@
21/* define this if you have a colour LCD */ 21/* define this if you have a colour LCD */
22#define HAVE_LCD_COLOR 22#define HAVE_LCD_COLOR
23 23
24/* define this if the LCD needs to be shutdown */ 24/* Define this if the LCD can shut down */
25#define HAVE_LCD_SHUTDOWN 25#define HAVE_LCD_SHUTDOWN
26 26
27/* define this if you have LCD enable function */
28#define HAVE_LCD_ENABLE
29
27/* define this if you want album art for this target */ 30/* define this if you want album art for this target */
28#define HAVE_ALBUMART 31#define HAVE_ALBUMART
29 32
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 @@
22 22
23extern fb_data *dev_fb; 23extern fb_data *dev_fb;
24#define LCD_FRAMEBUF_ADDR(col, row) (dev_fb + row*LCD_WIDTH + col) 24#define LCD_FRAMEBUF_ADDR(col, row) (dev_fb + row*LCD_WIDTH + col)
25 25#ifdef HAVE_LCD_ENABLE
26extern void lcd_set_active(bool active);
27extern void lcd_enable(bool enable);
28#endif
26#endif 29#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 @@
8 * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $ 8 * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $
9 * 9 *
10 * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz 10 * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz
11 * Copyright (C) 2013 Lorenzo Miori
11 * 12 *
12 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 14 * modify it under the terms of the GNU General Public License
@@ -22,26 +23,28 @@
22#include <stdlib.h> 23#include <stdlib.h>
23#include <unistd.h> 24#include <unistd.h>
24#include <stdio.h> 25#include <stdio.h>
25#include "string.h"
26#include <linux/fb.h> 26#include <linux/fb.h>
27#include <sys/mman.h> 27#include <sys/mman.h>
28#include <sys/ioctl.h> 28#include <sys/ioctl.h>
29 29#include "config.h"
30#include "file.h" 30#include "file.h"
31#include "debug.h" 31#include "debug.h"
32#include "system.h" 32#include "system.h"
33#include "screendump.h" 33#include "screendump.h"
34#include "lcd.h" 34#include "lcd.h"
35#include "lcd-target.h"
35 36
36static int dev_fd = 0; 37static int dev_fd = 0;
37fb_data *dev_fb = 0; 38fb_data *dev_fb = 0;
38 39
40#ifdef HAVE_LCD_SHUTDOWN
39void lcd_shutdown(void) 41void lcd_shutdown(void)
40{ 42{
41 printf("FB closed."); 43 printf("FB closed.");
42 munmap(dev_fb, FRAMEBUFFER_SIZE); 44 munmap(dev_fb, FRAMEBUFFER_SIZE);
43 close(dev_fd); 45 close(dev_fd);
44} 46}
47#endif
45 48
46void lcd_init_device(void) 49void lcd_init_device(void)
47{ 50{
@@ -69,7 +72,7 @@ void lcd_init_device(void)
69 exit(3); 72 exit(3);
70 } 73 }
71 74
72 vinfo.bits_per_pixel = 16; 75 vinfo.bits_per_pixel = LCD_DEPTH;
73 76
74 if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) { 77 if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) {
75 perror("fbset(ioctl)"); 78 perror("fbset(ioctl)");
@@ -80,8 +83,7 @@ void lcd_init_device(void)
80 83
81 /* Figure out the size of the screen in bytes */ 84 /* Figure out the size of the screen in bytes */
82 screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; 85 screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
83 if (screensize != FRAMEBUFFER_SIZE) 86 if (screensize != FRAMEBUFFER_SIZE) {
84 {
85 exit(4); 87 exit(4);
86 perror("Display and framebuffer mismatch!\n"); 88 perror("Display and framebuffer mismatch!\n");
87 } 89 }
@@ -93,4 +95,26 @@ void lcd_init_device(void)
93 exit(4); 95 exit(4);
94 } 96 }
95 printf("The framebuffer device was mapped to memory successfully.\n"); 97 printf("The framebuffer device was mapped to memory successfully.\n");
98
99 /* Be sure to turn on display at startup */
100 ioctl(dev_fd, FBIOBLANK, VESA_NO_BLANKING);
101#ifdef HAVE_LCD_ENABLE
102 lcd_set_active(true);
103#endif
104}
105
106#ifdef HAVE_LCD_ENABLE
107void lcd_enable(bool enable)
108 {
109 if (lcd_active() == enable)
110 return;
111
112 lcd_set_active(enable);
113
114 /* Turn on or off the display using Linux interface */
115 ioctl(dev_fd, FBIOBLANK, enable ? VESA_NO_BLANKING : VESA_POWERDOWN);
116
117 if (enable)
118 send_event(LCD_EVENT_ACTIVATION, NULL);
96} 119}
120#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 @@
29 29
30static bool backlight_on_status = true; /* Is on or off? */ 30static bool backlight_on_status = true; /* Is on or off? */
31 31
32/*TODO: see if LCD sleep could be implemented in a better way -> ie using a rockbox feature */
33/* Turn off LCD power supply */
34static void _backlight_lcd_sleep(void)
35{
36 int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
37 write(fp, "1", 1);
38 close(fp);
39}
40/* Turn on LCD screen */
41static void _backlight_lcd_power(void)
42{
43 int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
44 write(fp, "0", 1);
45 close(fp);
46}
47
48bool _backlight_init(void) 32bool _backlight_init(void)
49{ 33{
50 /* We have nothing to do */ 34 /* We have nothing to do */
@@ -56,7 +40,9 @@ void _backlight_on(void)
56 if (!backlight_on_status) 40 if (!backlight_on_status)
57 { 41 {
58 /* Turn on lcd power before backlight */ 42 /* Turn on lcd power before backlight */
59 _backlight_lcd_power(); 43#ifdef HAVE_LCD_ENABLE
44 lcd_enable(true);
45#endif
60 /* Original app sets this to 0xb1 when backlight is on... */ 46 /* Original app sets this to 0xb1 when backlight is on... */
61 ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1); 47 ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1);
62 } 48 }
@@ -67,11 +53,14 @@ void _backlight_on(void)
67 53
68void _backlight_off(void) 54void _backlight_off(void)
69{ 55{
70 if (backlight_on_status) { 56 if (backlight_on_status)
57 {
71 /* Disabling the DCDC15 completely, keeps brightness register value */ 58 /* Disabling the DCDC15 completely, keeps brightness register value */
72 ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00); 59 ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00);
73 /* Turn off lcd power then */ 60 /* Turn off lcd power then */
74 _backlight_lcd_sleep(); 61#ifdef HAVE_LCD_ENABLE
62 lcd_enable(false);
63#endif
75 } 64 }
76 65
77 backlight_on_status = false; 66 backlight_on_status = false;