typo fixes
[mplayer/greg.git] / libvo / vo_tdfx_vid.c
blob3401fc2ac8371a546d4dae70e7db3616eeb8c780
1 /*
2 * vo_tdfx_vid.c
4 * Copyright (C) Alban Bedel - 03/2003
6 * This file is part of MPlayer, a free movie player.
7 *
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
13 * MPlayer 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Make; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <errno.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <unistd.h>
32 #include <sys/ioctl.h>
33 #include <sys/mman.h>
34 #include "config.h"
35 #include "video_out.h"
36 #include "video_out_internal.h"
37 #include "aspect.h"
38 #include "mp_msg.h"
39 #include "help_mp.h"
41 #include "fastmemcpy.h"
42 #include "drivers/tdfx_vid.h"
45 static vo_info_t info =
47 "tdfx vid",
48 "tdfx_vid",
49 "Albeu",
53 //#define VERBOSE
55 LIBVO_EXTERN(tdfx_vid)
57 static tdfx_vid_config_t tdfx_cfg;
59 static unsigned char* agp_mem = NULL;
60 static int tdfx_fd = -1;
62 static uint32_t img_fmt; // The real input format
63 static uint32_t src_width, src_height, src_fmt, src_bpp, src_stride;
64 static uint32_t dst_width, dst_height, dst_fmt, dst_bpp, dst_stride;
66 static uint32_t tdfx_page;
67 static uint32_t front_buffer;
68 static uint32_t back_buffer;
69 static uint8_t num_buffer = 3;
70 static uint32_t buffer_size; // Max size
71 static uint8_t current_buffer = 0;
72 static uint8_t current_ip_buf = 0;
73 static uint32_t buffer_stride[3];
75 static int use_overlay = 1;
76 static tdfx_vid_overlay_t tdfx_ov;
78 // FIXME
79 static void clear_screen(void) {
80 tdfx_vid_agp_move_t mov;
82 memset(agp_mem,0,tdfx_cfg.screen_width*dst_bpp*tdfx_cfg.screen_height);
84 mov.move2 = TDFX_VID_MOVE_2_PACKED;
85 mov.width = tdfx_cfg.screen_width*dst_bpp;
86 mov.height = tdfx_cfg.screen_height;
87 mov.src = 0;
88 mov.src_stride = tdfx_cfg.screen_width*dst_bpp;
89 mov.dst = front_buffer;
90 mov.dst_stride = tdfx_cfg.screen_stride;
92 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_Move, mov.width,mov.src_stride,mov.height,mov.dst_stride);
94 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov))
95 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AGPMoveFailedToClearTheScreen);
99 static int draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
101 uint8_t* ptr[3];
103 #ifdef VERBOSE
104 printf("Draw slices %d\n",current_buffer);
105 #endif
106 switch(img_fmt) {
107 case IMGFMT_YUY2:
108 case IMGFMT_UYVY:
109 case IMGFMT_BGR8:
110 case IMGFMT_BGR16:
111 case IMGFMT_BGR24:
112 case IMGFMT_BGR32:
113 // copy :( to agp_mem
114 // still faster than tdfxfb wich directly copy to the video mem :)
115 mem2agpcpy_pic(agp_mem + current_buffer * buffer_size +
116 y*buffer_stride[0] + x * src_bpp,
117 image[0],
118 src_bpp*w,h,buffer_stride[0],stride[0]);
119 return 0;
121 case IMGFMT_YV12:
122 case IMGFMT_I420:
123 // Copy to agp mem
124 ptr[0] = agp_mem + current_buffer * buffer_size;
125 mem2agpcpy_pic(ptr[0] + y * buffer_stride[0] + x,image[0],w,h,
126 buffer_stride[0],stride[0]);
127 ptr[1] = ptr[0] + (src_height*src_width);
128 mem2agpcpy_pic(ptr[1] + y/2 * buffer_stride[1] + x/2,image[1],w/2,h/2,
129 buffer_stride[1],stride[1]);
130 ptr[2] = ptr[1] + (src_height*src_width/4);
131 mem2agpcpy_pic(ptr[2] + y/2 * buffer_stride[2] + x/2,image[2],w/2,h/2,
132 buffer_stride[2],stride[2]);
133 return 0;
136 return 1;
139 static void draw_osd(void)
143 static void
144 flip_page(void)
146 tdfx_vid_blit_t blit;
147 //return;
148 // Scale convert
149 #ifdef VERBOSE
150 printf("Flip\n");
151 #endif
152 if(use_overlay) {
153 // TDFX_VID_OVERLAY_ON does nothing if the overlay is alredy on
154 if(!ioctl(tdfx_fd,TDFX_VID_OVERLAY_ON)) { // X11 killed the overlay :(
155 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&tdfx_ov))
156 mp_msg(MSGT_VO, MSGL_ERR, "tdfx_vid: set_overlay failed\n");
158 // These formats need conversion
159 switch(src_fmt) {
160 case IMGFMT_BGR8:
161 case IMGFMT_BGR24:
162 case IMGFMT_BGR32:
163 memset(&blit,0,sizeof(tdfx_vid_blit_t));
164 blit.src = back_buffer;
165 blit.src_stride = src_stride;
166 blit.src_x = 0;
167 blit.src_y = 0;
168 blit.src_w = src_width;
169 blit.src_h = src_height;
170 blit.src_format = src_fmt;
172 blit.dst = front_buffer;
173 blit.dst_stride = dst_stride;
174 blit.dst_x = 0;
175 blit.dst_y = 0;
176 blit.dst_w = src_width;
177 blit.dst_h = src_height;
178 blit.dst_format = IMGFMT_BGR16;
179 if(ioctl(tdfx_fd,TDFX_VID_BLIT,&blit))
180 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_BlitFailed);
182 return;
184 memset(&blit,0,sizeof(tdfx_vid_blit_t));
185 blit.src = back_buffer;
186 blit.src_stride = src_stride;
187 blit.src_x = 0;
188 blit.src_y = 0;
189 blit.src_w = src_width;
190 blit.src_h = src_height;
191 blit.src_format = src_fmt;
193 blit.dst = front_buffer;
194 blit.dst_stride = dst_stride;
195 blit.dst_x = 0;
196 blit.dst_y = 0;
197 blit.dst_w = dst_width;
198 blit.dst_h = dst_height;
199 blit.dst_format = dst_fmt;
201 if(ioctl(tdfx_fd,TDFX_VID_BLIT,&blit))
202 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_BlitFailed);
205 static int
206 draw_frame(uint8_t *src[])
208 int stride[] = { src_stride, 0, 0};
209 return draw_slice(src,stride,src_width, src_height,0,0);
212 static int
213 query_format(uint32_t format)
215 switch(format) {
216 case IMGFMT_BGR8:
217 if(tdfx_cfg.screen_format == TDFX_VID_FORMAT_BGR8)
218 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
219 return 0;
220 case IMGFMT_YUY2:
221 case IMGFMT_UYVY:
222 case IMGFMT_BGR15:
223 case IMGFMT_BGR16:
224 case IMGFMT_BGR24:
225 case IMGFMT_BGR32:
226 case IMGFMT_YV12:
227 case IMGFMT_I420:
228 if(tdfx_cfg.screen_format == TDFX_VID_FORMAT_BGR8)
229 return 0;
230 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
232 return 0;
235 static int
236 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
239 if(tdfx_fd < 0)
240 return 1;
241 // When we are run as sub vo we must follow the size gaven to us
242 if(!(flags & VOFLAG_XOVERLAY_SUB_VO)) {
243 if(!vo_screenwidth)
244 vo_screenwidth = tdfx_cfg.screen_width;
245 if(!vo_screenheight)
246 vo_screenheight = tdfx_cfg.screen_height;
248 aspect_save_orig(width,height);
249 aspect_save_prescale(d_width,d_height);
250 aspect_save_screenres(vo_screenwidth,vo_screenheight);
252 if(flags&VOFLAG_FULLSCREEN) { /* -fs */
253 aspect(&d_width,&d_height,A_ZOOM);
254 vo_fs = VO_TRUE;
255 } else {
256 aspect(&d_width,&d_height,A_NOZOOM);
257 vo_fs = VO_FALSE;
260 src_width = width;
261 src_height = height;
262 buffer_size = 0;
263 buffer_stride[0] = 0;
264 src_fmt = 0;
265 switch(format) {
266 case IMGFMT_BGR8:
267 case IMGFMT_BGR24:
268 case IMGFMT_BGR32:
269 if(use_overlay)
270 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_NonNativeOverlayFormatNeedConversion);
271 case IMGFMT_BGR15:
272 case IMGFMT_BGR16:
273 src_bpp = ((format & 0x3F)+7)/8;
274 break;
275 case IMGFMT_YV12:
276 case IMGFMT_I420:
277 buffer_size = src_width * src_height * 3 / 2;
278 buffer_stride[0] = ((src_width+1)/2)*2;
279 buffer_stride[1] = buffer_stride[2] = buffer_stride[0]/2;
280 src_fmt = TDFX_VID_FORMAT_YUY2;
281 case IMGFMT_YUY2:
282 case IMGFMT_UYVY:
283 src_bpp = 2;
284 break;
285 default:
286 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_UnsupportedInputFormat,format);
287 return 1;
290 img_fmt = format;
291 src_stride = src_width*src_bpp;
292 // The overlay need a 4 bytes aligned stride
293 if(use_overlay)
294 src_stride = ((src_stride+3)/4)*4;
295 if(!src_fmt)
296 src_fmt = format;
297 if(!buffer_size)
298 buffer_size = src_stride*src_height;
299 if(!buffer_stride[0])
300 buffer_stride[0] = src_stride;
302 dst_fmt = tdfx_cfg.screen_format;
303 dst_bpp = ((dst_fmt & 0x3F)+7)/8;
304 dst_width = d_width;
305 dst_height = d_height;
306 dst_stride = tdfx_cfg.screen_stride;
308 tdfx_page = tdfx_cfg.screen_stride*tdfx_cfg.screen_height;
309 front_buffer = tdfx_cfg.screen_start;
310 back_buffer = front_buffer + tdfx_page;
312 while(use_overlay) {
313 tdfx_vid_overlay_t ov;
314 uint32_t ov_fmt = src_fmt, ov_stride = src_stride;
315 // Align the buffer
316 back_buffer = (((back_buffer+3)/4)*4);
317 // With the overlay the front buffer is not on the screen
318 // so we take the back buffer
319 front_buffer = back_buffer;
320 switch(src_fmt) {
321 case IMGFMT_BGR8:
322 case IMGFMT_BGR24:
323 case IMGFMT_BGR32:
324 back_buffer = front_buffer + 2*(src_stride*src_height);
325 ov_stride = dst_stride = src_width<<1;
326 ov_fmt = IMGFMT_BGR16;
327 break;
329 ov.src[0] = front_buffer;
330 ov.src[1] = front_buffer + (src_stride*src_height);
331 ov.src_width = src_width;
332 ov.src_height = src_height;
333 ov.src_stride = ov_stride;
334 ov.format = ov_fmt;
335 ov.dst_width = dst_width;
336 ov.dst_height = dst_height;
337 ov.dst_x = vo_dx;
338 ov.dst_y = vo_dy;
339 ov.use_colorkey = 0;
341 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&ov)) {
342 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlaySetupFailed);
343 use_overlay = 0;
344 break;
346 tdfx_ov = ov;
347 if(use_overlay == 1) {
348 if(ioctl(tdfx_fd,TDFX_VID_OVERLAY_ON)) {
349 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlayOnFailed);
350 use_overlay = 0;
351 break;
353 use_overlay++;
356 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_OverlayReady,
357 src_width,src_stride,src_height,src_bpp,
358 dst_width,dst_stride,dst_height,dst_bpp);
359 break;
362 if(!use_overlay)
363 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXVID_TextureBlitReady,
364 src_width,src_stride,src_height,src_bpp,
365 dst_width,dst_stride,dst_height,dst_bpp);
367 return 0;
370 static void
371 uninit(void)
373 if(use_overlay == 2) {
374 if(ioctl(tdfx_fd,TDFX_VID_OVERLAY_OFF))
375 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_OverlayOffFailed);
376 use_overlay--;
378 close(tdfx_fd);
379 tdfx_fd = -1;
383 static void check_events(void)
387 static int preinit(const char *arg)
390 tdfx_fd = open(arg ? arg : "/dev/tdfx_vid", O_RDWR);
391 if(tdfx_fd < 0) {
392 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_CantOpen,arg ? arg : "/dev/tdfx_vid",
393 strerror(errno));
394 return 1;
397 if(ioctl(tdfx_fd,TDFX_VID_GET_CONFIG,&tdfx_cfg)) {
398 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_CantGetCurrentCfg,strerror(errno));
399 return 1;
402 mp_msg(MSGT_VO,MSGL_INFO, "tdfx_vid version %d\n"
403 " Ram: %d\n"
404 " Screen: %d x %d\n"
405 " Format: %c%c%c%d\n",
406 tdfx_cfg.version,
407 tdfx_cfg.ram_size,
408 tdfx_cfg.screen_width, tdfx_cfg.screen_height,
409 tdfx_cfg.screen_format>>24,(tdfx_cfg.screen_format>>16)&0xFF,
410 (tdfx_cfg.screen_format>>8)&0xFF,tdfx_cfg.screen_format&0xFF);
412 // For now just allocate more than i ever need
413 agp_mem = mmap( NULL, 1024*768*4, PROT_READ | PROT_WRITE, MAP_SHARED,
414 tdfx_fd, 0);
416 if(agp_mem == MAP_FAILED) {
417 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_MemmapFailed);
418 return 1;
421 memset(agp_mem,0,1024*768*4);
423 return 0;
426 static uint32_t get_image(mp_image_t *mpi) {
427 int buf = 0;
429 #ifdef VERBOSE
430 printf("Get image %d\n",buf);
431 #endif
433 // Currently read are too slow bcs we read from the
434 // agp aperture and not the memory directly
435 //if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE;
437 if(mpi->flags&MP_IMGFLAG_READABLE &&
438 (mpi->type==MP_IMGTYPE_IPB || mpi->type==MP_IMGTYPE_IP)){
439 // reference (I/P) frame of IP or IPB:
440 if(num_buffer<2) return VO_FALSE; // not enough
441 current_ip_buf^=1;
442 // for IPB with 2 buffers we can DR only one of the 2 P frames:
443 if(mpi->type==MP_IMGTYPE_IPB && num_buffer<3 && current_ip_buf) return VO_FALSE;
444 buf=current_ip_buf;
445 if(mpi->type==MP_IMGTYPE_IPB) ++buf; // preserve space for B
448 switch(mpi->imgfmt) {
449 case IMGFMT_YUY2:
450 case IMGFMT_UYVY:
451 case IMGFMT_BGR8:
452 case IMGFMT_BGR15:
453 case IMGFMT_BGR16:
454 case IMGFMT_BGR24:
455 case IMGFMT_BGR32:
456 mpi->planes[0] = agp_mem + buf * buffer_size;
457 mpi->stride[0] = src_stride;
458 break;
459 case IMGFMT_YV12:
460 case IMGFMT_I420:
461 mpi->planes[0] = agp_mem + buf * buffer_size;
462 mpi->stride[0] = mpi->width;
463 mpi->planes[1] = mpi->planes[0] + mpi->stride[0]*mpi->height;
464 mpi->stride[1] = mpi->chroma_width;
465 mpi->planes[2] = mpi->planes[1] + mpi->stride[1]*mpi->chroma_height;
466 mpi->stride[2] = mpi->chroma_width;
467 break;
468 default:
469 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_GetImageTodo);
470 return VO_FALSE;
472 mpi->flags |= MP_IMGFLAG_DIRECT;
473 mpi->priv = (void*)buf;
475 return VO_TRUE;
478 static uint32_t start_slice(mp_image_t *mpi){
479 int buf = 0;
481 #ifdef VERBOSE
482 printf("Start slices %d\n",buf);
483 #endif
485 if(mpi->flags & MP_IMGFLAG_DIRECT)
486 buf = (int)mpi->priv;
487 current_buffer = buf;
489 return VO_TRUE;
492 static uint32_t draw_image(mp_image_t *mpi){
493 int buf = 0;
494 tdfx_vid_agp_move_t mov;
495 tdfx_vid_yuv_t yuv;
496 int p;
497 uint8_t* planes[3];
498 int stride[3];
500 #ifdef VERBOSE
501 printf("Draw image %d\n",buf);
502 #endif
504 if(mpi->flags & MP_IMGFLAG_DIRECT)
505 buf = (int)mpi->priv;
507 switch(mpi->imgfmt) {
508 case IMGFMT_YUY2:
509 case IMGFMT_UYVY:
510 case IMGFMT_BGR8:
511 case IMGFMT_BGR15:
512 case IMGFMT_BGR16:
513 case IMGFMT_BGR24:
514 case IMGFMT_BGR32:
515 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
516 // copy to agp_mem
517 #ifdef VERBOSE
518 printf("Memcpy\n");
519 #endif
520 planes[0] = agp_mem + buf * buffer_size;
521 mem2agpcpy_pic(planes[0],mpi->planes[0],src_bpp*mpi->width,mpi->height,
522 buffer_stride[0],mpi->stride[0]);
523 } else
524 planes[0] = agp_mem + buf * buffer_size;
526 mov.move2 = TDFX_VID_MOVE_2_PACKED;
527 mov.width = mpi->width*((mpi->bpp+7)/8);
528 mov.height = mpi->height;
529 mov.src = planes[0] - agp_mem;
530 mov.src_stride = buffer_stride[0];
532 mov.dst = back_buffer;
533 mov.dst_stride = src_stride;
535 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov))
536 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailed);
537 break;
539 case IMGFMT_YV12:
540 case IMGFMT_I420:
541 if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))) {
542 // Copy to agp mem
543 #ifdef VERBOSE
544 printf("Memcpy\n");
545 #endif
546 planes[0] = agp_mem + buf * buffer_size;
547 memcpy_pic(planes[0],mpi->planes[0],mpi->width,mpi->height,
548 buffer_stride[0],mpi->stride[0]);
549 planes[1] = planes[0] + (mpi->height*mpi->stride[0]);
550 memcpy_pic(planes[1],mpi->planes[1],mpi->chroma_width,mpi->chroma_height,
551 buffer_stride[1],mpi->stride[1]);
552 planes[2] = planes[1] + (mpi->chroma_height*mpi->stride[1]);
553 memcpy_pic(planes[2],mpi->planes[2],mpi->chroma_width,mpi->chroma_height,
554 buffer_stride[2],mpi->stride[2]);
555 } else {
556 planes[0] = agp_mem + buf * buffer_size;
557 planes[1] = planes[0] + buffer_stride[0] * src_height;
558 planes[2] = planes[1] + buffer_stride[1] * src_height/2;
561 // Setup the yuv thing
562 yuv.base = back_buffer;
563 yuv.stride = src_stride;
564 if(ioctl(tdfx_fd,TDFX_VID_SET_YUV,&yuv)) {
565 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_SetYuvFailed);
566 break;
570 // Now agp move that
571 // Y
572 mov.move2 = TDFX_VID_MOVE_2_YUV;
573 mov.width = mpi->width;
574 mov.height = mpi->height;
575 mov.src = planes[0] - agp_mem;
576 mov.src_stride = buffer_stride[0];
577 mov.dst = 0x0;
578 mov.dst_stride = TDFX_VID_YUV_STRIDE;
580 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
581 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnYPlane);
582 break;
584 //return 0;
585 // U
586 p = mpi->imgfmt == IMGFMT_YV12 ? 1 : 2;
587 mov.width = mpi->chroma_width;
588 mov.height = mpi->chroma_height;
589 mov.src = planes[p] - agp_mem;
590 mov.src_stride = buffer_stride[p];
591 mov.dst += TDFX_VID_YUV_PLANE_SIZE;
592 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
593 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnUPlane);
594 break;
596 // V
597 p = mpi->imgfmt == IMGFMT_YV12 ? 2 : 1;
598 mov.src = planes[p] - agp_mem;
599 mov.src_stride = buffer_stride[p];
600 mov.dst += TDFX_VID_YUV_PLANE_SIZE;
601 if(ioctl(tdfx_fd,TDFX_VID_AGP_MOVE,&mov)) {
602 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_AgpMoveFailedOnVPlane);
603 break;
605 break;
606 default:
607 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_TDFXVID_UnknownFormat,mpi->imgfmt);
608 return VO_TRUE;
611 return VO_TRUE;
614 static uint32_t fullscreen(void) {
615 vo_fs ^= 1;
616 aspect(&dst_width,&dst_height,vo_fs ? A_ZOOM : A_NOZOOM);
617 // This does not work :((
618 //clear_screen();
619 return VO_TRUE;
622 static uint32_t set_window(mp_win_t* w) {
623 if(!use_overlay) return VO_FALSE;
625 tdfx_ov.dst_x = w->x;
626 tdfx_ov.dst_y = w->y;
627 tdfx_ov.dst_width = w->w;
628 tdfx_ov.dst_height = w->h;
630 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&tdfx_ov))
631 mp_msg(MSGT_VO, MSGL_V, "tdfx_vid: set window failed\n");
633 return VO_TRUE;
636 static uint32_t set_colorkey(mp_colorkey_t* colork) {
637 if(!use_overlay) return VO_FALSE;
639 tdfx_ov.colorkey[0] = tdfx_ov.colorkey[1] = colork->x11;
640 tdfx_ov.use_colorkey = 1;
641 tdfx_ov.invert_colorkey = 0;
643 if(ioctl(tdfx_fd,TDFX_VID_SET_OVERLAY,&tdfx_ov))
644 mp_msg(MSGT_VO, MSGL_V, "tdfx_vid: set colorkey failed\n");
646 return VO_TRUE;
649 static int control(uint32_t request, void *data, ...)
651 switch (request) {
652 case VOCTRL_QUERY_FORMAT:
653 return query_format(*((uint32_t*)data));
654 case VOCTRL_GET_IMAGE:
655 return get_image(data);
656 case VOCTRL_DRAW_IMAGE:
657 return draw_image(data);
658 case VOCTRL_START_SLICE:
659 return start_slice(data);
660 case VOCTRL_FULLSCREEN:
661 return fullscreen();
662 case VOCTRL_XOVERLAY_SUPPORT:
663 return VO_TRUE;
664 case VOCTRL_XOVERLAY_SET_COLORKEY:
665 return set_colorkey(data);
666 case VOCTRL_XOVERLAY_SET_WIN:
667 return set_window(data);
669 return VO_NOTIMPL;