2002-01-05 10:13:25 +00:00
|
|
|
/*
|
2007-04-22 14:05:41 +00:00
|
|
|
* VIDIX - VIDeo Interface for *niX.
|
|
|
|
* Copyright (C) 2002 Nick Kurshev
|
|
|
|
* Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer 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.
|
|
|
|
*
|
|
|
|
* MPlayer 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 MPlayer; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* This interface is introduced as universal one to MPEG decoder,
|
|
|
|
* Back End Scaler (BES) and YUV2RGB hw accelerators.
|
|
|
|
*
|
2002-01-05 10:13:25 +00:00
|
|
|
* In the future it may be expanded up to capturing and audio things.
|
|
|
|
* Main goal of this this interface imlpementation is providing DGA
|
|
|
|
* everywhere where it's possible (unlike X11 and other).
|
2007-04-22 14:05:41 +00:00
|
|
|
*
|
2002-01-05 10:13:25 +00:00
|
|
|
* This interface is based on v4l2, fbvid.h, mga_vid.h projects
|
|
|
|
* and personally my ideas.
|
2007-04-22 14:05:41 +00:00
|
|
|
*
|
|
|
|
* NOTE: This interface is introduces as driver interface.
|
|
|
|
*/
|
|
|
|
|
2002-01-05 10:13:25 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-03-14 16:46:13 +00:00
|
|
|
#include "config.h"
|
2002-01-05 10:13:25 +00:00
|
|
|
#include "vidixlib.h"
|
2007-04-01 11:06:06 +00:00
|
|
|
#include "drivers.h"
|
2007-04-06 20:37:43 +00:00
|
|
|
#include "libavutil/common.h"
|
|
|
|
#include "mpbswap.h"
|
2002-01-05 10:13:25 +00:00
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
extern unsigned int vdlGetVersion( void )
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
|
|
|
return VIDIX_VERSION;
|
|
|
|
}
|
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
VDL_HANDLE vdlOpen(const char *path,const char *name,unsigned cap,int verbose)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
VDXContext *ctx;
|
2002-01-05 10:13:25 +00:00
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
if (!(ctx = malloc (sizeof (VDXContext))))
|
|
|
|
return NULL;
|
|
|
|
memset (ctx, 0, sizeof (VDXContext));
|
2002-04-27 22:42:27 +00:00
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
/* register all drivers */
|
|
|
|
vidix_register_all_drivers ();
|
|
|
|
|
|
|
|
if (!vidix_find_driver (ctx, name, cap, verbose))
|
2002-01-06 16:00:12 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
free (ctx);
|
|
|
|
return NULL;
|
2002-01-06 16:00:12 +00:00
|
|
|
}
|
2002-01-05 10:13:25 +00:00
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
if (verbose)
|
|
|
|
printf ("vidixlib: will use %s driver\n", ctx->drv->name);
|
|
|
|
|
|
|
|
if (!ctx->drv || !ctx->drv->init)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
if (verbose)
|
|
|
|
printf ("vidixlib: Can't init driver\n");
|
|
|
|
free (ctx);
|
|
|
|
return NULL;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
2007-04-01 11:06:06 +00:00
|
|
|
|
|
|
|
if (verbose)
|
|
|
|
printf ("vidixlib: Attempt to initialize driver at: %p\n",
|
|
|
|
ctx->drv->init);
|
2002-01-05 10:13:25 +00:00
|
|
|
|
2007-04-01 11:06:06 +00:00
|
|
|
if (ctx->drv->init () !=0)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
if (verbose)
|
|
|
|
printf ("vidixlib: Can't init driver\n");
|
|
|
|
free (ctx);
|
|
|
|
return NULL;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
2007-04-01 11:06:06 +00:00
|
|
|
|
|
|
|
if (verbose)
|
|
|
|
printf("vidixlib: '%s'successfully loaded\n", ctx->drv->name);
|
|
|
|
|
|
|
|
return ctx;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
void vdlClose(VDL_HANDLE ctx)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
if (ctx->drv->destroy)
|
|
|
|
ctx->drv->destroy ();
|
|
|
|
|
|
|
|
memset (ctx, 0, sizeof (VDXContext)); /* <- it's not stupid */
|
|
|
|
free (ctx);
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlGetCapability(VDL_HANDLE ctx, vidix_capability_t *cap)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
return ctx->drv->get_caps (cap);
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2002-02-05 18:51:37 +00:00
|
|
|
#define MPLAYER_IMGFMT_RGB (('R'<<24)|('G'<<16)|('B'<<8))
|
|
|
|
#define MPLAYER_IMGFMT_BGR (('B'<<24)|('G'<<16)|('R'<<8))
|
|
|
|
#define MPLAYER_IMGFMT_RGB_MASK 0xFFFFFF00
|
|
|
|
|
2002-02-06 16:41:06 +00:00
|
|
|
static uint32_t normalize_fourcc(uint32_t fourcc)
|
2002-02-05 18:51:37 +00:00
|
|
|
{
|
|
|
|
if((fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_RGB|0) ||
|
|
|
|
(fourcc & MPLAYER_IMGFMT_RGB_MASK) == (MPLAYER_IMGFMT_BGR|0))
|
|
|
|
return bswap_32(fourcc);
|
|
|
|
else return fourcc;
|
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlQueryFourcc(VDL_HANDLE ctx,vidix_fourcc_t *f)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2002-02-06 16:41:06 +00:00
|
|
|
f->fourcc = normalize_fourcc(f->fourcc);
|
2007-04-01 11:06:06 +00:00
|
|
|
return ctx->drv->query_fourcc (f);
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlConfigPlayback(VDL_HANDLE ctx,vidix_playback_t *p)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2002-02-06 16:41:06 +00:00
|
|
|
p->fourcc = normalize_fourcc(p->fourcc);
|
2007-04-01 11:06:06 +00:00
|
|
|
return ctx->drv->config_playback (p);
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackOn(VDL_HANDLE ctx)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
return ctx->drv->playback_on ();
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackOff(VDL_HANDLE ctx)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 11:06:06 +00:00
|
|
|
return ctx->drv->playback_off ();
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackFrameSelect(VDL_HANDLE ctx, unsigned frame_idx )
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->frame_sel ? ctx->drv->frame_sel (frame_idx) : ENOSYS;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackGetEq(VDL_HANDLE ctx, vidix_video_eq_t * e)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->get_eq ? ctx->drv->get_eq (e) : ENOSYS;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackSetEq(VDL_HANDLE ctx, const vidix_video_eq_t * e)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->set_eq ? ctx->drv->set_eq (e) : ENOSYS;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackCopyFrame(VDL_HANDLE ctx, const vidix_dma_t * f)
|
2002-01-05 10:13:25 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->copy_frame ? ctx->drv->copy_frame (f) : ENOSYS;
|
2002-01-05 10:13:25 +00:00
|
|
|
}
|
2002-01-09 18:58:25 +00:00
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlGetGrKeys(VDL_HANDLE ctx, vidix_grkey_t * k)
|
2002-01-09 18:58:25 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->get_gkey ? ctx->drv->get_gkey (k) : ENOSYS;
|
2002-01-09 18:58:25 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlSetGrKeys(VDL_HANDLE ctx, const vidix_grkey_t * k)
|
2002-01-09 18:58:25 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->set_gkey ? ctx->drv->set_gkey (k) : ENOSYS;
|
2002-01-09 18:58:25 +00:00
|
|
|
}
|
2002-01-16 08:33:17 +00:00
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackGetDeint(VDL_HANDLE ctx, vidix_deinterlace_t * d)
|
2002-01-16 08:33:17 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->get_deint ? ctx->drv->get_deint (d) : ENOSYS;
|
2002-01-16 08:33:17 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlPlaybackSetDeint(VDL_HANDLE ctx, const vidix_deinterlace_t * d)
|
2002-01-16 08:33:17 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->set_deint ? ctx->drv->set_deint (d) : ENOSYS;
|
2002-01-16 08:33:17 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlQueryNumOemEffects(VDL_HANDLE ctx, unsigned * number )
|
2002-01-16 08:33:17 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->get_num_fx ? ctx->drv->get_num_fx (number) : ENOSYS;
|
2002-01-16 08:33:17 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlGetOemEffect(VDL_HANDLE ctx, vidix_oem_fx_t * f)
|
2002-01-16 08:33:17 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->get_fx ? ctx->drv->get_fx (f) : ENOSYS;
|
2002-01-16 08:33:17 +00:00
|
|
|
}
|
|
|
|
|
2007-04-01 12:39:06 +00:00
|
|
|
int vdlSetOemEffect(VDL_HANDLE ctx, const vidix_oem_fx_t * f)
|
2002-01-16 08:33:17 +00:00
|
|
|
{
|
2007-04-01 21:58:45 +00:00
|
|
|
return ctx->drv->set_fx ? ctx->drv->set_fx (f) : ENOSYS;
|
2002-01-16 08:33:17 +00:00
|
|
|
}
|