summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/target/hosted/backlight-unix.c8
-rw-r--r--firmware/target/hosted/lcd-linuxfb.c44
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 @@
* \/ \/ \/ \/ \/
*
* Copyright (C) 2017 Marcin Bukat
+ * Copyright (C) 2019 by Roman Stolyarov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -28,6 +29,7 @@
#include "backlight-target.h"
#include "sysfs.h"
#include "panic.h"
+#include "lcd.h"
static const char * const sysfs_bl_brightness =
"/sys/class/backlight/pwm-backlight.0/brightness";
@@ -44,12 +46,18 @@ bool backlight_hw_init(void)
void backlight_hw_on(void)
{
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(true);
+#endif
sysfs_set_int(sysfs_bl_power, 0);
}
void backlight_hw_off(void)
{
sysfs_set_int(sysfs_bl_power, 1);
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(false);
+#endif
}
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 @@
*
* Copyright (C) 2017 Marcin Bukat
* Copyright (C) 2016 Amaury Pouly
+ * Copyright (C) 2019 Roman Stolyarov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -22,6 +23,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <string.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
@@ -34,19 +36,24 @@
static int fd = -1;
static struct fb_var_screeninfo vinfo;
+static struct fb_fix_screeninfo finfo;
fb_data *framebuffer = 0; /* global variable, see lcd-target.h */
+static void redraw(void)
+{
+ ioctl(fd, FBIOPAN_DISPLAY, &vinfo);
+}
+
void lcd_init_device(void)
{
const char * const fb_dev = "/dev/fb0";
- fd = open(fb_dev, O_RDWR);
+ fd = open(fb_dev, O_RDWR | O_SYNC);
if(fd < 0)
{
panicf("Cannot open framebuffer: %s\n", fb_dev);
}
/* get fixed and variable information */
- struct fb_fix_screeninfo finfo;
if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0)
{
panicf("Cannot read framebuffer fixed information");
@@ -75,6 +82,8 @@ void lcd_init_device(void)
panicf("Cannot map framebuffer");
}
+ memset(framebuffer, 0, finfo.smem_len);
+
#ifdef HAVE_LCD_ENABLE
lcd_set_active(true);
#endif
@@ -88,30 +97,23 @@ void lcd_shutdown(void)
}
#endif
+#ifdef HAVE_LCD_ENABLE
void lcd_enable(bool on)
{
- const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank";
-
-#ifdef HAVE_LCD_ENABLE
- if (lcd_active() != on)
-#endif
+ lcd_set_active(on);
+ if (on)
{
- sysfs_set_int(sysfs_fb_blank, on ? 0 : 1);
-#ifdef HAVE_LCD_ENABLE
- lcd_set_active(on);
-#endif
-
- if (on)
- {
- send_event(LCD_EVENT_ACTIVATION, NULL);
- }
+ send_event(LCD_EVENT_ACTIVATION, NULL);
+ ioctl(fd, FB_BLANK_UNBLANK);
+ }
+ else
+ {
+ memset(framebuffer, 0, finfo.smem_len);
+ redraw();
+ ioctl(fd, FB_BLANK_POWERDOWN);
}
}
-
-static void redraw(void)
-{
- ioctl(fd, FBIOPAN_DISPLAY, &vinfo);
-}
+#endif
extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
int width, int height);