From 3d5b2907927ddfcefeeb0f2045d1a75583ec7613 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 12 Feb 2017 21:30:44 +0100 Subject: [PATCH 01/33] remove fb_accel_cs.cpp after merge Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0aa871e2f973a2f0b9e2a45f360c3ba51c2bc71d Author: Stefan Seyfried Date: 2017-02-12 (Sun, 12 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_accel_cs.cpp | 313 ------------------------------------- 1 file changed, 313 deletions(-) delete mode 100644 src/driver/fb_accel_cs.cpp diff --git a/src/driver/fb_accel_cs.cpp b/src/driver/fb_accel_cs.cpp deleted file mode 100644 index c4aeb21e4..000000000 --- a/src/driver/fb_accel_cs.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* - Framebuffer acceleration hardware abstraction functions. - The hardware dependent acceleration functions for coolstream GXA chips - are represented in this class. - - (C) 2017 Stefan Seyfried - Derived from old neutrino-hd framebuffer code - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/*******************************************************************************/ -#define GXA_POINT(x, y) (((y) & 0x0FFF) << 16) | ((x) & 0x0FFF) -#define GXA_SRC_BMP_SEL(x) (x << 8) -#define GXA_DST_BMP_SEL(x) (x << 5) -#define GXA_PARAM_COUNT(x) (x << 2) - -#define GXA_CMD_REG 0x001C -#define GXA_FG_COLOR_REG 0x0020 -#define GXA_BG_COLOR_REG 0x0024 -#define GXA_LINE_CONTROL_REG 0x0038 -#define GXA_BMP1_TYPE_REG 0x0048 -#define GXA_BMP1_ADDR_REG 0x004C -#define GXA_BMP2_TYPE_REG 0x0050 -#define GXA_BMP2_ADDR_REG 0x0054 -#define GXA_BMP3_TYPE_REG 0x0058 -#define GXA_BMP3_ADDR_REG 0x005C -#define GXA_BMP4_TYPE_REG 0x0060 -#define GXA_BMP4_ADDR_REG 0x0064 -#define GXA_BMP5_TYPE_REG 0x0068 -#define GXA_BMP5_ADDR_REG 0x006C -#define GXA_BMP6_TYPE_REG 0x0070 -#define GXA_BMP7_TYPE_REG 0x0078 -#define GXA_DEPTH_REG 0x00F4 -#define GXA_CONTENT_ID_REG 0x0144 - -#define GXA_CMD_BLT 0x00010800 -#define GXA_CMD_NOT_ALPHA 0x00011000 -#define GXA_CMD_NOT_TEXT 0x00018000 -#define GXA_CMD_QMARK 0x00001000 - -#define GXA_BLEND_CFG_REG 0x003C -#define GXA_CFG_REG 0x0030 -#define GXA_CFG2_REG 0x00FC - -#define LOGTAG "[fb_accel_gxa] " -/* -static unsigned int _read_gxa(volatile unsigned char *base_addr, unsigned int offset) -{ - return *(volatile unsigned int *)(base_addr + offset); -} -*/ -static unsigned int _mark = 0; - -static void _write_gxa(volatile unsigned char *base_addr, unsigned int offset, unsigned int value) -{ - while ((*(volatile unsigned int *)(base_addr + GXA_DEPTH_REG)) & 0x40000000) {}; - *(volatile unsigned int *)(base_addr + offset) = value; -} - -/* this adds a tagged marker into the GXA queue. Once this comes out - of the other end of the queue, all commands before it are finished */ -void CFbAccelCS::add_gxa_sync_marker(void) -{ - unsigned int cmd = GXA_CMD_QMARK | GXA_PARAM_COUNT(1); - // TODO: locking? - _mark++; - _mark &= 0x0000001F; /* bit 0x20 crashes the kernel, if set */ - _write_gxa(gxa_base, cmd, _mark); - //fprintf(stderr, "%s: wrote %02x\n", __FUNCTION__, _mark); -} - -/* wait until the current marker comes out of the GXA command queue */ -void CFbAccelCS::waitForIdle(const char *func) -{ - unsigned int cfg, count = 0; - do { - cfg = *(volatile unsigned int *)(gxa_base + GXA_CMD_REG); - cfg >>= 24; /* the token is stored in bits 31...24 */ - if (cfg == _mark) - break; - /* usleep is too coarse, because of CONFIG_HZ=100 in kernel - so use sched_yield to at least give other threads a chance to run */ - sched_yield(); - //fprintf(stderr, "%s: read %02x, expected %02x\n", __FUNCTION__, cfg, _mark); - } while(++count < 8192); /* don't deadlock here if there is an error */ - - if (count > 2048) /* more than 2000 are unlikely, even for large BMP6 blits */ - fprintf(stderr, LOGTAG "waitForIdle: count is big (%d) [%s]!\n", count, func?func:""); -} - -CFbAccelCS::CFbAccelCS() -{ - fb_name = "Coolstream NEVIS GXA framebuffer"; -} - -void CFbAccelCS::init(const char * const) -{ -fprintf(stderr, ">FBACCEL::INIT\n"); - CFrameBuffer::init(); - if (lfb == NULL) { - printf(LOGTAG "CFrameBuffer::init() failed.\n"); - return; /* too bad... */ - } - available = fix.smem_len; - printf(LOGTAG "%dk video mem\n", available / 1024); - memset(lfb, 0, available); - lastcol = 0xffffffff; - lbb = lfb; /* the memory area to draw to... */ - - /* Open /dev/mem for HW-register access */ - devmem_fd = open("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC); - if (devmem_fd < 0) { - perror("CFbAccel open /dev/mem"); - goto error; - } - - /* mmap the GXA's base address */ - gxa_base = (volatile unsigned char*)mmap(0, 0x00040000, PROT_READ|PROT_WRITE, MAP_SHARED, devmem_fd, 0xE0600000); - if (gxa_base == (void *)-1) { - perror("CFbAccel mmap /dev/mem"); - goto error; - } - - setupGXA(); - error: - /* TODO: what to do here? does this really happen? */ - ; -}; - -CFbAccelCS::~CFbAccelCS() -{ - if (gxa_base != MAP_FAILED) - munmap((void *)gxa_base, 0x40000); - if (devmem_fd != -1) - close(devmem_fd); - if (lfb) - munmap(lfb, available); - if (fd > -1) - close(fd); -} - -void CFbAccelCS::setColor(fb_pixel_t col) -{ - if (col == lastcol) - return; - _write_gxa(gxa_base, GXA_FG_COLOR_REG, (unsigned int)col); /* setup the drawing color */ - lastcol = col; -} - -void CFbAccelCS::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) -{ - OpenThreads::ScopedLock m_lock(mutex); - unsigned int cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_CMD_NOT_ALPHA | - GXA_SRC_BMP_SEL(6) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2); - - _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)col); /* setup the drawing color */ - _write_gxa(gxa_base, GXA_BMP6_TYPE_REG, (3 << 16) | (1 << 27)); /* 3 == 32bpp, 1<<27 == fill */ - _write_gxa(gxa_base, cmd, GXA_POINT(x, y)); /* destination pos */ - _write_gxa(gxa_base, cmd, GXA_POINT(dx, dy)); /* destination size */ - _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)backgroundColor); - - /* the GXA seems to do asynchronous rendering, so we add a sync marker - to which the fontrenderer code can synchronize */ - add_gxa_sync_marker(); -} - -void CFbAccelCS::paintPixel(const int x, const int y, const fb_pixel_t col) -{ - paintLine(x, y, x + 1, y, col); -} - -void CFbAccelCS::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) -{ - OpenThreads::ScopedLock m_lock(mutex); - /* draw a single vertical line from point xa/ya to xb/yb */ - unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; - - setColor(col); - _write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404); /* X is major axis, skip last pixel */ - _write_gxa(gxa_base, cmd, GXA_POINT(xb, yb)); /* end point */ - _write_gxa(gxa_base, cmd, GXA_POINT(xa, ya)); /* start point */ -} - -void CFbAccelCS::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp) -{ - int xc, yc; - xc = (width > xRes) ? xRes : width; - yc = (height > yRes) ? yRes : height; - (void)transp; - u32 cmd; - void *uKva; - - uKva = cs_phys_addr(fbbuff); - //printf("CFbAccelCS::blit2FB: data %x Kva %x\n", (int) fbbuff, (int) uKva); - - if (uKva != NULL) { - OpenThreads::ScopedLock m_lock(mutex); - cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(1) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(3); - - _write_gxa(gxa_base, GXA_BMP1_TYPE_REG, (3 << 16) | width); - _write_gxa(gxa_base, GXA_BMP1_ADDR_REG, (unsigned int)uKva); - - _write_gxa(gxa_base, cmd, GXA_POINT(xoff, yoff)); /* destination pos */ - _write_gxa(gxa_base, cmd, GXA_POINT(xc, yc)); /* source width, FIXME real or adjusted xc, yc ? */ - _write_gxa(gxa_base, cmd, GXA_POINT(xp, yp)); /* source pos */ - - return; - } -#if 0 - for(int i = 0; i < yc; i++){ - memmove(clfb + (i + yoff)*stride + xoff*4, ip + (i + yp)*width + xp, xc*4); - } -#endif -} - -void CFbAccelCS::setupGXA() -{ - // We (re)store the GXA regs here in case DFB override them and was not - // able to restore them. - _write_gxa(gxa_base, GXA_BMP2_TYPE_REG, (3 << 16) | (unsigned int)screeninfo.xres); - _write_gxa(gxa_base, GXA_BMP2_ADDR_REG, (unsigned int) fix.smem_start); - _write_gxa(gxa_base, GXA_BLEND_CFG_REG, 0x00089064); - // TODO check mono-flip, bit 8 - _write_gxa(gxa_base, GXA_CFG_REG, 0x100 | (1 << 12) | (1 << 29)); - _write_gxa(gxa_base, GXA_CFG2_REG, 0x1FF); - _write_gxa(gxa_base, GXA_BG_COLOR_REG, (unsigned int)backgroundColor); - add_gxa_sync_marker(); -} - -/* wrong name... */ -int CFbAccelCS::setMode(unsigned int, unsigned int, unsigned int) -{ - fb_fix_screeninfo _fix; - - if (ioctl(fd, FBIOGET_FSCREENINFO, &_fix) < 0) { - perror("FBIOGET_FSCREENINFO"); - return -1; - } - stride = _fix.line_length; - if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) - printf("screen unblanking failed\n"); - xRes = screeninfo.xres; - yRes = screeninfo.yres; - bpp = screeninfo.bits_per_pixel; - int needmem = stride * yRes * 2; - if (available >= needmem) - { - backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; - return 0; - } - fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); - backbuffer = lfb; /* will not work well, but avoid crashes */ - return 0; /* dont fail because of this */ -} - -fb_pixel_t * CFbAccelCS::getBackBufferPointer() const -{ - return backbuffer; -} - -void CFbAccelCS::setBlendMode(uint8_t mode) -{ - if (ioctl(fd, FBIO_SETBLENDMODE, mode)) - printf("FBIO_SETBLENDMODE failed.\n"); -} - -void CFbAccelCS::setBlendLevel(int level) -{ - unsigned char value = 0xFF; - if (level >= 0 && level <= 100) - value = convertSetupAlpha2Alpha(level); - - if (ioctl(fd, FBIO_SETOPACITY, value)) - printf("FBIO_SETOPACITY failed.\n"); -#ifndef BOXMODEL_APOLLO - if (level == 100) // TODO: sucks. - usleep(20000); -#endif -} From 28545cce783640726c942375e3db74c3a66ada1c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 13 Feb 2017 00:03:58 +0100 Subject: [PATCH 02/33] acinclude: only set default model to hd1 if boxtype=coolstream Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/80c961d5f40c8437e502d422d35df807231c7517 Author: Stefan Seyfried Date: 2017-02-13 (Mon, 13 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 308d1619e..35c3a8f49 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -525,7 +525,7 @@ AC_ARG_WITH(boxmodel, *) AC_MSG_ERROR([unsupported value $withval for --with-boxmodel]) ;; - esac], [BOXMODEL="hd1"] + esac], [test "$BOXTYPE" = "coolstream" && BOXMODEL="hd1" || true] [if test "$BOXTYPE" = "dreambox" -o "$BOXTYPE" = "ipbox" && test -z "$BOXMODEL"; then AC_MSG_ERROR([Dreambox/IPBox needs --with-boxmodel]) fi]) From a58fbb9d6b8dcf690af27c3da2c6579be776acb1 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 14 Feb 2017 00:06:47 +0100 Subject: [PATCH 03/33] fb_generic: remove hardware specific #ifdef Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/bedee6b4c33ab0f6ed99a96f3a5e2727e0dd53e8 Author: Stefan Seyfried Date: 2017-02-14 (Tue, 14 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 5b2a24402..e863528ab 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -184,10 +184,7 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? -#ifdef BOXMODEL_CS_HD1 - virtual void setupGXA() {}; - virtual void add_gxa_sync_marker() {}; -#endif + virtual void setupGXA() { return; }; // reinitialize stuff void setTransparency( int tr = 0 ); virtual void setBlendMode(uint8_t mode = 1); From 44ef22e6b81125a4bef48890c191943faf6aa628 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 14 Feb 2017 00:09:33 +0100 Subject: [PATCH 04/33] implement getWidth4FB_HW_ACC in fb_accel class This helper to determine alignment for hardware blitting is now in system/helpers.h, where it does not really belong. Put it into the framebuffer class instead. Framebuffers that don't need it will just get a dummy function, the cs_hd2 framebuffer gets the real thing. Also add a bool function that indicates the need for alignment. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/05d1732cea4badade4ff6b9623cd2c6ad1e0a738 Author: Stefan Seyfried Date: 2017-02-14 (Tue, 14 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_accel.h | 2 ++ src/driver/fb_accel_cs_hd2.cpp | 17 +++++++++++++++++ src/driver/fb_generic.cpp | 8 ++++++-- src/driver/fb_generic.h | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index 54736d331..e3eceaab5 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -127,6 +127,8 @@ class CFbAccelCSHD2 void blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff); void setBlendMode(uint8_t); void setBlendLevel(int); + uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); + bool needAlign4Blit() { return true; }; }; class CFbAccelGLFB diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index 393e6396c..256a9c729 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -228,3 +228,20 @@ void CFbAccelCSHD2::setBlendLevel(int level) if (level == 100) // TODO: sucks. usleep(20000); } + +/* align for hw blit */ +uint32_t CFbAccelCSHD2::getWidth4FB_HW_ACC(const uint32_t _x, const uint32_t _w, const bool max) +{ + uint32_t ret = _w; + if ((_x + ret) >= xRes) + ret = xRes-_x-1; + if (ret%4 == 0) + return ret; + + int add = (max) ? 3 : 0; + ret = ((ret + add) / 4) * 4; + if ((_x + ret) >= xRes) + ret -= 4; + + return ret; +} diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 9377d77da..1160b9c44 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -514,7 +513,7 @@ fb_pixel_t* CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, co #ifdef BOXMODEL_CS_HD2 if (_dx%4 != 0) { - w_align = GetWidth4FB_HW_ACC(x, _dx, true); + w_align = getWidth4FB_HW_ACC(x, _dx, true); if (w_align < _dx) _dx = w_align; offs_align = w_align - _dx; @@ -1770,3 +1769,8 @@ bool CFrameBuffer::_checkFbArea(int _x, int _y, int _dx, int _dy, bool prev) void CFrameBuffer::mark(int , int , int , int ) { } + +uint32_t CFrameBuffer::getWidth4FB_HW_ACC(const uint32_t /*x*/, const uint32_t w, const bool /*max*/) +{ + return w; +} diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index e863528ab..fdd9cc8d5 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -185,6 +185,8 @@ class CFrameBuffer : public sigc::trackable bool getActive() const; // is framebuffer active? void setActive(bool enable); // is framebuffer active? virtual void setupGXA() { return; }; // reinitialize stuff + virtual bool needAlign4Blit() { return false; }; + virtual uint32_t getWidth4FB_HW_ACC(const uint32_t x, const uint32_t w, const bool max=true); void setTransparency( int tr = 0 ); virtual void setBlendMode(uint8_t mode = 1); From 5c02691597ab55f0102ad905d09b2b1f1310d3ce Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 14 Feb 2017 00:14:30 +0100 Subject: [PATCH 05/33] remove hardware specific code from gui Use the framebuffer's getWidth4FB_HW_ACC() instead of system/helpers. The use in cc_item_picture was guarded by a hardware #ifdef, use needAlign4Blit() instead. This needs testing on the affected hardware, which I do not have :-) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a5333b4ec1b2cef4a29aa1634cf3454dbbe23c7a Author: Stefan Seyfried Date: 2017-02-14 (Tue, 14 Feb 2017) ------------------ This commit was generated by Migit --- src/gui/components/cc_item_picture.cpp | 8 +++----- src/gui/movieplayer.cpp | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index bcaccf6c7..1870092af 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -33,7 +33,6 @@ #include "cc_item_picture.h" #include #include -#include #include extern CPictureViewer * g_PicViewer; @@ -222,10 +221,9 @@ void CComponentsPicture::initCCItem() { float h_ratio = float(height)*100/(float)dy; width = int(h_ratio*(float)dx/100); -#ifdef BOXMODEL_CS_HD2 - if (do_scale && (width > 10 || height > 10)) - width = GetWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness; -#endif + if (frameBuffer->needAlign4Blit() && + do_scale && (width > 10 || height > 10)) + width = frameBuffer->getWidth4FB_HW_ACC(x+fr_thickness, width-2*fr_thickness)+2*fr_thickness; keep_dx_aspect = false; } if (keep_dy_aspect && dx) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index fb6030073..81687c58d 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -2481,7 +2481,7 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) int xoff = (double) sub->rects[i]->x * xc; int yoff = (double) sub->rects[i]->y * yc; - int nw = GetWidth4FB_HW_ACC(xoff, (double) sub->rects[i]->w * xc); + int nw = frameBuffer->getWidth4FB_HW_ACC(xoff, (double) sub->rects[i]->w * xc); int nh = (double) sub->rects[i]->h * yc; printf("Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, From 0c04a7924505570032662cde86cf0516877df3d9 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 14 Feb 2017 00:15:11 +0100 Subject: [PATCH 06/33] system/helpers: disable GetWidth4FB_HW_ACC() ...will be removed later Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c95601630af7c79b09170b3cfbde05990b948165 Author: Stefan Seyfried Date: 2017-02-14 (Tue, 14 Feb 2017) ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 4 +++- src/system/helpers.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 8c0ddf67f..35532da03 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -49,7 +49,7 @@ #include "debug.h" #include #include -#include +//#include #include #include using namespace std; @@ -1074,6 +1074,7 @@ bool split_config_string(const std::string &str, std::map split(const std::string &s, char delim) { diff --git a/src/system/helpers.h b/src/system/helpers.h index 53205f8e1..0c99d6366 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -115,7 +115,9 @@ class CFileHelpers static uint64_t getDirSize(const std::string& dir){return getDirSize(dir.c_str());}; }; +#if 0 uint32_t GetWidth4FB_HW_ACC(const uint32_t _x, const uint32_t _w, const bool max=true); +#endif #if __cplusplus < 201103L std::string to_string(int); From aaa05f7f83ebc953e8e309fd9b10a28ec97d3123 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 14 Feb 2017 00:17:03 +0100 Subject: [PATCH 07/33] lcdd (tripledragon): remove bogus warning message Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9ed6cfe859d1d41867be995fed2486bb16b4a7eb Author: Stefan Seyfried Date: 2017-02-14 (Tue, 14 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/lcdd.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/driver/lcdd.cpp b/src/driver/lcdd.cpp index 982780144..51e2bebae 100644 --- a/src/driver/lcdd.cpp +++ b/src/driver/lcdd.cpp @@ -714,12 +714,13 @@ void CLCD::showVolume(const char vol, const bool perform_update) wake_up(); } -void CLCD::showPercentOver(const unsigned char perc, const bool perform_update, const MODES m) +void CLCD::showPercentOver(const unsigned char perc, const bool perform_update, const MODES /*m*/) { +/* if (mode != m) printf("CLCD::showPercentOver: mode (%d) != m (%d), please report\n", (int)mode, (int)m); // return; - +*/ int left, top, width, height = 5; bool draw = true; percentOver = perc; From 64d6e7f0675e41f27be7e7c3105eeddf949a6aa5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 15 Feb 2017 00:10:59 +0100 Subject: [PATCH 08/33] fb_accel_td: add missing getBackBufferPointer() this fixes tuxtxt rendering problems Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3413af4236645653ec0f0a54bdf39d2e81407245 Author: Stefan Seyfried Date: 2017-02-15 (Wed, 15 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_accel.h | 1 + src/driver/fb_accel_td.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/driver/fb_accel.h b/src/driver/fb_accel.h index e3eceaab5..090ef4cc4 100644 --- a/src/driver/fb_accel.h +++ b/src/driver/fb_accel.h @@ -171,6 +171,7 @@ 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); + fb_pixel_t * getBackBufferPointer() const; void setBlendMode(uint8_t); void setBlendLevel(int); }; diff --git a/src/driver/fb_accel_td.cpp b/src/driver/fb_accel_td.cpp index af3bf8f60..7033ed0bc 100644 --- a/src/driver/fb_accel_td.cpp +++ b/src/driver/fb_accel_td.cpp @@ -202,3 +202,8 @@ void CFbAccelTD::setBlendLevel(int level) if (level == 100) // sucks usleep(20000); } + +fb_pixel_t *CFbAccelTD::getBackBufferPointer() const +{ + return backbuffer; +} From cc8f8261f069dba1d4fbbaf2bebad713429401a5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 15 Feb 2017 00:31:26 +0100 Subject: [PATCH 09/33] tuxtxt: convert to int-pointer arithmetic, work with all framebuffers This converts the drawing code from byte-pointer to fb_pixel_t-pointer arithmetic, making the calculations more obvious and probably more efficient. Additionally, the color tables are now generated in a way that it should work regardless of the frame buffer color format. Allows to remove a few hardware specific #ifdefs. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f51278b094bdd1c27e922a593833cae088507c3f Author: Stefan Seyfried Date: 2017-02-15 (Wed, 15 Feb 2017) ------------------ This commit was generated by Migit --- lib/libtuxtxt/tuxtxt.cpp | 199 +++++++++++++++++---------------------- lib/libtuxtxt/tuxtxt.h | 34 +------ 2 files changed, 93 insertions(+), 140 deletions(-) diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index c6f5f4ce9..dc7d5a7c5 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -49,7 +49,7 @@ static int screen_x, screen_y, screen_w, screen_h; //#define USE_FBPAN // FBIOPAN_DISPLAY seems to be working in current driver -unsigned char *getFBp(int *y) +fb_pixel_t *getFBp(int *y) { if (*y < (int)var_screeninfo.yres) return lfb; @@ -60,20 +60,15 @@ unsigned char *getFBp(int *y) void FillRect(int x, int y, int w, int h, int color) { - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); - p += x*4 + y * fix_screeninfo.line_length; -#if !HAVE_TRIPLEDRAGON - unsigned int col = bgra[color][3] << 24 | bgra[color][2] << 16 | bgra[color][1] << 8 | bgra[color][0]; -#else - unsigned int col = *((unsigned int*)bgra[color]); -#endif + p += x + y * stride; if (w > 0) for (int count = 0; count < h; count++) { - unsigned int * dest0 = (unsigned int *)p; + fb_pixel_t *dest0 = p; for (int i = 0; i < w; i++) - *(dest0++) = col; - p += fix_screeninfo.line_length; + *(dest0++) = bgra[color]; + p += stride; } } @@ -319,25 +314,14 @@ void setfontwidth(int newwidth) } } -#if HAVE_TRIPLEDRAGON -#define _A 0 -#define _R 1 -#define _G 2 -#define _B 3 -#else -#define _A 3 -#define _R 2 -#define _G 1 -#define _B 0 -#endif void setcolors(unsigned short *pcolormap, int offset, int number) { - int i,trans_tmp; + int i,trans_tmp,tr; int j = offset; /* index in global color table */ - - trans_tmp=25-trans_mode; - - bgra[transp2][_A]=((trans_tmp+7)<<11 | 0x7FF)>>8; + int R = var_screeninfo.red.offset; + int G = var_screeninfo.green.offset; + int B = var_screeninfo.blue.offset; + int A = var_screeninfo.transp.offset; for (i = 0; i < number; i++) { @@ -348,13 +332,17 @@ void setcolors(unsigned short *pcolormap, int offset, int number) r = (r * (0x3f+(color_mode<<3))) >> 8; g = (g * (0x3f+(color_mode<<3))) >> 8; b = (b * (0x3f+(color_mode<<3))) >> 8; - - bgra[j][_R]=r; - bgra[j][_G]=g; - bgra[j][_B]=b; - + bgra[j] = (r << R) | (g << G) | (b << B) | (0xff << A); j++; } + trans_tmp=25-trans_mode; + tr = ((trans_tmp+7)<<11 | 0x7FF)>>8; + bgra[transp2] &= ~(0xff << A); /* clear alpha */ + bgra[transp2] |= tr << A; + bgra[menu3] &= ~(0xff << A); + bgra[menu3] |= 0xc0 << A; + bgra[transp] &= ~(0xff << A); + bgra[transp] |= 0; } /* hexdump of page contents to stdout for debugging */ @@ -1666,8 +1654,8 @@ int tuxtx_main(int /*_rc*/, int pid, int page, int source) #endif CFrameBuffer *fbp = CFrameBuffer::getInstance(); - lfb = (unsigned char *)fbp->getFrameBufferPointer(); - lbb = (unsigned char *)fbp->getBackBufferPointer(); + lfb = fbp->getFrameBufferPointer(); + lbb = fbp->getBackBufferPointer(); tuxtxt_cache.vtxtpid = pid; @@ -1693,6 +1681,8 @@ int tuxtx_main(int /*_rc*/, int pid, int page, int source) #else struct fb_var_screeninfo *var; var = fbp->getScreenInfo(); + /* this is actually the length of the screen in pixels */ + stride = fbp->getStride() / sizeof(fb_pixel_t); memcpy(&var_screeninfo, var, sizeof(struct fb_var_screeninfo)); fix_screeninfo.line_length = var_screeninfo.xres * sizeof(fb_pixel_t); #endif @@ -4117,7 +4107,7 @@ void SwitchHintMode() void RenderDRCS( //FIX ME unsigned char *s, /* pointer to char data, parity undecoded */ - unsigned char *d, /* pointer to frame buffer of top left pixel */ + fb_pixel_t *d, /* pointer to frame buffer of top left pixel */ unsigned char *ax, /* array[0..12] of x-offsets, array[0..10] of y-offsets for each pixel */ unsigned char fgcolor, unsigned char bgcolor) { @@ -4149,52 +4139,45 @@ void RenderDRCS( //FIX ME { // memset(d + ax[x], f1, ax[x+1] - ax[x]); for (ltmp=0 ; ltmp <= (ax[x+1]-ax[x]); ltmp++) - { - memmove(d + ax[x]*4 +ltmp*4,bgra[f1],4); - } + *(d + ax[x] + ltmp) = bgra[f1]; } if (ax[x+7] > ax[x+6]) { // memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */ for (ltmp=0 ; ltmp <= (ax[x+7]-ax[x+6]); ltmp++) - { - memmove(d + ax[x+6]*4 +ltmp*4,bgra[f2],4); - } - + *(d + ax[x+6] + ltmp) = bgra[f2]; } - d += fix_screeninfo.line_length; + d += stride; } - d -= h * fix_screeninfo.line_length; + d -= h * stride; } - d += h * fix_screeninfo.line_length; + d += h * stride; } } void DrawVLine(int x, int y, int l, int color) { - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, 0, l); - p += x*4 + y * fix_screeninfo.line_length; + p += x + y * stride; for ( ; l > 0 ; l--) { - memmove(p,bgra[color],4); - p += fix_screeninfo.line_length; + *p = bgra[color]; + p += stride; } } void DrawHLine(int x, int y, int l, int color) { int ltmp; - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, l, 0); if (l > 0) { for (ltmp=0; ltmp <= l; ltmp++) - { - memmove(p + x*4 + ltmp*4 + y * fix_screeninfo.line_length, bgra[color], 4); - } + *(p + x + ltmp + y * stride) = bgra[color]; } } @@ -4209,9 +4192,9 @@ void FillRectMosaicSeparated(int x, int y, int w, int h, int fgcolor, int bgcolo void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, int color) { - unsigned char *p = getFBp(&y0); + fb_pixel_t *p = getFBp(&y0); MARK_FB(x0, y0, l0, h); - p += x0 * 4 + y0 * fix_screeninfo.line_length; + p += x0 + y0 * stride; int xoffset, l; int yoffset; @@ -4224,19 +4207,17 @@ void FillTrapez(int x0, int y0, int l0, int xoffset1, int h, int l1, int color) if (l > 0) { for (ltmp=0; ltmp <= l; ltmp++) - { - memmove(p + xoffset*4 +ltmp*4, bgra[color], 4); - } + *(p + xoffset + ltmp) = bgra[color]; } - p += fix_screeninfo.line_length; + p += stride; } } void FlipHorz(int x, int y, int w, int h) { unsigned char *buf= new unsigned char[w*4]; - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); - p += x * 4 + y * fix_screeninfo.line_length; + p += x + y * stride; int w1,h1; if(buf != NULL){ @@ -4245,9 +4226,9 @@ void FlipHorz(int x, int y, int w, int h) memmove(buf,p,w*4); for (w1 = 0 ; w1 < w ; w1++) { - memmove(p+w1*4,buf+((w-w1)*4)-4,4); + memmove(p + w1,buf+((w-w1)*4)-4,4); } - p += fix_screeninfo.line_length; + p += stride; } delete [] buf; } @@ -4255,17 +4236,17 @@ void FlipHorz(int x, int y, int w, int h) void FlipVert(int x, int y, int w, int h) { unsigned char *buf= new unsigned char[w*4]; - unsigned char *p1, *p2; - unsigned char *p = getFBp(&y); + fb_pixel_t *p1, *p2; + fb_pixel_t *p = getFBp(&y); MARK_FB(x, y, w, h); - p += x*4 + y * fix_screeninfo.line_length; + p += x + y * stride; int h1; if(buf != NULL){ for (h1 = 0 ; h1 < h/2 ; h1++) { - p1 = (p+(h1*fix_screeninfo.line_length)); - p2 = (p+(h-(h1+1))*fix_screeninfo.line_length); + p1 = (p + (h1 * stride)); + p2 = (p + (h - (h1 + 1)) * stride); memmove(buf,p1,w*4); memmove(p1,p2,w*4); memmove(p2,buf,w*4); @@ -4521,9 +4502,9 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) { int x,y,f,c; y = yoffset; - unsigned char *p = getFBp(&y); + fb_pixel_t *p = getFBp(&y); MARK_FB(PosX, PosY, curfontwidth, fontheight); - p += PosX * 4 + PosY * fix_screeninfo.line_length; + p += PosX + PosY * stride; for (y=0; ytop + TTFShiftY); @@ -4848,18 +4829,18 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) int y = yoffset; p = getFBp(&y); - p += PosX * 4 + (PosY + Row) * fix_screeninfo.line_length; /* running pointer into framebuffer */ + p += PosX + (PosY + Row) * stride; /* running pointer into framebuffer */ for (Row = sbit->height; Row; Row--) /* row counts up, but down may be a little faster :) */ { int pixtodo = (usettf ? sbit->width : curfontwidth); - char *pstart = (char*) p; + fb_pixel_t *pstart = p; for (Bit = xfactor * (sbit->left + TTFShiftX); Bit > 0; Bit--) /* fill left margin */ { for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[bgcolor],4);/*bgcolor*/ - p+=4; + *(p + f * stride) = bgra[bgcolor]; + p++; if (!usettf) pixtodo--; } @@ -4879,14 +4860,14 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) color = bgcolor; for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[color],4); - p+=4; + *(p + f * stride) = bgra[color]; + p++; if (xfactor > 1) /* double width */ { for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[color],4); - p+=4; + *(p + f * stride) = bgra[color]; + p++; if (!usettf) pixtodo--; @@ -4898,11 +4879,11 @@ void RenderChar(int Char, tstPageAttr *Attribute, int zoom, int yoffset) Bit > 0; Bit--) /* fill rest of char width */ { for (f = factor-1; f >= 0; f--) - memmove((p + f*fix_screeninfo.line_length),bgra[bgcolor],4); - p+=4; + *(p + f * stride) = bgra[bgcolor]; + p++; } - p = (unsigned char*) pstart + factor*fix_screeninfo.line_length; + p = pstart + factor * stride; } Row = ascender - sbit->top + sbit->height + TTFShiftY; @@ -5612,7 +5593,7 @@ void CreateLine25() void CopyBB2FB() { - unsigned char *src, *dst, *topsrc; + fb_pixel_t *src, *dst, *topsrc; int fillcolor, i, screenwidth, swtmp; #ifdef HAVE_SPARK_HARDWARE CFrameBuffer *f = CFrameBuffer::getInstance(); @@ -5658,8 +5639,8 @@ void CopyBB2FB() return; } - src = topsrc = lbb + StartY * fix_screeninfo.line_length; - dst = lfb + StartY * fix_screeninfo.line_length; + src = topsrc = lbb + StartY * stride; + dst = lfb + StartY * stride; #ifdef USE_FBPAN #error USE_FBPAN code is not working right now. @@ -5673,7 +5654,7 @@ void CopyBB2FB() #endif /* copy line25 in normal height */ if (!pagecatching ) - memmove(dst+(24*fontheight)*fix_screeninfo.line_length, src + (24*fontheight)*fix_screeninfo.line_length, fix_screeninfo.line_length*fontheight); + memmove(dst + (24 * fontheight) * stride, src + (24 * fontheight) * stride, stride * fontheight); if (transpmode) fillcolor = transp; @@ -5681,12 +5662,12 @@ void CopyBB2FB() fillcolor = FullScrColor; if (zoommode == 2) - src += 12*fontheight*fix_screeninfo.line_length; + src += 12 * fontheight * stride; /* copy topmenu in normal height (since PIG also keeps dimensions) */ if (screenmode == 1) { - screenwidth = ( TV43STARTX ) * 4; + screenwidth = ( TV43STARTX ); #ifdef HAVE_SPARK_HARDWARE int cx = var_screeninfo.xres - TV43STARTX; /* x start */ int cw = TV43STARTX; /* width */ @@ -5694,47 +5675,43 @@ void CopyBB2FB() int ch = 24*fontheight; f->blit2FB(lbb, cw, ch, cx, cy, cx, cy, true); #else - unsigned char *topdst = dst; - size_t width = ex * sizeof(fb_pixel_t) - screenwidth; + fb_pixel_t *topdst = dst; + size_t width = (ex - screenwidth) * sizeof(fb_pixel_t); topsrc += screenwidth; topdst += screenwidth; for (i=0; i < 24*fontheight; i++) { memmove(topdst, topsrc, width); - topdst += fix_screeninfo.line_length; - topsrc += fix_screeninfo.line_length; + topdst += stride; + topsrc += stride; } #endif } else if (screenmode == 2) - screenwidth = ( TV169FULLSTARTX ) * 4; + screenwidth = ( TV169FULLSTARTX ); else - screenwidth = fix_screeninfo.line_length;//var_screeninfo.xres; + screenwidth = stride; for (i = StartY; i>0;i--) { for (swtmp=0; swtmp<=screenwidth; swtmp++) - { - memmove(dst - i*fix_screeninfo.line_length+swtmp*4, bgra[fillcolor], 4); - } + *(dst - i * stride + swtmp) = bgra[fillcolor]; } for (i = 12*fontheight; i; i--) { - memmove(dst, src, screenwidth); - dst += fix_screeninfo.line_length; - memmove(dst, src, screenwidth); - dst += fix_screeninfo.line_length; - src += fix_screeninfo.line_length; + memmove(dst, src, screenwidth * sizeof(fb_pixel_t)); + dst += stride; + memmove(dst, src, screenwidth * sizeof(fb_pixel_t)); + dst += stride; + src += stride; } for (i = var_screeninfo.yres - StartY - 25*fontheight; i >= 0;i--) { for (swtmp=0; swtmp<= screenwidth;swtmp++) - { - memmove(dst + fix_screeninfo.line_length*(fontheight+i)+swtmp*4, bgra[fillcolor], 4); - } + *(dst + stride * (fontheight + i) + swtmp) = bgra[fillcolor]; } #ifdef HAVE_SPARK_HARDWARE f->mark(0, 0, var_screeninfo.xres, var_screeninfo.yres); @@ -6056,8 +6033,8 @@ void DecodePage() RenderDRCS( page_char + 20 * (DRCSCOLS * row + col + 2), lfb - + (StartY + fontheight + DRCSYSPC * row + var_screeninfo.yres - var_screeninfo.yoffset) * fix_screeninfo.line_length - + (StartX + DRCSXSPC * col)*4, + + (StartY + fontheight + DRCSYSPC * row + var_screeninfo.yres - var_screeninfo.yoffset) * stride + + (StartX + DRCSXSPC * col), ax, white, black); memset(page_char + 40, 0xff, 24*40); /* don't render any char below row 0 */ diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index 1a6974c86..b347d6420 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -247,10 +247,11 @@ const char *ObjectType[] = #define NoServicesFound 3 /* framebuffer stuff */ -static unsigned char *lfb = 0; -static unsigned char *lbb = 0; +static fb_pixel_t *lfb = 0; +static fb_pixel_t *lbb = 0; struct fb_var_screeninfo var_screeninfo; struct fb_fix_screeninfo fix_screeninfo; +int stride; /* freetype stuff */ FT_Library library; @@ -1248,33 +1249,8 @@ const unsigned short defaultcolors[] = /* 0x0bgr */ 0x420, 0x210, 0x420, 0x000, 0x000 }; -#if !HAVE_TRIPLEDRAGON -/* 32bit colortable */ -unsigned char bgra[][5] = { -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", -"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xC0", "\0\0\0\x00", -"\0\0\0\x33" }; -#else -/* actually "ARGB" */ -unsigned char bgra[][5] = { -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", "\xFF\0\0\0", -"\xFF\0\0\0", "\xFF\0\0\0", "\xC0\0\0\0", "\x00\0\0\0", -"\x33\0\0\0" }; -#endif +/* filled in setcolors() */ +fb_pixel_t bgra[SIZECOLTABLE]; /* old 8bit color table */ unsigned short rd0[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0x00<<8, 0x00<<8, 0x00<<8, 0, 0 }; From b3e69e0a641c32992b01a7ce1bb54c23067429f5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 15 Feb 2017 20:30:52 +0100 Subject: [PATCH 10/33] fb_generic: add swidth variable, "stride in fb_pixel_t units" this should allow to use fb_pixel_t pointer arithmetics more often instead of byte pointers Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a6fc59ad6ca8adb3c5f23460ec2ced21fcb2d03e Author: Stefan Seyfried Date: 2017-02-15 (Wed, 15 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/fb_accel.cpp | 1 - src/driver/fb_accel_cs_hd1.cpp | 3 ++- src/driver/fb_accel_cs_hd2.cpp | 3 ++- src/driver/fb_accel_glfb.cpp | 3 ++- src/driver/fb_accel_sti.cpp | 1 + src/driver/fb_accel_td.cpp | 3 ++- src/driver/fb_generic.cpp | 5 ++--- src/driver/fb_generic.h | 2 +- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/driver/fb_accel.cpp b/src/driver/fb_accel.cpp index d8391ab34..ba8e052ce 100644 --- a/src/driver/fb_accel.cpp +++ b/src/driver/fb_accel.cpp @@ -82,7 +82,6 @@ void CFbAccel::paintBoxRel(const int x, const int y, const int dx, const int dy, void CFbAccel::paintRect(const int x, const int y, const int dx, const int dy, const fb_pixel_t col) { int line = 0; - int swidth = stride / sizeof(fb_pixel_t); fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); int pos; while (line < dy) diff --git a/src/driver/fb_accel_cs_hd1.cpp b/src/driver/fb_accel_cs_hd1.cpp index 4b3df3d20..9b20091cc 100644 --- a/src/driver/fb_accel_cs_hd1.cpp +++ b/src/driver/fb_accel_cs_hd1.cpp @@ -335,6 +335,7 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) return -1; } stride = _fix.line_length; + swidth = stride / sizeof(fb_pixel_t); if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) printf("screen unblanking failed\n"); xRes = screeninfo.xres; @@ -344,7 +345,7 @@ int CFbAccelCSHD1::setMode(unsigned int, unsigned int, unsigned int) int needmem = stride * yRes * 2; if (available >= needmem) { - backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + backbuffer = lfb + swidth * yRes; return 0; } fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index bc2983560..7e24aabf8 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -194,6 +194,7 @@ int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) return -1; } stride = _fix.line_length; + swidth = stride / sizeof(fb_pixel_t); if (ioctl(fd, FBIOBLANK, FB_BLANK_UNBLANK) < 0) printf("screen unblanking failed\n"); xRes = screeninfo.xres; @@ -203,7 +204,7 @@ int CFbAccelCSHD2::setMode(unsigned int, unsigned int, unsigned int) int needmem = stride * yRes * 2; if (available >= needmem) { - backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + backbuffer = lfb + swidth * yRes; return 0; } fprintf(stderr, LOGTAG "not enough FB memory (have %d, need %d)\n", available, needmem); diff --git a/src/driver/fb_accel_glfb.cpp b/src/driver/fb_accel_glfb.cpp index f6784c48f..cc4054258 100644 --- a/src/driver/fb_accel_glfb.cpp +++ b/src/driver/fb_accel_glfb.cpp @@ -54,6 +54,7 @@ void CFbAccelGLFB::init(const char *) } screeninfo = glfb->getScreenInfo(); stride = 4 * screeninfo.xres; + swidth = screeninfo.xres; available = glfb->getOSDBuffer()->size(); /* allocated in glfb constructor */ lbb = lfb = reinterpret_cast(glfb->getOSDBuffer()->data()); @@ -135,7 +136,7 @@ int CFbAccelGLFB::setMode(unsigned int, unsigned int, unsigned int) int needmem = stride * yRes * 2; if (available >= needmem) { - backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + backbuffer = lfb + swidth * yRes; return 0; } fprintf(stderr, LOGTAG " not enough FB memory (have %d, need %d)\n", available, needmem); diff --git a/src/driver/fb_accel_sti.cpp b/src/driver/fb_accel_sti.cpp index 446fc3828..dfe0ac5c3 100644 --- a/src/driver/fb_accel_sti.cpp +++ b/src/driver/fb_accel_sti.cpp @@ -512,6 +512,7 @@ int CFbAccelSTi::setMode(unsigned int, unsigned int, unsigned int) yRes = screeninfo.yres = screeninfo.yres_virtual = DEFAULT_YRES; bpp = screeninfo.bits_per_pixel = DEFAULT_BPP; stride = screeninfo.xres * screeninfo.bits_per_pixel / 8; + swidth = screeninfo.xres; return 0; } diff --git a/src/driver/fb_accel_td.cpp b/src/driver/fb_accel_td.cpp index 7033ed0bc..7ecc562c2 100644 --- a/src/driver/fb_accel_td.cpp +++ b/src/driver/fb_accel_td.cpp @@ -156,6 +156,7 @@ void CFbAccelTD::init(const char *) lbb = lfb; /* the memory area to draw to... */ available = fix.smem_len; stride = fix.line_length; + swidth = stride / sizeof(fb_pixel_t); xRes = screeninfo.xres; yRes = screeninfo.yres; bpp = screeninfo.bits_per_pixel; @@ -169,7 +170,7 @@ int CFbAccelTD::setMode(unsigned int, unsigned int, unsigned int) int needmem = stride * yRes * 2; if (available >= needmem) { - backbuffer = lfb + stride / sizeof(fb_pixel_t) * yRes; + backbuffer = lfb + swidth * yRes; return 0; } fprintf(stderr, LOGTAG " not enough FB memory (have %d, need %d)\n", available, needmem); diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 1160b9c44..1ae1ba24c 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -340,6 +340,7 @@ int CFrameBuffer::setMode(unsigned int /*nxRes*/, unsigned int /*nyRes*/, unsign } stride = _fix.line_length; + swidth = stride / sizeof(fb_pixel_t); printf("FB: %dx%dx%d line length %d. %s accelerator.\n", xRes, yRes, bpp, stride, "Not using graphics" ); @@ -623,7 +624,6 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int line++; } } else { - int swidth = stride / sizeof(fb_pixel_t); fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); int line = 0; while (line < dy) { @@ -934,7 +934,7 @@ void CFrameBuffer::paintPixel(const int x, const int y, const fb_pixel_t col) return; fb_pixel_t * pos = getFrameBufferPointer(); - pos += (stride / sizeof(fb_pixel_t)) * y; + pos += swidth * y; pos += x; *pos = col; @@ -1624,7 +1624,6 @@ void CFrameBuffer::blitBox2FB(const fb_pixel_t* boxBuf, uint32_t width, uint32_t uint32_t xc = (width > xRes) ? (uint32_t)xRes : width; uint32_t yc = (height > yRes) ? (uint32_t)yRes : height; - uint32_t swidth = stride / sizeof(fb_pixel_t); fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * yoff); fb_pixel_t* data = (fb_pixel_t*)boxBuf; diff --git a/src/driver/fb_generic.h b/src/driver/fb_generic.h index 7112a8226..c1a2d14d2 100644 --- a/src/driver/fb_generic.h +++ b/src/driver/fb_generic.h @@ -112,7 +112,7 @@ class CFrameBuffer : public sigc::trackable fb_pixel_t backgroundColor; std::string backgroundFilename; bool useBackgroundPaint; - unsigned int xRes, yRes, stride, bpp; + unsigned int xRes, yRes, stride, swidth, bpp; t_fb_var_screeninfo screeninfo; fb_cmap cmap; __u16 red[256], green[256], blue[256], trans[256]; From 3f77c93de9c1dbd95533b30d9ef4200547b92ef5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 11:29:20 +0100 Subject: [PATCH 11/33] fb_generic: use 32bit pointers instead of 8bit Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/73dc5eea7176d7d58e3d699ea723741e214f555c Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_generic.cpp | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 1ae1ba24c..0e9ed448c 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -438,7 +438,7 @@ void CFrameBuffer::paletteSet(struct fb_cmap *map) void CFrameBuffer::paintHLineRelInternal2Buf(const int& x, const int& dx, const int& y, const int& box_dx, const fb_pixel_t& col, fb_pixel_t* buf) { - uint8_t * pos = ((uint8_t *)buf) + x * sizeof(fb_pixel_t) + box_dx * sizeof(fb_pixel_t) * y; + fb_pixel_t * pos = buf + x + box_dx * y; fb_pixel_t * dest = (fb_pixel_t *)pos; for (int i = 0; i < dx; i++) *(dest++) = col; @@ -639,11 +639,11 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int void CFrameBuffer::paintVLineRelInternal(int x, int y, int dy, const fb_pixel_t col) { - uint8_t * pos = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * y; + fb_pixel_t *pos = getFrameBufferPointer() + x + swidth * y; for(int count=0;count Date: Sun, 19 Feb 2017 11:30:11 +0100 Subject: [PATCH 12/33] acinclude: move AC_SYS_LARGEFILE after AC_CANONICAL_* no idea why, but detection of 64bit largefile flags fails otherwise in some setups Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b10cd6a97344887404d42780a25a8831c662eb31 Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ This commit was generated by Migit --- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 35c3a8f49..beead1c54 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -3,7 +3,6 @@ AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE AC_GNU_SOURCE -AC_SYS_LARGEFILE AC_ARG_WITH(target, [ --with-target=TARGET target for compilation [[native,cdk]]], @@ -75,6 +74,7 @@ fi AC_CANONICAL_BUILD AC_CANONICAL_HOST +AC_SYS_LARGEFILE check_path () { return $(perl -e "if(\"$1\"=~m#^/usr/(local/)?bin#){print \"0\"}else{print \"1\";}") From 690f065e3f94f24105513a43615c688b1ea783c0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 11:52:37 +0100 Subject: [PATCH 13/33] libtuxtxt: remove unused fd parameter from tuxtx_main() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eb3fa7f2af63578f50ada67c8d919e77f414cca6 Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libtuxtxt/teletext.h | 2 +- lib/libtuxtxt/tuxtxt.cpp | 6 +++--- src/gui/movieplayer.cpp | 2 +- src/neutrino.cpp | 2 +- src/system/setting_helpers.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/libtuxtxt/teletext.h b/lib/libtuxtxt/teletext.h index 6bc3dc590..cb0037d1e 100644 --- a/lib/libtuxtxt/teletext.h +++ b/lib/libtuxtxt/teletext.h @@ -5,7 +5,7 @@ int tuxtxt_init(); void tuxtxt_close(); void tuxtxt_start(int tpid, int source = 0); // Start caching int tuxtxt_stop(); // Stop caching -int tuxtx_main(int _rc, int pid, int page = 0, int source = 0); +int tuxtx_main(int pid, int page = 0, int source = 0); void tuxtx_stop_subtitle(); int tuxtx_subtitle_running(int *pid, int *page, int *running); void tuxtx_pause_subtitle(bool pause = 1); diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index dc7d5a7c5..9dad43089 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -1561,7 +1561,7 @@ void tuxtx_pause_subtitle(bool pause) //printf("TuxTxt subtitle unpause, running %d pid %d page %d\n", reader_running, sub_pid, sub_page); ttx_paused = 0; if(!reader_running && sub_pid && sub_page) - tuxtx_main(0, sub_pid, sub_page); + tuxtx_main(sub_pid, sub_page); } else { if(!reader_running) @@ -1599,7 +1599,7 @@ void tuxtx_set_pid(int pid, int page, const char * cc) printf("TuxTxt subtitle set pid %d page %d lang %s (%d)\n", sub_pid, sub_page, cc, cfg_national_subset); ttx_paused = 1; if(sub_pid && sub_page) - tuxtx_main(0, sub_pid, sub_page); + tuxtx_main(sub_pid, sub_page); #endif } @@ -1620,7 +1620,7 @@ int tuxtx_subtitle_running(int *pid, int *page, int *running) return ret; } -int tuxtx_main(int /*_rc*/, int pid, int page, int source) +int tuxtx_main(int pid, int page, int source) { char cvs_revision[] = "$Revision: 1.95 $"; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 81687c58d..31601f30a 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1620,7 +1620,7 @@ void CMoviePlayerGui::PlayFileLoop(void) else { if (g_settings.cacheTXT) tuxtxt_stop(); - tuxtx_main(g_RCInput->getFileHandle(), g_RemoteControl->current_PIDs.PIDs.vtxtpid, 0, 2); + tuxtx_main(g_RemoteControl->current_PIDs.PIDs.vtxtpid, 0, 2); frameBuffer->paintBackground(); } if (restore) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 905879857..2526e4043 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2602,7 +2602,7 @@ void CNeutrinoApp::RealRun() StopSubtitles(); tuxtx_stop_subtitle(); - tuxtx_main(g_RCInput->getFileHandle(), g_RemoteControl->current_PIDs.PIDs.vtxtpid); + tuxtx_main(g_RemoteControl->current_PIDs.PIDs.vtxtpid); frameBuffer->paintBackground(); //if(!g_settings.cacheTXT) diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index cc728fd7a..cdd8f460a 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -362,7 +362,7 @@ printf("CSubtitleChangeExec::exec: TTX, pid %x page %x lang %s\n", pid, page, pt tuxtx_stop_subtitle(); tuxtx_set_pid(pid, page, ptr); dvbsub_stop(); - tuxtx_main(g_RCInput->getFileHandle(), pid, page); + tuxtx_main(pid, page); } return menu_return::RETURN_EXIT; } From 5505efc4372e461c34db291c7b54390d9dfac20b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 12:09:03 +0100 Subject: [PATCH 14/33] tuxtxt: remove unused dmx variable Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e906fc70e3b81bc5a7dc68df19e13676d5a32d16 Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libtuxtxt/libtuxtxt.cpp | 6 ------ lib/libtuxtxt/tuxtxt_def.h | 1 - 2 files changed, 7 deletions(-) diff --git a/lib/libtuxtxt/libtuxtxt.cpp b/lib/libtuxtxt/libtuxtxt.cpp index 40af36282..2754c24b3 100644 --- a/lib/libtuxtxt/libtuxtxt.cpp +++ b/lib/libtuxtxt/libtuxtxt.cpp @@ -36,7 +36,6 @@ int tuxtxt_init() tuxtxt_cache.thread_starting = 0; tuxtxt_cache.vtxtpid = -1; tuxtxt_cache.thread_id = 0; - tuxtxt_cache.dmx = -1; /* not sure if this is correct here... */ tuxtxt_cache.page = 0x100; return 1;//tuxtxt_init_demuxer(); @@ -82,11 +81,6 @@ void tuxtxt_close() printf ("libtuxtxt: cleaning up\n"); #endif tuxtxt_stop(); -#if 0 - if (tuxtxt_cache.dmx != -1) - close(tuxtxt_cache.dmx); -#endif - tuxtxt_cache.dmx = -1; tuxtxt_clear_cache(); tuxtxt_initialized=0; } diff --git a/lib/libtuxtxt/tuxtxt_def.h b/lib/libtuxtxt/tuxtxt_def.h index 255db1f74..6d25a0bec 100644 --- a/lib/libtuxtxt/tuxtxt_def.h +++ b/lib/libtuxtxt/tuxtxt_def.h @@ -92,7 +92,6 @@ typedef struct short flofpages[0x900][FLOFSIZE]; unsigned char adip[0x900][13]; unsigned char subpagetable[0x900]; - int dmx; int vtxtpid; int cached_pages, page, subpage, pageupdate,page_receiving, current_page[9], current_subpage[9]; int receiving, thread_starting, zap_subpage_manual; From e951cc8078b1498e4c494c0cb014ea6344cee43a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 14:34:44 +0100 Subject: [PATCH 15/33] tuxtxt: remove old framebuffer device code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/39bb1c5cad323589f8c23fe192f873b53817774b Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libtuxtxt/tuxtxt.cpp | 94 ---------------------------------------- lib/libtuxtxt/tuxtxt.h | 2 +- 2 files changed, 1 insertion(+), 95 deletions(-) diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 9dad43089..742228140 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -47,8 +47,6 @@ static int cfg_national_subset; static int screen_x, screen_y, screen_w, screen_h; -//#define USE_FBPAN // FBIOPAN_DISPLAY seems to be working in current driver - fb_pixel_t *getFBp(int *y) { if (*y < (int)var_screeninfo.yres) @@ -1519,18 +1517,6 @@ void eval_l25() /****************************************************************************** * main loop * ******************************************************************************/ -static void cleanup_fb_pan() -{ -#ifdef USE_FBPAN - if (var_screeninfo.yoffset) - { - var_screeninfo.yoffset = 0; - if (ioctl(fb, FBIOPAN_DISPLAY, &var_screeninfo) == -1) - perror("TuxTxt "); - } -#endif -} - static void* reader_thread(void * /*arg*/) { printf("TuxTxt subtitle thread started\n"); @@ -1549,7 +1535,6 @@ static void* reader_thread(void * /*arg*/) } if(!ttx_paused) CleanUp(); - cleanup_fb_pan(); tuxtxt_close(); printf("TuxTxt subtitle thread stopped\n"); pthread_exit(NULL); @@ -1571,7 +1556,6 @@ void tuxtx_pause_subtitle(bool pause) while(!ttx_paused) usleep(10); printf("TuxTxt subtitle paused\n"); - cleanup_fb_pan(); } } @@ -1644,15 +1628,6 @@ int tuxtx_main(int pid, int page, int source) printf("TuxTxt %s\n", versioninfo); printf("for 32bpp framebuffer\n"); - fb = -1; -#ifdef USE_FBPAN - if ((fb=open("/dev/fb/0", O_RDWR)) == -1) - { - perror("TuxTxt "); - return 0; - } -#endif - CFrameBuffer *fbp = CFrameBuffer::getInstance(); lfb = fbp->getFrameBufferPointer(); lbb = fbp->getBackBufferPointer(); @@ -1664,28 +1639,12 @@ int tuxtx_main(int pid, int page, int source) else printf("[tuxtxt] using PID %x page %d\n", tuxtxt_cache.vtxtpid, tuxtxt_cache.page); -#if 0 /* just get it from the framebuffer class */ - /* get fixed screeninfo */ - if (ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) - { - perror("TuxTxt "); - return 0; - } - - /* get variable screeninfo */ - if (ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) - { - perror("TuxTxt "); - return 0; - } -#else struct fb_var_screeninfo *var; var = fbp->getScreenInfo(); /* this is actually the length of the screen in pixels */ stride = fbp->getStride() / sizeof(fb_pixel_t); memcpy(&var_screeninfo, var, sizeof(struct fb_var_screeninfo)); fix_screeninfo.line_length = var_screeninfo.xres * sizeof(fb_pixel_t); -#endif /* set variable screeninfo for double buffering */ var_screeninfo.yoffset = 0; #if 0 @@ -1871,9 +1830,6 @@ int tuxtx_main(int pid, int page, int source) /* exit */ CleanUp(); - if (fb >= 0) - close(fb); - #if 1 if ( initialized ) tuxtxt_close(); @@ -2266,7 +2222,6 @@ void CleanUp() /* hide and close pig */ if (screenmode) SwitchScreenMode(0); /* turn off divided screen */ - //close(pig); #if TUXTXT_CFG_STANDALONE tuxtxt_stop_thread(); @@ -2278,9 +2233,6 @@ void CleanUp() //tuxtxt_stop(); #endif -#ifdef USE_FBPAN - cleanup_fb_pan(); -#endif //memset(lfb,0, var_screeninfo.yres*fix_screeninfo.line_length); //CFrameBuffer::getInstance()->paintBackground(); ClearFB(transp); @@ -3998,25 +3950,9 @@ void SwitchScreenMode(int newscreenmode) CFrameBuffer *f = CFrameBuffer::getInstance(); videoDecoder->Pig(tx, ty, tw, th, f->getScreenWidth(true), f->getScreenHeight(true)); -#if 0 - int sm = 0; - ioctl(pig, VIDIOC_OVERLAY, &sm); - sm = 1; - ioctl(pig, VIDIOC_G_FMT, &format); - format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - format.fmt.win.w.left = tx; - format.fmt.win.w.top = ty; - format.fmt.win.w.width = tw; - format.fmt.win.w.height = th; - ioctl(pig, VIDIOC_S_FMT, &format); - ioctl(pig, VIDIOC_OVERLAY, &sm); -#endif } else /* not split */ { -#if 0 - ioctl(pig, VIDIOC_OVERLAY, &screenmode); -#endif videoDecoder->Pig(-1, -1, -1, -1); int x = screen_x; @@ -5386,14 +5322,7 @@ void showlink(int column, int linkpage) int oldfontwidth = fontwidth; int yoffset; -#ifdef USE_FBPAN - if (var_screeninfo.yoffset) - yoffset = 0; - else - yoffset = var_screeninfo.yres; -#else yoffset = var_screeninfo.yres; //NEW -#endif int abx = ((displaywidth)%(40-nofirst) == 0 ? displaywidth+1 : (displaywidth)/(((displaywidth)%(40-nofirst)))+1);// distance between 'inserted' pixels int width = displaywidth /4; @@ -5606,23 +5535,10 @@ void CopyBB2FB() /* copy backbuffer to framebuffer */ if (!zoommode) { -#ifdef USE_FBPAN - /* if yoffset != 0, we had active page 1, and activate 0 */ - /* else active was page 0, activate page 1 */ - if (var_screeninfo.yoffset) - var_screeninfo.yoffset = 0; - else - var_screeninfo.yoffset = var_screeninfo.yres; - - //FIXME check zoom mode code - if (ioctl(fb, FBIOPAN_DISPLAY, &var_screeninfo) == -1) - perror("TuxTxt "); -#else #ifdef HAVE_SPARK_HARDWARE f->blit2FB(lbb, var_screeninfo.xres, var_screeninfo.yres, 0, 0, 0, 0, true); #else memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres); -#endif #endif /* adapt background of backbuffer if changed */ @@ -5642,16 +5558,6 @@ void CopyBB2FB() src = topsrc = lbb + StartY * stride; dst = lfb + StartY * stride; -#ifdef USE_FBPAN - #error USE_FBPAN code is not working right now. - if (var_screeninfo.yoffset) - dst += fix_screeninfo.line_length * var_screeninfo.yres; - else - { - src += fix_screeninfo.line_length * var_screeninfo.yres; - topsrc += fix_screeninfo.line_length * var_screeninfo.yres; - } -#endif /* copy line25 in normal height */ if (!pagecatching ) memmove(dst + (24 * fontheight) * stride, src + (24 * fontheight) * stride, stride * fontheight); diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index b347d6420..9c49adf03 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -593,7 +593,7 @@ char versioninfo[16]; int hotlist[10]; int maxhotlist; -int pig, fb, lcd; +int lcd; int sx, ex, sy, ey; int PosX, PosY, StartX, StartY; int lastpage; From aaf24788d4502ffcfc00d34100fc39a92f962f34 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 17:57:59 +0100 Subject: [PATCH 16/33] fb_accel_glfb: fix color palette setting Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/dce9f53654814abe91ec3110bed4a0a1632b54ba Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fb_accel_glfb.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/driver/fb_accel_glfb.cpp b/src/driver/fb_accel_glfb.cpp index cc4054258..2d9ba539f 100644 --- a/src/driver/fb_accel_glfb.cpp +++ b/src/driver/fb_accel_glfb.cpp @@ -37,6 +37,7 @@ extern GLFramebuffer *glfb; #include #include +#include #define LOGTAG "[fb_glfb] " @@ -62,6 +63,33 @@ void CFbAccelGLFB::init(const char *) setMode(720, 576, 8 * sizeof(fb_pixel_t)); blit_thread = false; + + /* Windows Colors */ + int tr = 0xff; + paletteSetColor(0x1, 0x010101, tr); + paletteSetColor(0x2, 0x800000, tr); + paletteSetColor(0x3, 0x008000, tr); + paletteSetColor(0x4, 0x808000, tr); + paletteSetColor(0x5, 0x000080, tr); + paletteSetColor(0x6, 0x800080, tr); + paletteSetColor(0x7, 0x008080, tr); + paletteSetColor(0x8, 0xA0A0A0, tr); + paletteSetColor(0x9, 0x505050, tr); + paletteSetColor(0xA, 0xFF0000, tr); + paletteSetColor(0xB, 0x00FF00, tr); + paletteSetColor(0xC, 0xFFFF00, tr); + paletteSetColor(0xD, 0x0000FF, tr); + paletteSetColor(0xE, 0xFF00FF, tr); + paletteSetColor(0xF, 0x00FFFF, tr); + paletteSetColor(0x10, 0xFFFFFF, tr); + paletteSetColor(0x11, 0x000000, tr); + paletteSetColor(COL_BACKGROUND, 0x000000, 0x0); + + paletteSet(); + + useBackground(false); + m_transparent = m_transparent_default; + /* start the autoblit-thread (run() function) */ OpenThreads::Thread::start(); }; From db982ac9433413c7e84b818ac7adc5e91900e8bc Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 18:04:50 +0100 Subject: [PATCH 17/33] tuxtxt: remove old, unused input code Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/98b7904a47032436dc05be69d7e1589eacedd456 Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libtuxtxt/tuxtxt.cpp | 140 --------------------------------------- lib/libtuxtxt/tuxtxt.h | 33 --------- 2 files changed, 173 deletions(-) diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 742228140..6caf75db8 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -6325,146 +6325,6 @@ int GetRCCode() return 0; } -#if 0 -#if 1 -int GetRCCode() -{ - struct input_event ev; - static __u16 rc_last_key = KEY_RESERVED; - - int val = fcntl(rc, F_GETFL); - if(!(val & O_NONBLOCK)) - printf("[tuxtxt] GetRCCode in blocking mode.\n"); - - /* get code */ - if (read(rc, &ev, sizeof(ev)) == sizeof(ev)) - { - if (ev.value) - { - if (ev.code != rc_last_key || - ev.code == KEY_DOWN || ev.code == KEY_UP || /* allow direction keys */ - ev.code == KEY_LEFT || ev.code == KEY_RIGHT) /* to autorepeat... */ - { - rc_last_key = ev.code; - switch (ev.code) - { - case KEY_UP: RCCode = RC_UP; break; - case KEY_DOWN: RCCode = RC_DOWN; break; - case KEY_LEFT: RCCode = RC_LEFT; break; - case KEY_RIGHT: RCCode = RC_RIGHT; break; - case KEY_OK: RCCode = RC_OK; break; - case KEY_0: RCCode = RC_0; break; - case KEY_1: RCCode = RC_1; break; - case KEY_2: RCCode = RC_2; break; - case KEY_3: RCCode = RC_3; break; - case KEY_4: RCCode = RC_4; break; - case KEY_5: RCCode = RC_5; break; - case KEY_6: RCCode = RC_6; break; - case KEY_7: RCCode = RC_7; break; - case KEY_8: RCCode = RC_8; break; - case KEY_9: RCCode = RC_9; break; - case KEY_RED: RCCode = RC_RED; break; - case KEY_GREEN: RCCode = RC_GREEN; break; - case KEY_YELLOW: RCCode = RC_YELLOW; break; - case KEY_BLUE: RCCode = RC_BLUE; break; - case KEY_VOLUMEUP: RCCode = RC_PLUS; break; - case KEY_VOLUMEDOWN: RCCode = RC_MINUS; break; - case KEY_MUTE: RCCode = RC_MUTE; break; -#if !HAVE_TRIPLEDRAGON - /* on CS, change transparent mode with TEXT key */ - case KEY_TEXT: RCCode = RC_TEXT; break; -#else - /* on TD, cycle split screen mode with TTX key - * - the TD has a special key for transparent mode */ - case KEY_TEXT: RCCode = RC_MINUS; break; -#endif - case KEY_TTTV: RCCode = RC_MUTE; break; - case KEY_TTZOOM: RCCode = RC_PLUS; break; - case KEY_REVEAL: RCCode = RC_HELP; break; - //case KEY_HELP: RCCode = RC_HELP; break; - case KEY_INFO: RCCode = RC_HELP; break; - case KEY_MENU: RCCode = RC_DBOX; break; - case KEY_EXIT: RCCode = RC_HOME; break; - case KEY_POWER: RCCode = RC_STANDBY; break; - } -printf("[tuxtxt] new key, code %X\n", RCCode); - return 1; - } - } - else - { - RCCode = -1; - rc_last_key = KEY_RESERVED; - } - } - - RCCode = -1; - usleep(1000000/25); - - return 0; -} -#else -/* this is obsolete and can soon be removed */ -int GetRCCode() -{ - static unsigned short LastKey = -1; - int count; - if ((count = read(rc, &RCCode, 2)) != 2) - { - RCCode = -1; - usleep(1000000/100); - return 0; - } - - fprintf(stderr, "rccode: %04x\n", RCCode); - if (RCCode == LastKey && - RCCode != 0x18 && RCCode != 0x19 && /* allow direction keys */ - RCCode != 0x1b && RCCode != 0x1c) /* to autorepeat... */ - { - RCCode = -1; - return 1; - } - - LastKey = RCCode; - if ((RCCode & 0xFF00) == 0x0000) - { - switch (RCCode) - { - case 0x18: RCCode = RC_UP; break; - case 0x1c: RCCode = RC_DOWN; break; - case 0x19: RCCode = RC_LEFT; break; - case 0x1b: RCCode = RC_RIGHT; break; - case 0x1a: RCCode = RC_OK; break; - case 0x0e: RCCode = RC_0; break; - case 0x02: RCCode = RC_1; break; - case 0x03: RCCode = RC_2; break; - case 0x04: RCCode = RC_3; break; - case 0x05: RCCode = RC_4; break; - case 0x06: RCCode = RC_5; break; - case 0x07: RCCode = RC_6; break; - case 0x09: RCCode = RC_7; break; - case 0x0a: RCCode = RC_8; break; - case 0x0b: RCCode = RC_9; break; - case 0x1f: RCCode = RC_RED; break; - case 0x20: RCCode = RC_GREEN; break; - case 0x21: RCCode = RC_YELLOW; break; - case 0x22: RCCode = RC_BLUE; break; - case 0x29: RCCode = RC_PLUS; break; // [=X=] key -> double height - case 0x27: RCCode = RC_MINUS; break; // [txt] key -> split mode - case 0x11: RCCode = RC_MUTE; break; - case 0x28: RCCode = RC_MUTE; break; // [ /=] key - case 0x14: RCCode = RC_HELP; break; - case 0x2a: RCCode = RC_HELP; break; // [==?] key - case 0x12: RCCode = RC_DBOX; break; - case 0x15: RCCode = RC_HOME; break; - case 0x01: RCCode = RC_STANDBY; break; - } - return 1; - } - return 1; -} -#endif -#endif /* Local Variables: */ /* indent-tabs-mode:t */ /* tab-width:3 */ diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index 9c49adf03..7ccc8994c 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -32,8 +32,6 @@ #include -#include - #include #include @@ -146,36 +144,6 @@ int tv_pip_y; #define hold_mosaic 0x1E #define release_mosaic 0x1F -#if 0 -/* rc codes */ -#define RC_0 0x00 -#define RC_1 0x01 -#define RC_2 0x02 -#define RC_3 0x03 -#define RC_4 0x04 -#define RC_5 0x05 -#define RC_6 0x06 -#define RC_7 0x07 -#define RC_8 0x08 -#define RC_9 0x09 -#define RC_RIGHT 0x0A -#define RC_LEFT 0x0B -#define RC_UP 0x0C -#define RC_DOWN 0x0D -#define RC_OK 0x0E -#define RC_MUTE 0x0F -#define RC_STANDBY 0x10 -#define RC_GREEN 0x11 -#define RC_YELLOW 0x12 -#define RC_RED 0x13 -#define RC_BLUE 0x14 -#define RC_PLUS 0x15 -#define RC_MINUS 0x16 -#define RC_HELP 0x17 -#define RC_DBOX 0x18 -#define RC_TEXT 0x19 -#define RC_HOME 0x1F -#else #define RC_0 CRCInput::RC_0 #define RC_1 CRCInput::RC_1 #define RC_2 CRCInput::RC_2 @@ -216,7 +184,6 @@ int tv_pip_y; #define RC_SPLIT (CRCInput::RC_MaxRC + 1) #define RC_TEXT CRCInput::RC_text #endif -#endif typedef enum /* object type */ { From 9734b25d6dd5c504b46291474ddfbbf037b76c51 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 18:14:57 +0100 Subject: [PATCH 18/33] tuxtxt: remove dead code, unnecessary header includes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/50cf26441fa0ba697d43548a5bcca3f7e275784d Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libtuxtxt/libtuxtxt.cpp | 4 +--- lib/libtuxtxt/tuxtxt.h | 4 ---- lib/libtuxtxt/tuxtxt_common.h | 11 ----------- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/libtuxtxt/libtuxtxt.cpp b/lib/libtuxtxt/libtuxtxt.cpp index 2754c24b3..28290ab0a 100644 --- a/lib/libtuxtxt/libtuxtxt.cpp +++ b/lib/libtuxtxt/libtuxtxt.cpp @@ -10,9 +10,7 @@ ******************************************************************************/ #define TUXTXT_DEBUG 0 - -#include -#include +#include #include "tuxtxt_def.h" #include "tuxtxt_common.h" diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index 7ccc8994c..4d8e3c452 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -21,7 +21,6 @@ #include -#include #include #include #include @@ -32,9 +31,6 @@ #include -#include -#include - #include "tuxtxt_def.h" #include diff --git a/lib/libtuxtxt/tuxtxt_common.h b/lib/libtuxtxt/tuxtxt_common.h index 0abbf87c1..52f9d419e 100644 --- a/lib/libtuxtxt/tuxtxt_common.h +++ b/lib/libtuxtxt/tuxtxt_common.h @@ -1,8 +1,6 @@ /* tuxtxt_common.h * for license info see the other tuxtxt files */ -#include -#include #include #include #include @@ -1132,15 +1130,6 @@ int tuxtxt_stop_thread() delete dmx; dmx = NULL; } -#if 0 - if (tuxtxt_cache.dmx != -1) - { - //ioctl(tuxtxt_cache.dmx, DMX_STOP); - -// close(tuxtxt_cache.dmx); - } -// tuxtxt_cache.dmx = -1; -#endif #if 1//TUXTXT_DEBUG printf("TuxTxt stopped service %x\n", tuxtxt_cache.vtxtpid); #endif From b6ef97d3671592c899885902c0dfc0e5076a0ada Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 19 Feb 2017 23:16:09 +0100 Subject: [PATCH 19/33] rcinput: use a dynamic list of input devices Instead of the fixed, static list of input devices, scan /dev/input/ for proper event devices. A "good" input device is one that supports the EVIOCGBIT ioctl and at least the EV_KEY event type. This probably needs further fixes, e.g. in repeat rate setting code. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/98557462efa77aad77c5149c52784454e43bba5c Author: Stefan Seyfried Date: 2017-02-19 (Sun, 19 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 180 ++++++++++++++++++++++++++++------------- src/driver/rcinput.h | 25 ++++-- 2 files changed, 139 insertions(+), 66 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index a262e5550..ff8e791e0 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -4,7 +4,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' 2003 thegoodguy - Copyright (C) 2008-2014,2016 Stefan Seyfried + Copyright (C) 2008-2014,2016-2017 Stefan Seyfried Copyright (C) 2013-2014 martii License: GPL @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -50,6 +49,8 @@ #include #include +#include + #include #include @@ -65,17 +66,6 @@ #define ENABLE_REPEAT_CHECK -#if HAVE_SPARK_HARDWARE -/* this relies on event0 being the AOTOM frontpanel driver device - * TODO: what if another input device is present? */ -const char * const RC_EVENT_DEVICE[NUMBER_OF_EVENT_DEVICES] = {"/dev/input/nevis_ir", "/dev/input/event0"}; -#elif HAVE_GENERIC_HARDWARE -/* the FIFO created by libstb-hal */ -const char * const RC_EVENT_DEVICE[NUMBER_OF_EVENT_DEVICES] = {"/tmp/neutrino.input"}; -#else -//const char * const RC_EVENT_DEVICE[NUMBER_OF_EVENT_DEVICES] = {"/dev/input/nevis_ir", "/dev/input/event0"}; -const char * const RC_EVENT_DEVICE[NUMBER_OF_EVENT_DEVICES] = {"/dev/input/nevis_ir"}; -#endif typedef struct input_event t_input_event; #ifdef KEYBOARD_INSTEAD_OF_REMOTE_CONTROL @@ -83,6 +73,13 @@ static struct termio orig_termio; static bool saved_orig_termio = false; #endif /* KEYBOARD_INSTEAD_OF_REMOTE_CONTROL */ static bool input_stopped = false; +static struct timespec devinput_mtime = { 0, 0 }; + +#ifdef RCDEBUG +#define d_printf printf +#else +#define d_printf(...) +#endif /********************************************************************************* * Constructor - opens rc-input device, selects rc-hardware and starts threads @@ -146,13 +143,9 @@ CRCInput::CRCInput() perror("[neutrino] listen failed...\n"); exit( -1 ); } - - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) - { - fd_rc[i] = -1; - } clickfd = -1; repeat_block = repeat_block_generic = 0; + checkdev(); open(); rc_last_key = KEY_MAX; firstKey = true; @@ -162,21 +155,93 @@ CRCInput::CRCInput() set_rc_hw(); } -/* if dev is given, open device with index , if not (re)open all */ -void CRCInput::open(int dev) +bool CRCInput::checkdev() { - if (dev == -1) - close(); - - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) - { - if (dev != -1) { - if (i != dev || fd_rc[i] != -1) - continue; + /* stat()ing the directory is fast and cheap. If a device gets added or + * removed, the mtime of /dev/input/ will change, which in turn + * warrants a more thorough investigation */ + struct stat st; + if (stat("/dev/input/", &st) == 0) { + if (st.st_mtim.tv_sec != devinput_mtime.tv_sec || + st.st_mtim.tv_nsec != devinput_mtime.tv_nsec) { + devinput_mtime.tv_sec = st.st_mtim.tv_sec; + devinput_mtime.tv_nsec = st.st_mtim.tv_nsec; + printf("[rcinput:%s] /dev/input mtime changed\n", __func__); + return true; + } + return false; /* still the same... */ + } + printf("[rcinput:%s] stat /dev/input failed: %m\n", __func__); + return true; /* need to check anyway... */ +} + +bool CRCInput::checkpath(in_dev id) +{ + for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { + if ((*it).path == id.path) { + printf("[rcinput:%s] skipping already opened %s\n", __func__, id.path.c_str()); + return true; + } + } + return false; +} + +/* if recheck == true, only not already opened devices are opened, if not, close then (re)open all */ +void CRCInput::open(bool recheck) +{ + if (recheck == false) + close(); + /* close() takes the lock, too... */ + OpenThreads::ScopedLock m_lock(mutex); + + unsigned long evbit; + struct in_dev id; + DIR *dir; + struct dirent *dentry; + dir = opendir("/dev/input"); + if (! dir) { + printf("[rcinput:%s] opendir failed: %m\n", __func__); + return; + } + + while ((dentry = readdir(dir)) != NULL) + { + if (dentry->d_type != DT_CHR) { + d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); + continue; + } + d_printf("[rcinput:%s] considering '%s'\n", __func__, dentry->d_name); + id.path = "/dev/input/" + std::string(dentry->d_name); + if (checkpath(id)) + continue; + id.fd = ::open(id.path.c_str(), O_RDWR|O_NONBLOCK|O_CLOEXEC); + if (id.fd == -1) { + printf("[rcinput:%s] open %s failed: %m\n", __func__, id.path.c_str()); + continue; + } + if (ioctl(id.fd, EVIOCGBIT(0, EV_MAX), &evbit) < 0) { + ::close(id.fd); /* not a proper input device, e.g. /dev/input/mice */ + continue; + } + if ((evbit & (1 << EV_KEY)) == 0) { + printf("[rcinput:%s] %s is bad; no EV_KEY support (0x%lx)\n", __func__, id.path.c_str(), evbit); + ::close(id.fd); + continue; + } + printf("[rcinput:%s] opened %s (fd %d) ev 0x%lx\n", __func__, id.path.c_str(), id.fd, evbit); + indev.push_back(id); + } + closedir(dir); + id.path = "/tmp/neutrino.input"; + if (! checkpath(id)) { + id.fd = ::open(id.path.c_str(), O_RDWR|O_NONBLOCK|O_CLOEXEC); + if (id.fd == -1) { + /* debug, because it only matters for HAVE_GENERIC_HARDWARE */ + d_printf("[rcinput:%s] open %s failed: %m\n", __func__, id.path.c_str()); + } else { + printf("[rcinput:%s] opened %s (fd %d)\n", __func__, id.path.c_str(), id.fd); + indev.push_back(id); } - if ((fd_rc[i] = ::open(RC_EVENT_DEVICE[i], O_RDWR|O_NONBLOCK|O_CLOEXEC)) == -1) - perror(RC_EVENT_DEVICE[i]); - printf("CRCInput::open: %s fd %d\n", RC_EVENT_DEVICE[i], fd_rc[i]); } //+++++++++++++++++++++++++++++++++++++++ @@ -224,12 +289,10 @@ void CRCInput::open(int dev) void CRCInput::close() { - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) { - if (fd_rc[i] != -1) { - ::close(fd_rc[i]); - fd_rc[i] = -1; - } - } + OpenThreads::ScopedLock m_lock(mutex); + for (unsigned int i = 0; i < indev.size(); i++) + ::close(indev[i].fd); + indev.clear(); #ifdef KEYBOARD_INSTEAD_OF_REMOTE_CONTROL if (saved_orig_termio) { @@ -251,9 +314,9 @@ void CRCInput::calculateMaxFd() { fd_max = fd_event; - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) - if (fd_rc[i] > fd_max) - fd_max = fd_rc[i]; + for (unsigned int i = 0; i < indev.size(); i++) + if (indev[i].fd > fd_max) + fd_max = indev[i].fd; if(fd_pipe_high_priority[0] > fd_max) fd_max = fd_pipe_high_priority[0]; @@ -558,10 +621,8 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 * TODO: real hot-plugging, e.g. of keyboards and triggering this loop... * right now it is only run if some event is happening "by accident" */ if (!input_stopped) { - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) { - if (fd_rc[i] == -1) - open(i); - } + if (checkdev()) + open(true); } // wiederholung reinmachen - dass wirklich die ganze zeit bis timeout gewartet wird! @@ -595,10 +656,10 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 tvselect.tv_usec = targetTimeout%1000000; FD_ZERO(&rfds); - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) + for (unsigned int i = 0; i < indev.size(); i++) { - if (fd_rc[i] != -1) - FD_SET(fd_rc[i], &rfds); + if (indev[i].fd != -1) + FD_SET(indev[i].fd, &rfds); } #ifdef KEYBOARD_INSTEAD_OF_REMOTE_CONTROL if (true) @@ -1234,19 +1295,19 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 } } - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) { - if ((fd_rc[i] != -1) && (FD_ISSET(fd_rc[i], &rfds))) { + for (std::vector::iterator i = indev.begin(); i != indev.end(); ++i) { + if (((*i).fd != -1) && (FD_ISSET((*i).fd, &rfds))) { uint64_t now_pressed = 0; t_input_event ev; memset(&ev, 0, sizeof(ev)); /* we later check for ev.type = EV_SYN = 0x00, so set something invalid here... */ ev.type = EV_MAX; - int ret = read(fd_rc[i], &ev, sizeof(t_input_event)); + int ret = read((*i).fd, &ev, sizeof(t_input_event)); if (ret != sizeof(t_input_event)) { if (errno == ENODEV) { /* hot-unplugged? */ - ::close(fd_rc[i]); - fd_rc[i] = -1; + ::close((*i).fd); + indev.erase(i); } continue; } @@ -1430,11 +1491,11 @@ void CRCInput::clearRCMsg() { t_input_event ev; - for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) + for (unsigned int i = 0; i < indev.size(); i++) { - if (fd_rc[i] != -1) + if (indev[i].fd != -1) { - while (read(fd_rc[i], &ev, sizeof(t_input_event)) == sizeof(t_input_event)) + while (read(indev[i].fd, &ev, sizeof(t_input_event)) == sizeof(t_input_event)) ; } } @@ -1688,9 +1749,12 @@ void CRCInput::play_click() void CRCInput::set_rc_hw(ir_protocol_t ir_protocol, unsigned int ir_address) { int ioctl_ret = -1; - + if (indev.empty()) { + printf("[rcinput:%s] indev is empty!\n", __func__); + return; + } //fixme?: for now fd_rc[] is hardcoded to 0 since only fd_rc[0] is used at the moment - ioctl_ret = ::ioctl(fd_rc[0], IOC_IR_SET_PRI_PROTOCOL, ir_protocol); + ioctl_ret = ::ioctl(indev[0].fd, IOC_IR_SET_PRI_PROTOCOL, ir_protocol); if(ioctl_ret < 0) perror("IOC_IR_SET_PRI_PROTOCOL"); else @@ -1700,7 +1764,7 @@ void CRCInput::set_rc_hw(ir_protocol_t ir_protocol, unsigned int ir_address) if(ir_address > 0) { //fixme?: for now fd_rc[] is hardcoded to 0 since only fd_rc[0] is used at the moment - ioctl_ret = ::ioctl(fd_rc[0], IOC_IR_SET_PRI_ADDRESS, ir_address); + ioctl_ret = ::ioctl(indev[0].fd, IOC_IR_SET_PRI_ADDRESS, ir_address); if(ioctl_ret < 0) perror("IOC_IR_SET_PRI_ADDRESS"); else diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 4bd580f3f..9a859b929 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -39,6 +39,9 @@ #include #include +#include +#include + #ifdef BOXMODEL_CS_HD2 #ifdef HAVE_COOLSTREAM_CS_IR_GENERIC_H #include @@ -138,6 +141,12 @@ class CRCInput bool correct_time; }; + struct in_dev + { + int fd; + std::string path; + }; + uint32_t timerid; std::vector timers; @@ -147,21 +156,19 @@ class CRCInput int fd_pipe_high_priority[2]; int fd_pipe_low_priority[2]; int fd_gamerc; -#ifdef HAVE_SPARK_HARDWARE -#define NUMBER_OF_EVENT_DEVICES 2 -#else -#define NUMBER_OF_EVENT_DEVICES 1 -#endif - int fd_rc[NUMBER_OF_EVENT_DEVICES]; + std::vector indev; int fd_keyb; int fd_event; int fd_max; int clickfd; __u16 rc_last_key; + OpenThreads::Mutex mutex; void set_dsp(); - void open(int dev = -1); + void open(bool recheck = false); + bool checkpath(in_dev id); + bool checkdev(); void close(); int translate(int code); void calculateMaxFd(void); @@ -280,7 +287,9 @@ class CRCInput inline int getFileHandle(void) /* used for plugins (i.e. games) only */ { - return fd_rc[0]; + if (indev.empty()) + return -1; + return indev[0].fd; } void stopInput(const bool ext = false); void restartInput(const bool ext = false); From 7256f9b6436267948bee450bcc3bf55ecb9fcfa5 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 20 Feb 2017 20:20:54 +0100 Subject: [PATCH 20/33] rcinput: add setKeyRepeatDelay() function this allows to get rid of the broken getFileHandle function later Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7a6dd0c46ed0cee6db239a8a92f0fde437fb99c6 Author: Stefan Seyfried Date: 2017-02-20 (Mon, 20 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 35 +++++++++++++++++++++++++++++++++++ src/driver/rcinput.h | 1 + 2 files changed, 36 insertions(+) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index ff8e791e0..b2268631c 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1743,6 +1743,41 @@ void CRCInput::play_click() { } +void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms) +{ + for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { + int fd = (*it).fd; + std::string path = (*it).path; + if (path == "/tmp/neutrino.input") + continue; /* setting repeat rate does not work here */ +#ifdef HAVE_COOL_HARDWARE + /* this is ugly, but the driver does not support anything advanced... */ + if (path == "/dev/input/nevis_ir") { + d_printf("[rcinput:%s] %s(fd %d) using proprietary ioctl\n", __func__, path.c_str(), fd); + ioctl(fd, IOC_IR_SET_F_DELAY, start_ms); + ioctl(fd, IOC_IR_SET_X_DELAY, repeat_ms); + continue; + } +#endif + d_printf("[rcinput:%s] %s(fd %d) writing EV_REP (%d->%d)\n", + __func__, path.c_str(), fd, start_ms, repeat_ms); + /* if we have a good input device, we don't need the private ioctl above */ + struct input_event ie; + memset(&ie, 0, sizeof(ie)); + ie.type = EV_REP; + /* increase by 10 ms to trick the repeat checker code in the + * rcinput loop into accepting the key event... */ + ie.value = start_ms + 10; + ie.code = REP_DELAY; + if (write(fd, &ie, sizeof(ie)) == -1) + printf("[rcinput:%s] %s(fd %d) write %s: %m\n", __func__, path.c_str(), fd, "REP_DELAY"); + + ie.value = repeat_ms + 10; + ie.code = REP_PERIOD; + if (write(fd, &ie, sizeof(ie)) == -1) + printf("[rcinput:%s] %s(fd %d) write %s: %m\n", __func__, path.c_str(), fd, "REP_PERIOD"); + } +} #ifdef IOC_IR_SET_PRI_PROTOCOL // hint: ir_protocol_t and other useful things are defined in cs_ir_generic.h diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 9a859b929..ac2846745 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -335,6 +335,7 @@ class CRCInput void reset_dsp(int rate); void setLongPressAny(bool b) { longPressAny = b; }; + void setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms); }; From 4edbd31fc28befe78f4e730283afdd24d623a02a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 20 Feb 2017 20:22:32 +0100 Subject: [PATCH 21/33] rcinput: fix set_rc_hw() after dynamic devices patch ...this could use some tests... :-) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/57fa882b810c30e4abb87da18a887e0128f2ce42 Author: Stefan Seyfried Date: 2017-02-20 (Mon, 20 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index b2268631c..12c7903f2 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1788,8 +1788,18 @@ void CRCInput::set_rc_hw(ir_protocol_t ir_protocol, unsigned int ir_address) printf("[rcinput:%s] indev is empty!\n", __func__); return; } - //fixme?: for now fd_rc[] is hardcoded to 0 since only fd_rc[0] is used at the moment - ioctl_ret = ::ioctl(indev[0].fd, IOC_IR_SET_PRI_PROTOCOL, ir_protocol); + int fd = -1; + for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { + if ((*it).path == "/dev/input/nevis_ir") { + fd = (*it).fd; + break; + } + } + if (fd == -1) { + printf("[rcinput:%s] no nevis_ir input device found??\n", __func__); + return; + } + ioctl_ret = ::ioctl(fd, IOC_IR_SET_PRI_PROTOCOL, ir_protocol); if(ioctl_ret < 0) perror("IOC_IR_SET_PRI_PROTOCOL"); else @@ -1799,7 +1809,7 @@ void CRCInput::set_rc_hw(ir_protocol_t ir_protocol, unsigned int ir_address) if(ir_address > 0) { //fixme?: for now fd_rc[] is hardcoded to 0 since only fd_rc[0] is used at the moment - ioctl_ret = ::ioctl(indev[0].fd, IOC_IR_SET_PRI_ADDRESS, ir_address); + ioctl_ret = ::ioctl(fd, IOC_IR_SET_PRI_ADDRESS, ir_address); if(ioctl_ret < 0) perror("IOC_IR_SET_PRI_ADDRESS"); else From fb97b3edbf73d91334f360204e9816d6f2ab757b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 20 Feb 2017 20:25:57 +0100 Subject: [PATCH 22/33] keybind_setup: use rcinput->setKeyRepeatDelay() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f308ca649ab1f73ae7b41c133f5eeff1e314cd9f Author: Stefan Seyfried Date: 2017-02-20 (Mon, 20 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/keybind_setup.cpp | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 31517ec09..7ff9bcaa1 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -573,28 +573,7 @@ bool CKeybindSetup::changeNotify(const neutrino_locale_t OptionName, void * /* d g_RCInput->repeat_block = fdelay * 1000; g_RCInput->repeat_block_generic = xdelay * 1000; - - int fd = g_RCInput->getFileHandle(); -#ifdef HAVE_COOL_HARDWARE - ioctl(fd, IOC_IR_SET_F_DELAY, fdelay); - ioctl(fd, IOC_IR_SET_X_DELAY, xdelay); -#else - /* if we have a good input device, we don't need the private ioctl above */ - struct input_event ie; - memset(&ie, 0, sizeof(ie)); - ie.type = EV_REP; - /* increase by 10 ms to trick the repeat checker code in the - * rcinput loop into accepting the key event... */ - ie.value = fdelay + 10; - ie.code = REP_DELAY; - if (write(fd, &ie, sizeof(ie)) == -1) - perror("CKeySetupNotifier::changeNotify REP_DELAY"); - - ie.value = xdelay + 10; - ie.code = REP_PERIOD; - if (write(fd, &ie, sizeof(ie)) == -1) - perror("CKeySetupNotifier::changeNotify REP_PERIOD"); -#endif + g_RCInput->setKeyRepeatDelay(fdelay, xdelay); } return false; } From e85e192d0dc22d38841a47b2cedb123037efb3ae Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 20 Feb 2017 20:26:39 +0100 Subject: [PATCH 23/33] rcinput: remove now unused (and broken) getFileHandle() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/63c3157dd8f31c6fab3b8d7bed68e9432adac75a Author: Stefan Seyfried Date: 2017-02-20 (Mon, 20 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/rcinput.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index ac2846745..93689f145 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -285,12 +285,6 @@ class CRCInput }; void set_rc_hw(void); - inline int getFileHandle(void) /* used for plugins (i.e. games) only */ - { - if (indev.empty()) - return -1; - return indev[0].fd; - } void stopInput(const bool ext = false); void restartInput(const bool ext = false); bool isLocked(void); From 37a8e1c9a41293f19df12407dc9d4ff26a105dfd Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 20 Feb 2017 20:36:45 +0100 Subject: [PATCH 24/33] rcinput: remove unused/unimplemented click functions Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9b8524b37b12ef53229253aab9153a8a9223ba84 Author: Stefan Seyfried Date: 2017-02-20 (Mon, 20 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/audioplay.cpp | 3 --- src/driver/rcinput.cpp | 26 -------------------------- src/driver/rcinput.h | 6 ------ src/gui/scan.cpp | 2 -- src/neutrino.cpp | 2 -- src/system/settings.h | 1 - 6 files changed, 40 deletions(-) diff --git a/src/driver/audioplay.cpp b/src/driver/audioplay.cpp index 956319297..494eb9baf 100644 --- a/src/driver/audioplay.cpp +++ b/src/driver/audioplay.cpp @@ -90,7 +90,6 @@ void* CAudioPlayer::PlayThread( void* /*dummy*/ ) { int soundfd = -1; set_threadname("audio:play"); - g_RCInput->close_click(); /* Decode stdin to stdout. */ CBaseDec::RetCode Status = CBaseDec::DecoderBase( &getInstance()->m_Audiofile, soundfd, @@ -109,8 +108,6 @@ void* CAudioPlayer::PlayThread( void* /*dummy*/ ) "unknown" ); } - g_RCInput->open_click(); - getInstance()->state = CBaseDec::STOP; pthread_exit(0); return NULL; diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 12c7903f2..d35c07701 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -143,7 +143,6 @@ CRCInput::CRCInput() perror("[neutrino] listen failed...\n"); exit( -1 ); } - clickfd = -1; repeat_block = repeat_block_generic = 0; checkdev(); open(); @@ -283,7 +282,6 @@ void CRCInput::open(bool recheck) //+++++++++++++++++++++++++++++++++++++++ #endif /* KEYBOARD_INSTEAD_OF_REMOTE_CONTROL */ - open_click(); calculateMaxFd(); } @@ -344,7 +342,6 @@ CRCInput::~CRCInput() if(fd_event) ::close(fd_event); - close_click(); } /************************************************************************** @@ -1416,8 +1413,6 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 *msg = trkey; *data = 0; /* <- button pressed */ - if(g_settings.key_click) - play_click(); return; } } /*if keyok */ @@ -1722,27 +1717,6 @@ int CRCInput::translate(int code) return (int)RC_nokey; } -void CRCInput::close_click() -{ -} - -void CRCInput::open_click() -{ -} -#if 0 -//never used -void CRCInput::reset_dsp(int /*rate*/) -{ -} - -void CRCInput::set_dsp() -{ -} -#endif -void CRCInput::play_click() -{ -} - void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms) { for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 93689f145..d2c29e50f 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -161,10 +161,8 @@ class CRCInput int fd_event; int fd_max; - int clickfd; __u16 rc_last_key; OpenThreads::Mutex mutex; - void set_dsp(); void open(bool recheck = false); bool checkpath(in_dev id); @@ -323,10 +321,6 @@ class CRCInput void clearRCMsg(); int messageLoop( bool anyKeyCancels = false, int timeout= -1 ); - void open_click(); - void close_click(); - void play_click(); - void reset_dsp(int rate); void setLongPressAny(bool b) { longPressAny = b; }; void setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms); diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index f9d24c9ae..de26daf1b 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -287,7 +287,6 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) success = false; if(!manual) { - g_RCInput->close_click(); if (my_system(NEUTRINO_SCAN_START_SCRIPT) != 0) perror(NEUTRINO_SCAN_START_SCRIPT " failed"); } @@ -356,7 +355,6 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) if(!manual) { if (my_system(NEUTRINO_SCAN_STOP_SCRIPT) != 0) perror(NEUTRINO_SCAN_STOP_SCRIPT " failed"); - g_RCInput->open_click(); } if(!test) { CComponentsHeaderLocalized header(x, y, width, hheight, success ? LOCALE_SCANTS_FINISHED : LOCALE_SCANTS_FAILED); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 2526e4043..c1e429075 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -4540,7 +4540,6 @@ void CNeutrinoApp::loadKeys(const char * fname) /* options */ g_settings.menu_left_exit = tconfig.getInt32( "menu_left_exit", 0 ); - g_settings.key_click = tconfig.getInt32( "key_click", 1 ); g_settings.repeat_blocker = tconfig.getInt32("repeat_blocker", 450); g_settings.repeat_genericblocker = tconfig.getInt32("repeat_genericblocker", 100); g_settings.longkeypress_duration = tconfig.getInt32("longkeypress_duration", LONGKEYPRESS_OFF); @@ -4623,7 +4622,6 @@ void CNeutrinoApp::saveKeys(const char * fname) tconfig.setInt32( "key_pic_size_active", g_settings.key_pic_size_active ); tconfig.setInt32( "menu_left_exit", g_settings.menu_left_exit ); - tconfig.setInt32( "key_click", g_settings.key_click ); tconfig.setInt32( "repeat_blocker", g_settings.repeat_blocker ); tconfig.setInt32( "repeat_genericblocker", g_settings.repeat_genericblocker ); tconfig.setInt32( "longkeypress_duration", g_settings.longkeypress_duration ); diff --git a/src/system/settings.h b/src/system/settings.h index b56e1240a..02daab6b8 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -508,7 +508,6 @@ struct SNeutrinoSettings int key_list_end; int key_power_off; int menu_left_exit; - int key_click; int timeshift_pause; int auto_timeshift; int temp_timeshift; From 82f67cbd02090cf45085ad0772cd909178f01b6e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 08:45:37 +0100 Subject: [PATCH 25/33] Revert "rcinput: Add exception handling for cs hd2" This reverts commit 7345242772ed9efedaa56d9ca794a52bb6b3e167. Wrong in so many ways :-) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/215bf871734f2c587dc0fd7a47ceeb743971e8ba Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 54 +----------------------------------------- src/driver/rcinput.h | 6 ----- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 7a5224115..f14f12320 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -177,27 +177,6 @@ bool CRCInput::checkdev() bool CRCInput::checkpath(in_dev id) { for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { -#ifdef BOXMODEL_CS_HD2 - if ((id.type == DT_LNK) || ((*it).type == DT_LNK)) { - std::string check1, check2; - if (id.type == DT_LNK) - check1 = readLink(id.path); - else - check1 = id.path; - - if ((*it).type == DT_LNK) - check2 = readLink((*it).path); - else - check2 = (*it).path; - - if ((!check1.empty()) && (!check2.empty()) && (check1 == check2)) { - printf("[rcinput:%s] skipping already opened %s => %s\n", __func__, id.path.c_str(), check1.c_str()); - return true; - } - else - return false; - } -#endif if ((*it).path == id.path) { printf("[rcinput:%s] skipping already opened %s\n", __func__, id.path.c_str()); return true; @@ -206,25 +185,6 @@ bool CRCInput::checkpath(in_dev id) return false; } -#ifdef BOXMODEL_CS_HD2 -bool CRCInput::checkLnkDev(std::string lnk) -{ - static struct stat info; - if (lstat(lnk.c_str(), &info) != -1) { - if (S_ISLNK(info.st_mode)) { - std::string tmp = readLink(lnk); - if (!tmp.empty()) { - if (lstat(tmp.c_str(), &info) != -1) { - if (S_ISCHR(info.st_mode)) - return true; - } - } - } - } - return false; -} -#endif - /* if recheck == true, only not already opened devices are opened, if not, close then (re)open all */ void CRCInput::open(bool recheck) { @@ -245,22 +205,10 @@ void CRCInput::open(bool recheck) while ((dentry = readdir(dir)) != NULL) { - if ((dentry->d_type != DT_CHR) -#ifdef BOXMODEL_CS_HD2 - && (dentry->d_type != DT_LNK) -#endif - - ) { + if (dentry->d_type != DT_CHR) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } -#ifdef BOXMODEL_CS_HD2 - if ((dentry->d_type == DT_LNK) && (!checkLnkDev("/dev/input/" + std::string(dentry->d_name)))) { - d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); - continue; - } - id.type = dentry->d_type; -#endif d_printf("[rcinput:%s] considering '%s'\n", __func__, dentry->d_name); id.path = "/dev/input/" + std::string(dentry->d_name); if (checkpath(id)) diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 37cfd4b8a..d2c29e50f 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -145,9 +145,6 @@ class CRCInput { int fd; std::string path; -#ifdef BOXMODEL_CS_HD2 - int type; -#endif }; uint32_t timerid; @@ -170,9 +167,6 @@ class CRCInput void open(bool recheck = false); bool checkpath(in_dev id); bool checkdev(); -#ifdef BOXMODEL_CS_HD2 - bool checkLnkDev(std::string lnk); -#endif void close(); int translate(int code); void calculateMaxFd(void); From 10321cbceb244fcdbc757241d978ae79fa17767c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 08:46:05 +0100 Subject: [PATCH 26/33] Revert "CRCInput::set_rc_hw: Fix device check for cs hd2" This reverts commit abe232fc6c5968859cf053013a6a80662b4cc006. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eab0a0ac0a308378f016987b1c6e5d27eb2ea6df Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index f14f12320..d35c07701 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1764,11 +1764,7 @@ void CRCInput::set_rc_hw(ir_protocol_t ir_protocol, unsigned int ir_address) } int fd = -1; for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { - if (((*it).path == "/dev/input/nevis_ir") -#ifdef BOXMODEL_CS_HD2 - || ((*it).path == "/dev/input/input0") -#endif - ){ + if ((*it).path == "/dev/input/nevis_ir") { fd = (*it).fd; break; } From 192b4158fe17cb205605beb3fc650075be896090 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 11:43:37 +0100 Subject: [PATCH 27/33] rcinput: add less ugly hack for crappy hd2 driver Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/844020b2fe7217391bbf867adbe931cb385a1b60 Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index d35c07701..da74943af 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -205,12 +205,23 @@ void CRCInput::open(bool recheck) while ((dentry = readdir(dir)) != NULL) { - if (dentry->d_type != DT_CHR) { + id.path = "/dev/input/" + std::string(dentry->d_name); + /* hack: on hd2, the device is called "/dev/cs_ir", + there are links in /dev/input: pointing to it nevis_ir and event0 (WTF???) + so if nevis_ir points to cs_ir, accept it, even though it is a symlink... + the rest of the code then uses coolstream specific parts if path == "nevis_ir" + a better solution would be to simply mknod /dev/input/nevis_ir c 240 0, creating + a second instance of /dev/cs_ir named /dv/input/nevis_ir (or to fix the driver + to actually create a real input device */ + if (dentry->d_type == DT_LNK && + id.path == "/dev/input/nevis_ir") { + if (readLink(id.path) != "/dev/cs_ir") + continue; + } else if (dentry->d_type != DT_CHR) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } d_printf("[rcinput:%s] considering '%s'\n", __func__, dentry->d_name); - id.path = "/dev/input/" + std::string(dentry->d_name); if (checkpath(id)) continue; id.fd = ::open(id.path.c_str(), O_RDWR|O_NONBLOCK|O_CLOEXEC); From 0458fd217f3bcace2079930e615dbe8b018bc8ea Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 20:05:26 +0100 Subject: [PATCH 28/33] Revert "- rc_input: rename checkLnkDev() to checkdev_lnk(); ..." This reverts commit a0481953d007ccb6853674dce706dd5382ca4059. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/63dce04974aaf858f43260024006cfe7e049a1ec Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 41 +++++++++++++++++++++-------------------- src/driver/rcinput.h | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 8357f2355..54fac46d7 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -174,25 +174,6 @@ bool CRCInput::checkdev() return true; /* need to check anyway... */ } -#ifdef BOXMODEL_CS_HD2 -bool CRCInput::checkdev_lnk(std::string lnk) -{ - static struct stat info; - if (lstat(lnk.c_str(), &info) != -1) { - if (S_ISLNK(info.st_mode)) { - std::string tmp = readLink(lnk); - if (!tmp.empty()) { - if (lstat(tmp.c_str(), &info) != -1) { - if (S_ISCHR(info.st_mode)) - return true; - } - } - } - } - return false; -} -#endif - bool CRCInput::checkpath(in_dev id) { for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { @@ -225,6 +206,25 @@ bool CRCInput::checkpath(in_dev id) return false; } +#ifdef BOXMODEL_CS_HD2 +bool CRCInput::checkLnkDev(std::string lnk) +{ + static struct stat info; + if (lstat(lnk.c_str(), &info) != -1) { + if (S_ISLNK(info.st_mode)) { + std::string tmp = readLink(lnk); + if (!tmp.empty()) { + if (lstat(tmp.c_str(), &info) != -1) { + if (S_ISCHR(info.st_mode)) + return true; + } + } + } + } + return false; +} +#endif + /* if recheck == true, only not already opened devices are opened, if not, close then (re)open all */ void CRCInput::open(bool recheck) { @@ -249,12 +249,13 @@ void CRCInput::open(bool recheck) #ifdef BOXMODEL_CS_HD2 && (dentry->d_type != DT_LNK) #endif + ) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } #ifdef BOXMODEL_CS_HD2 - if ((dentry->d_type == DT_LNK) && (!checkdev_lnk("/dev/input/" + std::string(dentry->d_name)))) { + if ((dentry->d_type == DT_LNK) && (!checkLnkDev("/dev/input/" + std::string(dentry->d_name)))) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 450dd4dd7..37cfd4b8a 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -171,7 +171,7 @@ class CRCInput bool checkpath(in_dev id); bool checkdev(); #ifdef BOXMODEL_CS_HD2 - bool checkdev_lnk(std::string lnk); + bool checkLnkDev(std::string lnk); #endif void close(); int translate(int code); From 2614197ccd19379886492883388b021a6ede603b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 20:05:54 +0100 Subject: [PATCH 29/33] Revert "- rc_input: just cosmetics to satisfy syntax-highlighters" This reverts commit bab85d298cb90b66e2035804432efecb20d4befc. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3d7f6f13c4646bddd536b6d119c217396c7ce488 Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 54fac46d7..931e23ca7 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -575,6 +575,8 @@ int CRCInput::checkTimers() return _id; } + + int64_t CRCInput::calcTimeoutEnd(const int timeout_in_seconds) { return time_monotonic_us() + ((uint64_t)timeout_in_seconds * (uint64_t) 1000000); @@ -1427,13 +1429,13 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 if (trkey == rc_last_key) { /* only allow selected keys to be repeated */ if (mayRepeat(trkey, bAllowRepeatLR) || - (g_settings.shutdown_real_rcdelay && ((trkey == RC_standby) && + (g_settings.shutdown_real_rcdelay && + ((trkey == RC_standby) && #if HAVE_COOL_HARDWARE - (cs_get_revision() > 7) + (cs_get_revision() > 7)))) #else - (g_info.hw_caps->can_shutdown) + (g_info.hw_caps->can_shutdown)))) #endif - ))) { #ifdef ENABLE_REPEAT_CHECK if (rc_last_repeat_key != trkey) { From a9f91785d46408e094720214c7a837c6ffbad7f0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 20:07:29 +0100 Subject: [PATCH 30/33] Revert "- rc_input: do always show key-presses in console; ..." This reverts commit 27011984ef2fab5ecab3a9fc05931d3df18283dc. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/41b5d78c421691720d51c78d122ecaf2eca6e19a Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 1fda8793c..989a2d872 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1344,7 +1344,7 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 } uint32_t trkey = translate(ev.code); - printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str()); + d_printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str()); if (trkey == RC_nokey) continue; From 47d8dbc86ceb2b8fc2fd1639f7d8236accab6334 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 20:29:51 +0100 Subject: [PATCH 31/33] rcinput: clarify comment regarding hd2 device Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eb6d73af7a40289d8a5e3fe83975d713b3830550 Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 989a2d872..4e1cdd1e2 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -209,10 +209,11 @@ void CRCInput::open(bool recheck) /* hack: on hd2, the device is called "/dev/cs_ir", there are links in /dev/input: pointing to it nevis_ir and event0 (WTF???) so if nevis_ir points to cs_ir, accept it, even though it is a symlink... - the rest of the code then uses coolstream specific parts if path == "nevis_ir" a better solution would be to simply mknod /dev/input/nevis_ir c 240 0, creating - a second instance of /dev/cs_ir named /dv/input/nevis_ir (or to fix the driver - to actually create a real input device */ + a second instance of /dev/cs_ir named /dev/input/nevis_ir (or to fix the driver + to actually create a real event0 device via udev) + Note: i'm deliberately not using event0, because this might be replaced by a "real" + event0 device if e.g. an USB keyboard is plugged in*/ if (dentry->d_type == DT_LNK && id.path == "/dev/input/nevis_ir") { if (readLink(id.path) != "/dev/cs_ir") From 5806b3b6df6d2b3fba8876e36a0da98ad4d9fe0e Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 21:23:11 +0100 Subject: [PATCH 32/33] fb_accel: move hd2 specific parts from fader to fb_accel Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9287d66472e9c834e23e87ef87aa9b6334a2dc22 Author: Stefan Seyfried Date: 2017-02-22 (Wed, 22 Feb 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/fade.cpp | 16 ---------------- src/driver/fb_accel_cs_hd2.cpp | 5 ++++- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/driver/fade.cpp b/src/driver/fade.cpp index 3af188521..daefa3696 100644 --- a/src/driver/fade.cpp +++ b/src/driver/fade.cpp @@ -55,11 +55,7 @@ void COSDFader::StartFadeIn() fadeIn = true; fadeOut = false; fadeValue = 100; -#ifdef BOXMODEL_CS_HD2 - frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_UNIFORM_ALPHA); // Global alpha multiplied with pixel alpha -#else frameBuffer->setBlendMode(2); // Global alpha multiplied with pixel alpha -#endif frameBuffer->setBlendLevel(fadeValue); #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_CS_HD2)) @@ -79,11 +75,7 @@ bool COSDFader::StartFadeOut() if ((!fadeOut) && g_settings.widget_fade) { fadeOut = true; fadeTimer = g_RCInput->addTimer( FADE_TIME, false ); -#ifdef BOXMODEL_CS_HD2 - frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_UNIFORM_ALPHA); // Global alpha multiplied with pixel alpha -#else frameBuffer->setBlendMode(2); // Global alpha multiplied with pixel alpha -#endif ret = true; } return ret; @@ -93,11 +85,7 @@ void COSDFader::StopFade() { if ( fadeIn || fadeOut ) { g_RCInput->killTimer(fadeTimer); -#ifdef BOXMODEL_CS_HD2 - frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_PER_PIXEL); // Global alpha multiplied with pixel alpha -#else frameBuffer->setBlendMode(1); // Global alpha multiplied with pixel alpha -#endif #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_CS_HD2)) usleep(60000); #endif @@ -124,11 +112,7 @@ bool COSDFader::FadeDone() fadeValue = max_alpha; g_RCInput->killTimer (fadeTimer); fadeIn = false; -#ifdef BOXMODEL_CS_HD2 - frameBuffer->setBlendMode(CNXTFB_BLEND_MODE_PER_PIXEL); // Global alpha multiplied with pixel alpha -#else frameBuffer->setBlendMode(1); // Global alpha multiplied with pixel alpha -#endif #if HAVE_SPARK_HARDWARE || HAVE_DUCKBOX_HARDWARE || (HAVE_COOL_HARDWARE && defined(BOXMODEL_CS_HD2)) usleep(60000); #endif diff --git a/src/driver/fb_accel_cs_hd2.cpp b/src/driver/fb_accel_cs_hd2.cpp index b801a37ff..ce20ce051 100644 --- a/src/driver/fb_accel_cs_hd2.cpp +++ b/src/driver/fb_accel_cs_hd2.cpp @@ -241,7 +241,10 @@ fb_pixel_t * CFbAccelCSHD2::getBackBufferPointer() const void CFbAccelCSHD2::setBlendMode(uint8_t mode) { - if (ioctl(fd, FBIO_SETBLENDMODE, mode)) + uint8_t arg = CNXTFB_BLEND_MODE_PER_PIXEL; + if (mode == 2) + arg = CNXTFB_BLEND_MODE_UNIFORM_ALPHA; + if (ioctl(fd, FBIO_SETBLENDMODE, arg)) printf("FBIO_SETBLENDMODE failed.\n"); } From e5694903480c5537b6649d8c7844b746c4e98202 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 25 Feb 2017 15:58:07 +0100 Subject: [PATCH 33/33] rcinput: apply ev.time adjustment to all events This fixes detection of keys that are allowed to be long-pressed if "long keypress" feature is enabled. No idea why this was applied only to key press events before :-) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/df4987ad846b1c4cb7909f1068cdec0ae75f6372 Author: Stefan Seyfried Date: 2017-02-25 (Sat, 25 Feb 2017) ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 4e1cdd1e2..83052f94a 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1322,21 +1322,19 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 } if (ev.type == EV_SYN) continue; /* ignore... */ - if (ev.value) { - /* try to compensate for possible changes in wall clock - * kernel ev.time default uses CLOCK_REALTIME, as does gettimeofday(). - * so subtract gettimeofday() from ev.time and then add - * CLOCK_MONOTONIC, which is supposed to not change with settimeofday. - * Everything would be much easier if we could use the post-kernel 3.4 - * EVIOCSCLOCKID ioctl :-) */ - struct timespec t1; - now_pressed = ev.time.tv_usec + ev.time.tv_sec * 1000000ULL; - if (!clock_gettime(CLOCK_MONOTONIC, &t1)) { - struct timeval t2; - gettimeofday(&t2, NULL); - now_pressed += t1.tv_sec * 1000000ULL + t1.tv_nsec / 1000; - now_pressed -= (t2.tv_usec + t2.tv_sec * 1000000ULL); - } + /* try to compensate for possible changes in wall clock + * kernel ev.time default uses CLOCK_REALTIME, as does gettimeofday(). + * so subtract gettimeofday() from ev.time and then add + * CLOCK_MONOTONIC, which is supposed to not change with settimeofday. + * Everything would be much easier if we could use the post-kernel 3.4 + * EVIOCSCLOCKID ioctl :-) */ + struct timespec t1; + now_pressed = ev.time.tv_usec + ev.time.tv_sec * 1000000ULL; + if (!clock_gettime(CLOCK_MONOTONIC, &t1)) { + struct timeval t2; + gettimeofday(&t2, NULL); + now_pressed += t1.tv_sec * 1000000ULL + t1.tv_nsec / 1000; + now_pressed -= (t2.tv_usec + t2.tv_sec * 1000000ULL); } SHTDCNT::getInstance()->resetSleepTimer(); if (ev.value && firstKey) {