2001-10-28 18:30:59 +00:00
|
|
|
/*
|
2001-10-17 18:24:50 +00:00
|
|
|
* video_out_vesa.c
|
|
|
|
*
|
|
|
|
* Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001
|
|
|
|
*
|
|
|
|
* You can redistribute this file under terms and conditions
|
2001-11-02 17:36:04 +00:00
|
|
|
* of GNU General Public licence v2.
|
2001-10-17 18:24:50 +00:00
|
|
|
* This file is partly based on vbetest.c from lrmi distributive.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
TODO:
|
|
|
|
- hw YUV support (need volunteers who have corresponding hardware)
|
2001-11-03 18:45:13 +00:00
|
|
|
- triple buffering (if it will really speedup playback).
|
2001-11-04 18:04:45 +00:00
|
|
|
note: triple buffering requires VBE 3.0 - need volunteers.
|
2001-10-17 18:24:50 +00:00
|
|
|
- refresh rate support (need additional info from mplayer)
|
|
|
|
*/
|
2001-11-09 02:17:02 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
#include <stdio.h>
|
2001-11-09 02:17:02 +00:00
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
2001-10-24 09:18:20 +00:00
|
|
|
#include <stdlib.h>
|
2001-10-17 18:24:50 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <limits.h>
|
2002-02-17 10:21:00 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
|
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
|
|
|
|
|
|
|
#include "fastmemcpy.h"
|
2001-10-21 15:04:04 +00:00
|
|
|
#include "sub.h"
|
2001-10-17 18:24:50 +00:00
|
|
|
#include "linux/vbelib.h"
|
|
|
|
#include "bswap.h"
|
2001-11-04 17:22:22 +00:00
|
|
|
#include "aspect.h"
|
2001-11-29 18:00:57 +00:00
|
|
|
#include "vesa_lvo.h"
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
2002-01-07 09:28:22 +00:00
|
|
|
#include "vosub_vidix.h"
|
2002-01-11 17:20:43 +00:00
|
|
|
#endif
|
2001-10-17 18:24:50 +00:00
|
|
|
|
2001-10-19 16:24:37 +00:00
|
|
|
#include "../postproc/swscale.h"
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
LIBVO_EXTERN(vesa)
|
2002-02-17 10:21:00 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_PNG
|
|
|
|
extern vo_functions_t video_out_png;
|
|
|
|
#endif
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
extern int verbose;
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
#define MAX_BUFFERS 3
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
#ifndef max
|
|
|
|
#define max(a,b) ((a)>(b)?(a):(b))
|
|
|
|
#endif
|
|
|
|
#ifndef min
|
|
|
|
#define min(a,b) ((a)<(b)?(a):(b))
|
|
|
|
#endif
|
|
|
|
|
2001-11-04 17:01:12 +00:00
|
|
|
#define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */
|
2001-10-17 18:24:50 +00:00
|
|
|
|
|
|
|
static vo_info_t vo_info =
|
|
|
|
{
|
|
|
|
"VESA VBE 2.0 video output",
|
|
|
|
"vesa",
|
|
|
|
"Nick Kurshev <nickols_k@mail.ru>",
|
|
|
|
"Requires ROOT privileges"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* driver data */
|
|
|
|
|
|
|
|
struct win_frame
|
|
|
|
{
|
|
|
|
uint8_t *ptr; /* pointer to window's frame memory */
|
|
|
|
uint32_t low; /* lowest boundary of frame */
|
|
|
|
uint32_t high; /* highest boundary of frame */
|
2001-11-01 18:12:58 +00:00
|
|
|
char idx; /* indicates index of relocatable frame (A=0 or B=1)
|
2001-11-02 17:36:04 +00:00
|
|
|
special case for DGA: idx=-1
|
|
|
|
idx=-2 indicates invalid frame, exists only in init() */
|
2001-10-17 18:24:50 +00:00
|
|
|
};
|
|
|
|
|
2001-11-02 17:36:04 +00:00
|
|
|
static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL;
|
|
|
|
|
2002-02-05 16:43:18 +00:00
|
|
|
static uint32_t srcW=0,srcH=0,srcBpp,srcFourcc; /* source image description */
|
|
|
|
static uint32_t dstBpp,dstW, dstH,dstFourcc; /* destinition image description */
|
|
|
|
|
|
|
|
static SwsContext * sws = NULL;
|
2001-10-19 16:24:37 +00:00
|
|
|
|
2001-10-21 10:32:43 +00:00
|
|
|
static int32_t x_offset,y_offset; /* to center image on screen */
|
2001-10-17 18:24:50 +00:00
|
|
|
static unsigned init_mode; /* mode before run of mplayer */
|
|
|
|
static void *init_state = NULL; /* state before run of mplayer */
|
|
|
|
static struct win_frame win; /* real-mode window to video memory */
|
2001-11-02 17:36:04 +00:00
|
|
|
static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */
|
2001-10-17 18:24:50 +00:00
|
|
|
static unsigned video_mode; /* selected video mode for playback */
|
|
|
|
static struct VesaModeInfoBlock video_mode_info;
|
2001-10-21 12:42:17 +00:00
|
|
|
static int flip_trigger = 0;
|
2001-10-21 15:04:04 +00:00
|
|
|
static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
|
2001-10-17 18:24:50 +00:00
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
/* multibuffering */
|
|
|
|
uint8_t* video_base; /* should be never changed */
|
|
|
|
uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */
|
|
|
|
uint8_t multi_size=0; /* total number of buffers */
|
|
|
|
uint8_t multi_idx=0; /* active buffer */
|
2001-11-02 17:36:04 +00:00
|
|
|
|
2001-11-13 17:13:33 +00:00
|
|
|
/* Linux Video Overlay */
|
|
|
|
static const char *lvo_name = NULL;
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
2002-01-07 09:28:22 +00:00
|
|
|
static const char *vidix_name = NULL;
|
2002-01-11 17:20:43 +00:00
|
|
|
#endif
|
2001-11-13 17:13:33 +00:00
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
#define HAS_DGA() (win.idx == -1)
|
2001-10-17 18:24:50 +00:00
|
|
|
#define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS)
|
2001-11-03 18:45:13 +00:00
|
|
|
#define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_WRITEABLE)
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
static char * vbeErrToStr(int err)
|
|
|
|
{
|
|
|
|
char *retval;
|
|
|
|
static char sbuff[80];
|
|
|
|
if((err & VBE_VESA_ERROR_MASK) == VBE_VESA_ERROR_MASK)
|
|
|
|
{
|
2002-02-12 15:06:04 +00:00
|
|
|
sprintf(sbuff,"VESA failed = 0x4f%02x",(err & VBE_VESA_ERRCODE_MASK)>>8);
|
2001-10-17 18:24:50 +00:00
|
|
|
retval = sbuff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
switch(err)
|
|
|
|
{
|
|
|
|
case VBE_OK: retval = "No error"; break;
|
|
|
|
case VBE_VM86_FAIL: retval = "vm86() syscall failed"; break;
|
|
|
|
case VBE_OUT_OF_DOS_MEM: retval = "Out of DOS memory"; break;
|
|
|
|
case VBE_OUT_OF_MEM: retval = "Out of memory"; break;
|
2001-10-22 09:29:16 +00:00
|
|
|
case VBE_BROKEN_BIOS: retval = "Broken BIOS or DOS TSR"; break;
|
2001-11-02 17:36:04 +00:00
|
|
|
default: sprintf(sbuff,"Unknown or internal error: %i",err); retval=sbuff; break;
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PRINT_VBE_ERR(name,err) { printf("vo_vesa: %s returns: %s\n",name,vbeErrToStr(err)); fflush(stdout); }
|
|
|
|
|
|
|
|
static void vesa_term( void )
|
|
|
|
{
|
|
|
|
int err;
|
2001-11-13 17:13:33 +00:00
|
|
|
if(lvo_name) vlvo_term();
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
2002-01-07 09:28:22 +00:00
|
|
|
else if(vidix_name) vidix_term();
|
2002-01-11 17:20:43 +00:00
|
|
|
#endif
|
2001-10-17 18:24:50 +00:00
|
|
|
if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err);
|
|
|
|
if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err);
|
2001-11-02 17:36:04 +00:00
|
|
|
if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high);
|
|
|
|
if(dga_buffer && !HAS_DGA()) free(dga_buffer);
|
2001-10-17 18:24:50 +00:00
|
|
|
vbeDestroy();
|
2002-02-05 16:43:18 +00:00
|
|
|
if(sws) freeSwsContext(sws);
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high)
|
|
|
|
#define VIDEO_PTR(offset) (win.ptr + offset - win.low)
|
|
|
|
|
|
|
|
static inline void __vbeSwitchBank(unsigned long offset)
|
|
|
|
{
|
|
|
|
unsigned long gran;
|
|
|
|
unsigned new_offset;
|
|
|
|
int err;
|
|
|
|
gran = video_mode_info.WinGranularity*1024;
|
|
|
|
new_offset = offset / gran;
|
2001-11-02 17:36:04 +00:00
|
|
|
if(HAS_DGA()) { err = -1; goto show_err; }
|
2001-10-17 18:24:50 +00:00
|
|
|
if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK)
|
|
|
|
{
|
2001-11-01 18:12:58 +00:00
|
|
|
show_err:
|
2001-11-04 16:20:58 +00:00
|
|
|
vesa_term();
|
2001-10-17 18:24:50 +00:00
|
|
|
PRINT_VBE_ERR("vbeSetWindow",err);
|
|
|
|
printf("vo_vesa: Fatal error occured! Can't continue\n");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
win.low = new_offset * gran;
|
|
|
|
win.high = win.low + video_mode_info.WinSize*1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __vbeSetPixel(int x, int y, int r, int g, int b)
|
|
|
|
{
|
|
|
|
int x_res = video_mode_info.XResolution;
|
|
|
|
int y_res = video_mode_info.YResolution;
|
|
|
|
int shift_r = video_mode_info.RedFieldPosition;
|
|
|
|
int shift_g = video_mode_info.GreenFieldPosition;
|
|
|
|
int shift_b = video_mode_info.BlueFieldPosition;
|
2002-02-05 16:43:18 +00:00
|
|
|
int pixel_size = (dstBpp+7)/8;
|
2001-10-17 18:24:50 +00:00
|
|
|
int bpl = video_mode_info.BytesPerScanLine;
|
2001-11-04 11:50:52 +00:00
|
|
|
int color;
|
|
|
|
unsigned offset;
|
2001-10-17 18:24:50 +00:00
|
|
|
|
|
|
|
if (x < 0 || x >= x_res || y < 0 || y >= y_res) return;
|
|
|
|
r >>= 8 - video_mode_info.RedMaskSize;
|
|
|
|
g >>= 8 - video_mode_info.GreenMaskSize;
|
|
|
|
b >>= 8 - video_mode_info.BlueMaskSize;
|
|
|
|
color = (r << shift_r) | (g << shift_g) | (b << shift_b);
|
|
|
|
offset = y * bpl + (x * pixel_size);
|
|
|
|
if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset);
|
|
|
|
memcpy(VIDEO_PTR(offset), &color, pixel_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-11-02 17:36:04 +00:00
|
|
|
Copies part of frame to video memory. Data should be in the same format
|
|
|
|
as video memory.
|
2001-10-17 18:24:50 +00:00
|
|
|
*/
|
2001-11-02 17:36:04 +00:00
|
|
|
static void __vbeCopyBlockFast(unsigned long offset,uint8_t *image,unsigned long size)
|
|
|
|
{
|
|
|
|
memcpy(&win.ptr[offset],image,size);
|
|
|
|
}
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size)
|
|
|
|
{
|
|
|
|
unsigned long delta,src_idx = 0;
|
|
|
|
while(size)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset);
|
|
|
|
delta = min(size,win.high - offset);
|
|
|
|
memcpy(VIDEO_PTR(offset),&image[src_idx],delta);
|
|
|
|
src_idx += delta;
|
|
|
|
offset += delta;
|
|
|
|
size -= delta;
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copies frame to video memory. Data should be in the same format as video
|
|
|
|
memory.
|
|
|
|
*/
|
2001-11-02 17:36:04 +00:00
|
|
|
|
2002-02-05 16:43:18 +00:00
|
|
|
#define PIXEL_SIZE() ((dstBpp+7)/8)
|
2001-11-04 11:50:52 +00:00
|
|
|
#define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) )
|
2002-02-05 16:43:18 +00:00
|
|
|
#define IMAGE_LINE_SIZE(pixel_size) (dstW*(pixel_size))
|
2001-11-02 17:36:04 +00:00
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
static void __vbeCopyData(uint8_t *image)
|
|
|
|
{
|
2001-10-20 16:56:24 +00:00
|
|
|
unsigned long i,j,image_offset,offset;
|
2001-10-17 18:24:50 +00:00
|
|
|
unsigned pixel_size,image_line_size,screen_line_size,x_shift;
|
2001-11-02 17:36:04 +00:00
|
|
|
pixel_size = PIXEL_SIZE();
|
|
|
|
screen_line_size = SCREEN_LINE_SIZE(pixel_size);
|
|
|
|
image_line_size = IMAGE_LINE_SIZE(pixel_size);
|
2002-02-05 16:43:18 +00:00
|
|
|
if(dstW == video_mode_info.XResolution)
|
2001-10-17 18:24:50 +00:00
|
|
|
{
|
2001-10-20 13:11:10 +00:00
|
|
|
/* Special case for zooming */
|
2002-02-05 16:43:18 +00:00
|
|
|
(*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*dstH);
|
2001-10-20 13:11:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x_shift = x_offset*pixel_size;
|
2002-02-05 16:43:18 +00:00
|
|
|
for(j=0,i=y_offset;j<dstH;i++,j++)
|
2001-10-20 13:11:10 +00:00
|
|
|
{
|
|
|
|
offset = i*screen_line_size+x_shift;
|
|
|
|
image_offset = j*image_line_size;
|
2001-11-02 17:36:04 +00:00
|
|
|
(*cpy_blk_fnc)(offset,&image[image_offset],image_line_size);
|
2001-10-20 13:11:10 +00:00
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-21 07:02:40 +00:00
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
/* is called for yuv only */
|
|
|
|
static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
|
|
|
|
uint8_t *dst[3]= {dga_buffer, NULL, NULL};
|
|
|
|
int dstStride[3];
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y);
|
2002-02-05 16:43:18 +00:00
|
|
|
dstStride[0]=dstride*((dstBpp+7)/8);
|
|
|
|
dstStride[1]=
|
|
|
|
dstStride[2]=dstStride[0]>>1;
|
|
|
|
if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE();
|
2002-02-06 20:52:14 +00:00
|
|
|
sws->swScale(sws,image,stride,y,h,dst,dstStride);
|
2001-10-21 12:42:17 +00:00
|
|
|
flip_trigger = 1;
|
2001-10-19 16:24:37 +00:00
|
|
|
return 0;
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
2002-02-07 19:37:09 +00:00
|
|
|
/* Please comment it out if you want have OSD within movie */
|
|
|
|
#define OSD_OUTSIDE_MOVIE 1
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
|
2002-02-07 19:37:09 +00:00
|
|
|
#ifndef OSD_OUTSIDE_MOVIE
|
|
|
|
if(HAS_DGA())
|
|
|
|
{
|
|
|
|
x0 += x_offset;
|
|
|
|
y0 += y_offset;
|
|
|
|
}
|
|
|
|
#endif
|
2001-11-03 18:45:13 +00:00
|
|
|
vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride);
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
|
2002-02-07 19:37:09 +00:00
|
|
|
#ifndef OSD_OUTSIDE_MOVIE
|
|
|
|
if(HAS_DGA())
|
|
|
|
{
|
|
|
|
x0 += x_offset;
|
|
|
|
y0 += y_offset;
|
|
|
|
}
|
|
|
|
#endif
|
2001-11-03 18:45:13 +00:00
|
|
|
vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride);
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
|
2002-02-07 19:37:09 +00:00
|
|
|
#ifndef OSD_OUTSIDE_MOVIE
|
|
|
|
if(HAS_DGA())
|
|
|
|
{
|
|
|
|
x0 += x_offset;
|
|
|
|
y0 += y_offset;
|
|
|
|
}
|
|
|
|
#endif
|
2001-11-03 18:45:13 +00:00
|
|
|
vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride);
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
|
2002-02-07 19:37:09 +00:00
|
|
|
#ifndef OSD_OUTSIDE_MOVIE
|
|
|
|
if(HAS_DGA())
|
|
|
|
{
|
|
|
|
x0 += x_offset;
|
|
|
|
y0 += y_offset;
|
|
|
|
}
|
|
|
|
#endif
|
2001-11-03 18:45:13 +00:00
|
|
|
vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride);
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
|
|
|
|
{
|
2001-11-04 17:01:12 +00:00
|
|
|
UNUSED(x0);
|
|
|
|
UNUSED(y0);
|
|
|
|
UNUSED(w);
|
|
|
|
UNUSED(h);
|
|
|
|
UNUSED(src);
|
|
|
|
UNUSED(srca);
|
|
|
|
UNUSED(stride);
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
static void draw_osd(void)
|
|
|
|
{
|
2001-11-03 18:45:13 +00:00
|
|
|
uint32_t w,h;
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: draw_osd was called\n");
|
2001-11-13 17:13:33 +00:00
|
|
|
{
|
2002-02-07 19:37:09 +00:00
|
|
|
#ifdef OSD_OUTSIDE_MOVIE
|
2002-02-05 16:43:18 +00:00
|
|
|
w = HAS_DGA()?video_mode_info.XResolution:dstW;
|
|
|
|
h = HAS_DGA()?video_mode_info.YResolution:dstH;
|
2002-02-07 19:37:09 +00:00
|
|
|
#else
|
|
|
|
w = dstW;
|
|
|
|
h = dstH;
|
|
|
|
#endif
|
2001-11-13 17:13:33 +00:00
|
|
|
if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc);
|
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void flip_page(void)
|
|
|
|
{
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: flip_page was called\n");
|
2001-11-02 17:36:04 +00:00
|
|
|
if(flip_trigger)
|
|
|
|
{
|
|
|
|
if(!HAS_DGA()) __vbeCopyData(dga_buffer);
|
|
|
|
flip_trigger = 0;
|
|
|
|
}
|
2002-02-03 09:12:32 +00:00
|
|
|
if(vo_doublebuffering && multi_size > 1)
|
2001-11-03 18:45:13 +00:00
|
|
|
{
|
2001-11-04 16:20:58 +00:00
|
|
|
int err;
|
2002-02-12 15:06:04 +00:00
|
|
|
if((err=vbeSetDisplayStart(multi_buff[multi_idx],vo_vsync)) != VBE_OK)
|
2001-11-04 16:20:58 +00:00
|
|
|
{
|
|
|
|
vesa_term();
|
2001-11-04 18:04:45 +00:00
|
|
|
PRINT_VBE_ERR("vbeSetDisplayStart",err);
|
2001-11-04 16:20:58 +00:00
|
|
|
printf("vo_vesa: Fatal error occured! Can't continue\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
multi_idx = multi_idx ? 0 : 1;
|
|
|
|
win.ptr = dga_buffer = video_base + multi_buff[multi_idx];
|
2001-11-03 18:45:13 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
if(tripple_buffering)
|
|
|
|
{
|
2002-02-12 15:06:04 +00:00
|
|
|
vbeSetScheduledDisplayStart(multi_buff[multi_idx],vo_vsync);
|
2001-11-03 18:45:13 +00:00
|
|
|
multi_idx++;
|
|
|
|
if(multi_idx > 2) multi_idx = 0;
|
2002-02-12 15:06:04 +00:00
|
|
|
win.ptr = dga_buffer = video_base + multi_buff[multi_idx];
|
2001-11-03 18:45:13 +00:00
|
|
|
}
|
|
|
|
*/
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* is called for rgb only */
|
|
|
|
static uint32_t draw_frame(uint8_t *src[])
|
|
|
|
{
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: draw_frame was called\n");
|
2002-02-05 16:43:18 +00:00
|
|
|
if(sws)
|
2001-10-28 10:17:57 +00:00
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW;
|
|
|
|
int srcStride[1];
|
|
|
|
uint8_t *dst[3]= {dga_buffer, NULL, NULL};
|
|
|
|
int dstStride[3];
|
|
|
|
dstStride[0]=dstride*((dstBpp+7)/8);
|
|
|
|
dstStride[1]=
|
|
|
|
dstStride[2]=dstStride[0]>>1;
|
|
|
|
if(srcFourcc == IMGFMT_RGB32 || srcFourcc == IMGFMT_BGR32)
|
|
|
|
srcStride[0] = srcW*4;
|
|
|
|
else
|
|
|
|
if(srcFourcc == IMGFMT_RGB24 || srcFourcc == IMGFMT_BGR24)
|
|
|
|
srcStride[0] = srcW*3;
|
|
|
|
else
|
|
|
|
srcStride[0] = srcW*2;
|
|
|
|
if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE();
|
2002-02-06 20:52:14 +00:00
|
|
|
sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride);
|
2002-02-05 16:43:18 +00:00
|
|
|
flip_trigger=1;
|
|
|
|
}
|
2001-10-28 10:17:57 +00:00
|
|
|
return 0;
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
2001-11-17 16:11:48 +00:00
|
|
|
#define SUBDEV_NODGA 0x00000001UL
|
|
|
|
#define SUBDEV_FORCEDGA 0x00000002UL
|
2002-01-26 19:12:49 +00:00
|
|
|
static uint32_t subdev_flags = 0xFFFFFFFEUL;
|
2001-11-17 16:11:48 +00:00
|
|
|
static uint32_t parseSubDevice(const char *sd)
|
|
|
|
{
|
|
|
|
uint32_t flags;
|
|
|
|
flags = 0;
|
|
|
|
if(strcmp(sd,"nodga") == 0) { flags |= SUBDEV_NODGA; flags &= ~(SUBDEV_FORCEDGA); }
|
|
|
|
else
|
|
|
|
if(strcmp(sd,"dga") == 0) { flags &= ~(SUBDEV_NODGA); flags |= SUBDEV_FORCEDGA; }
|
|
|
|
else
|
|
|
|
if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
2002-01-07 09:28:22 +00:00
|
|
|
else
|
|
|
|
if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */
|
2002-01-11 17:20:43 +00:00
|
|
|
#endif
|
2002-02-05 16:43:18 +00:00
|
|
|
else { printf("vo_vesa: Unknown subdevice: '%s'\n", sd); return 0xFFFFFFFFUL; }
|
2001-11-17 16:11:48 +00:00
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
static uint32_t query_format(uint32_t format)
|
|
|
|
{
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format));
|
2002-04-11 21:07:00 +00:00
|
|
|
return 1 | VFCAP_OSD | VFCAP_SWSCALE; /* due new SwScale code */
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
2001-11-04 16:20:58 +00:00
|
|
|
static void paintBkGnd( void )
|
|
|
|
{
|
|
|
|
int x_res = video_mode_info.XResolution;
|
|
|
|
int y_res = video_mode_info.YResolution;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = 0; y < y_res; ++y)
|
|
|
|
{
|
|
|
|
for (x = 0; x < x_res; ++x)
|
|
|
|
{
|
|
|
|
int r, g, b;
|
|
|
|
if ((x & 16) ^ (y & 16))
|
|
|
|
{
|
|
|
|
r = x * 255 / x_res;
|
|
|
|
g = y * 255 / y_res;
|
|
|
|
b = 255 - x * 255 / x_res;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = 255 - x * 255 / x_res;
|
|
|
|
g = y * 255 / y_res;
|
|
|
|
b = 255 - y * 255 / y_res;
|
|
|
|
}
|
|
|
|
__vbeSetPixel(x, y, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-15 16:45:26 +00:00
|
|
|
static void clear_screen( void )
|
|
|
|
{
|
|
|
|
int x_res = video_mode_info.XResolution;
|
|
|
|
int y_res = video_mode_info.YResolution;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
for (y = 0; y < y_res; ++y)
|
|
|
|
for (x = 0; x < x_res; ++x)
|
|
|
|
__vbeSetPixel(x, y, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2001-10-19 15:09:40 +00:00
|
|
|
static char *model2str(unsigned char type)
|
|
|
|
{
|
|
|
|
char *retval;
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case memText: retval = "Text"; break;
|
|
|
|
case memCGA: retval="CGA"; break;
|
|
|
|
case memHercules: retval="Hercules"; break;
|
|
|
|
case memPL: retval="Planar"; break;
|
|
|
|
case memPK: retval="Packed pixel"; break;
|
|
|
|
case mem256: retval="256"; break;
|
|
|
|
case memRGB: retval="Direct color RGB"; break;
|
|
|
|
case memYUV: retval="Direct color YUV"; break;
|
|
|
|
default: retval="Unknown"; break;
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2001-11-03 18:45:13 +00:00
|
|
|
unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs )
|
|
|
|
{
|
|
|
|
unsigned long screen_size, offset;
|
|
|
|
unsigned total,i;
|
2002-02-05 16:43:18 +00:00
|
|
|
screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((dstBpp+7)/8);
|
2001-11-03 18:45:13 +00:00
|
|
|
if(screen_size%64) screen_size=((screen_size/64)*64)+64;
|
|
|
|
total = vsize / screen_size;
|
2001-11-15 18:18:35 +00:00
|
|
|
if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total);
|
2001-11-03 18:45:13 +00:00
|
|
|
i = 0;
|
|
|
|
offset = 0;
|
|
|
|
total = min(total,nbuffs);
|
|
|
|
while(i < total) { multi_buff[i++] = offset; offset += screen_size; }
|
|
|
|
if(!i)
|
|
|
|
printf("vo_vesa: Your have too small size of video memory for this mode:\n"
|
|
|
|
"vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-17 18:24:50 +00:00
|
|
|
/* fullscreen:
|
|
|
|
* bit 0 (0x01) means fullscreen (-fs)
|
|
|
|
* bit 1 (0x02) means mode switching (-vm)
|
|
|
|
* bit 2 (0x04) enables software scaling (-zoom)
|
2001-10-21 14:02:09 +00:00
|
|
|
* bit 3 (0x08) enables flipping (-flip) (NK: and for what?)
|
2001-10-17 18:24:50 +00:00
|
|
|
*/
|
|
|
|
static uint32_t
|
2002-01-31 09:57:13 +00:00
|
|
|
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format,const vo_tune_info_t *info)
|
2001-10-17 18:24:50 +00:00
|
|
|
{
|
|
|
|
struct VbeInfoBlock vib;
|
|
|
|
struct VesaModeInfoBlock vmib;
|
|
|
|
size_t i,num_modes;
|
2002-01-26 19:12:49 +00:00
|
|
|
uint32_t w,h;
|
2001-10-17 18:24:50 +00:00
|
|
|
unsigned short *mode_ptr,win_seg;
|
|
|
|
unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX;
|
2002-02-09 10:24:44 +00:00
|
|
|
int err,fs_mode,use_scaler=0;
|
|
|
|
srcW = dstW = width;
|
|
|
|
srcH = dstH = height;
|
2001-10-21 14:30:36 +00:00
|
|
|
fs_mode = 0;
|
2002-01-26 19:12:49 +00:00
|
|
|
if(subdev_flags == 0xFFFFFFFEUL)
|
2001-11-18 15:06:32 +00:00
|
|
|
{
|
2002-01-26 19:12:49 +00:00
|
|
|
printf("vo_vesa: detected internal fatal error: init is called before preinit\n");
|
2001-11-18 15:06:32 +00:00
|
|
|
return -1;
|
2002-01-26 19:12:49 +00:00
|
|
|
}
|
2002-02-05 16:43:18 +00:00
|
|
|
if(subdev_flags == 0xFFFFFFFFUL) return -1;
|
2001-10-21 10:32:43 +00:00
|
|
|
if(flags & 0x8)
|
2001-10-17 18:24:50 +00:00
|
|
|
{
|
2001-10-21 10:32:43 +00:00
|
|
|
printf("vo_vesa: switch -flip is not supported\n");
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
2002-02-05 16:43:18 +00:00
|
|
|
if(flags & 0x04) use_scaler = 1;
|
2001-10-21 14:30:36 +00:00
|
|
|
if(flags & 0x01)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
if(use_scaler) use_scaler = 2;
|
2001-10-21 14:30:36 +00:00
|
|
|
else fs_mode = 1;
|
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; }
|
|
|
|
memcpy(vib.VESASignature,"VBE2",4);
|
|
|
|
if((err=vbeGetControllerInfo(&vib)) != VBE_OK)
|
|
|
|
{
|
|
|
|
PRINT_VBE_ERR("vbeGetControllerInfo",err);
|
|
|
|
printf("vo_vesa: possible reason: No VBE2 BIOS found\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Print general info here */
|
|
|
|
printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n",
|
|
|
|
(int)(vib.VESAVersion >> 8) & 0xff,
|
|
|
|
(int)(vib.VESAVersion & 0xff),
|
|
|
|
(int)(vib.OemSoftwareRev & 0xffff));
|
|
|
|
printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64);
|
2001-10-18 15:50:49 +00:00
|
|
|
printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n"
|
|
|
|
,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC,"
|
|
|
|
,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC,"
|
|
|
|
,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC,"
|
|
|
|
,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic,"
|
|
|
|
,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo");
|
|
|
|
printf("vo_vesa: !!! Below will be printed OEM info. !!!\n");
|
|
|
|
printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n");
|
|
|
|
printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr);
|
|
|
|
printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev);
|
|
|
|
printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr);
|
|
|
|
printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr);
|
|
|
|
printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr);
|
|
|
|
printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n"
|
|
|
|
"vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n");
|
2001-10-17 18:24:50 +00:00
|
|
|
/* Find best mode here */
|
|
|
|
num_modes = 0;
|
|
|
|
mode_ptr = vib.VideoModePtr;
|
|
|
|
while(*mode_ptr++ != 0xffff) num_modes++;
|
|
|
|
switch(format)
|
|
|
|
{
|
|
|
|
case IMGFMT_BGR8:
|
|
|
|
case IMGFMT_RGB8: bpp = 8; break;
|
|
|
|
case IMGFMT_BGR15:
|
|
|
|
case IMGFMT_RGB15: bpp = 15; break;
|
|
|
|
case IMGFMT_BGR16:
|
|
|
|
case IMGFMT_RGB16: bpp = 16; break;
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
case IMGFMT_RGB24: bpp = 24; break;
|
|
|
|
case IMGFMT_BGR32:
|
|
|
|
case IMGFMT_RGB32: bpp = 32; break;
|
2002-02-09 10:24:44 +00:00
|
|
|
default: bpp = 16; break;
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
2002-02-05 16:43:18 +00:00
|
|
|
srcBpp = bpp;
|
|
|
|
srcFourcc = format;
|
2001-10-28 10:17:57 +00:00
|
|
|
if(vo_dbpp) bpp = vo_dbpp;
|
2001-10-21 15:04:04 +00:00
|
|
|
switch(bpp)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
case 15: draw_alpha_fnc = draw_alpha_15;
|
|
|
|
dstFourcc = IMGFMT_BGR15;
|
|
|
|
break;
|
|
|
|
case 16: draw_alpha_fnc = draw_alpha_16;
|
|
|
|
dstFourcc = IMGFMT_BGR16;
|
|
|
|
break;
|
|
|
|
case 24: draw_alpha_fnc = draw_alpha_24;
|
|
|
|
dstFourcc = IMGFMT_BGR24;
|
|
|
|
break;
|
|
|
|
case 32: draw_alpha_fnc = draw_alpha_32;
|
|
|
|
dstFourcc = IMGFMT_BGR32;
|
|
|
|
break;
|
|
|
|
default: draw_alpha_fnc = draw_alpha_null;
|
|
|
|
dstFourcc = IMGFMT_BGR16;
|
|
|
|
break;
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
if(verbose)
|
|
|
|
{
|
2001-10-20 11:58:45 +00:00
|
|
|
printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format));
|
2001-10-17 18:24:50 +00:00
|
|
|
printf("vo_vesa: Total modes found: %u\n",num_modes);
|
|
|
|
mode_ptr = vib.VideoModePtr;
|
|
|
|
printf("vo_vesa: Mode list:");
|
|
|
|
for(i = 0;i < num_modes;i++)
|
|
|
|
{
|
|
|
|
printf(" %04X",mode_ptr[i]);
|
|
|
|
}
|
|
|
|
printf("\nvo_vesa: Modes in detail:\n");
|
|
|
|
}
|
|
|
|
mode_ptr = vib.VideoModePtr;
|
2002-02-05 16:43:18 +00:00
|
|
|
if(use_scaler)
|
2001-10-21 14:02:09 +00:00
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
dstW = d_width;
|
2002-02-09 10:24:44 +00:00
|
|
|
dstH = d_height;
|
2001-10-21 14:02:09 +00:00
|
|
|
}
|
|
|
|
if(vo_screenwidth) w = vo_screenwidth;
|
2002-02-05 16:43:18 +00:00
|
|
|
else w = max(dstW,width);
|
2001-10-21 14:02:09 +00:00
|
|
|
if(vo_screenheight) h = vo_screenheight;
|
2002-02-05 16:43:18 +00:00
|
|
|
else h = max(dstH,height);
|
2001-10-17 18:24:50 +00:00
|
|
|
for(i=0;i < num_modes;i++)
|
|
|
|
{
|
|
|
|
if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK)
|
|
|
|
{
|
|
|
|
PRINT_VBE_ERR("vbeGetModeInfo",err);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-10-21 10:32:43 +00:00
|
|
|
if(vmib.XResolution >= w &&
|
|
|
|
vmib.YResolution >= h &&
|
2001-10-17 18:24:50 +00:00
|
|
|
(vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE &&
|
|
|
|
vmib.BitsPerPixel == bpp &&
|
|
|
|
vmib.MemoryModel == memRGB)
|
|
|
|
{
|
2001-10-19 15:09:40 +00:00
|
|
|
if(vmib.XResolution <= best_x &&
|
|
|
|
vmib.YResolution <= best_y)
|
2001-10-17 18:24:50 +00:00
|
|
|
{
|
|
|
|
best_x = vmib.XResolution;
|
|
|
|
best_y = vmib.YResolution;
|
|
|
|
best_mode_idx = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(verbose)
|
|
|
|
{
|
2001-10-19 16:24:37 +00:00
|
|
|
printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n"
|
2001-10-19 15:09:40 +00:00
|
|
|
"vo_vesa: #planes=%u model=%u(%s) #pages=%u\n"
|
|
|
|
"vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n"
|
2001-10-24 09:18:20 +00:00
|
|
|
"vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n"
|
2001-10-17 18:24:50 +00:00
|
|
|
,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes
|
2001-10-19 15:09:40 +00:00
|
|
|
,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages
|
2001-10-17 18:24:50 +00:00
|
|
|
,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity
|
|
|
|
,vmib.DirectColorModeInfo,vmib.PhysBasePtr);
|
|
|
|
if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7)
|
|
|
|
printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n"
|
|
|
|
,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(best_mode_idx != UINT_MAX)
|
|
|
|
{
|
|
|
|
video_mode = vib.VideoModePtr[best_mode_idx];
|
|
|
|
fflush(stdout);
|
|
|
|
if((err=vbeGetMode(&init_mode)) != VBE_OK)
|
|
|
|
{
|
|
|
|
PRINT_VBE_ERR("vbeGetMode",err);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode);
|
|
|
|
if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK)
|
|
|
|
{
|
|
|
|
PRINT_VBE_ERR("vbeGetModeInfo",err);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-10-21 10:32:43 +00:00
|
|
|
printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n"
|
|
|
|
,best_mode_idx,video_mode,video_mode_info.XResolution
|
2002-02-05 16:43:18 +00:00
|
|
|
,video_mode_info.YResolution,dstBpp);
|
|
|
|
dstBpp = video_mode_info.BitsPerPixel;
|
2002-01-26 19:12:49 +00:00
|
|
|
if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0;
|
2002-02-09 10:24:44 +00:00
|
|
|
if(use_scaler || fs_mode)
|
2001-10-19 16:24:37 +00:00
|
|
|
{
|
2001-10-20 11:58:45 +00:00
|
|
|
/* software scale */
|
2002-02-05 16:43:18 +00:00
|
|
|
if(use_scaler > 1)
|
2001-11-04 17:22:22 +00:00
|
|
|
{
|
|
|
|
aspect_save_orig(width,height);
|
|
|
|
aspect_save_prescale(d_width,d_height);
|
|
|
|
aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution);
|
2002-02-05 16:43:18 +00:00
|
|
|
aspect(&dstW,&dstH,A_ZOOM);
|
2001-11-04 17:22:22 +00:00
|
|
|
}
|
2001-10-21 14:30:36 +00:00
|
|
|
else
|
|
|
|
if(fs_mode)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
dstW = video_mode_info.XResolution;
|
|
|
|
dstH = video_mode_info.YResolution;
|
2001-10-21 14:30:36 +00:00
|
|
|
}
|
2002-02-05 16:43:18 +00:00
|
|
|
use_scaler = 1;
|
2002-02-09 10:24:44 +00:00
|
|
|
}
|
|
|
|
if(!lvo_name
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
2002-02-09 10:24:44 +00:00
|
|
|
&& !vidix_name
|
2002-01-11 17:20:43 +00:00
|
|
|
#endif
|
2002-02-09 10:24:44 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc);
|
|
|
|
if(!sws)
|
|
|
|
{
|
|
|
|
printf("vo_vesa: Can't initialize SwScaler\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else if(verbose) printf("vo_vesa: Using SW BES emulator\n");
|
2001-10-19 15:09:40 +00:00
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE)
|
|
|
|
win.idx = 0; /* frame A */
|
|
|
|
else
|
|
|
|
if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE)
|
|
|
|
win.idx = 1; /* frame B */
|
2001-11-02 17:36:04 +00:00
|
|
|
else win.idx = -2;
|
|
|
|
/* Try use DGA instead */
|
|
|
|
if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR))
|
2001-11-01 18:12:58 +00:00
|
|
|
{
|
2001-11-02 17:36:04 +00:00
|
|
|
void *lfb;
|
|
|
|
unsigned long vsize;
|
|
|
|
vsize = vib.TotalMemory*64*1024;
|
|
|
|
lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize);
|
|
|
|
if(lfb == NULL)
|
|
|
|
printf("vo_vesa: Can't use DGA. Force bank switching mode. :(\n");
|
|
|
|
else
|
|
|
|
{
|
2001-11-03 18:45:13 +00:00
|
|
|
video_base = win.ptr = lfb;
|
2001-11-02 17:36:04 +00:00
|
|
|
win.low = 0UL;
|
|
|
|
win.high = vsize;
|
|
|
|
win.idx = -1; /* HAS_DGA() is on */
|
|
|
|
video_mode |= VESA_MODE_USE_LINEAR;
|
2001-11-03 18:45:13 +00:00
|
|
|
printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)"
|
2001-11-02 17:36:04 +00:00
|
|
|
,video_mode_info.PhysBasePtr
|
2001-11-03 18:45:13 +00:00
|
|
|
,vsize);
|
|
|
|
if(verbose) printf(" at %08lXh",(unsigned long)lfb);
|
|
|
|
printf("\n");
|
|
|
|
if(!(multi_size = fillMultiBuffer(vsize,2))) return -1;
|
|
|
|
if(vo_doublebuffering && multi_size < 2)
|
|
|
|
printf("vo_vesa: Can't use double buffering: not enough video memory\n");
|
2001-11-02 17:36:04 +00:00
|
|
|
}
|
2001-11-01 18:12:58 +00:00
|
|
|
}
|
2001-11-02 17:36:04 +00:00
|
|
|
if(win.idx == -2)
|
2001-10-17 18:24:50 +00:00
|
|
|
{
|
2001-11-02 17:36:04 +00:00
|
|
|
printf("vo_vesa: Can't find neither DGA nor relocatable window's frame.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(!HAS_DGA())
|
|
|
|
{
|
2002-01-26 19:12:49 +00:00
|
|
|
if(subdev_flags & SUBDEV_FORCEDGA)
|
2001-11-03 18:45:13 +00:00
|
|
|
{
|
|
|
|
printf("vo_vesa: you've forced DGA. Exiting\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2001-11-02 17:36:04 +00:00
|
|
|
if(!(win_seg = win.idx == 0 ? video_mode_info.WinASegment:video_mode_info.WinBSegment))
|
|
|
|
{
|
|
|
|
printf("vo_vesa: Can't find valid window address\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
win.ptr = PhysToVirtSO(win_seg,0);
|
|
|
|
win.low = 0L;
|
|
|
|
win.high= video_mode_info.WinSize*1024;
|
2001-11-03 18:45:13 +00:00
|
|
|
printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n"
|
|
|
|
,(unsigned long)win.ptr,(unsigned long)win.high);
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
2002-02-05 16:43:18 +00:00
|
|
|
if(video_mode_info.XResolution > dstW)
|
|
|
|
x_offset = (video_mode_info.XResolution - dstW) / 2;
|
2001-10-21 10:32:43 +00:00
|
|
|
else x_offset = 0;
|
2002-02-05 16:43:18 +00:00
|
|
|
if(video_mode_info.YResolution > dstH)
|
|
|
|
y_offset = (video_mode_info.YResolution - dstH) / 2;
|
2001-10-21 10:32:43 +00:00
|
|
|
else y_offset = 0;
|
2001-10-20 12:53:20 +00:00
|
|
|
if(verbose)
|
|
|
|
printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n"
|
2002-02-05 16:43:18 +00:00
|
|
|
,dstW,dstH
|
2001-10-20 12:53:20 +00:00
|
|
|
,video_mode_info.XResolution,video_mode_info.YResolution
|
|
|
|
,x_offset,y_offset);
|
2001-11-02 17:36:04 +00:00
|
|
|
if(HAS_DGA())
|
2001-11-01 18:12:58 +00:00
|
|
|
{
|
2001-11-02 17:36:04 +00:00
|
|
|
dga_buffer = win.ptr; /* Trickly ;) */
|
|
|
|
cpy_blk_fnc = __vbeCopyBlockFast;
|
2001-11-01 18:12:58 +00:00
|
|
|
}
|
2001-11-02 17:36:04 +00:00
|
|
|
else
|
2001-10-28 10:17:57 +00:00
|
|
|
{
|
2001-11-02 17:36:04 +00:00
|
|
|
cpy_blk_fnc = __vbeCopyBlock;
|
2002-02-09 10:24:44 +00:00
|
|
|
if(!lvo_name
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
|
|
|
&& !vidix_name
|
|
|
|
#endif
|
2002-02-09 10:24:44 +00:00
|
|
|
)
|
2001-11-02 17:36:04 +00:00
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp)))
|
2001-11-02 17:36:04 +00:00
|
|
|
{
|
|
|
|
printf("vo_vesa: Can't allocate temporary buffer\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer);
|
2001-10-21 15:04:04 +00:00
|
|
|
}
|
2001-10-28 10:17:57 +00:00
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
if((err=vbeSaveState(&init_state)) != VBE_OK)
|
|
|
|
{
|
|
|
|
PRINT_VBE_ERR("vbeSaveState",err);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if((err=vbeSetMode(video_mode,NULL)) != VBE_OK)
|
|
|
|
{
|
|
|
|
PRINT_VBE_ERR("vbeSetMode",err);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Now we are in video mode!!!*/
|
2001-10-21 15:04:04 +00:00
|
|
|
/* Below 'return -1' is impossible */
|
2001-10-17 18:24:50 +00:00
|
|
|
if(verbose)
|
|
|
|
{
|
|
|
|
printf("vo_vesa: Graphics mode was activated\n");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2001-11-13 17:13:33 +00:00
|
|
|
if(lvo_name)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0)
|
2001-11-13 17:13:33 +00:00
|
|
|
{
|
|
|
|
printf("vo_vesa: Can't initialize Linux Video Overlay\n");
|
2001-11-17 16:11:48 +00:00
|
|
|
lvo_name = NULL;
|
2001-11-13 17:13:33 +00:00
|
|
|
vesa_term();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else printf("vo_vesa: Using video overlay: %s\n",lvo_name);
|
|
|
|
}
|
2002-01-11 17:20:43 +00:00
|
|
|
#ifdef CONFIG_VIDIX
|
2002-01-07 09:28:22 +00:00
|
|
|
else
|
|
|
|
if(vidix_name)
|
|
|
|
{
|
2002-02-05 16:43:18 +00:00
|
|
|
if(vidix_init(width,height,x_offset,y_offset,dstW,
|
|
|
|
dstH,format,dstBpp,
|
2002-01-31 10:23:39 +00:00
|
|
|
video_mode_info.XResolution,video_mode_info.YResolution,info) != 0)
|
2002-01-07 09:28:22 +00:00
|
|
|
{
|
|
|
|
printf("vo_vesa: Can't initialize VIDIX driver\n");
|
|
|
|
vidix_name = NULL;
|
2002-02-06 16:41:41 +00:00
|
|
|
vesa_term();
|
2002-01-07 09:28:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2002-01-10 18:01:19 +00:00
|
|
|
else printf("vo_vesa: Using VIDIX\n");
|
2002-01-16 15:22:45 +00:00
|
|
|
vidix_start();
|
2002-01-07 09:28:22 +00:00
|
|
|
}
|
2002-01-11 17:20:43 +00:00
|
|
|
#endif
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-10-18 15:50:49 +00:00
|
|
|
printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp);
|
2001-10-17 18:24:50 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(verbose)
|
|
|
|
{
|
|
|
|
printf("vo_vesa: VESA initialization complete\n");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2001-11-15 16:45:26 +00:00
|
|
|
/* Clear screen for stupid BIOSes */
|
|
|
|
clear_screen();
|
2001-11-04 17:01:12 +00:00
|
|
|
if(HAS_DGA() && vo_doublebuffering)
|
2001-10-17 18:24:50 +00:00
|
|
|
{
|
2001-11-04 16:20:58 +00:00
|
|
|
for(i=0;i<MAX_BUFFERS;i++)
|
|
|
|
{
|
|
|
|
win.ptr = dga_buffer = video_base + multi_buff[i];
|
2002-01-06 10:58:04 +00:00
|
|
|
if(verbose>1) paintBkGnd();
|
2001-11-04 16:20:58 +00:00
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
2001-11-04 16:20:58 +00:00
|
|
|
else
|
2001-11-02 17:36:04 +00:00
|
|
|
{
|
2002-01-06 10:58:04 +00:00
|
|
|
if(verbose>1) paintBkGnd();
|
2001-11-04 16:20:58 +00:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2;
|
|
|
|
if(x < 0) x = 0;
|
|
|
|
vbeWriteString(x,0,7,title);
|
|
|
|
}
|
2001-11-02 17:36:04 +00:00
|
|
|
}
|
2001-10-17 18:24:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const vo_info_t*
|
|
|
|
get_info(void)
|
|
|
|
{
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: get_info was called\n");
|
2001-10-17 18:24:50 +00:00
|
|
|
return &vo_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
uninit(void)
|
|
|
|
{
|
2001-11-04 16:20:58 +00:00
|
|
|
vesa_term();
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: uninit was called\n");
|
2001-10-17 18:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void check_events(void)
|
|
|
|
{
|
2001-10-28 10:17:57 +00:00
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: check_events was called\n");
|
2001-10-17 18:24:50 +00:00
|
|
|
/* Nothing to do */
|
|
|
|
}
|
2002-01-26 16:01:26 +00:00
|
|
|
|
|
|
|
static uint32_t preinit(const char *arg)
|
|
|
|
{
|
2002-01-26 19:12:49 +00:00
|
|
|
int pre_init_err = 0;
|
|
|
|
if(verbose>1) printf("vo_vesa: preinit(%s) was called\n",arg);
|
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_vesa: subdevice %s is being initialized\n",arg);
|
|
|
|
subdev_flags = 0;
|
|
|
|
if(arg) subdev_flags = parseSubDevice(arg);
|
|
|
|
if(lvo_name) pre_init_err = vlvo_preinit(lvo_name);
|
|
|
|
#ifdef CONFIG_VIDIX
|
|
|
|
else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa);
|
|
|
|
#endif
|
|
|
|
if(verbose > 2)
|
|
|
|
printf("vo_subdevice: initialization returns: %i\n",pre_init_err);
|
|
|
|
return pre_init_err;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|
|
|
|
|
2002-02-17 10:21:00 +00:00
|
|
|
#ifdef HAVE_PNG
|
|
|
|
static int vesa_screenshot(const char *fname)
|
|
|
|
{
|
|
|
|
uint32_t i,n;
|
|
|
|
uint8_t *ptrs[video_mode_info.YResolution];
|
2002-02-17 17:18:05 +00:00
|
|
|
if(video_out_png.preinit(NULL))
|
2002-02-17 10:21:00 +00:00
|
|
|
{
|
2002-02-17 17:18:05 +00:00
|
|
|
printf("\nvo_vesa: can't preinit vo_png\n");
|
2002-02-17 10:21:00 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2002-02-17 17:18:05 +00:00
|
|
|
if(!video_out_png.control(VOCTRL_QUERY_FORMAT, &dstFourcc))
|
2002-02-17 10:21:00 +00:00
|
|
|
{
|
2002-02-17 17:18:05 +00:00
|
|
|
printf("\nvo_vesa: vo_png doesn't support: %s fourcc\n",vo_format_name(dstFourcc));
|
2002-02-17 10:21:00 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if(video_out_png.config(HAS_DGA()?video_mode_info.XResolution:dstW,
|
|
|
|
HAS_DGA()?video_mode_info.YResolution:dstH,
|
|
|
|
HAS_DGA()?video_mode_info.XResolution:dstW,
|
|
|
|
HAS_DGA()?video_mode_info.YResolution:dstH,
|
|
|
|
0,NULL,dstFourcc,NULL))
|
|
|
|
{
|
|
|
|
printf("\nvo_vesa: can't configure vo_png\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
n = HAS_DGA()?video_mode_info.YResolution:dstH;
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
ptrs[i] = &dga_buffer[(HAS_DGA()?video_mode_info.XResolution:dstW)*i*PIXEL_SIZE()];
|
|
|
|
if(video_out_png.draw_frame(ptrs))
|
|
|
|
{
|
|
|
|
printf("\nvo_vesa: vo_png: error during dumping\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
video_out_png.uninit();
|
|
|
|
if(verbose) printf("\nvo_vesa: png output has been created\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char _home_name[FILENAME_MAX + 1];
|
|
|
|
static char * __get_home_filename(const char *progname)
|
|
|
|
{
|
|
|
|
char *p = getenv("HOME");
|
|
|
|
|
|
|
|
if (p == NULL || strlen(p) < 2) {
|
|
|
|
struct passwd *psw = getpwuid(getuid());
|
|
|
|
if (psw != NULL) p = psw->pw_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p == NULL || strlen(p) > FILENAME_MAX - (strlen(progname) + 4))
|
|
|
|
p = "/tmp";
|
|
|
|
|
|
|
|
strcpy(_home_name, p);
|
|
|
|
strcat(_home_name, "/.");
|
|
|
|
return strcat(_home_name, progname);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-02-09 01:21:48 +00:00
|
|
|
static uint32_t control(uint32_t request, void *data, ...)
|
2002-01-26 16:01:26 +00:00
|
|
|
{
|
2002-02-09 00:47:26 +00:00
|
|
|
switch (request) {
|
|
|
|
case VOCTRL_QUERY_FORMAT:
|
|
|
|
return query_format(*((uint32_t*)data));
|
2002-02-17 10:21:00 +00:00
|
|
|
#ifdef HAVE_PNG
|
|
|
|
case VOCTRL_SCREENSHOT:
|
|
|
|
return vesa_screenshot(__get_home_filename("mplayer_vesa_dump.png"));
|
|
|
|
break;
|
|
|
|
#endif
|
2002-02-09 00:47:26 +00:00
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|