2002-04-09 16:02:55 +02:00
|
|
|
/* Copyright (C) Mark Zealey, 2002, <mark@zealos.org>
|
2001-09-27 14:23:54 +02:00
|
|
|
*
|
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.
|
2001-09-27 14:23:54 +02:00
|
|
|
*
|
2002-04-09 16:02:55 +02:00
|
|
|
* TODO:
|
|
|
|
* - Add DR support (for stuff other than YUY2)
|
|
|
|
* - Add UYVY support
|
|
|
|
* - Add zoom support
|
|
|
|
* - Remove some of the old dud code
|
2001-09-27 14:23:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-02-17 09:24:43 +01:00
|
|
|
#include <errno.h>
|
2001-09-27 14:23:54 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
2002-04-09 16:02:55 +02:00
|
|
|
#include "mp_image.h"
|
2001-09-27 14:23:54 +02:00
|
|
|
|
|
|
|
LIBVO_EXTERN(tdfxfb)
|
|
|
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
|
|
|
#include <linux/fb.h>
|
|
|
|
|
|
|
|
#include "drivers/3dfx.h"
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static vo_info_t vo_info =
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
|
|
|
"tdfxfb (/dev/fb?)",
|
|
|
|
"tdfxfb",
|
2002-04-09 16:02:55 +02:00
|
|
|
"Mark Zealey <mark@zealos.org>"
|
2001-09-27 14:23:54 +02: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-04-09 16:02:55 +02:00
|
|
|
/* XXX: Get rid of most of these vars... */
|
|
|
|
extern int verbose;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static int fd;
|
|
|
|
static struct fb_fix_screeninfo fb_finfo;
|
|
|
|
static struct fb_var_screeninfo fb_vinfo;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t in_width, in_height, in_format, in_depth, in_banshee_format,
|
|
|
|
screenwidth, screenheight, screendepth, vidwidth, vidheight, vidx, vidy,
|
|
|
|
vid_banshee_format, *vidpage, *inpage, vidpageoffset,
|
|
|
|
inpageoffset, *memBase0, *memBase1;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static volatile voodoo_io_reg *reg_IO;
|
2001-09-27 14:23:54 +02:00
|
|
|
static voodoo_2d_reg *reg_2d;
|
|
|
|
static voodoo_yuv_reg *reg_YUV;
|
2002-04-09 16:02:55 +02:00
|
|
|
static struct YUV_plane *YUV;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t preinit(const char *arg)
|
|
|
|
{
|
|
|
|
char *name;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(verbose) printf("tdfxfb: Open\n");
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(!(name = getenv("FRAMEBUFFER")))
|
|
|
|
name = "/dev/fb0";
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if (verbose)
|
|
|
|
printf("tdfxfb: Opening %s\n", name);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if ((fd = open(name, O_RDWR)) == -1) {
|
|
|
|
printf("tdfxfb: can't open %s: %s\n", name, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if (ioctl(fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
|
|
|
|
printf("tdfxfb: problem with FBITGET_FSCREENINFO ioctl: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if (ioctl(fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
|
|
|
|
printf("tdfxfb: problem with FBITGET_VSCREENINFO ioctl: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if (verbose) {
|
|
|
|
printf("fb_finfo:\n");
|
|
|
|
printf(" id: %s\n", fb_finfo.id);
|
|
|
|
printf(" frame bufer at %x len %x (%d)\n", fb_finfo.smem_start,
|
|
|
|
fb_finfo.smem_len, fb_finfo.smem_len);
|
|
|
|
printf(" mem io at %x len %x\n", fb_finfo.mmio_start,
|
|
|
|
fb_finfo.mmio_len);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
printf("fb_vinfo:\n");
|
|
|
|
printf(" resolution: %dx%d\n", fb_vinfo.xres, fb_vinfo.yres);
|
|
|
|
printf(" virtual res: %dx%d\n", fb_vinfo.xres_virtual,
|
|
|
|
fb_vinfo.yres_virtual);
|
|
|
|
printf(" virt offset: %dx%d\n", fb_vinfo.xoffset, fb_vinfo.yoffset);
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE)
|
|
|
|
printf("tdfxfb: This driver is only known to support the banshee!\n");
|
2001-09-27 14:23:54 +02:00
|
|
|
|
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) {
|
|
|
|
printf("tdfxfb: Couldn't map memory areas: %s\n", strerror(errno));
|
|
|
|
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 */
|
|
|
|
reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
|
|
|
|
reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET;
|
|
|
|
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(verbose) printf("tdfxfb: Close\n");
|
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
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height,
|
|
|
|
uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
if(verbose) printf("tdfxfb: Config\n");
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
screenwidth = fb_vinfo.xres;
|
|
|
|
screenheight = 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;
|
2001-09-27 14:23:54 +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;
|
|
|
|
vid_banshee_format = VOODOO_BLT_FORMAT_16;
|
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
case 24:
|
|
|
|
screendepth = 3;
|
|
|
|
vid_banshee_format = VOODOO_BLT_FORMAT_24;
|
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
case 32:
|
|
|
|
screendepth = 4;
|
|
|
|
vid_banshee_format = VOODOO_BLT_FORMAT_32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("tdfxfb: %d bpp output is not supported\n", fb_vinfo.bits_per_pixel);
|
2001-09-27 14:23:54 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
vid_banshee_format |= screenwidth * screendepth;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
in_banshee_format = VOODOO_BLT_FORMAT_YUYV;
|
|
|
|
/* Arpi says we don't need to support RGB */
|
|
|
|
switch(in_format) {
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
in_depth = 4;
|
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
case IMGFMT_YUY2:
|
|
|
|
in_depth = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("tdfxfb: Eik! Something's wrong with control().\n");
|
2001-09-27 14:23:54 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
in_banshee_format |= in_width * in_depth;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2001-10-21 22:03:00 +02:00
|
|
|
if (fullscreen) {
|
2001-09-27 14:23:54 +02:00
|
|
|
double exrat;
|
2001-10-21 22:03:00 +02:00
|
|
|
|
|
|
|
vidwidth = screenwidth;
|
|
|
|
vidheight = screenheight;
|
2002-04-09 16:02:55 +02:00
|
|
|
|
2001-09-27 14:23:54 +02:00
|
|
|
exrat = (double)in_width / in_height;
|
2002-04-09 16:02:55 +02:00
|
|
|
|
|
|
|
if(screenwidth / exrat <= screenheight)
|
2001-09-27 14:23:54 +02:00
|
|
|
vidheight = (double)screenwidth / exrat;
|
|
|
|
else
|
|
|
|
vidwidth = (double)screenheight * exrat;
|
|
|
|
|
|
|
|
vidx = (screenwidth - vidwidth) / 2;
|
|
|
|
vidy = (screenheight - vidheight) / 2;
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(verbose)
|
|
|
|
printf("vidwidth = %d, vidheight = %d, vidx = %d, vidy = %d\n",
|
|
|
|
vidwidth, vidheight, vidx, vidy);
|
2001-10-21 22:03:00 +02:00
|
|
|
} else {
|
|
|
|
if (in_width > screenwidth || in_height > screenheight) {
|
2002-04-09 16:02:55 +02:00
|
|
|
printf("tdfxfb: your resolution is too small to play the movie...\n");
|
2001-10-21 22:03:00 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
vidwidth = in_width;
|
|
|
|
vidheight = in_height;
|
|
|
|
vidx = 0;
|
|
|
|
vidy = 0;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Linux lives in the first frame */
|
|
|
|
vidpageoffset = screenwidth * screenheight * screendepth;
|
|
|
|
inpageoffset = vidpageoffset + 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) {
|
|
|
|
printf("tdfxfb: Not enough video memory to play this movie. Try at a lower resolution\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
vidpage = (void *)memBase1 + (unsigned long)vidpageoffset;
|
|
|
|
inpage = (void *)memBase1 + (unsigned long)inpageoffset;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
memset(vidpage, 0, screenwidth * screenheight * screendepth);
|
|
|
|
memset(inpage, 0, in_width * in_height * in_depth);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
printf("tdfxfb: screen is %dx%d at %d bpp, in is %dx%d at %d bpp (%p/%p)\n",
|
|
|
|
screenwidth, screenheight, screendepth * 8,
|
|
|
|
in_width, in_height, in_depth * 8,
|
|
|
|
memBase0, memBase1);
|
2001-09-27 14:23:54 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static const vo_info_t* get_info(void)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
|
|
|
return &vo_info;
|
|
|
|
}
|
|
|
|
|
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-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;
|
|
|
|
reg_2d->srcFormat = in_banshee_format;
|
|
|
|
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);
|
|
|
|
reg_2d->dstFormat = vid_banshee_format;
|
|
|
|
reg_2d->dstSize = XYREG(vidwidth, vidheight);
|
|
|
|
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
|
|
|
/* Reset the banshee to point at the video page if it got knocked off it
|
|
|
|
*/
|
|
|
|
reg_IO->vidDesktopStartAddr = vidpageoffset;
|
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;
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t draw_frame(uint8_t *src[])
|
2001-10-21 22:03:00 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
switch(in_format) {
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
memcpy(inpage, src[0], in_width * in_depth * in_height);
|
|
|
|
break;
|
2001-10-21 22:03:00 +02:00
|
|
|
}
|
|
|
|
|
2001-09-27 14:23:54 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t 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-09 16:02:55 +02:00
|
|
|
switch(in_format) {
|
|
|
|
case IMGFMT_YV12: /* The normal case */
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV: {
|
|
|
|
int j;
|
|
|
|
char *base;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Put the YUV channels into the banshees internal combiner unit
|
|
|
|
* thingie */
|
|
|
|
for(base = YUV->Y, j = 0; j < h; j++, base += YUV_STRIDE, i[0] += s[0])
|
|
|
|
memcpy(base, i[0], s[0]);
|
|
|
|
for(base = YUV->U, j = 0; j < h / 2; j++, base += YUV_STRIDE, i[1] += s[1])
|
|
|
|
memcpy(base, i[1], s[1]);
|
|
|
|
for(base = YUV->V, j = 0; j < h / 2; j++, base += YUV_STRIDE, i[2] += s[2])
|
|
|
|
memcpy(base, i[2], s[2]);
|
|
|
|
break;
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* No need for a default case, config would have handled it */
|
|
|
|
}
|
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 draw_alpha(int x, int y, int w, int h, unsigned char *src,
|
2001-09-27 14:23:54 +02:00
|
|
|
unsigned char *srca, int stride)
|
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
/* 2... WTF... */
|
|
|
|
char *dst = (char *)inpage + (y * in_width + x) * 2;
|
|
|
|
vo_draw_alpha_yuy2(w, h, src, srca, stride, dst, in_width * in_depth);
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2001-10-21 22:03:00 +02:00
|
|
|
static void draw_osd(void)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
vo_draw_text(in_width, in_height, draw_alpha);
|
2001-09-27 14:23:54 +02:00
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
/* Attempt to start doing DR (Copied mostly from mga_common.c) */
|
|
|
|
static uint32_t get_image(mp_image_t *mpi)
|
2001-09-27 14:23:54 +02:00
|
|
|
{
|
2002-04-09 16:02:55 +02:00
|
|
|
static int enabled = 0;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
if(!enabled) {
|
|
|
|
if(mpi->flags & MP_IMGFLAG_READABLE) /* slow video ram */
|
|
|
|
return VO_FALSE;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
switch(in_format) {
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
mpi->planes[0] = (char *)inpage;
|
|
|
|
mpi->stride[0] = in_width * in_depth;
|
|
|
|
break;
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
default:
|
|
|
|
#if 0
|
|
|
|
if(!(mpi->flags & MP_IMGFLAG_ACCEPT_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;
|
|
|
|
#else /* 0 */
|
|
|
|
return VO_FALSE;
|
|
|
|
#endif /* 0 */
|
|
|
|
}
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
printf("tdfxfb: get_image() SUCCESS -> Direct Rendering ENABLED\n");
|
2001-09-27 14:23:54 +02:00
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
enabled = 1;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2002-04-09 16:02:55 +02:00
|
|
|
static uint32_t 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:
|
|
|
|
return 7; /* Supported without conversion, supports OSD */
|
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 */
|
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 */
|
|
|
|
static void check_events(void) { }
|