synced with r28807
[mplayer/glamo.git] / libvo / vo_tdfx_vid.c
blob5c7f917d4e988f5cfe291b0af79a508c181fc8e7
1 /*
2 * copyright (C) 2003 Alban Bedel
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <errno.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 #include <sys/ioctl.h>
30 #include <sys/mman.h>
31 #include "config.h"
32 #include "video_out.h"
33 #include "video_out_internal.h"
34 #include "aspect.h"
35 #include "mp_msg.h"
36 #include "help_mp.h"
38 #include "fastmemcpy.h"
39 #include "drivers/tdfx_vid.h"
42 static const vo_info_t info =
44 "tdfx vid",
45 "tdfx_vid",
46 "Albeu",
50 //#define VERBOSE
52 const LIBVO_EXTERN(tdfx_vid)
54 static tdfx_vid_config_t tdfx_cfg;
56 static unsigned char* agp_mem = NULL;
57 static int tdfx_fd = -1;
59 static uint32_t img_fmt; // The real input format
60 static uint32_t src_width, src_height, src_fmt, src_bpp, src_stride;
61 static uint32_t dst_width, dst_height, dst_fmt, dst_bpp, dst_stride;
63 static uint32_t tdfx_page;
64 static uint32_t front_buffer;
65 static uint32_t back_buffer;
66 static uint8_t num_buffer = 3;
67 static uint32_t buffer_size; // Max size
68 static uint8_t current_buffer = 0;
69 static uint8_t current_ip_buf = 0;
70 static uint32_t buffer_stride[3];
72 static int use_overlay = 1;
73 static tdfx_vid_overlay_t tdfx_ov;
75 // FIXME
76 #if 0
77 static void clear_screen(void) {
78 tdfx_vid_agp_move_t mov;
80 memset(agp_mem,0,tdfx_cfg.screen_width*dst_bpp*tdfx_cfg.screen_height);
82 mov.move2 = TDFX_VID_MOVE_2_PACKED;
83 mov.width = tdfx_cfg.screen_width*dst_bpp;
84 mov.height = tdfx_cfg.screen_height;
85 mov.src = 0;
86 mov.src_stride = tdfx_cfg.screen_width*dst_bpp;
87 mov.dst = front_buffer;
88 mov.dst_stride = tdfx_cfg.screen_stride;
90 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_Move, mov.width,mov.src_stride,mov.height,mov.dst_stride);
92 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov))
93 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AGPMoveFailedToClearTheScreen);
96 #endif
98 static int draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
100 uint8_t* ptr[3];
102 #ifdef VERBOSE
103 printf("Draw slices %d\n",current_buffer);
104 #endif
105 switch(img_fmt) {
106 case IMGFMT_YUY2:
107 case IMGFMT_UYVY:
108 case IMGFMT_BGR8:
109 case IMGFMT_BGR16:
110 case IMGFMT_BGR24:
111 case IMGFMT_BGR32:
112 // copy :( to agp_mem
113 // still faster than tdfxfb wich directly copy to the video mem :)
114 mem2agpcpy_pic(agp_mem + current_buffer * buffer_size +
115 y*buffer_stride[0] + x * src_bpp,
116 image[0],
117 src_bpp*w,h,buffer_stride[0],stride[0]);
118 return 0;
120 case IMGFMT_YV12:
121 case IMGFMT_I420:
122 // Copy to agp mem
123 ptr[0] = agp_mem + current_buffer * buffer_size;
124 mem2agpcpy_pic(ptr[0] + y * buffer_stride[0] + x,image[0],w,h,
125 buffer_stride[0],stride[0]);
126 ptr[1] = ptr[0] + (src_height*src_width);
127 mem2agpcpy_pic(ptr[1] + y/2 * buffer_stride[1] + x/2,image[1],w/2,h/2,
128 buffer_stride[1],stride[1]);
129 ptr[2] = ptr[1] + (src_height*src_width/4);
130 mem2agpcpy_pic(ptr[2] + y/2 * buffer_stride[2] + x/2,image[2],w/2,h/2,
131 buffer_stride[2],stride[2]);
132 return 0;
135 return 1;
138 static void draw_osd(void)
142 static void
143 flip_page(void)
145 tdfx_vid_blit_t blit;
146 //return;
147 // Scale convert
148 #ifdef VERBOSE
149 printf("Flip\n");
150 #endif
151 if(use_overlay) {
152 // TDFX_VID_OVERLAY_ON does nothing if the overlay is already on
153 if(!ioctl(tdfx_fd,TDFX_VID_OVERLAY_ON)) { // X11 killed the overlay :(
154 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&tdfx_ov))
155 mp_msg(MSGT_VO, MSGL_ERR, "tdfx_vid: set_overlay failed\n");
157 // These formats need conversion
158 switch(src_fmt) {
159 case IMGFMT_BGR8:
160 case IMGFMT_BGR24:
161 case IMGFMT_BGR32:
162 memset(&blit,0,sizeof(tdfx_vid_blit_t));
163 blit.src = back_buffer;
164 blit.src_stride = src_stride;
165 blit.src_x = 0;
166 blit.src_y = 0;
167 blit.src_w = src_width;
168 blit.src_h = src_height;
169 blit.src_format = src_fmt;
171 blit.dst = front_buffer;
172 blit.dst_stride = dst_stride;
173 blit.dst_x = 0;
174 blit.dst_y = 0;
175 blit.dst_w = src_width;
176 blit.dst_h = src_height;
177 blit.dst_format = IMGFMT_BGR16;
178 if(ioctl(tdfx_fd,TDFX_VID_BLIT,&blit))
179 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_BlitFailed);
181 return;
183 memset(&blit,0,sizeof(tdfx_vid_blit_t));
184 blit.src = back_buffer;
185 blit.src_stride = src_stride;
186 blit.src_x = 0;
187 blit.src_y = 0;
188 blit.src_w = src_width;
189 blit.src_h = src_height;
190 blit.src_format = src_fmt;
192 blit.dst = front_buffer;
193 blit.dst_stride = dst_stride;
194 blit.dst_x = 0;
195 blit.dst_y = 0;
196 blit.dst_w = dst_width;
197 blit.dst_h = dst_height;
198 blit.dst_format = dst_fmt;
200 if(ioctl(tdfx_fd,TDFX_VID_BLIT,&blit))
201 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_BlitFailed);
204 static int
205 draw_frame(uint8_t *src[])
207 int stride[] = { src_stride, 0, 0};
208 return draw_slice(src,stride,src_width, src_height,0,0);
211 static int
212 query_format(uint32_t format)
214 switch(format) {
215 case IMGFMT_BGR8:
216 if(tdfx_cfg.screen_format == TDFX_VID_FORMAT_BGR8)
217 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
218 return 0;
219 case IMGFMT_YUY2:
220 case IMGFMT_UYVY:
221 case IMGFMT_BGR15:
222 case IMGFMT_BGR16:
223 case IMGFMT_BGR24:
224 case IMGFMT_BGR32:
225 case IMGFMT_YV12:
226 case IMGFMT_I420:
227 if(tdfx_cfg.screen_format == TDFX_VID_FORMAT_BGR8)
228 return 0;
229 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
231 return 0;
234 static int
235 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
238 if(tdfx_fd < 0)
239 return 1;
240 // When we are run as sub vo we must follow the size gaven to us
241 if(!(flags & VOFLAG_XOVERLAY_SUB_VO)) {
242 if(!vo_screenwidth)
243 vo_screenwidth = tdfx_cfg.screen_width;
244 if(!vo_screenheight)
245 vo_screenheight = tdfx_cfg.screen_height;
247 aspect_save_orig(width,height);
248 aspect_save_prescale(d_width,d_height);
249 aspect_save_screenres(vo_screenwidth,vo_screenheight);
251 if(flags&VOFLAG_FULLSCREEN) { /* -fs */
252 aspect(&d_width,&d_height,A_ZOOM);
253 vo_fs = VO_TRUE;
254 } else {
255 aspect(&d_width,&d_height,A_NOZOOM);
256 vo_fs = VO_FALSE;
259 src_width = width;
260 src_height = height;
261 buffer_size = 0;
262 buffer_stride[0] = 0;
263 src_fmt = 0;
264 switch(format) {
265 case IMGFMT_BGR8:
266 case IMGFMT_BGR24:
267 case IMGFMT_BGR32:
268 if(use_overlay)
269 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_NonNativeOverlayFormatNeedConversion);
270 case IMGFMT_BGR15:
271 case IMGFMT_BGR16:
272 src_bpp = ((format & 0x3F)+7)/8;
273 break;
274 case IMGFMT_YV12:
275 case IMGFMT_I420:
276 buffer_size = src_width * src_height * 3 / 2;
277 buffer_stride[0] = ((src_width+1)/2)*2;
278 buffer_stride[1] = buffer_stride[2] = buffer_stride[0]/2;
279 src_fmt = TDFX_VID_FORMAT_YUY2;
280 case IMGFMT_YUY2:
281 case IMGFMT_UYVY:
282 src_bpp = 2;
283 break;
284 default:
285 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_UnsupportedInputFormat,format);
286 return 1;
289 img_fmt = format;
290 src_stride = src_width*src_bpp;
291 // The overlay need a 4 bytes aligned stride
292 if(use_overlay)
293 src_stride = ((src_stride+3)/4)*4;
294 if(!src_fmt)
295 src_fmt = format;
296 if(!buffer_size)
297 buffer_size = src_stride*src_height;
298 if(!buffer_stride[0])
299 buffer_stride[0] = src_stride;
301 dst_fmt = tdfx_cfg.screen_format;
302 dst_bpp = ((dst_fmt & 0x3F)+7)/8;
303 dst_width = d_width;
304 dst_height = d_height;
305 dst_stride = tdfx_cfg.screen_stride;
307 tdfx_page = tdfx_cfg.screen_stride*tdfx_cfg.screen_height;
308 front_buffer = tdfx_cfg.screen_start;
309 back_buffer = front_buffer + tdfx_page;
311 while(use_overlay) {
312 tdfx_vid_overlay_t ov;
313 uint32_t ov_fmt = src_fmt, ov_stride = src_stride;
314 // Align the buffer
315 back_buffer = (((back_buffer+3)/4)*4);
316 // With the overlay the front buffer is not on the screen
317 // so we take the back buffer
318 front_buffer = back_buffer;
319 switch(src_fmt) {
320 case IMGFMT_BGR8:
321 case IMGFMT_BGR24:
322 case IMGFMT_BGR32:
323 back_buffer = front_buffer + 2*(src_stride*src_height);
324 ov_stride = dst_stride = src_width<<1;
325 ov_fmt = IMGFMT_BGR16;
326 break;
328 ov.src[0] = front_buffer;
329 ov.src[1] = front_buffer + (src_stride*src_height);
330 ov.src_width = src_width;
331 ov.src_height = src_height;
332 ov.src_stride = ov_stride;
333 ov.format = ov_fmt;
334 ov.dst_width = dst_width;
335 ov.dst_height = dst_height;
336 ov.dst_x = vo_dx;
337 ov.dst_y = vo_dy;
338 ov.use_colorkey = 0;
340 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&ov)) {
341 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlaySetupFailed);
342 use_overlay = 0;
343 break;
345 tdfx_ov = ov;
346 if(use_overlay == 1) {
347 if(ioctl(tdfx_fd,TDFX_VID_OVERLAY_ON)) {
348 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlayOnFailed);
349 use_overlay = 0;
350 break;
352 use_overlay++;
355 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_OverlayReady,
356 src_width,src_stride,src_height,src_bpp,
357 dst_width,dst_stride,dst_height,dst_bpp);
358 break;
361 if(!use_overlay)
362 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_TextureBlitReady,
363 src_width,src_stride,src_height,src_bpp,
364 dst_width,dst_stride,dst_height,dst_bpp);
366 return 0;
369 static void
370 uninit(void)
372 if(use_overlay == 2) {
373 if(ioctl(tdfx_fd,TDFX_VID_OVERLAY_OFF))
374 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlayOffFailed);
375 use_overlay--;
377 close(tdfx_fd);
378 tdfx_fd = -1;
382 static void check_events(void)
386 static int preinit(const char *arg)
389 tdfx_fd = open(arg ? arg : "/dev/tdfx_vid", O_RDWR);
390 if(tdfx_fd < 0) {
391 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_CantOpen,arg ? arg : "/dev/tdfx_vid",
392 strerror(errno));
393 return 1;
396 if(ioctl(tdfx_fd,TDFX_VID_GET_CONFIG,&tdfx_cfg)) {
397 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_CantGetCurrentCfg,strerror(errno));
398 return 1;
401 mp_msg(MSGT_VO,MSGL_INFO, "tdfx_vid version %d\n"
402 " Ram: %d\n"
403 " Screen: %d x %d\n"
404 " Format: %c%c%c%d\n",
405 tdfx_cfg.version,
406 tdfx_cfg.ram_size,
407 tdfx_cfg.screen_width, tdfx_cfg.screen_height,
408 tdfx_cfg.screen_format>>24,(tdfx_cfg.screen_format>>16)&0xFF,
409 (tdfx_cfg.screen_format>>8)&0xFF,tdfx_cfg.screen_format&0xFF);
411 // For now just allocate more than i ever need
412 agp_mem = mmap( NULL, 1024*768*4, PROT_READ | PROT_WRITE, MAP_SHARED,
413 tdfx_fd, 0);
415 if(agp_mem == MAP_FAILED) {
416 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_MemmapFailed);
417 return 1;
420 memset(agp_mem,0,1024*768*4);
422 return 0;
425 static uint32_t get_image(mp_image_t *mpi) {
426 int buf = 0;
428 #ifdef VERBOSE
429 printf("Get image %d\n",buf);
430 #endif
432 // Currently read are too slow bcs we read from the
433 // agp aperture and not the memory directly
434 //if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE;
436 if(mpi->flags&MP_IMGFLAG_READABLE &&
437 (mpi->type==MP_IMGTYPE_IPB || mpi->type==MP_IMGTYPE_IP)){
438 // reference (I/P) frame of IP or IPB:
439 if(num_buffer<2) return VO_FALSE; // not enough
440 current_ip_buf^=1;
441 // for IPB with 2 buffers we can DR only one of the 2 P frames:
442 if(mpi->type==MP_IMGTYPE_IPB && num_buffer<3 && current_ip_buf) return VO_FALSE;
443 buf=current_ip_buf;
444 if(mpi->type==MP_IMGTYPE_IPB) ++buf; // preserve space for B
447 switch(mpi->imgfmt) {
448 case IMGFMT_YUY2:
449 case IMGFMT_UYVY:
450 case IMGFMT_BGR8:
451 case IMGFMT_BGR15:
452 case IMGFMT_BGR16:
453 case IMGFMT_BGR24:
454 case IMGFMT_BGR32:
455 mpi->planes[0] = agp_mem + buf * buffer_size;
456 mpi->stride[0] = src_stride;
457 break;
458 case IMGFMT_YV12:
459 case IMGFMT_I420:
460 mpi->planes[0] = agp_mem + buf * buffer_size;
461 mpi->stride[0] = mpi->width;
462 mpi->planes[1] = mpi->planes[0] + mpi->stride[0]*mpi->height;
463 mpi->stride[1] = mpi->chroma_width;
464 mpi->planes[2] = mpi->planes[1] + mpi->stride[1]*mpi->chroma_height;
465 mpi->stride[2] = mpi->chroma_width;
466 break;
467 default:
468 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_GetImageTodo);
469 return VO_FALSE;
471 mpi->flags |= MP_IMGFLAG_DIRECT;
472 mpi->priv = (void*)buf;
474 return VO_TRUE;
477 static uint32_t start_slice(mp_image_t *mpi){
478 int buf = 0;
480 #ifdef VERBOSE
481 printf("Start slices %d\n",buf);
482 #endif
484 if(mpi->flags & MP_IMGFLAG_DIRECT)
485 buf = (int)mpi->priv;
486 current_buffer = buf;
488 return VO_TRUE;
491 static uint32_t draw_image(mp_image_t *mpi){
492 int buf = 0;
493 tdfx_vid_agp_move_t mov;
494 tdfx_vid_yuv_t yuv;
495 int p;
496 uint8_t* planes[3];
498 #ifdef VERBOSE
499 printf("Draw image %d\n",buf);
500 #endif
502 if(mpi->flags & MP_IMGFLAG_DIRECT)
503 buf = (int)mpi->priv;
505 switch(mpi->imgfmt) {
506 case IMGFMT_YUY2:
507 case IMGFMT_UYVY:
508 case IMGFMT_BGR8:
509 case IMGFMT_BGR15:
510 case IMGFMT_BGR16:
511 case IMGFMT_BGR24:
512 case IMGFMT_BGR32:
513 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
514 // copy to agp_mem
515 #ifdef VERBOSE
516 printf("Memcpy\n");
517 #endif
518 planes[0] = agp_mem + buf * buffer_size;
519 mem2agpcpy_pic(planes[0],mpi->planes[0],src_bpp*mpi->width,mpi->height,
520 buffer_stride[0],mpi->stride[0]);
521 } else
522 planes[0] = agp_mem + buf * buffer_size;
524 mov.move2 = TDFX_VID_MOVE_2_PACKED;
525 mov.width = mpi->width*((mpi->bpp+7)/8);
526 mov.height = mpi->height;
527 mov.src = planes[0] - agp_mem;
528 mov.src_stride = buffer_stride[0];
530 mov.dst = back_buffer;
531 mov.dst_stride = src_stride;
533 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov))
534 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailed);
535 break;
537 case IMGFMT_YV12:
538 case IMGFMT_I420:
539 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
540 // Copy to agp mem
541 #ifdef VERBOSE
542 printf("Memcpy\n");
543 #endif
544 planes[0] = agp_mem + buf * buffer_size;
545 memcpy_pic(planes[0],mpi->planes[0],mpi->width,mpi->height,
546 buffer_stride[0],mpi->stride[0]);
547 planes[1] = planes[0] + (mpi->height*mpi->stride[0]);
548 memcpy_pic(planes[1],mpi->planes[1],mpi->chroma_width,mpi->chroma_height,
549 buffer_stride[1],mpi->stride[1]);
550 planes[2] = planes[1] + (mpi->chroma_height*mpi->stride[1]);
551 memcpy_pic(planes[2],mpi->planes[2],mpi->chroma_width,mpi->chroma_height,
552 buffer_stride[2],mpi->stride[2]);
553 } else {
554 planes[0] = agp_mem + buf * buffer_size;
555 planes[1] = planes[0] + buffer_stride[0] * src_height;
556 planes[2] = planes[1] + buffer_stride[1] * src_height/2;
559 // Setup the yuv thing
560 yuv.base = back_buffer;
561 yuv.stride = src_stride;
562 if(ioctl(tdfx_fd,TDFX_VID_SET_YUV,&yuv)) {
563 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_SetYuvFailed);
564 break;
568 // Now agp move that
569 // Y
570 mov.move2 = TDFX_VID_MOVE_2_YUV;
571 mov.width = mpi->width;
572 mov.height = mpi->height;
573 mov.src = planes[0] - agp_mem;
574 mov.src_stride = buffer_stride[0];
575 mov.dst = 0x0;
576 mov.dst_stride = TDFX_VID_YUV_STRIDE;
578 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
579 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnYPlane);
580 break;
582 //return 0;
583 // U
584 p = mpi->imgfmt == IMGFMT_YV12 ? 1 : 2;
585 mov.width = mpi->chroma_width;
586 mov.height = mpi->chroma_height;
587 mov.src = planes[p] - agp_mem;
588 mov.src_stride = buffer_stride[p];
589 mov.dst += TDFX_VID_YUV_PLANE_SIZE;
590 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
591 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnUPlane);
592 break;
594 // V
595 p = mpi->imgfmt == IMGFMT_YV12 ? 2 : 1;
596 mov.src = planes[p] - agp_mem;
597 mov.src_stride = buffer_stride[p];
598 mov.dst += TDFX_VID_YUV_PLANE_SIZE;
599 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
600 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnVPlane);
601 break;
603 break;
604 default:
605 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_UnknownFormat,mpi->imgfmt);
606 return VO_TRUE;
609 return VO_TRUE;
612 static uint32_t fullscreen(void) {
613 vo_fs ^= 1;
614 aspect(&dst_width,&dst_height,vo_fs ? A_ZOOM : A_NOZOOM);
615 // This does not work :((
616 //clear_screen();
617 return VO_TRUE;
620 static uint32_t set_window(mp_win_t* w) {
621 if(!use_overlay) return VO_FALSE;
623 tdfx_ov.dst_x = w->x;
624 tdfx_ov.dst_y = w->y;
625 tdfx_ov.dst_width = w->w;
626 tdfx_ov.dst_height = w->h;
628 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&tdfx_ov))
629 mp_msg(MSGT_VO, MSGL_V, "tdfx_vid: set window failed\n");
631 return VO_TRUE;
634 static uint32_t set_colorkey(mp_colorkey_t* colork) {
635 if(!use_overlay) return VO_FALSE;
637 tdfx_ov.colorkey[0] = tdfx_ov.colorkey[1] = colork->x11;
638 tdfx_ov.use_colorkey = 1;
639 tdfx_ov.invert_colorkey = 0;
641 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&tdfx_ov))
642 mp_msg(MSGT_VO, MSGL_V, "tdfx_vid: set colorkey failed\n");
644 return VO_TRUE;
647 static int control(uint32_t request, void *data, ...)
649 switch (request) {
650 case VOCTRL_QUERY_FORMAT:
651 return query_format(*((uint32_t*)data));
652 case VOCTRL_GET_IMAGE:
653 return get_image(data);
654 case VOCTRL_DRAW_IMAGE:
655 return draw_image(data);
656 case VOCTRL_START_SLICE:
657 return start_slice(data);
658 case VOCTRL_FULLSCREEN:
659 return fullscreen();
660 case VOCTRL_XOVERLAY_SUPPORT:
661 return VO_TRUE;
662 case VOCTRL_XOVERLAY_SET_COLORKEY:
663 return set_colorkey(data);
664 case VOCTRL_XOVERLAY_SET_WIN:
665 return set_window(data);
667 return VO_NOTIMPL;