mirror of
https://github.com/mpv-player/mpv
synced 2024-10-18 10:25:02 +02:00
vo_vesa: DGA support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2611 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
2e0dadb17a
commit
c8c745857b
@ -10,7 +10,6 @@
|
||||
|
||||
/*
|
||||
TODO:
|
||||
- DGA support (need volunteers who have corresponding hardware)
|
||||
- hw YUV support (need volunteers who have corresponding hardware)
|
||||
- double (triple) buffering (if it will really speedup playback).
|
||||
- refresh rate support (need additional info from mplayer)
|
||||
@ -71,7 +70,8 @@ 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 */
|
||||
uint8_t idx; /* indicates index of relocatable frame (A or B) */
|
||||
char idx; /* indicates index of relocatable frame (A=0 or B=1)
|
||||
special case for DGA: idx=-1 */
|
||||
};
|
||||
|
||||
static int vesa_zoom=0; /* software scaling */
|
||||
@ -121,6 +121,7 @@ static void vesa_term( void )
|
||||
int err;
|
||||
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);
|
||||
if(win.idx == -1) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high);
|
||||
if(yuv_buffer) free(yuv_buffer);
|
||||
vbeDestroy();
|
||||
}
|
||||
@ -135,8 +136,10 @@ static inline void __vbeSwitchBank(unsigned long offset)
|
||||
int err;
|
||||
gran = video_mode_info.WinGranularity*1024;
|
||||
new_offset = offset / gran;
|
||||
if(win.idx == -1) goto show_err;
|
||||
if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK)
|
||||
{
|
||||
show_err:
|
||||
PRINT_VBE_ERR("vbeSetWindow",err);
|
||||
printf("vo_vesa: Fatal error occured! Can't continue\n");
|
||||
vesa_term();
|
||||
@ -601,7 +604,11 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
|
||||
else
|
||||
if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE)
|
||||
win.idx = 1; /* frame B */
|
||||
else { printf("vo_vesa: Can't find usable frame of window\n"); return -1; }
|
||||
else
|
||||
{
|
||||
printf("vo_vesa: Can't find usable frame of window\n");
|
||||
return -1;
|
||||
}
|
||||
if(!(win_seg = win.idx == 0 ? video_mode_info.WinASegment:video_mode_info.WinBSegment))
|
||||
{
|
||||
printf("vo_vesa: Can't find valid window address\n");
|
||||
@ -623,6 +630,24 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
|
||||
,image_width,image_height
|
||||
,video_mode_info.XResolution,video_mode_info.YResolution
|
||||
,x_offset,y_offset);
|
||||
if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR))
|
||||
{
|
||||
void *lfb;
|
||||
lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vib.TotalMemory*64*1024);
|
||||
if(lfb == NULL)
|
||||
{
|
||||
printf("vo_vesa: can't use DGA. Force bank switching\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
win.ptr = lfb;
|
||||
win.low = 0UL;
|
||||
win.high = vib.TotalMemory*64*1024;
|
||||
win.idx = -1;
|
||||
video_mode |= VESA_MODE_USE_LINEAR;
|
||||
printf("vo_vesa: Using DGA (%08lXh)\n",(unsigned long)lfb);
|
||||
}
|
||||
}
|
||||
if(yuv_fmt || rgb2rgb_fnc)
|
||||
{
|
||||
#ifdef HAVE_MEMALIGN
|
||||
|
@ -13,7 +13,12 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/io.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static struct VesaProtModeInterface vbe_pm_info;
|
||||
|
||||
@ -84,6 +89,7 @@ static inline int VBE_LRMI_int(int int_no, struct LRMI_regs *r)
|
||||
#endif
|
||||
|
||||
static unsigned hh_int_10_seg;
|
||||
static int fd_mem;
|
||||
int vbeInit( void )
|
||||
{
|
||||
unsigned short iopl_port;
|
||||
@ -106,10 +112,15 @@ int vbeInit( void )
|
||||
while((iopl_port=vbe_pm_info.iopl_ports[i]) != 0xFFFF
|
||||
&& vbe_pm_info.iopl_ports[i++] > 1023) ioperm(iopl_port,1,1);
|
||||
iopl(3);
|
||||
fd_mem = open("/dev/mem",O_RDWR);
|
||||
return VBE_OK;
|
||||
}
|
||||
|
||||
int vbeDestroy( void ) { return VBE_OK; }
|
||||
int vbeDestroy( void )
|
||||
{
|
||||
close(fd_mem);
|
||||
return VBE_OK;
|
||||
}
|
||||
|
||||
/* Fixme!!! This code is compatible only with mplayer's version of lrmi*/
|
||||
static inline int is_addr_valid(const void *p)
|
||||
@ -507,3 +518,19 @@ int vbeWriteString(int x, int y, int attr, char *str)
|
||||
if(retval == 0x4f) retval = VBE_OK;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void * vbeMapVideoBuffer(unsigned long phys_addr,unsigned long size)
|
||||
{
|
||||
void *lfb;
|
||||
if(fd_mem == -1) return NULL;
|
||||
if(verbose > 1) printf("vbelib: vbeMapVideoBuffer(%08lX,%08lX)\n",phys_addr,size);
|
||||
/* Here we don't need with MAP_FIXED and prefered address (first argument) */
|
||||
lfb = mmap((void *)0,size,PROT_READ | PROT_WRITE,MAP_SHARED,fd_mem,phys_addr);
|
||||
return lfb == (void *)-1 ? 0 : lfb;
|
||||
}
|
||||
|
||||
void vbeUnmapVideoBuffer(unsigned long linear_addr,unsigned long size)
|
||||
{
|
||||
if(verbose > 1) printf("vbelib: vbeUnmapVideoBuffer(%08lX,%08lX)\n",linear_addr,size);
|
||||
munmap((void *)linear_addr,size);
|
||||
}
|
||||
|
@ -223,4 +223,8 @@ extern int vbeGetProtModeInfo(struct VesaProtModeInterface *);
|
||||
/* Standard VGA stuff */
|
||||
int vbeWriteString(int x, int y, int attr, char *str);
|
||||
|
||||
/* Misc stuff (For portability only) */
|
||||
void * vbeMapVideoBuffer(unsigned long phys_addr,unsigned long size);
|
||||
void vbeUnmapVideoBuffer(unsigned long linear_addr,unsigned long size);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user