/*
MPlayer video driver for DirectFramebuffer device
(C) 2002
Written by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// directfb includes
#include <directfb.h>
// other things
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __linux__
#include <sys/kd.h>
#else
#include <linux/kd.h>
#endif
#include "config.h"
#include "video_out.h"
#include "video_out_internal.h"
#include "fastmemcpy.h"
#include "sub.h"
#include "mp_msg.h"
#include "aspect.h"
#ifndef min
#define min(x,y) (((x)<(y))?(x):(y))
#endif
#if DIRECTFBVERSION > 917
// triple buffering
#define TRIPLE 1
#endif
static vo_info_t info = {
"Direct Framebuffer Device",
"directfb",
"Jiri Svoboda Jiri.Svoboda@seznam.cz",
"v 2.0 (for DirectFB version >=0.9.13)"
};
LIBVO_EXTERN(directfb)
extern int verbose;
/******************************
* vo_directfb globals *
******************************/
#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
/*
* filled by preinit
*/
// main DirectFB handle
static IDirectFB *dfb = NULL;
// keyboard handle
static IDirectFBInputDevice *keyboard = NULL;
// A buffer for input events.
static IDirectFBEventBuffer *buffer = NULL;
/*
* filled during config
*/
// handle of used layer
static IDirectFBDisplayLayer *layer = NULL;
// surface of used layer
static IDirectFBSurface *primary = NULL;
static int primarylocked = 0;
// handle of temporary surface (if used)
static IDirectFBSurface *frame = NULL;
static int framelocked = 0;
// flipping mode flag (layer/surface)
static int flipping = 0;
// tvnorm
static int tvnorm = -1;
// scaling flag
static int stretch = 0;
// pictrure position
static int xoffset=0,yoffset=0;
// picture size
static int out_width=0,out_height=0;
// frame/primary size
static int width=0,height=0;
// frame primary format
DFBSurfacePixelFormat pixel_format;
/*
static void (*draw_alpha_p)(int w, int h, unsigned char *src,
unsigned char *srca, int stride, unsigned char *dst,
int dstride);
*/
/******************************
* cmd line parameteres *
******************************/
/* command line/config file options */
char *dfb_params;
static int layer_id = -1;
static int buffer_mode = 1;
static int use_input = 1;
static int field_parity = -1;
/******************************
* implementation *
******************************/
void unlock() {
if (frame && framelocked) frame->Unlock(frame);
if (primary && primarylocked) primary->Unlock(primary);
}
static uint32_t preinit(const char *arg)
{
DFBResult ret;
mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
if (dfb) return 0; // we are already inited!
buffer_mode = 1 + vo_doublebuffering; // honor -double switch
// config stuff - borrowed from dfbmga (to be as compatible as it could be :-)
if (vo_subdevice) {
int show_help = 0;
int opt_no = 0;
while (*vo_subdevice != '\0') {
if (!strncmp(vo_subdevice, "input", 5)) {
use_input = !opt_no;
vo_subdevice += 5;
opt_no = 0;
} else if (!strncmp(vo_subdevice, "buffermode=", 11)) {
if (opt_no) {
show_help = 1;
break;
}
vo_subdevice += 11;
if (!strncmp(vo_subdevice, "single", 6)) {
buffer_mode = 1;
vo_subdevice += 6;
} else if (!strncmp(vo_subdevice, "double", 6)) {
buffer_mode = 2;
vo_subdevice += 6;
} else if (!strncmp(vo_subdevice, "triple", 6)) {
buffer_mode = 3;
vo_subdevice += 6;
} else {
show_help = 1;
break;
}
opt_no = 0;
} else if (!strncmp(vo_subdevice, "fieldparity=", 12)) {
if (opt_no) {
show_help = 1;
break;
}
vo_subdevice += 12;
if (!strncmp(vo_subdevice, "top", 3)) {
field_parity = 0;
vo_subdevice += 3;
} else if (!strncmp(vo_subdevice, "bottom", 6)) {
field_parity = 1;
vo_subdevice += 6;
} else {
show_help = 1;
break;
}
|