diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-04-08 09:53:13 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-04-08 15:56:06 +0200 |
commit | 53b93ea6a60cf8900c88e00f774693dea9a4f297 (patch) | |
tree | e4370674e13dc6c1a9d71479707ff8e44c15a0ab | |
parent | 6fcd69a365365ad828410d0c58970e8bef9112b6 (diff) | |
download | rockbox-53b93ea6a60cf8900c88e00f774693dea9a4f297.tar.gz rockbox-53b93ea6a60cf8900c88e00f774693dea9a4f297.zip |
hiby: Refactor X3ii/X20 and Rocker LCD code
Once some missing power optimization stuff was added to the X3ii code,
they were completely identical.
Change-Id: I68e4db5e270e8ff22f91e521616a054bd7baa95d
-rw-r--r-- | firmware/SOURCES | 4 | ||||
-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.c | 140 |
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 | |||
124 | target/hosted/sysfs.c | 124 | target/hosted/sysfs.c |
125 | target/hosted/backlight-unix.c | 125 | target/hosted/backlight-unix.c |
126 | target/hosted/system-hosted.c | 126 | target/hosted/system-hosted.c |
127 | target/hosted/lcd-linuxfb.c | ||
127 | #endif | 128 | #endif |
128 | 129 | ||
129 | #if defined(AGPTEK_ROCKER) && !defined(SIMULATOR) | 130 | #if defined(AGPTEK_ROCKER) && !defined(SIMULATOR) |
130 | target/hosted/agptek/button-agptek.c | 131 | target/hosted/agptek/button-agptek.c |
131 | target/hosted/agptek/debug-agptek.c | 132 | target/hosted/agptek/debug-agptek.c |
132 | target/hosted/agptek/lcd-agptek.c | ||
133 | target/hosted/agptek/power-agptek.c | 133 | target/hosted/agptek/power-agptek.c |
134 | target/hosted/agptek/powermgmt-agptek.c | 134 | target/hosted/agptek/powermgmt-agptek.c |
135 | target/hosted/agptek/usb-agptek.c | 135 | target/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)) |
139 | target/hosted/xduoo/button-xduoo.c | 139 | target/hosted/xduoo/button-xduoo.c |
140 | target/hosted/xduoo/debug-xduoo.c | 140 | target/hosted/xduoo/debug-xduoo.c |
141 | target/hosted/xduoo/lcd-xduoo.c | 141 | |
142 | target/hosted/xduoo/power-xduoo.c | 142 | target/hosted/xduoo/power-xduoo.c |
143 | target/hosted/xduoo/powermgmt-xduoo.c | 143 | target/hosted/xduoo/powermgmt-xduoo.c |
144 | target/hosted/xduoo/usb-xduoo.c | 144 | target/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 | ||
115 | void lcd_update(void) | 119 | void 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 | ||
126 | void lcd_update_rect(int x, int y, int width, int height) | 132 | void 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 | |||
35 | static int fd = -1; | ||
36 | static struct fb_var_screeninfo vinfo; | ||
37 | fb_data *framebuffer = 0; /* global variable, see lcd-target.h */ | ||
38 | |||
39 | void 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 | ||
84 | void lcd_shutdown(void) | ||
85 | { | ||
86 | munmap(framebuffer, FRAMEBUFFER_SIZE); | ||
87 | close(fd); | ||
88 | } | ||
89 | #endif | ||
90 | |||
91 | void 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 | |||
107 | static void redraw(void) | ||
108 | { | ||
109 | ioctl(fd, FBIOPAN_DISPLAY, &vinfo); | ||
110 | } | ||
111 | |||
112 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | ||
113 | int width, int height); | ||
114 | |||
115 | void 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 | |||
123 | void 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 | } | ||