Path: blob/master/utils/xorg-deps/xf86-video-dummy/01_v0.3.8_xdummy-randr.patch
1007 views
diff --git a/src/dummy.h b/src/dummy.h1index c3fdd6e..9c74f56 1006442--- a/src/dummy.h3+++ b/src/dummy.h4@@ -13,6 +13,8 @@56#include "compat-api.h"78+#define DUMMY_MAX_SCREENS 49+10/* Supported chipsets */11typedef enum {12DUMMY_CHIP13@@ -72,6 +74,12 @@ typedef struct dummyRec14pointer* FBBase;15Bool (*CreateWindow)() ; /* wrapped CreateWindow */16Bool prop;17+ /* XRANDR support begin */18+ int num_screens;19+ struct _xf86Crtc *paCrtcs[DUMMY_MAX_SCREENS];20+ struct _xf86Output *paOutputs[DUMMY_MAX_SCREENS];21+ int connected_outputs;22+ /* XRANDR support end */23} DUMMYRec, *DUMMYPtr;2425/* The privates of the DUMMY driver */26diff --git a/src/dummy_driver.c b/src/dummy_driver.c27index 2656602..069e330 10064428--- a/src/dummy_driver.c29+++ b/src/dummy_driver.c30@@ -34,6 +34,8 @@31#include <X11/extensions/Xv.h>32#endif3334+#include "xf86Crtc.h"35+36/*37* Driver data structures.38*/39@@ -141,6 +143,219 @@ static XF86ModuleVersionInfo dummyVersRec =40{0,0,0,0}41};4243+44+/************************45+ * XRANDR support begin *46+ ************************/47+48+static Bool dummy_config_resize(ScrnInfoPtr pScrn, int cw, int ch);49+static Bool DUMMYAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);50+51+static const xf86CrtcConfigFuncsRec DUMMYCrtcConfigFuncs = {52+ .resize = dummy_config_resize53+};54+55+56+static void57+dummy_crtc_dpms(xf86CrtcPtr crtc, int mode)58+{59+}60+61+static Bool62+dummy_crtc_lock (xf86CrtcPtr crtc)63+{64+ return FALSE;65+}66+67+static Bool68+dummy_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode,69+ DisplayModePtr adjusted_mode)70+{71+ return TRUE;72+}73+74+static void75+dummy_crtc_stub (xf86CrtcPtr crtc)76+{77+}78+79+static void80+dummy_crtc_gamma_set (xf86CrtcPtr crtc, CARD16 *red,81+ CARD16 *green, CARD16 *blue, int size)82+{83+}84+85+static void *86+dummy_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)87+{88+ return NULL;89+}90+91+static void92+dummy_crtc_mode_set (xf86CrtcPtr crtc, DisplayModePtr mode,93+ DisplayModePtr adjusted_mode, int x, int y)94+{95+}96+97+static const xf86CrtcFuncsRec DUMMYCrtcFuncs = {98+ .dpms = dummy_crtc_dpms,99+ .save = NULL, /* These two are never called by the server. */100+ .restore = NULL,101+ .lock = dummy_crtc_lock,102+ .unlock = NULL, /* This will not be invoked if lock returns FALSE. */103+ .mode_fixup = dummy_crtc_mode_fixup,104+ .prepare = dummy_crtc_stub,105+ .mode_set = dummy_crtc_mode_set,106+ .commit = dummy_crtc_stub,107+ .gamma_set = dummy_crtc_gamma_set,108+ .shadow_allocate = dummy_crtc_shadow_allocate,109+ .shadow_create = NULL, /* These two should not be invoked if allocate110+ returns NULL. */111+ .shadow_destroy = NULL,112+ .set_cursor_colors = NULL,113+ .set_cursor_position = NULL,114+ .show_cursor = NULL,115+ .hide_cursor = NULL,116+ .load_cursor_argb = NULL,117+ .destroy = dummy_crtc_stub118+};119+120+static void121+dummy_output_stub (xf86OutputPtr output)122+{123+}124+125+static void126+dummy_output_dpms (xf86OutputPtr output, int mode)127+{128+}129+130+static int131+dummy_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode)132+{133+ return MODE_OK;134+}135+136+static Bool137+dummy_output_mode_fixup (xf86OutputPtr output, DisplayModePtr mode,138+ DisplayModePtr adjusted_mode)139+{140+ return TRUE;141+}142+143+static void144+dummy_output_mode_set (xf86OutputPtr output, DisplayModePtr mode,145+ DisplayModePtr adjusted_mode)146+{147+ DUMMYPtr dPtr = DUMMYPTR(output->scrn);148+ int index = (int64_t)output->driver_private;149+150+ /* set to connected at first mode set */151+ dPtr->connected_outputs |= 1 << index;152+}153+154+/* The first virtual monitor is always connected. Others only after setting its155+ * mode */156+static xf86OutputStatus157+dummy_output_detect (xf86OutputPtr output)158+{159+ DUMMYPtr dPtr = DUMMYPTR(output->scrn);160+ int index = (int64_t)output->driver_private;161+162+ if (dPtr->connected_outputs & (1 << index))163+ return XF86OutputStatusConnected;164+ else165+ return XF86OutputStatusDisconnected;166+}167+168+static DisplayModePtr169+dummy_output_get_modes (xf86OutputPtr output)170+{171+ DisplayModePtr pModes = NULL, pMode, pModeSrc;172+173+ /* copy modes from config */174+ for (pModeSrc = output->scrn->modes; pModeSrc; pModeSrc = pModeSrc->next)175+ {176+ pMode = xnfcalloc(1, sizeof(DisplayModeRec));177+ memcpy(pMode, pModeSrc, sizeof(DisplayModeRec));178+ pMode->next = NULL;179+ pMode->prev = NULL;180+ pMode->name = strdup(pModeSrc->name);181+ pModes = xf86ModesAdd(pModes, pMode);182+ if (pModeSrc->next == output->scrn->modes)183+ break;184+ }185+ return pModes;186+}187+188+189+static const xf86OutputFuncsRec DUMMYOutputFuncs = {190+ .create_resources = dummy_output_stub,191+ .dpms = dummy_output_dpms,192+ .save = NULL, /* These two are never called by the server. */193+ .restore = NULL,194+ .mode_valid = dummy_output_mode_valid,195+ .mode_fixup = dummy_output_mode_fixup,196+ .prepare = dummy_output_stub,197+ .commit = dummy_output_stub,198+ .mode_set = dummy_output_mode_set,199+ .detect = dummy_output_detect,200+ .get_modes = dummy_output_get_modes,201+#ifdef RANDR_12_INTERFACE202+ .set_property = NULL,203+#endif204+ .destroy = dummy_output_stub205+};206+207+static Bool208+dummy_config_resize(ScrnInfoPtr pScrn, int cw, int ch)209+{210+ if (!pScrn->vtSema) {211+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,212+ "We do not own the active VT, exiting.\n");213+ return TRUE;214+ }215+ return DUMMYAdjustScreenPixmap(pScrn, cw, ch);216+}217+218+Bool DUMMYAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height)219+{220+ ScreenPtr pScreen = pScrn->pScreen;221+ PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen);222+ DUMMYPtr dPtr = DUMMYPTR(pScrn);223+ uint64_t cbLine = (width * xf86GetBppFromDepth(pScrn, pScrn->depth) / 8 + 3) & ~3;224+ int displayWidth = cbLine * 8 / xf86GetBppFromDepth(pScrn, pScrn->depth);225+226+ if ( width == pScrn->virtualX227+ && height == pScrn->virtualY228+ && displayWidth == pScrn->displayWidth)229+ return TRUE;230+ if (!pPixmap) {231+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,232+ "Failed to get the screen pixmap.\n");233+ return FALSE;234+ }235+ if (cbLine > UINT32_MAX || cbLine * height >= pScrn->videoRam * 1024)236+ {237+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,238+ "Unable to set up a virtual screen size of %dx%d with %d Kb of video memory available. Please increase the video memory size.\n",239+ width, height, pScrn->videoRam);240+ return FALSE;241+ }242+ pScreen->ModifyPixmapHeader(pPixmap, width, height,243+ pScrn->depth, xf86GetBppFromDepth(pScrn, pScrn->depth), cbLine,244+ pPixmap->devPrivate.ptr);245+ pScrn->virtualX = width;246+ pScrn->virtualY = height;247+ pScrn->displayWidth = displayWidth;248+249+ return TRUE;250+}251+252+/**********************253+ * XRANDR support end *254+ **********************/255+256/*257* This is the module init data.258* Its name has to be the driver name followed by ModuleData259@@ -568,6 +783,56 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)260261xf86SetBlackWhitePixels(pScreen);262263+ /* initialize XRANDR */264+ xf86CrtcConfigInit(pScrn, &DUMMYCrtcConfigFuncs);265+ /* FIXME */266+ dPtr->num_screens = DUMMY_MAX_SCREENS;267+268+ for (int i=0; i < dPtr->num_screens; i++) {269+ char szOutput[256];270+271+ dPtr->paCrtcs[i] = xf86CrtcCreate(pScrn, &DUMMYCrtcFuncs);272+ dPtr->paCrtcs[i]->driver_private = (void *)(uintptr_t)i;273+274+ /* Set up our virtual outputs. */275+ snprintf(szOutput, sizeof(szOutput), "DUMMY%u", i);276+ dPtr->paOutputs[i] = xf86OutputCreate(pScrn, &DUMMYOutputFuncs,277+ szOutput);278+279+280+ xf86OutputUseScreenMonitor(dPtr->paOutputs[i], FALSE);281+ dPtr->paOutputs[i]->possible_crtcs = 1 << i;282+ dPtr->paOutputs[i]->possible_clones = 0;283+ dPtr->paOutputs[i]->driver_private = (void *)(uintptr_t)i;284+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Created crtc (%p) and output %s (%p)\n",285+ (void *)dPtr->paCrtcs[i], szOutput,286+ (void *)dPtr->paOutputs[i]);287+288+ }289+290+ /* bitmask */291+ dPtr->connected_outputs = 1;292+293+ xf86CrtcSetSizeRange(pScrn, 64, 64, DUMMY_MAX_WIDTH, DUMMY_MAX_HEIGHT);294+295+296+ /* Now create our initial CRTC/output configuration. */297+ if (!xf86InitialConfiguration(pScrn, TRUE)) {298+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial CRTC configuration failed!\n");299+ return (FALSE);300+ }301+302+ /* Initialise randr 1.2 mode-setting functions and set first mode.303+ * Note that the mode won't be usable until the server has resized the304+ * framebuffer to something reasonable. */305+ if (!xf86CrtcScreenInit(pScreen)) {306+ return FALSE;307+ }308+ if (!xf86SetDesiredModes(pScrn)) {309+ return FALSE;310+ }311+ /* XRANDR initialization end */312+313#ifdef USE_DGA314DUMMYDGAInit(pScreen);315#endif316317318