Mercurial > mplayer.hg
changeset 7708:c1e8287f9574
Use the common aspect code
Better preinint, fix the dr with planar format
uyvy support
author | albeu |
---|---|
date | Thu, 10 Oct 2002 14:17:59 +0000 |
parents | b3c7c62c106c |
children | a164381ae537 |
files | libvo/vo_tdfxfb.c |
diffstat | 1 files changed, 60 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/vo_tdfxfb.c Thu Oct 10 14:11:06 2002 +0000 +++ b/libvo/vo_tdfxfb.c Thu Oct 10 14:17:59 2002 +0000 @@ -28,6 +28,8 @@ #include <stdio.h> #include <stdlib.h> #include <errno.h> +#include <string.h> +#include <unistd.h> #include <sys/ioctl.h> #include <fcntl.h> #include <sys/mman.h> @@ -38,6 +40,7 @@ #include "video_out.h" #include "video_out_internal.h" #include "drivers/3dfx.h" +#include "aspect.h" LIBVO_EXTERN(tdfxfb) @@ -45,7 +48,7 @@ { "3Dfx Banshee/Voodoo3/Voodoo5", "tdfxfb", - "Mark Zealey <mark@zealos.org>" + "Mark Zealey <mark@zealos.org>", "" }; @@ -62,13 +65,13 @@ char V[0x0100000]; }; -static int fd; +static int fd = -1; static struct fb_fix_screeninfo fb_finfo; static struct fb_var_screeninfo fb_vinfo; static uint32_t in_width, in_height, in_format, in_depth, in_voodoo_format, screenwidth, screenheight, screendepth, vidwidth, vidheight, vidx, vidy, vid_voodoo_format, *vidpage, *hidpage, *inpage, vidpageoffset, - hidpageoffset, inpageoffset, *memBase0, *memBase1, fs, r_width, r_height; + hidpageoffset, inpageoffset, *memBase0 = NULL, *memBase1 = NULL, r_width, r_height; static volatile voodoo_io_reg *reg_IO; static voodoo_2d_reg *reg_2d; static voodoo_yuv_reg *reg_YUV; @@ -79,7 +82,9 @@ { char *name; - if(!(name = getenv("FRAMEBUFFER"))) + if(arg) + name = (char*)arg; + else if(!(name = getenv("FRAMEBUFFER"))) name = "/dev/fb0"; if((fd = open(name, O_RDWR)) == -1) { @@ -90,12 +95,16 @@ if(ioctl(fd, FBIOGET_FSCREENINFO, &fb_finfo)) { printf("tdfxfb: problem with FBITGET_FSCREENINFO ioctl: %s\n", strerror(errno)); + close(fd); + fd = -1; return -1; } if(ioctl(fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { printf("tdfxfb: problem with FBITGET_VSCREENINFO ioctl: %s\n", strerror(errno)); + close(fd); + fd = -1; return -1; } @@ -103,9 +112,24 @@ if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) { printf("tdfxfb: This driver is only supports the 3Dfx Banshee," " Voodoo3 and Voodoo 5\n"); + close(fd); + fd = -1; return -1; } + // Check the depth now as config() musn't fail + switch(fb_vinfo.bits_per_pixel) { + case 16: + case 24: + case 32: + break; // Ok + default: + printf("tdfxfb: %d bpp output is not supported\n", fb_vinfo.bits_per_pixel); + close(fd); + fd = -1; + return -1; + } + /* Open up a window to the hardware */ memBase1 = mmap(0, fb_finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); @@ -114,6 +138,11 @@ if((long)memBase0 == -1 || (long)memBase1 == -1) { printf("tdfxfb: Couldn't map memory areas: %s\n", strerror(errno)); + if((long)memBase0 != -1) + munmap(memBase0, fb_finfo.smem_len); + if((long)memBase1 != -1) + munmap(memBase1, fb_finfo.smem_len); + memBase0 = memBase1 = NULL; return -1; } @@ -171,29 +200,14 @@ /* Setup output screen dimensions etc */ static void setup_screen(uint32_t full) { - fs = full; - - if(fs) { /* Full screen */ - double ratio = (double)in_width / in_height; - vidwidth = screenwidth; - vidheight = screenheight; - - if(screenwidth / ratio <= screenheight) - vidheight = (double)screenwidth / ratio; - else - vidwidth = (double)screenheight * ratio; + vo_fs = full; - vidx = (screenwidth - vidwidth) / 2; - vidy = (screenheight - vidheight) / 2; - } else { /* Reset to normal size */ - if(r_width > screenwidth || r_height > screenheight) - printf("tdfxfb: your resolution is too small to display " - "the whole movie...\n"); - - vidwidth = r_width; - vidheight = r_height; - vidx = vidy = 0; - } + aspect(&vidwidth,&vidheight, vo_fs ? A_ZOOM : A_NOZOOM); + if(vo_fs) { + vidx = (screenwidth - vidwidth) / 2; + vidy = (screenheight - vidheight) / 2; + } else + vidx = vidy = 0; clear_screen(); } @@ -203,13 +217,16 @@ { screenwidth = fb_vinfo.xres; screenheight = fb_vinfo.yres; + aspect_save_screenres(fb_vinfo.xres,fb_vinfo.yres); in_width = width; in_height = height; in_format = format; + aspect_save_orig(width,height); r_width = d_width; r_height = d_height; + aspect_save_prescale(d_width,d_height); /* Setup the screen for rendering to */ switch(fb_vinfo.bits_per_pixel) { @@ -232,7 +249,7 @@ break; default: - printf("tdfxfb: %d bpp output is not supported\n", fb_vinfo.bits_per_pixel); + printf("tdfxfb: %d bpp output is not supported (This should never happend)\n", fb_vinfo.bits_per_pixel); return -1; } @@ -249,7 +266,9 @@ case IMGFMT_IYUV: case IMGFMT_YUY2: break; - + case IMGFMT_UYVY: + in_voodoo_format = VOODOO_BLT_FORMAT_UYVY; + break; case IMGFMT_BGR16: in_voodoo_format = VOODOO_BLT_FORMAT_16; alpha_func = vo_draw_alpha_rgb16; @@ -424,16 +443,20 @@ /* Attempt to start doing DR */ static uint32_t get_image(mp_image_t *mpi) { - static int enabled = 0; - if(!enabled && mpi->flags & MP_IMGFLAG_READABLE) /* slow video ram */ - return VO_FALSE; + if(mpi->flags & MP_IMGFLAG_READABLE) + return VO_FALSE; + if(mpi->type == MP_IMGTYPE_STATIC && vo_doublebuffering) + return VO_FALSE; + if(mpi->type > MP_IMGTYPE_TEMP) + return VO_FALSE; // TODO ?? switch(in_format) { case IMGFMT_YUY2: case IMGFMT_BGR16: case IMGFMT_BGR24: case IMGFMT_BGR32: + case IMGFMT_UYVY: mpi->planes[0] = (char *)inpage; mpi->stride[0] = in_width * in_depth; break; @@ -441,25 +464,20 @@ case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_IYUV: - if(!enabled) - if(!(mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE)) - return VO_FALSE; - + if(!(mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) && mpi->w != YUV_STRIDE) + return VO_FALSE; mpi->planes[0] = YUV->Y; mpi->planes[1] = YUV->U; mpi->planes[2] = YUV->V; mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = YUV_STRIDE; + reg_YUV->yuvBaseAddr = inpageoffset; + reg_YUV->yuvStride = in_width * in_depth; break; default: return VO_FALSE; } - if(!enabled) { - printf("tdfxfb: get_image() SUCCESS -> Direct Rendering ENABLED\n"); - enabled = 1; - } - mpi->width = in_width; mpi->flags |= MP_IMGFLAG_DIRECT; @@ -478,6 +496,7 @@ case IMGFMT_I420: case IMGFMT_IYUV: case IMGFMT_YUY2: + case IMGFMT_UYVY: case IMGFMT_BGR16: case IMGFMT_BGR24: case IMGFMT_BGR32: @@ -488,7 +507,7 @@ return 0; /* Not supported */ case VOCTRL_FULLSCREEN: - setup_screen(!fs); + setup_screen(!vo_fs); return 0; }