diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-01 08:36:05 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-01 12:49:39 +0000 |
commit | 0a7b23097ad033fb6f27fbbfd69e351c6acddef2 (patch) | |
tree | 9d87f43f468cd1fb7dc901be9259b67826cfa216 /firmware/target | |
parent | cb9b5d3b50425dd298e48d7d31cfff17be9f3c96 (diff) | |
download | rockbox-0a7b23097ad033fb6f27fbbfd69e351c6acddef2.tar.gz rockbox-0a7b23097ad033fb6f27fbbfd69e351c6acddef2.zip |
Hosted: Improvements in the LCD code. (Roman Stolyarov)
* Kill LCD when turning off the backlight
* Fix logic errors in lcd_enable() calls
* Use ioctls instead of sysfs to twiddle lcd enable
Change-Id: I6864ff63d87b747ac48719b0f4ba2de00333a1d3
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/hosted/backlight-unix.c | 8 | ||||
-rw-r--r-- | firmware/target/hosted/lcd-linuxfb.c | 44 |
2 files changed, 31 insertions, 21 deletions
diff --git a/firmware/target/hosted/backlight-unix.c b/firmware/target/hosted/backlight-unix.c index 2f00787f72..28bda52b20 100644 --- a/firmware/target/hosted/backlight-unix.c +++ b/firmware/target/hosted/backlight-unix.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * | 8 | * |
9 | * Copyright (C) 2017 Marcin Bukat | 9 | * Copyright (C) 2017 Marcin Bukat |
10 | * Copyright (C) 2019 by Roman Stolyarov | ||
10 | * | 11 | * |
11 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
@@ -28,6 +29,7 @@ | |||
28 | #include "backlight-target.h" | 29 | #include "backlight-target.h" |
29 | #include "sysfs.h" | 30 | #include "sysfs.h" |
30 | #include "panic.h" | 31 | #include "panic.h" |
32 | #include "lcd.h" | ||
31 | 33 | ||
32 | static const char * const sysfs_bl_brightness = | 34 | static const char * const sysfs_bl_brightness = |
33 | "/sys/class/backlight/pwm-backlight.0/brightness"; | 35 | "/sys/class/backlight/pwm-backlight.0/brightness"; |
@@ -44,12 +46,18 @@ bool backlight_hw_init(void) | |||
44 | 46 | ||
45 | void backlight_hw_on(void) | 47 | void backlight_hw_on(void) |
46 | { | 48 | { |
49 | #ifdef HAVE_LCD_ENABLE | ||
50 | lcd_enable(true); | ||
51 | #endif | ||
47 | sysfs_set_int(sysfs_bl_power, 0); | 52 | sysfs_set_int(sysfs_bl_power, 0); |
48 | } | 53 | } |
49 | 54 | ||
50 | void backlight_hw_off(void) | 55 | void backlight_hw_off(void) |
51 | { | 56 | { |
52 | sysfs_set_int(sysfs_bl_power, 1); | 57 | sysfs_set_int(sysfs_bl_power, 1); |
58 | #ifdef HAVE_LCD_ENABLE | ||
59 | lcd_enable(false); | ||
60 | #endif | ||
53 | } | 61 | } |
54 | 62 | ||
55 | void backlight_hw_brightness(int brightness) | 63 | void backlight_hw_brightness(int brightness) |
diff --git a/firmware/target/hosted/lcd-linuxfb.c b/firmware/target/hosted/lcd-linuxfb.c index 05d0055475..3d7c9d99a9 100644 --- a/firmware/target/hosted/lcd-linuxfb.c +++ b/firmware/target/hosted/lcd-linuxfb.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2017 Marcin Bukat | 9 | * Copyright (C) 2017 Marcin Bukat |
10 | * Copyright (C) 2016 Amaury Pouly | 10 | * Copyright (C) 2016 Amaury Pouly |
11 | * Copyright (C) 2019 Roman Stolyarov | ||
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,6 +23,7 @@ | |||
22 | #include <stdlib.h> | 23 | #include <stdlib.h> |
23 | #include <unistd.h> | 24 | #include <unistd.h> |
24 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include <string.h> | ||
25 | #include <linux/fb.h> | 27 | #include <linux/fb.h> |
26 | #include <sys/mman.h> | 28 | #include <sys/mman.h> |
27 | #include <sys/ioctl.h> | 29 | #include <sys/ioctl.h> |
@@ -34,19 +36,24 @@ | |||
34 | 36 | ||
35 | static int fd = -1; | 37 | static int fd = -1; |
36 | static struct fb_var_screeninfo vinfo; | 38 | static struct fb_var_screeninfo vinfo; |
39 | static struct fb_fix_screeninfo finfo; | ||
37 | fb_data *framebuffer = 0; /* global variable, see lcd-target.h */ | 40 | fb_data *framebuffer = 0; /* global variable, see lcd-target.h */ |
38 | 41 | ||
42 | static void redraw(void) | ||
43 | { | ||
44 | ioctl(fd, FBIOPAN_DISPLAY, &vinfo); | ||
45 | } | ||
46 | |||
39 | void lcd_init_device(void) | 47 | void lcd_init_device(void) |
40 | { | 48 | { |
41 | const char * const fb_dev = "/dev/fb0"; | 49 | const char * const fb_dev = "/dev/fb0"; |
42 | fd = open(fb_dev, O_RDWR); | 50 | fd = open(fb_dev, O_RDWR | O_SYNC); |
43 | if(fd < 0) | 51 | if(fd < 0) |
44 | { | 52 | { |
45 | panicf("Cannot open framebuffer: %s\n", fb_dev); | 53 | panicf("Cannot open framebuffer: %s\n", fb_dev); |
46 | } | 54 | } |
47 | 55 | ||
48 | /* get fixed and variable information */ | 56 | /* get fixed and variable information */ |
49 | struct fb_fix_screeninfo finfo; | ||
50 | if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) | 57 | if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) |
51 | { | 58 | { |
52 | panicf("Cannot read framebuffer fixed information"); | 59 | panicf("Cannot read framebuffer fixed information"); |
@@ -75,6 +82,8 @@ void lcd_init_device(void) | |||
75 | panicf("Cannot map framebuffer"); | 82 | panicf("Cannot map framebuffer"); |
76 | } | 83 | } |
77 | 84 | ||
85 | memset(framebuffer, 0, finfo.smem_len); | ||
86 | |||
78 | #ifdef HAVE_LCD_ENABLE | 87 | #ifdef HAVE_LCD_ENABLE |
79 | lcd_set_active(true); | 88 | lcd_set_active(true); |
80 | #endif | 89 | #endif |
@@ -88,30 +97,23 @@ void lcd_shutdown(void) | |||
88 | } | 97 | } |
89 | #endif | 98 | #endif |
90 | 99 | ||
100 | #ifdef HAVE_LCD_ENABLE | ||
91 | void lcd_enable(bool on) | 101 | void lcd_enable(bool on) |
92 | { | 102 | { |
93 | const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank"; | 103 | lcd_set_active(on); |
94 | 104 | if (on) | |
95 | #ifdef HAVE_LCD_ENABLE | ||
96 | if (lcd_active() != on) | ||
97 | #endif | ||
98 | { | 105 | { |
99 | sysfs_set_int(sysfs_fb_blank, on ? 0 : 1); | 106 | send_event(LCD_EVENT_ACTIVATION, NULL); |
100 | #ifdef HAVE_LCD_ENABLE | 107 | ioctl(fd, FB_BLANK_UNBLANK); |
101 | lcd_set_active(on); | 108 | } |
102 | #endif | 109 | else |
103 | 110 | { | |
104 | if (on) | 111 | memset(framebuffer, 0, finfo.smem_len); |
105 | { | 112 | redraw(); |
106 | send_event(LCD_EVENT_ACTIVATION, NULL); | 113 | ioctl(fd, FB_BLANK_POWERDOWN); |
107 | } | ||
108 | } | 114 | } |
109 | } | 115 | } |
110 | 116 | #endif | |
111 | static void redraw(void) | ||
112 | { | ||
113 | ioctl(fd, FBIOPAN_DISPLAY, &vinfo); | ||
114 | } | ||
115 | 117 | ||
116 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | 118 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, |
117 | int width, int height); | 119 | int width, int height); |