]> git.webhop.me Git - logoview.git/commitdiff
Armbox: Init OSD master
authorMarkham <markham001@gmx.de>
Sat, 2 Jun 2018 15:47:15 +0000 (17:47 +0200)
committerMarkham <markham001@gmx.de>
Sat, 2 Jun 2018 15:47:15 +0000 (17:47 +0200)
logoview.cpp
logoview.h

index 82d00e896963d45a48db2fb1e749e06351d54d09..f824e010e216f89ea6c195325c8246e5feacc79a 100644 (file)
 #include <sys/stat.h>
 #include <signal.h>
 #include <getopt.h>
+#include <dirent.h>
 
 #include "logoview.h"
 #include "jpeg.h"
 
-#define LV_VERSION "1.01d"
+#define LV_VERSION "1.01e"
 #define VERSIONSTR "\n\
       -------------------------------------------------------------\n\
       -- logoview v" LV_VERSION " * (C)2011-2012, M. Liebmann (micha-bbg) --\n\
@@ -93,6 +94,82 @@ CLogoView::~CLogoView()
 {
        ClearThis();
 }
+#if HAVE_ARM_HARDWARE
+void CLogoView::InitOsd()
+{
+#ifdef LV_DEBUG
+       printf("[logoview] *** Init OSD  ***\n");
+#endif
+       if (access("/proc/stb/fb/dst_left", R_OK) == 0) {
+               char buffer[64];
+               sprintf(buffer, "%8x", 0);
+               proc_put("/proc/stb/fb/dst_top", buffer, strlen(buffer));
+               proc_put("/proc/stb/fb/dst_left", buffer, strlen(buffer));
+               sprintf(buffer, "%8x", 576);
+               proc_put("/proc/stb/fb/dst_height", buffer, strlen(buffer));
+               sprintf(buffer, "%8x", 720);
+               proc_put("/proc/stb/fb/dst_width", buffer, strlen(buffer));
+               sprintf(buffer, "%8x", 1);
+               proc_put("/proc/stb/fb/dst_apply", buffer, strlen(buffer));
+       }
+}
+
+int CLogoView::proc_put(const char *path, const char *value, const int len)
+{
+       int ret, ret2;
+       int pfd = open(path, O_WRONLY);
+       if (pfd < 0)
+               return pfd;
+       ret = write(pfd, value, len);
+       ret2 = close(pfd);
+       if (ret2 < 0)
+               return ret2;
+       return ret;
+}
+
+int CLogoView::getpidof(const char *process)
+{
+       DIR *dp;
+       struct dirent *entry;
+       struct stat statbuf;
+
+       if ((dp = opendir("/proc")) == NULL)
+       {
+               fprintf(stderr, "Cannot open directory /proc\n");
+               return -1;
+       }
+
+       while ((entry = readdir(dp)) != NULL)
+       {
+               // get information about the file/folder
+               lstat(entry->d_name, &statbuf);
+               // files under /proc which start with a digit are processes
+               if (S_ISDIR(statbuf.st_mode) && isdigit(entry->d_name[0]))
+               {
+                       // 14 chars for /proc//status + 0
+                       char procpath[14 + strlen(entry->d_name)];
+                       char procname[50];
+                       FILE *file;
+
+                       sprintf(procpath, "/proc/%s/status", entry->d_name);
+
+                       if (! (file = fopen(procpath, "r")) ) {
+                               continue;
+                       }
+
+                       fscanf(file,"%*s %s", procname);
+                       fclose(file);
+
+                       // only 15 char available
+                       if (strncmp(procname, process, 15) == 0) {
+                               return atoi(entry->d_name);
+                       }
+               }
+       }
+       closedir (dp);
+       return 0;
+}
+#endif
 
 void CLogoView::SetScreenBuf(unsigned char *buf, int r, int g, int b, int t)
 {
@@ -301,6 +378,11 @@ int CLogoView::run(int argc, char* argv[])
                        default: return 0;
                }
        }
+#if HAVE_ARM_HARDWARE
+       if (! getpidof("neutrino"))
+               InitOsd();
+#endif
+
 #if 1
        fb = -1;
        int count = 0;
@@ -380,8 +462,11 @@ TIMER_START();
                return -1;
        }
 TIMER_STOP("[logoview] load pic       ");
-
+#if HAVE_ARM_HARDWARE
+       int skalFaktor = 1;
+#else
        int skalFaktor = 8;
+#endif
        int skalKorr   = 2;
 
        if ( var_screeninfo.xres <= 2*skalFaktor + (var_screeninfo.xres - (screen_StartX + (var_screeninfo.xres - screen_EndX))))
@@ -402,7 +487,8 @@ TIMER_STOP("[logoview] load pic       ");
 //printf("##### tmp_xres: %d, tmp_yres: %d, xres: %d, yres: %d\n", tmp_xres, tmp_yres, xres, yres);
 
 TIMER_START();
-       PicBuf = Resize(PicBuf, x, y, xres, yres, false);
+       if ( x != (int)xres || y != (int)yres)
+               PicBuf = Resize(PicBuf, x, y, xres, yres, false);
 TIMER_STOP("[logoview] Resize         ");
 #ifdef LV_DEBUG
        printf("[logoview] %s - %dx%d, resize to %dx%d\n", start_logo.c_str(), x, y, xres, yres);
index b6c5edbcbdd1682833637061313b2ad8cd76b2b9..b254952e73368b3edb493cbe730aeca53eaff170 100644 (file)
@@ -88,6 +88,11 @@ class CLogoView
                bool ReadConfig();
                unsigned char * Resize(unsigned char *orgin, int ox, int oy, int dx, int dy, bool alpha);
                void SetScreenBuf(unsigned char *buf, int r, int g, int b, int t);
+#if HAVE_ARM_HARDWARE
+               void InitOsd();
+               int proc_put(const char *path, const char *value, const int len);
+               int getpidof(const char *process);
+#endif
 };
 
 #ifdef LV_DEBUG