xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #56: 1006-randr12.patch

File 1006-randr12.patch, 7.8 KB (added by Antoine Martin, 6 years ago)

dummy randr 1.2: patch 6 Support RandR 1.2

  • src/dummy_driver.c

    Don't bother creating RandR outputs or creating or validating modes.
    Instead, just invent a dummy DisplayModeRec for the current screen
    size.
    
    Plug in a RandR framebuffer resize hook to allow resizing the screen.
    Update the screen pixmap, ScrnInfo structure, and dummy mode when that
    happens.
    
    Dispense with the pScrn->videoRam field.  Instead, use the Virtual
    size from the Display subsection of the Screen section.  If that's not
    set, default to something reasonable by today's standards.
    
    Based on an idea by Nicolas Boichat <drinkcat at chromium.org>
    (http://lists.x.org/archives/xorg-devel/2014-November/044580.html)
    
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    ---
     src/dummy_driver.c | 166 ++++++++++++++++++++++-------------------------------
     1 file changed, 70 insertions(+), 96 deletions(-)
    
    diff --git a/src/dummy_driver.c b/src/dummy_driver.c
    index 8262f39f2563..48956ef72b50 100644
    a b  
    2222#include "property.h"
    2323
    2424#include "xf86cmap.h"
    25 
    26 #include "xf86fbman.h"
     25#include "xf86Crtc.h"
    2726
    2827#include "fb.h"
    2928
    static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, 
    7170#define DUMMY_MINOR_VERSION PACKAGE_VERSION_MINOR
    7271#define DUMMY_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL
    7372
    74 #define DUMMY_MAX_WIDTH 32767
    75 #define DUMMY_MAX_HEIGHT 32767
    76 
    7773/*
    7874 * This is intentionally screen-independent.  It indicates the binding
    7975 * choice made in the first PreInit.
    dummySetup(pointer module, pointer opts, int *errmaj, int *errmin) 
    165161
    166162#endif /* XFree86LOADER */
    167163
     164/*
     165 * Build a DisplayModeRec that matches the screen's dimensions.
     166 *
     167 * Make up a fake pixel clock so that applications that use the VidMode
     168 * extension to query the "refresh rate" get 60 Hz.
     169 */
     170static void ConstructFakeDisplayMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
     171{
     172    mode->HDisplay = mode->HSyncStart = mode->HSyncEnd = mode->HTotal =
     173        pScrn->virtualX;
     174    mode->VDisplay = mode->VSyncStart = mode->VSyncEnd = mode->VTotal =
     175        pScrn->virtualY;
     176    mode->Clock = mode->HTotal * mode->VTotal * 60 / 1000;
     177
     178    xf86SetCrtcForModes(pScrn, 0);
     179}
     180
     181static Bool
     182dummy_xf86crtc_resize(ScrnInfoPtr pScrn, int width, int height)
     183{
     184    ScreenPtr pScreen = pScrn->pScreen;
     185    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
     186    int newPitch = width * (pScrn->bitsPerPixel / 8);
     187    void *oldScreen = rootPixmap->devPrivate.ptr;
     188    void *newScreen = calloc(newPitch, height);
     189
     190    if (!newScreen)
     191        return FALSE;
     192
     193    if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height,
     194                                     -1, -1, newPitch, newScreen)) {
     195        free(newScreen);
     196        return FALSE;
     197    }
     198
     199    free(oldScreen);
     200
     201    pScrn->virtualX = width;
     202    pScrn->virtualY = height;
     203    pScrn->displayWidth = width;
     204    ConstructFakeDisplayMode(pScrn, pScrn->modes);
     205
     206    return TRUE;
     207}
     208
     209static const xf86CrtcConfigFuncsRec dummy_xf86crtc_config_funcs = {
     210    dummy_xf86crtc_resize
     211};
     212
    168213static Bool
    169214DUMMYGetRec(ScrnInfoPtr pScrn)
    170215{
    DUMMYProbe(DriverPtr drv, int flags) 
    266311Bool
    267312DUMMYPreInit(ScrnInfoPtr pScrn, int flags)
    268313{
    269     ClockRangePtr clockRanges;
    270     int i;
    271314    DUMMYPtr dPtr;
    272     int maxClock = 230000;
    273315    GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device;
    274316
    275317    if (flags & PROBE_DETECT)
    DUMMYPreInit(ScrnInfoPtr pScrn, int flags) 
    351393
    352394    xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor);
    353395
    354     if (device->videoRam != 0) {
    355         pScrn->videoRam = device->videoRam;
    356         xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n",
    357                    pScrn->videoRam);
    358     } else {
    359         pScrn->videoRam = 4096;
    360         xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n",
    361                    pScrn->videoRam);
    362     }
    363    
    364     if (device->dacSpeeds[0] != 0) {
    365         maxClock = device->dacSpeeds[0];
    366         xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n",
    367                    maxClock);
    368     } else {
    369         xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n",
    370                    maxClock);
    371     }
    372 
    373     pScrn->progClock = TRUE;
    374     /*
    375      * Setup the ClockRanges, which describe what clock ranges are available,
    376      * and what sort of modes they can be used for.
    377      */
    378     clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
    379     clockRanges->next = NULL;
    380     clockRanges->ClockMulFactor = 1;
    381     clockRanges->minClock = 11000;   /* guessed §§§ */
    382     clockRanges->maxClock = 300000;
    383     clockRanges->clockIndex = -1;               /* programmable */
    384     clockRanges->interlaceAllowed = TRUE;
    385     clockRanges->doubleScanAllowed = TRUE;
    386 
    387     /* Subtract memory for HW cursor */
    388 
    389 
    390     {
    391         int apertureSize = (pScrn->videoRam * 1024);
    392         i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
    393                               pScrn->display->modes, clockRanges,
    394                               NULL, 256, DUMMY_MAX_WIDTH,
    395                               (8 * pScrn->bitsPerPixel),
    396                               128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX,
    397                               pScrn->display->virtualY, apertureSize,
    398                               LOOKUP_BEST_REFRESH);
    399 
    400        if (i == -1)
    401            RETURN;
    402     }
    403 
    404     /* Prune the modes marked as invalid */
    405     xf86PruneDriverModes(pScrn);
     396    xf86CrtcConfigInit(pScrn, &dummy_xf86crtc_config_funcs);
     397    xf86CrtcSetSizeRange(pScrn, 8, 8, SHRT_MAX, SHRT_MAX);
    406398
    407     if (i == 0 || pScrn->modes == NULL) {
    408         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
    409         RETURN;
     399    /* Pick up size from the "Display" subsection if it exists */
     400    if (pScrn->display->virtualX) {
     401        pScrn->virtualX = pScrn->display->virtualX;
     402        pScrn->virtualY = pScrn->display->virtualY;
     403    } else {
     404        /* Pick a "modern" screen resolution */
     405        pScrn->virtualX = 3840;
     406        pScrn->virtualY = 2160;
    410407    }
     408    pScrn->displayWidth = pScrn->virtualX;
    411409
    412     /*
    413      * Set the CRTC parameters for all of the modes based on the type
    414      * of mode, and the chipset's interlace requirements.
    415      *
    416      * Calling this is required if the mode->Crtc* values are used by the
    417      * driver and if the driver doesn't provide code to set them.  They
    418      * are not pre-initialised at all.
    419      */
    420     xf86SetCrtcForModes(pScrn, 0);
    421  
    422     /* Set the current mode to the first in the list */
     410    /* Construct a mode with the screen's initial dimensions */
     411    pScrn->modes = calloc(sizeof(DisplayModeRec), 1);
     412    ConstructFakeDisplayMode(pScrn, pScrn->modes);
     413    pScrn->modes->next = pScrn->modes->prev = pScrn->modes;
    423414    pScrn->currentMode = pScrn->modes;
    424415
    425     /* Print the list of modes being used */
    426     xf86PrintModes(pScrn);
    427 
    428416    /* If monitor resolution is set on the command line, use it */
    429417    xf86SetDpi(pScrn, 0, 0);
    430418
    DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 
    515503    dPtr = DUMMYPTR(pScrn);
    516504    DUMMYScrn = pScrn;
    517505
    518 
    519     if (!(pixels = malloc(pScrn->videoRam * 1024)))
     506    if (!(pixels = malloc(pScrn->displayWidth * pScrn->bitsPerPixel * 8 *
     507                          pScrn->virtualY)))
    520508        return FALSE;
    521509   
    522510    DUMMYAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
    DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 
    569557    if (dPtr->swCursor)
    570558        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n");
    571559
    572     {
    573 
    574          
    575         BoxRec AvailFBArea;
    576         int lines = pScrn->videoRam * 1024 /
    577             (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
    578         AvailFBArea.x1 = 0;
    579         AvailFBArea.y1 = 0;
    580         AvailFBArea.x2 = pScrn->displayWidth;
    581         AvailFBArea.y2 = lines;
    582         xf86InitFBManager(pScreen, &AvailFBArea);
    583        
    584         xf86DrvMsg(pScrn->scrnIndex, X_INFO,
    585                    "Using %i scanlines of offscreen memory \n"
    586                    , lines - pScrn->virtualY);
    587     }
    588 
    589560    xf86SetBackingStore(pScreen);
    590561    xf86SetSilkenMouse(pScreen);
    591562       
    DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 
    612583                             | CMAP_RELOAD_ON_MODE_SWITCH))
    613584        return FALSE;
    614585
     586    if (!xf86CrtcScreenInit(pScreen))
     587        return FALSE;
     588
    615589    pScreen->SaveScreen = DUMMYSaveScreen;
    616590
    617591