void X11DRV_XF86VM_Init(void) { Bool ok; int nmodes; unsigned int i; if (xf86vm_major) return; /* already initialized? */ /* see if XVidMode is available */ wine_tsx11_lock(); ok = XF86VidModeQueryExtension(gdi_display, &xf86vm_event, &xf86vm_error); if (ok) { X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); ok = XF86VidModeQueryVersion(gdi_display, &xf86vm_major, &xf86vm_minor); if (X11DRV_check_error()) ok = FALSE; } if (ok) { #ifdef X_XF86VidModeSetGammaRamp if (xf86vm_major > 2 || (xf86vm_major == 2 && xf86vm_minor >= 1)) { XF86VidModeGetGammaRampSize(gdi_display, DefaultScreen(gdi_display), &xf86vm_gammaramp_size); if (xf86vm_gammaramp_size == 256) xf86vm_use_gammaramp = TRUE; } #endif /* X_XF86VidModeSetGammaRamp */ /* retrieve modes */ if (usexvidmode && root_window == DefaultRootWindow( gdi_display )) ok = XF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes); else ok = FALSE; /* In desktop mode, do not switch resolution... But still use the Gamma ramp stuff */ } wine_tsx11_unlock(); if (!ok) return; TRACE("XVidMode modes: count=%d\n", nmodes); real_xf86vm_mode_count = nmodes; dd_modes = X11DRV_Settings_SetHandlers("XF86VidMode", X11DRV_XF86VM_GetCurrentMode, X11DRV_XF86VM_SetCurrentMode, nmodes, 1); /* convert modes to DDHALMODEINFO format */ for (i=0; i<real_xf86vm_mode_count; i++) { convert_modeinfo(real_xf86vm_modes[i]); } /* add modes for different color depths */ X11DRV_Settings_AddDepthModes(); dd_mode_count = X11DRV_Settings_GetModeCount(); TRACE("Available DD modes: count=%d\n", dd_mode_count); TRACE("Enabling XVidMode\n"); }
/* default handler only gets the current X desktop resolution */ void X11DRV_Settings_Init(void) { X11DRV_Settings_SetHandlers("NoRes", X11DRV_nores_GetCurrentMode, X11DRV_nores_SetCurrentMode, 1, 0); X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 60); }
/*********************************************************************** * X11DRV_init_desktop * * Setup the desktop when not using the root window. */ void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) { root_window = win; managed_mode = 0; /* no managed windows in desktop mode */ max_width = screen_width; max_height = screen_height; xinerama_init( width, height ); /* initialize the available resolutions */ dd_modes = X11DRV_Settings_SetHandlers("desktop", X11DRV_desktop_GetCurrentMode, X11DRV_desktop_SetCurrentMode, NUM_DESKTOP_MODES+2, 1); make_modes(); X11DRV_Settings_AddDepthModes(); dd_mode_count = X11DRV_Settings_GetModeCount(); }
/*********************************************************************** * X11DRV_init_desktop * * Setup the desktop when not using the root window. */ void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) { RECT primary_rect = get_primary_monitor_rect(); root_window = win; managed_mode = FALSE; /* no managed windows in desktop mode */ max_width = primary_rect.right - primary_rect.left; max_height = primary_rect.bottom - primary_rect.top; xinerama_init( width, height ); /* initialize the available resolutions */ dd_modes = X11DRV_Settings_SetHandlers("desktop", X11DRV_desktop_GetCurrentMode, X11DRV_desktop_SetCurrentMode, NUM_DESKTOP_MODES+2, 1); make_modes(); X11DRV_Settings_AddDepthModes(); dd_mode_count = X11DRV_Settings_GetModeCount(); }
void X11DRV_XF86VM_Init(void) { void *xvidmode_handle; Bool ok; int nmodes; unsigned int i; if (xf86vm_major) return; /* already initialized? */ xvidmode_handle = wine_dlopen(SONAME_LIBXXF86VM, RTLD_NOW, NULL, 0); if (!xvidmode_handle) { TRACE("Unable to open %s, XVidMode disabled\n", SONAME_LIBXXF86VM); usexvidmode = 0; return; } #define LOAD_FUNCPTR(f) \ if((p##f = wine_dlsym(xvidmode_handle, #f, NULL, 0)) == NULL) \ goto sym_not_found; LOAD_FUNCPTR(XF86VidModeGetAllModeLines) LOAD_FUNCPTR(XF86VidModeGetModeLine) LOAD_FUNCPTR(XF86VidModeLockModeSwitch) LOAD_FUNCPTR(XF86VidModeQueryExtension) LOAD_FUNCPTR(XF86VidModeQueryVersion) LOAD_FUNCPTR(XF86VidModeSetViewPort) LOAD_FUNCPTR(XF86VidModeSwitchToMode) #ifdef X_XF86VidModeSetGamma LOAD_FUNCPTR(XF86VidModeGetGamma) LOAD_FUNCPTR(XF86VidModeSetGamma) #endif #ifdef X_XF86VidModeSetGammaRamp LOAD_FUNCPTR(XF86VidModeGetGammaRamp) LOAD_FUNCPTR(XF86VidModeGetGammaRampSize) LOAD_FUNCPTR(XF86VidModeSetGammaRamp) #endif #undef LOAD_FUNCPTR /* see if XVidMode is available */ wine_tsx11_lock(); ok = pXF86VidModeQueryExtension(gdi_display, &xf86vm_event, &xf86vm_error); wine_tsx11_unlock(); if (!ok) return; X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); ok = pXF86VidModeQueryVersion(gdi_display, &xf86vm_major, &xf86vm_minor); if (X11DRV_check_error() || !ok) return; #ifdef X_XF86VidModeSetGammaRamp if (xf86vm_major > 2 || (xf86vm_major == 2 && xf86vm_minor >= 1)) { X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); pXF86VidModeGetGammaRampSize(gdi_display, DefaultScreen(gdi_display), &xf86vm_gammaramp_size); if (X11DRV_check_error()) xf86vm_gammaramp_size = 0; if (xf86vm_gammaramp_size == 256) xf86vm_use_gammaramp = TRUE; } #endif /* X_XF86VidModeSetGammaRamp */ /* retrieve modes */ if (usexvidmode && root_window == DefaultRootWindow( gdi_display )) { X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL); ok = pXF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes); if (X11DRV_check_error() || !ok) return; } else return; /* In desktop mode, do not switch resolution... But still use the Gamma ramp stuff */ TRACE("XVidMode modes: count=%d\n", nmodes); real_xf86vm_mode_count = nmodes; dd_modes = X11DRV_Settings_SetHandlers("XF86VidMode", X11DRV_XF86VM_GetCurrentMode, X11DRV_XF86VM_SetCurrentMode, nmodes, 1); /* convert modes to x11drv_mode_info format */ for (i=0; i<real_xf86vm_mode_count; i++) { convert_modeinfo(real_xf86vm_modes[i]); } /* add modes for different color depths */ X11DRV_Settings_AddDepthModes(); dd_mode_count = X11DRV_Settings_GetModeCount(); TRACE("Available DD modes: count=%d\n", dd_mode_count); TRACE("Enabling XVidMode\n"); return; sym_not_found: TRACE("Unable to load function pointers from %s, XVidMode disabled\n", SONAME_LIBXXF86VM); wine_dlclose(xvidmode_handle, NULL, 0); xvidmode_handle = NULL; usexvidmode = 0; }
void X11DRV_XRandR_Init(void) { Bool ok; int i, nmodes = 0; if (xrandr_major) return; /* already initialized? */ if (!usexrandr) return; /* disabled in config */ if (root_window != DefaultRootWindow( gdi_display )) return; if (!load_xrandr()) return; /* can't load the Xrandr library */ /* see if Xrandr is available */ wine_tsx11_lock(); ok = pXRRQueryExtension(gdi_display, &xrandr_event, &xrandr_error); if (ok) { X11DRV_expect_error(gdi_display, XRandRErrorHandler, NULL); ok = pXRRQueryVersion(gdi_display, &xrandr_major, &xrandr_minor); if (X11DRV_check_error()) ok = FALSE; } if (ok) { TRACE("Found XRandR - major: %d, minor: %d\n", xrandr_major, xrandr_minor); /* retrieve modes */ real_xrandr_sizes = pXRRSizes(gdi_display, DefaultScreen(gdi_display), &real_xrandr_sizes_count); ok = (real_xrandr_sizes_count>0); } if (ok) { TRACE("XRandR: found %u resolutions sizes\n", real_xrandr_sizes_count); real_xrandr_rates = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(short *) * real_xrandr_sizes_count); real_xrandr_rates_count = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(int) * real_xrandr_sizes_count); for (i=0; i < real_xrandr_sizes_count; i++) { real_xrandr_rates[i] = pXRRRates (gdi_display, DefaultScreen(gdi_display), i, &(real_xrandr_rates_count[i])); TRACE("- at %d: %dx%d (%d rates):", i, real_xrandr_sizes[i].width, real_xrandr_sizes[i].height, real_xrandr_rates_count[i]); if (real_xrandr_rates_count[i]) { int j; nmodes += real_xrandr_rates_count[i]; for (j = 0; j < real_xrandr_rates_count[i]; ++j) { if (j > 0) TRACE(","); TRACE(" %d", real_xrandr_rates[i][j]); } } else { nmodes++; TRACE(" <default>"); } TRACE(" Hz\n"); } } wine_tsx11_unlock(); if (!ok) return; real_xrandr_modes_count = nmodes; TRACE("XRandR modes: count=%d\n", nmodes); dd_modes = X11DRV_Settings_SetHandlers("XRandR", X11DRV_XRandR_GetCurrentMode, X11DRV_XRandR_SetCurrentMode, nmodes, 1); make_modes(); X11DRV_Settings_AddDepthModes(); dd_mode_count = X11DRV_Settings_GetModeCount(); TRACE("Available DD modes: count=%d\n", dd_mode_count); TRACE("Enabling XRandR\n"); }
static int xrandr12_init_modes(void) { unsigned int only_one_resolution = 1, mode_count; XRRScreenResources *resources; XRROutputInfo *output_info; XRRCrtcInfo *crtc_info; int ret = -1; int i, j; if (!(resources = pXRRGetScreenResourcesCurrent( gdi_display, root_window ))) { ERR("Failed to get screen resources.\n"); return ret; } if (!resources->ncrtc) { pXRRFreeScreenResources( resources ); if (!(resources = pXRRGetScreenResources( gdi_display, root_window ))) { ERR("Failed to get screen resources.\n"); return ret; } } if (!(crtc_info = xrandr12_get_primary_crtc_info( resources, &primary_crtc ))) { pXRRFreeScreenResources( resources ); ERR("Failed to get primary CRTC info.\n"); return ret; } TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode, crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y); if (!crtc_info->noutput || !(output_info = pXRRGetOutputInfo( gdi_display, resources, crtc_info->outputs[0] ))) { pXRRFreeCrtcInfo( crtc_info ); pXRRFreeScreenResources( resources ); ERR("Failed to get output info.\n"); return ret; } TRACE("OUTPUT 0: name %s.\n", debugstr_a(output_info->name)); if (!output_info->nmode) { ERR("Output has no modes.\n"); goto done; } if (!(xrandr12_modes = HeapAlloc( GetProcessHeap(), 0, sizeof(*xrandr12_modes) * output_info->nmode ))) { ERR("Failed to allocate xrandr mode info array.\n"); goto done; } dd_modes = X11DRV_Settings_SetHandlers( "XRandR 1.2", xrandr12_get_current_mode, xrandr12_set_current_mode, output_info->nmode, 1 ); xrandr_mode_count = 0; for (i = 0; i < output_info->nmode; ++i) { for (j = 0; j < resources->nmode; ++j) { XRRModeInfo *mode = &resources->modes[j]; if (mode->id == output_info->modes[i]) { unsigned int dots = mode->hTotal * mode->vTotal; unsigned int refresh = dots ? (mode->dotClock + dots / 2) / dots : 0; TRACE("Adding mode %#lx: %ux%u@%u.\n", mode->id, mode->width, mode->height, refresh); X11DRV_Settings_AddOneMode( mode->width, mode->height, 0, refresh ); xrandr12_modes[xrandr_mode_count++] = mode->id; break; } } } mode_count = X11DRV_Settings_GetModeCount(); for (i = 1; i < mode_count; ++i) { if (dd_modes[i].width != dd_modes[0].width || dd_modes[i].height != dd_modes[0].height) { only_one_resolution = 0; break; } } /* Recent (304.64, possibly earlier) versions of the nvidia driver only * report a DFP's native mode through RandR 1.2 / 1.3. Standard DMT modes * are only listed through RandR 1.0 / 1.1. This is completely useless, * but NVIDIA considers this a feature, so it's unlikely to change. The * best we can do is to fall back to RandR 1.0 and encourage users to * consider more cooperative driver vendors when we detect such a * configuration. */ if (only_one_resolution && XQueryExtension( gdi_display, "NV-CONTROL", &i, &j, &ret )) { ERR_(winediag)("Broken NVIDIA RandR detected, falling back to RandR 1.0. " "Please consider using the Nouveau driver instead.\n"); ret = -1; HeapFree( GetProcessHeap(), 0, xrandr12_modes ); goto done; } X11DRV_Settings_AddDepthModes(); ret = 0; done: pXRRFreeOutputInfo( output_info ); pXRRFreeCrtcInfo( crtc_info ); pXRRFreeScreenResources( resources ); return ret; }
static void xrandr10_init_modes(void) { XRRScreenSize *sizes; int sizes_count; int i, j, nmodes = 0; sizes = pXRRSizes( gdi_display, DefaultScreen(gdi_display), &sizes_count ); if (sizes_count <= 0) return; TRACE("XRandR: found %d sizes.\n", sizes_count); for (i = 0; i < sizes_count; ++i) { int rates_count; short *rates; rates = pXRRRates( gdi_display, DefaultScreen(gdi_display), i, &rates_count ); TRACE("- at %d: %dx%d (%d rates):", i, sizes[i].width, sizes[i].height, rates_count); if (rates_count) { nmodes += rates_count; for (j = 0; j < rates_count; ++j) { if (j > 0) TRACE(","); TRACE(" %d", rates[j]); } } else { ++nmodes; TRACE(" <default>"); } TRACE(" Hz\n"); } TRACE("XRandR modes: count=%d\n", nmodes); if (!(xrandr10_modes = HeapAlloc( GetProcessHeap(), 0, sizeof(*xrandr10_modes) * nmodes ))) { ERR("Failed to allocate xrandr mode info array.\n"); return; } dd_modes = X11DRV_Settings_SetHandlers( "XRandR 1.0", xrandr10_get_current_mode, xrandr10_set_current_mode, nmodes, 1 ); xrandr_mode_count = 0; for (i = 0; i < sizes_count; ++i) { int rates_count; short *rates; rates = pXRRRates( gdi_display, DefaultScreen(gdi_display), i, &rates_count ); if (rates_count) { for (j = 0; j < rates_count; ++j) { X11DRV_Settings_AddOneMode( sizes[i].width, sizes[i].height, 0, rates[j] ); xrandr10_modes[xrandr_mode_count++] = i; } } else { X11DRV_Settings_AddOneMode( sizes[i].width, sizes[i].height, 0, 0 ); xrandr10_modes[xrandr_mode_count++] = i; } } X11DRV_Settings_AddDepthModes(); nmodes = X11DRV_Settings_GetModeCount(); TRACE("Available DD modes: count=%d\n", nmodes); TRACE("Enabling XRandR\n"); }