Guts of a simple XVidMode-supporting DirectDraw HAL in x11drv.
This commit is contained in:
parent
0cfa278b02
commit
6e7ded456b
|
@ -7,7 +7,9 @@ EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB)
|
||||||
IMPORTS = user32 gdi32 kernel32
|
IMPORTS = user32 gdi32 kernel32
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
x11drv_main.c
|
x11ddraw.c \
|
||||||
|
x11drv_main.c \
|
||||||
|
xvidmode.c
|
||||||
|
|
||||||
PROGRAMS = \
|
PROGRAMS = \
|
||||||
$(TOPOBJDIR)/windows/x11drv/wineclipsrv
|
$(TOPOBJDIR)/windows/x11drv/wineclipsrv
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* DirectDraw driver interface
|
||||||
|
*
|
||||||
|
* Copyright 2001 TransGaming Technologies, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "windef.h"
|
||||||
|
#include "wingdi.h"
|
||||||
|
#include "ddrawi.h"
|
||||||
|
#include "xvidmode.h"
|
||||||
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||||
|
|
||||||
|
static DWORD PASCAL X11DRV_DDHAL_DestroyDriver(LPDDHAL_DESTROYDRIVERDATA data)
|
||||||
|
{
|
||||||
|
data->ddRVal = DD_OK;
|
||||||
|
return DDHAL_DRIVER_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD PASCAL X11DRV_DDHAL_SetMode(LPDDHAL_SETMODEDATA data)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LIBXXF86VM
|
||||||
|
if (xf86vm_mode_count) {
|
||||||
|
X11DRV_XF86VM_SetCurrentMode(data->dwModeIndex);
|
||||||
|
data->ddRVal = DD_OK;
|
||||||
|
return DDHAL_DRIVER_HANDLED;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return DDHAL_DRIVER_NOTHANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DDHAL_DDCALLBACKS hal_ddcallbacks = {
|
||||||
|
sizeof(DDHAL_DDCALLBACKS),
|
||||||
|
0x3ff, /* all callbacks are 32-bit */
|
||||||
|
X11DRV_DDHAL_DestroyDriver,
|
||||||
|
NULL, /* CreateSurface */
|
||||||
|
NULL, /* SetColorKey */
|
||||||
|
X11DRV_DDHAL_SetMode,
|
||||||
|
NULL, /* WaitForVerticalBlank */
|
||||||
|
NULL, /* CanCreateSurface */
|
||||||
|
NULL, /* CreatePalette */
|
||||||
|
NULL, /* GetScanLine */
|
||||||
|
NULL, /* SetExclusiveMode */
|
||||||
|
NULL /* FlipToGDISurface */
|
||||||
|
};
|
||||||
|
|
||||||
|
static DDHALINFO hal_info = {
|
||||||
|
sizeof(DDHALINFO),
|
||||||
|
&hal_ddcallbacks,
|
||||||
|
/* more stuff */
|
||||||
|
};
|
||||||
|
|
||||||
|
static LPDDHALDDRAWFNS ddraw_fns;
|
||||||
|
static DWORD ddraw_ver;
|
||||||
|
|
||||||
|
INT X11DRV_DCICommand(INT cbInput, LPVOID lpInData, LPVOID lpOutData)
|
||||||
|
{
|
||||||
|
LPDCICMD lpCmd = (LPDCICMD)lpInData;
|
||||||
|
|
||||||
|
TRACE("(%d,(%ld,%ld,%ld),%p)\n", cbInput, lpCmd->dwCommand,
|
||||||
|
lpCmd->dwParam1, lpCmd->dwParam2, lpOutData);
|
||||||
|
|
||||||
|
switch (lpCmd->dwCommand) {
|
||||||
|
case DDNEWCALLBACKFNS:
|
||||||
|
ddraw_fns = (LPDDHALDDRAWFNS)lpCmd->dwParam1;
|
||||||
|
return TRUE;
|
||||||
|
case DDVERSIONINFO:
|
||||||
|
{
|
||||||
|
LPDDVERSIONDATA lpVer = (LPDDVERSIONDATA)lpOutData;
|
||||||
|
ddraw_ver = lpCmd->dwParam1;
|
||||||
|
if (!lpVer) break;
|
||||||
|
/* well, whatever... the DDK says so */
|
||||||
|
lpVer->dwHALVersion = DD_RUNTIME_VERSION;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
case DDGET32BITDRIVERNAME:
|
||||||
|
{
|
||||||
|
LPDD32BITDRIVERDATA lpData = (LPDD32BITDRIVERDATA)lpOutData;
|
||||||
|
/* here, we could ask ddraw to load a separate DLL, that
|
||||||
|
* would contain the 32-bit ddraw HAL */
|
||||||
|
strcpy(lpData->szName,"x11drv");
|
||||||
|
/* the entry point named here should initialize our hal_info
|
||||||
|
* with 32-bit entry points */
|
||||||
|
strcpy(lpData->szEntryPoint,"DriverInit");
|
||||||
|
lpData->dwContext = 0;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
case DDCREATEDRIVEROBJECT:
|
||||||
|
{
|
||||||
|
LPDWORD lpInstance = (LPDWORD)lpOutData;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXXF86VM
|
||||||
|
hal_info.dwNumModes = xf86vm_mode_count;
|
||||||
|
hal_info.lpModeInfo = xf86vm_modes;
|
||||||
|
hal_info.dwModeIndex = X11DRV_XF86VM_GetCurrentMode();
|
||||||
|
#endif
|
||||||
|
/* FIXME: get x11drv's hInstance */
|
||||||
|
|
||||||
|
(ddraw_fns->lpSetInfo)(&hal_info, FALSE);
|
||||||
|
*lpInstance = hal_info.hInstance;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -38,6 +38,7 @@ static int *ph_errno = &h_errno;
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
#include "wine_gl.h"
|
#include "wine_gl.h"
|
||||||
#include "x11drv.h"
|
#include "x11drv.h"
|
||||||
|
#include "xvidmode.h"
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(x11drv);
|
DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||||
|
|
||||||
|
@ -382,6 +383,11 @@ static void process_attach(void)
|
||||||
/* initialize event handling */
|
/* initialize event handling */
|
||||||
X11DRV_EVENT_Init();
|
X11DRV_EVENT_Init();
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXXF86VM
|
||||||
|
/* initialize XVidMode */
|
||||||
|
X11DRV_XF86VM_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* load display.dll */
|
/* load display.dll */
|
||||||
LoadLibrary16( "display" );
|
LoadLibrary16( "display" );
|
||||||
}
|
}
|
||||||
|
@ -404,6 +410,11 @@ static void process_detach(void)
|
||||||
XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
|
XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
|
||||||
KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
|
KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXXF86VM
|
||||||
|
/* cleanup XVidMode */
|
||||||
|
X11DRV_XF86VM_Cleanup();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* cleanup GDI */
|
/* cleanup GDI */
|
||||||
X11DRV_GDI_Finalize();
|
X11DRV_GDI_Finalize();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
* DirectDraw XVidMode interface
|
||||||
|
*
|
||||||
|
* Copyright 2001 TransGaming Technologies, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
/* FIXME: XVidMode also includes gamma functions,
|
||||||
|
* we could perhaps use it to implement Get/SetGammaRamp */
|
||||||
|
|
||||||
|
/* FIXME: ChangeDisplaySettings ought to be able to use this */
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXXF86VM
|
||||||
|
|
||||||
|
#include "ts_xlib.h"
|
||||||
|
#include "ts_xf86vmode.h"
|
||||||
|
#include "x11drv.h"
|
||||||
|
|
||||||
|
#include "windef.h"
|
||||||
|
#include "wingdi.h"
|
||||||
|
#include "ddrawi.h"
|
||||||
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||||
|
|
||||||
|
LPDDHALMODEINFO xf86vm_modes;
|
||||||
|
unsigned xf86vm_mode_count;
|
||||||
|
XF86VidModeModeInfo** modes;
|
||||||
|
|
||||||
|
#define CONVERT_MODE(dotclock) \
|
||||||
|
info->dwWidth = mode->hdisplay; \
|
||||||
|
info->dwHeight = mode->vdisplay; \
|
||||||
|
info->wRefreshRate = dotclock * 1000 / (mode->htotal * mode->vtotal); \
|
||||||
|
TRACE(" width=%ld, height=%ld, refresh=%d\n", \
|
||||||
|
info->dwWidth, info->dwHeight, info->wRefreshRate); \
|
||||||
|
/* XVidMode cannot change display depths... */ \
|
||||||
|
/* let's not bother with filling out these then... */ \
|
||||||
|
info->lPitch = 0; \
|
||||||
|
info->dwBPP = 0; \
|
||||||
|
info->wFlags = 0; \
|
||||||
|
info->dwRBitMask = 0; \
|
||||||
|
info->dwGBitMask = 0; \
|
||||||
|
info->dwBBitMask = 0; \
|
||||||
|
info->dwAlphaBitMask = 0;
|
||||||
|
|
||||||
|
static void convert_modeinfo(XF86VidModeModeInfo *mode, LPDDHALMODEINFO info)
|
||||||
|
{
|
||||||
|
CONVERT_MODE(mode->dotclock)
|
||||||
|
}
|
||||||
|
|
||||||
|
static void convert_modeline(int dotclock, XF86VidModeModeLine *mode, LPDDHALMODEINFO info)
|
||||||
|
{
|
||||||
|
CONVERT_MODE(dotclock)
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11DRV_XF86VM_Init(void)
|
||||||
|
{
|
||||||
|
int nmodes, major, minor, i;
|
||||||
|
|
||||||
|
if (xf86vm_modes) return; /* already initialized? */
|
||||||
|
|
||||||
|
/* if in desktop mode, don't use XVidMode */
|
||||||
|
if (X11DRV_GetXRootWindow() != DefaultRootWindow(display)) return;
|
||||||
|
|
||||||
|
/* see if XVidMode is available */
|
||||||
|
if (!TSXF86VidModeQueryVersion(display, &major, &minor)) return;
|
||||||
|
|
||||||
|
/* retrieve modes */
|
||||||
|
if (!TSXF86VidModeGetAllModeLines(display, DefaultScreen(display), &nmodes,
|
||||||
|
&modes))
|
||||||
|
return;
|
||||||
|
|
||||||
|
TRACE("XVidMode modes: count=%d\n", nmodes);
|
||||||
|
|
||||||
|
xf86vm_mode_count = nmodes;
|
||||||
|
xf86vm_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * nmodes);
|
||||||
|
|
||||||
|
/* convert modes to DDHALMODEINFO format */
|
||||||
|
for (i=0; i<nmodes; i++)
|
||||||
|
convert_modeinfo(modes[i], &xf86vm_modes[i]);
|
||||||
|
|
||||||
|
TRACE("Enabling XVidMode\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11DRV_XF86VM_Cleanup(void)
|
||||||
|
{
|
||||||
|
TSXFree(modes);
|
||||||
|
}
|
||||||
|
|
||||||
|
int X11DRV_XF86VM_GetCurrentMode(void)
|
||||||
|
{
|
||||||
|
XF86VidModeModeLine line;
|
||||||
|
int dotclock, i;
|
||||||
|
DDHALMODEINFO cmode;
|
||||||
|
|
||||||
|
TRACE("Querying XVidMode current mode\n");
|
||||||
|
TSXF86VidModeGetModeLine(display, DefaultScreen(display), &dotclock, &line);
|
||||||
|
convert_modeline(dotclock, &line, &cmode);
|
||||||
|
for (i=0; i<xf86vm_mode_count; i++)
|
||||||
|
if (memcmp(&xf86vm_modes[i], &cmode, sizeof(cmode)) == 0) {
|
||||||
|
TRACE("mode=%d\n", i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
ERR("unknown mode, shouldn't happen\n");
|
||||||
|
return 0; /* return first mode */
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11DRV_XF86VM_SetCurrentMode(int mode)
|
||||||
|
{
|
||||||
|
TSXF86VidModeSwitchToMode(display, DefaultScreen(display), modes[mode]);
|
||||||
|
TSXF86VidModeSetViewPort(display, DefaultScreen(display), 0, 0);
|
||||||
|
TSXSync(display, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11DRV_XF86VM_SetExclusiveMode(int lock)
|
||||||
|
{
|
||||||
|
TSXF86VidModeLockModeSwitch(display, DefaultScreen(display), lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBXXF86VM */
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* DirectDraw HAL XVidMode interface
|
||||||
|
*
|
||||||
|
* Copyright 2001 TransGaming Technologies, Inc.
|
||||||
|
*/
|
||||||
|
#ifndef __WINE_XVIDMODE_H
|
||||||
|
#define __WINE_XVIDMODE_H
|
||||||
|
#include "config.h"
|
||||||
|
#ifdef HAVE_LIBXXF86VM
|
||||||
|
#include "ddrawi.h"
|
||||||
|
|
||||||
|
extern LPDDHALMODEINFO xf86vm_modes;
|
||||||
|
extern unsigned xf86vm_mode_count;
|
||||||
|
|
||||||
|
void X11DRV_XF86VM_Init(void);
|
||||||
|
void X11DRV_XF86VM_Cleanup(void);
|
||||||
|
int X11DRV_XF86VM_GetCurrentMode(void);
|
||||||
|
void X11DRV_XF86VM_SetCurrentMode(int mode);
|
||||||
|
void X11DRV_XF86VM_SetExclusiveMode(int lock);
|
||||||
|
|
||||||
|
#endif /* HAVE_LIBXXF86VM */
|
||||||
|
#endif /* __WINE_XVIDMODE_H */
|
Loading…
Reference in New Issue