-/*
- Copyright 2004-2005 Chris Tallon
- Portions copyright 2004 Jon Gettler
-
- This file is part of VOMP.
-
- VOMP 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.
-
- VOMP 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 VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SURFACEMVP_H
-#define SURFACEMVP_H
-
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-
-extern "C"
-{
- #include <jpeglib.h>
-}
-
-#include "defines.h"
-#include "surface.h"
-
-// Structures for surface management
-
-typedef struct
-{
- unsigned long num;
- unsigned long unknown[4];
- unsigned long width;
- unsigned long height;
- char unknown2;
-} stbgfx_display_t;
-
-typedef struct
-{
- unsigned long unknown;
- unsigned long win_unknown;
- unsigned long addr;
- unsigned long size;
- unsigned long unknown2;
- unsigned long width;
- unsigned long height;
- unsigned long unknown3;
- unsigned long unknown4;
- unsigned long width2;
- unsigned long unknown5;
- unsigned long unknown6;
-} stbgfx_map_item_t;
-
-typedef struct {
- stbgfx_map_item_t map[3];
- unsigned long other[2];
-} stbgfx_map_t;
-
-typedef struct
-{
- unsigned long handle; /* surface handle */
- unsigned long width;
- unsigned long height;
- unsigned long flags;
- long unknown; //unsigned long
- unsigned long depth; /* number of subplanes */
-} stbgfx_sfc_t;
-
-typedef struct
-{
- stbgfx_display_t display;
- stbgfx_map_t map;
- stbgfx_sfc_t sfc;
- unsigned char *base[3];
-} osd_surface_t;
-
-
-// Structures for surface drawing
-
-typedef struct
-{
- unsigned long handle;
- unsigned long x;
- unsigned long y;
- unsigned long width;
- unsigned long height;
- unsigned long colour;
-} osd_fillblt_t;
-
-typedef struct {
- unsigned long dst_handle;
- unsigned long dst_x;
- unsigned long dst_y;
- unsigned long width;
- unsigned long height;
- unsigned long src_handle;
- unsigned long src_x;
- unsigned long src_y;
- unsigned long u1;
- unsigned long u2;
- unsigned char u3;
-} osd_bitblt_t;
-
-// Surface ioctls
-
-#define GFX_FB_SFC_ALLOC _IOWR(0xfb,1,int*)
-#define GFX_FB_SFC_FREE _IOW(0xfb,2,int)
-#define GFX_FB_MAP _IOWR(0xfb,3,int*)
-#define GFX_FB_SFC_UNMAP _IOW(0xfb,4,int)
-#define GFX_FB_SET_PAL_1 _IOWR(0xfb,5,int*)
-#define GFX_FB_SET_PAL_2 _IOW(0xfb,6,int*)
-#define GFX_FB_OSD_SURFACE _IO(0xfb,7)
-#define GFX_FB_SFC_SET_SHARE _IOW(0xfb,8,int)
-#define GFX_FB_OSD_CUR_SETATTR _IOW(0xfb,9,int*)
-#define GFX_FB_ATTACH _IOW(0xfb,11,int)
-#define GFX_FB_SFC_DETACH _IOW(0xfb,12,int*)
-#define GFX_FB_MOVE_DISPLAY _IOWR(0xfb,13,int)
-#define GFX_FB_SET_DISPLAY _IOW(0xfb,14,int)
-#define GFX_FB_OSD_CUR_MOVE_1 _IOW(0xfb,15,int*)
-#define GFX_FB_OSD_CUR_MOVE_2 _IOW(0xfb,16,int)
-#define GFX_FB_SET_OSD _IOW(0xfb,18,int)
-#define GFX_FB_SET_DISP_CTRL _IOW(0xfb,21,int*)
-#define GFX_FB_GET_DISP_CTRL _IOWR(0xfb,22,int*)
-#define GFX_FB_SET_VIS_DEV_CTL _IOWR(0xfb,23,int*)
-#define GFX_FB_GET_VIS_DEV_CTL _IOWR(0xfb,24,int*)
-#define GFX_FB_OSD_BITBLT _IOW(0xfb,51,osd_bitblt_t*)
-#define GFX_FB_OSD_FILLBLT _IOW(0xfb,53,osd_fillblt_t*)
-#define GFX_FB_OSD_ADVFILLBLT _IOW(0xfb,54,osd_afillblt_t*)
-#define GFX_FB_OSD_BLEND _IOW(0xfb,55,int*)
-#define GFX_FB_OSD_ADVBLEND _IOW(0xfb,56,int*)
-#define GFX_FB_OSD_RESIZE _IOW(0xfb,58,int*)
-#define GFX_FB_ENGINE_WAIT _IOW(0xfb,60,int)
-#define GFX_FB_RESET_ENGINE _IO(0xfb,61)
-#define GFX_FB_SET_ENGINE_MODE _IOW(0xfb,62,int)
-#define GFX_FB_GET_ENGINE_MODE _IO(0xfb,63)
-#define GFX_FB_GET_SFC_INFO _IO(0xfb,64,int*)
-#define GFX_FB_OSD_SFC_CLIP _IOW(0xfb,65,osd_clip_rec_t*)
-#define GFX_FB_OSD_COLOURKEY _IOW(0xfb,67,int*)
-#define GFX_FB_GET_SFC_PSEUDO _IOWR(0xfb,68,int*)
-
-class SurfaceMVP : public Surface
-{
- public:
- SurfaceMVP(int id = 0);
- ~SurfaceMVP();
-
- int create(UINT width, UINT height);
- void display();
- unsigned long getSurfaceHandle();
-
- int fillblt(int x, int y, int width, int height, unsigned int rgba);
- void drawPixel(int x, int y, unsigned int c, bool fastdraw=false);
- void drawPixel(int x, int y, Colour& c, bool fastdraw=false);
- void drawHorzLine(int x1, int x2, int y, unsigned int c);
- void drawVertLine(int x, int y1, int y2, unsigned int c);
- void drawBitmap(int x, int y, const Bitmap& bm);
- int updateToScreen(int sx, int sy, int w, int h, int dx, int dy);
- void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
- void screenShot(char* fileName);
-
- static void initConversionTables()
- {
- initConversionTables(100,100,100);
- }
- //init tables with factors for R,G,B - each in percent
- static void initConversionTables(int r, int g, int b);
-
- int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy);
-
- private:
- int fdOsd;
- osd_surface_t surface;
-
- void yuv2rgb(int y, int u, int v, unsigned char* pr, unsigned char* pg, unsigned char* pb);
- /*
- * rgb2yuv() - convert an RGB pixel to YUV
- */
- inline void rgb2yuv(unsigned char r, unsigned char g, unsigned char b, unsigned char *y, unsigned char *u, unsigned char *v)
- {
- int Y, U, V;
-
- Y = conv_YB[b] + conv_YG[g] + conv_YR[r];
- U = conv_UB[b] + conv_UG[g] + conv_UR[r] + 128;
- V = conv_VB[b] + conv_VG[g] + conv_VR[r] + 128;
-
- if (Y > 255)
- Y = 255;
- else if (Y < 0)
- Y = 0;
- if (U > 255)
- U = 255;
- else if (U < 0)
- U = 0;
- if (V > 255)
- V = 255;
- else if (V < 0)
- V = 0;
-
- *y = Y;
- *u = U;
- *v = V;
- }
-
-
- // Implicit inlines
- void c2rgba(unsigned long c, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
- {
- *a = (c & 0xff000000) >> 24;
- *r = (c & 0x00ff0000) >> 16;
- *g = (c & 0x0000ff00) >> 8;
- *b = (c & 0x000000ff);
- }
-
- static int conv_YB[256];
- static int conv_YG[256];
- static int conv_YR[256];
- static int conv_UB[256];
- static int conv_UG[256];
- static int conv_UR[256];
- static int conv_VB[256];
- static int conv_VG[256];
- static int conv_VR[256];
-
- static int conv_BY[256];
- static int conv_GY[256];
- static int conv_RY[256];
- static int conv_BU[256];
- static int conv_GU[256];
- static int conv_RU[256];
- static int conv_BV[256];
- static int conv_GV[256];
- static int conv_RV[256];
-
-};
-
-#endif
+/*\r
+ Copyright 2004-2005 Chris Tallon\r
+ Portions copyright 2004 Jon Gettler\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+\r
+#ifndef SURFACEMVP_H\r
+#define SURFACEMVP_H\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <unistd.h>\r
+#include <sys/mman.h>\r
+#include <sys/ioctl.h>\r
+\r
+extern "C"\r
+{\r
+ #include <jpeglib.h>\r
+}\r
+\r
+#include "defines.h"\r
+#include "surface.h"\r
+\r
+// Structures for surface management\r
+\r
+typedef struct\r
+{\r
+ unsigned long num;\r
+ unsigned long unknown[4];\r
+ unsigned long width;\r
+ unsigned long height;\r
+ char unknown2;\r
+} stbgfx_display_t;\r
+\r
+typedef struct\r
+{\r
+ unsigned long unknown;\r
+ unsigned long win_unknown;\r
+ unsigned long addr;\r
+ unsigned long size;\r
+ unsigned long unknown2;\r
+ unsigned long width;\r
+ unsigned long height;\r
+ unsigned long unknown3;\r
+ unsigned long unknown4;\r
+ unsigned long width2;\r
+ unsigned long unknown5;\r
+ unsigned long unknown6;\r
+} stbgfx_map_item_t;\r
+\r
+typedef struct {\r
+ stbgfx_map_item_t map[3];\r
+ unsigned long other[2];\r
+} stbgfx_map_t;\r
+\r
+typedef struct\r
+{\r
+ unsigned long handle; /* surface handle */\r
+ unsigned long width;\r
+ unsigned long height;\r
+ unsigned long flags;\r
+ long unknown; //unsigned long\r
+ unsigned long depth; /* number of subplanes */\r
+} stbgfx_sfc_t;\r
+\r
+typedef struct\r
+{\r
+ stbgfx_display_t display;\r
+ stbgfx_map_t map;\r
+ stbgfx_sfc_t sfc;\r
+ unsigned char *base[3];\r
+} osd_surface_t;\r
+\r
+\r
+// Structures for surface drawing\r
+\r
+typedef struct\r
+{\r
+ unsigned long handle;\r
+ unsigned long x;\r
+ unsigned long y;\r
+ unsigned long width;\r
+ unsigned long height;\r
+ unsigned long colour;\r
+} osd_fillblt_t;\r
+\r
+typedef struct {\r
+ unsigned long dst_handle;\r
+ unsigned long dst_x;\r
+ unsigned long dst_y;\r
+ unsigned long width;\r
+ unsigned long height;\r
+ unsigned long src_handle;\r
+ unsigned long src_x;\r
+ unsigned long src_y;\r
+ unsigned long u1;\r
+ unsigned long u2;\r
+ unsigned char u3;\r
+} osd_bitblt_t;\r
+\r
+// Surface ioctls\r
+\r
+#define GFX_FB_SFC_ALLOC _IOWR(0xfb,1,int*)\r
+#define GFX_FB_SFC_FREE _IOW(0xfb,2,int)\r
+#define GFX_FB_MAP _IOWR(0xfb,3,int*)\r
+#define GFX_FB_SFC_UNMAP _IOW(0xfb,4,int)\r
+#define GFX_FB_SET_PAL_1 _IOWR(0xfb,5,int*)\r
+#define GFX_FB_SET_PAL_2 _IOW(0xfb,6,int*)\r
+#define GFX_FB_OSD_SURFACE _IO(0xfb,7)\r
+#define GFX_FB_SFC_SET_SHARE _IOW(0xfb,8,int)\r
+#define GFX_FB_OSD_CUR_SETATTR _IOW(0xfb,9,int*)\r
+#define GFX_FB_ATTACH _IOW(0xfb,11,int)\r
+#define GFX_FB_SFC_DETACH _IOW(0xfb,12,int*)\r
+#define GFX_FB_MOVE_DISPLAY _IOWR(0xfb,13,int)\r
+#define GFX_FB_SET_DISPLAY _IOW(0xfb,14,int)\r
+#define GFX_FB_OSD_CUR_MOVE_1 _IOW(0xfb,15,int*)\r
+#define GFX_FB_OSD_CUR_MOVE_2 _IOW(0xfb,16,int)\r
+#define GFX_FB_SET_OSD _IOW(0xfb,18,int)\r
+#define GFX_FB_SET_DISP_CTRL _IOW(0xfb,21,int*)\r
+#define GFX_FB_GET_DISP_CTRL _IOWR(0xfb,22,int*)\r
+#define GFX_FB_SET_VIS_DEV_CTL _IOWR(0xfb,23,int*)\r
+#define GFX_FB_GET_VIS_DEV_CTL _IOWR(0xfb,24,int*)\r
+#define GFX_FB_OSD_BITBLT _IOW(0xfb,51,osd_bitblt_t*)\r
+#define GFX_FB_OSD_FILLBLT _IOW(0xfb,53,osd_fillblt_t*)\r
+#define GFX_FB_OSD_ADVFILLBLT _IOW(0xfb,54,osd_afillblt_t*)\r
+#define GFX_FB_OSD_BLEND _IOW(0xfb,55,int*)\r
+#define GFX_FB_OSD_ADVBLEND _IOW(0xfb,56,int*)\r
+#define GFX_FB_OSD_RESIZE _IOW(0xfb,58,int*)\r
+#define GFX_FB_ENGINE_WAIT _IOW(0xfb,60,int)\r
+#define GFX_FB_RESET_ENGINE _IO(0xfb,61)\r
+#define GFX_FB_SET_ENGINE_MODE _IOW(0xfb,62,int)\r
+#define GFX_FB_GET_ENGINE_MODE _IO(0xfb,63)\r
+#define GFX_FB_GET_SFC_INFO _IO(0xfb,64,int*)\r
+#define GFX_FB_OSD_SFC_CLIP _IOW(0xfb,65,osd_clip_rec_t*)\r
+#define GFX_FB_OSD_COLOURKEY _IOW(0xfb,67,int*)\r
+#define GFX_FB_GET_SFC_PSEUDO _IOWR(0xfb,68,int*)\r
+\r
+class SurfaceMVP : public Surface\r
+{\r
+ public:\r
+ SurfaceMVP(int id = 0);\r
+ ~SurfaceMVP();\r
+\r
+ int create(UINT width, UINT height);\r
+ void display();\r
+ unsigned long getSurfaceHandle();\r
+\r
+ int fillblt(int x, int y, int width, int height, unsigned int rgba);\r
+ void drawPixel(int x, int y, unsigned int c, bool fastdraw=false);\r
+ void drawPixel(int x, int y, Colour& c, bool fastdraw=false);\r
+ void drawHorzLine(int x1, int x2, int y, unsigned int c);\r
+ void drawVertLine(int x, int y1, int y2, unsigned int c);\r
+ void drawBitmap(int x, int y, const Bitmap& bm);\r
+ int updateToScreen(int sx, int sy, int w, int h, int dx, int dy);\r
+ void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);\r
+ void screenShot(const char* fileName);\r
+\r
+ static void initConversionTables()\r
+ {\r
+ initConversionTables(100,100,100);\r
+ }\r
+ //init tables with factors for R,G,B - each in percent\r
+ static void initConversionTables(int r, int g, int b);\r
+\r
+ int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy);\r
+\r
+ private:\r
+ int fdOsd;\r
+ osd_surface_t surface;\r
+\r
+ void yuv2rgb(int y, int u, int v, unsigned char* pr, unsigned char* pg, unsigned char* pb);\r
+ /*\r
+ * rgb2yuv() - convert an RGB pixel to YUV\r
+ */\r
+ inline void rgb2yuv(unsigned char r, unsigned char g, unsigned char b, unsigned char *y, unsigned char *u, unsigned char *v)\r
+ {\r
+ int Y, U, V;\r
+\r
+ Y = conv_YB[b] + conv_YG[g] + conv_YR[r];\r
+ U = conv_UB[b] + conv_UG[g] + conv_UR[r] + 128;\r
+ V = conv_VB[b] + conv_VG[g] + conv_VR[r] + 128;\r
+\r
+ if (Y > 255)\r
+ Y = 255;\r
+ else if (Y < 0)\r
+ Y = 0;\r
+ if (U > 255)\r
+ U = 255;\r
+ else if (U < 0)\r
+ U = 0;\r
+ if (V > 255)\r
+ V = 255;\r
+ else if (V < 0)\r
+ V = 0;\r
+\r
+ *y = Y;\r
+ *u = U;\r
+ *v = V;\r
+ }\r
+\r
+\r
+ // Implicit inlines\r
+ void c2rgba(unsigned long c, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)\r
+ {\r
+ *a = (c & 0xff000000) >> 24;\r
+ *r = (c & 0x00ff0000) >> 16;\r
+ *g = (c & 0x0000ff00) >> 8;\r
+ *b = (c & 0x000000ff);\r
+ }\r
+\r
+ static int conv_YB[256];\r
+ static int conv_YG[256];\r
+ static int conv_YR[256];\r
+ static int conv_UB[256];\r
+ static int conv_UG[256];\r
+ static int conv_UR[256];\r
+ static int conv_VB[256];\r
+ static int conv_VG[256];\r
+ static int conv_VR[256];\r
+\r
+ static int conv_BY[256];\r
+ static int conv_GY[256];\r
+ static int conv_RY[256];\r
+ static int conv_BU[256];\r
+ static int conv_GU[256];\r
+ static int conv_RU[256];\r
+ static int conv_BV[256];\r
+ static int conv_GV[256];\r
+ static int conv_RV[256];\r
+\r
+};\r
+\r
+#endif\r