Split generic OS X API check into separate CoreAudio, CoreVideo, Quartz checks.
[mplayer/glamo.git] / libvo / vo_directfb2.c
blob7aafe091e99162bcdfc4af41159494f04564b16b
1 /*
2 * MPlayer video driver for DirectFramebuffer device
4 * copyright (C) 2002 Jiri Svoboda <Jiri.Svoboda@seznam.cz>
6 * based on vo_directfb2.c
8 * This file is part of MPlayer.
10 * MPlayer is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * MPlayer is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with MPlayer; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 // directfb includes
27 #include <directfb.h>
29 #define DFB_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
31 // other things
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
37 #ifdef __linux__
38 #include <sys/kd.h>
39 #else
40 #include <linux/kd.h>
41 #endif
43 #include "config.h"
44 #include "video_out.h"
45 #include "video_out_internal.h"
46 #include "fastmemcpy.h"
47 #include "sub.h"
48 #include "mp_msg.h"
49 #include "aspect.h"
50 #include "subopt-helper.h"
51 #include "mp_fifo.h"
53 #ifndef min
54 #define min(x,y) (((x)<(y))?(x):(y))
55 #endif
57 #if DIRECTFBVERSION > DFB_VERSION(0,9,17)
58 // triple buffering
59 #define TRIPLE 1
60 #endif
62 static const vo_info_t info = {
63 "Direct Framebuffer Device",
64 "directfb",
65 "Jiri Svoboda Jiri.Svoboda@seznam.cz",
66 "v 2.0 (for DirectFB version >=0.9.13)"
69 const LIBVO_EXTERN(directfb)
71 /******************************
72 * vo_directfb globals *
73 ******************************/
75 #define DFBCHECK(x...) \
76 { \
77 DFBResult err = x; \
79 if (err != DFB_OK) \
80 { \
81 fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
82 DirectFBErrorFatal( #x, err ); \
83 } \
87 * filled by preinit
90 // main DirectFB handle
91 static IDirectFB *dfb = NULL;
92 // keyboard handle
93 static IDirectFBInputDevice *keyboard = NULL;
94 // A buffer for input events.
95 static IDirectFBEventBuffer *buffer = NULL;
98 * filled during config
101 // handle of used layer
102 static IDirectFBDisplayLayer *layer = NULL;
103 // surface of used layer
104 static IDirectFBSurface *primary = NULL;
105 static int primarylocked = 0;
106 // handle of temporary surface (if used)
107 static IDirectFBSurface *frame = NULL;
108 static int framelocked = 0;
109 // flipping mode flag (layer/surface)
110 static int flipping = 0;
111 // scaling flag
112 static int stretch = 0;
113 // picture position
114 static int xoffset=0,yoffset=0;
115 // picture size
116 static int out_width=0,out_height=0;
117 // frame/primary size
118 static int width=0,height=0;
119 // frame primary format
120 DFBSurfacePixelFormat pixel_format;
122 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
123 unsigned char *srca, int stride, unsigned char *dst,
124 int dstride);
127 /******************************
128 * cmd line parameteres *
129 ******************************/
131 /* command line/config file options */
132 static int layer_id = -1;
133 static int buffer_mode = 1;
134 static int use_input = 1;
135 static int field_parity = -1;
137 /******************************
138 * implementation *
139 ******************************/
141 void unlock(void) {
142 if (frame && framelocked) frame->Unlock(frame);
143 if (primary && primarylocked) primary->Unlock(primary);
146 static int get_parity(strarg_t *arg) {
147 if (strargcmp(arg, "top") == 0)
148 return 0;
149 if (strargcmp(arg, "bottom") == 0)
150 return 1;
151 return -1;
154 static int check_parity(void *arg) {
155 return get_parity(arg) != -1;
158 static int get_mode(strarg_t *arg) {
159 if (strargcmp(arg, "single") == 0)
160 return 1;
161 if (strargcmp(arg, "double") == 0)
162 return 2;
163 if (strargcmp(arg, "triple") == 0)
164 return 3;
165 return 0;
168 static int check_mode(void *arg) {
169 return get_mode(arg) != 0;
172 static int preinit(const char *arg)
174 DFBResult ret;
175 strarg_t mode_str = {0, NULL};
176 strarg_t par_str = {0, NULL};
177 strarg_t dfb_params = {0, NULL};
178 const opt_t subopts[] = {
179 {"input", OPT_ARG_BOOL, &use_input, NULL},
180 {"buffermode", OPT_ARG_STR, &mode_str, check_mode},
181 {"fieldparity", OPT_ARG_STR, &par_str, check_parity},
182 {"layer", OPT_ARG_INT, &layer_id, NULL},
183 {"dfbopts", OPT_ARG_STR, &dfb_params, NULL},
184 {NULL}
187 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
189 if (dfb) return 0; // we are already initialized!
191 // set defaults
192 buffer_mode = 1 + vo_doublebuffering; // honor -double switch
193 layer_id = -1;
194 use_input = 1;
195 field_parity = -1;
196 if (subopt_parse(arg, subopts) != 0) {
197 mp_msg( MSGT_VO, MSGL_ERR,
198 "\n-vo directfb command line help:\n"
199 "Example: mplayer -vo directfb:layer=1:buffermode=single\n"
200 "\nOptions (use 'no' prefix to disable):\n"
201 " input Use DirectFB for keyboard input\n"
202 "\nOther options:\n"
203 " layer=n\n"
204 " n=0..xx Use layer with id n for output (0=primary)\n"
205 " buffermode=(single|double|triple)\n"
206 " single Use single buffering\n"
207 " double Use double buffering\n"
208 " triple Use triple buffering\n"
209 " fieldparity=(top|bottom)\n"
210 " top Top field first\n"
211 " bottom Bottom field first\n"
212 " dfbopts=<str>\n"
213 " Specify a parameter list for DirectFB\n"
214 "\n" );
215 return -1;
217 if (mode_str.len)
218 buffer_mode = get_mode(&mode_str);
219 if (par_str.len)
220 field_parity = get_parity(&par_str);
223 if (dfb_params.len > 0)
225 int argc = 2;
226 char arg0[10] = "mplayer";
227 char *arg1 = malloc(dfb_params.len + 7);
228 char* argv[3];
229 char ** a;
231 a = &argv[0];
233 strcpy(arg1, "--dfb:");
234 strncat(arg1, dfb_params.str, dfb_params.len);
236 argv[0]=arg0;
237 argv[1]=arg1;
238 argv[2]=NULL;
240 DFBCHECK (DirectFBInit (&argc,&a));
242 free(arg1);
243 } else {
245 DFBCHECK (DirectFBInit (NULL,NULL));
248 if (((directfb_major_version <= 0) &&
249 (directfb_minor_version <= 9) &&
250 (directfb_micro_version < 13)))
252 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Unsupported DirectFB version\n");
253 return 1;
257 * (set options)
260 // uncomment this if you do not wish to create a new VT for DirectFB
261 // DFBCHECK (DirectFBSetOption ("no-vt-switch",""));
263 // uncomment this if you want to allow VT switching
264 // DFBCHECK (DirectFBSetOption ("vt-switching",""));
266 // uncomment this if you want to hide gfx cursor (req dfb >=0.9.9)
267 DFBCHECK (DirectFBSetOption ("no-cursor",""));
269 // bg color fix
270 DFBCHECK (DirectFBSetOption ("bg-color","00000000"));
273 * (Initialize)
276 DFBCHECK (DirectFBCreate (&dfb));
278 #if DIRECTFBVERSION < DFB_VERSION(0,9,17)
279 if (DFB_OK != dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN)) {
280 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - cannot switch to fullscreen mode");
282 #endif
285 * (Get keyboard)
288 if (use_input) {
289 ret = dfb->GetInputDevice (dfb, DIDID_KEYBOARD, &keyboard);
290 if (ret==DFB_OK) {
291 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Keyboard init OK\n");
292 } else {
293 keyboard = NULL;
294 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: Keyboard init FAILED\n");
300 * Create an input buffer for the keyboard.
302 if (keyboard) DFBCHECK (keyboard->CreateEventBuffer (keyboard, &buffer));
304 // just to start clean ...
305 if (buffer) buffer->Reset(buffer);
307 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit OK\n");
309 return 0;
313 DFBSurfacePixelFormat convformat(uint32_t format)
315 // add more formats !!!
316 switch (format) {
317 case IMGFMT_RGB32: return DSPF_RGB32; break;
318 case IMGFMT_BGR32: return DSPF_RGB32; break;
319 case IMGFMT_RGB24: return DSPF_RGB24; break;
320 case IMGFMT_BGR24: return DSPF_RGB24; break;
321 case IMGFMT_RGB16: return DSPF_RGB16; break;
322 case IMGFMT_BGR16: return DSPF_RGB16; break;
323 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
324 case IMGFMT_RGB15: return DSPF_ARGB1555; break;
325 case IMGFMT_BGR15: return DSPF_ARGB1555; break;
326 #else
327 case IMGFMT_RGB15: return DSPF_RGB15; break;
328 case IMGFMT_BGR15: return DSPF_RGB15; break;
329 #endif
330 case IMGFMT_YUY2: return DSPF_YUY2; break;
331 case IMGFMT_UYVY: return DSPF_UYVY; break;
332 case IMGFMT_YV12: return DSPF_YV12; break;
333 case IMGFMT_I420: return DSPF_I420; break;
334 // case IMGFMT_IYUV: return DSPF_IYUV; break;
335 case IMGFMT_RGB8: return DSPF_RGB332; break;
336 case IMGFMT_BGR8: return DSPF_RGB332; break;
338 default: return 0;
340 return 0;
343 typedef struct enum1_s {
344 uint32_t format;
345 int scale;
346 int result;
347 unsigned int id;
348 unsigned int width;
349 unsigned int height;
350 int setsize;
351 } enum1_t;
353 DFBEnumerationResult test_format_callback( unsigned int id,
354 DFBDisplayLayerDescription desc,
355 void *data)
357 enum1_t *params =(enum1_t *)data;
358 IDirectFBDisplayLayer *layer;
359 DFBResult ret;
361 if ((layer_id == -1 )||(layer_id == id)) {
363 ret = dfb->GetDisplayLayer( dfb, id, &layer);
364 if (ret) {
365 DirectFBError( "dfb->GetDisplayLayer failed", ret );
366 return DFENUM_OK;
367 } else {
368 DFBDisplayLayerConfig dlc;
370 if (params->setsize) {
371 dlc.flags = DLCONF_WIDTH |DLCONF_HEIGHT;
372 dlc.width = params->width;
373 dlc.height = params->height;
374 layer->SetConfiguration(layer,&dlc);
378 dlc.flags = DLCONF_PIXELFORMAT;
379 dlc.pixelformat = convformat(params->format);
381 layer->SetOpacity(layer,0);
383 ret = layer->TestConfiguration(layer,&dlc,NULL);
385 layer->Release(layer);
387 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
389 if (ret==DFB_OK) {
390 // printf("Test OK\n");
391 if (params->result) {
392 if ((!params->scale) && (desc.caps & DLCAPS_SCREEN_LOCATION)) {
393 params->scale=1;
394 params->id=id;
395 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
397 } else {
398 params->result=1;
399 params->id=id;
400 if (desc.caps & DLCAPS_SCREEN_LOCATION) params->scale=1;
401 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Test format - added layer %i scale/pos %i\n",id,(desc.caps & DLCAPS_SCREEN_LOCATION));
408 return DFENUM_OK;
411 static int query_format(uint32_t format)
413 int ret = VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD; // osd should be removed the in future -> will be handled outside...
414 enum1_t params;
417 if (!convformat(format)) return 0;
418 // temporarily disable YV12
419 // if (format == IMGFMT_YV12) return 0;
420 // if (format == IMGFMT_I420) return 0;
421 if (format == IMGFMT_IYUV) return 0;
423 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Format query: %s\n",vo_format_name(format));
425 params.format=format;
426 params.scale=0;
427 params.result=0;
428 params.setsize=0;
430 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
432 if (params.result) {
433 if (params.scale) ret |=VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN;
434 return ret;
437 return 0;
440 typedef struct videomode_s {
441 int width;
442 int height;
443 int out_width;
444 int out_height;
445 int overx;
446 int overy;
447 int bpp;
448 } videomode_t;
451 DFBEnumerationResult video_modes_callback( int width,int height,int bpp, void *data)
453 videomode_t *params =(videomode_t *)data;
455 int overx=0,overy=0,closer=0,over=0;
456 int we_are_under=0;
458 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Validator entered %i %i %i\n",width,height,bpp);
460 overx=width-params->out_width;
461 overy=height-params->out_height;
463 if (!params->width) {
464 params->width=width;
465 params->height=height;
466 params->overx=overx;
467 params->overy=overy;
468 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Mode added %i %i %i\n",width,height,bpp);
471 if ((params->overy<0)||(params->overx<0)) we_are_under=1; // stored mode is smaller than req mode
472 if (abs(overx*overy)<abs(params->overx * params->overy)) closer=1; // current mode is closer to desired res
473 if ((overx>=0)&&(overy>=0)) over=1; // current mode is bigger or equaul to desired res
474 if ((closer && (over || we_are_under)) || (we_are_under && over)) {
475 params->width=width;
476 params->height=height;
477 params->overx=overx;
478 params->overy=overy;
479 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Better mode added %i %i %i\n",width,height,bpp);
482 return DFENUM_OK;
485 #define CONFIG_ERROR -1
487 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
488 uint32_t d_height, uint32_t flags, char *title,
489 uint32_t format)
492 * (Locals)
495 // decode flags
497 int fs = flags & VOFLAG_FULLSCREEN;
498 int vm = flags & VOFLAG_MODESWITCHING;
500 DFBSurfaceDescription dsc;
501 DFBResult ret;
502 DFBDisplayLayerConfig dlc;
503 DFBSurfaceCapabilities caps;
505 enum1_t params;
507 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config entered [%ix%i]\n",s_width,s_height);
508 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: With requested format: %s\n",vo_format_name(format));
510 // initial cleanup
511 if (frame) {
512 frame->Release(frame);
513 frame=NULL;
516 if (primary) {
517 primary->Release(primary);
518 primary=NULL;
521 if (layer) {
522 layer->Release(layer);
523 layer=NULL;
527 // vm things
529 if (vm) {
530 videomode_t params;
531 params.out_width=d_width;
532 params.out_height=d_height;
533 params.width=0;
534 params.height=0;
535 switch (format) {
536 case IMGFMT_RGB32:
537 case IMGFMT_BGR32:
538 params.bpp=32;
539 break;
540 case IMGFMT_RGB24:
541 case IMGFMT_BGR24:
542 params.bpp=24;
543 break;
544 case IMGFMT_RGB16:
545 case IMGFMT_BGR16:
546 case IMGFMT_RGB15:
547 case IMGFMT_BGR15:
548 params.bpp=16;
549 break;
550 default: params.bpp=0;
553 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - trying to change videomode\n");
554 DFBCHECK (dfb->EnumVideoModes(dfb,video_modes_callback,&params));
555 ret=dfb->SetVideoMode(dfb,params.width,params.height,params.bpp);
556 if (ret) {
557 ret=dfb->SetVideoMode(dfb,params.width,params.height,24);
558 if (ret) {
559 ret=dfb->SetVideoMode(dfb,params.width,params.height,32);
560 if (ret) {
561 ret=dfb->SetVideoMode(dfb,params.width,params.height,16);
562 if (ret) {
563 ret=dfb->SetVideoMode(dfb,params.width,params.height,8);
568 } // vm end
570 // just to be sure clear primary layer
571 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
572 ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer);
573 if (ret==DFB_OK) {
574 ret = layer->GetSurface(layer,&primary);
575 if (ret==DFB_OK) {
576 primary->Clear(primary,0,0,0,0xff);
577 ret = primary->Flip(primary,NULL,0);
578 if (ret==DFB_OK) {
579 primary->Clear(primary,0,0,0,0xff);
581 primary->Release(primary);
583 primary=NULL;
584 layer->Release(layer);
586 layer=NULL;
587 #endif
589 // find best layer
591 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - looking for suitable layer\n");
592 params.format=format;
593 params.scale=0;
594 params.result=0;
595 params.width=s_width;
596 params.height=s_height;
597 params.setsize=1;
599 DFBCHECK (dfb->EnumDisplayLayers(dfb,test_format_callback,&params));
601 if (!params.result) {
602 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - no suitable layer found\n");
603 params.id = DLID_PRIMARY;
606 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - layer %i\n",params.id);
608 // setup layer
610 DFBCHECK (dfb->GetDisplayLayer( dfb, params.id, &layer));
612 #if DIRECTFBVERSION > DFB_VERSION(0,9,16)
613 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - switching layer to exclusive mode\n");
614 ret = layer->SetCooperativeLevel (layer, DLSCL_EXCLUSIVE);
616 if (DFB_OK != ret) {
617 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");
618 DirectFBError("MPlayer - Switch layer to exlusive mode.",ret);
620 #endif
621 if (params.scale) {
622 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (size)\n");
623 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
624 dlc.width = s_width;
625 dlc.height = s_height;
627 ret = layer->SetConfiguration(layer,&dlc);
629 if (ret) {
630 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (size)\n");
631 DirectFBError("MPlayer - Layer size change.",ret);
635 // look if we need to change the pixel format of the layer
636 // and just to be sure also fetch all layer properties
637 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_OPTIONS | DLCONF_BUFFERMODE;
639 ret = layer->GetConfiguration(layer,&dlc);
641 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_WIDTH | DLCONF_HEIGHT;
643 if (ret) {
644 mp_msg(MSGT_VO, MSGL_WARN,"DirectFB: Warning - could not get layer properties!\n");
645 } else {
646 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer reports format:%x\n",dlc.pixelformat);
649 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
651 dlc.flags = DLCONF_PIXELFORMAT;
652 dlc.pixelformat = convformat(params.format);
654 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Desired pixelformat: %x\n",dlc.pixelformat);
656 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - changing layer configuration (format)\n");
657 ret = layer->SetConfiguration(layer,&dlc);
659 if (ret) {
660 unsigned int bpp;
661 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (format, flags=%x)\n",dlc.flags);
662 DirectFBError("MPlayer - layer pixelformat change",ret);
664 // ugly fbdev workaround - try to switch pixelformat via videomode change
665 switch (dlc.pixelformat) {
666 case DSPF_ARGB:
667 case DSPF_RGB32: bpp=32;break;
668 case DSPF_RGB24: bpp=24;break;
669 case DSPF_RGB16: bpp=16;break;
670 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
671 case DSPF_ARGB1555: bpp=15;break;
672 #else
673 case DSPF_RGB15: bpp=15;break;
674 #endif
675 case DSPF_RGB332 : bpp=8;break;
678 switch (dlc.pixelformat) {
679 case DSPF_ARGB:
680 case DSPF_RGB32:
681 case DSPF_RGB24:
682 case DSPF_RGB16:
683 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
684 case DSPF_ARGB1555:
685 #else
686 case DSPF_RGB15:
687 #endif
688 case DSPF_RGB332:
689 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Trying to recover via videomode change (VM).\n");
690 // get size
691 dlc.flags = DLCONF_WIDTH | DLCONF_HEIGHT;
692 if (DFB_OK==layer->GetConfiguration(layer,&dlc)) {
693 // try to set videomode
694 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Videomode %ix%i BPP %i\n",dlc.width,dlc.height,bpp);
695 ret = dfb->SetVideoMode(dfb,dlc.width,dlc.height,bpp);
696 if (ret) DirectFBError("MPlayer - VM - pixelformat change",ret);
700 //get current pixel format
701 dlc.flags = DLCONF_PIXELFORMAT;
702 ret = layer->GetConfiguration(layer,&dlc);
703 if (ret) {
704 DirectFBError("MPlayer - VM - Layer->GetConfiguration",ret);
705 } else {
706 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Layer now has pixelformat [%x]\n",dlc.pixelformat);
709 // check if we were succesful
710 if ((dlc.pixelformat != convformat(params.format)) || (ret != DFB_OK)) {
711 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Recovery failed!.\n");
712 return CONFIG_ERROR;
715 break;
717 default: return CONFIG_ERROR;
723 // flipping of layer
724 // try triple, double... buffering
726 dlc.flags = DLCONF_BUFFERMODE;
727 #ifdef TRIPLE
728 if (buffer_mode > 2) {
729 dlc.buffermode = DLBM_TRIPLE;
730 ret = layer->SetConfiguration( layer, &dlc );
731 } else {
732 ret=!DFB_OK;
735 if (ret!=DFB_OK) {
736 #endif
737 if (buffer_mode > 1) {
738 dlc.buffermode = DLBM_BACKVIDEO;
739 ret = layer->SetConfiguration( layer, &dlc );
740 if (ret!=DFB_OK) {
741 dlc.buffermode = DLBM_BACKSYSTEM;
742 ret = layer->SetConfiguration( layer, &dlc );
745 if (ret == DFB_OK) {
746 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Double buffering is active\n");
748 #ifdef TRIPLE
749 } else {
750 mp_msg(MSGT_VO, MSGL_V,"DirectFB: Triple buffering is active\n");
752 #endif
754 #if DIRECTFBVERSION > DFB_VERSION(0,9,16)
755 if (field_parity != -1) {
756 dlc.flags = DLCONF_OPTIONS;
757 ret = layer->GetConfiguration( layer, &dlc );
758 if (ret==DFB_OK) {
759 dlc.options |= DLOP_FIELD_PARITY;
760 ret = layer->SetConfiguration( layer, &dlc );
761 if (ret==DFB_OK) {
762 layer->SetFieldParity( layer, field_parity );
766 mp_msg( MSGT_VO, MSGL_DBG2, "DirectFB: Requested field parity: ");
767 switch (field_parity) {
768 case -1:
769 mp_msg( MSGT_VO, MSGL_DBG2, "Don't care\n");
770 break;
771 case 0:
772 mp_msg( MSGT_VO, MSGL_DBG2, "Top field first\n");
773 break;
774 case 1:
775 mp_msg( MSGT_VO, MSGL_DBG2, "Bottom field first\n");
776 break;
779 #endif
782 // get layer surface
784 ret = layer->GetSurface(layer,&primary);
786 if (ret) {
787 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError - could not get surface\n");
788 return CONFIG_ERROR; // what shall we report on failure?
791 // test surface for flipping
792 DFBCHECK(primary->GetCapabilities(primary,&caps));
793 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
794 primary->Clear(primary,0,0,0,0xff);
795 #endif
796 flipping = 0;
797 if (caps & (DSCAPS_FLIPPING
798 #ifdef TRIPLE
799 | DSCAPS_TRIPLE
800 #endif
801 )) {
802 ret = primary->Flip(primary,NULL,0);
803 if (ret==DFB_OK) {
804 flipping = 1;
805 #if DIRECTFBVERSION > DFB_VERSION(0,9,13)
806 primary->Clear(primary,0,0,0,0xff);
807 #ifdef TRIPLE
808 // if we have 3 buffers clean once more
809 if (caps & DSCAPS_TRIPLE) {
810 primary->Flip(primary,NULL,0);
811 primary->Clear(primary,0,0,0,0xff);
812 flipping = 2;
814 #endif
815 #endif
819 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - flipping = %i\n",flipping);
821 // is scale needed ? Aspect ratio and layer pos/size
824 // get surface size
825 DFBCHECK(primary->GetSize(primary,&width,&height));
827 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Config - surface size = %ix%i\n",width,height);
829 aspect_save_orig(s_width,s_height);
830 aspect_save_prescale(d_width,d_height);
831 if (params.scale) {
832 aspect_save_screenres(10000,10000);
833 aspect(&out_width,&out_height,A_ZOOM);
835 ret = layer->SetScreenLocation(layer,(1-(float)out_width/10000)/2,(1-(float)out_height/10000)/2,((float)out_width/10000),((float)out_height/10000));
837 if (ret) mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: ConfigError in layer configuration (position)\n");
839 xoffset = 0;
840 yoffset = 0;
842 } else {
844 aspect_save_screenres(width,height);
846 if(fs) /* -fs */
847 aspect(&out_width,&out_height,A_ZOOM);
848 else
849 aspect(&out_width,&out_height,A_NOZOOM);
852 xoffset = (width - out_width) / 2;
853 yoffset = (height - out_height) / 2;
856 if (((s_width==out_width)&&(s_height==out_height)) || (params.scale)) {
857 stretch = 0;
858 } else {
859 stretch = 1;
863 // temporary buffer in case of not flipping or scaling
864 if ((!flipping) || stretch) {
866 DFBCHECK (primary->GetPixelFormat (primary, &dsc.pixelformat));
868 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH;
870 dsc.width = s_width;
871 dsc.height = s_height;
873 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &frame));
874 DFBCHECK(frame->GetSize(frame,&width,&height));
875 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Frame is active.\n");
878 // get format for draw_alpha - should be removed soon - osd will be rendered outside vo driver
879 if (frame) {
880 DFBCHECK (frame->GetPixelFormat(frame,&pixel_format));
881 } else {
882 DFBCHECK (primary->GetPixelFormat(primary,&pixel_format));
885 // finally turn on layer
886 layer->SetOpacity(layer,255);
888 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Config finished [%ix%i] - [%ix%i]\n",out_width,out_height,width,height);
890 return 0;
893 #include "osdep/keycodes.h"
895 static void check_events(void)
898 if (buffer) {
900 DFBInputEvent event;
902 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events entered\n");
903 if (buffer->GetEvent(buffer, DFB_EVENT (&event)) == DFB_OK) {
905 if (event.type == DIET_KEYPRESS) {
906 switch (event.key_symbol) {
907 case DIKS_ESCAPE:
908 mplayer_put_key(KEY_ESC);
909 break;
910 case DIKS_PAGE_UP: mplayer_put_key(KEY_PAGE_UP);break;
911 case DIKS_PAGE_DOWN: mplayer_put_key(KEY_PAGE_DOWN);break;
912 case DIKS_CURSOR_UP: mplayer_put_key(KEY_UP);break;
913 case DIKS_CURSOR_DOWN: mplayer_put_key(KEY_DOWN);break;
914 case DIKS_CURSOR_LEFT: mplayer_put_key(KEY_LEFT);break;
915 case DIKS_CURSOR_RIGHT: mplayer_put_key(KEY_RIGHT);break;
916 case DIKS_INSERT: mplayer_put_key(KEY_INSERT);break;
917 case DIKS_DELETE: mplayer_put_key(KEY_DELETE);break;
918 case DIKS_HOME: mplayer_put_key(KEY_HOME);break;
919 case DIKS_END: mplayer_put_key(KEY_END);break;
921 default:mplayer_put_key(event.key_symbol);
925 // empty buffer, because of repeating (keyboard repeat is faster than key handling
926 // and this causes problems during seek)
927 // temporary workaround should be solved in the future
928 buffer->Reset(buffer);
931 //if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf ("DirectFB: Check events finished\n");
934 static void flip_page(void)
936 DFBSurfaceBlittingFlags flags=DSBLIT_NOFX;
938 unlock(); // unlock frame & primary
940 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Flip page entered");
942 DFBCHECK (primary->SetBlittingFlags(primary,flags));
944 if (frame) {
945 if (stretch) {
946 DFBRectangle rect;
947 rect.x=xoffset;
948 rect.y=yoffset;
949 rect.w=out_width;
950 rect.h=out_height;
952 DFBCHECK (primary->StretchBlit(primary,frame,NULL,&rect));
954 } else {
956 DFBCHECK (primary->Blit(primary,frame,NULL,xoffset,yoffset));
962 #ifdef TRIPLE
963 switch (flipping) {
964 case 1: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAIT));
965 break;
966 case 2: DFBCHECK (primary->Flip (primary, NULL, DSFLIP_ONSYNC));
967 break;
968 default:; // should never be reached
970 #else
971 if (flipping) {
972 DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
974 #endif
980 static void uninit(void)
983 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit entered\n");
985 unlock();
988 * (Release)
991 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing buffer\n");
992 if (buffer) buffer->Release (buffer);
993 mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing keyboard\n");
994 if (keyboard) keyboard->Release (keyboard);
996 if (frame) {
997 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing frame\n");
998 frame->Release (frame);
999 frame = NULL;
1002 // switch off BES
1003 // if (layer) layer->SetOpacity(layer,0);
1005 if (layer) {
1006 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing layer\n");
1007 layer->Release(layer);
1008 layer = NULL;
1011 if (primary) {
1012 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: Releasing primary\n");
1013 primary->Release (primary);
1014 primary = NULL;
1018 /* mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Releasing DirectFB library\n");
1020 dfb->Release (dfb);
1022 //mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Uninit done.\n");
1026 static uint32_t directfb_set_video_eq(char *data, int value) //data==name
1029 DFBColorAdjustment ca;
1030 float factor = (float)0xffff / 200.0;
1032 DFBDisplayLayerDescription desc;
1034 unlock();
1036 if (layer) {
1038 layer->GetDescription(layer,&desc);
1040 ca.flags=DCAF_NONE;
1042 if (! strcmp( data,"brightness" )) {
1043 if (desc.caps & DLCAPS_BRIGHTNESS) {
1044 ca.brightness = value * factor +0x8000;
1045 ca.flags |= DCAF_BRIGHTNESS;
1046 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Brightness 0x%X %i\n",ca.brightness,value);
1047 } else return VO_FALSE;
1050 if (! strcmp( data,"contrast" )) {
1051 if ((desc.caps & DLCAPS_CONTRAST)) {
1052 ca.contrast = value * factor + 0x8000;
1053 ca.flags |= DCAF_CONTRAST;
1054 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Contrast 0x%X %i\n",ca.contrast,value);
1055 } else return VO_FALSE;
1058 if (! strcmp( data,"hue" )) {
1059 if ((desc.caps & DLCAPS_HUE)) {
1060 ca.hue = value * factor + 0x8000;
1061 ca.flags |= DCAF_HUE;
1062 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Hue 0x%X %i\n",ca.hue,value);
1063 } else return VO_FALSE;
1066 if (! strcmp( data,"saturation" )) {
1067 if ((desc.caps & DLCAPS_SATURATION)) {
1068 ca.saturation = value * factor + 0x8000;
1069 ca.flags |= DCAF_SATURATION;
1070 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: SetVEq Saturation 0x%X %i\n",ca.saturation,value);
1071 } else return VO_FALSE;
1074 if (ca.flags != DCAF_NONE) {
1075 layer->SetColorAdjustment(layer,&ca);
1076 return VO_TRUE;
1080 return VO_FALSE;
1084 static uint32_t directfb_get_video_eq(char *data, int *value) // data==name
1087 DFBColorAdjustment ca;
1088 float factor = 200.0 / (float)0xffff;
1090 DFBDisplayLayerDescription desc;
1092 if (layer) {
1094 unlock();
1096 layer->GetDescription(layer,&desc);
1098 layer->GetColorAdjustment(layer,&ca);
1100 if (! strcmp( data,"brightness" )) {
1101 if (desc.caps & DLCAPS_BRIGHTNESS) {
1102 *value = (int) ((ca.brightness-0x8000) * factor);
1103 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Brightness 0x%X %i\n",ca.brightness,*value);
1104 return VO_TRUE;
1105 } else return VO_FALSE;
1108 if (! strcmp( data,"contrast" )) {
1109 if ((desc.caps & DLCAPS_CONTRAST)) {
1110 *value = (int) ((ca.contrast-0x8000) * factor);
1111 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Contrast 0x%X %i\n",ca.contrast,*value);
1112 return VO_TRUE;
1113 } else return VO_FALSE;
1116 if (! strcmp( data,"hue" )) {
1117 if ((desc.caps & DLCAPS_HUE)) {
1118 *value = (int) ((ca.hue-0x8000) * factor);
1119 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Hue 0x%X %i\n",ca.hue,*value);
1120 return VO_TRUE;
1121 } else return VO_FALSE;
1124 if (! strcmp( data,"saturation" )) {
1125 if ((desc.caps & DLCAPS_SATURATION)) {
1126 *value = (int) ((ca.saturation-0x8000) * factor);
1127 mp_msg(MSGT_VO, MSGL_DBG2,"DirectFB: GetVEq Saturation 0x%X %i\n",ca.saturation,*value);
1128 return VO_TRUE;
1129 } else return VO_FALSE;
1132 return VO_FALSE;
1135 static uint32_t get_image(mp_image_t *mpi)
1138 int err;
1139 uint8_t *dst;
1140 int pitch;
1142 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() called\n");
1143 if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
1144 if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static
1146 // printf("width=%d vs. pitch=%d, flags=0x%X \n",mpi->width,pitch,mpi->flags);
1148 if((mpi->width==pitch) ||
1149 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){
1150 // we're lucky or codec accepts stride => ok, let's go!
1152 if (frame) {
1153 err = frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch);
1154 framelocked=1;
1155 } else {
1156 err = primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch);
1157 primarylocked=1;
1160 if (err) {
1161 mp_msg(MSGT_VO, MSGL_ERR,"DirectFB: DR lock failed!");
1162 return VO_FALSE;
1165 if(mpi->flags&MP_IMGFLAG_PLANAR){
1166 //YV12 format
1167 mpi->planes[0]=dst;
1168 if(mpi->flags&MP_IMGFLAG_SWAPPED){
1169 mpi->planes[1]=dst + pitch*height;
1170 mpi->planes[2]=mpi->planes[1] + pitch*height/4;
1171 } else {
1172 mpi->planes[2]=dst + pitch*height;
1173 mpi->planes[1]=mpi->planes[2] + pitch*height/4;
1175 mpi->width=width;
1176 mpi->stride[0]=pitch;
1177 mpi->stride[1]=mpi->stride[2]=pitch/2;
1178 } else {
1179 //YUY2 and RGB formats
1180 mpi->planes[0]=dst;
1181 mpi->width=width;
1182 mpi->stride[0]=pitch;
1185 // center image
1187 if (!frame) {
1188 if(mpi->flags&MP_IMGFLAG_PLANAR){
1189 mpi->planes[0]= dst + yoffset * pitch + xoffset;
1190 mpi->planes[1]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1191 mpi->planes[2]+= ((yoffset * pitch) >> 2) + (xoffset >> 1);
1192 } else {
1193 mpi->planes[0]=dst + yoffset * pitch + xoffset * (mpi->bpp >> 3);
1197 mpi->flags|=MP_IMGFLAG_DIRECT;
1198 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: get_image() SUCCESS -> Direct Rendering ENABLED\n");
1199 return VO_TRUE;
1202 return VO_FALSE;
1205 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
1207 int i;
1208 unsigned int pitch;
1209 uint8_t *dst;
1210 uint8_t *dst2;
1211 uint8_t *srcp;
1212 unsigned int p;
1214 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: draw_slice entered\n");
1216 unlock();
1218 if (frame) {
1219 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1220 framelocked = 1;
1221 } else {
1222 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1223 primarylocked = 1;
1226 p=min(w,pitch);
1228 dst += y*pitch + x;
1229 dst2 = dst + pitch*height - y*pitch + y*pitch/4 - x/2;
1230 srcp = src[0];
1232 for (i=0;i<h;i++) {
1233 fast_memcpy(dst,srcp,p);
1234 dst += pitch;
1235 srcp += stride[0];
1238 if (pixel_format == DSPF_YV12) {
1240 dst = dst2;
1241 srcp = src[2];
1242 p = p/2;
1244 for (i=0;i<h/2;i++) {
1245 fast_memcpy(dst,srcp,p);
1246 dst += pitch/2;
1247 srcp += stride[2];
1250 dst = dst2 + pitch*height/4;
1251 srcp = src[1];
1253 for (i=0;i<h/2;i++) {
1254 fast_memcpy(dst,srcp,p);
1255 dst += pitch/2;
1256 srcp += stride[1];
1259 } else {
1261 dst = dst2;
1262 srcp = src[1];
1263 p = p/2;
1265 for (i=0;i<h/2;i++) {
1266 fast_memcpy(dst,srcp,p);
1267 dst += pitch/2;
1268 srcp += stride[1];
1271 dst = dst2 + pitch*height/4;
1272 srcp = src[2];
1274 for (i=0;i<h/2;i++) {
1275 fast_memcpy(dst,srcp,p);
1276 dst += pitch/2;
1277 srcp += stride[2];
1282 unlock();
1284 return 0;
1288 static uint32_t put_image(mp_image_t *mpi){
1291 // static IDirectFBSurface *tmp = NULL;
1292 // DFBSurfaceDescription dsc;
1293 // DFBRectangle rect;
1295 // 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);
1297 unlock();
1299 // already out?
1300 if((mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
1301 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - nothing to do\n");
1302 return VO_TRUE;
1305 if (mpi->flags&MP_IMGFLAG_PLANAR) {
1306 // memcpy all planes - sad but necessary
1307 int i;
1308 unsigned int pitch;
1309 uint8_t *dst;
1310 uint8_t *src;
1311 unsigned int p;
1313 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - planar branch\n");
1314 if (frame) {
1315 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,(void *)&dst,&pitch));
1316 framelocked = 1;
1317 } else {
1318 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1319 primarylocked = 1;
1322 p=min(mpi->w,pitch);
1324 src = mpi->planes[0]+mpi->y*mpi->stride[0]+mpi->x;
1326 for (i=0;i<mpi->h;i++) {
1327 fast_memcpy(dst+i*pitch,src+i*mpi->stride[0],p);
1331 if (pixel_format == DSPF_YV12) {
1333 dst += pitch*height;
1334 p = p/2;
1335 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1337 for (i=0;i<mpi->h/2;i++) {
1338 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1341 dst += pitch*height/4;
1342 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1344 for (i=0;i<mpi->h/2;i++) {
1345 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1348 } else {
1350 dst += pitch*height;
1351 p = p/2;
1352 src = mpi->planes[1]+mpi->y*mpi->stride[1]+mpi->x/2;
1354 for (i=0;i<mpi->h/2;i++) {
1355 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[1],p);
1358 dst += pitch*height/4;
1359 src = mpi->planes[2]+mpi->y*mpi->stride[2]+mpi->x/2;
1361 for (i=0;i<mpi->h/2;i++) {
1362 fast_memcpy(dst+i*pitch/2,src+i*mpi->stride[2],p);
1366 unlock();
1368 } else {
1369 // I had to disable native directfb blit because it wasn't working under some conditions :-(
1372 dsc.flags = DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_WIDTH | DSDESC_PREALLOCATED;
1373 dsc.preallocated[0].data = mpi->planes[0];
1374 dsc.preallocated[0].pitch = mpi->stride[0];
1375 dsc.width = mpi->width;
1376 dsc.height = mpi->height;
1377 dsc.pixelformat = convformat(mpi->imgfmt);
1379 DFBCHECK (dfb->CreateSurface( dfb, &dsc, &tmp));
1381 rect.x=mpi->x;
1382 rect.y=mpi->y;
1383 rect.w=mpi->w;
1384 rect.h=mpi->h;
1386 if (frame) {
1387 DFBCHECK (tmp->Blit(tmp,frame,&rect,0,0));
1388 } else {
1389 DFBCHECK (tmp->Blit(tmp,primary,&rect,xoffset,yoffset));
1391 tmp->Release(tmp);
1394 unsigned int pitch;
1395 uint8_t *dst;
1397 // if ( mp_msg_test(MSGT_VO,MSGL_V) ) printf("DirectFB: Put_image - non-planar branch\n");
1398 if (frame) {
1399 DFBCHECK (frame->Lock(frame,DSLF_WRITE,(void *)&dst,&pitch));
1400 framelocked = 1;
1401 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]);
1402 } else {
1403 DFBCHECK (primary->Lock(primary,DSLF_WRITE,(void *)&dst,&pitch));
1404 primarylocked = 1;
1405 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]);
1407 unlock();
1410 return VO_TRUE;
1415 static int control(uint32_t request, void *data, ...)
1417 switch (request) {
1418 case VOCTRL_QUERY_FORMAT:
1419 return query_format(*((uint32_t*)data));
1420 case VOCTRL_GET_IMAGE:
1421 return get_image(data);
1422 case VOCTRL_DRAW_IMAGE:
1423 return put_image(data);
1424 case VOCTRL_SET_EQUALIZER:
1426 va_list ap;
1427 int value;
1429 va_start(ap, data);
1430 value = va_arg(ap, int);
1431 va_end(ap);
1433 return directfb_set_video_eq(data, value);
1435 case VOCTRL_GET_EQUALIZER:
1437 va_list ap;
1438 int *value;
1440 va_start(ap, data);
1441 value = va_arg(ap, int*);
1442 va_end(ap);
1444 return directfb_get_video_eq(data, value);
1447 return VO_NOTIMPL;
1450 // unused function
1452 static int draw_frame(uint8_t *src[])
1454 return -1;
1457 // hopefully will be removed soon
1459 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1460 unsigned char *srca, int stride)
1462 void *dst;
1463 int pitch;
1465 unlock(); // isn't it silly I have to unlock surface and then lock it again :-)
1467 if (frame) {
1468 DFBCHECK (frame->Lock(frame,DSLF_WRITE|DSLF_READ,&dst,&pitch));
1469 framelocked = 1;
1470 } else {
1471 DFBCHECK (primary->Lock(primary,DSLF_WRITE,&dst,&pitch));
1472 primarylocked = 1;
1475 switch(pixel_format) {
1476 case DSPF_RGB32:
1477 case DSPF_ARGB:
1478 vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 4*x0,pitch);
1479 break;
1481 case DSPF_RGB24:
1482 vo_draw_alpha_rgb24(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 3*x0,pitch);
1483 break;
1485 case DSPF_RGB16:
1486 vo_draw_alpha_rgb16(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1487 break;
1488 #if DIRECTFBVERSION > DFB_VERSION(0,9,15)
1489 case DSPF_ARGB1555:
1490 #else
1491 case DSPF_RGB15:
1492 #endif
1493 vo_draw_alpha_rgb15(w,h,src,srca,stride,((uint8_t *) dst)+pitch*y0 + 2*x0,pitch);
1494 break;
1496 case DSPF_YUY2:
1497 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0,pitch);
1498 break;
1500 case DSPF_UYVY:
1501 vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 2*x0 + 1,pitch);
1502 break;
1504 case DSPF_I420:
1505 case DSPF_YV12:
1506 vo_draw_alpha_yv12(w,h,src,srca,stride,((uint8_t *) dst) + pitch*y0 + 1*x0,pitch);
1507 break;
1510 unlock();
1513 static void draw_osd(void)
1515 vo_draw_text(width,height,draw_alpha);