2008-09-07 16:09:51 +02:00
|
|
|
/*
|
|
|
|
* copyright (C) 2002 Mark Zealey <mark@zealos.org>
|
2001-09-27 14:23:54 +02:00
|
|
|
*
|
2008-09-07 16:09:51 +02:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2002-04-09 16:02:55 +02:00
|
|
|
* 30/03/02: An almost total rewrite, added DR support and support for modes
|
|
|
|
* other than 16bpp. Fixed the crash when playing multiple files
|
|
|
|
* 07/04/02: Fixed DR support, added YUY2 support, fixed OSD stuff.
|
|
|
|
* 08/04/02: Fixed a wierd sound corruption problem caused by some optomizations
|
|
|
|
* I made.
|
2002-04-11 23:43:09 +02:00
|
|
|
* 09/04/02: Fixed a problem with changing the variables passed to draw_slice().
|
|
|
|
* Fixed DR support for YV12 et al. Added BGR support. Removed lots of dud code.
|
|
|
|
* 10/04/02: Changed the memcpy functions to mem2agpcpy.. should be a tad
|
|
|
|
* faster.
|
|
|
|
* 11/04/02: Added a compile option so you can watch the film with the console
|
|
|
|
* as the background, or not.
|
2002-04-13 01:55:06 +02:00
|
|
|
* 13/04/02: Fix rough OSD stuff by rendering it straight onto the output
|
2002-04-13 02:14:59 +02:00
|
|
|
* buffer. Added double-buffering. Supports hardware zoom/reduce zoom modes.
|
2002-04-13 12:04:22 +02:00
|
|
|
* 13/04/02: Misc cleanups of the code.
|
2002-10-23 18:52:54 +02:00
|
|
|
* 22/10/02: Added geometry support to it
|
2001-09-27 14:23:54 +02:00
|
|
|
*
|
2002-04-11 23:43:09 +02:00
|
|
|
* Hints and tricks:
|
|
|
|
* - Use -dr to get direct rendering
|
2003-10-25 20:44:41 +02:00
|
|
|
* - Use -vf yuy2 to get yuy2 rendering, *MUCH* faster than yv12
|
2002-04-13 02:14:59 +02:00
|
|
|
* - To get a black background and nice smooth OSD, use -double
|
|
|
|
* - To get the console as a background, but with scaled OSD, use -nodouble
|
|
|
|
* - The driver supports both scaling and shrinking the image using the -x and
|
2002-10-23 18:52:54 +02:00
|
|
|
* -y options on the mplayer commandline. Also repositioning via the -geometry
|
|
|
|
* option.
|
2001-09-27 14:23:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-02-17 09:24:43 +01:00
|
|
|
#include <errno.h>
|
2002-10-10 16:17:59 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2002-04-11 23:43:09 +02:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <linux/fb.h>
|
2001-09-27 14:23:54 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
2006-04-24 06:23:53 +02:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
2002-04-11 23:43:09 +02:00
|
|
|
#include "fastmemcpy.h"
|
2001-09-27 14:23:54 +02:00
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
2002-04-11 23:43:09 +02:00
|
|
|
#include "drivers/3dfx.h"
|
2002-10-10 16:17:59 +02:00
|
|
|
#include "aspect.h"
|
2002-11-07 00:54:29 +01:00
|
|
|
#include "sub.h"
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2007-12-02 15:06:03 +01:00
|
|
|
static const vo_info_t info =
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-11 23:43:09 +02:00
|
|
|
"3Dfx Banshee/Voodoo3/Voodoo5",
|
2001-09-27 14:23:54 +02:00
|
|
|
"tdfxfb",
|
2002-10-10 16:17:59 +02:00
|
|
|
"Mark Zealey <mark@zealos.org>",
|
2001-09-27 14:23:54 +02:00
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2007-12-02 15:39:15 +01:00
|
|
|
const LIBVO_EXTERN(tdfxfb)
|
2002-11-11 16:22:10 +01:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Some registers on the card */
|
|
|
|
#define S2S_STRECH_BLT 2 // BLT + Strech
|
|
|
|
#define S2S_IMMED (1 << 8) // Do it immediatly
|
|
|
|
#define S2S_ROP (0xCC << 24) // ???
|
|
|
|
|
|
|
|
/* Stepping between the different YUV plane registers */
|
|
|
|
#define YUV_STRIDE 1024
|
|
|
|
struct YUV_plane {
|
|
|
|
char Y[0x0100000];
|
|
|
|
char U[0x0100000];
|
|
|
|
char V[0x0100000];
|
|
|
|
};
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-10-10 16:17:59 +02:00
|
|
|
static int fd = -1;
|
2002-04-09 16:02:55 +02:00
|
|
|
static struct fb_fix_screeninfo fb_finfo;
|
|
|
|
static struct fb_var_screeninfo fb_vinfo;
|
2002-04-11 23:43:09 +02:00
|
|
|
static uint32_t in_width, in_height, in_format, in_depth, in_voodoo_format,
|
2002-04-09 16:02:55 +02:00
|
|
|
screenwidth, screenheight, screendepth, vidwidth, vidheight, vidx, vidy,
|
2002-04-13 01:55:06 +02:00
|
|
|
vid_voodoo_format, *vidpage, *hidpage, *inpage, vidpageoffset,
|
2002-10-10 16:17:59 +02:00
|
|
|
hidpageoffset, inpageoffset, *memBase0 = NULL, *memBase1 = NULL, r_width, r_height;
|
2002-04-09 16:02:55 +02:00
|
|
|
static volatile voodoo_io_reg *reg_IO;
|
2003-10-15 18:50:27 +02:00
|
|
|
static volatile voodoo_2d_reg *reg_2d;
|
2001-09-27 14:23:54 +02:00
|
|
|
static voodoo_yuv_reg *reg_YUV;
|
2002-04-09 16:02:55 +02:00
|
|
|
static struct YUV_plane *YUV;
|
2002-04-13 02:14:59 +02:00
|
|
|
static void (*alpha_func)(), (*alpha_func_double)();
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2005-08-05 03:24:37 +02:00
|
|
|
static int preinit(const char *arg)
|
2002-04-09 16:02:55 +02:00
|
|
|
{
|
|
|
|
char *name;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-10-10 16:17:59 +02:00
|
|
|
if(arg)
|
|
|
|
name = (char*)arg;
|
|
|
|
else if(!(name = getenv("FRAMEBUFFER")))
|
2002-04-09 16:02:55 +02:00
|
|
|
name = "/dev/fb0";
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
if((fd = open(name, O_RDWR)) == -1) {
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_CantOpen, name, strerror(errno));
|
2002-04-09 16:02:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
if(ioctl(fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_ProblemWithFbitgetFscreenInfo,
|
2002-04-09 16:02:55 +02:00
|
|
|
strerror(errno));
|
2002-10-10 16:17:59 +02:00
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
2002-04-09 16:02:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
if(ioctl(fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_ProblemWithFbitgetVscreenInfo,
|
2002-04-09 16:02:55 +02:00
|
|
|
strerror(errno));
|
2002-10-10 16:17:59 +02:00
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
2002-04-09 16:02:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
/* BANSHEE means any of the series aparently */
|
|
|
|
if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) {
|
2006-04-29 01:06:42 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_ThisDriverOnlySupports);
|
2002-10-10 16:17:59 +02:00
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
2002-04-11 23:43:09 +02:00
|
|
|
return -1;
|
2002-04-09 16:02:55 +02:00
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-10-10 16:17:59 +02:00
|
|
|
// Check the depth now as config() musn't fail
|
|
|
|
switch(fb_vinfo.bits_per_pixel) {
|
|
|
|
case 16:
|
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
break; // Ok
|
|
|
|
default:
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_OutputIsNotSupported, fb_vinfo.bits_per_pixel);
|
2002-10-10 16:17:59 +02:00
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Open up a window to the hardware */
|
|
|
|
memBase1 = mmap(0, fb_finfo.smem_len, PROT_READ | PROT_WRITE,
|
|
|
|
MAP_SHARED, fd, 0);
|
|
|
|
memBase0 = mmap(0, fb_finfo.mmio_len, PROT_READ | PROT_WRITE,
|
|
|
|
MAP_SHARED, fd, fb_finfo.smem_len);
|
2001-10-21 22:03:00 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if((long)memBase0 == -1 || (long)memBase1 == -1) {
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_CouldntMapMemoryAreas, strerror(errno));
|
2002-10-10 16:17:59 +02:00
|
|
|
if((long)memBase0 != -1)
|
|
|
|
munmap(memBase0, fb_finfo.smem_len);
|
|
|
|
if((long)memBase1 != -1)
|
|
|
|
munmap(memBase1, fb_finfo.smem_len);
|
|
|
|
memBase0 = memBase1 = NULL;
|
2002-04-09 16:02:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Set up global pointers to the voodoo's regs */
|
2002-04-11 23:43:09 +02:00
|
|
|
reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
|
|
|
|
reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET;
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET;
|
|
|
|
YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
return 0;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static void uninit(void)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
if(reg_IO) {
|
|
|
|
/* Restore the screen (Linux lives at 0) */
|
|
|
|
reg_IO->vidDesktopStartAddr = 0;
|
|
|
|
reg_IO = NULL;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* And close our mess */
|
|
|
|
if(memBase1) {
|
|
|
|
munmap(memBase1, fb_finfo.smem_len);
|
|
|
|
memBase1 = NULL;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(memBase0) {
|
|
|
|
munmap(memBase0, fb_finfo.mmio_len);
|
|
|
|
memBase0 = NULL;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(fd != -1) {
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
}
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2009-05-04 19:35:26 +02:00
|
|
|
static void clear_screen(void)
|
2002-04-11 23:43:09 +02:00
|
|
|
{
|
2002-08-29 14:04:21 +02:00
|
|
|
/* There needs to be some sort of delay here or else things seriously
|
|
|
|
* screw up. Causes the image to not be the right size on screen if
|
|
|
|
* this isn't like this. A printf before the memset call also seems to
|
|
|
|
* work, but this made more sense since it actually checks the status of
|
|
|
|
* the card.
|
|
|
|
*/
|
|
|
|
if(vo_doublebuffering) {
|
|
|
|
/* first wait for the card to be ready, do not try to write
|
|
|
|
* every time - alex */
|
|
|
|
do {} while((reg_IO->status & 0x1f) < 1);
|
|
|
|
memset(vidpage, 0, screenwidth * screenheight * screendepth);
|
2002-04-13 02:14:59 +02:00
|
|
|
memset(hidpage, 0, screenwidth * screenheight * screendepth);
|
|
|
|
}
|
2002-04-11 23:43:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup output screen dimensions etc */
|
2002-04-13 12:04:22 +02:00
|
|
|
static void setup_screen(uint32_t full)
|
2002-04-11 23:43:09 +02:00
|
|
|
{
|
2002-10-23 18:52:54 +02:00
|
|
|
aspect(&vidwidth, &vidheight, full ? A_ZOOM : A_NOZOOM);
|
2003-03-02 22:09:15 +01:00
|
|
|
|
2003-03-03 17:43:43 +01:00
|
|
|
geometry(&vidx, &vidy, &vidwidth, &vidheight, screenwidth, screenheight);
|
2002-10-10 16:17:59 +02:00
|
|
|
vo_fs = full;
|
2002-04-11 23:43:09 +02:00
|
|
|
clear_screen();
|
|
|
|
}
|
|
|
|
|
2005-08-05 03:24:37 +02:00
|
|
|
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height,
|
2002-08-28 23:32:32 +02:00
|
|
|
uint32_t flags, char *title, uint32_t format)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
screenwidth = fb_vinfo.xres;
|
|
|
|
screenheight = fb_vinfo.yres;
|
2002-10-10 16:17:59 +02:00
|
|
|
aspect_save_screenres(fb_vinfo.xres,fb_vinfo.yres);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
in_width = width;
|
|
|
|
in_height = height;
|
|
|
|
in_format = format;
|
2002-10-10 16:17:59 +02:00
|
|
|
aspect_save_orig(width,height);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-13 01:55:06 +02:00
|
|
|
r_width = d_width;
|
|
|
|
r_height = d_height;
|
2002-10-10 16:17:59 +02:00
|
|
|
aspect_save_prescale(d_width,d_height);
|
2002-04-13 01:55:06 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Setup the screen for rendering to */
|
|
|
|
switch(fb_vinfo.bits_per_pixel) {
|
|
|
|
case 16:
|
|
|
|
screendepth = 2;
|
2002-04-11 23:43:09 +02:00
|
|
|
vid_voodoo_format = VOODOO_BLT_FORMAT_16;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func_double = vo_draw_alpha_rgb16;
|
2002-04-09 16:02:55 +02:00
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
case 24:
|
|
|
|
screendepth = 3;
|
2002-04-11 23:43:09 +02:00
|
|
|
vid_voodoo_format = VOODOO_BLT_FORMAT_24;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func_double = vo_draw_alpha_rgb24;
|
2002-04-09 16:02:55 +02:00
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
case 32:
|
|
|
|
screendepth = 4;
|
2002-04-11 23:43:09 +02:00
|
|
|
vid_voodoo_format = VOODOO_BLT_FORMAT_32;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func_double = vo_draw_alpha_rgb32;
|
2002-04-09 16:02:55 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-04-24 23:04:25 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, MSGTR_LIBVO_TDFXFB_BppOutputIsNotSupported, fb_vinfo.bits_per_pixel);
|
2001-09-27 14:23:54 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
vid_voodoo_format |= screenwidth * screendepth;
|
|
|
|
|
|
|
|
/* Some defaults here */
|
|
|
|
in_voodoo_format = VOODOO_BLT_FORMAT_YUYV;
|
|
|
|
in_depth = 2;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func = vo_draw_alpha_yuy2;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
switch(in_format) {
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
2002-04-11 23:43:09 +02:00
|
|
|
case IMGFMT_YUY2:
|
2002-04-09 16:02:55 +02:00
|
|
|
break;
|
2002-10-10 16:17:59 +02:00
|
|
|
case IMGFMT_UYVY:
|
|
|
|
in_voodoo_format = VOODOO_BLT_FORMAT_UYVY;
|
|
|
|
break;
|
2002-04-11 23:43:09 +02:00
|
|
|
case IMGFMT_BGR16:
|
|
|
|
in_voodoo_format = VOODOO_BLT_FORMAT_16;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func = vo_draw_alpha_rgb16;
|
2002-04-11 23:43:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
in_depth = 3;
|
|
|
|
in_voodoo_format = VOODOO_BLT_FORMAT_24;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func = vo_draw_alpha_rgb24;
|
2002-04-11 23:43:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IMGFMT_BGR32:
|
|
|
|
in_depth = 4;
|
|
|
|
in_voodoo_format = VOODOO_BLT_FORMAT_32;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func = vo_draw_alpha_rgb32;
|
2002-04-09 16:02:55 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_SomethingIsWrongWithControl);
|
2001-09-27 14:23:54 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
in_voodoo_format |= in_width * in_depth;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-08-29 14:04:21 +02:00
|
|
|
/* Linux lives in the first frame */
|
|
|
|
if(vo_doublebuffering) {
|
|
|
|
vidpageoffset = screenwidth * screenheight * screendepth;
|
|
|
|
hidpageoffset = vidpageoffset + screenwidth * screenheight * screendepth;
|
|
|
|
} else
|
|
|
|
vidpageoffset = hidpageoffset = 0; /* Console background */
|
|
|
|
|
2002-04-13 02:14:59 +02:00
|
|
|
|
2002-04-13 01:55:06 +02:00
|
|
|
inpageoffset = hidpageoffset + screenwidth * screenheight * screendepth;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(inpageoffset + in_width * in_depth * in_height > fb_finfo.smem_len) {
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_TDFXFB_NotEnoughVideoMemoryToPlay);
|
2002-04-09 16:02:55 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
vidpage = (void *)memBase1 + (unsigned long)vidpageoffset;
|
2002-04-13 01:55:06 +02:00
|
|
|
hidpage = (void *)memBase1 + (unsigned long)hidpageoffset;
|
2002-04-09 16:02:55 +02:00
|
|
|
inpage = (void *)memBase1 + (unsigned long)inpageoffset;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-13 12:04:22 +02:00
|
|
|
setup_screen(flags & VOFLAG_FULLSCREEN);
|
2002-04-11 23:43:09 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
memset(inpage, 0, in_width * in_height * in_depth);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2006-04-24 06:23:53 +02:00
|
|
|
mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_TDFXFB_ScreenIs,
|
2002-04-09 16:02:55 +02:00
|
|
|
screenwidth, screenheight, screendepth * 8,
|
|
|
|
in_width, in_height, in_depth * 8,
|
2002-04-13 01:55:06 +02:00
|
|
|
d_width, d_height);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-04-13 02:14:59 +02:00
|
|
|
/* Double-buffering draw_alpha */
|
|
|
|
static void draw_alpha_double(int x, int y, int w, int h, unsigned char *src,
|
2002-04-13 01:55:06 +02:00
|
|
|
unsigned char *srca, int stride)
|
|
|
|
{
|
|
|
|
char *dst = (char *)vidpage + ((y + vidy) * screenwidth + x + vidx) * screendepth;
|
2002-04-13 02:14:59 +02:00
|
|
|
alpha_func_double(w, h, src, srca, stride, dst, screenwidth * screendepth);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Single-buffering draw_alpha */
|
|
|
|
static void draw_alpha(int x, int y, int w, int h, unsigned char *src,
|
|
|
|
unsigned char *srca, int stride)
|
|
|
|
{
|
|
|
|
char *dst = (char *)inpage + (y * in_width + x) * in_depth;
|
|
|
|
alpha_func(w, h, src, srca, stride, dst, in_width * in_depth);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_osd(void)
|
|
|
|
{
|
|
|
|
if(!vo_doublebuffering)
|
|
|
|
vo_draw_text(in_width, in_height, draw_alpha);
|
2002-04-13 01:55:06 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Render onto the screen */
|
|
|
|
static void flip_page(void)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
voodoo_2d_reg regs = *reg_2d; /* Copy the regs */
|
|
|
|
int i = 0;
|
2001-10-21 22:03:00 +02:00
|
|
|
|
2002-04-13 02:14:59 +02:00
|
|
|
if(vo_doublebuffering) {
|
|
|
|
/* Flip to an offscreen buffer for rendering */
|
|
|
|
uint32_t t = vidpageoffset;
|
|
|
|
void *j = vidpage;
|
2002-04-13 01:55:06 +02:00
|
|
|
|
2002-04-13 02:14:59 +02:00
|
|
|
vidpage = hidpage;
|
|
|
|
hidpage = j;
|
|
|
|
vidpageoffset = hidpageoffset;
|
|
|
|
hidpageoffset = t;
|
|
|
|
}
|
2002-04-13 01:55:06 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->commandExtra = 0;
|
|
|
|
reg_2d->clip0Min = 0;
|
|
|
|
reg_2d->clip0Max = 0xffffffff;
|
2001-10-21 22:03:00 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->srcBaseAddr = inpageoffset;
|
|
|
|
reg_2d->srcXY = 0;
|
2002-04-11 23:43:09 +02:00
|
|
|
reg_2d->srcFormat = in_voodoo_format;
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->srcSize = XYREG(in_width, in_height);
|
2001-10-21 22:03:00 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->dstBaseAddr = vidpageoffset;
|
|
|
|
reg_2d->dstXY = XYREG(vidx, vidy);
|
2002-04-11 23:43:09 +02:00
|
|
|
reg_2d->dstFormat = vid_voodoo_format;
|
2002-08-29 14:04:21 +02:00
|
|
|
reg_2d->dstSize = XYREG(vidwidth, vidheight);
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->command = S2S_STRECH_BLT | S2S_IMMED | S2S_ROP;
|
2001-10-21 22:03:00 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Wait for the command to finish (If we don't do this, we get wierd
|
|
|
|
* sound corruption... */
|
|
|
|
while((reg_IO->status & 0x1f) < 1)
|
|
|
|
/* Wait */;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
*((volatile uint32_t *)((uint32_t *)reg_IO + COMMAND_3D)) = COMMAND_3D_NOP;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
while(i < 3)
|
|
|
|
if(!(reg_IO->status & STATUS_BUSY))
|
|
|
|
i++;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Restore the old regs now */
|
|
|
|
reg_2d->commandExtra = regs.commandExtra;
|
|
|
|
reg_2d->clip0Min = regs.clip0Min;
|
|
|
|
reg_2d->clip0Max = regs.clip0Max;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->srcBaseAddr = regs.srcBaseAddr;
|
|
|
|
reg_2d->srcXY = regs.srcXY;
|
|
|
|
reg_2d->srcFormat = regs.srcFormat;
|
|
|
|
reg_2d->srcSize = regs.srcSize;
|
2001-10-21 22:03:00 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->dstBaseAddr = regs.dstBaseAddr;
|
|
|
|
reg_2d->dstXY = regs.dstXY;
|
|
|
|
reg_2d->dstFormat = regs.dstFormat;
|
|
|
|
reg_2d->dstSize = regs.dstSize;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
reg_2d->command = 0;
|
2002-04-13 01:55:06 +02:00
|
|
|
|
|
|
|
/* Render any text onto this buffer */
|
2002-04-13 02:14:59 +02:00
|
|
|
if(vo_doublebuffering)
|
|
|
|
vo_draw_text(vidwidth, vidheight, draw_alpha_double);
|
2002-04-13 01:55:06 +02:00
|
|
|
|
|
|
|
/* And flip to the new buffer! */
|
|
|
|
reg_IO->vidDesktopStartAddr = vidpageoffset;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2005-08-05 03:24:37 +02:00
|
|
|
static int draw_frame(uint8_t *src[])
|
2001-10-21 22:03:00 +02:00
|
|
|
{
|
2002-04-11 23:43:09 +02:00
|
|
|
mem2agpcpy(inpage, src[0], in_width * in_depth * in_height);
|
2001-09-27 14:23:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-08-05 03:24:37 +02:00
|
|
|
static int draw_slice(uint8_t *i[], int s[], int w, int h, int x, int y)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-11 23:43:09 +02:00
|
|
|
/* We want to render to the YUV to the input page + the location
|
|
|
|
* of the stripes we're doing */
|
|
|
|
reg_YUV->yuvBaseAddr = inpageoffset + in_width * in_depth * y + x;
|
|
|
|
reg_YUV->yuvStride = in_width * in_depth;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
/* Put the YUV channels into the voodoos internal combiner unit
|
|
|
|
* thingie */
|
|
|
|
mem2agpcpy_pic(YUV->Y, i[0], s[0], h , YUV_STRIDE, s[0]);
|
|
|
|
mem2agpcpy_pic(YUV->U, i[1], s[1], h / 2, YUV_STRIDE, s[1]);
|
|
|
|
mem2agpcpy_pic(YUV->V, i[2], s[2], h / 2, YUV_STRIDE, s[2]);
|
2002-04-09 16:02:55 +02:00
|
|
|
return 0;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-13 12:04:22 +02:00
|
|
|
/* Attempt to start doing DR */
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t get_image(mp_image_t *mpi)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
|
|
|
|
2002-10-10 16:17:59 +02:00
|
|
|
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 ??
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
switch(in_format) {
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
case IMGFMT_BGR16:
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
case IMGFMT_BGR32:
|
2002-10-10 16:17:59 +02:00
|
|
|
case IMGFMT_UYVY:
|
2002-04-11 23:43:09 +02:00
|
|
|
mpi->planes[0] = (char *)inpage;
|
|
|
|
mpi->stride[0] = in_width * in_depth;
|
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-11 23:43:09 +02:00
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
2002-10-10 16:17:59 +02:00
|
|
|
if(!(mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) && mpi->w != YUV_STRIDE)
|
|
|
|
return VO_FALSE;
|
2002-04-11 23:43:09 +02:00
|
|
|
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;
|
2002-10-10 16:17:59 +02:00
|
|
|
reg_YUV->yuvBaseAddr = inpageoffset;
|
|
|
|
reg_YUV->yuvStride = in_width * in_depth;
|
2002-04-11 23:43:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return VO_FALSE;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
mpi->width = in_width;
|
|
|
|
mpi->flags |= MP_IMGFLAG_DIRECT;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
return VO_TRUE;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2005-08-05 03:24:37 +02:00
|
|
|
static int control(uint32_t request, void *data, ...)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
switch(request) {
|
|
|
|
case VOCTRL_GET_IMAGE:
|
|
|
|
return get_image(data);
|
|
|
|
|
|
|
|
case VOCTRL_QUERY_FORMAT:
|
|
|
|
switch(*((uint32_t*)data)) {
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
case IMGFMT_YUY2:
|
2002-10-10 16:17:59 +02:00
|
|
|
case IMGFMT_UYVY:
|
2002-04-11 23:43:09 +02:00
|
|
|
case IMGFMT_BGR16:
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
case IMGFMT_BGR32:
|
2002-04-13 01:55:06 +02:00
|
|
|
return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |
|
|
|
|
VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
|
2001-10-21 22:03:00 +02:00
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
return 0; /* Not supported */
|
2002-04-11 23:43:09 +02:00
|
|
|
|
|
|
|
case VOCTRL_FULLSCREEN:
|
2002-10-10 16:17:59 +02:00
|
|
|
setup_screen(!vo_fs);
|
2002-04-13 12:04:22 +02:00
|
|
|
return 0;
|
2001-10-21 22:03:00 +02:00
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
return VO_NOTIMPL;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Dummy funcs */
|
2002-04-13 02:14:59 +02:00
|
|
|
static void check_events(void) {}
|