diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index d84474d16..b0a11a334 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -150,6 +150,8 @@ class CFbAccelTD void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col); void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp); void waitForIdle(const char *func = NULL); + void setBlendMode(uint8_t); + void setBlendLevel(int); }; #endif diff --git a/src/driver/fb_accel_td.cpp b/src/driver/fb_accel_td.cpp index 7cddcfa3c..af3bf8f60 100644 --- a/src/driver/fb_accel_td.cpp +++ b/src/driver/fb_accel_td.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -143,6 +144,7 @@ void CFbAccelTD::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t void CFbAccelTD::init(const char *) { CFrameBuffer::init(); + fcntl(fd, F_SETFD, FD_CLOEXEC); if (lfb == NULL) { printf(LOGTAG "CFrameBuffer::init() failed.\n"); return; /* too bad... */ @@ -174,3 +176,29 @@ int CFbAccelTD::setMode(unsigned int, unsigned int, unsigned int) backbuffer = lfb; /* will not work well, but avoid crashes */ return 0; } + +void CFbAccelTD::setBlendMode(uint8_t mode) +{ + Stb04GFXOsdControl g; + ioctl(gfxfd, STB04GFX_OSD_GETCONTROL, &g); + g.use_global_alpha = (mode == 2); /* 1 == pixel alpha, 2 == global alpha */ + ioctl(gfxfd, STB04GFX_OSD_SETCONTROL, &g); +} + +void CFbAccelTD::setBlendLevel(int level) +{ + /* this is bypassing directfb, but faster and easier */ + Stb04GFXOsdControl g; + ioctl(gfxfd, STB04GFX_OSD_GETCONTROL, &g); + if (g.use_global_alpha == 0) + return; + + if (level < 0 || level > 100) + return; + + /* this is the same as convertSetupAlpha2Alpha(), but non-float */ + g.global_alpha = 255 - (255 * level / 100); + ioctl(gfxfd, STB04GFX_OSD_SETCONTROL, &g); + if (level == 100) // sucks + usleep(20000); +}