2001-06-19 23:20:59 +00:00
|
|
|
/*
|
2001-06-15 16:31:19 +00:00
|
|
|
vo_ggi.c - General Graphics Interface (GGI) Renderer for MPlayer
|
|
|
|
|
|
|
|
(C) Alex Beregszaszi <alex@naxine.org>
|
|
|
|
|
|
|
|
Uses libGGI - http://www.ggi-project.org/
|
|
|
|
|
2002-02-24 16:28:44 +00:00
|
|
|
TODO:
|
2002-04-15 18:04:18 +00:00
|
|
|
* implement direct rendering support - NEEDS TESTING
|
|
|
|
* implement non-directbuffer support - NEEDS TESTING
|
2002-02-24 16:28:44 +00:00
|
|
|
* check on many devices
|
2002-04-19 16:50:03 +00:00
|
|
|
* implement gamma handling (VAA isn't obsoleted?)
|
|
|
|
|
|
|
|
BUGS:
|
|
|
|
* fbdev & DR produces two downscaled images
|
|
|
|
* fbdev & FLIP (& DR) produces no image
|
2002-02-24 16:28:44 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
Thanks to Andreas Beck for his patches.
|
2002-04-19 16:50:03 +00:00
|
|
|
|
2002-02-24 16:28:44 +00:00
|
|
|
Many thanks to Atmosfear, he hacked this driver to work with Planar
|
2001-06-17 12:24:52 +00:00
|
|
|
formats, and he fixed the RGB handling.
|
|
|
|
*/
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
#include "../config.h"
|
2001-06-15 16:31:19 +00:00
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
#include "fastmemcpy.h"
|
2001-06-15 16:31:19 +00:00
|
|
|
|
|
|
|
#include <ggi/ggi.h>
|
2001-06-17 12:24:52 +00:00
|
|
|
|
2002-02-24 02:50:02 +00:00
|
|
|
/* maximum buffers */
|
2002-02-23 23:31:08 +00:00
|
|
|
#define GGI_FRAMES 4
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
#undef GGI_GAMMA
|
2002-04-19 16:50:03 +00:00
|
|
|
#undef GGI_FLIP
|
2002-04-15 18:04:18 +00:00
|
|
|
|
|
|
|
#include "../libmpcodecs/mp_image.h"
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
LIBVO_EXTERN (ggi)
|
|
|
|
|
|
|
|
static vo_info_t vo_info =
|
|
|
|
{
|
|
|
|
"General Graphics Interface (GGI) output",
|
|
|
|
"ggi",
|
|
|
|
"Alex Beregszaszi <alex@naxine.org>",
|
2001-06-17 12:24:52 +00:00
|
|
|
"under developement"
|
2001-06-15 16:31:19 +00:00
|
|
|
};
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
static struct ggi_conf_s {
|
|
|
|
char *driver;
|
|
|
|
|
|
|
|
ggi_visual_t vis;
|
2002-02-23 23:31:08 +00:00
|
|
|
ggi_directbuffer *buffer[GGI_FRAMES];
|
|
|
|
ggi_mode gmode;
|
|
|
|
|
|
|
|
int frames;
|
|
|
|
int currframe;
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
/* source image format */
|
|
|
|
int srcwidth;
|
|
|
|
int srcheight;
|
2002-02-23 23:31:08 +00:00
|
|
|
int srcformat;
|
|
|
|
int srcdepth;
|
2002-04-19 16:50:03 +00:00
|
|
|
int srcbpp;
|
2001-06-19 23:20:59 +00:00
|
|
|
|
|
|
|
/* destination */
|
2002-02-24 02:21:14 +00:00
|
|
|
int dstwidth;
|
|
|
|
int dstheight;
|
2002-02-24 16:28:44 +00:00
|
|
|
|
|
|
|
int async;
|
2002-04-15 18:04:18 +00:00
|
|
|
int directbuffer;
|
2002-04-19 16:50:03 +00:00
|
|
|
|
|
|
|
int voflags;
|
2001-06-19 23:20:59 +00:00
|
|
|
} ggi_conf;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
static uint32_t draw_frame_directbuffer(uint8_t *src[]);
|
|
|
|
static void draw_osd_directbuffer(void);
|
|
|
|
static void flip_page_directbuffer(void);
|
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,
|
2002-04-19 16:50:03 +00:00
|
|
|
uint32_t d_height, uint32_t flags, char *title, uint32_t format,const vo_tune_info_t *info)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
ggi_mode mode =
|
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
GGI_FRAMES, /* frames */
|
2002-02-24 02:21:14 +00:00
|
|
|
{ width, height }, /* visible */
|
2001-06-15 16:31:19 +00:00
|
|
|
{ GGI_AUTO, GGI_AUTO }, /* virt */
|
|
|
|
{ GGI_AUTO, GGI_AUTO }, /* size */
|
|
|
|
GT_AUTO, /* graphtype */
|
|
|
|
{ GGI_AUTO, GGI_AUTO } /* dots per pixel */
|
|
|
|
};
|
2002-02-24 02:21:14 +00:00
|
|
|
int i;
|
|
|
|
ggi_directbuffer *DB;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
switch(format)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-24 02:21:14 +00:00
|
|
|
case IMGFMT_RGB|8:
|
|
|
|
case IMGFMT_BGR|8:
|
2001-06-15 16:31:19 +00:00
|
|
|
mode.graphtype = GT_8BIT;
|
|
|
|
break;
|
2002-02-24 02:21:14 +00:00
|
|
|
case IMGFMT_RGB|15:
|
|
|
|
case IMGFMT_BGR|15:
|
2001-06-15 16:31:19 +00:00
|
|
|
mode.graphtype = GT_15BIT;
|
|
|
|
break;
|
2002-02-24 02:21:14 +00:00
|
|
|
case IMGFMT_RGB|16:
|
|
|
|
case IMGFMT_BGR|16:
|
2001-06-15 16:31:19 +00:00
|
|
|
mode.graphtype = GT_16BIT;
|
|
|
|
break;
|
2002-02-24 02:21:14 +00:00
|
|
|
case IMGFMT_RGB|24:
|
|
|
|
case IMGFMT_BGR|24:
|
2001-06-15 16:31:19 +00:00
|
|
|
mode.graphtype = GT_24BIT;
|
|
|
|
break;
|
2002-02-24 02:21:14 +00:00
|
|
|
case IMGFMT_RGB|32:
|
|
|
|
case IMGFMT_BGR|32:
|
2001-06-15 16:31:19 +00:00
|
|
|
mode.graphtype = GT_32BIT;
|
|
|
|
break;
|
|
|
|
}
|
2002-02-23 23:31:08 +00:00
|
|
|
|
2002-04-19 16:50:03 +00:00
|
|
|
#if 0
|
2002-02-24 02:21:14 +00:00
|
|
|
printf("[ggi] mode: ");
|
|
|
|
ggiPrintMode(&mode);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiCheckMode(ggi_conf.vis, &mode);
|
2002-02-24 02:21:14 +00:00
|
|
|
|
|
|
|
if (ggiSetMode(ggi_conf.vis, &mode))
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set mode\n");
|
2001-06-15 16:31:19 +00:00
|
|
|
return(-1);
|
|
|
|
}
|
2002-02-24 02:21:14 +00:00
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
if (ggiGetMode(ggi_conf.vis, &mode))
|
2001-06-17 18:32:14 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get mode\n");
|
2001-06-17 18:32:14 +00:00
|
|
|
return(-1);
|
|
|
|
}
|
2002-02-23 23:31:08 +00:00
|
|
|
|
2002-02-24 16:28:44 +00:00
|
|
|
if ((mode.graphtype == GT_INVALID) || (mode.graphtype == GT_AUTO))
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
ggi_conf.gmode = mode;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2002-04-19 16:50:03 +00:00
|
|
|
#if 0
|
2002-02-23 23:31:08 +00:00
|
|
|
printf("[ggi] mode: ");
|
2002-02-24 02:21:14 +00:00
|
|
|
ggiPrintMode(&mode);
|
2002-02-23 23:31:08 +00:00
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
vo_depthonscreen = GT_DEPTH(mode.graphtype);
|
|
|
|
vo_screenwidth = mode.visible.x;
|
|
|
|
vo_screenheight = mode.visible.y;
|
|
|
|
|
|
|
|
vo_dx = vo_dy = 0;
|
|
|
|
vo_dwidth = mode.virt.x;
|
|
|
|
vo_dheight = mode.virt.y;
|
2002-02-24 16:28:44 +00:00
|
|
|
vo_dbpp = GT_SIZE(mode.graphtype);
|
2001-06-17 12:24:52 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
ggi_conf.srcwidth = width;
|
|
|
|
ggi_conf.srcheight = height;
|
|
|
|
ggi_conf.srcformat = format;
|
2002-04-19 16:50:03 +00:00
|
|
|
|
|
|
|
ggi_conf.voflags = flags;
|
2002-02-24 02:21:14 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
if (IMGFMT_IS_RGB(ggi_conf.srcformat))
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2002-02-23 23:31:08 +00:00
|
|
|
else
|
|
|
|
if (IMGFMT_IS_BGR(ggi_conf.srcformat))
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
ggi_conf.srcdepth = IMGFMT_BGR_DEPTH(ggi_conf.srcformat);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2002-02-23 23:31:08 +00:00
|
|
|
else
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n",
|
|
|
|
vo_format_name(ggi_conf.srcformat));
|
|
|
|
return(-1);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
vo_dwidth = ggi_conf.dstwidth = ggi_conf.gmode.virt.x;
|
|
|
|
vo_dheight = ggi_conf.dstheight = ggi_conf.gmode.virt.y;
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
ggi_conf.directbuffer = 1;
|
|
|
|
|
2002-02-24 02:50:02 +00:00
|
|
|
ggi_conf.frames = ggiDBGetNumBuffers(ggi_conf.vis);
|
|
|
|
if (ggi_conf.frames > GGI_FRAMES)
|
|
|
|
ggi_conf.frames = GGI_FRAMES;
|
|
|
|
|
|
|
|
ggi_conf.currframe = 0;
|
|
|
|
if (!ggi_conf.frames)
|
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
goto db_err;
|
2002-02-24 02:50:02 +00:00
|
|
|
}
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2002-02-24 02:50:02 +00:00
|
|
|
for (i = 0; i < ggi_conf.frames; i++)
|
|
|
|
ggi_conf.buffer[i] = NULL;
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
/* get available number of buffers */
|
2002-02-24 16:28:44 +00:00
|
|
|
for (i = 0; DB = (ggi_directbuffer *)ggiDBGetBuffer(ggi_conf.vis, i),
|
|
|
|
i < ggi_conf.frames; i++)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-24 02:21:14 +00:00
|
|
|
if (!(DB->type & GGI_DB_SIMPLE_PLB) ||
|
|
|
|
(DB->page_size != 0) ||
|
|
|
|
(DB->write == NULL) ||
|
|
|
|
(DB->noaccess != 0) ||
|
|
|
|
(DB->align != 0) ||
|
|
|
|
(DB->layout != blPixelLinearBuffer))
|
|
|
|
continue;
|
2002-02-23 23:31:08 +00:00
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
ggi_conf.buffer[DB->frame] = DB;
|
2002-02-23 23:31:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ggi_conf.buffer[0] == NULL)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
goto db_err;
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
for (i = 0; i < ggi_conf.frames; i++)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
if (ggi_conf.buffer[i] == NULL)
|
|
|
|
{
|
2002-02-24 02:21:14 +00:00
|
|
|
ggi_conf.frames = i-1;
|
|
|
|
break;
|
2002-02-23 23:31:08 +00:00
|
|
|
}
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2002-02-23 23:31:08 +00:00
|
|
|
ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe);
|
|
|
|
ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe);
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
goto db_ok;
|
|
|
|
|
|
|
|
db_err:
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer unavailable, using async mode\n");
|
|
|
|
ggi_conf.directbuffer = 0;
|
|
|
|
ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC);
|
|
|
|
|
|
|
|
db_ok:
|
|
|
|
if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
|
|
|
|
ggiSetColorfulPalette(ggi_conf.vis);
|
|
|
|
|
|
|
|
if (ggiGetFlags(ggi_conf.vis) & GGIFLAG_ASYNC)
|
|
|
|
ggi_conf.async = 1;
|
|
|
|
|
2002-02-24 02:21:14 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d, frames: %d\n",
|
|
|
|
ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth,
|
2002-02-24 16:28:44 +00:00
|
|
|
vo_dwidth, vo_dheight, vo_dbpp, ggi_conf.frames);
|
2002-04-15 18:04:18 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "[ggi] directbuffer: %s, async mode: %s\n",
|
|
|
|
ggi_conf.directbuffer ? "yes" : "no",
|
|
|
|
ggi_conf.async ? "yes" : "no");
|
2002-02-24 16:28:44 +00:00
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
if (ggi_conf.directbuffer)
|
2002-02-24 16:28:44 +00:00
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
video_out_ggi.draw_frame = draw_frame_directbuffer;
|
|
|
|
video_out_ggi.draw_osd = draw_osd_directbuffer;
|
|
|
|
video_out_ggi.flip_page = flip_page_directbuffer;
|
2002-02-24 16:28:44 +00:00
|
|
|
}
|
2002-04-19 16:50:03 +00:00
|
|
|
|
|
|
|
ggi_conf.srcbpp = (ggi_conf.srcdepth+7)/8;
|
2002-02-24 02:21:14 +00:00
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
static const vo_info_t *get_info(void)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
|
|
|
return &vo_info;
|
|
|
|
}
|
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
static uint32_t get_image(mp_image_t *mpi)
|
|
|
|
{
|
|
|
|
/* GGI DirectRendering supports (yet) only BGR/RGB modes */
|
|
|
|
if (!ggi_conf.directbuffer ||
|
|
|
|
#if 1
|
|
|
|
(IMGFMT_IS_RGB(mpi->imgfmt) &&
|
|
|
|
(IMGFMT_RGB_DEPTH(mpi->imgfmt) != vo_dbpp)) ||
|
|
|
|
(IMGFMT_IS_BGR(mpi->imgfmt) &&
|
|
|
|
(IMGFMT_BGR_DEPTH(mpi->imgfmt) != vo_dbpp)) ||
|
|
|
|
#else
|
|
|
|
(mpi->imgfmt != ggi_conf.srcformat) ||
|
|
|
|
#endif
|
|
|
|
((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) ||
|
|
|
|
(mpi->flags & MP_IMGFLAG_PLANAR) ||
|
|
|
|
(mpi->flags & MP_IMGFLAG_YUV) ||
|
|
|
|
(mpi->width != ggi_conf.srcwidth) ||
|
|
|
|
(mpi->height != ggi_conf.srcheight)
|
|
|
|
)
|
|
|
|
return(VO_FALSE);
|
|
|
|
|
|
|
|
if (ggi_conf.frames > 1)
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_VO, MSGL_WARN, "[ggi] doublebuffering disabled due to directrendering\n");
|
|
|
|
ggi_conf.currframe = 0;
|
|
|
|
ggi_conf.frames = 1;
|
|
|
|
}
|
2002-04-19 16:50:03 +00:00
|
|
|
|
|
|
|
mpi->planes[1] = mpi->planes[2] = NULL;
|
|
|
|
mpi->stride[1] = mpi->stride[2] = 0;
|
|
|
|
|
|
|
|
mpi->stride[0] = ggi_conf.srcwidth*ggi_conf.srcbpp;
|
2002-04-15 18:04:18 +00:00
|
|
|
mpi->planes[0] = ggi_conf.buffer[ggi_conf.currframe]->write;
|
|
|
|
mpi->flags |= MP_IMGFLAG_DIRECT;
|
|
|
|
|
2002-04-19 16:50:03 +00:00
|
|
|
#ifdef GGI_FLIP
|
|
|
|
if (ggi_conf.voflags & VOFLAG_FLIPPING)
|
|
|
|
{
|
|
|
|
mpi->stride[0] = -mpi->stride[0];
|
|
|
|
mpi->planes[0] -= mpi->stride[0]*(ggi_conf.srcheight-1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
return(VO_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t draw_frame_directbuffer(uint8_t *src[])
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-04-19 16:50:03 +00:00
|
|
|
unsigned char *dst_ptr;
|
|
|
|
int dst_stride, dst_bpp;
|
2002-04-15 18:04:18 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
ggiResourceAcquire(ggi_conf.buffer[ggi_conf.currframe]->resource,
|
|
|
|
GGI_ACTYPE_WRITE);
|
2001-06-17 12:24:52 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
ggiSetWriteFrame(ggi_conf.vis, ggi_conf.currframe);
|
2001-06-19 23:20:59 +00:00
|
|
|
|
2002-04-19 16:50:03 +00:00
|
|
|
dst_ptr = ggi_conf.buffer[ggi_conf.currframe]->write;
|
|
|
|
dst_stride = ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.stride;
|
|
|
|
dst_bpp = (ggi_conf.buffer[ggi_conf.currframe]->buffer.plb.pixelformat->size+7)/8;
|
2002-04-15 18:04:18 +00:00
|
|
|
|
2002-04-19 16:50:03 +00:00
|
|
|
#ifdef GGI_FLIP
|
|
|
|
if (ggi_conf.voflags & VOFLAG_FLIPPING)
|
2001-06-19 23:20:59 +00:00
|
|
|
{
|
2002-04-19 16:50:03 +00:00
|
|
|
dst_stride = -dst_stride;
|
|
|
|
dst_ptr -= dst_stride*(ggi_conf.srcheight-1);
|
2001-06-19 23:20:59 +00:00
|
|
|
}
|
2002-04-15 18:04:18 +00:00
|
|
|
#endif
|
2001-06-15 16:31:19 +00:00
|
|
|
|
2002-04-19 16:50:03 +00:00
|
|
|
/* memcpy_pic(dst, src, bytes per line, height, dst_stride, src_stride) */
|
|
|
|
|
|
|
|
memcpy_pic(dst_ptr, src[0], ggi_conf.srcwidth*dst_bpp, ggi_conf.srcheight,
|
|
|
|
dst_stride,
|
|
|
|
ggi_conf.srcwidth*ggi_conf.srcbpp);
|
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
ggiResourceRelease(ggi_conf.buffer[ggi_conf.currframe]->resource);
|
2002-04-15 18:04:18 +00:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint32_t draw_frame(uint8_t *src[])
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
unsigned char *spt;
|
|
|
|
ggi_color col;
|
|
|
|
|
|
|
|
spt = src[0];
|
|
|
|
|
|
|
|
for (y = 0; y < ggi_conf.srcheight; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < ggi_conf.srcwidth; x++)
|
|
|
|
{
|
|
|
|
/* add support for RGB */
|
|
|
|
switch(ggi_conf.srcformat)
|
|
|
|
{
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
case IMGFMT_BGR32:
|
|
|
|
col.r = *spt++ << 8;
|
|
|
|
col.g = *spt++ << 8;
|
|
|
|
col.b = *spt++ << 8;
|
|
|
|
if (ggi_conf.srcformat == IMGFMT_BGR32)
|
|
|
|
spt++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "[ggi] unsupported input format\n");
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// printf("pixel: x:%d, y:%d, r:%d, g:%d, b:%d\n",
|
|
|
|
// x, y, col.r, col.b, col.g);
|
|
|
|
ggiPutPixel(ggi_conf.vis, x, y, ggiMapColor(ggi_conf.vis, &col));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ggiFlush(ggi_conf.vis);
|
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
|
|
|
|
unsigned char *srca, int stride)
|
|
|
|
{
|
2002-02-24 16:28:44 +00:00
|
|
|
switch(vo_dbpp)
|
2001-06-17 12:24:52 +00:00
|
|
|
{
|
2002-02-24 02:21:14 +00:00
|
|
|
case 32:
|
|
|
|
vo_draw_alpha_rgb32(w, h, src, srca, stride,
|
|
|
|
ggi_conf.buffer[ggi_conf.currframe]->write+4*(ggi_conf.dstwidth*y0+x0), 4*ggi_conf.dstwidth);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
vo_draw_alpha_rgb24(w, h, src, srca, stride,
|
|
|
|
ggi_conf.buffer[ggi_conf.currframe]->write+3*(ggi_conf.dstwidth*y0+x0), 3*ggi_conf.dstwidth);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
vo_draw_alpha_rgb16(w, h, src, srca, stride,
|
|
|
|
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.dstwidth*y0+x0), 2*ggi_conf.dstwidth);
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
vo_draw_alpha_rgb15(w, h, src, srca, stride,
|
|
|
|
ggi_conf.buffer[ggi_conf.currframe]->write+2*(ggi_conf.dstwidth*y0+x0), 2*ggi_conf.dstwidth);
|
|
|
|
break;
|
2001-06-17 12:24:52 +00:00
|
|
|
}
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
static void draw_osd_directbuffer(void)
|
2001-06-15 16:31:19 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
vo_draw_text(ggi_conf.srcwidth, ggi_conf.srcheight, draw_alpha);
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
static void draw_osd(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void flip_page_directbuffer(void)
|
2001-08-13 11:08:18 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
ggiSetDisplayFrame(ggi_conf.vis, ggi_conf.currframe);
|
2002-04-15 18:04:18 +00:00
|
|
|
mp_dbg(MSGT_VO, MSGL_DBG2, "[ggi] flipping, current write frame: %d, display frame: %d\n",
|
2002-02-23 23:31:08 +00:00
|
|
|
ggiGetWriteFrame(ggi_conf.vis), ggiGetDisplayFrame(ggi_conf.vis));
|
|
|
|
|
|
|
|
ggi_conf.currframe = (ggi_conf.currframe+1) % ggi_conf.frames;
|
2002-02-24 16:28:44 +00:00
|
|
|
|
|
|
|
if (ggi_conf.async)
|
|
|
|
ggiFlush(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
2002-04-15 18:04:18 +00:00
|
|
|
static void flip_page(void)
|
|
|
|
{
|
|
|
|
ggiFlush(ggi_conf.vis);
|
|
|
|
}
|
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h,
|
|
|
|
int x, int y)
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t query_format(uint32_t format)
|
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
ggi_mode mode;
|
|
|
|
|
|
|
|
if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.vis)
|
2001-06-17 12:24:52 +00:00
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
if (ggiGetMode(ggi_conf.vis, &mode) == 0)
|
|
|
|
{
|
|
|
|
vo_depthonscreen = GT_DEPTH(mode.graphtype);
|
|
|
|
vo_dbpp = GT_SIZE(mode.graphtype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((IMGFMT_IS_BGR(format) && (IMGFMT_BGR_DEPTH(format) == vo_dbpp)) ||
|
|
|
|
(IMGFMT_IS_RGB(format) && (IMGFMT_RGB_DEPTH(format) == vo_dbpp)))
|
|
|
|
{
|
|
|
|
if (ggi_conf.directbuffer)
|
2002-04-19 16:50:03 +00:00
|
|
|
#ifdef GGI_FLIP
|
2002-05-27 17:44:32 +00:00
|
|
|
return(VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|
|
|
|
|
VFCAP_OSD|VFCAP_FLIP);
|
2002-04-19 16:50:03 +00:00
|
|
|
#else
|
2002-05-27 17:44:32 +00:00
|
|
|
return(VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD);
|
2002-04-19 16:50:03 +00:00
|
|
|
#endif
|
2002-04-15 18:04:18 +00:00
|
|
|
else
|
2002-05-27 17:44:32 +00:00
|
|
|
return(VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW);
|
2002-04-15 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IMGFMT_IS_BGR(format) || IMGFMT_IS_RGB(format))
|
|
|
|
{
|
|
|
|
if (ggi_conf.directbuffer)
|
2002-04-19 16:50:03 +00:00
|
|
|
#ifdef GGI_FLIP
|
2002-05-27 17:44:32 +00:00
|
|
|
return(VFCAP_CSP_SUPPORTED|VFCAP_OSD|VFCAP_FLIP);
|
2002-04-19 16:50:03 +00:00
|
|
|
#else
|
2002-05-27 17:44:32 +00:00
|
|
|
return(VFCAP_CSP_SUPPORTED|VFCAP_OSD);
|
2002-04-19 16:50:03 +00:00
|
|
|
#endif
|
2002-04-15 18:04:18 +00:00
|
|
|
else
|
2002-05-27 17:44:32 +00:00
|
|
|
return(VFCAP_CSP_SUPPORTED);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
2002-04-15 18:04:18 +00:00
|
|
|
|
2001-06-17 12:24:52 +00:00
|
|
|
return(0);
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
static uint32_t preinit(const char *arg)
|
|
|
|
{
|
|
|
|
if (ggiInit() != 0)
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] unable to initialize GGI\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2002-02-24 16:28:44 +00:00
|
|
|
if ((char *)arg)
|
|
|
|
ggi_conf.driver = strdup(arg);
|
2002-02-23 23:31:08 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
static void uninit(void)
|
|
|
|
{
|
2002-02-24 16:28:44 +00:00
|
|
|
if (ggi_conf.driver)
|
|
|
|
free(ggi_conf.driver);
|
2001-06-19 23:20:59 +00:00
|
|
|
ggiClose(ggi_conf.vis);
|
2001-06-15 16:31:19 +00:00
|
|
|
ggiExit();
|
|
|
|
}
|
|
|
|
|
2002-02-24 16:28:44 +00:00
|
|
|
#ifdef GGI_GAMMA
|
|
|
|
/* GAMMA handling */
|
|
|
|
static int ggi_get_video_eq(vidix_video_eq_t *info)
|
|
|
|
{
|
|
|
|
memset(info, 0, sizeof(vidix_video_eq_t));
|
|
|
|
}
|
2002-04-15 18:04:18 +00:00
|
|
|
#endif
|
2002-02-24 16:28:44 +00:00
|
|
|
|
|
|
|
static void query_vaa(vo_vaa_t *vaa)
|
|
|
|
{
|
|
|
|
memset(vaa, 0, sizeof(vo_vaa_t));
|
2002-04-15 18:04:18 +00:00
|
|
|
#ifdef GGI_GAMMA
|
2002-02-24 16:28:44 +00:00
|
|
|
vaa->get_video_eq = ggi_get_video_eq;
|
|
|
|
vaa->set_video_eq = ggi_set_video_eq;
|
|
|
|
#endif
|
2002-04-15 18:04:18 +00:00
|
|
|
}
|
2002-02-24 16:28:44 +00:00
|
|
|
|
2002-02-23 23:31:08 +00:00
|
|
|
static uint32_t control(uint32_t request, void *data, ...)
|
|
|
|
{
|
2002-04-15 18:04:18 +00:00
|
|
|
switch(request)
|
|
|
|
{
|
|
|
|
case VOCTRL_QUERY_VAA:
|
|
|
|
query_vaa((vo_vaa_t*)data);
|
|
|
|
return VO_TRUE;
|
|
|
|
case VOCTRL_QUERY_FORMAT:
|
|
|
|
return query_format(*((uint32_t*)data));
|
|
|
|
case VOCTRL_GET_IMAGE:
|
|
|
|
return get_image(data);
|
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
2002-02-23 23:31:08 +00:00
|
|
|
}
|
|
|
|
|
2002-02-24 16:28:44 +00:00
|
|
|
/* EVENT handling */
|
2001-06-17 14:33:06 +00:00
|
|
|
#include "../linux/keycodes.h"
|
2001-06-19 23:20:59 +00:00
|
|
|
extern void mplayer_put_key(int code);
|
|
|
|
|
2001-06-15 16:31:19 +00:00
|
|
|
static void check_events(void)
|
|
|
|
{
|
2001-06-17 14:33:06 +00:00
|
|
|
struct timeval tv = {0, 0};
|
|
|
|
ggi_event event;
|
|
|
|
ggi_event_mask mask;
|
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if ((mask = ggiEventPoll(ggi_conf.vis, emAll, &tv)))
|
|
|
|
if (ggiEventRead(ggi_conf.vis, &event, emAll) != 0)
|
2001-06-17 14:33:06 +00:00
|
|
|
{
|
2002-02-23 23:31:08 +00:00
|
|
|
mp_dbg(MSGT_VO, MSGL_DBG3, "type: %4x, origin: %4x, sym: %4x, label: %4x, button=%4x\n",
|
2001-06-19 23:20:59 +00:00
|
|
|
event.any.origin, event.any.type, event.key.sym, event.key.label, event.key.button);
|
2001-06-17 14:33:06 +00:00
|
|
|
|
2001-06-19 23:20:59 +00:00
|
|
|
if (event.key.type == evKeyPress)
|
2001-06-17 14:33:06 +00:00
|
|
|
{
|
2001-06-19 23:20:59 +00:00
|
|
|
switch(event.key.sym)
|
2001-06-17 14:33:06 +00:00
|
|
|
{
|
|
|
|
case GIIK_PAsterisk: /* PStar */
|
|
|
|
case GIIUC_Asterisk:
|
|
|
|
mplayer_put_key('*');
|
|
|
|
break;
|
|
|
|
case GIIK_PSlash:
|
|
|
|
case GIIUC_Slash:
|
|
|
|
mplayer_put_key('/');
|
|
|
|
break;
|
|
|
|
case GIIK_PPlus:
|
|
|
|
case GIIUC_Plus:
|
|
|
|
mplayer_put_key('+');
|
|
|
|
break;
|
|
|
|
case GIIK_PMinus:
|
|
|
|
case GIIUC_Minus:
|
|
|
|
mplayer_put_key('-');
|
|
|
|
break;
|
|
|
|
case GIIUC_o:
|
|
|
|
case GIIUC_O:
|
|
|
|
mplayer_put_key('o');
|
|
|
|
break;
|
|
|
|
case GIIUC_g:
|
|
|
|
case GIIUC_G:
|
|
|
|
mplayer_put_key('g');
|
|
|
|
break;
|
|
|
|
case GIIUC_z:
|
|
|
|
case GIIUC_Z:
|
|
|
|
mplayer_put_key('z');
|
|
|
|
break;
|
|
|
|
case GIIUC_x:
|
|
|
|
case GIIUC_X:
|
|
|
|
mplayer_put_key('x');
|
|
|
|
break;
|
|
|
|
case GIIUC_m:
|
|
|
|
case GIIUC_M:
|
|
|
|
mplayer_put_key('m');
|
|
|
|
break;
|
|
|
|
case GIIUC_d:
|
|
|
|
case GIIUC_D:
|
|
|
|
mplayer_put_key('d');
|
|
|
|
break;
|
|
|
|
case GIIUC_q:
|
|
|
|
case GIIUC_Q:
|
|
|
|
mplayer_put_key('q');
|
|
|
|
break;
|
2002-02-23 23:31:08 +00:00
|
|
|
case GIIUC_h:
|
|
|
|
case GIIUC_H:
|
|
|
|
mplayer_put_key('h');
|
|
|
|
break;
|
|
|
|
case GIIUC_l:
|
|
|
|
case GIIUC_L:
|
|
|
|
mplayer_put_key('l');
|
|
|
|
break;
|
2001-06-17 14:33:06 +00:00
|
|
|
case GIIUC_Space:
|
|
|
|
case GIIUC_p:
|
|
|
|
case GIIUC_P:
|
|
|
|
mplayer_put_key('p');
|
|
|
|
break;
|
|
|
|
case GIIK_Up:
|
|
|
|
mplayer_put_key(KEY_UP);
|
|
|
|
break;
|
|
|
|
case GIIK_Down:
|
|
|
|
mplayer_put_key(KEY_DOWN);
|
|
|
|
break;
|
|
|
|
case GIIK_Left:
|
|
|
|
mplayer_put_key(KEY_LEFT);
|
|
|
|
break;
|
|
|
|
case GIIK_Right:
|
|
|
|
mplayer_put_key(KEY_RIGHT);
|
|
|
|
break;
|
|
|
|
case GIIK_PageUp:
|
|
|
|
mplayer_put_key(KEY_PAGE_UP);
|
|
|
|
break;
|
|
|
|
case GIIK_PageDown:
|
|
|
|
mplayer_put_key(KEY_PAGE_DOWN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
2001-06-15 16:31:19 +00:00
|
|
|
}
|