summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/SOURCES4
-rw-r--r--firmware/target/hosted/lcd-linuxfb.c (renamed from firmware/target/hosted/agptek/lcd-agptek.c)12
-rw-r--r--firmware/target/hosted/xduoo/lcd-xduoo.c140
3 files changed, 12 insertions, 144 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 7be6010ab7..459006e5a7 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -124,12 +124,12 @@ target/hosted/lc-unix.c
124target/hosted/sysfs.c 124target/hosted/sysfs.c
125target/hosted/backlight-unix.c 125target/hosted/backlight-unix.c
126target/hosted/system-hosted.c 126target/hosted/system-hosted.c
127target/hosted/lcd-linuxfb.c
127#endif 128#endif
128 129
129#if defined(AGPTEK_ROCKER) && !defined(SIMULATOR) 130#if defined(AGPTEK_ROCKER) && !defined(SIMULATOR)
130target/hosted/agptek/button-agptek.c 131target/hosted/agptek/button-agptek.c
131target/hosted/agptek/debug-agptek.c 132target/hosted/agptek/debug-agptek.c
132target/hosted/agptek/lcd-agptek.c
133target/hosted/agptek/power-agptek.c 133target/hosted/agptek/power-agptek.c
134target/hosted/agptek/powermgmt-agptek.c 134target/hosted/agptek/powermgmt-agptek.c
135target/hosted/agptek/usb-agptek.c 135target/hosted/agptek/usb-agptek.c
@@ -138,7 +138,7 @@ target/hosted/agptek/usb-agptek.c
138#if ((defined(XDUOO_X3II)||defined(XDUOO_X20)) && !defined(SIMULATOR)) 138#if ((defined(XDUOO_X3II)||defined(XDUOO_X20)) && !defined(SIMULATOR))
139target/hosted/xduoo/button-xduoo.c 139target/hosted/xduoo/button-xduoo.c
140target/hosted/xduoo/debug-xduoo.c 140target/hosted/xduoo/debug-xduoo.c
141target/hosted/xduoo/lcd-xduoo.c 141
142target/hosted/xduoo/power-xduoo.c 142target/hosted/xduoo/power-xduoo.c
143target/hosted/xduoo/powermgmt-xduoo.c 143target/hosted/xduoo/powermgmt-xduoo.c
144target/hosted/xduoo/usb-xduoo.c 144target/hosted/xduoo/usb-xduoo.c
diff --git a/firmware/target/hosted/agptek/lcd-agptek.c b/firmware/target/hosted/lcd-linuxfb.c
index 9cd4daea5d..6a3aa36b5d 100644
--- a/firmware/target/hosted/agptek/lcd-agptek.c
+++ b/firmware/target/hosted/lcd-linuxfb.c
@@ -92,10 +92,14 @@ void lcd_enable(bool on)
92{ 92{
93 const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank"; 93 const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank";
94 94
95#ifdef HAVE_LCD_SLEEP
95 if (lcd_active() != on) 96 if (lcd_active() != on)
97#endif
96 { 98 {
97 sysfs_set_int(sysfs_fb_blank, on ? 0 : 1); 99 sysfs_set_int(sysfs_fb_blank, on ? 0 : 1);
100#ifdef HAVE_LCD_ENABLE
98 lcd_set_active(on); 101 lcd_set_active(on);
102#endif
99 103
100 if (on) 104 if (on)
101 { 105 {
@@ -114,7 +118,9 @@ extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
114 118
115void lcd_update(void) 119void lcd_update(void)
116{ 120{
117 if (lcd_active()) 121#ifdef HAVE_LCD_SLEEP
122 if (lcd_active() != on)
123#endif
118 { 124 {
119 /* Copy the Rockbox framebuffer to the second framebuffer */ 125 /* Copy the Rockbox framebuffer to the second framebuffer */
120 lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0), 126 lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0),
@@ -125,7 +131,9 @@ void lcd_update(void)
125 131
126void lcd_update_rect(int x, int y, int width, int height) 132void lcd_update_rect(int x, int y, int width, int height)
127{ 133{
128 if (lcd_active()) 134#ifdef HAVE_LCD_SLEEP
135 if (lcd_active() != on)
136#endif
129 { 137 {
130 fb_data *dst = LCD_FRAMEBUF_ADDR(x, y); 138 fb_data *dst = LCD_FRAMEBUF_ADDR(x, y);
131 fb_data * src = FBADDR(x,y); 139 fb_data * src = FBADDR(x,y);
diff --git a/firmware/target/hosted/xduoo/lcd-xduoo.c b/firmware/target/hosted/xduoo/lcd-xduoo.c
deleted file mode 100644
index 4b3148da03..0000000000
--- a/firmware/target/hosted/xduoo/lcd-xduoo.c
+++ /dev/null
@@ -1,140 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 * Copyright (C) 2016 Amaury Pouly
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
22#include <stdlib.h>
23#include <unistd.h>
24#include <stdio.h>
25#include <linux/fb.h>
26#include <sys/mman.h>
27#include <sys/ioctl.h>
28#include <fcntl.h>
29#include "lcd.h"
30#include "lcd-target.h"
31#include "backlight-target.h"
32#include "sysfs.h"
33#include "panic.h"
34
35static int fd = -1;
36static struct fb_var_screeninfo vinfo;
37fb_data *framebuffer = 0; /* global variable, see lcd-target.h */
38
39void lcd_init_device(void)
40{
41 const char * const fb_dev = "/dev/fb0";
42 fd = open(fb_dev, O_RDWR);
43 if(fd < 0)
44 {
45 panicf("Cannot open framebuffer: %s\n", fb_dev);
46 }
47
48 /* get fixed and variable information */
49 struct fb_fix_screeninfo finfo;
50 if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0)
51 {
52 panicf("Cannot read framebuffer fixed information");
53 }
54
55 if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
56 {
57 panicf("Cannot read framebuffer variable information");
58 }
59
60#if 0
61 /* check resolution and framebuffer size */
62 if(vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT || vinfo.bits_per_pixel != LCD_DEPTH)
63 {
64 panicf("Unexpected framebuffer resolution: %dx%dx%d\n", vinfo.xres,
65 vinfo.yres, vinfo.bits_per_pixel);
66 }
67#endif
68 /* Note: we use a framebuffer size of width*height*bbp. We cannot trust the
69 * values returned by the driver for line_length */
70
71 /* map framebuffer */
72 framebuffer = mmap(0, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
73 if((void *)framebuffer == MAP_FAILED)
74 {
75 panicf("Cannot map framebuffer");
76 }
77
78#ifdef HAVE_LCD_ENABLE
79 lcd_set_active(true);
80#endif
81}
82
83#ifdef HAVE_LCD_SHUTDOWN
84void lcd_shutdown(void)
85{
86 munmap(framebuffer, FRAMEBUFFER_SIZE);
87 close(fd);
88}
89#endif
90
91void lcd_enable(bool on)
92{
93 const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank";
94
95 if (lcd_active() != on)
96 {
97 sysfs_set_int(sysfs_fb_blank, on ? 0 : 1);
98 lcd_set_active(on);
99
100 if (on)
101 {
102 send_event(LCD_EVENT_ACTIVATION, NULL);
103 }
104 }
105}
106
107static void redraw(void)
108{
109 ioctl(fd, FBIOPAN_DISPLAY, &vinfo);
110}
111
112extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
113 int width, int height);
114
115void lcd_update(void)
116{
117 /* Copy the Rockbox framebuffer to the second framebuffer */
118 lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0),
119 LCD_WIDTH*LCD_HEIGHT, 1);
120 redraw();
121}
122
123void lcd_update_rect(int x, int y, int width, int height)
124{
125 fb_data *dst = LCD_FRAMEBUF_ADDR(x, y);
126 fb_data * src = FBADDR(x,y);
127
128 /* Copy part of the Rockbox framebuffer to the second framebuffer */
129 if (width < LCD_WIDTH)
130 {
131 /* Not full width - do line-by-line */
132 lcd_copy_buffer_rect(dst, src, width, height);
133 }
134 else
135 {
136 /* Full width - copy as one line */
137 lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
138 }
139 redraw();
140}