summaryrefslogtreecommitdiffstats
path: root/libvo/vo_dga.c
diff options
context:
space:
mode:
authorattila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-06-14 04:53:03 +0000
committerattila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-06-14 04:53:03 +0000
commit0e4e21aac59563f297b3ece42cec0031fcfd47b1 (patch)
treef985373c16526ebb690273613e94b694b711b6db /libvo/vo_dga.c
parentb44c3a048ad7e1a7ac0e20316947783aa20ca226 (diff)
downloadmpv-0e4e21aac59563f297b3ece42cec0031fcfd47b1.tar.bz2
mpv-0e4e21aac59563f297b3ece42cec0031fcfd47b1.tar.xz
major reindentation of x11 code try #2
note that this is plain ident output, i didnt tweak it by hand like the last attempt. if anyone is interested in the indent profile i used, just drop me a mail. please contact me on irc on how to send me my share of cola, but be aware that i will only accept swiss or german cola, as the japanese is way to sweet :) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12583 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_dga.c')
-rw-r--r--libvo/vo_dga.c1372
1 files changed, 712 insertions, 660 deletions
diff --git a/libvo/vo_dga.c b/libvo/vo_dga.c
index 5055de2753..30bf24f37b 100644
--- a/libvo/vo_dga.c
+++ b/libvo/vo_dga.c
@@ -30,168 +30,181 @@
#include <X11/extensions/xf86vmode.h>
#endif
-static vo_info_t info =
-{
+static vo_info_t info = {
#ifdef HAVE_DGA2
- "DGA ( Direct Graphic Access V2.0 )",
+ "DGA ( Direct Graphic Access V2.0 )",
#else
#ifdef HAVE_XF86VM
- "DGA ( Direct Graphic Access V1.0+XF86VidModeExt. )",
+ "DGA ( Direct Graphic Access V1.0+XF86VidModeExt. )",
#else
- "DGA ( Direct Graphic Access V1.0 )",
+ "DGA ( Direct Graphic Access V1.0 )",
#endif
#endif
- "dga",
- "Andreas Ackermann <acki@acki-netz.de>",
- ""
+ "dga",
+ "Andreas Ackermann <acki@acki-netz.de>",
+ ""
};
-LIBVO_EXTERN( dga )
-
-
+LIBVO_EXTERN(dga)
//------------------------------------------------------------------
-
-
//#define BITSPP (vo_dga_modes[vo_dga_active_mode].vdm_bitspp)
//#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp)
-
#define VO_DGA_INVALID_RES 100000
-
#define HW_MODE (vo_dga_modes[vo_dga_hw_mode])
-#define SRC_MODE (vo_dga_modes[vo_dga_src_mode])
-
-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;
- int vdm_hw_mode;
+#define SRC_MODE (vo_dga_modes[vo_dga_src_mode])
+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;
+ int vdm_hw_mode;
};
//------------------------------------------------------------------
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
-
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, },
- { 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}
+ // 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
+
+ {0, 0, 0, 0, 0, 0, 0, 0, 0,},
+ {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}
};
-static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes);
+static int vo_dga_mode_num =
+ sizeof(vo_dga_modes) / sizeof(struct vd_modes);
// enable a HW mode (by description)
-static int vd_EnableMode( int depth, int bitspp,
- 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;
- vo_dga_modes[i].vdm_hw_mode = i;
- return i;
+static int vd_EnableMode(int depth, int bitspp,
+ 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;
+ vo_dga_modes[i].vdm_hw_mode = i;
+ return i;
+ }
}
- }
- return 0;
+ return 0;
}
-static int vd_ModeEqual(int depth, int bitspp,
- 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);
+static int vd_ModeEqual(int depth, int bitspp,
+ 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);
}
// enable a HW mode (mplayer_depth decides which)
-static int vd_ValidateMode( int mplayer_depth){
- 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;
- vo_dga_modes[i].vdm_hw_mode = i;
- return i;
+static int vd_ValidateMode(int mplayer_depth)
+{
+ 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;
+ vo_dga_modes[i].vdm_hw_mode = i;
+ return i;
+ }
}
- }
- return 0;
+ return 0;
}
// do we support this mode? (not important whether native or conversion)
-static int vd_ModeValid( int mplayer_depth){
- 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;
+static int vd_ModeValid(int mplayer_depth)
+{
+ 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;
+ return 0;
}
-static char *vd_GetModeString(int index){
+static char *vd_GetModeString(int index)
+{
#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,
- "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)",
- 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,
- vo_dga_modes[index].vdm_supported ? "native" : "not supported",
- vo_dga_modes[index].vdm_mplayer_depth);
- return stringbuf;
+ static char stringbuf[VO_DGA_MAX_STRING_LEN];
+
+ stringbuf[VO_DGA_MAX_STRING_LEN - 1] = 0;
+ snprintf(stringbuf, VO_DGA_MAX_STRING_LEN - 2,
+ "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)",
+ 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,
+ vo_dga_modes[index].
+ vdm_supported ? "native" : "not supported",
+ vo_dga_modes[index].vdm_mplayer_depth);
+ return stringbuf;
}
//-----------------------------------------------------------------
#if defined(HAVE_XF86VM) && !defined(HAVE_DGA2)
-static XF86VidModeModeInfo **vo_dga_vidmodes=NULL;
+static XF86VidModeModeInfo **vo_dga_vidmodes = NULL;
#endif
-static int vo_dga_src_format;
-static int vo_dga_width; // bytes per line in framebuffer
-static int vo_dga_vp_width; // visible pixels per line in
+static int vo_dga_src_format;
+static int vo_dga_width; // bytes per line in framebuffer
+static int vo_dga_vp_width; // visible pixels per line in
+
// framebuffer
-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
-static int vo_dga_vp_offset=0; // offset in dest
-static int vo_dga_bytes_per_line; // bytes per line to copy
-static int vo_dga_vp_skip; // dto. for dest
-static int vo_dga_lines; // num of lines to copy
-static int vo_dga_hw_mode = 0; // index in mode list that is actually
+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
+static int vo_dga_vp_offset = 0; // offset in dest
+static int vo_dga_bytes_per_line; // bytes per line to copy
+static int vo_dga_vp_skip; // dto. for dest
+static int vo_dga_lines; // num of lines to copy
+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
+static int vo_dga_src_mode = 0; // index in mode list that is used by
+
// codec
-static int vo_dga_XServer_mode = 0;// index in mode list for resolution
+static int vo_dga_XServer_mode = 0; // index in mode list for resolution
#ifdef HAVE_DGA2
- static XDGAMode * vo_modelines;
- static int vo_modecount;
+static XDGAMode *vo_modelines;
+static int vo_modecount;
#endif
#define MAX_NR_VIDEO_BUFFERS 3
@@ -199,48 +212,53 @@ static int vo_dga_XServer_mode = 0;// index in mode list for resolution
#define CURRENT_VIDEO_BUFFER \
(vo_dga_video_buffer[vo_dga_current_video_buffer])
-static int vo_dga_nr_video_buffers; // Total number of frame buffers.
-static int vo_dga_current_video_buffer; // Buffer available for rendering.
+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;
+ int y;
+ uint8_t *data;
} vo_dga_video_buffer[MAX_NR_VIDEO_BUFFERS];
/* saved src and dst dimensions for SwScaler */
static unsigned int scale_srcW = 0,
- scale_dstW = 0,
- scale_srcH = 0,
- scale_dstH = 0;
+ scale_dstW = 0, scale_srcH = 0, scale_dstH = 0;
//---------------------------------------------------------
-static void draw_alpha( int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride ){
-
- char *d;
- unsigned int offset;
- unsigned int buffer_stride;
-
- offset = vo_dga_width * y0 +x0;
- buffer_stride = vo_dga_width;
- d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
-
- 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;
- }
+static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
+ unsigned char *srca, int stride)
+{
+
+ char *d;
+ unsigned int offset;
+ unsigned int buffer_stride;
+
+ offset = vo_dga_width * y0 + x0;
+ buffer_stride = vo_dga_width;
+ d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
+
+ 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;
+ }
}
@@ -251,53 +269,56 @@ static void draw_alpha( int x0,int y0, int w,int h, unsigned char* src, unsigned
// quick & dirty - for debugging only
#if 0
-static void fillblock(char *strt, int yoff, int lines, int val){
- 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;
- }
+static void fillblock(char *strt, int yoff, int lines, int val)
+{
+ 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;
+ }
}
#endif
//---------------------------------------------------------
-static uint32_t draw_frame( uint8_t *src[] ){
+static uint32_t draw_frame(uint8_t * src[])
+{
+
+ int vp_skip = vo_dga_vp_skip;
+ int numlines = vo_dga_lines;
+
+ char *s, *d;
- int vp_skip = vo_dga_vp_skip;
- int numlines = vo_dga_lines;
+ s = *src;
+ d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
- char *s, *d;
+ mem2agpcpy_pic(d, s,
+ vo_dga_bytes_per_line,
+ numlines,
+ vo_dga_bytes_per_line + vo_dga_vp_skip,
+ vo_dga_bytes_per_line);
- s = *src;
- d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
-
- mem2agpcpy_pic(
- d, s,
- vo_dga_bytes_per_line,
- numlines,
- vo_dga_bytes_per_line+vo_dga_vp_skip,
- vo_dga_bytes_per_line);
-
- // DBG-COde
+ // DBG-COde
#if 0
- d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
- 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);
+ d = CURRENT_VIDEO_BUFFER.data + vo_dga_vp_offset;
+ 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);
#endif
- return 0;
+ return 0;
}
//---------------------------------------------------------
static void check_events(void)
{
- vo_x11_check_events(mDisplay);
+ vo_x11_check_events(mDisplay);
}
//---------------------------------------------------------
@@ -305,96 +326,100 @@ static void check_events(void)
#include "sub.h"
static void draw_osd(void)
-{ vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha); }
+{
+ vo_draw_text(vo_dga_src_width, vo_dga_src_height, draw_alpha);
+}
static void switch_video_buffers(void)
{
- vo_dga_current_video_buffer =
- (vo_dga_current_video_buffer + 1) % vo_dga_nr_video_buffers;
+ vo_dga_current_video_buffer =
+ (vo_dga_current_video_buffer + 1) % vo_dga_nr_video_buffers;
}
-static void flip_page( void )
+static void flip_page(void)
{
- if(1 < vo_dga_nr_video_buffers)
- {
+ if (1 < vo_dga_nr_video_buffers)
+ {
#ifdef HAVE_DGA2
- XDGASetViewport(mDisplay, mScreen,
- 0,
- CURRENT_VIDEO_BUFFER.y,
- XDGAFlipRetrace);
+ XDGASetViewport(mDisplay, mScreen,
+ 0, CURRENT_VIDEO_BUFFER.y, XDGAFlipRetrace);
#else
- XF86DGASetViewPort(mDisplay, mScreen,
- 0,
- CURRENT_VIDEO_BUFFER.y);
+ XF86DGASetViewPort(mDisplay, mScreen, 0, CURRENT_VIDEO_BUFFER.y);
#endif
- switch_video_buffers();
- }
+ switch_video_buffers();
+ }
}
//---------------------------------------------------------
-static uint32_t draw_slice( uint8_t *src[],int stride[],
- int w,int h,int x,int y )
+static uint32_t draw_slice(uint8_t * src[], int stride[],
+ int w, int h, int x, int y)
{
- return 0;
+ return 0;
};
//---------------------------------------------------------
-static uint32_t query_format( uint32_t format )
+static uint32_t query_format(uint32_t format)
{
- if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR &&
- vd_ModeValid(format&0xff))
- {
- return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_OSD;
- }
-
- return 0;
+ if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR &&
+ vd_ModeValid(format & 0xff))
+ {
+ return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD;
+ }
+
+ return 0;
}
//---------------------------------------------------------
-static void
-uninit(void)
+static void uninit(void)
{
#ifdef HAVE_DGA2
- XDGADevice *dgadevice;
+ XDGADevice *dgadevice;
#endif
- if ( !vo_config_count ) return;
+ if (!vo_config_count)
+ return;
- if(vo_dga_is_running){
- vo_dga_is_running = 0;
- mp_msg(MSGT_VO, MSGL_V, "vo_dga: in uninit\n");
- if(vo_grabpointer)
- XUngrabPointer (mDisplay, CurrentTime);
- XUngrabKeyboard (mDisplay, CurrentTime);
+ if (vo_dga_is_running)
+ {
+ vo_dga_is_running = 0;
+ mp_msg(MSGT_VO, MSGL_V, "vo_dga: in uninit\n");
+ if (vo_grabpointer)
+ XUngrabPointer(mDisplay, CurrentTime);
+ XUngrabKeyboard(mDisplay, CurrentTime);
#ifdef HAVE_DGA2
- XDGACloseFramebuffer(mDisplay, mScreen);
- dgadevice = XDGASetMode(mDisplay, mScreen, 0);
- if(dgadevice != NULL){
- XFree(dgadevice);
- }
+ XDGACloseFramebuffer(mDisplay, mScreen);
+ dgadevice = XDGASetMode(mDisplay, mScreen, 0);
+ if (dgadevice != NULL)
+ {
+ XFree(dgadevice);
+ }
#else
- XF86DGADirectVideo (mDisplay, mScreen, 0);
- // first disable DirectVideo and then switch mode back!
+ XF86DGADirectVideo(mDisplay, mScreen, 0);
+ // first disable DirectVideo and then switch mode back!
#ifdef HAVE_XF86VM
- if (vo_dga_vidmodes != NULL ){
- int screen; screen=XDefaultScreen( mDisplay );
- mp_msg(MSGT_VO, MSGL_V, "vo_dga: VidModeExt: Switching back..\n");
- // seems some graphics adaptors need this more than once ...
- 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]);
- XFree(vo_dga_vidmodes);
- }
+ if (vo_dga_vidmodes != NULL)
+ {
+ int screen;
+
+ screen = XDefaultScreen(mDisplay);
+ mp_msg(MSGT_VO, MSGL_V,
+ "vo_dga: VidModeExt: Switching back..\n");
+ // seems some graphics adaptors need this more than once ...
+ 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]);
+ XFree(vo_dga_vidmodes);
+ }
#endif
#endif
- }
- vo_x11_uninit();
+ }
+ vo_x11_uninit();
}
@@ -402,75 +427,57 @@ uninit(void)
// TODO: check for larger maxy value
// (useful for double buffering!!!)
-static int check_res( int num, int x, int y, int bpp,
- int new_x, int new_y, int new_vbi, int new_maxy,
- int *old_x, int *old_y, int *old_vbi, int *old_maxy){
-
- mp_msg(MSGT_VO, MSGL_V, "vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ depth %2d ..",
- num, new_x, new_y, new_vbi, bpp );
- mp_msg(MSGT_VO, MSGL_V, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi);
- 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))
- )
- // 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)
- ||
- (
- (
- (new_x == *old_x) &&
- (new_y == *old_y) &&
- (
- (
- new_vbi >= *old_vbi && *old_vbi < 50
- )
- ||
- (
- *old_vbi >= 50 &&
- new_vbi < *old_vbi &&
- new_vbi >= 50
- )
- )
- )
- ||
- // 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)
- )
- )
- )
- )
+static int check_res(int num, int x, int y, int bpp,
+ int new_x, int new_y, int new_vbi, int new_maxy,
+ int *old_x, int *old_y, int *old_vbi, int *old_maxy)
+{
+
+ mp_msg(MSGT_VO, MSGL_V,
+ "vo_dga: (%3d) Trying %4d x %4d @ %3d Hz @ depth %2d ..", num,
+ new_x, new_y, new_vbi, bpp);
+ mp_msg(MSGT_VO, MSGL_V, "(old: %dx%d@%d).", *old_x, *old_y, *old_vbi);
+ 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)))
+ // 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)
+ ||
+ (((new_x == *old_x) &&
+ (new_y == *old_y) &&
+ ((new_vbi >= *old_vbi
+ && *old_vbi < 50)
+ || (*old_vbi >= 50
+ && new_vbi < *old_vbi
+ && new_vbi >= 50))) ||
+ // 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)))))
{
- *old_x = new_x;
- *old_y = new_y;
- *old_maxy = new_maxy;
- *old_vbi = new_vbi;
- mp_msg(MSGT_VO, MSGL_V, ".ok!!\n");
- return 1;
- }else{
- mp_msg(MSGT_VO, MSGL_V, ".no\n");
- return 0;
+ *old_x = new_x;
+ *old_y = new_y;
+ *old_maxy = new_maxy;
+ *old_vbi = new_vbi;
+ mp_msg(MSGT_VO, MSGL_V, ".ok!!\n");
+ return 1;
+ } else
+ {
+ mp_msg(MSGT_VO, MSGL_V, ".no\n");
+ return 0;
}
}
@@ -478,460 +485,505 @@ static int check_res( int num, int x, int y, int bpp,
//---------------------------------------------------------
-static void init_video_buffers(uint8_t *buffer_base,
- int view_port_height,
- int bytes_per_scanline,
- int max_view_port_y,
- int use_multiple_buffers)
+static void init_video_buffers(uint8_t * buffer_base,
+ int view_port_height,
+ int bytes_per_scanline,
+ int max_view_port_y,
+ int use_multiple_buffers)
{
- int bytes_per_buffer = view_port_height * bytes_per_scanline;
- int i;
-
- if(use_multiple_buffers)
- vo_dga_nr_video_buffers = max_view_port_y / view_port_height;
- else
- vo_dga_nr_video_buffers = 1;
-
- if (vo_dga_nr_video_buffers > MAX_NR_VIDEO_BUFFERS)
- vo_dga_nr_video_buffers = MAX_NR_VIDEO_BUFFERS;
- if (vo_dga_nr_video_buffers <= 0)
- vo_dga_nr_video_buffers = 1;
-
- vo_dga_current_video_buffer = 0;
-
- for(i = 0; i < vo_dga_nr_video_buffers; i++)
- {
- vo_dga_video_buffer[i].y = i * view_port_height;
- 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);
- }
+ int bytes_per_buffer = view_port_height * bytes_per_scanline;
+ int i;
+
+ if (use_multiple_buffers)
+ vo_dga_nr_video_buffers = max_view_port_y / view_port_height;
+ else
+ vo_dga_nr_video_buffers = 1;
+
+ if (vo_dga_nr_video_buffers > MAX_NR_VIDEO_BUFFERS)
+ vo_dga_nr_video_buffers = MAX_NR_VIDEO_BUFFERS;
+ if (vo_dga_nr_video_buffers <= 0)
+ vo_dga_nr_video_buffers = 1;
+
+ vo_dga_current_video_buffer = 0;
+
+ for (i = 0; i < vo_dga_nr_video_buffers; i++)
+ {
+ vo_dga_video_buffer[i].y = i * view_port_height;
+ 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);
+ }
}
-static uint32_t config( uint32_t width, uint32_t height,
- uint32_t d_width,uint32_t d_height,
- uint32_t flags,char *title,uint32_t format)
+static uint32_t config(uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height,
+ uint32_t flags, char *title, uint32_t format)
{
- int x_off, y_off;
- int wanted_width, wanted_height;
+ int x_off, y_off;
+ int wanted_width, wanted_height;
+
+ static unsigned char *vo_dga_base;
+ static int prev_width, prev_height;
- static unsigned char *vo_dga_base;
- static int prev_width, prev_height;
#ifdef HAVE_DGA2
- // needed to change DGA video mode
- int mX=VO_DGA_INVALID_RES, mY=VO_DGA_INVALID_RES , mVBI=100000, mMaxY=0, i,j=0;
- int dga_modenum;
- XDGAMode *modeline;
- XDGADevice *dgadevice;
+ // needed to change DGA video mode
+ int mX = VO_DGA_INVALID_RES, mY = VO_DGA_INVALID_RES, mVBI =
+ 100000, mMaxY = 0, i, j = 0;
+ int dga_modenum;
+ XDGAMode *modeline;
+ XDGADevice *dgadevice;
#else
#ifdef HAVE_XF86VM
- unsigned int vm_event, vm_error;
- unsigned int vm_ver, vm_rev;
- int i, j=0, have_vm=0;
- int mX=VO_DGA_INVALID_RES, mY=VO_DGA_INVALID_RES, mVBI=100000, mMaxY=0, dga_modenum;
+ unsigned int vm_event, vm_error;
+ unsigned int vm_ver, vm_rev;
+ int i, j = 0, have_vm = 0;
+ int mX = VO_DGA_INVALID_RES, mY = VO_DGA_INVALID_RES, mVBI =
+ 100000, mMaxY = 0, dga_modenum;
#endif
- int bank, ram;
+ int bank, ram;
#endif
- vo_dga_src_format = format;
+ vo_dga_src_format = format;
- wanted_width = d_width;
- wanted_height = d_height;
+ wanted_width = d_width;
+ wanted_height = d_height;
- if(!wanted_height) wanted_height = height;
- if(!wanted_width) wanted_width = width;
+ if (!wanted_height)
+ wanted_height = height;
+ if (!wanted_width)
+ wanted_width = width;
- if( !vo_dbpp ){
- if((format & IMGFMT_BGR_MASK) == IMGFMT_BGR){
- vo_dga_src_mode = vd_ModeValid( format & 0xff );
+ if (!vo_dbpp)
+ {
+ if ((format & IMGFMT_BGR_MASK) == IMGFMT_BGR)
+ {
+ vo_dga_src_mode = vd_ModeValid(format & 0xff);
+ }
+ } else
+ {
+ vo_dga_src_mode = vd_ModeValid(vo_dbpp);
+ }
+ vo_dga_hw_mode = SRC_MODE.vdm_hw_mode;
+
+ if (!vo_dga_src_mode)
+ {
+ mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: unsupported video format!\n");
+ return 1;
}
- }else{
- vo_dga_src_mode = vd_ModeValid(vo_dbpp);
- }
- vo_dga_hw_mode = SRC_MODE.vdm_hw_mode;
-
- if(!vo_dga_src_mode){
- mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: unsupported video format!\n");
- return 1;
- }
-
- vo_dga_vp_width = vo_screenwidth;
- vo_dga_vp_height = vo_screenheight;
-
- mp_msg(MSGT_VO, MSGL_V, "vo_dga: XServer res: %dx%d\n",
- vo_dga_vp_width, vo_dga_vp_height);
+
+ vo_dga_vp_width = vo_screenwidth;
+ vo_dga_vp_height = vo_screenheight;
+
+ mp_msg(MSGT_VO, MSGL_V, "vo_dga: XServer res: %dx%d\n",
+ vo_dga_vp_width, vo_dga_vp_height);
// choose a suitable mode ...
-
+
#ifdef HAVE_DGA2
// Code to change the video mode added by Michael Graffam
// mgraffam@idsi.net
- mp_msg(MSGT_VO, MSGL_V, "vo_dga: vo_modelines=%p, vo_modecount=%d\n", vo_modelines, vo_modecount);
-
- if (vo_modelines == NULL)
- {
- mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: can't get modelines\n");
- return 1;
- }
-
- mp_msg(MSGT_VO, MSGL_INFO,
- "vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n");
- for (i=0; i<vo_modecount; i++)
- {
- if(vd_ModeEqual( vo_modelines[i].depth,
- vo_modelines[i].bitsPerPixel,
- vo_modelines[i].redMask,
- vo_modelines[i].greenMask,
- vo_modelines[i].blueMask,
- vo_dga_hw_mode)){
-
- mp_msg(MSGT_VO, MSGL_V, "maxy: %4d, depth: %2d, %4dx%4d, ",
- 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,
- &mX, &mY, &mVBI, &mMaxY )) j = i;
- }
- }
- mp_msg(MSGT_VO, MSGL_INFO,
- "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n",
- mX, mY, mVBI,
- HW_MODE.vdm_depth,
- HW_MODE.vdm_bitspp);
- mp_msg(MSGT_VO, MSGL_INFO,
- "vo_dga: Video parameters by codec: %3d x %3d, depth %2d, bitspp %2d.\n",
- width, height,
- SRC_MODE.vdm_depth,
- SRC_MODE.vdm_bitspp);
- vo_dga_vp_width = mX;
- vo_dga_vp_height = mY;
-
- 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);
+ mp_msg(MSGT_VO, MSGL_V, "vo_dga: vo_modelines=%p, vo_modecount=%d\n",
+ vo_modelines, vo_modecount);
+
+ if (vo_modelines == NULL)
+ {
+ mp_msg(MSGT_VO, MSGL_ERR, "vo_dga: can't get modelines\n");
+ return 1;
+ }
+
+ mp_msg(MSGT_VO, MSGL_INFO,
+ "vo_dga: DGA 2.0 available :-) Can switch resolution AND depth!\n");
+ for (i = 0; i < vo_modecount; i++)
+ {
+ if (vd_ModeEqual(vo_modelines[i].depth,
+ vo_modelines[i].bitsPerPixel,
+ vo_modelines[i].redMask,
+ vo_modelines[i].greenMask,
+ vo_modelines[i].blueMask, vo_dga_hw_mode))
+ {
+
+ mp_msg(MSGT_VO, MSGL_V, "maxy: %4d, depth: %2d, %4dx%4d, ",
+ 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_modelin