]> git.webhop.me Git - logomask.git/commitdiff
* initial commit
authorsvenhoefer <svenhoefer@svenhoefer.com>
Tue, 14 Aug 2012 20:13:47 +0000 (22:13 +0200)
committersvenhoefer <svenhoefer@svenhoefer.com>
Tue, 14 Aug 2012 20:13:47 +0000 (22:13 +0200)
14 files changed:
gfx.c [new file with mode: 0644]
gfx.h [new file with mode: 0644]
io.c [new file with mode: 0644]
io.h [new file with mode: 0644]
lmask [new file with mode: 0755]
logomask.c [new file with mode: 0644]
logomask.cfg [new file with mode: 0644]
logomask.h [new file with mode: 0644]
logoset.c [new file with mode: 0644]
logoset.cfg [new file with mode: 0644]
logoset.h [new file with mode: 0644]
starter_logomask.c [new file with mode: 0644]
text.c [new file with mode: 0644]
text.h [new file with mode: 0644]

diff --git a/gfx.c b/gfx.c
new file mode 100644 (file)
index 0000000..7b66830
--- /dev/null
+++ b/gfx.c
@@ -0,0 +1,60 @@
+#include "logomask.h"
+#include "gfx.h"
+
+gpixel *make_color(int col, gpixel *pix)
+{
+       pix->cpixel.bl=bl[col];
+       pix->cpixel.gn=gn[col];
+       pix->cpixel.rd=rd[col];
+       pix->cpixel.tr=tr[col];
+       return pix;
+};
+
+void RenderBox(int sx, int sy, int ex, int ey, int mode, gpixel *pix)
+{
+       int F,ssx=startx+sx,ssy=starty+sy,dxx=ex-sx,dyy=ey-sy,rx,ry,wx,wy,count;
+
+       unsigned char *pos=(lbb+(ssx<<2)+fix_screeninfo.line_length*ssy);
+       unsigned char *pos0, *pos1, *pos2, *pos3, *i;
+               
+       if (dxx<0) 
+       {
+               printf("[gfx.c] RenderBox called with dx < 0 (%d)\n", dxx);
+               dxx=0;
+       }
+
+       if(mode==FILL)
+       {
+               for (count=0; count<dyy; count++)
+               {
+                       for(i=pos; i<pos+(dxx<<2);i+=4)
+                               memcpy(i, pix, 4);
+                       pos+=fix_screeninfo.line_length;
+               }
+       }
+       else
+       {
+               for (count=0; count<2 && count<dyy-2; count++)
+               {
+                       for(i=pos; i<pos+(dxx<<2);i+=4)
+                               memcpy(i, pix, 4);
+                       pos+=fix_screeninfo.line_length;
+               }
+               for (count=2; count<dyy-2; count++)
+               {
+                       memcpy(pos, pix, 4);
+                       memcpy(pos+4, pix, 4);
+                       memcpy(pos+((dxx-2)<<2), pix, 4);
+                       memcpy(pos+((dxx-1)<<2), pix, 4);
+                       pos+=fix_screeninfo.line_length;
+               }
+               for (count=0; count<2 && count<dyy-2; count++)
+               {
+                       for(i=pos; i<pos+(dxx<<2);i+=4)
+                               memcpy(i, pix, 4);
+                       pos+=fix_screeninfo.line_length;
+               }
+       }
+}
+
+
diff --git a/gfx.h b/gfx.h
new file mode 100644 (file)
index 0000000..63dc110
--- /dev/null
+++ b/gfx.h
@@ -0,0 +1,15 @@
+#ifndef __GFX_H__
+
+#define __GFX_H__
+
+typedef struct {unsigned char bl; unsigned char gn; unsigned char rd; unsigned char tr;} pixstruct;
+typedef union {
+       unsigned long lpixel;
+       pixstruct cpixel;
+} gpixel;
+
+gpixel *make_color(int col, gpixel *pix);
+
+void RenderBox(int sx, int sy, int ex, int ey, int mode, gpixel *pix);
+
+#endif
diff --git a/io.c b/io.c
new file mode 100644 (file)
index 0000000..67f8553
--- /dev/null
+++ b/io.c
@@ -0,0 +1,77 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <locale.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <time.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/dir.h>
+#include <sys/stat.h>
+#include <linux/input.h>
+
+#include "io.h"
+
+#define RC_DEVICE      "/dev/input/nevis_ir"
+
+extern int instance;
+struct input_event ev;
+static unsigned short rccode=-1;
+static int rc;
+
+int InitRC(void)
+{
+       rc = open(RC_DEVICE, O_RDONLY);
+       if(rc == -1)
+       {
+               perror("msgbox <open remote control>");
+               exit(1);
+       }
+       fcntl(rc, F_SETFL, O_NONBLOCK | O_SYNC);
+       while(RCKeyPressed());
+       return 1;
+}
+
+int CloseRC(void)
+{
+       while(RCKeyPressed());
+       close(rc);
+       return 1;
+}
+
+int RCKeyPressed(void)
+{
+       if(read(rc, &ev, sizeof(ev)) == sizeof(ev))
+       {
+               if(ev.value)
+               {
+                       rccode=ev.code;
+                       return 1;
+               }
+       }
+       rccode = -1;
+       return 0;
+}
+
+
+int GetRCCode(void)
+{
+       int rv;
+       
+       if(!RCKeyPressed())
+       {
+               return -1;
+       }
+       rv=rccode;
+//     while(RCKeyPressed());
+       
+       return rv;
+}
+
+
diff --git a/io.h b/io.h
new file mode 100644 (file)
index 0000000..d7914d4
--- /dev/null
+++ b/io.h
@@ -0,0 +1,11 @@
+#ifndef __IO_H__
+
+#define __IO_H__
+
+#define RC_DEVICE      "/dev/input/nevis_ir"
+
+int InitRC(void);
+int CloseRC(void);
+int RCKeyPressed(void);
+
+#endif
diff --git a/lmask b/lmask
new file mode 100755 (executable)
index 0000000..e5d948d
--- /dev/null
+++ b/lmask
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if pidof logomask > /dev/null; then
+       touch /tmp/.logomask_kill
+else
+       logomask &
+fi
+exit 0
diff --git a/logomask.c b/logomask.c
new file mode 100644 (file)
index 0000000..7f1102c
--- /dev/null
@@ -0,0 +1,345 @@
+#include <string.h>
+#include <time.h>
+#include "logomask.h"
+#include "gfx.h"
+
+extern int FSIZE_BIG;
+extern int FSIZE_MED;
+extern int FSIZE_SMALL;
+
+#define NCF_FILE "/var/tuxbox/config/neutrino.conf"
+#define CFG_FILE "/var/tuxbox/config/logomask.conf"
+
+#define CL_VERSION  "1.00"
+#define MAX_MASK 16
+
+//                                     TRANSP, BLACK,  RED,    GREEN,  YELLOW, BLUE,   MAGENTA, TURQUOISE,
+//                                     WHITE,  GRAY,   LRED,   LGREEN, LYELLOW,LBLUE,  LMAGENTA,LTURQUOISE
+unsigned char
+                       rd[]={  0x00,   0x00,   0x80,   0x00,   0x80,   0x00,   0x80,   0x00,
+                                       0xFF,   0x80,   0xFF,   0x00,   0xFF,   0x00,   0xFF,   0x00
+                                },
+                       gn[]={  0x00,   0x00,   0x00,   0x80,   0x80,   0x00,   0x00,   0x80,
+                                       0xFF,   0x80,   0x00,   0xFF,   0xFF,   0x00,   0x00,   0xFF
+                                },
+                        bl[]={ 0x00,   0x00,   0x00,   0x00,   0x00,   0x80,   0x80,   0x80,
+                                       0xFF,   0x80,   0x00,   0x00,   0x00,   0xFF,   0xFF,   0xFF
+                            },
+                        tr[]={ 0x00,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,
+                                       0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF
+                                 };
+
+unsigned char *lfb = 0, *lbb = 0;
+char tstr[BUFSIZE];
+int xpos=0,ypos=0,sdat=0,big=0,secs=1;
+gpixel lpix;
+
+void TrimString(char *strg)
+{
+char *pt1=strg, *pt2=strg;
+
+       while(*pt2 && *pt2<=' ')
+       {
+               ++pt2;
+       }
+       if(pt1 != pt2)
+       {
+               do
+               {
+                       *pt1=*pt2;
+                       ++pt1;
+                       ++pt2;
+               }
+               while(*pt2);
+               *pt1=0;
+       }
+       while(strlen(strg) && strg[strlen(strg)-1]<=' ')
+       {
+               strg[strlen(strg)-1]=0;
+       }
+}
+int Read_Neutrino_Cfg(char *entry)
+{
+FILE *nfh;
+char *cfptr=NULL;
+int rv=-1;
+
+       if((nfh=fopen(NCF_FILE,"r"))!=NULL)
+       {
+               tstr[0]=0;
+
+               while((!feof(nfh)) && ((strstr(tstr,entry)==NULL) || ((cfptr=strchr(tstr,'='))==NULL)))
+               {
+                       fgets(tstr,500,nfh);
+               }
+               if(!feof(nfh) && cfptr)
+               {
+                       ++cfptr;
+                       if(sscanf(cfptr,"%d",&rv)!=1)
+                       {
+                               rv=-1;
+                       }
+//                     printf("%s\n%s=%s -> %d\n",tstr,entry,cfptr,rv);
+               }
+               fclose(nfh);
+       }
+       return rv;
+}
+
+/******************************************************************************
+ * logomask Main
+ ******************************************************************************/
+
+int main (int argc, char **argv)
+{
+       int i,j,m,found,loop=1,mask=0,test=0,pmode=0,lmode=0,mchanged=1,cchanged=2,mwait;
+       unsigned char lastchan[20]="", actchan[20]=""/*,channel[128]=""*/;
+       int xp[MAX_MASK][8],yp[MAX_MASK][8],xw[MAX_MASK][8],yw[MAX_MASK][8],valid[MAX_MASK],xxp,xxw,yyp,yyw,nmsk=0;
+       gpixel tp, cmc, mc[MAX_MASK];
+       FILE *fh;
+       char *cpt1,*cpt2;
+       
+               if(argc==2 && strstr(argv[1],"test")!=NULL)
+               {
+                       test=1;
+               }
+               printf("logomask Version %s\n",CL_VERSION);
+               if((mwait=Read_Neutrino_Cfg("timing.infobar"))<0)
+                       mwait=6;
+               
+//             mwait-=1;
+
+               fb = open(FB_DEVICE, O_RDWR);
+
+               if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
+               {
+                       printf("logomask <FBIOGET_FSCREENINFO failed>\n");
+                       return -1;
+               }
+               if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
+               {
+                       printf("logomask <FBIOGET_VSCREENINFO failed>\n");
+                       return -1;
+               }
+               
+               if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
+               {
+                       printf("logomask <mapping of Framebuffer failed>\n");
+                       return -1;
+               }
+
+       //init backbuffer
+
+               if(!(lbb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
+               {
+                       printf("logomask <allocating of Backbuffer failed>\n");
+                       munmap(lfb, fix_screeninfo.smem_len);
+                       return -1;
+               }
+
+               memset(lbb, 0, fix_screeninfo.line_length*var_screeninfo.yres);
+//             memset(mc, BLACK, sizeof(mc));
+               startx = sx;
+               starty = sy;
+
+
+       // if problem with config file return from plugin
+
+               while(loop)
+               {
+                       sleep(1);
+                       mchanged=0;
+                       system("pzapit -var > /tmp/logomaskset.stat");
+                       if((fh=fopen("/tmp/logomaskset.stat","r"))!=NULL)
+                       {
+                               if(fgets(tstr,500,fh))
+                               {
+                                       TrimString(tstr);
+                                       if(strlen(tstr))
+                                       {
+                                               lmode=pmode;
+                                               if(sscanf(tstr+strlen(tstr)-1,"%d",&i)!=1)
+                                               {
+                                                       pmode=0;
+                                               }
+                                               else
+                                               {
+                                                       mchanged=(pmode!=i);
+                                                       pmode=i;
+                                               }
+                                       }
+                               }
+                               fclose(fh);
+                       }
+
+                       system("pzapit -gi > /tmp/logomask.chan");
+                       if((fh=fopen("/tmp/logomask.chan","r"))!=NULL)
+                       {
+                               if(fgets(tstr, BUFSIZE, fh))
+                               {
+                                       TrimString(tstr);
+                                       if((cpt1=strchr(tstr,' '))!=NULL)
+                                               *cpt1=0;
+                               }
+                               fclose(fh);
+                               if(strlen(tstr))
+                               {
+                                       strcpy(actchan,tstr);
+                                       cchanged=(cchanged==2)?3:((strcmp(actchan,lastchan)?1:0));
+                                       if(mchanged || cchanged)
+                                       {
+                                               found=0;
+                                               if(cchanged)
+                                               {
+                                                       if(cchanged==1)
+                                                       {
+                                                               sleep(mwait);
+                                                       }
+                                                       cchanged=1;
+                                               }
+                                               if(mask)
+                                               {
+                                                       for(m=0; m<nmsk; m++)
+                                                       {
+                                                               if(valid[m])
+                                                               {
+                                                                       xxp=xp[m][lmode];
+                                                                       xxw=xw[m][lmode];                               
+                                                                       yyp=yp[m][lmode];
+                                                                       yyw=yw[m][lmode];
+                                                                       make_color(TRANSP, &cmc);
+                                                                       RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL,&cmc);
+                                                                       for(i=0;i<=yyw;i++)
+                                                                       {
+                                                                               j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
+                                                                               if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
+                                                                               {
+                                                                                       memcpy(lfb+j, lbb+j, xxw<<2);
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                               mask=0;
+                                               
+                                       if((fh=fopen(CFG_FILE,"r"))!=NULL)
+                                       {
+                                               strcpy(lastchan,actchan);
+                                               found=0;
+                                               while(fgets(tstr, BUFSIZE, fh) && !found)
+                                               {
+                                                       TrimString(tstr);
+                                                       if(strlen(tstr))
+                                                       {
+                                                               if(strstr(tstr,actchan)!=NULL)
+                                                               {
+                                                                       mask=1;
+                                                                       nmsk=0;
+                                                                       cpt2=strstr(tstr,",MC");
+                                                                       if((cpt1=strchr(tstr,','))!=NULL)
+                                                                       {
+                                                                               while(cpt1)
+                                                                               {
+                                                                                       valid[nmsk]=0;
+                                                                                       if(cpt2 && sscanf(cpt2+1,"MC%8x",&tp)==1)
+                                                                                       {
+                                                                                               cmc.lpixel=tp.lpixel;
+                                                                                               cpt2=strchr(cpt2+1,',');
+                                                                                       }
+                                                                                       else
+                                                                                       {
+                                                                                               make_color(BLACK, &cmc);
+                                                                                       }
+                                                                                       for(i=0; i<8 && cpt1; i++)
+                                                                                       {
+                                                                                               cpt1++;
+                                                                                               if(sscanf(cpt1,"%d,%d,%d,%d",&xxp,&xxw,&yyp,&yyw)==4)
+                                                                                               {
+                                                                                                       xp[nmsk][i]=xxp;
+                                                                                                       xw[nmsk][i]=xxw;
+                                                                                                       yp[nmsk][i]=yyp;
+                                                                                                       yw[nmsk][i]=yyw;
+                                                                                                       mc[nmsk].lpixel=cmc.lpixel;
+                                                                                                       found=1;
+                                                                                                       valid[nmsk]=1;
+                                                                                               }
+                                                                                               for(j=0; j<4 && cpt1; j++)
+                                                                                               {
+                                                                                                       cpt1=strchr(cpt1+1,',');
+                                                                                               }
+                                                                                       }
+                                                                                       if(valid[nmsk])
+                                                                                       {
+                                                                                               nmsk++;
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                               fclose(fh);
+                                       }
+                               }
+                       }
+                       if(mask)
+                       {
+                               for(m=0; m<nmsk; m++)
+                               {
+                                       if(valid[m])
+                                       {
+                                               xxp=xp[m][pmode];
+                                               xxw=xw[m][pmode];                               
+                                               yyp=yp[m][pmode];
+                                               yyw=yw[m][pmode];
+                                               cmc.lpixel=mc[m].lpixel;
+                                               RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, (test)?GRID:FILL, &cmc);
+                                               for(i=0;i<=yyw;i++)
+                                               {
+                                                       j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
+                                                       if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
+                                                       {
+                                                               memcpy(lfb+j, lbb+j, xxw<<2);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       if(++loop>5)
+                       {
+                               if(access("/tmp/.logomask_kill",0)!=-1)
+                               {
+                                       loop=0;
+                               }
+                       }       
+               }
+       }
+
+       make_color(TRANSP, &cmc);
+       for(m=0; m<nmsk; m++)
+       {
+               if(valid[m])
+               {
+                       xxp=xp[m][pmode];
+                       xxw=xw[m][pmode];                               
+                       yyp=yp[m][pmode];
+                       yyw=yw[m][pmode];
+                       RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &cmc);
+                       for(i=0;i<=yyw;i++)
+                       {
+                               j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
+                               if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
+                               {
+                                       memcpy(lfb+j, lbb+j, xxw<<2);
+                               }
+                       }
+               }
+       }
+
+       free(lbb);
+       munmap(lfb, fix_screeninfo.smem_len);
+       close(fb);
+       remove("/tmp/.logomask_kill");
+       remove("/tmp/logomask.*");
+       return 0;
+}
+
diff --git a/logomask.cfg b/logomask.cfg
new file mode 100644 (file)
index 0000000..0459f86
--- /dev/null
@@ -0,0 +1,7 @@
+type=2
+name=Logomaskierung ein/aus
+desc=Senderlogos maskieren
+needfb=1
+needrc=1
+needlcd=0
+needoffs=1
diff --git a/logomask.h b/logomask.h
new file mode 100644 (file)
index 0000000..841b057
--- /dev/null
@@ -0,0 +1,99 @@
+#ifndef __logomask_H__
+
+#define __logomask_H__
+
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <linux/fb.h>
+#if HAVE_DVB_API_VERSION == 3
+#include <linux/input.h>
+#endif
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+// rc codes
+
+#undef KEY_EPG
+#undef KEY_SAT
+#undef KEY_STOP
+#undef KEY_PLAY
+
+#define KEY_1                                  2
+#define KEY_2                                  3
+#define KEY_3                                  4
+#define KEY_4                                  5
+#define KEY_5                                  6
+#define KEY_6                                  7
+#define KEY_7                                  8
+#define KEY_8                                  9
+#define KEY_9                                  10
+#define KEY_BACKSPACE           14
+#define KEY_UP                  103
+#define KEY_LEFT                105
+#define KEY_RIGHT               106
+#define KEY_DOWN                108
+#define KEY_MUTE                113
+#define KEY_VOLUMEDOWN          114
+#define KEY_VOLUMEUP            115
+#define KEY_POWER               116
+#define KEY_HELP                138
+#define KEY_HOME                102
+#define KEY_EXIT                                174
+#define KEY_SETUP               141
+#define KEY_PAGEUP              104
+#define KEY_PAGEDOWN            109
+#define KEY_OK                         0x160
+#define KEY_RED                        0x18e
+#define KEY_GREEN                      0x18f
+#define KEY_YELLOW                     0x190
+#define KEY_BLUE                       0x191
+
+#define KEY_TVR                                        0x179
+#define KEY_TTX                                        0x184
+#define KEY_COOL                               0x1A1
+#define KEY_FAV                                        0x16C
+#define KEY_EPG                                        0x16D
+#define KEY_VF                                 0x175
+
+#define KEY_SAT                                        0x17D
+#define KEY_SKIPP                              0x197
+#define KEY_SKIPM                              0x19C
+#define KEY_TS                                 0x167
+#define KEY_AUDIO                              0x188
+#define KEY_REW                                        0x0A8
+#define KEY_FWD                                        0x09F
+#define KEY_HOLD                               0x077
+#define KEY_REC                                        0x0A7
+#define KEY_STOP                               0x080
+#define KEY_PLAY                               0x0CF
+
+//devs
+int fb, rc;
+
+//framebuffer stuff
+
+enum {FILL, GRID};
+
+enum {TRANSP, BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, TURQUOISE, WHITE, GRAY, LRED, LGREEN, LYELLOW, LBLUE, LMAGENTA, LTURQUOISE};
+
+extern unsigned char rd[], gn[], bl[], tr[];
+extern unsigned char *lfb, *lbb;
+
+struct fb_fix_screeninfo fix_screeninfo;
+struct fb_var_screeninfo var_screeninfo;
+
+int startx, starty, sx, ex, sy, ey;
+char online;
+
+#define FB_DEVICE      "/dev/fb/0"
+
+#define BUFSIZE 4096
+
+#endif
diff --git a/logoset.c b/logoset.c
new file mode 100644 (file)
index 0000000..6020082
--- /dev/null
+++ b/logoset.c
@@ -0,0 +1,794 @@
+#include <string.h>
+#include <time.h>
+#include "logoset.h"
+#include "io.h"
+#include "gfx.h"
+#include "text.h"
+
+extern int FSIZE_BIG;
+extern int FSIZE_MED;
+extern int FSIZE_SMALL;
+
+#define NCF_FILE "/var/tuxbox/config/neutrino.conf"
+#define CFG_FILE "/var/tuxbox/config/logomask.conf"
+unsigned char FONT[64]= "/share/fonts/pakenham.ttf";
+
+#define CL_VERSION  "1.00"
+#define MAX_MASK 16
+
+//                                     TRANSP, BLACK,  RED,    GREEN,  YELLOW, BLUE,   MAGENTA, TURQUOISE,
+//                                     WHITE,  GRAY,   LRED,   LGREEN, LYELLOW,LBLUE,  LMAGENTA,LTURQUOISE
+unsigned char
+                       rd[]={  0x00,   0x00,   0x80,   0x00,   0x80,   0x00,   0x80,   0x00,
+                                       0xFF,   0x80,   0xFF,   0x00,   0xFF,   0x00,   0xFF,   0x00
+                                },
+                       gn[]={  0x00,   0x00,   0x00,   0x80,   0x80,   0x00,   0x00,   0x80,
+                                       0xFF,   0x80,   0x00,   0xFF,   0xFF,   0x00,   0x00,   0xFF
+                                },
+                        bl[]={ 0x00,   0x00,   0x00,   0x00,   0x00,   0x80,   0x80,   0x80,
+                                       0xFF,   0x80,   0x00,   0x00,   0x00,   0xFF,   0xFF,   0xFF
+                            },
+                        tr[]={ 0x00,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,
+                                       0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF,   0xFF
+                                 };
+
+
+unsigned char *lfb = 0, *lbb = 0;
+char tstr[BUFSIZE];
+gpixel lpix;
+
+
+void TrimString(char *strg)
+{
+char *pt1=strg, *pt2=strg;
+
+       while(*pt2 && *pt2<=' ')
+       {
+               ++pt2;
+       }
+       if(pt1 != pt2)
+       {
+               do
+               {
+                       *pt1=*pt2;
+                       ++pt1;
+                       ++pt2;
+               }
+               while(*pt2);
+               *pt1=0;
+       }
+       while(strlen(strg) && strg[strlen(strg)-1]<=' ')
+       {
+               strg[strlen(strg)-1]=0;
+       }
+}
+
+/******************************************************************************
+ * logoset Main
+ ******************************************************************************/
+
+int main (int argc, char **argv)
+{
+       int i,j,found=0,m,mask=1,kmode=1,pmode=0, lc=-1, changed=0, todo=1, help=1, help_changed=0, move=0;
+       unsigned char actchan[20]=""/*,channel[128]=""*/;
+       FILE *fh,*fh2;
+       char *cpt1,*cpt2;
+       gpixel mp, mc[MAX_MASK], tp;
+       int tsx=startx+450, tsy=starty+120, tdy=24, tsz=28, txw=500, tcol=TURQUOISE;
+       int xp[MAX_MASK][8],yp[MAX_MASK][8],xw[MAX_MASK][8],yw[MAX_MASK][8],valid[MAX_MASK],cmc[MAX_MASK],xxp,xxw,yyp,yyw,nmsk=0,amsk=0;
+       double xs=1.0, ys=1.0;
+       time_t t1,t2;
+
+               for(j=0; j<MAX_MASK; j++)
+               {
+                       valid[j]=0;
+                       cmc[j]=BLACK;
+                       make_color(BLACK, &mc[j]);
+                       for(i=0; i<8; i++)
+                       {
+                               xp[j][i]=(1280-40)/2;
+                               xw[j][i]=40;
+                               yp[j][i]=(720-20)/2;
+                               yw[j][i]=20;
+                       }       
+               }
+               system("pzapit -var > /tmp/logomaskset.stat");
+               if((fh=fopen("/tmp/logomaskset.stat","r"))!=NULL)
+               {
+                       if(fgets(tstr,500,fh))
+                       {
+                               TrimString(tstr);
+                               if(strlen(tstr))
+                               {
+                                       if(sscanf(tstr+strlen(tstr)-1,"%d",&pmode)!=1)
+                                       {
+                                               pmode=0;
+                                       }
+                               }
+                       }
+               }
+       
+               system("touch /tmp/.logomask_kill");
+
+               fb = open(FB_DEVICE, O_RDWR);
+
+               if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
+               {
+                       printf("logomask <FBIOGET_FSCREENINFO failed>\n");
+                       return -1;
+               }
+               if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
+               {
+                       printf("logomask <FBIOGET_VSCREENINFO failed>\n");
+                       return -1;
+               }
+               
+               if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
+               {
+                       printf("logomask <mapping of Framebuffer failed>\n");
+                       return -1;
+               }
+
+       //init fontlibrary
+
+               if((error = FT_Init_FreeType(&library)))
+               {
+                       printf("logomask <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
+                       munmap(lfb, fix_screeninfo.smem_len);
+                       return -1;
+               }
+
+               if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
+               {
+                       printf("logomask <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
+                       FT_Done_FreeType(library);
+                       munmap(lfb, fix_screeninfo.smem_len);
+                       return -1;
+               }
+
+               if((error = FTC_SBitCache_New(manager, &cache)))
+               {
+                       printf("logomask <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
+                       FTC_Manager_Done(manager);
+                       FT_Done_FreeType(library);
+                       munmap(lfb, fix_screeninfo.smem_len);
+                       return -1;
+               }
+
+               if((error = FTC_Manager_LookupFace(manager, FONT, &face)))
+               {
+                       printf("logomask <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
+                       FTC_Manager_Done(manager);
+                       FT_Done_FreeType(library);
+                       munmap(lfb, fix_screeninfo.smem_len);
+                       return -1;
+               }
+
+               use_kerning = FT_HAS_KERNING(face);
+
+               desc.face_id = FONT;
+               desc.flags = FT_LOAD_MONOCHROME;
+
+
+               InitRC();
+
+       //init backbuffer
+
+               if(!(lbb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
+               {
+                       printf("logomask <allocating of Backbuffer failed>\n");
+                       munmap(lfb, fix_screeninfo.smem_len);
+                       return -1;
+               }
+
+               memset(lbb, 0, fix_screeninfo.line_length*var_screeninfo.yres);
+
+               startx = sx;
+               starty = sy;
+
+               system("pzapit -gi > /tmp/logomask.chan");
+               if((fh=fopen("/tmp/logomask.chan","r"))!=NULL)
+               {
+                       if(fgets(tstr, BUFSIZE, fh))
+                       {
+                               TrimString(tstr);
+                               if((cpt1=strchr(tstr,' '))!=NULL)
+                                       *cpt1=0;
+                       }
+                       fclose(fh);
+                       if(strlen(tstr))
+                       {
+                               strcpy(actchan,tstr);
+                       }
+
+                       if((fh=fopen(CFG_FILE,"r"))!=NULL)
+                       {
+                               found=0;
+                               while(fgets(tstr, BUFSIZE, fh) && !found)
+                               {
+                                       TrimString(tstr);
+                                       if(strlen(tstr))
+                                       {
+                                               if(strstr(tstr,actchan)!=NULL)
+                                               {
+                                                       mask=1;
+                                                       nmsk=0;
+                                                       cpt2=strstr(tstr,",MC");
+                                                       if((cpt1=strchr(tstr,','))!=NULL)
+                                                       {
+                                                               while(cpt1)
+                                                               {
+                                                                       valid[nmsk]=0;
+                                                                       if(cpt2 && sscanf(cpt2+1,"MC%8X",&mp.lpixel)==1)
+                                                                       {
+                                                                               cpt2=strchr(cpt2+1,',');
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               make_color(BLACK, &mp);
+                                                                       }
+                                                                       for(i=0; i<8 && cpt1; i++)
+                                                                       {
+                                                                               cpt1++;
+                                                                               if(sscanf(cpt1,"%d,%d,%d,%d",&xxp,&xxw,&yyp,&yyw)==4)
+                                                                               {
+                                                                                       xp[nmsk][i]=xxp;
+                                                                                       xw[nmsk][i]=xxw;
+                                                                                       yp[nmsk][i]=yyp;
+                                                                                       yw[nmsk][i]=yyw;
+                                                                                       mc[nmsk].lpixel=mp.lpixel;
+                                                                                       found=1;
+                                                                                       valid[nmsk]=1;
+                                                                               }
+                                                                               for(j=0; j<4 && cpt1; j++)
+                                                                               {
+                                                                                       cpt1=strchr(cpt1+1,',');
+                                                                               }
+                                                                       }
+                                                                       if(valid[nmsk])
+                                                                       {
+                                                                               nmsk++;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               fclose(fh);
+                       }
+               }
+
+               if(!nmsk)
+               {
+                       nmsk=1;
+                       valid[0]=1;
+               }
+               mask=nmsk;
+               for(m=0; m<MAX_MASK; m++)
+               {
+                       if(valid[m])
+                       {
+                               xxp=xp[m][pmode];
+                               xxw=xw[m][pmode];                               
+                               yyp=yp[m][pmode];
+                               yyw=yw[m][pmode];
+                               tp.lpixel=mc[m].lpixel;
+                               RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &tp);
+                               if(m==amsk)
+                                       RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, GRID, make_color(LBLUE,&tp));
+                               for(i=0;i<=yyw;i++)
+                               {
+                                       j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
+                                       if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
+                                       {
+                                               memcpy(lfb+j, lbb+j, xxw<<2);
+                                       }
+                               }
+                       }
+               }
+               time(&t1);
+               while((rc!=KEY_EXIT) && (rc!=KEY_OK))
+               {
+                       rc=GetRCCode();
+                       if((rc!=-1) && (rc!=KEY_EXIT) && (rc!=KEY_OK))
+                       {
+                               time(&t1);
+                               move=0;
+                               xxp=xp[amsk][pmode];
+                               xxw=xw[amsk][pmode];
+                               yyp=yp[amsk][pmode];
+                               yyw=yw[amsk][pmode];
+                               lpix.lpixel=mc[amsk].lpixel;
+                               switch(rc)
+                               {
+                                       case KEY_LEFT:
+                                       if(lc==KEY_LEFT)
+                                       {
+                                               xs+=0.3;
+                                       }
+                                       else
+                                       {
+                                               xs=1.0;
+                                       }
+                                       if(kmode)
+                                       {
+                                               if(xxp>0)
+                                               {
+                                                       changed=1;
+                                                       xxp-=xs;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if(xxw>6)
+                                               {
+                                                       changed=1;
+                                                       xxw-=xs;
+                                               }
+                                       }
+                                       move=1;
+                                       break;
+                               
+                                       case KEY_RIGHT:
+                                       if((xxp+xxw)<(fix_screeninfo.line_length-1))
+                                       {
+                                               changed=1;
+                                               if(lc==KEY_RIGHT)
+                                               {
+                                                       xs+=0.3;
+                                               }
+                                               else
+                                               {
+                                                       xs=1.0;
+                                               }
+                                               if(kmode)
+                                               {
+                                                       xxp+=xs;
+                                               }
+                                               else
+                                               {
+                                                       xxw+=xs;
+                                               }
+                                       }
+                                       move=1;
+                                       break;
+                               
+                                       case KEY_UP:
+                                       if(lc==KEY_UP)
+                                       {
+                                               ys+=0.2;
+                                       }
+                                       else
+                                       {
+                                               ys=1.0;
+                                       }
+                                       if(kmode)
+                                       {
+                                               if(yyp>0)
+                                               {
+                                                       changed=1;
+                                                       yyp-=ys;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if(yyw>6)
+                                               {
+                                                       changed=1;
+                                                       yyw-=ys;
+                                               }
+                                       }
+                                       move=1;
+                                       break;
+                               
+                                       case KEY_DOWN:
+                                       if((yyp+yyw)<(var_screeninfo.yres-1))
+                                       {
+                                               changed=1;
+                                               if(lc==KEY_DOWN)
+                                               {
+                                                       ys+=0.2;
+                                               }
+                                               else
+                                               {
+                                                       ys=1.0;
+                                               }
+                                               if(kmode)
+                                               {
+                                                       yyp+=ys;
+                                               }
+                                               else
+                                               {
+                                                       yyw+=ys;
+                                               }
+                                       }
+                                       move=1;
+                                       break;
+                               
+                                       case KEY_RED:
+                                               changed=1;
+                                               RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, make_color(TRANSP,&tp));
+                                               for(i=0;i<=yyw;i++)
+                                               {
+                                                       j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
+                                                       if(((j+(xxw<<2)))<fix_screeninfo.line_length*var_screeninfo.yres)
+                                                       {
+                                                               memcpy(lfb+j, lbb+j, xxw<<2);
+                                                       }
+                                               }
+                                               valid[amsk]=0;
+                                               nmsk--;
+                                               kmode=1;
+                                               if(nmsk)
+                                               {
+                                                       todo=2;
+                                                       amsk=-1;
+                                                       for(m=0; m<MAX_MASK && amsk<0; m++)
+                                                       {
+                                                               if(valid[m])
+                                                               {
+                                                                       amsk=m;
+                                                                       xxp=xp[amsk][pmode];
+                                                                       xxw=xw[amsk][pmode];
+                                                                       yyp=yp[amsk][pmode];
+                                                                       yyw=yw[amsk][pmode];
+                                                                       lpix.lpixel=mc[amsk].lpixel;
+                                                               }
+                                                       }       
+                                               }
+                                               else
+                                               {
+                                                       todo=mask=0;
+                                               }
+                                       break;
+                               
+                                       case KEY_GREEN:
+                                               if(nmsk<MAX_MASK)
+                                               {
+                                                       todo=2;
+                                                       changed=1;
+                                                       kmode=1;
+                                                       amsk=-1;
+                                                       for(m=0; amsk<0 && m<MAX_MASK; m++)
+                                                       {
+                                                               if(!valid[m])
+                                                               {
+                                                                       amsk=m;
+                                                                       valid[amsk]=1;
+                                                                       nmsk++;
+                                                                       cmc[amsk]=BLACK;
+                                                                       make_color(BLACK, &mc[amsk]);
+                                                                       for(i=0; i<8; i++)
+                                                                       {
+                                                                               xp[amsk][i]=(1280-40)/2;
+                                                                               xw[amsk][i]=40;
+                                                                               yp[amsk][i]=(720-20)/2;
+                                                                               yw[amsk][i]=20;
+                                                                       }
+                                                                       xxp=xp[amsk][pmode];
+                                                                       xxw=xw[amsk][pmode];
+                                                                       yyp=yp[amsk][pmode];
+                                                                       yyw=yw[amsk][pmode];
+                                                                       lpix.lpixel=mc[amsk].lpixel;
+                                                               }
+                                                       }
+                                               }       
+                                       break;
+                                       
+                                       case KEY_PAGEUP:
+                                               if(nmsk>1)
+                                               {
+                                                       m=amsk+1;
+                                                       if(m>=MAX_MASK)
+                                                       {
+                                                               m=0;
+                                                       }
+                                                       while(!valid[m])
+                                                       {
+                                                               if(++m>=MAX_MASK)
+                                                               {
+                                                                       m=0;
+                                                               }
+                                                       }
+                                                       RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &lpix);
+                                                       amsk=m;
+                                                       xxp=xp[amsk][pmode];
+                                                       xxw=xw[amsk][pmode];
+                                                       yyp=yp[amsk][pmode];
+                                                       yyw=yw[amsk][pmode];
+                                                       lpix.lpixel=mc[amsk].lpixel;
+                                               }
+                                       break;
+                               
+                                       case KEY_PAGEDOWN:
+                                               if(nmsk>1)
+                                               {
+                                                       m=amsk-1;
+                                                       if(m<0)
+                                                       {
+                                                               m=MAX_MASK-1;
+                                                       }
+                                                       while(!valid[m])
+                                                       {
+                                                               if(--m<0)
+                                                               {
+                                                                       m=MAX_MASK;
+                                                               }
+                                                       }
+                                                       RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, &lpix);
+                                                       amsk=m;
+                                                       xxp=xp[amsk][pmode];
+                                                       xxw=xw[amsk][pmode];
+                                                       yyp=yp[amsk][pmode];
+                                                       yyw=yw[amsk][pmode];
+                                                       lpix.lpixel=mc[amsk].lpixel;
+                                               }
+                                       break;
+
+                                       case KEY_YELLOW:
+                                               kmode=0;
+                                       break;
+                               
+                                       case KEY_BLUE:
+                                               kmode=1;
+                                       break;
+                                       
+                                       case KEY_1:
+                                               if(nmsk)
+                                               {
+                                                       if(mc[amsk].cpixel.rd < 0xF0)
+                                                               mc[amsk].cpixel.rd+=0x10;
+                                                       else
+                                                               mc[amsk].cpixel.rd=0xFF;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_4:
+                                               if(nmsk)
+                                               {
+                                                       mc[amsk].cpixel.rd=0x80;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_7:
+                                               if(nmsk)
+                                               {
+                                                       if(mc[amsk].cpixel.rd > 0x0F)
+                                                               mc[amsk].cpixel.rd-=0x10;
+                                                       else
+                                                               mc[amsk].cpixel.rd=0x00;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_2:
+                                               if(nmsk)
+                                               {
+                                                       if(mc[amsk].cpixel.gn < 0xF0)
+                                                               mc[amsk].cpixel.gn+=0x10;
+                                                       else
+                                                               mc[amsk].cpixel.gn=0xFF;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_5:
+                                               if(nmsk)
+                                               {
+                                                       mc[amsk].cpixel.gn=0x80;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_8:
+                                               if(nmsk)
+                                               {
+                                                       if(mc[amsk].cpixel.gn > 0x0F)
+                                                               mc[amsk].cpixel.gn-=0x10;
+                                                       else
+                                                               mc[amsk].cpixel.gn=0x00;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_3:
+                                               if(nmsk)
+                                               {
+                                                       if(mc[amsk].cpixel.bl < 0xF0)
+                                                               mc[amsk].cpixel.bl+=0x10;
+                                                       else
+                                                               mc[amsk].cpixel.bl=0xFF;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_6:
+                                               if(nmsk)
+                                               {
+                                                       mc[amsk].cpixel.bl=0x80;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_9:
+                                               if(nmsk)
+                                               {
+                                                       if(mc[amsk].cpixel.bl > 0x0F)
+                                                               mc[amsk].cpixel.bl-=0x10;
+                                                       else
+                                                               mc[amsk].cpixel.bl=0x00;
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_MUTE:
+                                               if(nmsk)
+                                               {
+                                                       if(++cmc[amsk]>LTURQUOISE)
+                                                               cmc[amsk]=BLACK;
+                                                       make_color(cmc[amsk], &mc[amsk]);
+                                                       changed=1;
+                                               }
+                                       break;
+
+                                       case KEY_HELP:
+                                               help_changed=1;
+                                       break;
+                               }
+                               lc=rc;
+                               lpix.lpixel=mc[amsk].lpixel;
+                               if(mask || todo==2)
+                               {
+                                       RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], FILL, make_color(TRANSP, &tp));
+                                       for(i=0;i<=yw[amsk][pmode];i++)
+                                       {
+                                               j=(yp[amsk][pmode]+i)*fix_screeninfo.line_length+(xp[amsk][pmode]<<2);
+                                               if((j+(xw[amsk][pmode]<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
+                                               {
+                                                       memcpy(lfb+j, lbb+j, (xw[amsk][pmode]+1)<<2);
+                                               }
+                                       }
+                                       xp[amsk][pmode]=xxp;
+                                       xw[amsk][pmode]=xxw;
+                                       yp[amsk][pmode]=yyp;
+                                       yw[amsk][pmode]=yyw;
+                                       for(m=0; mask && m<MAX_MASK; m++)
+                                       {
+                                               if(valid[m])
+                                               {
+                                                       xxp=xp[m][pmode];
+                                                       xxw=xw[m][pmode];
+                                                       yyp=yp[m][pmode];
+                                                       yyw=yw[m][pmode];
+                                                       tp.lpixel=mc[m].lpixel;
+                                                       RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, FILL, ((m==amsk) && move)?make_color(TRANSP, &tp):&tp);
+                                                       if(m==amsk)
+                                                               RenderBox(xxp, yyp, xxp+xxw, yyp+yyw, GRID, make_color((kmode)?LBLUE:LYELLOW,&tp));
+                                                       for(i=0;i<=yyw;i++)
+                                                       {
+                                                               j=(yyp+i)*fix_screeninfo.line_length+(xxp<<2);
+                                                               if((j+(xxw<<2))<fix_screeninfo.line_length*var_screeninfo.yres)
+                                                               {
+                                                                       memcpy(lfb+j, lbb+j, (xxw+1)<<2);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       time(&t2);
+                       if((t2-t1)>1)
+                       {
+                               xs=1.0;
+                               ys=1.0;
+                               tsy=starty+120;
+                               if(move)
+                               {
+                                       RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], FILL, &mc[amsk]);
+                                       RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], GRID, make_color((kmode)?LBLUE:LYELLOW,&tp));
+                               }
+                               move=0;
+                               if(help_changed)
+                               {
+                                       help^=1;
+                               }
+                               if(help)
+                               {
+                                       RenderBox(tsx,tsy,tsx+txw,tsy+20*tdy,FILL,make_color(TRANSP, &tp));
+                                       if(nmsk)
+                                               RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], GRID, make_color((kmode)?LBLUE:LYELLOW, &tp));
+                                       RenderString("Maskensteuerung", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Blau  :  Umschalten auf Positionseinstellung", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Gelb  :  Umschalten auf Größeneinstellung", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Grün  :  Maske hinzufügen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Rot    :  Maske löschen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("PgUp :  nächste Maske auswählen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("PgDn :  vorherige Maske auswählen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Maskenfarbe", tsx, tsy+=(2*tdy), txw, LEFT, tsz, tcol);
+                                       RenderString("1,4,7   :  Farbton Rot erhöhen, auf Mitte setzen, verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("2,5,8  :  Farbton Grün erhöhen, auf Mitte setzen, verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("3,6,9  :  Farbton Blau erhöhen, auf Mitte setzen, verringern", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Mute  :  Maskenfarbe aus Vorgabe auswählen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Allgemein", tsx, tsy+=(2*tdy), txw, LEFT, tsz, tcol);
+                                       RenderString("?        :  Hilfetext ein/ausschalten", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("Home:  Abbrechen", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                                       RenderString("OK     :  Speichern und Beenden", tsx, tsy+=tdy, txw, LEFT, tsz, tcol);
+                               }
+                               else
+                               {
+                                       if(help_changed)
+                                       {
+                                               RenderBox(tsx, tsy, tsx+txw, tsy+20*tdy, FILL, make_color(TRANSP, &tp));
+                                               if(nmsk)
+                                                       RenderBox(xp[amsk][pmode], yp[amsk][pmode], xp[amsk][pmode]+xw[amsk][pmode], yp[amsk][pmode]+yw[amsk][pmode], GRID, make_color((kmode)?LBLUE:LYELLOW, &tp));
+                                       }
+                               }
+                               help_changed=0;
+                               memcpy(lfb, lbb, fix_screeninfo.line_length*var_screeninfo.yres);
+                       }
+               }
+               if(rc==KEY_EXIT)
+               {
+                       changed=0;
+                       todo=0;
+               }
+               if(rc==KEY_OK && changed)
+               {
+                       if((fh2=fopen("/tmp/logomask.conf","w"))!=NULL)
+                       {
+                               fh=fopen(CFG_FILE,"r");
+                               while(fh && fgets(tstr, BUFSIZE, fh))
+                               {
+                                       TrimString(tstr);
+                                       if(strlen(tstr))
+                                       {
+                                               if(strstr(tstr,actchan)==NULL)
+                                               {
+                                                       fprintf(fh2,"%s\n",tstr);
+                                               }
+                                       }
+                               }
+                               if(fh)
+                               {
+                                       fclose(fh);
+                               }
+                               if(todo)
+                               {
+                                       fprintf(fh2,"%s",actchan);
+                                       for(j=0; j<MAX_MASK; j++)
+                                       {
+                                               if(valid[j])
+                                               {
+                                                       for(i=0; i<8; i++)
+                                                       {
+                                                               fprintf(fh2,",%d,%d,%d,%d",xp[j][i],xw[j][i],yp[j][i],yw[j][i]);
+                                                       }
+                                               }
+                                       }
+                                       for(j=0; j<MAX_MASK; j++)
+                                       {
+                                               if(valid[j])
+                                               {
+                                                       fprintf(fh2,",MC%08X",mc[j].lpixel);
+                                               }
+                                       }
+                                       fprintf(fh2,",\n");
+                               }
+                               fclose(fh2);
+                               remove(CFG_FILE);
+                               system("mv /tmp/logomask.conf /var/tuxbox/config/logomask.conf");
+                       }
+               }               
+               free(lbb);
+               munmap(lfb, fix_screeninfo.smem_len);
+
+               close(fb);
+               CloseRC();
+               remove("/tmp/.logomask_kill");
+               remove("/tmp/logomaskset.*");
+               system("logomask &");
+               return 0;
+}
+
diff --git a/logoset.cfg b/logoset.cfg
new file mode 100644 (file)
index 0000000..2405d88
--- /dev/null
@@ -0,0 +1,7 @@
+type=2
+name=Logomasken einstellen
+desc=Logomasken einstellen
+needfb=1
+needrc=1
+needlcd=0
+needoffs=0
diff --git a/logoset.h b/logoset.h
new file mode 100644 (file)
index 0000000..37ce1ed
--- /dev/null
+++ b/logoset.h
@@ -0,0 +1,126 @@
+#ifndef __logomask_H__
+
+#define __logomask_H__
+
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <linux/fb.h>
+#if HAVE_DVB_API_VERSION == 3
+#include <linux/input.h>
+#endif
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_CACHE_H
+#include FT_CACHE_SMALL_BITMAPS_H
+
+// rc codes
+
+#undef KEY_EPG
+#undef KEY_SAT
+#undef KEY_STOP
+#undef KEY_PLAY
+
+#define KEY_1                                  2
+#define KEY_2                                  3
+#define KEY_3                                  4
+#define KEY_4                                  5
+#define KEY_5                                  6
+#define KEY_6                                  7
+#define KEY_7                                  8
+#define KEY_8                                  9
+#define KEY_9                                  10
+#define KEY_BACKSPACE           14
+#define KEY_UP                  103
+#define KEY_LEFT                105
+#define KEY_RIGHT               106
+#define KEY_DOWN                108
+#define KEY_MUTE                113
+#define KEY_VOLUMEDOWN          114
+#define KEY_VOLUMEUP            115
+#define KEY_POWER               116
+#define KEY_HELP                138
+#define KEY_HOME                102
+#define KEY_EXIT                                174
+#define KEY_SETUP               141
+#define KEY_PAGEUP              104
+#define KEY_PAGEDOWN            109
+#define KEY_OK                         0x160
+#define KEY_RED                        0x18e
+#define KEY_GREEN                      0x18f
+#define KEY_YELLOW                     0x190
+#define KEY_BLUE                       0x191
+
+#define KEY_TVR                                        0x179
+#define KEY_TTX                                        0x184
+#define KEY_COOL                               0x1A1
+#define KEY_FAV                                        0x16C
+#define KEY_EPG                                        0x16D
+#define KEY_VF                                 0x175
+
+#define KEY_SAT                                        0x17D
+#define KEY_SKIPP                              0x197
+#define KEY_SKIPM                              0x19C
+#define KEY_TS                                 0x167
+#define KEY_AUDIO                              0x188
+#define KEY_REW                                        0x0A8
+#define KEY_FWD                                        0x09F
+#define KEY_HOLD                               0x077
+#define KEY_REC                                        0x0A7
+#define KEY_STOP                               0x080
+#define KEY_PLAY                               0x0CF
+
+//freetype stuff
+
+extern unsigned char FONT[64];
+
+enum {LEFT, CENTER, RIGHT};
+enum {SMALL, MED, BIG};
+
+FT_Error                       error;
+FT_Library                     library;
+FTC_Manager                    manager;
+FTC_SBitCache          cache;
+FTC_SBit                       sbit;
+FTC_ImageTypeRec       desc;
+FT_Face                                face;
+FT_UInt                                prev_glyphindex;
+FT_Bool                                use_kerning;
+
+//devs
+int fb, rc;
+
+//framebuffer stuff
+
+enum {FILL, GRID};
+
+enum {TRANSP, BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, TURQUOISE, WHITE, GRAY, LRED, LGREEN, LYELLOW, LBLUE, LMAGENTA, LTURQUOISE};
+
+extern unsigned char rd[], gn[], bl[], tr[];
+extern unsigned char *lfb, *lbb;
+
+extern int FSIZE_BIG;
+extern int FSIZE_MED;
+extern int FSIZE_SMALL;
+extern int TABULATOR;
+
+struct fb_fix_screeninfo fix_screeninfo;
+struct fb_var_screeninfo var_screeninfo;
+
+int startx, starty, sx, ex, sy, ey;
+char online;
+
+#define FB_DEVICE      "/dev/fb/0"
+
+#define BUFSIZE 4096
+
+#endif
diff --git a/starter_logomask.c b/starter_logomask.c
new file mode 100644 (file)
index 0000000..d608a5f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * shellexec - d-box2 linux project
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <plugin.h>
+#define SCRIPT "logomask"
+
+int main(void)
+{
+        int ret, pid, status;
+        pid=fork();
+        if (pid == -1) {
+                fprintf(stderr, "[%s.so] fork\n", SCRIPT);
+                return;
+        } else
+        if (pid == 0) {
+                fprintf(stderr, "[%s.so] forked, executing %s\n", SCRIPT, SCRIPT);
+                for (ret=3 ; ret < 255; ret++)
+                       close (ret);
+                        ret = system("/var/plugins/lmask");
+                        if (ret)
+                                fprintf(stderr, "[%s.so] script return code: %d (%m)\n", SCRIPT, ret);
+                        else
+                                fprintf(stderr, "[%s.so] script return code: %d\n", SCRIPT, ret);
+                _exit(ret);
+       }
+        fprintf(stderr, "[%s.so] parent, waiting for child with pid %d...\n", SCRIPT, pid);
+        waitpid(pid, &status, 0);
+        fprintf(stderr, "[%s.so] parent, waitpid() returned..\n", SCRIPT);
+        if (WIFEXITED(status))
+                fprintf(stderr, "[%s.so] child returned with status %d\n", SCRIPT, WEXITSTATUS(status));
+        return 0;
+} 
diff --git a/text.c b/text.c
new file mode 100644 (file)
index 0000000..bbc8eda
--- /dev/null
+++ b/text.c
@@ -0,0 +1,195 @@
+#include "text.h"
+#include "gfx.h"
+#include "io.h"
+
+int FSIZE_BIG=28;
+int FSIZE_MED=24;
+int FSIZE_SMALL=20;
+int TABULATOR=72;
+
+/******************************************************************************
+ * MyFaceRequester
+ ******************************************************************************/
+
+FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface)
+{
+       FT_Error result;
+
+       result = FT_New_Face(library, face_id, 0, aface);
+
+       if(result) printf("msgbox <Font \"%s\" failed>\n", (char*)face_id);
+
+       return result;
+}
+
+/******************************************************************************
+ * RenderChar
+ ******************************************************************************/
+
+int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, int color)
+{
+//     unsigned char pix[4]={oldcmap.red[col],oldcmap.green[col],oldcmap.blue[col],oldcmap.transp[col]};
+//     unsigned char pix[4]={0x80,0x80,0x80,0x80};
+       unsigned char pix[4]={bl[color],gn[color],rd[color],tr[color]};
+       int row, pitch, bit, x = 0, y = 0;
+       FT_UInt glyphindex;
+       FT_Vector kerning;
+       FT_Error error;
+
+       currentchar=currentchar & 0xFF;
+
+       //load char
+
+               if(!(glyphindex = FT_Get_Char_Index(face, (int)currentchar)))
+               {
+//                     printf("msgbox <FT_Get_Char_Index for Char \"%c\" failed\n", (int)currentchar);
+                       return 0;
+               }
+
+
+               if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, NULL)))
+               {
+//                     printf("msgbox <FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
+                       return 0;
+               }
+
+// no kerning used
+/*
+               if(use_kerning)
+               {
+                       FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);
+
+                       prev_glyphindex = glyphindex;
+                       kerning.x >>= 6;
+               }
+               else
+*/
+                       kerning.x = 0;
+
+       //render char
+
+               if(color != -1) /* don't render char, return charwidth only */
+               {
+                       if(sx + sbit->xadvance >= ex) return -1; /* limit to maxwidth */
+
+                       for(row = 0; row < sbit->height; row++)
+                       {
+                               for(pitch = 0; pitch < sbit->pitch; pitch++)
+                               {
+                                       for(bit = 7; bit >= 0; bit--)
+                                       {
+                                               if(pitch*8 + 7-bit >= sbit->width) break; /* render needed bits only */
+
+                                               if((sbit->buffer[row * sbit->pitch + pitch]) & 1<<bit) memcpy(lbb + (startx + sx + sbit->left + kerning.x + x)*4 + fix_screeninfo.line_length*(starty + sy - sbit->top + y),pix,4);
+
+                                               x++;
+                                       }
+                               }
+
+                               x = 0;
+                               y++;
+                       }
+
+               }
+
+       //return charwidth
+
+               return sbit->xadvance + kerning.x;
+}
+
+/******************************************************************************
+ * GetStringLen
+ ******************************************************************************/
+
+int GetStringLen(int sx, unsigned char *string, int size)
+{
+int i, found;
+int stringlen = 0;
+
+       //reset kerning
+
+               prev_glyphindex = 0;
+
+       //calc len
+
+               if(size)
+               {
+                       desc.width = desc.height = size;
+               }
+               
+               while(*string != '\0')
+               {
+                       stringlen += RenderChar(*string, -1, -1, -1, -1);
+                       string++;
+               }
+
+       return stringlen;
+}
+
+
+void CatchTabs(char *text)
+{
+       int i;
+       char *tptr=text;
+       
+       while((tptr=strstr(tptr,"~T"))!=NULL)
+       {
+               *(++tptr)='t';
+               for(i=0; i<3; i++)
+               {
+                       if(*(++tptr))
+                       {
+                               *tptr=' ';
+                       }
+               }
+       }
+}
+
+/******************************************************************************
+ * RenderString
+ ******************************************************************************/
+
+int RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color)
+{
+       int stringlen, ex, charwidth,i,found;
+       char rstr[BUFSIZE], *rptr=rstr, rc;
+       int varcolor=color;
+
+       //set size
+       
+               strcpy(rstr,string);
+
+               desc.width = desc.height = size;
+               TABULATOR=3*size;
+       //set alignment
+
+               stringlen = GetStringLen(sx, rstr, size);
+
+               if(layout != LEFT)
+               {
+                       switch(layout)
+                       {
+                               case CENTER:    if(stringlen < maxwidth) sx += (maxwidth - stringlen)/2;
+                                               break;
+
+                               case RIGHT:     if(stringlen < maxwidth) sx += maxwidth - stringlen;
+                       }
+               }
+
+       //reset kerning
+
+               prev_glyphindex = 0;
+
+       //render string
+
+               ex = sx + maxwidth;
+
+               while(*rptr != '\0')
+               {
+                       if((charwidth = RenderChar(*rptr, sx, sy, ex, varcolor)) == -1) return sx; /* string > maxwidth */
+                       sx += charwidth;
+                       rptr++;
+               }
+       return stringlen;
+}
+
diff --git a/text.h b/text.h
new file mode 100644 (file)
index 0000000..d69c99d
--- /dev/null
+++ b/text.h
@@ -0,0 +1,12 @@
+#ifndef __TEXT_H__
+
+#define __TEXT_H__
+
+#include "logoset.h"
+
+FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface);
+int RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color);
+int GetStringLen(int sx, unsigned char *string, int size);
+void CatchTabs(char *text);
+
+#endif