/* * vo_vesa interface to Linux Video Overlay * (partly based on vo_mga.c) * * copyright (C) 2001 Nick Kurshev * * This file is part of MPlayer. * * MPlayer is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MPlayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with MPlayer; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include #include #include #include #include "config.h" #include "mp_msg.h" #include "vesa_lvo.h" #include "libmpcodecs/img_format.h" #include "drivers/mga_vid.h" /* <- should be changed to "linux/'something'.h" */ #include "fastmemcpy.h" #include "osd.h" #include "video_out.h" #include "sub.h" #include "libmpcodecs/vfcap.h" #define WIDTH_ALIGN 32 /* should be 16 for rage:422 and 32 for rage:420 */ #define NUM_FRAMES 10 static uint8_t *frames[NUM_FRAMES]; static int lvo_handler = -1; static uint8_t *lvo_mem = NULL; static uint8_t next_frame; static mga_vid_config_t mga_vid_config; static unsigned image_bpp,image_height,image_width,src_format; int vlvo_control(uint32_t request, void *data); #define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8) #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) #define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size)) int vlvo_init(unsigned src_width,unsigned src_height, unsigned x_org,unsigned y_org,unsigned dst_width, unsigned dst_height,unsigned format,unsigned dest_bpp) { size_t i,awidth; mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVO] This branch is no longer supported.\n[VESA_LVO] Please use -vo vesa:vidix instead.\n"); return -1; if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { mp_msg(MSGT_VO,MSGL_DBG2, "vesa_lvo: vlvo_init() was called\n");} image_width = src_width; image_height = src_height; mga_vid_config.version=MGA_VID_VERSION; src_format = mga_vid_config.format=format; awidth = (src_width + (WIDTH_ALIGN-1)) & ~(WIDTH_ALIGN-1); switch(format){ case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: image_bpp=16; mga_vid_config.frame_size = awidth*src_height+(awidth*src_height)/2; break; case IMGFMT_YUY2: case IMGFMT_UYVY: image_bpp=16; mga_vid_config.frame_size = awidth*src_height*2; break; case IMGFMT_RGB15: case IMGFMT_BGR15: case IMGFMT_RGB16: case IMGFMT_BGR16: image_bpp=16; mga_vid_config.frame_size = awidth*src_height*2; break; case IMGFMT_RGB24: case IMGFMT_BGR24: image_bpp=24; mga_vid_config.frame_size = awidth*src_height*3; break; case IMGFMT_RGB32: case IMGFMT_BGR32: image_bpp=32; mga_vid_config.frame_size = awidth*src_height*4; break; default: mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVI] Invalid output format: %s(%0X)\n",vo_format_name(format),format); return -1; } mga_vid_config.colkey_on=0; mga_vid_config.src_width = src_width; mga_vid_config.src_height= src_height; mga_vid_config.dest_width = dst_width; mga_vid_config.dest_height= dst_height; mga_vid_config.x_org=x_org; mga_vid_config.y_org=y_org; mga_vid_config.num_frames=NUM_FRAMES; if (ioctl(lvo_handler,MGA_VID_CONFIG,&mga_vid_config)) { perror("vesa_lvo: Error in mga_vid_config ioctl()"); mp_tmsg(MSGT_VO,MSGL_WARN, "[VESA_LVO] Your fb_vid driver version is incompatible with this MPlayer version!\n"); return -1; } ioctl(lvo_handler,MGA_VID_ON,0); frames[0] = (char*)mmap(0,mga_vid_config.frame_size*mga_vid_config.num_frames,PROT_WRITE,MAP_SHARED,lvo_handler,0); for(i=1;i