Add explanatory comments to the #endif part of multiple inclusion guards.
[mplayer/greg.git] / libvo / vo_directfb2.c
blob4dad3a277e2e74e74b077220ed6f0b0059de4a44
1 /*
2 MPlayer video driver for DirectFramebuffer device
4 (C) 2002
6 Written by Jiri Svoboda <Jiri.Svoboda@seznam.cz>
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the
20 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301 USA.
24 // directfb includes
26 #include <directfb.h>
28 #define DFB_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
30 // other things
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
36 #ifdef __linux__
37 #include <sys/kd.h>
38 #else
39 #include <linux/kd.h>
40 #endif
42 #include "config.h"
43 #include "video_out.h"
44 #include "video_out_internal.h"
45 #include "fastmemcpy.h"
46 #include "sub.h"
47 #include "mp_msg.h"
48 #include "aspect.h"
49 #include "subopt-helper.h"
50 #include "mp_fifo.h"
52 #ifndef min
53 #define min(x,y) (((x)<(y))?(x):(y))
54 #endif
56 #if DIRECTFBVERSION > DFB_VERSION(0,9,17)
57 // triple buffering
58 #define TRIPLE 1
59 #endif
61 static const vo_info_t info = {
62 "Direct Framebuffer Device",
63 "directfb",
64 "Jiri Svoboda Jiri.Svoboda@seznam.cz",
65 "v 2.0 (for DirectFB version >=0.9.13)"
68 const LIBVO_EXTERN(directfb)
70 /******************************
71 * vo_directfb globals *
72 ******************************/
74 #define DFBCHECK(x...) \
75 { \
76 DFBResult err = x; \
78 if (err != DFB_OK) \
79 { \
80 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
81 DirectFBErrorFatal( #x, err ); \
82 } \
86 * filled by preinit
89 // main DirectFB handle
90 static IDirectFB *dfb = NULL;
91 // keyboard handle
92 static IDirectFBInputDevice *keyboard = NULL;
93 // A buffer for input events.
94 static IDirectFBEventBuffer *buffer = NULL;
97 * filled during config
100 // handle of used layer
101 static IDirectFBDisplayLayer *layer = NULL;
102 // surface of used layer
103 static IDirectFBSurface *primary = NULL;
104 static int primarylocked = 0;
105 // handle of temporary surface (if used)
106 static IDirectFBSurface *frame = NULL;
107 static int framelocked = 0;
108 // flipping mode flag (layer/surface)
109 static int flipping = 0;
110 // scaling flag
111 static int stretch = 0;
112 // picture position
113 static int xoffset=0,yoffset=0;
114 // picture size
115 static int out_width=0,out_height=0;
116 // frame/primary size
117 static int width=0,height=0;
118 // frame primary format
119 DFBSurfacePixelFormat pixel_format;
121 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
122 unsigned char *srca, int stride, unsigned char *dst,
123 int dstride);
126 /******************************
127 * cmd line parameteres *
128 ******************************/
130 /* command line/config file options */
131 static int layer_id = -1;
132 static int buffer_mode = 1;
133 static int use_input = 1;
134 static int field_parity = -1;
136 /******************************
137 * implementation *
138 ******************************/
140 void unlock(void) {
141 if (frame && framelocked) frame->Unlock(frame);
142 if (primary && primarylocked) primary->Unlock(primary);
145 static int get_parity(strarg_t *arg) {
146 if (strargcmp(arg, "top") == 0)
147 return 0;
148 if (strargcmp(arg, "bottom") == 0)
149 return 1;
150 return -1;
153 static int check_parity(void *arg) {
154 return get_parity(arg) != -1;
157 static int get_mode(strarg_t *arg) {
158 if (strargcmp(arg, "single") == 0)
159 return 1;
160 if (strargcmp(arg, "double") == 0)
161 return 2;
162 if (strargcmp(arg, "triple") == 0)
163 return 3;
164 return 0;
167 static int check_mode(void *arg) {
168 return get_mode(arg) != 0;
171 static int preinit(const char *arg)
173 DFBResult ret;
174 strarg_t mode_str = {0, NULL};
175 strarg_t par_str = {0, NULL};
176 strarg_t dfb_params = {0, NULL};
177 opt_t subopts[] = {
178 {"input", OPT_ARG_BOOL, &use_input, NULL},
179 {"buffermode", OPT_ARG_STR, &mode_str, check_mode},
180 {"fieldparity", OPT_ARG_STR, &par_str, check_parity},
181 {"layer", OPT_ARG_INT, &layer_id, NULL},
182 {"dfbopts", OPT_ARG_STR, &dfb_params, NULL},
183 {NULL}
186 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
188 if (dfb) return 0; // we are already initialized!
190 // set defaults
191 buffer_mode = 1 + vo_doublebuffering; // honor -double switch
192 layer_id = -1;
193 use_input = 1;
194 field_parity = -1;
195 if (subopt_parse(arg, subopts) != 0) {
196 mp_msg( MSGT_VO, MSGL_ERR,
197 "\n-vo directfb command line help:\n"
198 "Example: mplayer -vo directfb:layer=1:buffermode=single\n"
199 "\nOptions (use 'no' prefix to disable):\n"
200 " input Use DirectFB for keyboard input\n"
201 "\nOther options:\n"
202 " layer=n\n"
203 " n=0..xx Use layer with id n for output (0=primary)\n"
204 " buffermode=(single|double|triple)\n"
205 " single Use single buffering\n"
206 " double Use double buffering\n"
207 " triple Use triple buffering\n"
208 " fieldparity=(top|bottom)\n"
209 " top Top field first\n"
210 " bottom Bottom field first\n"
211 " dfbopts=<str>\n"
212 " Specify a parameter list for DirectFB\n"
213 "\n" );
214 return -1;
216 if (mode_str.len)
217 buffer_mode = get_mode(&mode_str);
218 if (par_str.len)
219 field_parity = get_parity(&par_str);
222 if (dfb_params.len > 0)
224 int argc = 2;
225 char arg0[10] = "mplayer";
226 char *arg1 = malloc(dfb_params.len + 7);
227 char* argv[3];
228 char ** a;
230 a = &argv[0];
232 strcpy(arg1, "--dfb:");
233 strncat(arg1, dfb_params.str, dfb_params.len);
235 argv[0]=arg0;
236 argv[1]=arg1;
237 argv[2]=NULL;
239 DFBCHECK (DirectFBInit (&argc,&a));
241 free(arg1);
242 } else {
244 DFBCHECK (DirectFBInit (NULL,NULL));
247 if (((directfb_major_version <= 0) &&
248 (directfb_minor_version <= 9) &&
249 (directfb_micro_version < 13)))
251 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Unsupported DirectFB version\n");
252 return 1;
256 * (set options)
259 // uncomment this if you do not wish to create a new VT for DirectFB
260 // DFBCHECK (DirectFBSetOption ("no-vt-switch",""));
262 // uncomment this if you want to allow VT switching
263 // DFBCHECK (DirectFBSetOption ("vt-switching",""));
265 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9)
266 DFBCHECK (DirectFBSetOption ("no-cursor",""));
268 // bg color fix
269 DFBCHECK (DirectFBSetOption ("bg-color","00000000"));
272 * (Initialize)
275 DFBCHECK (DirectFBCreate (&dfb));
277 #if DIRECTFBVERSION < DFB_VERSION(0,9,17)
278 if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) {
279 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot switch to fullscreen mode");
281 #endif
284 * (Get keyboard)
287 if (use_input) {
288 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);
289 if (ret==DFB_OK) {
290 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Keyboard init OK\n");
291 } else {
292 keyboard = NULL;
293 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Keyboard init FAILED\n");
299 * Create an input buffer for the keyboard.
301 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer));
303 // just to start clean ...
304 if (buffer) buffer->Reset(buffer);
306 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit OK\n");
308 return 0;
312 DFBSurfacePixelFormat convformat(uint32_t format)
314 // add more formats !!!
315 switch (format) {
316 case IMGFMT_RGB32: return DSPF_RGB32; break;
317 case IMGFMT_BGR32: return DSPF_RGB32; break;
318 case IMGFMT_RGB24: return DSPF_RGB24; break;
319 case IMGFMT_BGR24: return DSPF_RGB24; break;
320 case IMGFMT_RGB16: return DSPF_RGB16; break;
321 case IMGFMT_BGR16: return DSPF_RGB16; break;
322 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
323 case IMGFMT_RGB15: return DSPF_ARGB1555; break;
324 case IMGFMT_BGR15: return DSPF_ARGB1555; break;
325 #else
326 case IMGFMT_RGB15: return DSPF_RGB15; break;
327 case IMGFMT_BGR15: return DSPF_RGB15; break;
328 #endif
329 case IMGFMT_YUY2: return DSPF_YUY2; break;
330 case IMGFMT_UYVY: return DSPF_UYVY; break;
331 case IMGFMT_YV12: return DSPF_YV12; break;
332 case IMGFMT_I420: return DSPF_I420; break;
333 // case IMGFMT_IYUV: return DSPF_IYUV; break;
334 case IMGFMT_RGB8: return DSPF_RGB332; break;
335 case IMGFMT_BGR8: return DSPF_RGB332; break;
337 default: return 0;
339 return 0;
342 typedef struct enum1_s {
343 uint32_t format;
344 int scale;
345 int result;
346 unsigned int id;
347 unsigned int width;
348 unsigned int height;
349 int setsize;
350 } enum1_t;
352 DFBEnumerationResult test_format_callback( unsigned int id,
353 DFBDisplayLayerDescription desc,
354 void *data)
356 enum1_t *params =(enum1_t *)data;
357 IDirectFBDisplayLayer *layer;
358 DFBResult ret;
360 if ((layer_id == -1 )||(layer_id == id)) {
362 ret = dfb->GetDisplayLayer( dfb, id, &layer);
363 if (ret) {
364 DirectFBError( "dfb->GetDisplayLayer failed", ret );
365 return DFENUM_OK;
366 } else {
367 DFBDisplayLayerConfig dlc;
369 if (params->setsize) {
370 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT;
371 dlc.width = params->width;
372 dlc.height = params->height;
373 layer->SetConfiguration(layer,&dlc);
377 dlc.flags = DLCONF_PIXELFORMAT;
378 dlc.pixelformat = convformat(params->format);
380 layer->SetOpacity(layer,0);
382 ret = layer->TestConfiguration(layer,&dlc,NULL);
384 layer->Release(layer);
386 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
388 if (ret==DFB_OK) {
389 // printf("Test OK\n");
390 if (params->result) {
391 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) {
392 params->scale=1;
393 params->id=id;
394 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
396 } else {
397 params->result=1;
398 params->id=id;
399 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1;
400 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
407 return DFENUM_OK;
410 static int query_format(uint32_t format)
412 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed the in future -> will be handled outside...
413 enum1_t params;
416 if (!convformat(format)) return 0;
417 // temporarily disable YV12
418 // if (format == IMGFMT_YV12) return 0;
419 // if (format == IMGFMT_I420) return 0;
420 if (format == IMGFMT_IYUV) return 0;
422 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Format query: %s\n",vo_format_name(format));
424 params.format=format;
425 params.scale=0;
426 params.result=0;
427 params.setsize=0;
429 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
431 if (params.result) {
432 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN;
433 return ret;
436 return 0;
439 typedef struct videomode_s {
440 int width;
441 int height;
442 int out_width;
443 int out_height;
444 int overx;
445 int overy;
446 int bpp;
447 } videomode_t;
450 DFBEnumerationResult video_modes_callback( unsigned int width,unsigned int height,unsigned int bpp, void *data)
452 videomode_t *params =(videomode_t *)data;
454 int overx=0,overy=0,closer=0,over=0;
455 int we_are_under=0;
457 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Validator entered %i %i %i\n",width,height,bpp);
459 overx=width-params->out_width;
460 overy=height-params->out_height;
462 if (!params->width) {
463 params->width=width;
464 params->height=height;
465 params->overx=overx;
466 params->overy=overy;
467 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Mode added %i %i %i\n",width,height,bpp);
470 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode
471 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res
472 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res
473 if ((closer && (over || we_are_under)) || (we_are_under && over)) {
474 params->width=width;
475 params->height=height;
476 params->overx=overx;
477 params->overy=overy;
478 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Better mode added %i %i %i\n",width,height,bpp);
481 return DFENUM_OK;
484 #define CONFIG_ERROR -1
486 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
487 uint32_t d_height, uint32_t flags, char *title,
488 uint32_t format)
491 * (Locals)
494 // decode flags
496 int fs = flags & VOFLAG_FULLSCREEN;
497 int vm = flags & VOFLAG_MODESWITCHING;
499 DFBSurfaceDescription dsc;
500 DFBResult ret;
501 DFBDisplayLayerConfig dlc;
502 DFBSurfaceCapabilities caps;
504 enum1_t params;
506 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config entered [%ix%i]\n",s_width,s_height);
507 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: With requested format: %s\n",vo_format_name(format));
509 // initial cleanup
510 if (frame) {
511 frame->Release(frame);
512 frame=NULL;
515 if (primary) {
516 primary->Release(primary);
517 primary=NULL;
520 if (layer) {
521 layer->Release(layer);
522 layer=NULL;
526 // vm things
528 if (vm) {
529 videomode_t params;
530 params.out_width=d_width;
531 params.out_height=d_height;
532 params.width=0;
533 params.height=0;
534 switch (format) {
535 case IMGFMT_RGB32:
536 case IMGFMT_BGR32:
537 params.bpp=32;
538 break;
539 case IMGFMT_RGB24:
540 case IMGFMT_BGR24:
541 params.bpp=24;
542 break;
543 case IMGFMT_RGB16:
544 case IMGFMT_BGR16:
545 case IMGFMT_RGB15:
546 case IMGFMT_BGR15:
547 params.bpp=16;
548 break;
549 default: params.bpp=0;
552 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - trying to change videomode\n");
553 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,&params));
554 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp);
555 if (ret) {
556 ret=dfb->SetVideoMode(dfb,params.width,params.height,24);
557 if (ret) {
558 ret=dfb->SetVideoMode(dfb,params.width,params.height,32);
559 if (ret) {
560 ret=dfb->SetVideoMode(dfb,params.width,params.height,16);
561 if (ret) {
562 ret=dfb->SetVideoMode(dfb,params.width,params.height,8);
567 } // vm end
569 // just to be sure clear primary layer
570 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
571 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer);
572 if (ret==DFB_OK) {
573 ret = layer->GetSurface(layer,&primary);
574 if (ret==DFB_OK) {
575 primary->Clear(primary,0,0,0,0xff);
576 ret = primary->Flip(primary,NULL,0);
577 if (ret==DFB_OK) {
578 primary->Clear(primary,0,0,0,0xff);
580 primary->Release(primary);
582 primary=NULL;
583 layer->Release(layer);
585 layer=NULL;
586 #endif
588 // find best layer
590 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - looking for suitable layer\n");
591 params.format=format;
592 params.scale=0;
593 params.result=0;
594 params.width=s_width;
595 params.height=s_height;
596 params.setsize=1;
598 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
600 if (!params.result) {
601 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - no suitable layer found\n");
602 params.id = DLID_PRIMARY;
605 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - layer %i\n",params.id);
607 // setup layer
609 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer));
611 #if DIRECTFBVERSION > DFB_VERSION(0,9,16)
612 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - switching layer to exclusive mode\n");
613 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE);
615 if (DFB_OK != ret) {
616 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot switch layer to exclusive mode. This could cause\nproblems. You may need to select correct pixel format manually!\n");
617 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret);
619 #endif
620 if (params.scale) {
621 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (size)\n");
622 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
623 dlc.width = s_width;
624 dlc.height = s_height;
626 ret = layer->SetConfiguration(layer,&dlc);
628 if (ret) {
629 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (size)\n");
630 DirectFBError("MPlayer - Layer size change.",ret);
634 // look if we need to change the pixel format of the layer
635 // and just to be sure also fetch all layer properties
636 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE;
638 ret = layer->GetConfiguration(layer,&dlc);
640 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT;
642 if (ret) {
643 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - could not get layer properties!\n");
644 } else {
645 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer reports format:%x\n",dlc.pixelformat);
648 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
650 dlc.flags = DLCONF_PIXELFORMAT;
651 dlc.pixelformat = convformat(params.format);
653 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Desired pixelformat: %x\n",dlc.pixelformat);
655 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (format)\n");
656 ret = layer->SetConfiguration(layer,&dlc);
658 if (ret) {
659 unsigned int bpp;
660 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags);
661 DirectFBError("MPlayer - layer pixelformat change",ret);
663 // ugly fbdev workaround - try to switch pixelformat via videomode change
664 switch (dlc.pixelformat) {
665 case DSPF_ARGB:
666 case DSPF_RGB32: bpp=32;break;
667 case DSPF_RGB24: bpp=24;break;
668 case DSPF_RGB16: bpp=16;break;
669 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
670 case DSPF_ARGB1555: bpp=15;break;
671 #else
672 case DSPF_RGB15: bpp=15;break;
673 #endif
674 case DSPF_RGB332 : bpp=8;break;
677 switch (dlc.pixelformat) {
678 case DSPF_ARGB:
679 case DSPF_RGB32:
680 case DSPF_RGB24:
681 case DSPF_RGB16:
682 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
683 case DSPF_ARGB1555:
684 #else
685 case DSPF_RGB15:
686 #endif
687 case DSPF_RGB332:
688 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Trying to recover via videomode change (VM).\n");
689 // get size
690 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
691 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) {
692 // try to set videomode
693 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp);
694 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp);
695 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret);
699 //get current pixel format
700 dlc.flags = DLCONF_PIXELFORMAT;
701 ret = layer->GetConfiguration(layer,&dlc);
702 if (ret) {
703 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret);
704 } else {
705 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer now has pixelformat [%x]\n",dlc.pixelformat);
708 // check if we were succesful
709 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
710 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Recovery failed!.\n");
711 return CONFIG_ERROR;
714 break;
716 default: return CONFIG_ERROR;
722 // flipping of layer
723 // try triple, double... buffering
725 dlc.flags = DLCONF_BUFFERMODE;
726 #ifdef TRIPLE
727 if (buffer_mode > 2) {
728 dlc.buffermode = DLBM_TRIPLE;
729 ret = layer->SetConfiguration( layer, &dlc );
730 } else {
731 ret=!DFB_OK;
734 if (ret!=DFB_OK) {
735 #endif
736 if (buffer_mode > 1) {
737 dlc.buffermode = DLBM_BACKVIDEO;
738 ret = layer->SetConfiguration( layer, &dlc );
739 if (ret!=DFB_OK) {
740 dlc.buffermode = DLBM_BACKSYSTEM;
741 ret = layer->SetConfiguration( layer, &dlc );
744 if (ret == DFB_OK) {
745 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Double buffering is active\n");
747 #ifdef TRIPLE
748 } else {
749 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Triple buffering is active\n");
751 #endif
753 #if DIRECTFBVERSION > DFB_VERSION(0,9,16)
754 if (field_parity != -1) {
755 dlc.flags = DLCONF_OPTIONS;
756 ret = layer->GetConfiguration( layer, &dlc );
757 if (ret==DFB_OK) {
758 dlc.options |= DLOP_FIELD_PARITY;
759 ret = layer->SetConfiguration( layer, &dlc );
760 if (ret==DFB_OK) {
761 layer->SetFieldParity( layer, field_parity );
765 mp_msg( MSGT_VO, MSGL_DBG2, "DirectFB: Requested field parity: ");
766 switch (field_parity) {
767 case -1:
768 mp_msg( MSGT_VO, MSGL_DBG2, "Don't care\n");
769 break;
770 case 0:
771 mp_msg( MSGT_VO, MSGL_DBG2, "Top field first\n");
772 break;
773 case 1:
774 mp_msg( MSGT_VO, MSGL_DBG2, "Bottom field first\n");
775 break;
778 #endif
781 // get layer surface
783 ret = layer->GetSurface(layer,&primary);
785 if (ret) {
786 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - could not get surface\n");
787 return CONFIG_ERROR; // what shall we report on failure?
790 // test surface for flipping
791 DFBCHECK(primary->GetCapabilities(primary,&caps));
792 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
793 primary->Clear(primary,0,0,0,0xff);
794 #endif
795 flipping = 0;
796 if (caps & (DSCAPS_FLIPPING
797 #ifdef TRIPLE
798 | DSCAPS_TRIPLE
799 #endif
800 )) {
801 ret = primary->Flip(primary,NULL,0);
802 if (ret==DFB_OK) {
803 flipping = 1;
804 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
805 primary->Clear(primary,0,0,0,0xff);
806 #ifdef TRIPLE
807 // if we have 3 buffers clean once more
808 if (caps & DSCAPS_TRIPLE) {
809 primary->Flip(primary,NULL,0);
810 primary->Clear(primary,0,0,0,0xff);
811 flipping = 2;
813 #endif
814 #endif
818 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - flipping = %i\n",flipping);
820 // is scale needed ? Aspect ratio and layer pos/size
823 // get surface size
824 DFBCHECK(primary->GetSize(primary,&width,&height));
826 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - surface size = %ix%i\n",width,height);
828 aspect_save_orig(s_width,s_height);
829 aspect_save_prescale(d_width,d_height);
830 if (params.scale) {
831 aspect_save_screenres(10000,10000);
832 aspect(&out_width,&out_height,A_ZOOM);
834 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000));
836 if (ret) mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (position)\n");
838 xoffset = 0;
839 yoffset = 0;
841 } else {
843 aspect_save_screenres(width,height);
845 if(fs) /* -fs */
846 aspect(&out_width,&out_height,A_ZOOM);
847 else
848 aspect(&out_width,&out_height,A_NOZOOM);
851 xoffset = (width - out_width) / 2;
852 yoffset = (height - out_height) / 2;
855 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) {
856 stretch = 0;
857 } else {
858 stretch = 1;
862 // temporary buffer in case of not flipping or scaling
863 if ((!flipping) || stretch) {
865 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat));
867 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH;
869 dsc.width = s_width;
870 dsc.height = s_height;
872 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame));
873 DFBCHECK(frame->GetSize(frame,&width,&height));
874 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Frame is active.\n");
877 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver
878 if (frame) {
879 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format));
880 } else {
881 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format));
884 // finally turn on layer
885 layer->SetOpacity(layer,255);
887 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height);
889 return 0;
892 #include "osdep/keycodes.h"
894 static void check_events(void)
897 if (buffer) {
899 DFBInputEvent event;
901 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events entered\n");
902 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) {
904 if (event.type == DIET_KEYPRESS) {
905 switch (event.key_symbol) {
906 case DIKS_ESCAPE:
907 mplayer_put_key(KEY_ESC);
908 break;
909 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break;
910 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
911 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break;
912 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break;
913 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break;
914 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break;
915 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break;
916 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break;
917 case DIKS_HOME: mplayer_put_key(KEY_HOME);break;
918 case DIKS_END: mplayer_put_key(KEY_END);break;
920 default:mplayer_put_key(event.key_symbol);
924 // empty buffer, because of repeating (keyboard repeat is faster than key handling
925 // and this causes problems during seek)
926 // temporary workaround should be solved in the future
927 buffer->Reset(buffer);
930 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events finished\n");
933 static void flip_page(void)
935 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX;
937 unlock(); // unlock frame & primary
939 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Flip page entered");
941 DFBCHECK (primary->SetBlittingFlags(primary,flags));
943 if (frame) {
944 if (stretch) {
945 DFBRectangle rect;
946 rect.x=xoffset;
947 rect.y=yoffset;
948 rect.w=out_width;
949 rect.h=out_height;
951 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect));
953 } else {
955 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset));
961 #ifdef TRIPLE
962 switch (flipping) {
963 case 1: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAIT));
964 break;
965 case 2: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_ONSYNC));
966 break;
967 default:; // should never be reached
969 #else
970 if (flipping) {
971 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
973 #endif
979 static void uninit(void)
982 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit entered\n");
984 unlock();
987 * (Release)
990 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing buffer\n");
991 if (buffer) buffer->Release (buffer);
992 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing keyboard\n");
993 if (keyboard) keyboard->Release (keyboard);
995 if (frame) {
996 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing frame\n");
997 frame->Release (frame);
998 frame = NULL;
1001 // switch off BES
1002 // if (layer) layer->SetOpacity(layer,0);
1004 if (layer) {
1005 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing layer\n");
1006 layer->Release(layer);
1007 layer = NULL;
1010 if (primary) {
1011 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing primary\n");
1012 primary->Release (primary);
1013 primary = NULL;
1017 /* mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing DirectFB library\n");
1019 dfb->Release (dfb);
1021 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit done.\n");
1025 static uint32_t directfb_set_video_eq(char *data, int value) //data==name
1028 DFBColorAdjustment ca;
1029 float factor = (float)0xffff / 200.0;
1031 DFBDisplayLayerDescription desc;
1033 unlock();
1035 if (layer) {
1037 layer->GetDescription(layer,&desc);
1039 ca.flags=DCAF_NONE;
1041 if (! strcmp( data,"brightness" )) {
1042 if (desc.caps & DLCAPS_BRIGHTNESS) {
1043 ca.brightness = value * factor +0x8000;
1044 ca.flags |= DCAF_BRIGHTNESS;
1045 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value);
1046 } else return VO_FALSE;
1049 if (! strcmp( data,"contrast" )) {
1050 if ((desc.caps & DLCAPS_CONTRAST)) {
1051 ca.contrast = value * factor + 0x8000;
1052 ca.flags |= DCAF_CONTRAST;
1053 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value);
1054 } else return VO_FALSE;
1057 if (! strcmp( data,"hue" )) {
1058 if ((desc.caps & DLCAPS_HUE)) {
1059 ca.hue = value * factor + 0x8000;
1060 ca.flags |= DCAF_HUE;
1061 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value);
1062 } else return VO_FALSE;
1065 if (! strcmp( data,"saturation" )) {
1066 if ((desc.caps & DLCAPS_SATURATION)) {
1067 ca.saturation = value * factor + 0x8000;
1068 ca.flags |= DCAF_SATURATION;
1069 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value);
1070 } else return VO_FALSE;
1073 if (ca.flags != DCAF_NONE) {
1074 layer->SetColorAdjustment(layer,&ca);
1075 return VO_TRUE;
1079 return VO_FALSE;
1083 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name
1086 DFBColorAdjustment ca;
1087 float factor = 200.0 / (float)0xffff;
1089 DFBDisplayLayerDescription desc;
1091 if (layer) {
1093 unlock();
1095 layer->GetDescription(layer,&desc);
1097 layer->GetColorAdjustment(layer,&ca);
1099 if (! strcmp( data,"brightness" )) {
1100 if (desc.caps & DLCAPS_BRIGHTNESS) {
1101 *value = (int) ((ca.brightness-0x8000) * factor);
1102 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value);
1103 return VO_TRUE;
1104 } else return VO_FALSE;
1107 if (! strcmp( data,"contrast" )) {
1108 if ((desc.caps & DLCAPS_CONTRAST)) {
1109 *value = (int) ((ca.contrast-0x8000) * factor);
1110 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value);
1111 return VO_TRUE;
1112 } else return VO_FALSE;
1115 if (! strcmp( data,"hue" )) {
1116 if ((desc.caps & DLCAPS_HUE)) {
1117 *value = (int) ((ca.hue-0x8000) * factor);
1118 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value);
1119 return VO_TRUE;
1120 } else return VO_FALSE;
1123 if (! strcmp( data,"saturation" )) {
1124 if ((desc.caps & DLCAPS_SATURATION)) {
1125 *value = (int) ((ca.saturation-0x8000) * factor);
1126 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value);
1127 return VO_TRUE;
1128 } else return VO_FALSE;
1131 return VO_FALSE;
1134 static uint32_t get_image(mp_image_t *mpi)
1137 int err;
1138 void *dst;
1139 int pitch;
1141 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() called\n");
1142 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
1143 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static
1145 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags);
1147 if((mpi->width==pitch) ||
1148 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){
1149 // we're lucky or codec accepts stride => ok, let's go!
1151 if (frame) {
1152 err = frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch);
1153 framelocked=1;
1154 } else {
1155 err = primary->Lock(primary,DSLF_WRITE,&dst,&pitch);
1156 primarylocked=1;
1159 if (err) {
1160 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: DR lock failed!");
1161 return VO_FALSE;
1164 if(mpi->flags&MP_IMGFLAG_PLANAR){
1165 //YV12 format
1166 mpi->planes[0]=dst;
1167 if(mpi->flags&MP_IMGFLAG_SWAPPED){
1168 mpi->planes[1]=dst + pitch*height;
1169 mpi->planes[2]=mpi->planes[1] + pitch*height/4;
1170 } else {
1171 mpi->planes[2]=dst + pitch*height;
1172 mpi->planes[1]=mpi->planes[2] + pitch*height/4;
1174 mpi->width=width;
1175 mpi->stride[0]=pitch;
1176 mpi->stride[1]=mpi->stride[2]=pitch/2;
1177 } else {
1178 //YUY2 and RGB formats
1179 mpi->planes[0]=dst;
1180 mpi->width=width;
1181 mpi->stride[0]=pitch;
1184 // center image
1186 if (!frame) {
1187 if(mpi->flags&MP_IMGFLAG_PLANAR){
1188 mpi->planes[0]= dst + yoffset * pitch + xoffset;
1189 mpi->planes[1]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1190 mpi->planes[2]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1191 } else {
1192 mpi->planes[0]=dst + yoffset * pitch + xoffset * (mpi->bpp >> 3);
1196 mpi->flags|=MP_IMGFLAG_DIRECT;
1197 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n");
1198 return VO_TRUE;
1201 return VO_FALSE;
1204 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
1206 int i;
1207 unsigned int pitch;
1208 void *dst;
1209 void *dst2;
1210 void *srcp;
1211 unsigned int p;
1213 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: draw_slice entered\n");
1215 unlock();
1217 if (frame) {
1218 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1219 framelocked = 1;
1220 } else {
1221 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1222 primarylocked = 1;
1225 p=min(w,pitch);
1227 dst += y*pitch + x;
1228 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2;
1229 srcp = src[0];
1231 for (i=0;i<h;i++) {
1232 fast_memcpy(dst,srcp,p);
1233 dst += pitch;
1234 srcp += stride[0];
1237 if (pixel_format == DSPF_YV12) {
1239 dst = dst2;
1240 srcp = src[2];
1241 p = p/2;
1243 for (i=0;i<h/2;i++) {
1244 fast_memcpy(dst,srcp,p);
1245 dst += pitch/2;
1246 srcp += stride[2];
1249 dst = dst2 + pitch*height/4;
1250 srcp = src[1];
1252 for (i=0;i<h/2;i++) {
1253 fast_memcpy(dst,srcp,p);
1254 dst += pitch/2;
1255 srcp += stride[1];
1258 } else {
1260 dst = dst2;
1261 srcp = src[1];
1262 p = p/2;
1264 for (i=0;i<h/2;i++) {
1265 fast_memcpy(dst,srcp,p);
1266 dst += pitch/2;
1267 srcp += stride[1];
1270 dst = dst2 + pitch*height/4;
1271 srcp = src[2];
1273 for (i=0;i<h/2;i++) {
1274 fast_memcpy(dst,srcp,p);
1275 dst += pitch/2;
1276 srcp += stride[2];
1281 unlock();
1283 return 0;
1287 static uint32_t put_image(mp_image_t *mpi){
1290 // static IDirectFBSurface *tmp = NULL;
1291 // DFBSurfaceDescription dsc;
1292 // DFBRectangle rect;
1294 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image entered %i %i %i %i %i %i\n",mpi->x,mpi->y,mpi->w,mpi->h,mpi->width,mpi->height);
1296 unlock();
1298 // already out?
1299 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
1300 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - nothing to do\n");
1301 return VO_TRUE;
1304 if (mpi->flags&MP_IMGFLAG_PLANAR) {
1305 // memcpy all planes - sad but necessary
1306 int i;
1307 unsigned int pitch;
1308 void *dst;
1309 void *src;
1310 unsigned int p;
1312 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - planar branch\n");
1313 if (frame) {
1314 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1315 framelocked = 1;
1316 } else {
1317 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1318 primarylocked = 1;
1321 p=min(mpi->w,pitch);
1323 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x;
1325 for (i=0;i<mpi->h;i++) {
1326 fast_memcpy(dst+i*pitch,src+i*mpi->stride[0],p);
1330 if (pixel_format == DSPF_YV12) {
1332 dst += pitch*height;
1333 p = p/2;
1334 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1336 for (i=0;i<mpi->h/2;i++) {
1337 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1340 dst += pitch*height/4;
1341 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1343 for (i=0;i<mpi->h/2;i++) {
1344 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1347 } else {
1349 dst += pitch*height;
1350 p = p/2;
1351 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1353 for (i=0;i<mpi->h/2;i++) {
1354 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1357 dst += pitch*height/4;
1358 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1360 for (i=0;i<mpi->h/2;i++) {
1361 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1365 unlock();
1367 } else {
1368 // I had to disable native directfb blit because it wasn't working under some conditions :-(
1371 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED;
1372 dsc.preallocated[0].data = mpi->planes[0];
1373 dsc.preallocated[0].pitch = mpi->stride[0];
1374 dsc.width = mpi->width;
1375 dsc.height = mpi->height;
1376 dsc.pixelformat = convformat(mpi->imgfmt);
1378 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp));
1380 rect.x=mpi->x;
1381 rect.y=mpi->y;
1382 rect.w=mpi->w;
1383 rect.h=mpi->h;
1385 if (frame) {
1386 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0));
1387 } else {
1388 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset));
1390 tmp->Release(tmp);
1393 unsigned int pitch;
1394 void *dst;
1396 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - non-planar branch\n");
1397 if (frame) {
1398 DFBCHECK (frame->Lock(frame,DSLF_WRITE,&dst,&pitch));
1399 framelocked = 1;
1400 mem2agpcpy_pic(dst,mpi->planes[0] + mpi->y * mpi->stride[0] + mpi->x * (mpi->bpp >> 3) ,mpi->w * (mpi->bpp >> 3),mpi->h,pitch,mpi->stride[0]);
1401 } else {
1402 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1403 primarylocked = 1;
1404 mem2agpcpy_pic(dst + yoffset * pitch + xoffset * (mpi->bpp >> 3),mpi->planes[0] + mpi->y * mpi->stride[0] + mpi->x * (mpi->bpp >> 3) ,mpi->w * (mpi->bpp >> 3),mpi->h,pitch,mpi->stride[0]);
1406 unlock();
1409 return VO_TRUE;
1414 static int control(uint32_t request, void *data, ...)
1416 switch (request) {
1417 case VOCTRL_QUERY_FORMAT:
1418 return query_format(*((uint32_t*)data));
1419 case VOCTRL_GET_IMAGE:
1420 return get_image(data);
1421 case VOCTRL_DRAW_IMAGE:
1422 return put_image(data);
1423 case VOCTRL_SET_EQUALIZER:
1425 va_list ap;
1426 int value;
1428 va_start(ap, data);
1429 value = va_arg(ap, int);
1430 va_end(ap);
1432 return(directfb_set_video_eq(data, value));
1434 case VOCTRL_GET_EQUALIZER:
1436 va_list ap;
1437 int *value;
1439 va_start(ap, data);
1440 value = va_arg(ap, int*);
1441 va_end(ap);
1443 return(directfb_get_video_eq(data, value));
1446 return VO_NOTIMPL;
1449 // unused function
1451 static int draw_frame(uint8_t *src[])
1453 return -1;
1456 // hopefully will be removed soon
1458 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1459 unsigned char *srca, int stride)
1461 void *dst;
1462 int pitch;
1464 unlock(); // isn't it silly I have to unlock surface and then lock it again :-)
1466 if (frame) {
1467 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1468 framelocked = 1;
1469 } else {
1470 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1471 primarylocked = 1;
1474 switch(pixel_format) {
1475 case DSPF_RGB32:
1476 case DSPF_ARGB:
1477 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch);
1478 break;
1480 case DSPF_RGB24:
1481 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch);
1482 break;
1484 case DSPF_RGB16:
1485 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1486 break;
1487 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
1488 case DSPF_ARGB1555:
1489 #else
1490 case DSPF_RGB15:
1491 #endif
1492 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1493 break;
1495 case DSPF_YUY2:
1496 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch);
1497 break;
1499 case DSPF_UYVY:
1500 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch);
1501 break;
1503 case DSPF_I420:
1504 case DSPF_YV12:
1505 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch);
1506 break;
1509 unlock();
1512 static void draw_osd(void)
1514 vo_draw_text(width,height,draw_alpha);