diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-01 22:03:21 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-02 02:24:42 +0000 |
commit | 9ee618e8891638027d05114250190f215bc01a63 (patch) | |
tree | 8fca5b761f8b7cdfa27eabb973b531bb011974e1 | |
parent | f4f3255edf95fcecf5ceb9586a529c7600a7cb13 (diff) | |
download | rockbox-9ee618e8891638027d05114250190f215bc01a63.tar.gz rockbox-9ee618e8891638027d05114250190f215bc01a63.zip |
hosted: Fix overzealous spamming of backlight and lcd enable
This caused random delays in LCD activity, and also caused key inputs to go nuts
Change-Id: Ie483c86f7461455308f8c5f8999df313521c6b55
-rw-r--r-- | firmware/target/hosted/backlight-unix.c | 16 | ||||
-rw-r--r-- | firmware/target/hosted/lcd-linuxfb.c | 21 |
2 files changed, 27 insertions, 10 deletions
diff --git a/firmware/target/hosted/backlight-unix.c b/firmware/target/hosted/backlight-unix.c index 28bda52b20..06da05e487 100644 --- a/firmware/target/hosted/backlight-unix.c +++ b/firmware/target/hosted/backlight-unix.c | |||
@@ -44,20 +44,28 @@ bool backlight_hw_init(void) | |||
44 | return true; | 44 | return true; |
45 | } | 45 | } |
46 | 46 | ||
47 | static int last_bl = -1; | ||
48 | |||
47 | void backlight_hw_on(void) | 49 | void backlight_hw_on(void) |
48 | { | 50 | { |
51 | if (last_bl != 1) { | ||
49 | #ifdef HAVE_LCD_ENABLE | 52 | #ifdef HAVE_LCD_ENABLE |
50 | lcd_enable(true); | 53 | lcd_enable(true); |
51 | #endif | 54 | #endif |
52 | sysfs_set_int(sysfs_bl_power, 0); | 55 | sysfs_set_int(sysfs_bl_power, 0); |
56 | last_bl = 1; | ||
57 | } | ||
53 | } | 58 | } |
54 | 59 | ||
55 | void backlight_hw_off(void) | 60 | void backlight_hw_off(void) |
56 | { | 61 | { |
57 | sysfs_set_int(sysfs_bl_power, 1); | 62 | if (last_bl != 0) { |
63 | sysfs_set_int(sysfs_bl_power, 1); | ||
58 | #ifdef HAVE_LCD_ENABLE | 64 | #ifdef HAVE_LCD_ENABLE |
59 | lcd_enable(false); | 65 | lcd_enable(false); |
60 | #endif | 66 | #endif |
67 | last_bl = 0; | ||
68 | } | ||
61 | } | 69 | } |
62 | 70 | ||
63 | void backlight_hw_brightness(int brightness) | 71 | void backlight_hw_brightness(int brightness) |
diff --git a/firmware/target/hosted/lcd-linuxfb.c b/firmware/target/hosted/lcd-linuxfb.c index 6a57be9e40..8edb82757f 100644 --- a/firmware/target/hosted/lcd-linuxfb.c +++ b/firmware/target/hosted/lcd-linuxfb.c | |||
@@ -53,15 +53,15 @@ void lcd_init_device(void) | |||
53 | panicf("Cannot open framebuffer: %s\n", fb_dev); | 53 | panicf("Cannot open framebuffer: %s\n", fb_dev); |
54 | } | 54 | } |
55 | 55 | ||
56 | /* get fixed and variable information */ | 56 | if (fcntl( fd, F_SETFD, FD_CLOEXEC ) < 0) |
57 | if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) | ||
58 | { | 57 | { |
59 | panicf("Cannot read framebuffer fixed information"); | 58 | panicf("Can't set CLOEXEC"); |
60 | } | 59 | } |
61 | 60 | ||
62 | if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) | 61 | /* get fixed and variable information */ |
62 | if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) | ||
63 | { | 63 | { |
64 | panicf("Cannot read framebuffer variable information"); | 64 | panicf("Cannot read framebuffer fixed information"); |
65 | } | 65 | } |
66 | 66 | ||
67 | #if 0 | 67 | #if 0 |
@@ -76,12 +76,17 @@ void lcd_init_device(void) | |||
76 | * values returned by the driver for line_length */ | 76 | * values returned by the driver for line_length */ |
77 | 77 | ||
78 | /* map framebuffer */ | 78 | /* map framebuffer */ |
79 | framebuffer = mmap(0, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); | 79 | framebuffer = mmap(NULL, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
80 | if((void *)framebuffer == MAP_FAILED) | 80 | if((void *)framebuffer == MAP_FAILED) |
81 | { | 81 | { |
82 | panicf("Cannot map framebuffer"); | 82 | panicf("Cannot map framebuffer"); |
83 | } | 83 | } |
84 | 84 | ||
85 | if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) | ||
86 | { | ||
87 | panicf("Cannot read framebuffer variable information"); | ||
88 | } | ||
89 | |||
85 | memset(framebuffer, 0, finfo.smem_len); | 90 | memset(framebuffer, 0, finfo.smem_len); |
86 | 91 | ||
87 | #ifdef HAVE_LCD_ENABLE | 92 | #ifdef HAVE_LCD_ENABLE |
@@ -104,7 +109,11 @@ void lcd_enable(bool on) | |||
104 | { | 109 | { |
105 | if (fd < 0) return; | 110 | if (fd < 0) return; |
106 | 111 | ||
112 | if (lcd_active() == on) | ||
113 | return; | ||
114 | |||
107 | lcd_set_active(on); | 115 | lcd_set_active(on); |
116 | |||
108 | if (on) | 117 | if (on) |
109 | { | 118 | { |
110 | send_event(LCD_EVENT_ACTIVATION, NULL); | 119 | send_event(LCD_EVENT_ACTIVATION, NULL); |