opendreambox-archive-keyring: update to krogoth key
[opendreambox.git] / meta-opendreambox / recipes-dreambox / tuxtxt / tuxbox-libtuxtxt / 32bpp.diff
1 diff -Naur libs-org/libtuxtxt/libtuxtxt.c libs/libtuxtxt/libtuxtxt.c
2 --- libs-org/libtuxtxt/libtuxtxt.c      2010-03-06 10:51:52.000000000 +0100
3 +++ libs/libtuxtxt/libtuxtxt.c  2010-03-06 10:55:25.000000000 +0100
4 @@ -7,6 +7,15 @@
5   *    Info entnommen aus videotext-0.6.19991029,                              *
6   *    Copyright (c) 1994-96 Martin Buck  <martin-2.buck@student.uni-ulm.de>   *
7   *                                                                            *
8 + *              ported 2006 to Dreambox 7025 / 32Bit framebuffer              *
9 + *                   by Seddi <seddi@i-have-a-dreambox.com>                   *
10 + *                                                                            *
11 + *              ported 32Bit framebuffer to Tuxtxt v1.99 (2008)               *
12 + *                      by the PLi team (Sat-Turner)                          *
13 + *                                                                            *
14 + *              ported to 20090130                                            *
15 + *                      by the PLi team (pieterg)                             *
16 + *                                                                            *
17   ******************************************************************************/
18  
19  #ifdef DEBUG
20 diff -Naur libs-org/libtuxtxt/tuxtxt_common.h libs/libtuxtxt/tuxtxt_common.h
21 --- libs-org/libtuxtxt/tuxtxt_common.h  2010-03-06 10:51:52.000000000 +0100
22 +++ libs/libtuxtxt/tuxtxt_common.h      2010-03-06 10:56:26.000000000 +0100
23 @@ -627,6 +627,19 @@
24         aG3_70, aG3_71, aG3_72, aG3_73, aG3_74, aG3_75, aG3_76, aG3_77, aG3_78, aG3_79, aG3_7a, aG3_7b, aG3_7c, aG3_7d, aG3_7e
25  };
26  
27 +/* 32bit colortable */
28 +unsigned char bgra[][4] = {
29 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
30 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
31 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
32 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
33 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
34 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
35 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
36 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
37 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xC0", "\0\0\0\x00",
38 +"\0\0\0\x33" };
39 +
40  tuxtxt_cache_struct tuxtxt_cache;
41  static pthread_mutex_t tuxtxt_cache_lock = PTHREAD_MUTEX_INITIALIZER;
42  int tuxtxt_get_zipsize(int p,int sp)
43 @@ -3294,14 +3307,21 @@
44  void tuxtxt_FillRect(unsigned char *lfb, int xres, int x, int y, int w, int h, int color)
45  {
46         if (!lfb) return;
47 -       unsigned char *p = lfb + x + y * xres;
48 +       unsigned char *p = lfb + x*4 + y * xres;
49 +       unsigned char linebuf[w*4];
50 +       int xtmp;
51  
52         if (w > 0)
53 +       {
54 +               for (xtmp=0; xtmp<w; xtmp++)
55 +                       memcpy(linebuf+xtmp*4,bgra[color],4);
56 +
57                 for ( ; h > 0 ; h--)
58                 {
59 -                       memset(p, color, w);
60 +                       memcpy(p,linebuf,w*4);
61                         p += xres;
62                 }
63 +       }
64  }
65  
66  void tuxtxt_RenderDRCS(int xres,
67 @@ -3311,7 +3331,7 @@
68         unsigned char fgcolor, unsigned char bgcolor)
69  {
70         if (d == NULL) return;
71 -       int bit, x, y;
72 +       int bit, x, y, ltmp;
73         unsigned char *ay = ax + 13; /* array[0..10] of y-offsets for each pixel */
74  
75         for (y = 0; y < 10; y++) /* 10*2 bytes a 6 pixels per char definition */
76 @@ -3335,9 +3355,21 @@
77                         for (i = 0; i < h; i++)
78                         {
79                                 if (ax[x+1] > ax[x])
80 -                                       memset(d + ax[x], f1, ax[x+1] - ax[x]);
81 +                               {
82 +//                                     memset(d + ax[x], f1, ax[x+1] - ax[x]);
83 +                                       for (ltmp=0 ; ltmp < (ax[x+1]-ax[x]); ltmp++)
84 +                                       {
85 +                                               memcpy(d + ax[x]*4 +ltmp*4,bgra[f1],4);
86 +                                       }
87 +                               }
88                                 if (ax[x+7] > ax[x+6])
89 -                                       memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */
90 +                               {
91 +//                                     memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */
92 +                                       for (ltmp=0 ; ltmp < (ax[x+7]-ax[x+6]); ltmp++)
93 +                                       {
94 +                                               memcpy(d + ax[x+6]*4 +ltmp*4,bgra[f2],4);
95 +                                       }
96 +                               }
97                                 d += xres;
98                         }
99                         d -= h * xres;
100 @@ -3350,20 +3382,26 @@
101  void tuxtxt_DrawVLine(unsigned char *lfb, int xres, int x, int y, int l, int color)
102  {
103         if (!lfb) return;
104 -       unsigned char *p = lfb + x + y * xres;
105 +       unsigned char *p = lfb + 4*x + y * xres;
106  
107         for ( ; l > 0 ; l--)
108         {
109 -               *p = color;
110 +               memcpy(p,bgra[color],4);
111                 p += xres;
112         }
113  }
114  
115  void tuxtxt_DrawHLine(unsigned char* lfb,int xres,int x, int y, int l, int color)
116  {
117 +       int ltmp;
118         if (!lfb) return;
119         if (l > 0)
120 -               memset(lfb + x + y * xres, color, l);
121 +       {
122 +               for (ltmp=0; ltmp < l; ltmp++)
123 +               {
124 +                       memcpy(lfb + x*4 + ltmp*4 + y * xres, bgra[color], 4);
125 +               }
126 +       }
127  }
128  
129  void tuxtxt_FillRectMosaicSeparated(unsigned char *lfb, int xres,int x, int y, int w, int h, int fgcolor, int bgcolor, int set)
130 @@ -3378,48 +3416,54 @@
131  
132  void tuxtxt_FillTrapez(unsigned char *lfb, int xres,int x0, int y0, int l0, int xoffset1, int h, int l1, int color)
133  {
134 -       unsigned char *p = lfb + x0 + y0 * xres;
135 +       unsigned char *p = lfb + x0*4 + y0 * xres;
136         int xoffset, l;
137         int yoffset;
138 +       int ltmp;
139  
140         for (yoffset = 0; yoffset < h; yoffset++)
141         {
142                 l = l0 + ((l1-l0) * yoffset + h/2) / h;
143                 xoffset = (xoffset1 * yoffset + h/2) / h;
144                 if (l > 0)
145 -                       memset(p + xoffset, color, l);
146 +               {
147 +                       for (ltmp=0; ltmp < l; ltmp++)
148 +                       {
149 +                               memcpy(p + xoffset*4 +ltmp*4, bgra[color], 4);
150 +                       }
151 +               }
152                 p += xres;
153         }
154  }
155  void tuxtxt_FlipHorz(unsigned char *lfb, int xres,int x, int y, int w, int h)
156  {
157 -       unsigned char buf[w];
158 -       unsigned char *p = lfb + x + y * xres;
159 +       unsigned char buf[w*4];
160 +       unsigned char *p = lfb + x*4 + y * xres;
161         int w1,h1;
162  
163         for (h1 = 0 ; h1 < h ; h1++)
164         {
165 -               memcpy(buf,p,w);
166 +               memcpy(buf,p,w*4);
167                 for (w1 = 0 ; w1 < w ; w1++)
168                 {
169 -                       *(p+w1) = buf[w-(w1+1)];
170 +                       memcpy(p+w1*4,buf+((w-w1)*4)-4,4);
171                 }
172                 p += xres;
173         }
174  }
175  void tuxtxt_FlipVert(unsigned char *lfb, int xres,int x, int y, int w, int h)
176  {
177 -       unsigned char buf[w];
178 -       unsigned char *p = lfb + x + y * xres, *p1, *p2;
179 +       unsigned char buf[w*4];
180 +       unsigned char *p = lfb + x*4 + y * xres, *p1, *p2;
181         int h1;
182  
183         for (h1 = 0 ; h1 < h/2 ; h1++)
184         {
185                 p1 = (p+(h1*xres));
186                 p2 = (p+(h-(h1+1))*xres);
187 -               memcpy(buf,p1,w);
188 -               memcpy(p1,p2,w);
189 -               memcpy(p2,buf,w);
190 +               memcpy(buf,p1,w*4);
191 +               memcpy(p1,p2,w*4);
192 +               memcpy(p2,buf,w*4);
193         }
194  }
195  
196 @@ -3683,7 +3727,7 @@
197                                 if (lfb) 
198                                 {
199                                         int x,y,f,c;
200 -                                       unsigned char* p = lfb + *pPosX + PosY* xres;
201 +                                       unsigned char* p = lfb + (*pPosX)*4 + PosY* xres;
202                                         for (y=0; y<fontheight;y++)
203                                         {
204                                                 for (f=0; f<factor; f++)
205 @@ -3691,7 +3735,7 @@
206                                                         for (x=0; x<curfontwidth*xfactor;x++)
207                                                         {
208                                                                 c = (y&4 ? (x/3)&1 :((x+3)/3)&1);
209 -                                                               *(p+x) = (c ? fgcolor : bgcolor);
210 +                                                               memcpy((p+x*4),bgra[(c ? fgcolor : bgcolor)],4);
211                                                         }
212                                                         p += xres;
213                                                 }
214 @@ -3729,7 +3773,7 @@
215                         }
216                         axdrcs[12] = curfontwidth; /* adjust last x-offset according to position, FIXME: double width */
217                         tuxtxt_RenderDRCS(xres,p,
218 -                                                 lfb + *pPosX + PosY * xres,
219 +                                                 lfb + (*pPosX)*4 + PosY * xres,
220                                                   axdrcs, fgcolor, bgcolor);
221                 }
222                 else
223 @@ -3996,12 +4040,12 @@
224  void tuxtxt_FillBorder(tstRenderInfo* renderinfo, int color)
225  {
226         int ys =  renderinfo->var_screeninfo.yres-renderinfo->var_screeninfo.yoffset;
227 -       tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,0     , ys                     ,renderinfo->StartX      ,renderinfo->var_screeninfo.yres                       ,color);
228 -       tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->StartX, ys                     ,renderinfo->displaywidth,renderinfo->StartY                                    ,color);
229 -       tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->StartX, ys+renderinfo->StartY+25*renderinfo->fontheight,renderinfo->displaywidth,renderinfo->var_screeninfo.yres-(renderinfo->StartY+25*renderinfo->fontheight),color);
230 +       tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,0     , ys                     ,renderinfo->StartX      ,renderinfo->var_screeninfo.yres                       ,color);
231 +       tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->StartX, ys                     ,renderinfo->displaywidth,renderinfo->StartY                                    ,color);
232 +       tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->StartX, ys+renderinfo->StartY+25*renderinfo->fontheight,renderinfo->displaywidth,renderinfo->var_screeninfo.yres-(renderinfo->StartY+25*renderinfo->fontheight),color);
233  
234         if (renderinfo->screenmode == 0 )
235 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->StartX+renderinfo->displaywidth, ys,renderinfo->var_screeninfo.xres-(renderinfo->StartX+renderinfo->displaywidth),renderinfo->var_screeninfo.yres   ,color);
236 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->StartX+renderinfo->displaywidth, ys,renderinfo->var_screeninfo.xres-(renderinfo->StartX+renderinfo->displaywidth),renderinfo->var_screeninfo.yres   ,color);
237  }
238  
239  
240 @@ -4037,12 +4081,12 @@
241  }
242  void tuxtxt_ClearBB(tstRenderInfo* renderinfo,int color)
243  {
244 -       memset(renderinfo->lfb + (renderinfo->var_screeninfo.yres-renderinfo->var_screeninfo.yoffset )*renderinfo->var_screeninfo.xres, color, renderinfo->var_screeninfo.xres*renderinfo->var_screeninfo.yres);
245 +       tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,0, renderinfo->var_screeninfo.yres - renderinfo->var_screeninfo.yoffset, renderinfo->var_screeninfo.xres, renderinfo->var_screeninfo.yres, color);
246  }
247  
248  void tuxtxt_ClearFB(tstRenderInfo* renderinfo,int color)
249  {
250 -       memset(renderinfo->lfb + renderinfo->var_screeninfo.xres*renderinfo->var_screeninfo.yoffset, color, renderinfo->var_screeninfo.xres*renderinfo->var_screeninfo.yres);
251 +       tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,0, renderinfo->var_screeninfo.yoffset, renderinfo->var_screeninfo.xres, renderinfo->var_screeninfo.yres, color);
252  }
253  
254  int  tuxtxt_GetCurFontWidth(tstRenderInfo* renderinfo)
255 @@ -4079,7 +4123,7 @@
256         renderinfo->PosX += t;
257         int curfontwidth2 = tuxtxt_GetCurFontWidth(renderinfo);
258         renderinfo->PosX -= t;
259 -       int alphachar = tuxtxt_RenderChar(renderinfo->lfb+(yoffset+renderinfo->StartY)*renderinfo->var_screeninfo.xres,  renderinfo->var_screeninfo.xres,Char, &renderinfo->PosX, renderinfo->PosY-renderinfo->StartY, Attribute, zoom, curfontwidth, curfontwidth2, renderinfo->fontheight, renderinfo->transpmode,renderinfo->axdrcs, renderinfo->ascender);
260 +       int alphachar = tuxtxt_RenderChar(renderinfo->lfb+(yoffset+renderinfo->StartY)*renderinfo->fix_screeninfo.line_length, renderinfo->fix_screeninfo.line_length, Char, &renderinfo->PosX, renderinfo->PosY-renderinfo->StartY, Attribute, zoom, curfontwidth, curfontwidth2, renderinfo->fontheight, renderinfo->transpmode,renderinfo->axdrcs, renderinfo->ascender);
261         if (alphachar <= 0) return;
262  
263         if (zoom && Attribute->doubleh)
264 @@ -4112,7 +4156,7 @@
265  #if TUXTXT_DEBUG
266                 printf("TuxTxt <FT_Get_Char_Index for Char %x \"%c\" failed\n", alphachar, alphachar);
267  #endif
268 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY + yoffset, curfontwidth, factor*renderinfo->fontheight, bgcolor);
269 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY + yoffset, curfontwidth, factor*renderinfo->fontheight, bgcolor);
270                 renderinfo->PosX += curfontwidth;
271                 return;
272         }
273 @@ -4127,7 +4171,7 @@
274                 printf("TuxTxt <FTC_SBitCache_Lookup: 0x%x> c%x a%x g%x w%d h%d x%d y%d\n",
275                                  error, alphachar, Attribute, glyph, curfontwidth, renderinfo->fontheight, renderinfo->PosX, renderinfo->PosY);
276  #endif
277 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY + yoffset, curfontwidth, renderinfo->fontheight, bgcolor);
278 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY + yoffset, curfontwidth, renderinfo->fontheight, bgcolor);
279                 renderinfo->PosX += curfontwidth;
280                 return;
281         }
282 @@ -4188,13 +4232,13 @@
283                     Row = 0;
284                 }
285                 else            
286 -                   tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY + yoffset, curfontwidth, Row, bgcolor); /* fill upper margin */
287 +                               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY + yoffset, curfontwidth, Row, bgcolor); /* fill upper margin */
288  
289                 if (renderinfo->ascender - renderinfo->sbit->top + renderinfo->TTFShiftY + he > renderinfo->fontheight)
290                         he = renderinfo->fontheight - renderinfo->ascender + renderinfo->sbit->top - renderinfo->TTFShiftY; /* limit char height to defined/calculated fontheight */
291                 if (he < 0) he = renderinfo->fontheight;
292  
293 -               p = renderinfo->lfb + renderinfo->PosX + (yoffset + renderinfo->PosY + Row) * renderinfo->var_screeninfo.xres; /* running pointer into framebuffer */
294 +               p = renderinfo->lfb + renderinfo->PosX*4 + (yoffset + renderinfo->PosY + Row) * renderinfo->fix_screeninfo.line_length; /* running pointer into framebuffer */
295                 for (Row = he; Row; Row--) /* row counts up, but down may be a little faster :) */
296                 {
297                         int pixtodo = (renderinfo->usettf ? renderinfo->sbit->width : curfontwidth);
298 @@ -4203,8 +4247,8 @@
299                         for (Bit = xfactor * (renderinfo->sbit->left + renderinfo->TTFShiftX); Bit > 0; Bit--) /* fill left margin */
300                         {
301                                 for (f = factor-1; f >= 0; f--)
302 -                                       *(p + f*renderinfo->var_screeninfo.xres) = bgcolor;
303 -                               p++;
304 +                                       memcpy((p + f*renderinfo->fix_screeninfo.line_length),bgra[bgcolor],4);/*bgcolor*/
305 +                               p+=4;
306                                 if (!renderinfo->usettf)
307                                         pixtodo--;
308                         }
309 @@ -4224,14 +4268,14 @@
310                                                 color = bgcolor;
311  
312                                         for (f = factor-1; f >= 0; f--)
313 -                                               *(p + f*renderinfo->var_screeninfo.xres) = color;
314 -                                       p++;
315 +                                               memcpy((p + f*renderinfo->fix_screeninfo.line_length),bgra[color],4);
316 +                                       p+=4;
317  
318                                         if (xfactor > 1) /* double width */
319                                         {
320                                                 for (f = factor-1; f >= 0; f--)
321 -                                                       *(p + f*renderinfo->var_screeninfo.xres) = color;
322 -                                               p++;
323 +                                                       memcpy((p + f*renderinfo->fix_screeninfo.line_length),bgra[color],4);
324 +                                               p+=4;
325                                                 if (!renderinfo->usettf)
326                                                         pixtodo--;
327                                         }
328 @@ -4242,17 +4286,17 @@
329                                   Bit > 0; Bit--) /* fill rest of char width */
330                         {
331                                 for (f = factor-1; f >= 0; f--)
332 -                                       *(p + f*renderinfo->var_screeninfo.xres) = bgcolor;
333 -                               p++;
334 +                                       memcpy((p + f*renderinfo->fix_screeninfo.line_length),bgra[bgcolor],4);
335 +                               p+=4;
336                         }
337  
338 -                       p = pstart + factor*renderinfo->var_screeninfo.xres;
339 +                       p = pstart + factor*renderinfo->fix_screeninfo.line_length;
340                 }
341  
342                 Row = renderinfo->ascender - renderinfo->sbit->top + he + renderinfo->TTFShiftY;
343 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY + yoffset + Row*factor, curfontwidth, (renderinfo->fontheight - Row) * factor, bgcolor); /* fill lower margin */
344 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY + yoffset + Row*factor, curfontwidth, (renderinfo->fontheight - Row) * factor, bgcolor); /* fill lower margin */
345                 if (Attribute->underline)
346 -                       tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY + yoffset + (renderinfo->fontheight-2)* factor, curfontwidth,2*factor, fgcolor); /* underline char */
347 +                       tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY + yoffset + (renderinfo->fontheight-2)* factor, curfontwidth,2*factor, fgcolor); /* underline char */
348  
349                 renderinfo->PosX += curfontwidth;
350                 renderinfo->TTFShiftY = backupTTFshiftY; // restore TTFShiftY
351 @@ -4300,9 +4344,8 @@
352  
353  void tuxtxt_SwitchScreenMode(tstRenderInfo* renderinfo,int newscreenmode)
354  {
355 -#if HAVE_DVB_API_VERSION >= 3
356         struct v4l2_format format;
357 -#endif
358 +
359         /* reset transparency mode */
360         if (renderinfo->transpmode)
361                 renderinfo->transpmode = 0;
362 @@ -4370,42 +4413,53 @@
363  
364                 tuxtxt_setfontwidth(renderinfo,fw);
365  
366 -#if HAVE_DVB_API_VERSION < 3
367 -               avia_pig_hide(renderinfo->pig);
368 -               avia_pig_set_pos(renderinfo->pig, tx, ty);
369 -               avia_pig_set_size(renderinfo->pig, tw, th);
370 -               avia_pig_set_stack(renderinfo->pig, 2);
371 -               avia_pig_show(renderinfo->pig);
372 -#else
373 -               int sm = 0;
374 -               ioctl(renderinfo->pig, VIDIOC_OVERLAY, &sm);
375 -               sm = 1;
376 -               ioctl(renderinfo->pig, VIDIOC_G_FMT, &format);
377 -               format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
378 -               format.fmt.win.w.left   = tx;
379 -               format.fmt.win.w.top    = ty;
380 -               format.fmt.win.w.width  = tw;
381 -               format.fmt.win.w.height = th;
382 -               ioctl(renderinfo->pig, VIDIOC_S_FMT, &format);
383 -               ioctl(renderinfo->pig, VIDIOC_OVERLAY, &sm);
384 -#endif
385 -               ioctl(renderinfo->avs, AVSIOSSCARTPIN8, &fncmodes[renderinfo->screen_mode2]);
386 -               ioctl(renderinfo->saa, SAAIOSWSS, &saamodes[renderinfo->screen_mode2]);
387 +               // Video picture scale/pos for e2
388 +               int i;
389 +               for (i=0; i<4; ++i)
390 +               {
391 +                       char *targets[]={"left", "top", "width", "height"};
392 +                       char filename[128];
393 +                       snprintf(filename, 128, "/proc/stb/vmpeg/%d/dst_%s", 0, targets[i]);
394 +                       FILE *f = fopen(filename, "w");
395 +                       if (!f)
396 +                               break;
397 +                       int val = 0;
398 +                       switch (i)
399 +                       {
400 +                       case 0: val = tx; break;
401 +                       case 1: val = ty; break;
402 +                       case 2: val = tw; break;
403 +                       case 3: val = th; break;
404 +                       }
405 +                       fprintf(f, "%08x\n", val);
406 +                       fclose(f);
407 +               }
408 +               
409 +               writeproc("/proc/stb/avs/0/sb", fncmodes[renderinfo->screen_mode2]);
410 +               writeproc("/proc/stb/denc/0/wss", saamodes[renderinfo->screen_mode2]);
411         }
412         else /* not split */
413         {
414 -#if HAVE_DVB_API_VERSION < 3
415 -               avia_pig_hide(renderinfo->pig);
416 -#else
417 -               ioctl(renderinfo->pig, VIDIOC_OVERLAY, &renderinfo->screenmode);
418 -#endif
419 +               // Video picture scale/pos for e2
420 +               int i;
421 +               for (i=0; i<4; ++i)
422 +               {
423 +                       char *targets[]={"left", "top", "width", "height"};
424 +                       char filename[128];
425 +                       snprintf(filename, 128, "/proc/stb/vmpeg/%d/dst_%s", 0, targets[i]);
426 +                       FILE *f = fopen(filename, "w");
427 +                       if (!f)
428 +                               break;
429 +                       fprintf(f, "%08x\n", 0);
430 +                       fclose(f);
431 +               }
432  
433                 tuxtxt_setfontwidth(renderinfo,renderinfo->fontwidth_normal);
434                 renderinfo->displaywidth= (renderinfo->ex-renderinfo->sx);
435                 renderinfo->StartX = renderinfo->sx; //+ (ex-sx - 40*fontwidth) / 2; /* center screen */
436  
437 -               ioctl(renderinfo->avs, AVSIOSSCARTPIN8, &fncmodes[renderinfo->screen_mode1]);
438 -               ioctl(renderinfo->saa, SAAIOSWSS, &saamodes[renderinfo->screen_mode1]);
439 +               writeproc("/proc/stb/avs/0/sb", fncmodes[renderinfo->screen_mode1]);
440 +               writeproc("/proc/stb/denc/0/wss", saamodes[renderinfo->screen_mode1]);
441         }
442  }
443  
444 @@ -4431,7 +4485,7 @@
445         if (renderinfo->boxed)
446         {
447                 renderinfo->PosX = renderinfo->StartX + column*width;
448 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY+yoffset, renderinfo->displaywidth, renderinfo->fontheight, tuxtxt_color_transp);
449 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY+yoffset, renderinfo->displaywidth, renderinfo->fontheight, tuxtxt_color_transp);
450                 return;
451         }
452  
453 @@ -4442,7 +4496,7 @@
454  
455                 if (l > 9) /* smaller font, if no space for one half space at front and end */
456                         tuxtxt_setfontwidth(renderinfo,oldfontwidth * 10 / (l+1));
457 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY+yoffset, width+(renderinfo->displaywidth%4), renderinfo->fontheight, tuxtxt_atrtable[ATR_L250 + column].bg);
458 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY+yoffset, width+(renderinfo->displaywidth%4), renderinfo->fontheight, tuxtxt_atrtable[ATR_L250 + column].bg);
459                 renderinfo->PosX += ((width) - (l*renderinfo->fontwidth+l*renderinfo->fontwidth/abx))/2; /* center */
460                 for (p = tuxtxt_cache.adip[linkpage]; *p; p++)
461                         tuxtxt_RenderCharBB(renderinfo,*p, &tuxtxt_atrtable[ATR_L250 + column]);
462 @@ -4451,7 +4505,7 @@
463         else /* display number */
464         {
465                 renderinfo->PosX = renderinfo->StartX + column*width;
466 -               tuxtxt_FillRect(renderinfo->lfb,renderinfo->var_screeninfo.xres,renderinfo->PosX, renderinfo->PosY+yoffset, renderinfo->displaywidth+renderinfo->sx-renderinfo->PosX, renderinfo->fontheight, tuxtxt_atrtable[ATR_L250 + column].bg);
467 +               tuxtxt_FillRect(renderinfo->lfb,renderinfo->fix_screeninfo.line_length,renderinfo->PosX, renderinfo->PosY+yoffset, renderinfo->displaywidth+renderinfo->sx-renderinfo->PosX, renderinfo->fontheight, tuxtxt_atrtable[ATR_L250 + column].bg);
468                 if (linkpage < tuxtxt_cache.page)
469                 {
470                         line[6] = '<';
471 @@ -4620,7 +4674,7 @@
472  void tuxtxt_CopyBB2FB(tstRenderInfo* renderinfo)
473  {
474         unsigned char *src, *dst, *topsrc;
475 -       int fillcolor, i, screenwidth;
476 +       int fillcolor, i, screenwidth, swtmp;
477  
478         /* line 25 */
479         if (!renderinfo->pagecatching)
480 @@ -4636,8 +4690,8 @@
481                 if (ioctl(renderinfo->fb, FBIOPAN_DISPLAY, &renderinfo->var_screeninfo) == -1)
482                         perror("TuxTxt <FBIOPAN_DISPLAY>");
483  
484 -               if (renderinfo->StartX > 0 && *renderinfo->lfb != *(renderinfo->lfb + renderinfo->var_screeninfo.xres * renderinfo->var_screeninfo.yres)) /* adapt background of backbuffer if changed */
485 -                       tuxtxt_FillBorder(renderinfo,*(renderinfo->lfb + renderinfo->var_screeninfo.xres * renderinfo->var_screeninfo.yoffset));
486 +               if (renderinfo->StartX > 0 && *renderinfo->lfb != *(renderinfo->lfb + renderinfo->fix_screeninfo.line_length * renderinfo->var_screeninfo.yres)) /* adapt background of backbuffer if changed */
487 +                       tuxtxt_FillBorder(renderinfo,*(renderinfo->lfb + renderinfo->fix_screeninfo.line_length * renderinfo->var_screeninfo.yoffset));
488  //                      ClearBB(*(lfb + renderinfo->var_screeninfo.xres * renderinfo->var_screeninfo.yoffset));
489  
490                 if (renderinfo->clearbbcolor >= 0)
491 @@ -4648,18 +4702,18 @@
492                 return;
493         }
494  
495 -       src = dst = topsrc = renderinfo->lfb + renderinfo->StartY*renderinfo->var_screeninfo.xres;
496 +       src = dst = topsrc = renderinfo->lfb + renderinfo->StartY*renderinfo->fix_screeninfo.line_length;
497  
498  
499         if (renderinfo->var_screeninfo.yoffset)
500 -               dst += renderinfo->var_screeninfo.xres * renderinfo->var_screeninfo.yres;
501 +               dst += renderinfo->fix_screeninfo.line_length * renderinfo->var_screeninfo.yres;
502         else
503         {
504 -               src += renderinfo->var_screeninfo.xres * renderinfo->var_screeninfo.yres;
505 -               topsrc += renderinfo->var_screeninfo.xres * renderinfo->var_screeninfo.yres;
506 +               src += renderinfo->fix_screeninfo.line_length * renderinfo->var_screeninfo.yres;
507 +               topsrc += renderinfo->fix_screeninfo.line_length * renderinfo->var_screeninfo.yres;
508         }
509         if (!renderinfo->pagecatching )
510 -               memcpy(dst+(24*renderinfo->fontheight)*renderinfo->var_screeninfo.xres, src + (24*renderinfo->fontheight)*renderinfo->var_screeninfo.xres, renderinfo->var_screeninfo.xres*renderinfo->fontheight); /* copy line25 in normal height */
511 +               memcpy(dst+(24*renderinfo->fontheight)*renderinfo->fix_screeninfo.line_length, src + (24*renderinfo->fontheight)*renderinfo->fix_screeninfo.line_length, renderinfo->fix_screeninfo.line_length*renderinfo->fontheight); /* copy line25 in normal height */
512  
513         if (renderinfo->transpmode)
514                 fillcolor = tuxtxt_color_transp;
515 @@ -4667,94 +4721,81 @@
516                 fillcolor = tuxtxt_cache.FullScrColor;
517  
518         if (renderinfo->zoommode == 2)
519 -               src += 12*renderinfo->fontheight*renderinfo->var_screeninfo.xres;
520 +               src += 12*renderinfo->fontheight*renderinfo->fix_screeninfo.line_length;
521  
522         if (renderinfo->screenmode == 1) /* copy topmenu in normal height (since PIG also keeps dimensions) */
523         {
524                 unsigned char *topdst = dst;
525  
526 -               screenwidth = TV43STARTX;
527 +               screenwidth = (TV43STARTX) * 4;
528  
529                 topsrc += screenwidth;
530                 topdst += screenwidth;
531                 for (i=0; i < 24*renderinfo->fontheight; i++)
532                 {
533                         memcpy(topdst, topsrc,renderinfo->ex-screenwidth);
534 -                       topdst += renderinfo->var_screeninfo.xres;
535 -                       topsrc += renderinfo->var_screeninfo.xres;
536 +                       topdst += renderinfo->fix_screeninfo.line_length;
537 +                       topsrc += renderinfo->fix_screeninfo.line_length;
538                 }
539         }
540         else if (renderinfo->screenmode == 2)
541 -               screenwidth = TV169FULLSTARTX;
542 +               screenwidth = (TV169FULLSTARTX) * 4;
543         else
544 -               screenwidth = renderinfo->var_screeninfo.xres;
545 +               screenwidth = renderinfo->fix_screeninfo.line_length;
546  
547         for (i = renderinfo->StartY; i>0;i--)
548         {
549 -               memset(dst - i*renderinfo->var_screeninfo.xres, fillcolor, screenwidth);
550 +               for (swtmp=0; swtmp<screenwidth/4; swtmp++)
551 +               {
552 +                       memcpy(dst - i*renderinfo->fix_screeninfo.line_length+swtmp*4, bgra[fillcolor], 4);
553 +               }
554         }
555  
556         for (i = 12*renderinfo->fontheight; i; i--)
557         {
558                 memcpy(dst, src, screenwidth);
559 -               dst += renderinfo->var_screeninfo.xres;
560 +               dst += renderinfo->fix_screeninfo.line_length;
561                 memcpy(dst, src, screenwidth);
562 -               dst += renderinfo->var_screeninfo.xres;
563 -               src += renderinfo->var_screeninfo.xres;
564 +               dst += renderinfo->fix_screeninfo.line_length;
565 +               src += renderinfo->fix_screeninfo.line_length;
566         }
567  
568  //     if (!pagecatching )
569  //             memcpy(dst, lfb + (StartY+24*fontheight)*renderinfo->var_screeninfo.xres, renderinfo->var_screeninfo.xres*fontheight); /* copy line25 in normal height */
570 -       for (i = renderinfo->var_screeninfo.yres - renderinfo->StartY - 25*renderinfo->fontheight; i >= 0;i--)
571 -       {
572 -               memset(dst + renderinfo->var_screeninfo.xres*(renderinfo->fontheight+i), fillcolor, screenwidth);
573 -       }
574 +       dst -= renderinfo->fix_screeninfo.line_length;
575 +
576 +       unsigned char linebuf[screenwidth];
577 +       for (swtmp=0; swtmp < screenwidth/4;swtmp++)
578 +               memcpy(linebuf+swtmp*4, bgra[fillcolor], 4);
579 +       for (i = renderinfo->var_screeninfo.yres - renderinfo->StartY - 25 * renderinfo->fontheight; i >= 0;i--)
580 +               memcpy(dst + renderinfo->fix_screeninfo.line_length*(renderinfo->fontheight+i), linebuf, screenwidth);
581  }
582  
583  void tuxtxt_setcolors(tstRenderInfo* renderinfo,unsigned short *pcolormap, int offset, int number)
584  {
585 -       struct fb_cmap colormap_0 = {0, tuxtxt_color_SIZECOLTABLE, renderinfo->rd0, renderinfo->gn0, renderinfo->bl0, renderinfo->tr0};
586 -       int i, changed=0;
587 +       int i,trans_tmp;
588         int j = offset; /* index in global color table */
589  
590 -       unsigned short t = renderinfo->tr0[tuxtxt_color_transp2];
591 -       renderinfo->tr0[tuxtxt_color_transp2] = (renderinfo->trans_mode+7)<<11 | 0x7FF;
592 -#ifndef HAVE_DREAMBOX_HARDWARE
593 -       /* "correct" semi-transparent for Nokia (GTX only allows 2(?) levels of transparency) */
594 -       if (tuxbox_get_vendor() == TUXBOX_VENDOR_NOKIA)
595 -               renderinfo->tr0[tuxtxt_color_transp2] = 0xFFFF;
596 -#endif
597 -       if (t != renderinfo->tr0[tuxtxt_color_transp2]) changed = 1;
598 +       trans_tmp=25-renderinfo->trans_mode;
599 +
600 +       bgra[tuxtxt_color_transp2][3]=((trans_tmp+7)<<11 | 0x7FF)>>8;
601 +
602         for (i = 0; i < number; i++)
603         {
604 -               int r = (pcolormap[i] << 12) & 0xf000;
605 -               int g = (pcolormap[i] <<  8) & 0xf000;
606 -               int b = (pcolormap[i] <<  4) & 0xf000;
607 -
608 +               int r = (pcolormap[i] << 12 & 0xF000) >> 8;
609 +               int g = (pcolormap[i] << 8 & 0xF000) >> 8;
610 +               int b = (pcolormap[i] << 4 & 0xF000) >> 8;
611  
612                 r = (r * (0x3f+(renderinfo->color_mode<<3))) >> 8;
613                 g = (g * (0x3f+(renderinfo->color_mode<<3))) >> 8;
614                 b = (b * (0x3f+(renderinfo->color_mode<<3))) >> 8;
615 -               if (renderinfo->rd0[j] != r)
616 -               {
617 -                       renderinfo->rd0[j] = r;
618 -                       changed = 1;
619 -               }
620 -               if (renderinfo->gn0[j] != g)
621 -               {
622 -                       renderinfo->gn0[j] = g;
623 -                       changed = 1;
624 -               }
625 -               if (renderinfo->bl0[j] != b)
626 -               {
627 -                       renderinfo->bl0[j] = b;
628 -                       changed = 1;
629 -               }
630 +
631 +               bgra[j][2]=r;
632 +               bgra[j][1]=g;
633 +               bgra[j][0]=b;
634 +
635                 j++;
636         }
637 -       if (changed)
638 -               if (ioctl(renderinfo->fb, FBIOPUTCMAP, &colormap_0) == -1)
639 -                       perror("TuxTxt <FBIOPUTCMAP>");
640  }
641  
642  /******************************************************************************
643 @@ -4968,11 +5009,11 @@
644  
645                         for (row = 0; row < DRCSROWS; row++)
646                                 for (col = 0; col < DRCSCOLS; col++)
647 -                                       tuxtxt_RenderDRCS(renderinfo->var_screeninfo.xres,
648 +                                       tuxtxt_RenderDRCS(renderinfo->fix_screeninfo.line_length,
649                                                 renderinfo->page_char + 20 * (DRCSCOLS * row + col + 2),
650                                                 renderinfo->lfb
651 -                                               + (renderinfo->StartY + renderinfo->fontheight + DRCSYSPC * row + renderinfo->var_screeninfo.yres - renderinfo->var_screeninfo.yoffset) * renderinfo->var_screeninfo.xres
652 -                                               + renderinfo->StartX + DRCSXSPC * col,
653 +                                               + (renderinfo->StartY + renderinfo->fontheight + DRCSYSPC * row + renderinfo->var_screeninfo.yres - renderinfo->var_screeninfo.yoffset) * renderinfo->fix_screeninfo.line_length
654 +                                                         + (renderinfo->StartX + DRCSXSPC * col)*4,
655                                                 ax, tuxtxt_color_white, tuxtxt_color_black);
656  
657                         memset(renderinfo->page_char + 40, 0xff, 24*40); /* don't render any char below row 0 */
658 @@ -5062,13 +5103,13 @@
659                                 renderinfo->pageinfo = p;
660                                 renderinfo->boxed = p->boxed;
661                         }
662 +                       if (tuxtxt_cache.colortable) /* as late as possible to shorten the time the old page is displayed with the new colors */
663 +                               tuxtxt_setcolors(renderinfo,tuxtxt_cache.colortable, 16, 16); /* set colors for CLUTs 2+3 */
664                         if (renderinfo->boxed || renderinfo->transpmode)
665  //                             tuxtxt_cache.FullScrColor = tuxtxt_color_transp;
666                                 tuxtxt_FillBorder(renderinfo,tuxtxt_color_transp);
667                         else
668                                 tuxtxt_FillBorder(renderinfo,tuxtxt_cache.FullScrColor);
669 -                       if (tuxtxt_cache.colortable) /* as late as possible to shorten the time the old page is displayed with the new colors */
670 -                               tuxtxt_setcolors(renderinfo,tuxtxt_cache.colortable, 16, 16); /* set colors for CLUTs 2+3 */
671                 }
672                 else
673                         startrow = 1;
674 @@ -5408,39 +5449,6 @@
675                 renderinfo->page_atrb[i].doublew = 0;
676                 renderinfo->page_atrb[i].IgnoreAtBlackBgSubst = 0;
677         }
678 -       if (setTVFormat)
679 -       {
680 -               /* open avs */
681 -               if ((renderinfo->avs = open(AVS, O_RDWR)) == -1)
682 -               {
683 -                       perror("TuxTxt <open AVS>");
684 -                       FTC_Manager_Done(renderinfo->manager);
685 -                       FT_Done_FreeType(renderinfo->library);
686 -                       return 0;
687 -               }
688 -
689 -               ioctl(renderinfo->avs, AVSIOGSCARTPIN8, &renderinfo->fnc_old);
690 -               ioctl(renderinfo->avs, AVSIOSSCARTPIN8, &fncmodes[renderinfo->screen_mode1]);
691 -               /* open saa */
692 -               if ((renderinfo->saa = open(SAA, O_RDWR)) == -1)
693 -               {
694 -                       perror("TuxTxt <open SAA>");
695 -                       FTC_Manager_Done(renderinfo->manager);
696 -                       FT_Done_FreeType(renderinfo->library);
697 -                       return 0;
698 -               }
699 -       
700 -               ioctl(renderinfo->saa, SAAIOGWSS, &renderinfo->saa_old);
701 -               ioctl(renderinfo->saa, SAAIOSWSS, &saamodes[renderinfo->screen_mode1]);
702 -       }
703 -       /* open pig */
704 -       if ((renderinfo->pig = open(PIG, O_RDWR)) == -1)
705 -       {
706 -               perror("TuxTxt <open PIG>");
707 -               FTC_Manager_Done(renderinfo->manager);
708 -               FT_Done_FreeType(renderinfo->library);
709 -               return 0;
710 -       }
711         return 1;       
712  }
713  /******************************************************************************
714 @@ -5489,7 +5497,7 @@
715                 FT_Done_FreeType(renderinfo->library);
716         renderinfo->manager = 0;
717         renderinfo->library = 0;
718 -       tuxtxt_ClearFB(renderinfo,renderinfo->previousbackcolor);
719 +       memset(renderinfo->lfb, 0, renderinfo->fix_screeninfo.smem_len);
720         /* unmap framebuffer */
721         munmap(renderinfo->lfb, renderinfo->fix_screeninfo.smem_len);
722         printf("[TTX] Rendering ended\n");
723 diff -Naur libs-org/libtuxtxt/tuxtxt_def.h libs/libtuxtxt/tuxtxt_def.h
724 --- libs-org/libtuxtxt/tuxtxt_def.h     2010-03-06 10:51:52.000000000 +0100
725 +++ libs/libtuxtxt/tuxtxt_def.h 2010-03-06 10:55:25.000000000 +0100
726 @@ -72,8 +72,10 @@
727  #define hold_mosaic         0x1E
728  #define release_mosaic      0x1F
729  
730 -const int fncmodes[] = {AVS_FNCOUT_EXT43, AVS_FNCOUT_EXT169};
731 -const int saamodes[] = {SAA_WSS_43F, SAA_WSS_169F};
732 +extern unsigned char bgra[][4];
733 +
734 +const char * fncmodes[] = {"12", "6"};
735 +const char * saamodes[] = {"4:3_full_format", "16:9_full_format"};
736  
737  typedef enum /* object type */
738  {