2001-02-27 02:08:44 +01:00
|
|
|
/*
|
|
|
|
*
|
2003-04-29 19:15:14 +02:00
|
|
|
* X11 DGA Interface
|
2001-02-27 02:08:44 +01:00
|
|
|
*
|
|
|
|
* Copyright ( C ) 2001, Andreas Ackermann. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* <acki@acki-netz.de>
|
|
|
|
*
|
2001-03-30 19:16:56 +02:00
|
|
|
* Sourceforge username: acki2
|
|
|
|
*
|
2001-02-27 02:08:44 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-02-17 09:24:43 +01:00
|
|
|
#include <errno.h>
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
2002-01-08 21:58:53 +01:00
|
|
|
#include "aspect.h"
|
2003-04-29 19:15:14 +02:00
|
|
|
#include "x11_common.h"
|
|
|
|
#include "fastmemcpy.h"
|
|
|
|
#include "../mp_msg.h"
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/extensions/xf86dga.h>
|
|
|
|
|
2001-03-31 11:16:08 +02:00
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
#include <X11/extensions/xf86vmode.h>
|
|
|
|
#endif
|
|
|
|
|
2002-11-11 16:22:10 +01:00
|
|
|
static vo_info_t info =
|
2001-02-27 02:08:44 +01:00
|
|
|
{
|
2001-04-19 23:39:10 +02:00
|
|
|
#ifdef HAVE_DGA2
|
|
|
|
"DGA ( Direct Graphic Access V2.0 )",
|
|
|
|
#else
|
2002-09-25 23:18:43 +02:00
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
"DGA ( Direct Graphic Access V1.0+XF86VidModeExt. )",
|
|
|
|
#else
|
|
|
|
"DGA ( Direct Graphic Access V1.0 )",
|
|
|
|
#endif
|
2001-04-19 23:39:10 +02:00
|
|
|
#endif
|
2001-02-27 02:08:44 +01:00
|
|
|
"dga",
|
|
|
|
"Andreas Ackermann <acki@acki-netz.de>",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2002-11-11 16:22:10 +01:00
|
|
|
LIBVO_EXTERN( dga )
|
|
|
|
|
2001-04-13 20:49:59 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
//#define BITSPP (vo_dga_modes[vo_dga_active_mode].vdm_bitspp)
|
|
|
|
//#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp)
|
2001-04-17 22:51:58 +02:00
|
|
|
|
2001-06-18 00:21:47 +02:00
|
|
|
#define VO_DGA_INVALID_RES 100000
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
#define HW_MODE (vo_dga_modes[vo_dga_hw_mode])
|
|
|
|
#define SRC_MODE (vo_dga_modes[vo_dga_src_mode])
|
2001-04-17 22:51:58 +02:00
|
|
|
|
2001-04-13 20:49:59 +02:00
|
|
|
struct vd_modes {
|
|
|
|
int vdm_mplayer_depth;
|
|
|
|
int vdm_supported;
|
|
|
|
int vdm_depth;
|
|
|
|
int vdm_bitspp;
|
|
|
|
int vdm_bytespp;
|
|
|
|
int vdm_rmask;
|
|
|
|
int vdm_gmask;
|
|
|
|
int vdm_bmask;
|
2001-05-02 00:37:37 +02:00
|
|
|
int vdm_hw_mode;
|
2001-04-13 20:49:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
static struct vd_modes vo_dga_modes[] = {
|
|
|
|
// these entries describe HW modes
|
|
|
|
// however, we use the same entries to tell mplayer what we support
|
|
|
|
// so the last two values describe, which HW mode to use and which conversion
|
|
|
|
// function to use for a mode that is not supported by HW
|
|
|
|
|
2003-07-28 16:54:19 +02:00
|
|
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, },
|
2003-06-02 00:09:20 +02:00
|
|
|
{ 15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f, 2, },
|
|
|
|
{ 16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f, 2, },
|
|
|
|
{ 24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff, 4},
|
|
|
|
{ 32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4}
|
2001-04-13 20:49:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes);
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
// enable a HW mode (by description)
|
2002-09-25 23:18:43 +02:00
|
|
|
static int vd_EnableMode( int depth, int bitspp,
|
2001-04-13 20:49:59 +02:00
|
|
|
int rmask, int gmask, int bmask){
|
|
|
|
int i;
|
|
|
|
for(i=1; i<vo_dga_mode_num; i++){
|
|
|
|
if(vo_dga_modes[i].vdm_depth == depth &&
|
|
|
|
vo_dga_modes[i].vdm_bitspp == bitspp &&
|
|
|
|
vo_dga_modes[i].vdm_rmask == rmask &&
|
|
|
|
vo_dga_modes[i].vdm_gmask == gmask &&
|
|
|
|
vo_dga_modes[i].vdm_bmask == bmask){
|
|
|
|
vo_dga_modes[i].vdm_supported = 1;
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_modes[i].vdm_hw_mode = i;
|
2001-04-13 20:49:59 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
static int vd_ModeEqual(int depth, int bitspp,
|
2001-04-13 20:49:59 +02:00
|
|
|
int rmask, int gmask, int bmask, int index){
|
|
|
|
return (
|
|
|
|
(vo_dga_modes[index].vdm_depth == depth &&
|
|
|
|
vo_dga_modes[index].vdm_bitspp == bitspp &&
|
|
|
|
vo_dga_modes[index].vdm_rmask == rmask &&
|
|
|
|
vo_dga_modes[index].vdm_gmask == gmask &&
|
|
|
|
vo_dga_modes[index].vdm_bmask == bmask)
|
|
|
|
? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
// enable a HW mode (mplayer_depth decides which)
|
2002-09-25 23:18:43 +02:00
|
|
|
static int vd_ValidateMode( int mplayer_depth){
|
2001-04-14 00:11:08 +02:00
|
|
|
int i;
|
|
|
|
if(mplayer_depth == 0)return 0;
|
|
|
|
for(i=1; i<vo_dga_mode_num; i++){
|
|
|
|
if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth ){
|
|
|
|
vo_dga_modes[i].vdm_supported = 1;
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_modes[i].vdm_hw_mode = i;
|
2001-04-14 00:11:08 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
// do we support this mode? (not important whether native or conversion)
|
2002-09-25 23:18:43 +02:00
|
|
|
static int vd_ModeValid( int mplayer_depth){
|
2001-04-13 20:49:59 +02:00
|
|
|
int i;
|
|
|
|
if(mplayer_depth == 0)return 0;
|
|
|
|
for(i=1; i<vo_dga_mode_num; i++){
|
|
|
|
if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth &&
|
|
|
|
vo_dga_modes[i].vdm_supported != 0){
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
static char *vd_GetModeString(int index){
|
2001-04-13 20:49:59 +02:00
|
|
|
|
|
|
|
#define VO_DGA_MAX_STRING_LEN 100
|
|
|
|
static char stringbuf[VO_DGA_MAX_STRING_LEN];
|
|
|
|
stringbuf[VO_DGA_MAX_STRING_LEN-1]=0;
|
|
|
|
snprintf(stringbuf, VO_DGA_MAX_STRING_LEN-2,
|
2001-05-02 00:37:37 +02:00
|
|
|
"depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)",
|
2001-04-13 20:49:59 +02:00
|
|
|
vo_dga_modes[index].vdm_depth,
|
|
|
|
vo_dga_modes[index].vdm_bitspp,
|
|
|
|
vo_dga_modes[index].vdm_rmask,
|
|
|
|
vo_dga_modes[index].vdm_gmask,
|
|
|
|
vo_dga_modes[index].vdm_bmask,
|
2003-06-02 00:09:20 +02:00
|
|
|
vo_dga_modes[index].vdm_supported ? "native" : "not supported",
|
2001-04-13 20:49:59 +02:00
|
|
|
vo_dga_modes[index].vdm_mplayer_depth);
|
|
|
|
return stringbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------
|
|
|
|
|
2003-07-28 16:54:19 +02:00
|
|
|
#if defined(HAVE_XF86VM) && !defined(HAVE_DGA2)
|
2001-03-31 11:16:08 +02:00
|
|
|
static XF86VidModeModeInfo **vo_dga_vidmodes=NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-04-18 00:28:09 +02:00
|
|
|
static int vo_dga_src_format;
|
2001-03-03 22:46:39 +01:00
|
|
|
static int vo_dga_width; // bytes per line in framebuffer
|
2001-03-31 11:16:08 +02:00
|
|
|
static int vo_dga_vp_width; // visible pixels per line in
|
|
|
|
// framebuffer
|
2001-03-03 22:46:39 +01:00
|
|
|
static int vo_dga_vp_height; // visible lines in framebuffer
|
|
|
|
static int vo_dga_is_running = 0;
|
|
|
|
static int vo_dga_src_width; // width of video in pixels
|
|
|
|
static int vo_dga_src_height; // height of video in pixels
|
|
|
|
static int vo_dga_src_offset=0; // offset in src
|
2001-03-30 19:16:56 +02:00
|
|
|
static int vo_dga_vp_offset=0; // offset in dest
|
2001-03-31 01:12:31 +02:00
|
|
|
static int vo_dga_bytes_per_line; // bytes per line to copy
|
2001-03-30 19:16:56 +02:00
|
|
|
static int vo_dga_vp_skip; // dto. for dest
|
2001-04-13 20:49:59 +02:00
|
|
|
static int vo_dga_lines; // num of lines to copy
|
2001-05-02 00:37:37 +02:00
|
|
|
static int vo_dga_hw_mode = 0; // index in mode list that is actually
|
|
|
|
// used by framebuffer
|
|
|
|
static int vo_dga_src_mode = 0; // index in mode list that is used by
|
|
|
|
// codec
|
2001-04-13 20:49:59 +02:00
|
|
|
static int vo_dga_XServer_mode = 0;// index in mode list for resolution
|
2002-11-03 01:39:28 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_DGA2
|
|
|
|
static XDGAMode * vo_modelines;
|
|
|
|
static int vo_modecount;
|
|
|
|
#endif
|
2001-02-27 02:08:44 +01:00
|
|
|
|
2002-09-25 23:08:44 +02:00
|
|
|
#define MAX_NR_VIDEO_BUFFERS 3
|
|
|
|
|
2002-10-01 23:47:32 +02:00
|
|
|
#define CURRENT_VIDEO_BUFFER \
|
|
|
|
(vo_dga_video_buffer[vo_dga_current_video_buffer])
|
2002-09-25 23:08:44 +02:00
|
|
|
|
|
|
|
static int vo_dga_nr_video_buffers; // Total number of frame buffers.
|
|
|
|
static int vo_dga_current_video_buffer; // Buffer available for rendering.
|
|
|
|
|
|
|
|
static struct video_buffer
|
|
|
|
{
|
|
|
|
int y;
|
|
|
|
uint8_t *data;
|
|
|
|
} vo_dga_video_buffer[MAX_NR_VIDEO_BUFFERS];
|
2001-03-31 01:12:31 +02:00
|
|
|
|
2002-01-08 21:58:53 +01:00
|
|
|
/* saved src and dst dimensions for SwScaler */
|
|
|
|
static unsigned int scale_srcW = 0,
|
|
|
|
scale_dstW = 0,
|
|
|
|
scale_srcH = 0,
|
|
|
|
scale_dstH = 0;
|
|
|
|
|
2001-04-13 20:49:59 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2001-04-17 22:51:58 +02:00
|
|
|
static void draw_alpha( int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride ){
|
|
|
|
|
|
|
|
char *d;
|
2001-04-18 00:28:09 +02:00
|
|
|
unsigned int offset;
|
|
|
|
unsigned int buffer_stride;
|
2001-04-17 22:51:58 +02:00
|
|
|
|
2001-04-18 00:28:09 +02:00
|
|
|
offset = vo_dga_width * y0 +x0;
|
|
|
|
buffer_stride = vo_dga_width;
|
2002-10-01 23:47:32 +02:00
|
|
|
d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
|
2001-04-17 22:51:58 +02:00
|
|
|
|
2001-04-18 00:28:09 +02:00
|
|
|
switch( HW_MODE.vdm_mplayer_depth ){
|
|
|
|
|
|
|
|
case 32:
|
|
|
|
vo_draw_alpha_rgb32(w,h,src,srca,stride, d+4*offset , 4*buffer_stride);
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
vo_draw_alpha_rgb24(w,h,src,srca,stride, d+3*offset , 3*buffer_stride);
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
vo_draw_alpha_rgb15(w,h,src,srca,stride, d+2*offset , 2*buffer_stride);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
vo_draw_alpha_rgb16(w,h,src,srca,stride, d+2*offset , 2*buffer_stride);
|
|
|
|
break;
|
|
|
|
}
|
2001-04-17 22:51:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
|
2001-04-13 20:49:59 +02:00
|
|
|
|
2001-02-27 02:08:44 +01:00
|
|
|
|
2001-05-07 21:16:04 +02:00
|
|
|
// quick & dirty - for debugging only
|
2003-07-28 16:54:19 +02:00
|
|
|
#if 0
|
2002-09-25 23:18:43 +02:00
|
|
|
static void fillblock(char *strt, int yoff, int lines, int val){
|
2001-05-07 21:16:04 +02:00
|
|
|
char *i;
|
|
|
|
for(i = strt + yoff * vo_dga_width *HW_MODE.vdm_bytespp;
|
|
|
|
i< strt + (lines+yoff) * vo_dga_width *HW_MODE.vdm_bytespp; ){
|
|
|
|
*i++ = val;
|
|
|
|
}
|
|
|
|
}
|
2003-07-28 16:54:19 +02:00
|
|
|
#endif
|
2001-02-27 02:08:44 +01:00
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
static uint32_t draw_frame( uint8_t *src[] ){
|
|
|
|
|
|
|
|
int vp_skip = vo_dga_vp_skip;
|
|
|
|
int numlines = vo_dga_lines;
|
|
|
|
|
|
|
|
char *s, *d;
|
|
|
|
|
2001-03-31 01:12:31 +02:00
|
|
|
s = *src;
|
2002-10-01 23:47:32 +02:00
|
|
|
d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
|
2001-05-02 00:37:37 +02:00
|
|
|
|
2002-02-15 02:00:26 +01:00
|
|
|
mem2agpcpy_pic(
|
|
|
|
d, s,
|
|
|
|
vo_dga_bytes_per_line,
|
|
|
|
numlines,
|
|
|
|
vo_dga_bytes_per_line+vo_dga_vp_skip,
|
|
|
|
vo_dga_bytes_per_line);
|
2002-09-25 23:08:44 +02:00
|
|
|
|
2001-05-07 21:16:04 +02:00
|
|
|
// DBG-COde
|
|
|
|
|
|
|
|
#if 0
|
2002-10-01 23:47:32 +02:00
|
|
|
d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
|
2001-05-07 21:16:04 +02:00
|
|
|
fillblock(d, 0, 10, 0x800000ff);
|
|
|
|
fillblock(d, 10, 10, 0x8000ff00);
|
|
|
|
fillblock(d, 20, 10, 0x80ff0000);
|
|
|
|
fillblock(d, 30, 10, 0xff0000ff);
|
|
|
|
fillblock(d, 40, 10, 0x800000ff);
|
|
|
|
fillblock(d, 50, 10, 0x0f0000ff);
|
2002-09-25 23:08:44 +02:00
|
|
|
#endif
|
2001-02-27 02:08:44 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2001-03-03 22:46:39 +01:00
|
|
|
static void check_events(void)
|
|
|
|
{
|
2002-11-07 00:54:29 +01:00
|
|
|
vo_x11_check_events(mDisplay);
|
2001-03-03 22:46:39 +01:00
|
|
|
}
|
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|
2001-02-27 02:08:44 +01:00
|
|
|
|
2001-04-24 13:42:04 +02:00
|
|
|
#include "sub.h"
|
2001-04-24 12:21:12 +02:00
|
|
|
|
2001-08-13 13:08:18 +02:00
|
|
|
static void draw_osd(void)
|
|
|
|
{ vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha); }
|
|
|
|
|
2002-09-25 23:08:44 +02:00
|
|
|
static void switch_video_buffers(void)
|
|
|
|
{
|
|
|
|
vo_dga_current_video_buffer =
|
|
|
|
(vo_dga_current_video_buffer + 1) % vo_dga_nr_video_buffers;
|
|
|
|
}
|
2001-03-31 01:12:31 +02:00
|
|
|
|
2002-09-25 23:08:44 +02:00
|
|
|
static void flip_page( void )
|
|
|
|
{
|
|
|
|
if(1 < vo_dga_nr_video_buffers)
|
|
|
|
{
|
2001-03-31 01:12:31 +02:00
|
|
|
#ifdef HAVE_DGA2
|
2002-11-03 01:39:28 +01:00
|
|
|
XDGASetViewport(mDisplay, mScreen,
|
2002-09-25 23:08:44 +02:00
|
|
|
0,
|
2002-10-01 23:47:32 +02:00
|
|
|
CURRENT_VIDEO_BUFFER.y,
|
2002-09-25 23:08:44 +02:00
|
|
|
XDGAFlipRetrace);
|
2001-03-31 01:12:31 +02:00
|
|
|
#else
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86DGASetViewPort(mDisplay, mScreen,
|
2002-09-25 23:08:44 +02:00
|
|
|
0,
|
2002-10-07 13:29:19 +02:00
|
|
|
CURRENT_VIDEO_BUFFER.y);
|
2001-03-31 01:12:31 +02:00
|
|
|
#endif
|
2002-09-25 23:08:44 +02:00
|
|
|
switch_video_buffers();
|
|
|
|
}
|
2001-02-27 02:08:44 +01:00
|
|
|
}
|
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2001-02-27 02:08:44 +01:00
|
|
|
static uint32_t draw_slice( uint8_t *src[],int stride[],
|
|
|
|
int w,int h,int x,int y )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2001-02-27 02:08:44 +01:00
|
|
|
static uint32_t query_format( uint32_t format )
|
|
|
|
{
|
|
|
|
|
2001-04-13 20:49:59 +02:00
|
|
|
if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR &&
|
2002-05-27 19:14:13 +02:00
|
|
|
vd_ModeValid(format&0xff))
|
|
|
|
{
|
|
|
|
return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD;
|
|
|
|
}
|
2001-04-13 20:49:59 +02:00
|
|
|
|
2001-02-27 02:08:44 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
uninit(void)
|
|
|
|
{
|
|
|
|
|
2001-03-31 00:09:38 +02:00
|
|
|
#ifdef HAVE_DGA2
|
|
|
|
XDGADevice *dgadevice;
|
|
|
|
#endif
|
2001-03-31 11:16:08 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
if ( !vo_config_count ) return;
|
|
|
|
|
2001-03-31 11:16:08 +02:00
|
|
|
if(vo_dga_is_running){
|
|
|
|
vo_dga_is_running = 0;
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: in uninit\n");
|
2002-09-28 22:09:14 +02:00
|
|
|
if(vo_grabpointer)
|
2002-11-03 01:39:28 +01:00
|
|
|
XUngrabPointer (mDisplay, CurrentTime);
|
|
|
|
XUngrabKeyboard (mDisplay, CurrentTime);
|
2001-03-31 00:09:38 +02:00
|
|
|
#ifdef HAVE_DGA2
|
2002-11-03 01:39:28 +01:00
|
|
|
XDGACloseFramebuffer(mDisplay, mScreen);
|
|
|
|
dgadevice = XDGASetMode(mDisplay, mScreen, 0);
|
2001-03-31 11:16:08 +02:00
|
|
|
if(dgadevice != NULL){
|
|
|
|
XFree(dgadevice);
|
|
|
|
}
|
2001-03-31 00:09:38 +02:00
|
|
|
#else
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86DGADirectVideo (mDisplay, mScreen, 0);
|
2001-03-31 11:16:08 +02:00
|
|
|
// first disable DirectVideo and then switch mode back!
|
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
if (vo_dga_vidmodes != NULL ){
|
2002-11-03 01:39:28 +01:00
|
|
|
int screen; screen=XDefaultScreen( mDisplay );
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: VidModeExt: Switching back..\n");
|
2001-03-31 11:16:08 +02:00
|
|
|
// seems some graphics adaptors need this more than once ...
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86VidModeSwitchToMode(mDisplay,screen,vo_dga_vidmodes[0]);
|
|
|
|
XF86VidModeSwitchToMode(mDisplay,screen,vo_dga_vidmodes[0]);
|
|
|
|
XF86VidModeSwitchToMode(mDisplay,screen,vo_dga_vidmodes[0]);
|
|
|
|
XF86VidModeSwitchToMode(mDisplay,screen,vo_dga_vidmodes[0]);
|
2001-03-31 11:16:08 +02:00
|
|
|
XFree(vo_dga_vidmodes);
|
|
|
|
}
|
2001-03-31 00:09:38 +02:00
|
|
|
#endif
|
2001-03-31 11:16:08 +02:00
|
|
|
#endif
|
|
|
|
}
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_x11_uninit();
|
2001-02-27 02:08:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-31 00:09:38 +02:00
|
|
|
//----------------------------------------------------------
|
2001-04-13 20:49:59 +02:00
|
|
|
// TODO: check for larger maxy value
|
|
|
|
// (useful for double buffering!!!)
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
static int check_res( int num, int x, int y, int bpp,
|
2001-05-07 21:16:04 +02:00
|
|
|
int new_x, int new_y, int new_vbi, int new_maxy,
|
|
|
|
int *old_x, int *old_y, int *old_vbi, int *old_maxy){
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ depth %2d ..",
|
2001-04-01 10:07:14 +02:00
|
|
|
num, new_x, new_y, new_vbi, bpp );
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi);
|
2001-03-31 00:09:38 +02:00
|
|
|
if (
|
|
|
|
(new_x >= x) &&
|
|
|
|
(new_y >= y) &&
|
|
|
|
(
|
|
|
|
// prefer a better resolution either in X or in Y
|
|
|
|
// as long as the other dimension is at least the same
|
|
|
|
//
|
|
|
|
// hmm ... MAYBE it would be more clever to focus on the
|
|
|
|
// x-resolution; I had 712x400 and 640x480 and the movie
|
|
|
|
// was 640x360; 640x480 would be the 'right thing' here
|
|
|
|
// but since 712x400 was queried first I got this one.
|
|
|
|
// I think there should be a cmd-line switch to let the
|
|
|
|
// user choose the mode he likes ... (acki2)
|
|
|
|
|
|
|
|
(
|
|
|
|
((new_x < *old_x) &&
|
|
|
|
!(new_y > *old_y)) ||
|
|
|
|
((new_y < *old_y) &&
|
|
|
|
!(new_x > *old_x))
|
2001-04-01 10:07:14 +02:00
|
|
|
)
|
2001-03-31 00:09:38 +02:00
|
|
|
// but if we get an identical resolution choose
|
|
|
|
// the one with the lower refreshrate (saves bandwidth !!!)
|
|
|
|
// as long as it's above 50 Hz (acki2 on 30/3/2001)
|
|
|
|
||
|
|
|
|
(
|
2003-05-30 20:05:49 +02:00
|
|
|
(
|
2001-03-31 00:09:38 +02:00
|
|
|
(new_x == *old_x) &&
|
|
|
|
(new_y == *old_y) &&
|
|
|
|
(
|
|
|
|
(
|
|
|
|
new_vbi >= *old_vbi && *old_vbi < 50
|
2001-04-01 10:07:14 +02:00
|
|
|
)
|
2001-03-31 00:09:38 +02:00
|
|
|
||
|
|
|
|
(
|
|
|
|
*old_vbi >= 50 &&
|
|
|
|
new_vbi < *old_vbi &&
|
|
|
|
new_vbi >= 50
|
|
|
|
)
|
|
|
|
)
|
2003-05-30 20:05:49 +02:00
|
|
|
)
|
2001-05-07 21:16:04 +02:00
|
|
|
||
|
|
|
|
// if everything is equal, then use the mode with the lower
|
|
|
|
// stride
|
|
|
|
(
|
|
|
|
(new_x == *old_x) &&
|
|
|
|
(new_y == *old_y) &&
|
|
|
|
(new_vbi == *old_vbi) &&
|
|
|
|
(new_maxy > *old_maxy)
|
|
|
|
)
|
2001-03-31 00:09:38 +02:00
|
|
|
)
|
2001-04-01 10:07:14 +02:00
|
|
|
)
|
|
|
|
)
|
2001-03-31 00:09:38 +02:00
|
|
|
{
|
|
|
|
*old_x = new_x;
|
|
|
|
*old_y = new_y;
|
2001-05-07 21:16:04 +02:00
|
|
|
*old_maxy = new_maxy;
|
2001-03-31 00:09:38 +02:00
|
|
|
*old_vbi = new_vbi;
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, ".ok!!\n");
|
2001-03-31 00:09:38 +02:00
|
|
|
return 1;
|
|
|
|
}else{
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, ".no\n");
|
2001-03-31 00:09:38 +02:00
|
|
|
return 0;
|
2001-03-30 19:16:56 +02:00
|
|
|
}
|
2001-03-31 00:09:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2002-09-27 22:48:06 +02:00
|
|
|
static void init_video_buffers(uint8_t *buffer_base,
|
|
|
|
int view_port_height,
|
|
|
|
int bytes_per_scanline,
|
|
|
|
int max_view_port_y,
|
2002-09-25 23:08:44 +02:00
|
|
|
int use_multiple_buffers)
|
|
|
|
{
|
2002-09-27 22:48:06 +02:00
|
|
|
int bytes_per_buffer = view_port_height * bytes_per_scanline;
|
2002-09-25 23:08:44 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if(use_multiple_buffers)
|
2002-09-27 22:48:06 +02:00
|
|
|
vo_dga_nr_video_buffers = max_view_port_y / view_port_height;
|
2002-09-25 23:08:44 +02:00
|
|
|
else
|
|
|
|
vo_dga_nr_video_buffers = 1;
|
|
|
|
|
2003-02-04 17:14:54 +01:00
|
|
|
if (vo_dga_nr_video_buffers > MAX_NR_VIDEO_BUFFERS)
|
2002-09-25 23:08:44 +02:00
|
|
|
vo_dga_nr_video_buffers = MAX_NR_VIDEO_BUFFERS;
|
2003-02-04 17:14:54 +01:00
|
|
|
if (vo_dga_nr_video_buffers <= 0)
|
|
|
|
vo_dga_nr_video_buffers = 1;
|
|
|
|
|
|
|
|
vo_dga_current_video_buffer = 0;
|
2002-09-25 23:08:44 +02:00
|
|
|
|
|
|
|
for(i = 0; i < vo_dga_nr_video_buffers; i++)
|
|
|
|
{
|
2002-09-27 22:48:06 +02:00
|
|
|
vo_dga_video_buffer[i].y = i * view_port_height;
|
2002-09-25 23:08:44 +02:00
|
|
|
vo_dga_video_buffer[i].data =
|
|
|
|
buffer_base + i * bytes_per_buffer;
|
|
|
|
|
|
|
|
// Clear video buffer.
|
|
|
|
memset(vo_dga_video_buffer[i].data, 0, bytes_per_buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-01-31 10:57:13 +01:00
|
|
|
static uint32_t config( uint32_t width, uint32_t height,
|
2001-03-31 00:09:38 +02:00
|
|
|
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-03-31 00:09:38 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
int x_off, y_off;
|
2001-04-13 20:49:59 +02:00
|
|
|
int wanted_width, wanted_height;
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
static unsigned char *vo_dga_base;
|
|
|
|
static int prev_width, prev_height;
|
2001-03-31 00:09:38 +02:00
|
|
|
#ifdef HAVE_DGA2
|
|
|
|
// needed to change DGA video mode
|
2002-11-03 01:39:28 +01:00
|
|
|
int mX=VO_DGA_INVALID_RES, mY=VO_DGA_INVALID_RES , mVBI=100000, mMaxY=0, i,j=0;
|
2001-03-31 00:09:38 +02:00
|
|
|
int dga_modenum;
|
2002-11-03 01:39:28 +01:00
|
|
|
XDGAMode *modeline;
|
2001-03-31 00:09:38 +02:00
|
|
|
XDGADevice *dgadevice;
|
|
|
|
#else
|
2001-03-31 11:16:08 +02:00
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
unsigned int vm_event, vm_error;
|
|
|
|
unsigned int vm_ver, vm_rev;
|
2001-04-01 10:07:14 +02:00
|
|
|
int i, j=0, have_vm=0;
|
2002-11-03 01:39:28 +01:00
|
|
|
int mX=VO_DGA_INVALID_RES, mY=VO_DGA_INVALID_RES, mVBI=100000, mMaxY=0, dga_modenum;
|
2001-03-31 11:16:08 +02:00
|
|
|
#endif
|
2001-03-31 00:09:38 +02:00
|
|
|
int bank, ram;
|
|
|
|
#endif
|
|
|
|
|
2002-01-08 21:58:53 +01:00
|
|
|
vo_dga_src_format = format;
|
|
|
|
|
2001-04-13 20:49:59 +02:00
|
|
|
wanted_width = d_width;
|
|
|
|
wanted_height = d_height;
|
|
|
|
|
|
|
|
if(!wanted_height) wanted_height = height;
|
|
|
|
if(!wanted_width) wanted_width = width;
|
|
|
|
|
|
|
|
if( !vo_dbpp ){
|
2003-04-29 19:15:14 +02:00
|
|
|
if((format & IMGFMT_BGR_MASK) == IMGFMT_BGR){
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_src_mode = vd_ModeValid( format & 0xff );
|
2001-04-13 20:49:59 +02:00
|
|
|
}
|
2001-03-31 00:09:38 +02:00
|
|
|
}else{
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_src_mode = vd_ModeValid(vo_dbpp);
|
|
|
|
}
|
|
|
|
vo_dga_hw_mode = SRC_MODE.vdm_hw_mode;
|
|
|
|
|
|
|
|
if(!vo_dga_src_mode){
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: unsupported video format!\n");
|
2001-04-13 20:49:59 +02:00
|
|
|
return 1;
|
2001-03-31 00:09:38 +02:00
|
|
|
}
|
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_dga_vp_width = vo_screenwidth;
|
|
|
|
vo_dga_vp_height = vo_screenheight;
|
2001-03-31 11:16:08 +02:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: XServer res: %dx%d\n",
|
2001-04-13 20:49:59 +02:00
|
|
|
vo_dga_vp_width, vo_dga_vp_height);
|
2001-03-31 11:16:08 +02:00
|
|
|
|
2001-03-31 00:09:38 +02:00
|
|
|
// choose a suitable mode ...
|
|
|
|
|
|
|
|
#ifdef HAVE_DGA2
|
|
|
|
// Code to change the video mode added by Michael Graffam
|
|
|
|
// mgraffam@idsi.net
|
2001-12-04 18:24:25 +01:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: vo_modelines=%p, vo_modecount=%d\n", vo_modelines, vo_modecount);
|
2001-12-04 18:24:25 +01:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
if (vo_modelines == NULL)
|
2001-12-04 18:24:25 +01:00
|
|
|
{
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: can't get modelines\n");
|
2001-12-04 18:24:25 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
2001-04-13 20:49:59 +02:00
|
|
|
"vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n");
|
2002-11-03 01:39:28 +01:00
|
|
|
for (i=0; i<vo_modecount; i++)
|
2001-03-31 00:09:38 +02:00
|
|
|
{
|
2002-11-03 01:39:28 +01:00
|
|
|
if(vd_ModeEqual( vo_modelines[i].depth,
|
|
|
|
vo_modelines[i].bitsPerPixel,
|
|
|
|
vo_modelines[i].redMask,
|
|
|
|
vo_modelines[i].greenMask,
|
|
|
|
vo_modelines[i].blueMask,
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_hw_mode)){
|
2001-04-13 20:49:59 +02:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "maxy: %4d, depth: %2d, %4dx%4d, ",
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_modelines[i].maxViewportY, vo_modelines[i].depth,
|
|
|
|
vo_modelines[i].imageWidth, vo_modelines[i].imageHeight );
|
|
|
|
if ( check_res(i, wanted_width, wanted_height, vo_modelines[i].depth,
|
|
|
|
vo_modelines[i].viewportWidth,
|
|
|
|
vo_modelines[i].viewportHeight,
|
|
|
|
(unsigned) vo_modelines[i].verticalRefresh,
|
|
|
|
vo_modelines[i].maxViewportY,
|
2001-05-07 21:16:04 +02:00
|
|
|
&mX, &mY, &mVBI, &mMaxY )) j = i;
|
2001-03-31 00:09:38 +02:00
|
|
|
}
|
2001-03-30 19:16:56 +02:00
|
|
|
}
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
2001-05-02 00:37:37 +02:00
|
|
|
"vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n",
|
2001-04-13 20:49:59 +02:00
|
|
|
mX, mY, mVBI,
|
2001-05-02 00:37:37 +02:00
|
|
|
HW_MODE.vdm_depth,
|
|
|
|
HW_MODE.vdm_bitspp);
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
2001-05-02 00:37:37 +02:00
|
|
|
"vo_dga: Video parameters by codec: %3d x %3d, depth %2d, bitspp %2d.\n",
|
|
|
|
width, height,
|
|
|
|
SRC_MODE.vdm_depth,
|
|
|
|
SRC_MODE.vdm_bitspp);
|
2002-01-08 21:58:53 +01:00
|
|
|
vo_dga_vp_width = mX;
|
2001-03-31 00:09:38 +02:00
|
|
|
vo_dga_vp_height = mY;
|
2002-01-08 21:58:53 +01:00
|
|
|
|
|
|
|
if((flags&0x04)||(flags&0x01)) { /* -zoom or -fs */
|
|
|
|
scale_dstW = (d_width + 7) & ~7;
|
|
|
|
scale_dstH = d_height;
|
|
|
|
scale_srcW = width;
|
|
|
|
scale_srcH = height;
|
|
|
|
aspect_save_screenres(mX,mY);
|
|
|
|
aspect_save_orig(scale_srcW,scale_srcH);
|
|
|
|
aspect_save_prescale(scale_dstW,scale_dstH);
|
|
|
|
if(flags&0x01) /* -fs */
|
|
|
|
aspect(&scale_dstW,&scale_dstH,A_ZOOM);
|
|
|
|
else if(flags&0x04) /* -fs */
|
|
|
|
aspect(&scale_dstW,&scale_dstH,A_NOZOOM);
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
2002-01-08 21:58:53 +01:00
|
|
|
"vo_dga: Aspect corrected size for SwScaler: %4d x %4d.\n",
|
|
|
|
scale_dstW, scale_dstH);
|
|
|
|
/* XXX this is a hack, but I'm lazy ;-) :: atmos */
|
|
|
|
width = scale_dstW;
|
|
|
|
height = scale_dstH;
|
|
|
|
}
|
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_dga_width = vo_modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp ;
|
|
|
|
dga_modenum = vo_modelines[j].num;
|
|
|
|
modeline = vo_modelines + j;
|
2001-03-31 00:09:38 +02:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2001-03-31 11:16:08 +02:00
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
2001-04-13 20:49:59 +02:00
|
|
|
"vo_dga: DGA 1.0 compatibility code: Using XF86VidMode for mode switching!\n");
|
2001-03-31 11:16:08 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
if (XF86VidModeQueryExtension(mDisplay, &vm_event, &vm_error)) {
|
|
|
|
XF86VidModeQueryVersion(mDisplay, &vm_ver, &vm_rev);
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: XF86VidMode Extension v%i.%i\n", vm_ver, vm_rev);
|
2001-03-31 11:16:08 +02:00
|
|
|
have_vm=1;
|
|
|
|
} else {
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: XF86VidMode Extension not available.\n");
|
2001-03-31 11:16:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_VREFRESH(dotclk, x, y)( (((dotclk)/(x))*1000)/(y) )
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2001-03-31 11:16:08 +02:00
|
|
|
if (have_vm) {
|
2002-11-03 01:39:28 +01:00
|
|
|
int modecount;
|
|
|
|
XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&vo_dga_vidmodes);
|
2001-03-31 11:16:08 +02:00
|
|
|
|
|
|
|
if(vo_dga_vidmodes != NULL ){
|
2001-04-01 10:07:14 +02:00
|
|
|
for (i=0; i<modecount; i++){
|
2001-04-13 20:49:59 +02:00
|
|
|
if ( check_res(i, wanted_width, wanted_height,
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_modes[vo_dga_hw_mode].vdm_depth,
|
2001-03-31 11:16:08 +02:00
|
|
|
vo_dga_vidmodes[i]->hdisplay,
|
|
|
|
vo_dga_vidmodes[i]->vdisplay,
|
|
|
|
GET_VREFRESH(vo_dga_vidmodes[i]->dotclock,
|
|
|
|
vo_dga_vidmodes[i]->htotal,
|
|
|
|
vo_dga_vidmodes[i]->vtotal),
|
2001-05-07 21:16:04 +02:00
|
|
|
0,
|
|
|
|
&mX, &mY, &mVBI, &mMaxY )) j = i;
|
2001-03-31 11:16:08 +02:00
|
|
|
}
|
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO,
|
2001-04-13 20:49:59 +02:00
|
|
|
"vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n",
|
|
|
|
mX, mY, mVBI,
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_modes[vo_dga_hw_mode].vdm_depth,
|
|
|
|
vo_dga_modes[vo_dga_hw_mode].vdm_bitspp,
|
2001-04-13 20:49:59 +02:00
|
|
|
width, height);
|
2001-03-31 11:16:08 +02:00
|
|
|
}else{
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: XF86VidMode returned no screens - using current resolution.\n");
|
2001-03-31 11:16:08 +02:00
|
|
|
}
|
|
|
|
dga_modenum = j;
|
|
|
|
vo_dga_vp_width = mX;
|
|
|
|
vo_dga_vp_height = mY;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Only have DGA 1.0 extension and no XF86VidMode :-(\n");
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " Thus, resolution switching is NOT possible.\n");
|
2001-04-13 20:49:59 +02:00
|
|
|
|
2001-03-31 11:16:08 +02:00
|
|
|
#endif
|
2001-03-31 00:09:38 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
vo_dga_src_width = width;
|
|
|
|
vo_dga_src_height = height;
|
|
|
|
|
|
|
|
if(vo_dga_src_width > vo_dga_vp_width ||
|
|
|
|
vo_dga_src_height > vo_dga_vp_height)
|
|
|
|
{
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Sorry, video larger than viewport is not yet supported!\n");
|
2001-03-31 00:09:38 +02:00
|
|
|
// ugly, do something nicer in the future ...
|
2001-03-31 11:16:08 +02:00
|
|
|
#ifndef HAVE_DGA2
|
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
if(vo_dga_vidmodes){
|
|
|
|
XFree(vo_dga_vidmodes);
|
|
|
|
vo_dga_vidmodes = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
2001-03-31 00:09:38 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2001-06-18 00:21:47 +02:00
|
|
|
|
|
|
|
if(vo_dga_vp_width == VO_DGA_INVALID_RES){
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Something is wrong with your DGA. There doesn't seem to be a\n"
|
2001-06-18 18:38:06 +02:00
|
|
|
" single suitable mode!\n"
|
2003-06-13 03:25:11 +02:00
|
|
|
" Please file a bug report (see DOCS/en/bugreports.html)\n");
|
2001-06-18 00:21:47 +02:00
|
|
|
#ifndef HAVE_DGA2
|
|
|
|
#ifdef HAVE_XF86VM
|
|
|
|
if(vo_dga_vidmodes){
|
|
|
|
XFree(vo_dga_vidmodes);
|
|
|
|
vo_dga_vidmodes = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-03-31 00:09:38 +02:00
|
|
|
// now lets start the DGA thing
|
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
if ( !vo_config_count || width != prev_width || height != prev_height )
|
|
|
|
{
|
2001-03-31 00:09:38 +02:00
|
|
|
#ifdef HAVE_DGA2
|
2002-11-03 01:39:28 +01:00
|
|
|
|
|
|
|
if (!XDGAOpenFramebuffer(mDisplay, mScreen)){
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Framebuffer mapping failed!!!\n");
|
|
|
|
return 1;
|
2001-03-31 00:09:38 +02:00
|
|
|
}
|
2002-11-03 01:39:28 +01:00
|
|
|
|
|
|
|
dgadevice=XDGASetMode(mDisplay, mScreen, dga_modenum);
|
|
|
|
XDGASync(mDisplay, mScreen);
|
2001-03-27 06:29:22 +02:00
|
|
|
|
2001-03-31 00:09:38 +02:00
|
|
|
vo_dga_base = dgadevice->data;
|
2001-03-27 06:29:22 +02:00
|
|
|
XFree(dgadevice);
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
XDGASetViewport (mDisplay, mScreen, 0, 0, XDGAFlipRetrace);
|
|
|
|
|
2001-03-28 21:58:45 +02:00
|
|
|
#else
|
2002-11-03 01:39:28 +01:00
|
|
|
|
2001-03-31 11:16:08 +02:00
|
|
|
#ifdef HAVE_XF86VM
|
2001-12-28 21:52:54 +01:00
|
|
|
if (have_vm)
|
|
|
|
{
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86VidModeLockModeSwitch(mDisplay,mScreen,0);
|
2001-03-31 11:16:08 +02:00
|
|
|
// Two calls are needed to switch modes on my ATI Rage 128. Why?
|
|
|
|
// for riva128 one call is enough!
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86VidModeSwitchToMode(mDisplay,mScreen,vo_dga_vidmodes[dga_modenum]);
|
|
|
|
XF86VidModeSwitchToMode(mDisplay,mScreen,vo_dga_vidmodes[dga_modenum]);
|
2001-12-28 21:52:54 +01:00
|
|
|
}
|
2001-03-31 11:16:08 +02:00
|
|
|
#endif
|
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86DGAGetViewPortSize(mDisplay,mScreen,
|
2001-03-30 19:16:56 +02:00
|
|
|
&vo_dga_vp_width,
|
|
|
|
&vo_dga_vp_height);
|
2001-03-27 06:29:22 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86DGAGetVideo (mDisplay, mScreen,
|
2001-03-30 19:16:56 +02:00
|
|
|
(char **)&vo_dga_base, &vo_dga_width, &bank, &ram);
|
2001-03-28 21:58:45 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86DGADirectVideo (mDisplay, mScreen,
|
2001-03-31 00:09:38 +02:00
|
|
|
XF86DGADirectGraphics | XF86DGADirectMouse |
|
|
|
|
XF86DGADirectKeyb);
|
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
XF86DGASetViewPort (mDisplay, mScreen, 0, 0);
|
2001-03-31 00:09:38 +02:00
|
|
|
|
2001-03-28 21:58:45 +02:00
|
|
|
#endif
|
2002-11-03 01:39:28 +01:00
|
|
|
}
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
// do some more checkings here ...
|
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n",
|
2001-02-27 02:08:44 +01:00
|
|
|
vo_dga_width, vo_dga_vp_width,
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_vp_height, HW_MODE.vdm_bytespp, vo_dga_base,
|
|
|
|
HW_MODE.vdm_bitspp);
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
x_off = (vo_dga_vp_width - vo_dga_src_width)>>1;
|
|
|
|
y_off = (vo_dga_vp_height - vo_dga_src_height)>>1;
|
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp;
|
2001-03-31 00:09:38 +02:00
|
|
|
vo_dga_lines = vo_dga_src_height;
|
2001-02-27 02:08:44 +01:00
|
|
|
|
|
|
|
vo_dga_src_offset = 0;
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * HW_MODE.vdm_bytespp;
|
2001-02-27 02:08:44 +01:00
|
|
|
|
2001-05-02 00:37:37 +02:00
|
|
|
vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo
|
2001-02-27 02:08:44 +01:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n",
|
2001-02-27 02:08:44 +01:00
|
|
|
vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line);
|
|
|
|
|
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
XGrabKeyboard (mDisplay, DefaultRootWindow(mDisplay), True,
|
2001-02-27 02:08:44 +01:00
|
|
|
GrabModeAsync,GrabModeAsync, CurrentTime);
|
2002-09-28 22:09:14 +02:00
|
|
|
if(vo_grabpointer)
|
2002-11-03 01:39:28 +01:00
|
|
|
XGrabPointer (mDisplay, DefaultRootWindow(mDisplay), True,
|
2001-02-27 02:08:44 +01:00
|
|
|
ButtonPressMask,GrabModeAsync, GrabModeAsync,
|
|
|
|
None, None, CurrentTime);
|
2001-06-17 22:59:39 +02:00
|
|
|
|
2002-11-03 01:39:28 +01:00
|
|
|
if ( !vo_config_count || width != prev_width || height != prev_height )
|
|
|
|
{
|
|
|
|
init_video_buffers(vo_dga_base,
|
2002-09-27 22:48:06 +02:00
|
|
|
vo_dga_vp_height,
|
|
|
|
vo_dga_width * HW_MODE.vdm_bytespp,
|
2002-11-03 01:39:28 +01:00
|
|
|
#ifdef HAVE_DGA2
|
2002-09-27 22:48:06 +02:00
|
|
|
modeline->maxViewportY,
|
|
|
|
#else
|
|
|
|
vo_dga_vp_height,
|
|
|
|
#endif
|
|
|
|
vo_doublebuffering);
|
2002-11-03 01:39:28 +01:00
|
|
|
prev_width=width; prev_height=height;
|
|
|
|
}
|
2001-06-17 22:59:39 +02:00
|
|
|
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: Using %d frame buffer%s.\n",
|
2002-09-25 23:08:44 +02:00
|
|
|
vo_dga_nr_video_buffers, vo_dga_nr_video_buffers == 1 ? "" : "s");
|
2001-03-31 01:12:31 +02:00
|
|
|
|
2001-02-27 02:08:44 +01:00
|
|
|
vo_dga_is_running = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-10-27 04:15:48 +01:00
|
|
|
static int dga_depths_init = 0;
|
|
|
|
|
2002-01-26 17:01:26 +01:00
|
|
|
static uint32_t preinit(const char *arg)
|
|
|
|
{
|
2002-02-17 09:24:43 +01:00
|
|
|
if(arg)
|
|
|
|
{
|
2002-09-25 23:18:43 +02:00
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Unknown subdevice: %s\n",arg);
|
2002-02-17 09:24:43 +01:00
|
|
|
return ENOSYS;
|
|
|
|
}
|
2002-10-27 04:15:48 +01:00
|
|
|
|
|
|
|
if( !vo_init() ) return -1; // Can't open X11
|
|
|
|
|
|
|
|
if(dga_depths_init == 0){ // FIXME!?
|
|
|
|
int i;
|
|
|
|
|
|
|
|
vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen);
|
|
|
|
|
|
|
|
if(vo_dga_XServer_mode ==0){
|
|
|
|
#ifndef HAVE_DGA2
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: Your X-Server is not running in a ");
|
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "resolution supported by DGA driver!\n");
|
|
|
|
#endif
|
|
|
|
}//else{
|
|
|
|
// mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: X running at: %s\n",
|
|
|
|
// vd_GetModeString(vo_dga_XServer_mode));
|
|
|
|
//}
|
|
|
|
|
|
|
|
#ifdef HAVE_DGA2
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_modelines=XDGAQueryModes(mDisplay, mScreen, &vo_modecount);
|
|
|
|
if(vo_modelines){
|
|
|
|
for(i=0; i< vo_modecount; i++){
|
2002-10-27 04:15:48 +01:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo_dga: (%03d) depth=%d, bpp=%d, r=%08x, g=%08x, b=%08x, %d x %d\n",
|
|
|
|
i,
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_modelines[i].depth,
|
|
|
|
vo_modelines[i].bitsPerPixel,
|
|
|
|
vo_modelines[i].redMask,
|
|
|
|
vo_modelines[i].greenMask,
|
|
|
|
vo_modelines[i].blueMask,
|
|
|
|
vo_modelines[i].viewportWidth,
|
|
|
|
vo_modelines[i].viewportHeight);
|
2002-10-27 04:15:48 +01:00
|
|
|
vd_EnableMode(
|
2002-11-03 01:39:28 +01:00
|
|
|
vo_modelines[i].depth,
|
|
|
|
vo_modelines[i].bitsPerPixel,
|
|
|
|
vo_modelines[i].redMask,
|
|
|
|
vo_modelines[i].greenMask,
|
|
|
|
vo_modelines[i].blueMask);
|
2002-10-27 04:15:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
dga_depths_init = 1;
|
|
|
|
|
|
|
|
if( !vo_dga_modes[1].vdm_supported && vo_dga_modes[2].vdm_supported ){
|
|
|
|
vo_dga_modes[1].vdm_supported = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !vo_dga_modes[3].vdm_supported && vo_dga_modes[4].vdm_supported ){
|
|
|
|
vo_dga_modes[3].vdm_supported = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=1; i<vo_dga_mode_num; i++){
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "vo_dga: Mode: %s", vd_GetModeString(i));
|
|
|
|
if(vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth){
|
|
|
|
vo_dga_modes[i].vdm_supported = 0;
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, " ...disabled by -bpp %d", vo_dbpp );
|
|
|
|
}
|
|
|
|
mp_msg(MSGT_VO, MSGL_INFO, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-17 09:24:43 +01:00
|
|
|
return 0;
|
2002-01-26 17:01:26 +01:00
|
|
|
}
|
|
|
|
|
2002-11-03 16:14:36 +01:00
|
|
|
static uint32_t get_image(mp_image_t *mpi)
|
|
|
|
{
|
|
|
|
if (
|
|
|
|
!IMGFMT_IS_BGR(mpi->imgfmt) ||
|
|
|
|
(IMGFMT_BGR_DEPTH(mpi->imgfmt) != vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth) ||
|
|
|
|
(mpi->type==MP_IMGTYPE_STATIC && vo_dga_nr_video_buffers>1) ||
|
|
|
|
(mpi->type==MP_IMGTYPE_IP && vo_dga_nr_video_buffers<2) ||
|
|
|
|
(mpi->type==MP_IMGTYPE_IPB)
|
|
|
|
)
|
|
|
|
return(VO_FALSE);
|
|
|
|
|
|
|
|
if( (mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE) ||
|
|
|
|
(mpi->flags&MP_IMGFLAG_ACCEPT_WIDTH &&
|
|
|
|
((vo_dga_bytes_per_line+vo_dga_vp_skip)%(mpi->bpp/8))==0 ) ||
|
|
|
|
(mpi->width*(mpi->bpp/8)==(vo_dga_bytes_per_line+vo_dga_vp_skip)) ){
|
|
|
|
|
|
|
|
mpi->planes[0] = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
|
|
|
|
mpi->stride[0] = vo_dga_bytes_per_line + vo_dga_vp_skip;
|
|
|
|
mpi->width=(vo_dga_bytes_per_line+vo_dga_vp_skip)/(mpi->bpp/8);
|
|
|
|
mpi->flags |= MP_IMGFLAG_DIRECT;
|
|
|
|
return(VO_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(VO_FALSE);
|
|
|
|
}
|
|
|
|
|
2002-02-09 02:21:48 +01:00
|
|
|
static uint32_t control(uint32_t request, void *data, ...)
|
2002-01-26 17:01:26 +01:00
|
|
|
{
|
2002-02-09 01:47:26 +01:00
|
|
|
switch (request) {
|
2002-11-03 16:14:36 +01:00
|
|
|
case VOCTRL_GET_IMAGE:
|
|
|
|
return get_image(data);
|
2002-02-09 01:47:26 +01:00
|
|
|
case VOCTRL_QUERY_FORMAT:
|
|
|
|
return query_format(*((uint32_t*)data));
|
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
2002-01-26 17:01:26 +01:00
|
|
|
}
|
|
|
|
|
2001-03-30 19:16:56 +02:00
|
|
|
//---------------------------------------------------------
|