diff options
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/vo_ggi.c | 574 |
1 files changed, 236 insertions, 338 deletions
diff --git a/libvo/vo_ggi.c b/libvo/vo_ggi.c index 9fb804c918..b671bafd9d 100644 --- a/libvo/vo_ggi.c +++ b/libvo/vo_ggi.c @@ -5,6 +5,7 @@ Uses libGGI - http://www.ggi-project.org/ + Thanks to Andreas Beck for his patches. Many thanks to Atmosfear, he hacked this driver to working with Planar formats, and he fixed the RGB handling. */ @@ -14,6 +15,8 @@ #include <string.h> #include <errno.h> +#include "mp_msg.h" + #include "../config.h" #include "video_out.h" #include "video_out_internal.h" @@ -22,16 +25,14 @@ #include <ggi/ggi.h> -#undef GGI_OST -#undef GII_BUGGY_KEYCODES -#define GGI_OSD +#undef GET_DB_INFO -#undef get_db_info +#define GGI_FRAMES 4 /* do not make conversions from planar formats */ -#undef GGI_PLANAR_NOCONV +#undef GGI_YUV_SUPPORT -#ifndef GGI_PLANAR_NOCONV +#ifndef GGI_YUV_SUPPORT #include "../postproc/rgb2rgb.h" #endif @@ -45,14 +46,15 @@ static vo_info_t vo_info = "under developement" }; -extern int verbose; - -/* idea stolen from vo_sdl.c :) */ static struct ggi_conf_s { char *driver; ggi_visual_t vis; - ggi_directbuffer *buffer; + ggi_directbuffer *buffer[GGI_FRAMES]; + ggi_mode gmode; + + int frames; + int currframe; uint8_t bpp; uint8_t bppmul; @@ -71,31 +73,23 @@ static struct ggi_conf_s { int stridePlaneRGB; /* original */ - int width, height; + int srcwidth, srcheight; + int srcformat; + int srcdepth; + int srctype; /* destination */ int dstwidth, dstheight; /* source image format */ int format; - - /* direct buffer */ - uint8_t *dbuff; - - /* i.e. need lock */ - int need_acquire; - -#ifdef GGI_OST - ggi_pixel white; - ggi_pixel black; -#endif } ggi_conf; static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth) { ggi_mode mode = { - 1, /* frames */ + GGI_FRAMES, /* frames */ { GGI_AUTO, GGI_AUTO }, /* visible */ { GGI_AUTO, GGI_AUTO }, /* virt */ { GGI_AUTO, GGI_AUTO }, /* size */ @@ -104,14 +98,13 @@ static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth) }; ggi_color pal[256]; - if (verbose) - printf("ggi-setmode: requested: %dx%d (%d depth)\n", - d_width, d_height, d_depth); + mp_msg(MSGT_VO, MSGL_V, "[ggi] mode requested: %dx%d (%d depth)\n", + d_width, d_height, d_depth); - mode.size.x = vo_screenwidth; - mode.size.y = vo_screenheight; - mode.visible.x = mode.virt.x = d_width; - mode.visible.y = mode.virt.y = d_height; +// mode.size.x = vo_screenwidth; +// mode.size.y = vo_screenheight; + mode.visible.x = d_width; + mode.visible.y = d_height; switch(d_depth) { @@ -140,30 +133,29 @@ static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth) mode.graphtype = GT_32BIT; break; default: - printf("ggi-setmode: unknown bit depth - using auto\n"); + mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unknown bit depth - using auto\n"); mode.graphtype = GT_AUTO; } - + + /* FIXME */ ggiCheckMode(ggi_conf.vis, &mode); if (ggiSetMode(ggi_conf.vis, &mode) != 0) { - printf("ggi-setmode: unable to set mode\n"); - ggiClose(ggi_conf.vis); - ggiExit(); + mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set mode\n"); + uninit(); return(-1); } if (ggiGetMode(ggi_conf.vis, &mode) != 0) { - printf("ggi-setmode: unable to get mode\n"); - ggiClose(ggi_conf.vis); - ggiExit(); + mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get mode\n"); + uninit(); return(-1); } + + ggi_conf.gmode = mode; - ggi_conf.width = mode.virt.x; - ggi_conf.height = mode.virt.y; vo_screenwidth = mode.visible.x; vo_screenheight = mode.visible.y; vo_depthonscreen = d_depth; @@ -171,7 +163,7 @@ static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth) // ggi_bpp = GT_SIZE(mode.graphtype); ggi_conf.bpp = vo_depthonscreen; -#ifdef get_db_info +#ifdef GET_DB_INFO { const ggi_directbuffer *db = ggiDBGetBuffer(ggi_conf.vis, 0); @@ -189,138 +181,74 @@ static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth) ggiGetPalette(ggi_conf.vis, 0, 1 << ggi_conf.bpp, pal); } - if (verbose) - printf("ggi-setmode: %dx%d (virt: %dx%d) (size: %dx%d) screen depth: %d, bpp: %d\n", - vo_screenwidth, vo_screenheight, ggi_conf.width, ggi_conf.height, - mode.size.x, mode.size.y, - vo_depthonscreen, ggi_conf.bpp); +#if 0 + printf("[ggi] mode: "); + ggiPrintMode(&ggi_conf.gmode); + printf("\n"); +#endif + + mp_msg(MSGT_VO, MSGL_INFO, "[ggi] screen: %dx%dx%d frames: %d\n", + vo_screenwidth, vo_screenheight, vo_depthonscreen, ggi_conf.gmode.frames); ggi_conf.bppmul = (ggi_conf.bpp+7)/8; return(0); } -typedef struct ggi_aspect_ret_s { int w, h, x, y; } ggi_aspect_ret; - -/* stolen from vo_sdl.c */ -#define MONITOR_ASPECT 4.0/3.0 -static ggi_aspect_ret aspect_size(int srcw, int srch, int dstw, int dsth) -{ - ggi_aspect_ret ret; - float float_h; - - if (verbose) - printf("ggi-aspectsize: src: %dx%d dst: %dx%d\n", - srcw, srch, dstw, dsth); - - float_h = ((float)dsth / (float)srcw * (float)srch) * ((float)dsth / - ((float)dstw / (MONITOR_ASPECT))); - - if (float_h > dsth) - { - ret.w = (int)((float)dsth / (float)float_h) * dstw; - ret.h = dsth; - ret.x = (dstw - ret.w) / 2; - ret.y = 0; - } - else - { - ret.h = (int)float_h; - ret.w = dstw; - ret.x = 0; - ret.y = (dsth - ret.h) / 2; - } - - printf("ggi-aspectsize: %dx%d (x: %d, y: %d)\n", ret.w, ret.h, ret.x, ret.y); - return(ret); -} static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info) { + int i; + vo_depthonscreen = 32; - printf("ggi-init: This driver has got bugs, if you can, fix them.\n"); + mp_msg(MSGT_VO, MSGL_INFO, "[ggi] This driver has got bugs, if you can, fix them.\n"); - if (ggiInit() != 0) + /* source image parameters */ + ggi_conf.srcwidth = width; + ggi_conf.srcheight = height; + ggi_conf.srcformat = format; + if (IMGFMT_IS_RGB(ggi_conf.srcformat)) { - printf("ggi-init: unable to initialize GGI\n"); - return(-1); + ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat); + ggi_conf.srctype = RGB; } - - ggi_conf.driver = NULL; - - if ((ggi_conf.vis = ggiOpen(ggi_conf.driver)) == NULL) + else + if (IMGFMT_IS_BGR(ggi_conf.srcformat)) { - printf("ggi-init: unable to open GGI for %s output\n", - (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); - ggiExit(); - return(-1); + ggi_conf.srcdepth = IMGFMT_BGR_DEPTH(ggi_conf.srcformat); + ggi_conf.srctype = BGR; } - - printf("ggi-init: using %s GGI output\n", - (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); - - switch(format) + else + switch(ggi_conf.srcformat) { - case IMGFMT_RGB8: - ggi_conf.bpp = 8; - ggi_conf.mode = RGB; - break; - case IMGFMT_RGB15: - ggi_conf.bpp = 15; - ggi_conf.mode = RGB; - break; - case IMGFMT_RGB16: - ggi_conf.bpp = 16; - ggi_conf.mode = RGB; - break; - case IMGFMT_RGB24: - ggi_conf.bpp = 24; - ggi_conf.mode = RGB; - break; - case IMGFMT_RGB32: - ggi_conf.bpp = 32; - ggi_conf.mode = RGB; - break; - case IMGFMT_BGR8: - ggi_conf.bpp = 8; - ggi_conf.mode = BGR; - break; - case IMGFMT_BGR15: - ggi_conf.bpp = 15; - ggi_conf.mode = BGR; - break; - case IMGFMT_BGR16: - ggi_conf.bpp = 16; - ggi_conf.mode = BGR; - break; - case IMGFMT_BGR24: - ggi_conf.bpp = 24; - ggi_conf.mode = BGR; - break; - case IMGFMT_BGR32: - ggi_conf.bpp = 32; - ggi_conf.mode = BGR; - break; - case IMGFMT_YV12: /* rgb, 24bit */ - case IMGFMT_I420: case IMGFMT_IYUV: - ggi_conf.bpp = 16; - ggi_conf.mode = YUV; -#ifndef GGI_PLANAR_NOCONV - yuv2rgb_init(32/*vo_depthonscreen*/, MODE_RGB); + case IMGFMT_I420: + case IMGFMT_YV12: +#ifdef GGI_YUV_SUPPORT + ggi_conf.srcdepth = 12; + ggi_conf.srctype = YUV; +#else + ggi_conf.bpp = vo_depthonscreen; + ggi_conf.mode = RGB; + yuv2rgb_init(vo_depthonscreen, MODE_RGB); #endif break; + case IMGFMT_UYVY: case IMGFMT_YUY2: - ggi_conf.bpp = 24; - ggi_conf.mode = YUV; -#ifndef GGI_PLANAR_NOCONV - yuv2rgb_init(32, MODE_RGB); +#ifdef GGI_YUV_SUPPORT + ggi_conf.srcdepth = 16; + ggi_conf.srctype = YUV; +#else + ggi_conf.bpp = vo_depthonscreen; + ggi_conf.mode = RGB; + yuv2rgb_init(vo_depthonscreen, MODE_RGB); #endif break; default: - printf("ggi-init: no suitable image format found (requested: %s)\n", - vo_format_name(format)); + mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", + vo_format_name(ggi_conf.srcformat)); + uninit(); return(-1); } @@ -328,7 +256,7 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, ggi_conf.framePlaneRGB = width * height * ((ggi_conf.bpp+7)/8); /* fix it! */ ggi_conf.stridePlaneRGB = width * ((ggi_conf.bpp+7)/8); -#ifdef GGI_PLANAR_NOCONV +#ifdef GGI_YUV_SUPPORT ggi_conf.framePlaneY = width * height; ggi_conf.framePlaneUV = (width * height) >> 2; ggi_conf.framePlaneYUY = width * height * 2; @@ -336,12 +264,13 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, ggi_conf.stridePlaneUV = width/2; ggi_conf.stridePlaneYUY = width * 2; #endif - ggi_conf.width = width; - ggi_conf.height = height; +// ggi_conf.width = width; +// ggi_conf.height = height; ggi_conf.dstwidth = d_width ? d_width : width; ggi_conf.dstheight = d_height ? d_height : height; { +#if 0 ggi_aspect_ret asp; if (width != d_width || height != d_height) @@ -351,67 +280,63 @@ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, asp.w = width; asp.h = height; } +#endif - if (ggi_setmode(asp.w, asp.h, vo_depthonscreen) != 0) + if (ggi_setmode(width, height, vo_depthonscreen) != 0) { printf("ggi-init: setmode returned with error\n"); return(-1); } } - printf("ggi-init: input: %d bpp %s - screen depth: %d\n", ggi_conf.bpp, - vo_format_name(ggi_conf.format), vo_depthonscreen); - - ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC); + mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %d bpp %s - screen depth: %d\n", + ggi_conf.bpp, vo_format_name(ggi_conf.format), vo_depthonscreen); - ggi_conf.buffer = (ggi_directbuffer *)ggiDBGetBuffer(ggi_conf.vis, 0); +// ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC); - if (ggi_conf.buffer == NULL) { - printf("ggi-init: double buffering is not available\n"); - ggiClose(ggi_conf.vis); - ggiExit(); - return(-1); - } + ggi_directbuffer *DB; - if (!(ggi_conf.buffer->type & GGI_DB_SIMPLE_PLB) || - (ggi_conf.buffer->page_size != 0) || - (ggi_conf.buffer->write == NULL) || - (ggi_conf.buffer->noaccess != 0) || - (ggi_conf.buffer->align != 0) || - (ggi_conf.buffer->layout != blPixelLinearBuffer)) + for (i = 0; i < GGI_FRAMES; i++) + ggi_conf.buffer[i] = NULL; + + ggi_conf.frames = ggi_conf.currframe = 0; + + for (i = 0; DB = ggiDBGetBuffer(ggi_conf.vis, i); i++) + { + if (!(DB->type & GGI_DB_SIMPLE_PLB) || + (DB->page_size != 0) || + (DB->write == NULL) || + (DB->noaccess != 0) || + (DB->align != 0) || + (DB->layout != blPixelLinearBuffer)) + continue; + + ggi_conf.buffer[DB->frame] = DB; + ggi_conf.frames++; + } + } + + + if (ggi_conf.buffer[0] == NULL) { - printf("ggi-init: incorrect video memory type\n"); - ggiClose(ggi_conf.vis); - ggiExit(); + mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer is not available\n"); + uninit(); return(-1); } - if (ggi_conf.buffer->resource != NULL) - ggi_conf.need_acquire = 1; - - if (verbose && ggi_conf.need_acquire) - printf("ggi-init: ggi needs acquire\n"); - - ggi_conf.dbuff = ggi_conf.buffer->write; - -#ifdef GGI_OST - /* just for fun */ + for (i = 0; i < ggi_conf.frames; i++) { - ggi_color col; - - /* set black */ - col.r = col.g = col.b = 0x0000; - ggi_conf.black = ggiMapColor(ggi_conf.vis, &col); - - /* set white */ - col.r = col.g = col.b = 0xffff; - ggi_conf.white = ggiMapColor(ggi_conf.vis, &col); - - ggiSetGCForeground(ggi_conf.vis, ggi_conf.white); - ggiSetGCBackground(ggi_conf.vis, ggi_conf.black); + if (ggi_conf.buffer[i] == NULL) + { + mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer for doublbuffering is not available\n"); + uninit(); + return(-1); + } } -#endif + + ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); + ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); return(0); } @@ -423,38 +348,46 @@ static const vo_info_t *get_info(void) static uint32_t draw_frame(uint8_t *src[]) { - if (ggi_conf.need_acquire) - ggiResourceAcquire(ggi_conf.buffer->resource, GGI_ACTYPE_WRITE); + int x, y, size; + unsigned char *ptr, *ptr2, *spt; + + ggiResourceAcquire(ggi_conf.buffer[ggi_conf.currframe]->resource, + GGI_ACTYPE_WRITE); -// ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.buffer->frame); -// ggiSetWriteFrame(ggi_conf.vis, ggi_conf.buffer->frame); + ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); -#ifdef GGI_PLANAR_NOCONV - switch(ggi_conf.format) +#if 1 + ptr = ggi_conf.buffer[ggi_conf.currframe]->write; + spt = src[0]; + size = ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size/8; + + for (y = 0; y < ggi_conf.srcheight; y++) { - case IMGFMT_YV12: - case IMGFMT_I420: - case IMGFMT_IYUV: - memcpy(ggi_conf.dbuff, src[0], ggi_conf.framePlaneY); - ggi_conf.dbuff += ggi_conf.framePlaneY; - memcpy(ggi_conf.dbuff, src[2], ggi_conf.framePlaneUV); - ggi_conf.dbuff += ggi_conf.framePlaneUV; - memcpy(ggi_conf.dbuff, src[1], ggi_conf.framePlaneUV); - printf("yv12 img written"); - break; - default: - memcpy(ggi_conf.dbuff, src[0], ggi_conf.framePlaneRGB); + ptr2 = ptr; + for (x = 0; x < ggi_conf.srcwidth; x++) + { + ptr2[0] = *spt++; + ptr2[1] = *spt++; + ptr2[2] = *spt++; + switch(ggi_conf.format) + { + case IMGFMT_BGR32: + case IMGFMT_RGB32: + spt++; + break; + } + ptr2 += size; + } + ptr += ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride; } #else - memcpy(ggi_conf.dbuff, src[0], ggi_conf.framePlaneRGB); + memcpy(ggi_conf.buffer[ggi_conf.currframe]->write, src[0], ggi_conf.framePlaneRGB); #endif - if (ggi_conf.need_acquire) - ggiResourceRelease(ggi_conf.buffer->resource); + ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource); return(0); } -#ifdef GGI_OSD static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) { @@ -463,28 +396,28 @@ static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: -#ifdef GGI_PLANAR_NOCONV +#ifdef GGI_YUV_SUPPORT vo_draw_alpha_yv12(w, h, src, srca, stride, - ggi_conf.dbuff+(ggi_conf.width*y0+x0), - ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+(ggi_conf.srcwidth*y0+x0), + ggi_conf.srcwidth); #else switch (vo_depthonscreen) { case 32: vo_draw_alpha_rgb32(w, h, src, srca, stride, - ggi_conf.dbuff+4*(ggi_conf.width*y0+x0), 4*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.srcwidth*y0+x0), 4*ggi_conf.srcwidth); break; case 24: vo_draw_alpha_rgb24(w, h, src, srca, stride, - ggi_conf.dbuff+3*(ggi_conf.width*y0+x0), 3*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+3*(ggi_conf.srcwidth*y0+x0), 3*ggi_conf.srcwidth); break; case 16: vo_draw_alpha_rgb16(w, h, src, srca, stride, - ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth); break; case 15: vo_draw_alpha_rgb15(w, h, src, srca, stride, - ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth); break; } #endif @@ -492,68 +425,74 @@ static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, case IMGFMT_YUY2: case IMGFMT_YVYU: vo_draw_alpha_yuy2(w, h, src, srca, stride, - ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), - 2*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), + 2*ggi_conf.srcwidth); break; case IMGFMT_UYVY: vo_draw_alpha_yuy2(w, h, src, srca, stride, - ggi_conf.dbuff+2*(ggi_conf.width*y0+x0)+1, - 2*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0)+1, + 2*ggi_conf.srcwidth); break; case IMGFMT_RGB15: case IMGFMT_BGR15: vo_draw_alpha_rgb15(w, h, src, srca, stride, - ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth); break; case IMGFMT_RGB16: case IMGFMT_BGR16: vo_draw_alpha_rgb16(w, h, src, srca, stride, - ggi_conf.dbuff+2*(ggi_conf.width*y0+x0), 2*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.srcwidth*y0+x0), 2*ggi_conf.srcwidth); break; case IMGFMT_RGB24: case IMGFMT_BGR24: vo_draw_alpha_rgb24(w, h, src, srca, stride, - ggi_conf.dbuff+3*(ggi_conf.width*y0+x0), 3*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+3*(ggi_conf.srcwidth*y0+x0), 3*ggi_conf.srcwidth); break; case IMGFMT_RGB32: case IMGFMT_BGR32: vo_draw_alpha_rgb32(w, h, src, srca, stride, - ggi_conf.dbuff+4*(ggi_conf.width*y0+x0), 4*ggi_conf.width); + ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.srcwidth*y0+x0), 4*ggi_conf.srcwidth); break; } } -#endif static void draw_osd(void) { -#ifdef GGI_OSD - vo_draw_text(ggi_conf.width, ggi_conf.height, draw_alpha); -#endif + vo_draw_text(ggi_conf.srcwidth, ggi_conf.srcheight, draw_alpha); } static void flip_page(void) { - ggiFlush(ggi_conf.vis); + ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe); + mp_dbg(MSGT_VO, MSGL_DBG2, "flip_page: current write frame: %d, display frame: %d\n", + ggiGetWriteFrame(ggi_conf.vis), ggiGetDisplayFrame(ggi_conf.vis)); + + ggi_conf.currframe = (ggi_conf.currframe+1) % ggi_conf.frames; } static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) { - if (ggi_conf.need_acquire) - ggiResourceAcquire(ggi_conf.buffer->resource, GGI_ACTYPE_WRITE); -#ifndef GGI_PLANAR_NOCONV - yuv2rgb(((uint8_t *) ggi_conf.dbuff)+(ggi_conf.width*y+x)*ggi_conf.bppmul, - src[0], src[1], src[2], w, h, ggi_conf.width*ggi_conf.bppmul, stride[0], - stride[1]); + ggiResourceAcquire(ggi_conf.buffer[ggi_conf.currframe]->resource, + GGI_ACTYPE_WRITE); + + ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe); + +#ifndef GGI_YUV_SUPPORT + yuv2rgb(((uint8_t *) ggi_conf.buffer[ggi_conf.currframe]->write)+ + ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride*y+ + x*(ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size/8), + src[0], src[1], src[2], w, h, ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride, + stride[0], stride[1]); #else int i; - ggi_conf.dbuff += (ggi_conf.stridePlaneY * y + x); + ggi_conf.buffer[ggi_conf.currframe]->write += (ggi_conf.stridePlaneY * y + x); for (i = 0; i < h; i++) { - memcpy(ggi_conf.dbuff, src[0], w); + memcpy(ggi_conf.buffer[ggi_conf.currframe]->write, src[0], w); src[0] += stride[0]; - ggi_conf.dbuff += ggi_conf.stridePlaneY; + ggi_conf.buffer[ggi_conf.currframe]->write += ggi_conf.stridePlaneY; } x /= 2; @@ -561,16 +500,16 @@ static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, w /= 2; h /= 2; - ggi_conf.dbuff += ggi_conf.stridePlaneY + (ggi_conf.stridePlaneUV * y + x); + ggi_conf.buffer[ggi_conf.currframe]->write += ggi_conf.stridePlaneY + (ggi_conf.stridePlaneUV * y + x); for (i = 0; i < h; i++) { - memcpy(ggi_conf.dbuff, src[1], w); + memcpy(ggi_conf.buffer[ggi_conf.currframe]->write, src[1], w); src[1] += stride[1]; - ggi_conf.dbuff += ggi_conf.stridePlaneUV; + ggi_conf.buffer[ggi_conf.currframe]->write += ggi_conf.stridePlaneUV; } #endif - if (ggi_conf.need_acquire) - ggiResourceRelease(ggi_conf.buffer->resource); + + ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource); return(0); } @@ -600,13 +539,48 @@ static uint32_t query_format(uint32_t format) return(0); } +static uint32_t preinit(const char *arg) +{ + if (ggiInit() != 0) + { + mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize GGI\n"); + return(-1); + } + + if (arg) + ggi_conf.driver = arg; + else + ggi_conf.driver = NULL; + + if ((ggi_conf.vis = ggiOpen(ggi_conf.driver)) == NULL) + { + mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to open '%s' output\n", + (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); + ggiExit(); + return(-1); + } + + mp_msg(MSGT_VO, MSGL_V, "[ggi] using '%s' output\n", + (ggi_conf.driver == NULL) ? "default" : ggi_conf.driver); + + return 0; +} + static void uninit(void) { - ggiResourceRelease(ggi_conf.buffer->resource); ggiClose(ggi_conf.vis); ggiExit(); } +static uint32_t control(uint32_t request, void *data, ...) +{ + switch (request) { + case VOCTRL_QUERY_FORMAT: + return query_format(*((uint32_t*)data)); + } + return VO_NOTIMPL; +} + #include "../linux/keycodes.h" extern void mplayer_put_key(int code); @@ -619,75 +593,11 @@ static void check_events(void) if ((mask = ggiEventPoll(ggi_conf.vis, emAll, &tv))) if (ggiEventRead(ggi_conf.vis, &event, emAll) != 0) { -#if 0 /* debug ;) */ - printf("type: %4x, origin: %4x, sym: %4x, label: %4x, button=%4x\n", + mp_dbg(MSGT_VO, MSGL_DBG3, "type: %4x, origin: %4x, sym: %4x, label: %4x, button=%4x\n", event.any.origin, event.any.type, event.key.sym, event.key.label, event.key.button); -#endif if (event.key.type == evKeyPress) { -#ifdef GII_BUGGY_KEYCODES - switch(event.key.button) - { - case 0x37: - mplayer_put_key('*'); - break; - case 0x68: - mplayer_put_key('/'); - break; - case 0x4e: - mplayer_put_key('+'); - break; - case 0x4a: - mplayer_put_key('-'); - break; - case 0x18: /* o */ - mplayer_put_key('o'); - break; - case 0x22: /* g */ - mplayer_put_key('g'); - break; - case 0x15: /* z */ - mplayer_put_key('z'); - break; - case 0x2d: /* x */ - mplayer_put_key('x'); - break; - case 0x32: /* m */ - mplayer_put_key('m'); - break; - case 0x20: /* d */ - mplayer_put_key('d'); - break; - case 0x10: /* q */ - mplayer_put_key('q'); - break; - case 0x39: /* space */ - case 0x19: /* p */ - mplayer_put_key('p'); - break; - case 0x5a: - mplayer_put_key(KEY_UP); - break; - case 0x60: - mplayer_put_key(KEY_DOWN); - break; - case 0x5c: - mplayer_put_key(KEY_LEFT); - break; - case 0x5e: - mplayer_put_key(KEY_RIGHT); - break; - case 0x5b: - mplayer_put_key(KEY_PAGE_UP); - break; - case 0x61: - mplayer_put_key(KEY_PAGE_DOWN); - break; - default: - break; - } -#else switch(event.key.sym) { case GIIK_PAsterisk: /* PStar */ @@ -734,6 +644,14 @@ static void check_events(void) case GIIUC_Q: mplayer_put_key('q'); break; + case GIIUC_h: + case GIIUC_H: + mplayer_put_key('h'); + break; + case GIIUC_l: + case GIIUC_L: + mplayer_put_key('l'); + break; case GIIUC_Space: case GIIUC_p: case GIIUC_P: @@ -760,27 +678,7 @@ static void check_events(void) default: break; } -#endif } } return; } - -static uint32_t preinit(const char *arg) -{ - if(arg) - { - printf("vo_ggi: Unknown subdevice: %s\n",arg); - return ENOSYS; - } - return 0; -} - -static uint32_t control(uint32_t request, void *data, ...) -{ - switch (request) { - case VOCTRL_QUERY_FORMAT: - return query_format(*((uint32_t*)data)); - } - return VO_NOTIMPL; -} |