[PATCH] dix: make inputInfo.all_devices and all_master_devices real devices (#50641)
These devices are used as placeholders for devices in passive grabs and replaced with the real device once the grab activates. The current static allocation means they don't have devPrivates allocated. If SELinux is enabled and a client registers a passive grab on XIAll(Master)Devices, this causes a null-pointer dereference of obj in SELinuxDevice(). X.Org Bug 50641 http://bugs.freedesktop.org/show_bug.cgi?id=50641 Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- This fixes the crash, the devices we used for passive grabs were special when they dont need to be (anymore). Creating them normally means we get a devPrivate and the crash goes away. That's only one half of the problem though, afaict we still activate grabs on devices that may be restricted. You'll also need the list.h patch I just sent out http://patchwork.freedesktop.org/patch/11050/ Xi/extinit.c | 16 dix/devices.c | 17 + 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Xi/extinit.c b/Xi/extinit.c index 94f46f7..5a691f8 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -185,9 +185,6 @@ static struct dev_type { CARD8 event_base[numInputClasses]; XExtEventInfo EventInfo[32]; -static DeviceIntRec xi_all_devices; -static DeviceIntRec xi_all_master_devices; - /** * Dispatch vector. Functions defined in here will be called when the matching * request arrives. @@ -1137,9 +1134,6 @@ IResetProc(ExtensionEntry * unused) EventSwapVector[DevicePresenceNotify] = NotImplemented; EventSwapVector[DevicePropertyNotify] = NotImplemented; RestoreExtensionEvents(); - -free(xi_all_devices.name); -free(xi_all_master_devices.name); } /*** @@ -1298,16 +1292,6 @@ XInputExtensionInit(void) GERegisterExtension(IReqCode, XI2EventSwap); -memset(xi_all_devices, 0, sizeof(xi_all_devices)); -memset(xi_all_master_devices, 0, sizeof(xi_all_master_devices)); -xi_all_devices.id = XIAllDevices; -xi_all_devices.name = strdup(XIAllDevices); -xi_all_master_devices.id = XIAllMasterDevices; -xi_all_master_devices.name = strdup(XIAllMasterDevices); - -inputInfo.all_devices = xi_all_devices; -inputInfo.all_master_devices = xi_all_master_devices; - XIResetProperties(); } else { diff --git a/dix/devices.c b/dix/devices.c index 08875bc..b1e1079 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -675,6 +675,20 @@ CorePointerProc(DeviceIntPtr pDev, int what) void InitCoreDevices(void) { +inputInfo.all_devices = AddInputDevice(serverClient, NULL, TRUE); +inputInfo.all_master_devices = AddInputDevice(serverClient, NULL, TRUE); + +if (!inputInfo.all_devices || !inputInfo.all_master_devices) + FatalError(Failed to allocate XIAllDevices/XIAllMasterDevices); + +inputInfo.all_devices-id = XIAllDevices; +inputInfo.all_master_devices-id = XIAllMasterDevices; + +nt_list_del(inputInfo.all_devices, inputInfo.devices, DeviceIntRec, next); +nt_list_del(inputInfo.all_devices, inputInfo.off_devices, DeviceIntRec, next); +nt_list_del(inputInfo.all_master_devices, inputInfo.devices, DeviceIntRec, next); +nt_list_del(inputInfo.all_master_devices, inputInfo.off_devices, DeviceIntRec, next); + if (AllocDevicePair(serverClient, Virtual core, inputInfo.pointer, inputInfo.keyboard, CorePointerProc, CoreKeyboardProc, TRUE) != Success) @@ -1021,6 +1035,9 @@ CloseDownDevices(void) CloseDevice(inputInfo.keyboard); +CloseDevice(inputInfo.all_devices); +CloseDevice(inputInfo.all_master_devices); + inputInfo.devices = NULL; inputInfo.off_devices = NULL; inputInfo.keyboard = NULL; -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH] Replace padlength tables with inline functions from misc.h
On Mon, Jul 02, 2012 at 08:30:49PM -0700, Alan Coopersmith wrote: Adds new function padding_for_int32() and uses existing pad_to_int32() depending on required results. Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com --- On 07/ 2/12 10:58 AM, Keith Packard wrote: (also, we should get rid of the padlength array and just use '-count 3' instead :-) Here you go. I'm not thrilled about the padding_for_int32() name, but haven't thought of a better one yet, so feel free to suggest a more aesthetically pleasing color for this bike shed. only comment would be padlength_to_int32, but english prepositions have never been my forte. Reviewed-by: Peter Hutterer peter.hutte...@who-t.net, though blurry-eyed by now Cheers, Peter dix/dispatch.c |4 +--- include/misc.h | 14 ++ os/io.c |6 ++ randr/rrscreen.c |5 + test/input.c | 34 -- 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 73b22dd..ed33a8e 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -466,8 +466,6 @@ Dispatch(void) static int VendorRelease = VENDOR_RELEASE; static char *VendorString = VENDOR_NAME; -static const int padlength[4] = { 0, 3, 2, 1 }; - void SetVendorRelease(int release) { @@ -528,7 +526,7 @@ CreateConnectionBlock(void) memmove(pBuf, VendorString, (int) setup.nbytesVendor); sizesofar += setup.nbytesVendor; pBuf += setup.nbytesVendor; -i = padlength[setup.nbytesVendor 3]; +i = padding_for_int32(setup.nbytesVendor); sizesofar += i; while (--i = 0) *pBuf++ = 0; diff --git a/include/misc.h b/include/misc.h index fea74b8..c2d146d 100644 --- a/include/misc.h +++ b/include/misc.h @@ -228,6 +228,20 @@ pad_to_int32(const int bytes) return (((bytes) + 3) ~3); } +/** + * Calculate padding needed to bring the number of bytes to an even + * multiple of 4. + * @param bytes The minimum number of bytes needed. + * @return The bytes of padding needed to arrive at the closest multiple of 4 + * that is equal or higher than bytes. + */ +static inline int +padding_for_int32(const int bytes) +{ +return ((-bytes) 3); +} + + extern char **xstrtokenize(const char *str, const char *separators); /** diff --git a/os/io.c b/os/io.c index 8d0e5cc..e44db39 100644 --- a/os/io.c +++ b/os/io.c @@ -578,8 +578,6 @@ ResetCurrentRequest(ClientPtr client) } } -static const int padlength[4] = { 0, 3, 2, 1 }; - / * FlushAllOutput() *Flush all clients with output. However, if some client still @@ -757,7 +755,7 @@ WriteToClient(ClientPtr who, int count, const void *__buf) oc-output = oco; } -padBytes = padlength[count 3]; +padBytes = padding_for_int32(count); if (ReplyCallback) { ReplyInfoRec replyinfo; @@ -850,7 +848,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) if (!oco) return 0; written = 0; -padsize = padlength[extraCount 3]; +padsize = padding_for_int32(extraCount); notWritten = oco-count + extraCount + padsize; todo = notWritten; while (notWritten) { diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 67cf0ab..fc341b4 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -22,8 +22,6 @@ #include randrstr.h -static const int padlength[4] = { 0, 3, 2, 1 }; - static CARD16 RR10CurrentSizeID(ScreenPtr pScreen); @@ -46,8 +44,7 @@ RREditConnectionInfo(ScreenPtr pScreen) connSetup = (xConnSetup *) ConnectionInfo; vendor = (char *) connSetup + sizeof(xConnSetup); formats = (xPixmapFormat *) ((char *) vendor + - connSetup-nbytesVendor + - padlength[connSetup-nbytesVendor 3]); + pad_to_int32(connSetup-nbytesVendor)); root = (xWindowRoot *) ((char *) formats + sizeof(xPixmapFormat) * screenInfo.numPixmapFormats); diff --git a/test/input.c b/test/input.c index 90ab9ae..191c817 100644 --- a/test/input.c +++ b/test/input.c @@ -965,6 +965,19 @@ test_pad_to_int32(int i) } static void +test_padding_for_int32(int i) +{ +static const int padlength[4] = { 0, 3, 2, 1 }; +int expected_bytes = (((i + 3) / 4) * 4) - i; + +assert(padding_for_int32(i) = 0); +assert(padding_for_int32(i) = 3); +assert(padding_for_int32(i) == expected_bytes); +assert(padding_for_int32(i) == padlength[i 3]); +assert((padding_for_int32(i) + i) == pad_to_int32(i)); +} + +static void include_byte_padding_macros(void) { printf(Testing bits_to_bytes()\n); @@ -996,12 +1009,12 @@ include_byte_padding_macros(void) test_bytes_to_int32(INT_MAX - 4);
Re: [PATCH] list.h: don't crash when removing an element from a NULL list
Peter Hutterer peter.hutte...@who-t.net writes: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- Keith, please merge this directly if you're happy with it. It looks fine, but I don't see any place that this actually matters in current code? (the more I see of these twisty list macros, the more I prefer open-coded lists though; wow this is hard to understand). -- keith.pack...@intel.com pgpIKgA91Bh3F.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH] list.h: don't crash when removing an element from a NULL list
On Wed, Jul 04, 2012 at 11:32:38PM -0700, Keith Packard wrote: Peter Hutterer peter.hutte...@who-t.net writes: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- Keith, please merge this directly if you're happy with it. It looks fine, but I don't see any place that this actually matters in current code? no, but the selinux fix will need it (partially out of laziness, partially to make the code nicer). (the more I see of these twisty list macros, the more I prefer open-coded lists though; wow this is hard to understand). given how often we've found bugs in open-coded lists I disagree. yes, they're hairy but they're tested, the macro behaves the same everywhere. and if you really worry about the code being wrong, run it through the pre-processor and it will look like an open-coded list. Cheers, Peter ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH] randr: add provider object (v9)
From: Dave Airlie airl...@redhat.com A provider object represents a GPU or virtual device that provides rendering or output services to the X server. This protocol allow controlling provider objects for output and offload slave devices. v1.1: fix typo add missing define v2: rename nProperties back to nAtoms, makes server simpler to c-n-p, add missing Get request/reply v3: bring back configure property, no point in diverging from the output property code without good reason. also fix typo pointed out on irc by rei4dan. v3.1: drop cut-n-paste, increase RRNumberRequests v4: reviewed by Aaron, address comments: Fix provider error code add missing notify, remove dri2 references, fix c-n-p issues. v5: add provider change notify event with current role. v5.1: fix cut-n-paste v6: document flags, fix whitespace, add better errors for SetProviderRoles, add new events, fix pending language. v6.1: add missing change notify event struct + missing padding v7: fix a bunch more tab/spaces, add appendix sections for requests, events and errors, remove multimaster flag in favour of max master counter, move some members around to follow other events. v7.1 fix maxMaster + wrong comment, one whitespace v7.2 bump to being randr 1.4, fix some too generic names. v7.3 remove dynamic flag, fix some language v8 overhaul complete protocol, remove set provider roles, add specific methods for setting offload sinks and output sources, add a list of associated providers into the get provider info struct. Signed-off-by: Dave Airlie airl...@redhat.com --- randr.h| 34 +++- randrproto.h | 235 + randrproto.txt | 520 +++- 3 files changed, 783 insertions(+), 6 deletions(-) diff --git a/randr.h b/randr.h index 04604aa..33d22fb 100644 --- a/randr.h +++ b/randr.h @@ -40,11 +40,11 @@ typedef unsigned long XRandrModeFlags; #define RANDR_NAME RANDR #define RANDR_MAJOR1 -#define RANDR_MINOR3 +#define RANDR_MINOR4 -#define RRNumberErrors 3 +#define RRNumberErrors 4 #define RRNumberEvents 2 -#define RRNumberRequests 32 +#define RRNumberRequests 42 #define X_RRQueryVersion 0 /* we skip 1 to make old clients fail pretty immediately */ @@ -92,12 +92,28 @@ typedef unsigned long XRandrModeFlags; #define RRTransformScaleDown (1L 2) #define RRTransformProjective (1L 3) +/* v1.4 */ +#define X_RRGetProviders 32 +#define X_RRGetProviderInfo 33 +#define X_RRSetProviderOffloadSink34 +#define X_RRSetProviderOutputSource 35 +#define X_RRListProviderProperties36 +#define X_RRQueryProviderProperty 37 +#define X_RRConfigureProviderProperty 38 +#define X_RRChangeProviderProperty39 +#define X_RRDeleteProviderProperty40 +#define X_RRGetProviderProperty 41 + /* Event selection bits */ #define RRScreenChangeNotifyMask (1L 0) /* V1.2 additions */ #define RRCrtcChangeNotifyMask (1L 1) #define RROutputChangeNotifyMask(1L 2) #define RROutputPropertyNotifyMask (1L 3) +/* V1.4 additions */ +#define RRProviderChangeNotifyMask (1L 4) +#define RRProviderPropertyNotifyMask (1L 5) +#define RRResourceChangeNotifyMask (1L 6) /* Event codes */ #define RRScreenChangeNotify 0 @@ -107,7 +123,9 @@ typedef unsigned long XRandrModeFlags; #define RRNotify_CrtcChange 0 #define RRNotify_OutputChange 1 #define RRNotify_OutputProperty2 - +#define RRNotify_ProviderChange3 +#define RRNotify_ProviderProperty 4 +#define RRNotify_ResourceChange5 /* used in the rotation field; rotation and reflection in 0.1 proto. */ #define RR_Rotate_01 #define RR_Rotate_90 2 @@ -148,6 +166,7 @@ typedef unsigned long XRandrModeFlags; #define BadRROutput0 #define BadRRCrtc 1 #define BadRRMode 2 +#define BadRRProvider 3 /* Conventional RandR output properties */ @@ -162,4 +181,11 @@ typedef unsigned long XRandrModeFlags; #define RR_PROPERTY_BORDER Border #define RR_PROPERTY_BORDER_DIMENSIONS BorderDimensions +/* roles this device can carry out */ +#define RR_Capability_None 0 +#define RR_Capability_SourceOutput 1 +#define RR_Capability_SinkOutput 2 +#define RR_Capability_SourceOffload 4 +#define RR_Capability_SinkOffload 8 + #endif /* _RANDR_H_ */ diff --git a/randrproto.h b/randrproto.h index 3b98a9f..30691e7 100644 --- a/randrproto.h +++ b/randrproto.h @@ -48,6 +48,7 @@ #define RROutput CARD32 #define RRMode CARD32 #define RRCrtc CARD32 +#define RRProvider CARD32 #define RRModeFlags CARD32 #define Rotation CARD16 @@ -646,6 +647,195 @@ typedef struct { #define sz_xRRGetOutputPrimaryReply32 /* + * Additions for V1.4 + */ + +typedef struct { +CARD8 reqType; +CARD8 randrReqType; +CARD16 length B16; +Window
[PATCH 02/36] PRIVATES HACK: fix crash on hotplug for nosw
From: Dave Airlie airl...@redhat.com --- dix/privates.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/privates.c b/dix/privates.c index 0948325..2b8af27 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -348,7 +348,7 @@ dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size) else { /* Resize if we can, or make sure nothing's allocated if we can't */ if (!allocated_early[type]) -assert(!global_keys[type].created); +; //assert(!global_keys[type].created); else if (!allocated_early[type] (dixReallocPrivates, bytes)) return FALSE; offset = global_keys[type].offset; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 01/36] Use screen-specific privates for exa pixmap and gc privates
From: Keith Packard kei...@keithp.com Signed-off-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- exa/exa.c | 10 -- exa/exa_priv.h | 12 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/exa/exa.c b/exa/exa.c index 0f90e59..623ece0 100644 --- a/exa/exa.c +++ b/exa/exa.c @@ -38,8 +38,6 @@ #include exa.h DevPrivateKeyRec exaScreenPrivateKeyRec; -DevPrivateKeyRec exaPixmapPrivateKeyRec; -DevPrivateKeyRec exaGCPrivateKeyRec; #ifdef MITSHM static ShmFuncs exaShmFuncs = { NULL, NULL }; @@ -915,8 +913,8 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) exaDDXDriverInit(pScreen); -if (!dixRegisterPrivateKey -(exaGCPrivateKeyRec, PRIVATE_GC, sizeof(ExaGCPrivRec))) { +if (!dixRegisterScreenSpecificPrivateKey +(pScreen, pExaScr-gcPrivateKeyRec, PRIVATE_GC, sizeof(ExaGCPrivRec))) { LogMessage(X_WARNING, EXA(%d): Failed to allocate GC private\n, pScreen-myNum); return FALSE; @@ -964,8 +962,8 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) * Hookup offscreen pixmaps */ if (pExaScr-info-flags EXA_OFFSCREEN_PIXMAPS) { -if (!dixRegisterPrivateKey -(exaPixmapPrivateKeyRec, PRIVATE_PIXMAP, +if (!dixRegisterScreenSpecificPrivateKey +(pScreen, pExaScr-pixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof(ExaPixmapPrivRec))) { LogMessage(X_WARNING, EXA(%d): Failed to allocate pixmap private\n, diff --git a/exa/exa_priv.h b/exa/exa_priv.h index f980fea..68eadc5 100644 --- a/exa/exa_priv.h +++ b/exa/exa_priv.h @@ -208,6 +208,8 @@ typedef struct { RegionRec maskReg; PixmapPtr srcPix; +DevPrivateKeyRec pixmapPrivateKeyRec; +DevPrivateKeyRec gcPrivateKeyRec; } ExaScreenPrivRec, *ExaScreenPrivPtr; /* @@ -225,17 +227,11 @@ typedef struct { extern DevPrivateKeyRec exaScreenPrivateKeyRec; #define exaScreenPrivateKey (exaScreenPrivateKeyRec) -extern DevPrivateKeyRec exaPixmapPrivateKeyRec; - -#define exaPixmapPrivateKey (exaPixmapPrivateKeyRec) -extern DevPrivateKeyRec exaGCPrivateKeyRec; - -#define exaGCPrivateKey (exaGCPrivateKeyRec) #define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)dixGetPrivate((s)-devPrivates, exaScreenPrivateKey)) #define ExaScreenPriv(s) ExaScreenPrivPtrpExaScr = ExaGetScreenPriv(s) -#define ExaGetGCPriv(gc) ((ExaGCPrivPtr)dixGetPrivateAddr((gc)-devPrivates, exaGCPrivateKey)) +#define ExaGetGCPriv(gc) ((ExaGCPrivPtr)dixGetPrivateAddr((gc)-devPrivates, ExaGetScreenPriv(gc-pScreen)-gcPrivateKeyRec)) #define ExaGCPriv(gc) ExaGCPrivPtr pExaGC = ExaGetGCPriv(gc) /* @@ -286,7 +282,7 @@ extern DevPrivateKeyRec exaGCPrivateKeyRec; #define EXA_PIXMAP_SCORE_PINNED1000 #define EXA_PIXMAP_SCORE_INIT 1001 -#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)dixGetPrivateAddr((p)-devPrivates, exaPixmapPrivateKey)) +#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)dixGetPrivateAddr((p)-devPrivates, ExaGetScreenPriv((p)-drawable.pScreen)-pixmapPrivateKeyRec)) #define ExaPixmapPriv(p) ExaPixmapPrivPtr pExaPixmap = ExaGetPixmapPriv(p) #define EXA_RANGE_PITCH (1 0) -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 04/36] screen: split out screen init code. (v2)
From: Dave Airlie airl...@redhat.com This is a precursor for reusing this code to init gpu screens. v2: fixup int check as per Keith's review. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 44 +++- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 7d2d3b7..39d791d 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3724,29 +3724,13 @@ with its screen number, a pointer to its ScreenRec, argc, and argv. */ -int -AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , - int /*argc */ , - char ** /*argv */ - ), int argc, char **argv) +static int init_screen(ScreenPtr pScreen, int i) { - -int i; int scanlinepad, format, depth, bitsPerPixel, j, k; -ScreenPtr pScreen; - -i = screenInfo.numScreens; -if (i == MAXSCREENS) -return -1; - -pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); -if (!pScreen) -return -1; dixInitScreenSpecificPrivates(pScreen); if (!dixAllocatePrivates(pScreen-devPrivates, PRIVATE_SCREEN)) { -free(pScreen); return -1; } pScreen-myNum = i; @@ -3784,7 +3768,33 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , PixmapWidthPaddingInfo[depth].notPower2 = 0; } } +return 0; +} + +int +AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , + int /*argc */ , + char ** /*argv */ + ), int argc, char **argv) +{ +int i; +ScreenPtr pScreen; +Bool ret; + +i = screenInfo.numScreens; +if (i == MAXSCREENS) +return -1; + +pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); +if (!pScreen) +return -1; + +ret = init_screen(pScreen, i); +if (ret != 0) { +free(pScreen); +return ret; +} /* This is where screen specific stuff gets initialized. Load the screen structure, call the hardware, whatever. This is also where the default colormap should be allocated and -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 05/36] dix: introduce gpu screens. (v4)
From: Dave Airlie airl...@redhat.com This patch introduces gpu screens into screenInfo. It adds interfaces for adding and removing gpu screens, along with adding private fixup, block handler support, and scratch pixmap init. GPU screens have a myNum that is offset by GPU_SCREEN_OFFSET (256), this is used for logging etc. RemoveGPUScreen isn't used until xfree86: add platform bus hotplug support. v2: no glyph pictures for GPU screens for now. v3: introduce MAXGPUSCREENS, fix return value check v4: fixup myNum when renumbering screens (ajax) Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 76 +- dix/dixutils.c |6 +++ dix/main.c | 15 +++ dix/privates.c | 111 -- include/misc.h |4 ++ include/screenint.h |9 include/scrnintstr.h |4 ++ render/glyph.c |2 + 8 files changed, 177 insertions(+), 50 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 39d791d..d229667 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3724,7 +3724,7 @@ with its screen number, a pointer to its ScreenRec, argc, and argv. */ -static int init_screen(ScreenPtr pScreen, int i) +static int init_screen(ScreenPtr pScreen, int i, Bool gpu) { int scanlinepad, format, depth, bitsPerPixel, j, k; @@ -3734,6 +3734,10 @@ static int init_screen(ScreenPtr pScreen, int i) return -1; } pScreen-myNum = i; +if (gpu) { +pScreen-myNum += GPU_SCREEN_OFFSET; +pScreen-isGPU = TRUE; +} pScreen-totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */ pScreen-ClipNotify = 0;/* for R4 ddx compatibility */ pScreen-CreateScreenResources = 0; @@ -3790,7 +3794,7 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , if (!pScreen) return -1; -ret = init_screen(pScreen, i); +ret = init_screen(pScreen, i, FALSE); if (ret != 0) { free(pScreen); return ret; @@ -3820,3 +3824,71 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , return i; } + +int +AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , + int /*argc */ , + char ** /*argv */ + ), + int argc, char **argv) +{ +int i; +ScreenPtr pScreen; +Bool ret; + +i = screenInfo.numGPUScreens; +if (i == MAXGPUSCREENS) +return -1; + +pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); +if (!pScreen) +return -1; + +ret = init_screen(pScreen, i, TRUE); +if (ret != 0) { +free(pScreen); +return ret; +} + +/* This is where screen specific stuff gets initialized. Load the + screen structure, call the hardware, whatever. + This is also where the default colormap should be allocated and + also pixel values for blackPixel, whitePixel, and the cursor + Note that InitScreen is NOT allowed to modify argc, argv, or + any of the strings pointed to by argv. They may be passed to + multiple screens. + */ +screenInfo.gpuscreens[i] = pScreen; +screenInfo.numGPUScreens++; +if (!(*pfnInit) (pScreen, argc, argv)) { +dixFreePrivates(pScreen-devPrivates, PRIVATE_SCREEN); +free(pScreen); +screenInfo.numGPUScreens--; +return -1; +} + +update_desktop_dimensions(); + +dixRegisterScreenPrivateKey(cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, +0); + +return i; +} + +void +RemoveGPUScreen(ScreenPtr pScreen) +{ +int idx, j; +if (!pScreen-isGPU) +return; + +idx = pScreen-myNum - GPU_SCREEN_OFFSET; +for (j = idx; j screenInfo.numGPUScreens - 1; j++) { +screenInfo.gpuscreens[j] = screenInfo.gpuscreens[j + 1]; +screenInfo.gpuscreens[j]-myNum = j + GPU_SCREEN_OFFSET; +} +screenInfo.numGPUScreens--; + +free(pScreen); + +} diff --git a/dix/dixutils.c b/dix/dixutils.c index b249a81..3f24629 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -386,6 +386,9 @@ BlockHandler(pointer pTimeout, pointer pReadmask) for (i = 0; i screenInfo.numScreens; i++) (*screenInfo.screens[i]-BlockHandler) (screenInfo.screens[i], pTimeout, pReadmask); +for (i = 0; i screenInfo.numGPUScreens; i++) +(*screenInfo.gpuscreens[i]-BlockHandler) (screenInfo.gpuscreens[i], + pTimeout, pReadmask); for (i = 0; i numHandlers; i++) if (!handlers[i].deleted) (*handlers[i].BlockHandler) (handlers[i].blockData, @@ -422,6 +425,9 @@ WakeupHandler(int result, pointer pReadmask) for (i = 0; i screenInfo.numScreens; i++) (*screenInfo.screens[i]-WakeupHandler) (screenInfo.screens[i],
[PATCH 06/36] xf86: cleanup helper code to use a pointer. (v1.1)
From: Dave Airlie airl...@redhat.com This is in preparation for gpu screens in here, just use a pScrn pointer to point at the new screen. suggested by Keith. v1.1: fix spacing as suggested by Aaron. Reviewed-by: Keith Packard kei...@keithp.com Reviewed-by: Aaron Plattner aplatt...@nvidia.com Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86Helper.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index 5ef1dab..18f30b7 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -167,6 +167,7 @@ ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags) { int i; +ScrnInfoPtr pScrn; if (xf86Screens == NULL) xf86NumScreens = 0; @@ -174,22 +175,22 @@ xf86AllocateScreen(DriverPtr drv, int flags) i = xf86NumScreens++; xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr)); xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); -xf86Screens[i]-scrnIndex = i; /* Changes when a screen is removed */ -xf86Screens[i]-origIndex = i; /* This never changes */ -xf86Screens[i]-privates = xnfcalloc(sizeof(DevUnion), - xf86ScrnInfoPrivateCount); +pScrn = xf86Screens[i]; +pScrn-scrnIndex = i; /* Changes when a screen is removed */ +pScrn-origIndex = i; /* This never changes */ +pScrn-privates = xnfcalloc(sizeof(DevUnion), xf86ScrnInfoPrivateCount); /* * EnableDisableFBAccess now gets initialized in InitOutput() - * xf86Screens[i]-EnableDisableFBAccess = xf86EnableDisableFBAccess; + * pScrn-EnableDisableFBAccess = xf86EnableDisableFBAccess; */ -xf86Screens[i]-drv = drv; +pScrn-drv = drv; drv-refCount++; -xf86Screens[i]-module = DuplicateModule(drv-module, NULL); +pScrn-module = DuplicateModule(drv-module, NULL); -xf86Screens[i]-DriverFunc = drv-driverFunc; +pScrn-DriverFunc = drv-driverFunc; -return xf86Screens[i]; +return pScrn; } /* -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 07/36] xfree86: add DDX gpu screen support. (v3)
From: Dave Airlie airl...@redhat.com This just adds the structures and interfaces required for adding/deleteing gpu screens at the DDX level. The platform probe can pass a new flag to the driver, so they can call xf86AllocateScreen and pass back the new gpu screen flag. It also calls the gpu screens preinit and screeninit routines at startup. v2: fix delete screen use after free. v3: split out pScrn into separate patch Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86.h|3 ++ hw/xfree86/common/xf86Bus.c |4 ++ hw/xfree86/common/xf86Globals.c |2 + hw/xfree86/common/xf86Helper.c | 98 ++- hw/xfree86/common/xf86Init.c| 42 + hw/xfree86/common/xf86Priv.h|2 + hw/xfree86/common/xf86str.h |5 +- 7 files changed, 132 insertions(+), 24 deletions(-) diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 88a219c..6116985 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -465,4 +465,7 @@ extern _X_EXPORT ScreenPtr xf86ScrnToScreen(ScrnInfoPtr pScrn); #define XF86_SCRN_INTERFACE 1 /* define for drivers to use in api compat */ +/* flags passed to xf86 allocate screen */ +#define XF86_ALLOCATE_GPU_SCREEN 1 + #endif /* _XF86_H */ diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index d0cfb2b..6de8409 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -189,6 +189,10 @@ xf86BusConfig(void) } } +/* bind GPU conf screen to protocol screen 0 */ +for (i = 0; i xf86NumGPUScreens; i++) +xf86GPUScreens[i]-confScreen = xf86Screens[0]-confScreen; + /* If no screens left, return now. */ if (xf86NumScreens == 0) { xf86Msg(X_ERROR, diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index 0071004..bb08917 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -51,6 +51,7 @@ DevPrivateKeyRec xf86CreateRootWindowKeyRec; DevPrivateKeyRec xf86ScreenKeyRec; ScrnInfoPtr *xf86Screens = NULL;/* List of ScrnInfos */ +ScrnInfoPtr *xf86GPUScreens = NULL;/* List of ScrnInfos */ const unsigned char byte_reversed[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, @@ -153,6 +154,7 @@ int xf86NumDrivers = 0; InputDriverPtr *xf86InputDriverList = NULL; int xf86NumInputDrivers = 0; int xf86NumScreens = 0; +int xf86NumGPUScreens = 0; const char *xf86VisualNames[] = { StaticGray, diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index 18f30b7..f681a85 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -169,15 +169,28 @@ xf86AllocateScreen(DriverPtr drv, int flags) int i; ScrnInfoPtr pScrn; -if (xf86Screens == NULL) -xf86NumScreens = 0; - -i = xf86NumScreens++; -xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr)); -xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); -pScrn = xf86Screens[i]; -pScrn-scrnIndex = i; /* Changes when a screen is removed */ -pScrn-origIndex = i; /* This never changes */ +if (flags XF86_ALLOCATE_GPU_SCREEN) { +if (xf86GPUScreens == NULL) +xf86NumGPUScreens = 0; +i = xf86NumGPUScreens++; +xf86GPUScreens = xnfrealloc(xf86GPUScreens, xf86NumGPUScreens * sizeof(ScrnInfoPtr)); +xf86GPUScreens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); +pScrn = xf86GPUScreens[i]; +pScrn-scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */ +pScrn-is_gpu = TRUE; +} else { +if (xf86Screens == NULL) +xf86NumScreens = 0; + +i = xf86NumScreens++; +xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr)); +xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1); +pScrn = xf86Screens[i]; + +pScrn-scrnIndex = i; /* Changes when a screen is removed */ +} + +pScrn-origIndex = pScrn-scrnIndex; /* This never changes */ pScrn-privates = xnfcalloc(sizeof(DevUnion), xf86ScrnInfoPrivateCount); /* * EnableDisableFBAccess now gets initialized in InitOutput() @@ -203,10 +216,17 @@ xf86DeleteScreen(ScrnInfoPtr pScrn) { int i; int scrnIndex; - -/* First check if the screen is valid */ -if (xf86NumScreens == 0 || xf86Screens == NULL) -return; +Bool is_gpu = FALSE; +if (pScrn-is_gpu) { +/* First check if the screen is valid */ +if (xf86NumGPUScreens == 0 || xf86GPUScreens == NULL) +return; +is_gpu = TRUE; +} else { +/* First check if the screen is valid */ +if (xf86NumScreens == 0 || xf86Screens == NULL) +return; +} if (!pScrn) return; @@ -238,12 +258,23 @@
[PATCH 09/36] xfree86: add platform bus hotplug support (v3)
From: Dave Airlie airl...@redhat.com This provides add/remove support for platform devices at xfree86 ddx level. v2: cleanup properly if no driver found. v3: load the modesetting driver before checking driver list. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86platformBus.c| 103 hw/xfree86/common/xf86platformBus.h|5 ++ hw/xfree86/os-support/linux/lnx_platform.c | 49 + 3 files changed, 157 insertions(+) diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 50b7636..0cc6c0a 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -376,4 +376,107 @@ xf86platformProbeDev(DriverPtr drvp) return foundScreen; } +int +xf86platformAddDevice(int index) +{ +int i, old_screens, scr_index; +DriverPtr drvp = NULL; +int entity; +screenLayoutPtr layout; +static char *hotplug_driver_name = modesetting; + +/* force load the driver for now */ +xf86LoadOneModule(hotplug_driver_name, NULL); + +for (i = 0; i xf86NumDrivers; i++) { +if (!xf86DriverList[i]) +continue; + +if (!strcmp(xf86DriverList[i]-driverName, hotplug_driver_name)) { +drvp = xf86DriverList[i]; +break; +} +} +if (i == xf86NumDrivers) +return -1; + +old_screens = xf86NumGPUScreens; +entity = xf86ClaimPlatformSlot(xf86_platform_devices[index], + drvp, 0, 0, 0); +if (!drvp-platformProbe(drvp, entity, PLATFORM_PROBE_GPU_SCREEN, xf86_platform_devices[index], 0)) { +xf86UnclaimPlatformSlot(xf86_platform_devices[index], NULL); +} +if (old_screens == xf86NumGPUScreens) +return -1; +i = old_screens; + +for (layout = xf86ConfigLayout.screens; layout-screen != NULL; + layout++) { +xf86GPUScreens[i]-confScreen = layout-screen; +break; +} + +if (xf86GPUScreens[i]-PreInit +xf86GPUScreens[i]-PreInit(xf86GPUScreens[i], 0)) +xf86GPUScreens[i]-configured = TRUE; + +if (!xf86GPUScreens[i]-configured) { +ErrorF(hotplugged device %d didn't configure\n, i); +xf86DeleteScreen(xf86GPUScreens[i]); +return -1; +} + + scr_index = AddGPUScreen(xf86GPUScreens[i]-ScreenInit, 0, NULL); + + dixSetPrivate(xf86GPUScreens[i]-pScreen-devPrivates, + xf86ScreenKey, xf86GPUScreens[i]); + + CreateScratchPixmapsForScreen(xf86GPUScreens[i]-pScreen); + + return 0; +} + +void +xf86platformRemoveDevice(int index) +{ +EntityPtr entity; +int ent_num, i, j; +Bool found; + +for (ent_num = 0; ent_num xf86NumEntities; ent_num++) { +entity = xf86Entities[ent_num]; +if (entity-bus.type == BUS_PLATFORM +entity-bus.id.plat == xf86_platform_devices[index]) +break; +} +if (ent_num == xf86NumEntities) +goto out; + +found = FALSE; +for (i = 0; i xf86NumGPUScreens; i++) { +for (j = 0; j xf86GPUScreens[i]-numEntities; j++) +if (xf86GPUScreens[i]-entityList[j] == ent_num) { +found = TRUE; +break; +} +if (found) +break; +} +if (!found) { +ErrorF(failed to find screen to remove\n); +goto out; +} + +xf86GPUScreens[i]-pScreen-CloseScreen(xf86GPUScreens[i]-pScreen); + +RemoveGPUScreen(xf86GPUScreens[i]-pScreen); +xf86DeleteScreen(xf86GPUScreens[i]); + +xf86UnclaimPlatformSlot(xf86_platform_devices[index], NULL); + +xf86_remove_platform_device(index); + + out: +return; +} #endif diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h index 15a3022..49afc24 100644 --- a/hw/xfree86/common/xf86platformBus.h +++ b/hw/xfree86/common/xf86platformBus.h @@ -47,6 +47,11 @@ xf86_remove_platform_device(int dev_index); extern Bool xf86_add_platform_device_attrib(int index, int attrib_id, char *attrib_str); +extern int +xf86platformAddDevice(int index); +extern void +xf86platformRemoveDevice(int index); + extern _X_EXPORT char * xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib_id); extern _X_EXPORT Bool diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c index 9c63ee5..76f5583 100644 --- a/hw/xfree86/os-support/linux/lnx_platform.c +++ b/hw/xfree86/os-support/linux/lnx_platform.c @@ -15,6 +15,8 @@ #include xf86platformBus.h #include xf86Bus.h +#include hotplug.h + static Bool get_drm_info(struct OdevAttributes *attribs, char *path) { @@ -127,4 +129,51 @@ out_free: config_odev_free_attribute_list(attribs); } +void NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ +int old_num = xf86_num_platform_devices; +int ret; +xf86PlatformDeviceProbe(attribs); + +if (old_num ==
[PATCH 10/36] xfree86: add autoAddGPU option (v2)
From: Dave Airlie airl...@redhat.com This option is to stop the X server adding non-primary devices as gpu screens. v2: fix per Keith's suggestion. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86Config.c | 15 ++- hw/xfree86/common/xf86Globals.c |9 +++-- hw/xfree86/common/xf86Privstr.h |2 ++ hw/xfree86/common/xf86platformBus.c |7 +++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index b22b617..edc0d3d 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -712,7 +712,8 @@ typedef enum { FLAG_AUTO_ENABLE_DEVICES, FLAG_GLX_VISUALS, FLAG_DRI2, -FLAG_USE_SIGIO +FLAG_USE_SIGIO, +FLAG_AUTO_ADD_GPU, } FlagValues; /** @@ -770,6 +771,8 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE}, {FLAG_USE_SIGIO, UseSIGIO, OPTV_BOOLEAN, {0}, FALSE}, +{FLAG_AUTO_ADD_GPU, AutoAddGPU, OPTV_BOOLEAN, + {0}, FALSE}, {-1, NULL, OPTV_NONE, {0}, FALSE}, }; @@ -862,6 +865,16 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) xf86Msg(from, %sutomatically enabling devices\n, xf86Info.autoEnableDevices ? A : Not a); +if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_GPU)) { +xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_GPU, + xf86Info.autoAddGPU); +from = X_CONFIG; +} +else { +from = X_DEFAULT; +} +xf86Msg(from, %sutomatically adding GPU devices\n, +xf86Info.autoAddGPU ? A : Not a); /* * Set things up based on the config file information. Some of these * settings may be overridden later when the command line options are diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index bb08917..7df7a80 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -126,11 +126,16 @@ xf86InfoRec xf86Info = { #if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) .forceInputDevices = FALSE, .autoAddDevices = TRUE, -.autoEnableDevices = TRUE +.autoEnableDevices = TRUE, #else .forceInputDevices = TRUE, .autoAddDevices = FALSE, -.autoEnableDevices = FALSE +.autoEnableDevices = FALSE, +#endif +#if defined(CONFIG_UDEV_KMS) +.autoAddGPU = TRUE, +#else +.autoAddGPU = FALSE, #endif }; diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index e78cd40..e20be03 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -110,6 +110,8 @@ typedef struct { Bool dri2; MessageType dri2From; + +Bool autoAddGPU; } xf86InfoRec, *xf86InfoPtr; #ifdef DPMSExtension diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 0cc6c0a..3bfb22e 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -373,6 +373,13 @@ xf86platformProbeDev(DriverPtr drvp) continue; } +/* if autoaddgpu devices is enabled then go find a few more and add them as GPU screens */ +if (xf86Info.autoAddGPU numDevs) { +for (j = 0; j xf86_num_platform_devices; j++) { +probeSingleDevice(xf86_platform_devices[j], drvp, devList[0], PLATFORM_PROBE_GPU_SCREEN); +} +} + return foundScreen; } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 08/36] xserver/config: add udev/drm hotplug callbacks. (v2)
From: Dave Airlie airl...@redhat.com This adds callbacks into the ddx for udev gpu hotplug. v2: fix some strncmp returns. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- config/udev.c | 42 ++ include/hotplug.h |4 2 files changed, 46 insertions(+) diff --git a/config/udev.c b/config/udev.c index efa8d32..5297b90 100644 --- a/config/udev.c +++ b/config/udev.c @@ -52,6 +52,12 @@ static struct udev_monitor *udev_monitor; +#ifdef CONFIG_UDEV_KMS +static Bool +config_udev_odev_setup_attribs(const char *path, const char *syspath, + config_odev_probe_proc_ptr probe_callback); +#endif + static void device_added(struct udev_device *udev_device) { @@ -85,6 +91,20 @@ device_added(struct udev_device *udev_device) if (!SeatId strcmp(dev_seat, seat0)) return; +#ifdef CONFIG_UDEV_KMS +if (!strcmp(udev_device_get_subsystem(udev_device), drm)) { +const char *sysname = udev_device_get_sysname(udev_device); + +if (strncmp(sysname, card, 4) != 0) +return; + +LogMessage(X_INFO, config/udev: Adding drm device (%s)\n, path); + +config_udev_odev_setup_attribs(path, syspath, NewGPUDeviceRequest); +return; +} +#endif + if (!udev_device_get_property_value(udev_device, ID_INPUT)) { LogMessageVerb(X_INFO, 10, config/udev: ignoring device %s without @@ -240,6 +260,22 @@ device_removed(struct udev_device *device) char *value; const char *syspath = udev_device_get_syspath(device); +#ifdef CONFIG_UDEV_KMS +if (!strcmp(udev_device_get_subsystem(device), drm)) { +const char *sysname = udev_device_get_sysname(device); +const char *path = udev_device_get_devnode(device); + +if (strncmp(sysname,card, 4) != 0) +return; +ErrorF(removing GPU device %s %d\n, syspath, path); +if (!path) +return; + +config_udev_odev_setup_attribs(path, syspath, DeleteGPUDeviceRequest); +return; +} +#endif + if (asprintf(value, udev:%s, syspath) == -1) return; @@ -296,6 +332,9 @@ config_udev_pre_init(void) udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, input, NULL); udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, tty, NULL); /* For Wacom serial devices */ +#ifdef CONFIG_UDEV_KMS +udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, drm, NULL); /* For output GPU devices */ +#endif #ifdef HAVE_UDEV_MONITOR_FILTER_ADD_MATCH_TAG if (SeatId strcmp(SeatId, seat0)) @@ -322,6 +361,9 @@ config_udev_init(void) udev_enumerate_add_match_subsystem(enumerate, input); udev_enumerate_add_match_subsystem(enumerate, tty); +#ifdef CONFIG_UDEV_KMS +udev_enumerate_add_match_subsystem(enumerate, drm); +#endif #ifdef HAVE_UDEV_ENUMERATE_ADD_MATCH_TAG if (SeatId strcmp(SeatId, seat0)) diff --git a/include/hotplug.h b/include/hotplug.h index 5000762..96b078d 100644 --- a/include/hotplug.h +++ b/include/hotplug.h @@ -65,4 +65,8 @@ config_odev_free_attributes(struct OdevAttributes *attribs); typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs); void config_odev_probe(config_odev_probe_proc_ptr probe_callback); +#ifdef CONFIG_UDEV_KMS +void NewGPUDeviceRequest(struct OdevAttributes *attribs); +void DeleteGPUDeviceRequest(struct OdevAttributes *attribs); +#endif #endif /* HOTPLUG_H */ -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 12/36] xfree86: add framework for provider support in ddx. (v3)
From: Dave Airlie airl...@redhat.com This adds the framework for DDX provider support. v2: as per keithp's suggestion remove the xf86 provider object and just store it in the toplevel object. v3: update for new protocol Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86str.h|1 + hw/xfree86/modes/xf86Crtc.c| 17 +++ hw/xfree86/modes/xf86Crtc.h| 34 + hw/xfree86/modes/xf86RandR12.c | 47 4 files changed, 99 insertions(+) diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 6bd6a62..0590262 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -814,6 +814,7 @@ typedef struct _ScrnInfoRec { funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; Bool is_gpu; +uint32_t capabilities; } ScrnInfoRec; typedef struct { diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 2c8878f..62de5a0 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -3202,3 +3202,20 @@ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn) return FALSE; } + +void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec *funcs, const char *name) +{ +xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + +assert(!xf86_config-name); +assert(name); + +xf86_config-name = strdup(name); +xf86_config-provider_funcs = funcs; +#ifdef RANDR_12_INTERFACE +xf86_config-randr_provider = NULL; +#endif +} + diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index a6a3c2e..58d8cec 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -607,6 +607,29 @@ struct _xf86Output { INT16 initialBorder[4]; }; +typedef struct _xf86ProviderFuncs { +/** + * Called to allow the provider a chance to create properties after the + * RandR objects have been created. + */ +void +(*create_resources) (ScrnInfoPtr scrn); + +/** + * Callback when an provider's property has changed. + */ +Bool +(*set_property) (ScrnInfoPtr scrn, + Atom property, RRPropertyValuePtr value); + +/** + * Callback to get an updated property value + */ +Bool +(*get_property) (ScrnInfoPtr provider, Atom property); + +} xf86ProviderFuncsRec, *xf86ProviderFuncsPtr; + typedef struct _xf86CrtcConfigFuncs { /** * Requests that the driver resize the screen. @@ -681,6 +704,13 @@ typedef struct _xf86CrtcConfig { /* callback when crtc configuration changes */ xf86_crtc_notify_proc_ptr xf86_crtc_notify; +char *name; +const xf86ProviderFuncsRec *provider_funcs; +#ifdef RANDR_12_INTERFACE +RRProviderPtr randr_provider; +#else +void *randr_provider; +#endif } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern _X_EXPORT int xf86CrtcConfigPrivateIndex; @@ -975,4 +1005,8 @@ extern _X_EXPORT void extern _X_EXPORT Bool xf86_crtc_supports_gamma(ScrnInfoPtr pScrn); +extern _X_EXPORT void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec * funcs, const char *name); + #endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 59b6f82..1eaef9d 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1552,6 +1552,14 @@ xf86RandR12CreateObjects12(ScreenPtr pScreen) output-funcs-create_resources(output); RRPostPendingProperties(output-randr_output); } + +if (config-name) { +config-randr_provider = RRProviderCreate(pScreen, config-name, + strlen(config-name), config); + +RRProviderSetCapabilities(config-randr_provider, pScrn-capabilities); +} + return TRUE; } @@ -1746,6 +1754,41 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn) } static Bool +xf86RandR14ProviderSetProperty(ScreenPtr pScreen, + RRProviderPtr randr_provider, + Atom property, RRPropertyValuePtr value) +{ +xf86CrtcConfigPtr config = randr_provider-devPrivate; +ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + +/* If we don't have any property handler, then we don't care what the + * user is setting properties to. + */ +if (config-provider_funcs-set_property == NULL) +return TRUE; + +/* + * This function gets called even when vtSema is FALSE, as + * drivers will need to remember the correct value to apply + * when the VT switch occurs + */ +return config-provider_funcs-set_property(pScrn, property, value); +} + +static Bool +xf86RandR14ProviderGetProperty(ScreenPtr pScreen, + RRProviderPtr randr_provider, Atom property) +{ +xf86CrtcConfigPtr config = randr_provider-devPrivate; +ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); +
[PATCH 13/36] dix: add unattached list for attaching screens to initially. (v1.1)
From: Dave Airlie airl...@redhat.com This list is meant for attaching unbound gpu screens to initially, before the client side rebinds them. v1.1: add another assert in the add path. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 20 include/screenint.h |5 + include/scrnintstr.h |6 ++ 3 files changed, 31 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index d229667..6ddcb97 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3742,6 +3742,8 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) pScreen-ClipNotify = 0;/* for R4 ddx compatibility */ pScreen-CreateScreenResources = 0; +xorg_list_init(pScreen-unattached_list); + /* * This loop gets run once for every Screen that gets added, * but thats ok. If the ddx layer initializes the formats @@ -3892,3 +3894,21 @@ RemoveGPUScreen(ScreenPtr pScreen) free(pScreen); } + +void +AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new) +{ +assert(new-isGPU); +assert(!new-current_master); +xorg_list_add(new-unattached_head, pScreen-unattached_list); +new-current_master = pScreen; +} + +void +DetachUnboundGPU(ScreenPtr slave) +{ +assert(slave-isGPU); +xorg_list_del(slave-unattached_head); +slave-current_master = NULL; +} + diff --git a/include/screenint.h b/include/screenint.h index 8205f63..c0c60ef 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -71,6 +71,11 @@ extern _X_EXPORT int AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , extern _X_EXPORT void RemoveGPUScreen(ScreenPtr pScreen); +extern _X_EXPORT void +AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new); +extern _X_EXPORT void +DetachUnboundGPU(ScreenPtr unbound); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/scrnintstr.h b/include/scrnintstr.h index bcac475..6b738de 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -479,6 +479,12 @@ typedef struct _Screen { Bool canDoBGNoneRoot; Bool isGPU; + +struct xorg_list unattached_list; +struct xorg_list unattached_head; + +ScreenPtr current_master; + } ScreenRec; static inline RegionPtr -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 14/36] dix: attach unbound screens to protocol screen 0
From: Dave Airlie airl...@redhat.com This is the default attachment, unbound gpu screens get attached to the 0 protocol screen. detach on hotunplug. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86Init.c |3 +++ hw/xfree86/modes/xf86Crtc.c |4 2 files changed, 7 insertions(+) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index a60cf38..54fc523 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -920,6 +920,9 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) #endif } +for (i = 0; i xf86NumGPUScreens; i++) +AttachUnboundGPU(xf86Screens[0]-pScreen, xf86GPUScreens[i]-pScreen); + xf86VGAarbiterWrapFunctions(); xf86UnblockSIGIO(was_blocked); diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 62de5a0..a8dc187 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -726,6 +726,10 @@ xf86CrtcCloseScreen(ScreenPtr screen) xf86RotateCloseScreen(screen); +/* detach any providers */ +if (config-randr_provider) { +DetachUnboundGPU(screen); +} for (o = 0; o config-num_output; o++) { xf86OutputPtr output = config-output[o]; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 15/36] randr: expose unattached providers to the clients.
From: Dave Airlie airl...@redhat.com This provides the unattached provider list to the clients. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrprovider.c |8 1 file changed, 8 insertions(+) diff --git a/randr/rrprovider.c b/randr/rrprovider.c index b787b94..0a801d4 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -59,6 +59,7 @@ ProcRRGetProviders (ClientPtr client) unsigned int extraLen; RRProvider *providers; int total_providers = 0, count_providers = 0; +ScreenPtr iter; REQUEST_SIZE_MATCH(xRRGetProvidersReq); rc = dixLookupWindow(pWin, stuff-window, client, DixGetAttrAccess); @@ -71,6 +72,10 @@ ProcRRGetProviders (ClientPtr client) if (pScrPriv-provider) total_providers++; +xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { +pScrPriv = rrGetScrPriv(iter); +total_providers += pScrPriv-provider ? 1 : 0; +} pScrPriv = rrGetScrPriv(pScreen); rep.pad = 0; @@ -100,6 +105,9 @@ ProcRRGetProviders (ClientPtr client) providers = (RRProvider *)extra; ADD_PROVIDER(pScreen); +xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { +ADD_PROVIDER(iter); +} } if (client-swapped) { -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 16/36] xf86dga: handle DGAAvailable for gpu screens. (v2)
From: Dave Airlie airl...@redhat.com v2: Split out DGAAvailable into two interfaces, one for calls from protocol decoding and one for internal usage, after discussion with ajax and keithp. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86DGA.c | 15 --- hw/xfree86/dixmods/extmod/dgaproc.h |1 + hw/xfree86/modes/xf86DiDGA.c|2 +- hw/xfree86/vgahw/vgaCmap.c |2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 6416372..61612c3 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -521,18 +521,27 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) } Bool -DGAAvailable(int index) +DGAScreenAvailable(ScreenPtr pScreen) { if (!DGAScreenKeyRegistered) return FALSE; -if (DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) +if (DGA_GET_SCREEN_PRIV(pScreen)) return TRUE; - return FALSE; } Bool +DGAAvailable(int index) +{ +ScreenPtr pScreen; + +assert(index MAXSCREENS); +pScreen = screenInfo.screens[index]; +return DGAScreenAvailable(pScreen); +} + +Bool DGAActive(int index) { DGAScreenPtr pScreenPriv; diff --git a/hw/xfree86/dixmods/extmod/dgaproc.h b/hw/xfree86/dixmods/extmod/dgaproc.h index b4e0ddf..2c2fae0 100644 --- a/hw/xfree86/dixmods/extmod/dgaproc.h +++ b/hw/xfree86/dixmods/extmod/dgaproc.h @@ -64,6 +64,7 @@ extern _X_EXPORT void DGASelectInput(int Index, ClientPtr client, long mask); extern _X_EXPORT Bool DGAAvailable(int Index); +extern _X_EXPORT Bool DGAScreenAvailable(ScreenPtr pScreen); extern _X_EXPORT Bool DGAActive(int Index); extern _X_EXPORT void DGAShutdown(void); extern _X_EXPORT void DGAInstallCmap(ColormapPtr cmap); diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c index bb954ac..3f1a330 100644 --- a/hw/xfree86/modes/xf86DiDGA.c +++ b/hw/xfree86/modes/xf86DiDGA.c @@ -178,7 +178,7 @@ _xf86_di_dga_reinit_internal(ScreenPtr pScreen) ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); -if (!DGAAvailable(pScreen-myNum)) +if (!DGAScreenAvailable(pScreen)) return TRUE; if (!xf86_dga_get_modes(pScreen)) diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c index a1aa405..e7a0d02 100644 --- a/hw/xfree86/vgahw/vgaCmap.c +++ b/hw/xfree86/vgahw/vgaCmap.c @@ -97,7 +97,7 @@ xColorItem *pdefs; } writeColormap = scrninfp-vtSema; -if (DGAAvailable(scrnIndex)) { +if (DGAScreenAvailable(pmap-pScreen)) { writeColormap = writeColormap || (DGAGetDirectMode(scrnIndex) !(DGAGetFlags(scrnIndex) XF86DGADirectColormap)) || -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 17/36] dix: add ability to link output slave gpus to the current gpu (v1.1)
From: Dave Airlie airl...@redhat.com Just add the interfaces to attach/detach output slaves, and a linked list to keep track of them. Hook up the randr providers list to include these slaves. v1.1: add another assert to the add path. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 17 + include/screenint.h |6 ++ include/scrnintstr.h |3 +++ randr/rrprovider.c |7 +++ 4 files changed, 33 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index 6ddcb97..2eb13db 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3743,6 +3743,7 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) pScreen-CreateScreenResources = 0; xorg_list_init(pScreen-unattached_list); +xorg_list_init(pScreen-output_slave_list); /* * This loop gets run once for every Screen that gets added, @@ -3912,3 +3913,19 @@ DetachUnboundGPU(ScreenPtr slave) slave-current_master = NULL; } +void +AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new) +{ +assert(new-isGPU); +assert(!new-current_master); +xorg_list_add(new-output_head, pScreen-output_slave_list); +new-current_master = pScreen; +} + +void +DetachOutputGPU(ScreenPtr slave) +{ +assert(slave-isGPU); +xorg_list_del(slave-output_head); +slave-current_master = NULL; +} diff --git a/include/screenint.h b/include/screenint.h index c0c60ef..b992cc2 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -76,6 +76,12 @@ AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new); extern _X_EXPORT void DetachUnboundGPU(ScreenPtr unbound); +extern _X_EXPORT void +AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new); + +extern _X_EXPORT void +DetachOutputGPU(ScreenPtr output); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 6b738de..7efc5c3 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -485,6 +485,9 @@ typedef struct _Screen { ScreenPtr current_master; +struct xorg_list output_slave_list; +struct xorg_list output_head; + } ScreenRec; static inline RegionPtr diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 0a801d4..33cb77d 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -72,6 +72,10 @@ ProcRRGetProviders (ClientPtr client) if (pScrPriv-provider) total_providers++; +xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { +pScrPriv = rrGetScrPriv(iter); +total_providers += pScrPriv-provider ? 1 : 0; +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { pScrPriv = rrGetScrPriv(iter); total_providers += pScrPriv-provider ? 1 : 0; @@ -105,6 +109,9 @@ ProcRRGetProviders (ClientPtr client) providers = (RRProvider *)extra; ADD_PROVIDER(pScreen); +xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { +ADD_PROVIDER(iter); +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { ADD_PROVIDER(iter); } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 18/36] dix: pixmap sharing infrastructure (v3)
From: Dave Airlie airl...@redhat.com This is a hooks for pixmap sharing and tracking. The pixmap sharing ones get an integer handle for the pixmap and use a handle to be the backing for a pixmap. The tracker interface is to be used when a GPU needs to track pixmaps to be updated for another GPU. v2: pass slave to sharing so it can use it to work out driver. v3: use void * as per keithp's suggestion. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- include/scrnintstr.h | 17 + 1 file changed, 17 insertions(+) diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 7efc5c3..3a738d3 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -179,6 +179,8 @@ typedef void (*ClipNotifyProcPtr) (WindowPtr /*pWindow */ , #define CREATE_PIXMAP_USAGE_BACKING_PIXMAP 2 /* pixmap will contain a glyph */ #define CREATE_PIXMAP_USAGE_GLYPH_PICTURE 3 +/* pixmap will be shared */ +#define CREATE_PIXMAP_USAGE_SHARED 4 typedef PixmapPtr (*CreatePixmapProcPtr) (ScreenPtr /*pScreen */ , int /*width */ , @@ -339,6 +341,16 @@ typedef void (*DeviceCursorCleanupProcPtr) (DeviceIntPtr /* pDev */ , typedef void (*ConstrainCursorHarderProcPtr) (DeviceIntPtr, ScreenPtr, int, int *, int *); + +typedef Bool (*SharePixmapBackingProcPtr)(PixmapPtr, ScreenPtr, void **); + +typedef Bool (*SetSharedPixmapBackingProcPtr)(PixmapPtr, void *); + +typedef Bool (*StartPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr, + int x, int y); + +typedef Bool (*StopPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr); + typedef struct _Screen { int myNum; /* index of this instance in Screens[] */ ATOM id; @@ -488,6 +500,11 @@ typedef struct _Screen { struct xorg_list output_slave_list; struct xorg_list output_head; +SharePixmapBackingProcPtr SharePixmapBacking; +SetSharedPixmapBackingProcPtr SetSharedPixmapBacking; + +StartPixmapTrackingProcPtr StartPixmapTracking; +StopPixmapTrackingProcPtr StopPixmapTracking; } ScreenRec; static inline RegionPtr -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 19/36] exa: pixmap sharing infrastructure (v3)
From: Dave Airlie airl...@redhat.com This just adds exa interfaces for mixed exa so drivers can share and set shared pixmaps up correctly. v2: update for passing slave screen. v3: update for void * Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- exa/exa.c |7 +++ exa/exa.h |6 +- exa/exa_mixed.c | 33 + exa/exa_priv.h |7 +++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/exa/exa.c b/exa/exa.c index 623ece0..d12344f 100644 --- a/exa/exa.c +++ b/exa/exa.c @@ -782,6 +782,10 @@ exaCloseScreen(ScreenPtr pScreen) unwrap(pExaScr, pScreen, ChangeWindowAttributes); unwrap(pExaScr, pScreen, BitmapToRegion); unwrap(pExaScr, pScreen, CreateScreenResources); +if (pExaScr-SavedSharePixmapBacking) +unwrap(pExaScr, pScreen, SharePixmapBacking); +if (pExaScr-SavedSetSharedPixmapBacking) +unwrap(pExaScr, pScreen, SetSharedPixmapBacking); unwrap(pExaScr, ps, Composite); if (pExaScr-SavedGlyphs) unwrap(pExaScr, ps, Glyphs); @@ -976,6 +980,9 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_mixed); wrap(pExaScr, pScreen, ModifyPixmapHeader, exaModifyPixmapHeader_mixed); +wrap(pExaScr, pScreen, SharePixmapBacking, exaSharePixmapBacking_mixed); +wrap(pExaScr, pScreen, SetSharedPixmapBacking, exaSetSharedPixmapBacking_mixed); + pExaScr-do_migration = exaDoMigration_mixed; pExaScr-pixmap_has_gpu_copy = exaPixmapHasGpuCopy_mixed; pExaScr-do_move_in_pixmap = exaMoveInPixmap_mixed; diff --git a/exa/exa.h b/exa/exa.h index 8a6539f..be022b2 100644 --- a/exa/exa.h +++ b/exa/exa.h @@ -39,7 +39,7 @@ #include fb.h #define EXA_VERSION_MAJOR 2 -#define EXA_VERSION_MINOR 5 +#define EXA_VERSION_MINOR 6 #define EXA_VERSION_RELEASE 0 typedef struct _ExaOffscreenArea ExaOffscreenArea; @@ -694,6 +694,10 @@ typedef struct _ExaDriver { int depth, int usage_hint, int bitsPerPixel, int *new_fb_pitch); /** @} */ +Bool (*SharePixmapBacking)(PixmapPtr pPixmap, ScreenPtr slave, void **handle_p); + +Bool (*SetSharedPixmapBacking)(PixmapPtr pPixmap, void *handle); + } ExaDriverRec, *ExaDriverPtr; /** @name EXA driver flags diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c index 0681731..0fb4091 100644 --- a/exa/exa_mixed.c +++ b/exa/exa_mixed.c @@ -294,3 +294,36 @@ exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap) return ret; } + +Bool +exaSharePixmapBacking_mixed(PixmapPtr pPixmap, ScreenPtr slave, void **handle_p) +{ +ScreenPtr pScreen = pPixmap-drawable.pScreen; +ExaScreenPriv(pScreen); +Bool ret = FALSE; + +exaMoveInPixmap(pPixmap); +/* get the driver to give us a handle */ +if (pExaScr-info-SharePixmapBacking) +ret = pExaScr-info-SharePixmapBacking(pPixmap, slave, handle_p); + +return ret; +} + +Bool +exaSetSharedPixmapBacking_mixed(PixmapPtr pPixmap, void *handle) +{ +ScreenPtr pScreen = pPixmap-drawable.pScreen; +ExaScreenPriv(pScreen); +Bool ret = FALSE; + +if (pExaScr-info-SetSharedPixmapBacking) +ret = pExaScr-info-SetSharedPixmapBacking(pPixmap, handle); + +if (ret == TRUE) +exaMoveInPixmap(pPixmap); + +return ret; +} + + diff --git a/exa/exa_priv.h b/exa/exa_priv.h index 68eadc5..ea7e7fa 100644 --- a/exa/exa_priv.h +++ b/exa/exa_priv.h @@ -163,6 +163,8 @@ typedef struct { BitmapToRegionProcPtr SavedBitmapToRegion; CreateScreenResourcesProcPtr SavedCreateScreenResources; ModifyPixmapHeaderProcPtr SavedModifyPixmapHeader; +SharePixmapBackingProcPtr SavedSharePixmapBacking; +SetSharedPixmapBackingProcPtr SavedSetSharedPixmapBacking; SourceValidateProcPtr SavedSourceValidate; CompositeProcPtr SavedComposite; TrianglesProcPtr SavedTriangles; @@ -658,6 +660,11 @@ void void exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg); +Bool +exaSetSharedPixmapBacking_mixed(PixmapPtr pPixmap, void *handle); +Bool +exaSharePixmapBacking_mixed(PixmapPtr pPixmap, ScreenPtr slave, void **handle_p); + /* exa_render.c */ Bool exaOpReadsDestination(CARD8 op); -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 20/36] randr: add initial scanout pixmap support (v3)
From: Dave Airlie airl...@redhat.com When randr notices a crtc configuration request for a slave device, it checks if the slave allocated pixmap exists and is suitable, if not it allocates a new shared pixmap from the master, shares it to the slave, and starts the master tracking damage to it, to keep it updated from the current front pixmap. If the resize means the crtc is no longer used it will destroy the slave pixmap. This adds the concept of a scanout_pixmap to the randr_crtc object, and also adds a master pixmap pointer to the pixmap object, along with defining some pixmap helper functions for getting pixmap box/regions. v2: split out pixmap sharing to a separate function. v3: update for void * Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- dix/pixmap.c| 29 + include/pixmap.h|3 + include/pixmapstr.h | 22 +++ randr/randrstr.h| 12 randr/rrcrtc.c | 171 +++ 5 files changed, 237 insertions(+) diff --git a/dix/pixmap.c b/dix/pixmap.c index 0c85c3f..7272098 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -129,3 +129,32 @@ FreePixmap(PixmapPtr pPixmap) dixFiniPrivates(pPixmap, PRIVATE_PIXMAP); free(pPixmap); } + +PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave) +{ +PixmapPtr spix; +int ret; +void *handle; +ScreenPtr master = pixmap-drawable.pScreen; +int depth = pixmap-drawable.depth; + +ret = master-SharePixmapBacking(pixmap, slave, handle); +if (ret == FALSE) + return NULL; + +spix = slave-CreatePixmap(slave, 0, 0, depth, + CREATE_PIXMAP_USAGE_SHARED); +slave-ModifyPixmapHeader(spix, pixmap-drawable.width, + pixmap-drawable.height, depth, 0, + pixmap-devKind, NULL); + +spix-master_pixmap = pixmap; + +ret = slave-SetSharedPixmapBacking(spix, handle); +if (ret == FALSE) { + slave-DestroyPixmap(spix); + return NULL; +} + +return spix; +} diff --git a/include/pixmap.h b/include/pixmap.h index 9bb5bb7..8c523bd 100644 --- a/include/pixmap.h +++ b/include/pixmap.h @@ -109,4 +109,7 @@ extern _X_EXPORT PixmapPtr AllocatePixmap(ScreenPtr /*pScreen */ , extern _X_EXPORT void FreePixmap(PixmapPtr /*pPixmap */ ); +extern _X_EXPORT PixmapPtr +PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave); + #endif /* PIXMAP_H */ diff --git a/include/pixmapstr.h b/include/pixmapstr.h index 0800c62..40af5c4 100644 --- a/include/pixmapstr.h +++ b/include/pixmapstr.h @@ -80,6 +80,28 @@ typedef struct _Pixmap { short screen_y; #endif unsigned usage_hint;/* see CREATE_PIXMAP_USAGE_* */ + +PixmapPtr master_pixmap;/* pointer to master copy of pixmap for pixmap sharing */ } PixmapRec; +static inline void +PixmapBox(BoxPtr box, PixmapPtr pixmap) +{ +box-x1 = 0; +box-x2 = pixmap-drawable.width; + +box-y1 = 0; +box-y2 = pixmap-drawable.height; +} + + +static inline void +PixmapRegionInit(RegionPtr region, PixmapPtr pixmap) +{ +BoxRec box; + +PixmapBox(box, pixmap); +RegionInit(region, box, 1); +} + #endif /* PIXMAPSTRUCT_H */ diff --git a/randr/randrstr.h b/randr/randrstr.h index 0e04b74..4ed581d 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -127,6 +127,8 @@ struct _rrCrtc { PictTransform transform; struct pict_f_transform f_transform; struct pict_f_transform f_inverse; + +PixmapPtr scanout_pixmap; }; struct _rrOutput { @@ -247,6 +249,8 @@ typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, #endif +typedef Bool (*RRCrtcSetScanoutPixmapProcPtr)(RRCrtcPtr crtc, PixmapPtr pixmap); + typedef struct _rrScrPriv { /* * 'public' part of the structure; DDXen fill this in @@ -270,6 +274,8 @@ typedef struct _rrScrPriv { RRGetPanningProcPtr rrGetPanning; RRSetPanningProcPtr rrSetPanning; #endif +/* TODO #if RANDR_15_INTERFACE */ +RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; RRProviderGetPropertyProcPtr rrProviderGetProperty; RRProviderSetPropertyProcPtr rrProviderSetProperty; @@ -654,6 +660,12 @@ extern _X_EXPORT void RRCrtcInitErrorValue(void); /* + * Detach and free a scanout pixmap + */ +extern _X_EXPORT void + RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc); + +/* * Crtc dispatch */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 0c596dd..29b02a9 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -367,6 +367,154 @@ RRComputeContiguity(ScreenPtr pScreen) pScrPriv-discontiguous = discontiguous; } +void +RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc) +{ +ScreenPtr master = crtc-pScreen-current_master; +int ret; +PixmapPtr mscreenpix; +rrScrPriv(crtc-pScreen); + +mscreenpix = master-GetScreenPixmap(master); + +ret = pScrPriv-rrCrtcSetScanoutPixmap(crtc, NULL); +if
[PATCH 23/36] randr: fix tellchanged to work with slave scanouts
From: Dave Airlie airl...@redhat.com Tell changed need to tell only for the master pixmap, however it gets called from various places for slave screens, so convert to telling clients about changes on the master screen. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/randr.c | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 103c31e..ae81166 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -467,25 +467,37 @@ TellChanged(WindowPtr pWin, pointer value) void RRTellChanged(ScreenPtr pScreen) { +ScreenPtr master; rrScrPriv(pScreen); +rrScrPrivPtr mastersp; int i; +if (pScreen-isGPU) { +master = pScreen-current_master; +mastersp = rrGetScrPriv(master); +} +else { +master = pScreen; +mastersp = pScrPriv; +} + if (pScrPriv-changed) { UpdateCurrentTimeIf(); -if (pScrPriv-configChanged) { -pScrPriv-lastConfigTime = currentTime; -pScrPriv-configChanged = FALSE; +if (mastersp-configChanged) { +mastersp-lastConfigTime = currentTime; +mastersp-configChanged = FALSE; } pScrPriv-changed = FALSE; -WalkTree(pScreen, TellChanged, (pointer) pScreen); +mastersp-changed = FALSE; +WalkTree(master, TellChanged, (pointer) master); for (i = 0; i pScrPriv-numOutputs; i++) pScrPriv-outputs[i]-changed = FALSE; for (i = 0; i pScrPriv-numCrtcs; i++) pScrPriv-crtcs[i]-changed = FALSE; -if (pScrPriv-layoutChanged) { +if (mastersp-layoutChanged) { pScrPriv-layoutChanged = FALSE; -RRPointerScreenConfigured(pScreen); -RRSendConfigNotify(pScreen); +RRPointerScreenConfigured(master); +RRSendConfigNotify(master); } } } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 21/36] xf86: add initial scanout pixmap support
From: Dave Airlie airl...@redhat.com Add the simple passthrough interface for drivers to use, so they can set scanout pixmaps. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.h|5 + hw/xfree86/modes/xf86RandR12.c | 10 ++ 2 files changed, 15 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 58d8cec..25fb34d 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -218,6 +218,11 @@ typedef struct _xf86CrtcFuncs { void (*set_origin) (xf86CrtcPtr crtc, int x, int y); +/** + */ +Bool +(*set_scanout_pixmap)(xf86CrtcPtr crtc, PixmapPtr pixmap); + } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; #define XF86_CRTC_VERSION 4 diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 1eaef9d..ca3388a 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1789,6 +1789,15 @@ xf86RandR14ProviderGetProperty(ScreenPtr pScreen, } static Bool +xf86CrtcSetScanoutPixmap(RRCrtcPtr randr_crtc, PixmapPtr pixmap) +{ +xf86CrtcPtr crtc = randr_crtc-devPrivate; +if (!crtc-funcs-set_scanout_pixmap) +return FALSE; +return crtc-funcs-set_scanout_pixmap(crtc, pixmap); +} + +static Bool xf86RandR12Init12(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); @@ -1813,6 +1822,7 @@ xf86RandR12Init12(ScreenPtr pScreen) rp-rrProviderSetProperty = xf86RandR14ProviderSetProperty; rp-rrProviderGetProperty = xf86RandR14ProviderGetProperty; +rp-rrCrtcSetScanoutPixmap = xf86CrtcSetScanoutPixmap; pScrn-PointerMoved = xf86RandR12PointerMoved; pScrn-ChangeGamma = xf86RandR12ChangeGamma; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 24/36] randr: check the screen size bounds against the master
From: Dave Airlie airl...@redhat.com The master contains the complete screen size bounds, so check the width/height against it. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrcrtc.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index e5fe059..949ae60 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1125,6 +1125,16 @@ ProcRRSetCrtcConfig(ClientPtr client) int source_height; PictTransform transform; struct pixman_f_transform f_transform, f_inverse; +int width, height; + +if (pScreen-isGPU) { +width = pScreen-current_master-width; +height = pScreen-current_master-height; +} +else { +width = pScreen-width; +height = pScreen-height; +} RRTransformCompute(stuff-x, stuff-y, mode-mode.width, mode-mode.height, @@ -1134,13 +1144,13 @@ ProcRRSetCrtcConfig(ClientPtr client) RRModeGetScanoutSize(mode, transform, source_width, source_height); -if (stuff-x + source_width pScreen-width) { +if (stuff-x + source_width width) { client-errorValue = stuff-x; free(outputs); return BadValue; } -if (stuff-y + source_height pScreen-height) { +if (stuff-y + source_height height) { client-errorValue = stuff-y; free(outputs); return BadValue; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 25/36] dix/pixmap: track dirty pixmaps in server. (v3)
From: Dave Airlie airl...@redhat.com This adds two functions for drivers to use directly to keep a linked list of slave pixmaps to do damage tracking on and keep updated. It also adds a helper function that drivers may optionally call to do a simple copy area damage update. v2: use damage.h not damagestr.h, fixes ephyr build. v3: address ajax review: use slave_dst, drop unused dst member. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c |1 + dix/pixmap.c | 105 ++ include/pixmap.h | 16 include/pixmapstr.h |8 include/scrnintstr.h |2 + 5 files changed, 125 insertions(+), 7 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 2eb13db..78afe91 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3742,6 +3742,7 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) pScreen-ClipNotify = 0;/* for R4 ddx compatibility */ pScreen-CreateScreenResources = 0; +xorg_list_init(pScreen-pixmap_dirty_list); xorg_list_init(pScreen-unattached_list); xorg_list_init(pScreen-output_slave_list); diff --git a/dix/pixmap.c b/dix/pixmap.c index 7272098..01e1635 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -140,21 +140,112 @@ PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave) ret = master-SharePixmapBacking(pixmap, slave, handle); if (ret == FALSE) - return NULL; - +return NULL; + spix = slave-CreatePixmap(slave, 0, 0, depth, - CREATE_PIXMAP_USAGE_SHARED); + CREATE_PIXMAP_USAGE_SHARED); slave-ModifyPixmapHeader(spix, pixmap-drawable.width, - pixmap-drawable.height, depth, 0, - pixmap-devKind, NULL); + pixmap-drawable.height, depth, 0, + pixmap-devKind, NULL); spix-master_pixmap = pixmap; ret = slave-SetSharedPixmapBacking(spix, handle); if (ret == FALSE) { - slave-DestroyPixmap(spix); - return NULL; +slave-DestroyPixmap(spix); +return NULL; } return spix; } + +Bool +PixmapStartDirtyTracking(PixmapPtr src, + PixmapPtr slave_dst, + int x, int y) +{ +ScreenPtr screen = src-drawable.pScreen; +PixmapDirtyUpdatePtr dirty_update; + +dirty_update = calloc(1, sizeof(PixmapDirtyUpdateRec)); +if (!dirty_update) +return FALSE; + +dirty_update-src = src; +dirty_update-slave_dst = slave_dst; +dirty_update-x = x; +dirty_update-y = y; + +dirty_update-damage = DamageCreate(NULL, NULL, +DamageReportNone, +TRUE, src-drawable.pScreen, +src-drawable.pScreen); +DamageRegister(src-drawable, dirty_update-damage); +xorg_list_add(dirty_update-ent, screen-pixmap_dirty_list); +return TRUE; +} + +Bool +PixmapStopDirtyTracking(PixmapPtr src, PixmapPtr slave_dst) +{ +ScreenPtr screen = src-drawable.pScreen; +PixmapDirtyUpdatePtr ent, safe; + +xorg_list_for_each_entry_safe(ent, safe, screen-pixmap_dirty_list, ent) { +if (ent-src == src ent-slave_dst == slave_dst) { +DamageUnregister(src-drawable, ent-damage); +DamageDestroy(ent-damage); +xorg_list_del(ent-ent); +free(ent); +} +} +return TRUE; +} + +Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region) +{ +ScreenPtr pScreen = dirty-src-drawable.pScreen; +int n; +BoxPtr b; +RegionPtr region = DamageRegion(dirty-damage); +GCPtr pGC; +PixmapPtr dst; +SourceValidateProcPtr SourceValidate; + +SourceValidate = pScreen-SourceValidate; +pScreen-SourceValidate = NULL; + +RegionTranslate(dirty_region, dirty-x, dirty-y); +RegionIntersect(dirty_region, dirty_region, region); + +if (RegionNil(dirty_region)) { +RegionUninit(dirty_region); +return FALSE; +} + +dst = dirty-slave_dst-master_pixmap; + +RegionTranslate(dirty_region, -dirty-x, -dirty-y); +n = RegionNumRects(dirty_region); +b = RegionRects(dirty_region); + +pGC = GetScratchGC(dirty-src-drawable.depth, pScreen); +ValidateGC(dst-drawable, pGC); + +while (n--) { +BoxRec dst_box; +int w, h; + +dst_box = *b; +w = dst_box.x2 - dst_box.x1; +h = dst_box.y2 - dst_box.y1; + +pGC-ops-CopyArea(dirty-src-drawable, dst-drawable, pGC, + dirty-x + dst_box.x1, dirty-y + dst_box.y1, w, h, dst_box.x1, dst_box.y1); +b++; +} +FreeScratchGC(pGC); + +pScreen-SourceValidate = SourceValidate; +return TRUE; +} diff --git a/include/pixmap.h b/include/pixmap.h index 8c523bd..921a94d 100644 --- a/include/pixmap.h +++
[PATCH 26/36] xf86/crtc: add new interface to detach slave crtcs
From: Dave Airlie airl...@redhat.com This will detach any scanout pixmaps attached to slave crtcs. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c | 20 hw/xfree86/modes/xf86Crtc.h |3 +++ 2 files changed, 23 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index a8dc187..5057eac 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -3223,3 +3223,23 @@ xf86ProviderSetup(ScrnInfoPtr scrn, #endif } +void +xf86DetachAllCrtc(ScrnInfoPtr scrn) +{ +xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); +int i; + +for (i = 0; i xf86_config-num_crtc; i++) { +xf86CrtcPtr crtc = xf86_config-crtc[i]; + +if (crtc-randr_crtc) +RRCrtcDetachScanoutPixmap(crtc-randr_crtc); + +/* dpms off */ +(*crtc-funcs-dpms) (crtc, DPMSModeOff); +/* force a reset the next time its used */ +crtc-randr_crtc-mode = NULL; +crtc-mode.HDisplay = 0; +crtc-x = crtc-y = 0; +} +} diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 25fb34d..38b9ea5 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -1014,4 +1014,7 @@ extern _X_EXPORT void xf86ProviderSetup(ScrnInfoPtr scrn, const xf86ProviderFuncsRec * funcs, const char *name); +extern _X_EXPORT void +xf86DetachAllCrtc(ScrnInfoPtr scrn); + #endif /* _XF86CRTC_H_ */ -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 29/36] xf86: add output source setting callback
From: Dave Airlie airl...@redhat.com This adds support for the randr callback for setting the output source for a device. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c|6 +- hw/xfree86/modes/xf86RandR12.c | 35 +++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 5057eac..9e43c40 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -728,7 +728,11 @@ xf86CrtcCloseScreen(ScreenPtr screen) /* detach any providers */ if (config-randr_provider) { -DetachUnboundGPU(screen); +if (config-randr_provider-output_source) { +DetachOutputGPU(screen); +config-randr_provider-output_source = NULL; +} else +DetachUnboundGPU(screen); } for (o = 0; o config-num_output; o++) { xf86OutputPtr output = config-output[o]; diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index ca3388a..165e2b7 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1754,6 +1754,39 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn) } static Bool +xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr source_provider) +{ + + +if (!source_provider) { +if (provider-output_source) { +ScreenPtr cmScreen = pScreen-current_master; +SetRootClip(cmScreen, FALSE); + +DetachOutputGPU(pScreen); +AttachUnboundGPU(cmScreen, pScreen); +SetRootClip(cmScreen, TRUE); +} +provider-output_source = NULL; +return TRUE; +} + +if (provider-output_source == source_provider) +return TRUE; + +SetRootClip(source_provider-pScreen, TRUE); + +DetachUnboundGPU(pScreen); +AttachOutputGPU(source_provider-pScreen, pScreen); + +provider-output_source = source_provider; +SetRootClip(source_provider-pScreen, FALSE); +return TRUE; +} + +static Bool xf86RandR14ProviderSetProperty(ScreenPtr pScreen, RRProviderPtr randr_provider, Atom property, RRPropertyValuePtr value) @@ -1820,6 +1853,8 @@ xf86RandR12Init12(ScreenPtr pScreen) rp-rrModeDestroy = xf86RandR12ModeDestroy; rp-rrSetConfig = NULL; +rp-rrProviderSetOutputSource = xf86RandR14ProviderSetOutputSource; + rp-rrProviderSetProperty = xf86RandR14ProviderSetProperty; rp-rrProviderGetProperty = xf86RandR14ProviderGetProperty; rp-rrCrtcSetScanoutPixmap = xf86CrtcSetScanoutPixmap; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 27/36] randr: hook up output slave to screen resources return
From: Dave Airlie airl...@redhat.com When the client asks for the screen resources list, it will now get a list of crtc/outputs for the master + all attached slaves, this will let randr configure all attached slave devices properly. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrscreen.c | 169 ++ 1 file changed, 169 insertions(+) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index c564d1f..9bf9316 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -292,6 +292,172 @@ ProcRRSetScreenSize(ClientPtr client) return Success; } + +#define update_totals(gpuscreen, pScrPriv) do { \ +total_crtcs += pScrPriv-numCrtcs;\ +total_outputs += pScrPriv-numOutputs;\ +modes = RRModesForScreen(gpuscreen, num_modes); \ +if (!modes) \ +return BadAlloc; \ +for (j = 0; j num_modes; j++) \ +total_name_len += modes[j]-mode.nameLength; \ +total_modes += num_modes; \ +free(modes); \ +} while(0) + +static inline void swap_modeinfos(xRRModeInfo *modeinfos, int i) +{ +swapl(modeinfos[i].id); +swaps(modeinfos[i].width); +swaps(modeinfos[i].height); +swapl(modeinfos[i].dotClock); +swaps(modeinfos[i].hSyncStart); +swaps(modeinfos[i].hSyncEnd); +swaps(modeinfos[i].hTotal); +swaps(modeinfos[i].hSkew); +swaps(modeinfos[i].vSyncStart); +swaps(modeinfos[i].vSyncEnd); +swaps(modeinfos[i].vTotal); +swaps(modeinfos[i].nameLength); +swapl(modeinfos[i].modeFlags); +} + +#define update_arrays(gpuscreen, pScrPriv) do {\ +for (j = 0; j pScrPriv-numCrtcs; j++) { \ +crtcs[crtc_count] = pScrPriv-crtcs[j]-id;\ +if (client-swapped) \ +swapl(crtcs[crtc_count]); \ +crtc_count++; \ +} \ +for (j = 0; j pScrPriv-numOutputs; j++) { \ +outputs[output_count] = pScrPriv-outputs[j]-id; \ +if (client-swapped) \ +swapl(outputs[output_count]); \ +output_count++;\ +} \ +{ \ +RRModePtr mode;\ +modes = RRModesForScreen(gpuscreen, num_modes); \ +for (j = 0; j num_modes; j++) { \ +mode = modes[j]; \ +modeinfos[mode_count] = mode-mode;\ +if (client-swapped) { \ +swap_modeinfos(modeinfos, mode_count); \ +} \ +memcpy(names, mode-name, mode-mode.nameLength); \ +names += mode-mode.nameLength;\ +mode_count++; \ +} \ +free(modes); \ +} \ +} while (0) + +static int +rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen) +{ +int j; +int total_crtcs, total_outputs, total_modes, total_name_len; +int crtc_count, output_count, mode_count; +ScreenPtr iter; +rrScrPrivPtr pScrPriv; +int num_modes; +RRModePtr *modes; +xRRGetScreenResourcesReply rep; +unsigned long extraLen; +CARD8 *extra; +RRCrtc *crtcs; +RROutput *outputs; +xRRModeInfo *modeinfos; +CARD8 *names; + +/* we need to iterate all the GPU masters and all their output slaves */ +total_crtcs = 0; +total_outputs = 0; +total_modes = 0; +total_name_len = 0; + +pScrPriv = rrGetScrPriv(pScreen); + +if (query pScrPriv) +if (!RRGetInfo(pScreen, query)) +return BadAlloc; + +update_totals(pScreen, pScrPriv); + +xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { +pScrPriv = rrGetScrPriv(iter); + +if (query) + if (!RRGetInfo(iter, query)) +return BadAlloc; +update_totals(iter, pScrPriv); +} + +ErrorF(reporting %d %d %d %d\n, total_crtcs, total_outputs, total_modes, total_name_len); + +pScrPriv = rrGetScrPriv(pScreen); +rep.pad = 0; +rep.type = X_Reply; +rep.sequenceNumber = client-sequence; +rep.length = 0; +rep.timestamp = pScrPriv-lastSetTime.milliseconds; +rep.configTimestamp = pScrPriv-lastConfigTime.milliseconds; +rep.nCrtcs = total_crtcs; +rep.nOutputs = total_outputs; +rep.nModes =
[PATCH 28/36] randr: add output source setup
From: Dave Airlie airl...@redhat.com This adds the output sources to the associated list and adds the protocol handler for the randr SetProviderOutputSource. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/randrstr.h |8 randr/rrdispatch.c |2 +- randr/rrprovider.c | 58 +++- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/randr/randrstr.h b/randr/randrstr.h index 4ed581d..d7b0804 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -165,6 +165,7 @@ struct _rrProvider { int nameLength; RRPropertyPtr properties; Bool pendingProperties; +struct _rrProvider *output_source; }; #if RANDR_12_INTERFACE @@ -226,6 +227,10 @@ typedef Bool (*RRProviderSetPropertyProcPtr) (ScreenPtr pScreen, typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations); typedef Bool (*RRCloseScreenProcPtr) (ScreenPtr pscreen); +typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr output_source); + /* These are for 1.0 compatibility */ typedef struct _rrRefresh { @@ -277,6 +282,7 @@ typedef struct _rrScrPriv { /* TODO #if RANDR_15_INTERFACE */ RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; +RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource; RRProviderGetPropertyProcPtr rrProviderGetProperty; RRProviderSetPropertyProcPtr rrProviderSetProperty; /* @@ -884,6 +890,8 @@ ProcRRGetProviders(ClientPtr client); extern _X_EXPORT int ProcRRGetProviderInfo(ClientPtr client); +extern _X_EXPORT int +ProcRRSetProviderOutputSource(ClientPtr client); extern _X_EXPORT Bool RRProviderInit(void); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 054e47a..6fe51c7 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -246,7 +246,7 @@ int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = { ProcRRGetProviders, /* 32 */ ProcRRGetProviderInfo, /* 33 */ NULL, /* 34 */ -NULL, /* 35 */ +ProcRRSetProviderOutputSource, /* 35 */ ProcRRListProviderProperties,/* 36 */ ProcRRQueryProviderProperty, /* 37 */ ProcRRConfigureProviderProperty, /* 38 */ diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 33cb77d..9237860 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -137,7 +137,7 @@ ProcRRGetProviderInfo (ClientPtr client) { REQUEST(xRRGetProviderInfoReq); xRRGetProviderInfoReply rep; -rrScrPrivPtr pScrPriv; +rrScrPrivPtr pScrPriv, pScrProvPriv; RRProviderPtr provider; ScreenPtr pScreen; CARD8 *extra; @@ -168,6 +168,10 @@ ProcRRGetProviderInfo (ClientPtr client) /* count associated providers */ rep.nAssociatedProviders = 0; +if (provider-output_source) +rep.nAssociatedProviders++; +xorg_list_for_each_entry(provscreen, pScreen-output_slave_list, output_head) +rep.nAssociatedProviders++; rep.length = (pScrPriv-numCrtcs + pScrPriv-numOutputs + (rep.nAssociatedProviders * 2) + bytes_to_int32(rep.nameLength)); @@ -198,6 +202,26 @@ ProcRRGetProviderInfo (ClientPtr client) swapl(outputs[i]); } +i = 0; +if (provider-output_source) { +providers[i] = provider-output_source-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SourceOutput; +swapl(prov_cap[i]); +i++; +} +xorg_list_for_each_entry(provscreen, pScreen-output_slave_list, output_head) { +pScrProvPriv = rrGetScrPriv(provscreen); +providers[i] = pScrProvPriv-provider-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SinkOutput; +if (client-swapped) +swapl(prov_cap[i]); +i++; +} + memcpy(name, provider-name, rep.nameLength); if (client-swapped) { swaps(rep.sequenceNumber); @@ -216,6 +240,38 @@ ProcRRGetProviderInfo (ClientPtr client) return Success; } +int +ProcRRSetProviderOutputSource(ClientPtr client) +{ +REQUEST(xRRSetProviderOutputSourceReq); +rrScrPrivPtr pScrPriv; +RRProviderPtr provider, source_provider = NULL; +ScreenPtr pScreen; + +REQUEST_AT_LEAST_SIZE(xRRSetProviderOutputSourceReq); + +VERIFY_RR_PROVIDER(stuff-provider, provider, DixReadAccess); + +if (!(provider-capabilities RR_Capability_SinkOutput)) +return BadValue; + +if (stuff-source_provider) { +VERIFY_RR_PROVIDER(stuff-source_provider, source_provider, DixReadAccess); + +if (!(source_provider-capabilities RR_Capability_SourceOutput)) +return BadValue; +} + +pScreen = provider-pScreen; +pScrPriv = rrGetScrPriv(pScreen); + +pScrPriv-rrProviderSetOutputSource(pScreen, provider,
[PATCH 30/36] xf86/cursor: fallback to sw cursor if we have slaves present.
From: Dave Airlie airl...@redhat.com Current USB devices have no hw rendered cursors, so we need the master GPU to render the cursor, so whenever we plug in a slave device, fallback to sw rendered cursors. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/ramdac/xf86Cursor.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 8b91e05..8d48a75 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -336,7 +336,7 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, if (!infoPtr-pScrn-vtSema) ScreenPriv-SavedCursor = pCurs; -if (infoPtr-pScrn-vtSema +if (infoPtr-pScrn-vtSema xorg_list_is_empty(pScreen-pixmap_dirty_list) (ScreenPriv-ForceHWCursorCount || (( #ifdef ARGB_CURSOR -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 31/36] dix/xf86: initial offload slave tracking (v1.1)
From: Dave Airlie airl...@redhat.com add the linked list and provider hooks. v1.1: add another assert in the add path. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 19 +++ include/screenint.h |6 ++ include/scrnintstr.h |3 +++ randr/rrprovider.c |7 +++ 4 files changed, 35 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index 78afe91..c66341a 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3745,6 +3745,7 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) xorg_list_init(pScreen-pixmap_dirty_list); xorg_list_init(pScreen-unattached_list); xorg_list_init(pScreen-output_slave_list); +xorg_list_init(pScreen-offload_slave_list); /* * This loop gets run once for every Screen that gets added, @@ -3930,3 +3931,21 @@ DetachOutputGPU(ScreenPtr slave) xorg_list_del(slave-output_head); slave-current_master = NULL; } + +void +AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new) +{ +assert(new-isGPU); +assert(!new-current_master); +xorg_list_add(new-offload_head, pScreen-offload_slave_list); +new-current_master = pScreen; +} + +void +DetachOffloadGPU(ScreenPtr slave) +{ +assert(slave-isGPU); +xorg_list_del(slave-offload_head); +slave-current_master = NULL; +} + diff --git a/include/screenint.h b/include/screenint.h index b992cc2..e36b4d8 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -82,6 +82,12 @@ AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new); extern _X_EXPORT void DetachOutputGPU(ScreenPtr output); +extern _X_EXPORT void +AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new); + +extern _X_EXPORT void +DetachOffloadGPU(ScreenPtr slave); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 5ef37ed..80601b9 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -507,6 +507,9 @@ typedef struct _Screen { StopPixmapTrackingProcPtr StopPixmapTracking; struct xorg_list pixmap_dirty_list; +struct xorg_list offload_slave_list; +struct xorg_list offload_head; + } ScreenRec; static inline RegionPtr diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 9237860..bf53d8b 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -76,6 +76,10 @@ ProcRRGetProviders (ClientPtr client) pScrPriv = rrGetScrPriv(iter); total_providers += pScrPriv-provider ? 1 : 0; } +xorg_list_for_each_entry(iter, pScreen-offload_slave_list, offload_head) { +pScrPriv = rrGetScrPriv(iter); +total_providers += pScrPriv-provider ? 1 : 0; +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { pScrPriv = rrGetScrPriv(iter); total_providers += pScrPriv-provider ? 1 : 0; @@ -112,6 +116,9 @@ ProcRRGetProviders (ClientPtr client) xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { ADD_PROVIDER(iter); } +xorg_list_for_each_entry(iter, pScreen-offload_slave_list, offload_head) { +ADD_PROVIDER(iter); +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { ADD_PROVIDER(iter); } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 22/36] randr: fixup constrain to work with slave screens.
From: Dave Airlie airl...@redhat.com Current code constrains the cursor to the crtcs on the master device, for slave outputs to work we have to include their crtcs in the constrain calculations. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrcrtc.c | 57 +--- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 29b02a9..e5fe059 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1544,18 +1544,10 @@ ProcRRGetCrtcTransform(ClientPtr client) return Success; } -void -RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, -int *y) +static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y) { rrScrPriv(pScreen); int i; - -/* intentional dead space - let it float */ -if (pScrPriv-discontiguous) -return; - -/* if we're moving inside a crtc, we're fine */ for (i = 0; i pScrPriv-numCrtcs; i++) { RRCrtcPtr crtc = pScrPriv-crtcs[i]; @@ -1567,8 +1559,15 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, crtc_bounds(crtc, left, right, top, bottom); if ((*x = left) (*x right) (*y = top) (*y bottom)) -return; +return TRUE; } +return FALSE; +} + +static Bool constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y) +{ +rrScrPriv(pScreen); +int i; /* if we're trying to escape, clamp to the CRTC we're coming from */ for (i = 0; i pScrPriv-numCrtcs; i++) { @@ -1592,7 +1591,43 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, if (*y = bottom) *y = bottom - 1; -return; +return TRUE; } } +return FALSE; +} + +void +RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, +int *y) +{ +rrScrPriv(pScreen); +Bool ret; +ScreenPtr slave; + +/* intentional dead space - let it float */ +if (pScrPriv-discontiguous) +return; + +/* if we're moving inside a crtc, we're fine */ +ret = check_all_screen_crtcs(pScreen, x, y); +if (ret == TRUE) +return; + +xorg_list_for_each_entry(slave, pScreen-output_slave_list, output_head) { +ret = check_all_screen_crtcs(slave, x, y); +if (ret == TRUE) +return; +} + +/* if we're trying to escape, clamp to the CRTC we're coming from */ +ret = constrain_all_screen_crtcs(pDev, pScreen, x, y); +if (ret == TRUE) +return; + +xorg_list_for_each_entry(slave, pScreen-output_slave_list, output_head) { +ret = constrain_all_screen_crtcs(pDev, slave, x, y); +if (ret == TRUE) +return; +} } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 33/36] xf86: store scanout pixmap in the xf86 struct as well.
From: Dave Airlie airl...@redhat.com This is so we can tell the scanout pixmap has changed between calls to the crtc set function. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.h|6 +- hw/xfree86/modes/xf86RandR12.c |4 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 38b9ea5..802303f 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -225,7 +225,7 @@ typedef struct _xf86CrtcFuncs { } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; -#define XF86_CRTC_VERSION 4 +#define XF86_CRTC_VERSION 5 struct _xf86Crtc { /** @@ -376,6 +376,10 @@ struct _xf86Crtc { * Added in ABI version 4 */ Bool driverIsPerformingTransform; + +/* Added in ABI version 5 + */ +PixmapPtr current_scanout; }; typedef struct _xf86OutputFuncs { diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 165e2b7..309f933 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1157,6 +1157,9 @@ xf86RandR12CrtcSet(ScreenPtr pScreen, if (rotation != crtc-rotation) changed = TRUE; +if (crtc-current_scanout != randr_crtc-scanout_pixmap) +changed = TRUE; + transform = RRCrtcGetTransform(randr_crtc); if ((transform != NULL) != crtc-transformPresent) changed = TRUE; @@ -1218,6 +1221,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen, */ crtc-desiredMode = mode; crtc-desiredRotation = rotation; +crtc-current_scanout = randr_crtc-scanout_pixmap; if (transform) { crtc-desiredTransform = *transform; crtc-desiredTransformPresent = TRUE; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 34/36] xf86: add callback for offloak sink setting support.
From: Dave Airlie airl...@redhat.com This adds support for setting the offload sink to the xf86 ddx. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c|5 - hw/xfree86/modes/xf86RandR12.c | 27 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 9e43c40..e5f58e7 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -728,7 +728,10 @@ xf86CrtcCloseScreen(ScreenPtr screen) /* detach any providers */ if (config-randr_provider) { -if (config-randr_provider-output_source) { +if (config-randr_provider-offload_sink) { +DetachOffloadGPU(screen); +config-randr_provider-offload_sink = NULL; +} else if (config-randr_provider-output_source) { DetachOutputGPU(screen); config-randr_provider-output_source = NULL; } else diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 309f933..12acdff 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1791,6 +1791,32 @@ xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen, } static Bool +xf86RandR14ProviderSetOffloadSink(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr sink_provider) +{ +if (!sink_provider) { +if (provider-offload_sink) { +ScreenPtr cmScreen = pScreen-current_master; +DetachOutputGPU(pScreen); +AttachUnboundGPU(cmScreen, pScreen); +} + +provider-offload_sink = NULL; +return TRUE; +} + +if (provider-offload_sink == sink_provider) +return TRUE; + +DetachUnboundGPU(pScreen); +AttachOffloadGPU(sink_provider-pScreen, pScreen); + +provider-offload_sink = sink_provider; +return TRUE; +} + +static Bool xf86RandR14ProviderSetProperty(ScreenPtr pScreen, RRProviderPtr randr_provider, Atom property, RRPropertyValuePtr value) @@ -1858,6 +1884,7 @@ xf86RandR12Init12(ScreenPtr pScreen) rp-rrSetConfig = NULL; rp-rrProviderSetOutputSource = xf86RandR14ProviderSetOutputSource; +rp-rrProviderSetOffloadSink = xf86RandR14ProviderSetOffloadSink; rp-rrProviderSetProperty = xf86RandR14ProviderSetProperty; rp-rrProviderGetProperty = xf86RandR14ProviderGetProperty; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 32/36] randr: add hooks for offload sink provider protocol
From: Dave Airlie airl...@redhat.com This adds the protocol handler and associated providers handling for the offload slaves, it allows two providers to be connected as offload sink/source. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/randrstr.h | 10 ++ randr/rrdispatch.c |2 +- randr/rrprovider.c | 54 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/randr/randrstr.h b/randr/randrstr.h index d7b0804..64c9afb 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -165,6 +165,7 @@ struct _rrProvider { int nameLength; RRPropertyPtr properties; Bool pendingProperties; +struct _rrProvider *offload_sink; struct _rrProvider *output_source; }; @@ -231,6 +232,11 @@ typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen, RRProviderPtr provider, RRProviderPtr output_source); +typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr offload_sink); + + /* These are for 1.0 compatibility */ typedef struct _rrRefresh { @@ -283,6 +289,7 @@ typedef struct _rrScrPriv { RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource; +RRProviderSetOffloadSinkProcPtr rrProviderSetOffloadSink; RRProviderGetPropertyProcPtr rrProviderGetProperty; RRProviderSetPropertyProcPtr rrProviderSetProperty; /* @@ -893,6 +900,9 @@ ProcRRGetProviderInfo(ClientPtr client); extern _X_EXPORT int ProcRRSetProviderOutputSource(ClientPtr client); +extern _X_EXPORT int +ProcRRSetProviderOffloadSink(ClientPtr client); + extern _X_EXPORT Bool RRProviderInit(void); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 6fe51c7..1942d74 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -245,7 +245,7 @@ int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = { /* V1.4 additions */ ProcRRGetProviders, /* 32 */ ProcRRGetProviderInfo, /* 33 */ -NULL, /* 34 */ +ProcRRSetProviderOffloadSink, /* 34 */ ProcRRSetProviderOutputSource, /* 35 */ ProcRRListProviderProperties,/* 36 */ ProcRRQueryProviderProperty, /* 37 */ diff --git a/randr/rrprovider.c b/randr/rrprovider.c index bf53d8b..cd353a0 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -175,10 +175,15 @@ ProcRRGetProviderInfo (ClientPtr client) /* count associated providers */ rep.nAssociatedProviders = 0; +if (provider-offload_sink) +rep.nAssociatedProviders++; if (provider-output_source) rep.nAssociatedProviders++; xorg_list_for_each_entry(provscreen, pScreen-output_slave_list, output_head) rep.nAssociatedProviders++; +xorg_list_for_each_entry(provscreen, pScreen-offload_slave_list, offload_head) +rep.nAssociatedProviders++; + rep.length = (pScrPriv-numCrtcs + pScrPriv-numOutputs + (rep.nAssociatedProviders * 2) + bytes_to_int32(rep.nameLength)); @@ -210,6 +215,15 @@ ProcRRGetProviderInfo (ClientPtr client) } i = 0; +if (provider-offload_sink) { +providers[i] = provider-offload_sink-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SinkOffload; +if (client-swapped) +swapl(prov_cap[i]); +i++; +} if (provider-output_source) { providers[i] = provider-output_source-id; if (client-swapped) @@ -228,6 +242,17 @@ ProcRRGetProviderInfo (ClientPtr client) swapl(prov_cap[i]); i++; } +xorg_list_for_each_entry(provscreen, pScreen-offload_slave_list, offload_head) { +pScrProvPriv = rrGetScrPriv(provscreen); +providers[i] = pScrProvPriv-provider-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SourceOffload; +if (client-swapped) +swapl(prov_cap[i]); +i++; +} + memcpy(name, provider-name, rep.nameLength); if (client-swapped) { @@ -279,6 +304,35 @@ ProcRRSetProviderOutputSource(ClientPtr client) return Success; } +int +ProcRRSetProviderOffloadSink(ClientPtr client) +{ +REQUEST(xRRSetProviderOffloadSinkReq); +rrScrPrivPtr pScrPriv; +RRProviderPtr provider, sink_provider = NULL; +ScreenPtr pScreen; + +REQUEST_AT_LEAST_SIZE(xRRSetProviderOffloadSinkReq); + +VERIFY_RR_PROVIDER(stuff-provider, provider, DixReadAccess); +if (!(provider-capabilities RR_Capability_SourceOffload)) +return BadValue; + +if (stuff-sink_provider) { +VERIFY_RR_PROVIDER(stuff-sink_provider, sink_provider, DixReadAccess); +if (!(sink_provider-capabilities
[PATCH 36/36] dri2: add initial prime support. (v1.2)
From: Dave Airlie airl...@redhat.com This adds the initial prime support for dri2 offload. The main thing is when we get a connection from a prime client, we stored the information and mark all drawables from that client as prime. We then create all buffers for that drawable on the prime device dri2screen. Then DRI2UpdatePrime is provided which drivers can call to get a shared pixmap which they can use as the front buffer. The driver is then responsible for doing the back-front copy to the shared buffer. prime requires a compositing manager be run, but it handles the case where a window get un-redirected by allocating a new pixmap and pointing the crtc at it while the client is in that state. Currently prime can't handle pageflipping, so always does straight copy swap, v1.1: renumber on top of master. v1.2: fix auth on top of master. Signed-off-by: Dave Airlie airl...@redhat.com --- glx/glxdri2.c |2 +- hw/xfree86/dri2/dri2.c| 265 + hw/xfree86/dri2/dri2.h| 25 - hw/xfree86/dri2/dri2ext.c |4 +- 4 files changed, 267 insertions(+), 29 deletions(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 7b76c3a..984f115 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -840,7 +840,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen) return NULL; if (!xf86LoaderCheckSymbol(DRI2Connect) || -!DRI2Connect(pScreen, DRI2DriverDRI, +!DRI2Connect(serverClient, pScreen, DRI2DriverDRI, screen-fd, driverName, deviceName)) { LogMessage(X_INFO, AIGLX: Screen %d is not DRI2 capable\n, pScreen-myNum); diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index d3b3c73..87158ff 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -45,7 +45,7 @@ #include dixstruct.h #include dri2.h #include xf86VGAarbiter.h - +#include damage.h #include xf86.h CARD8 dri2_major; /* version of DRI2 supported by DDX */ @@ -63,6 +63,17 @@ static DevPrivateKeyRec dri2PixmapPrivateKeyRec; #define dri2PixmapPrivateKey (dri2PixmapPrivateKeyRec) +static DevPrivateKeyRec dri2ClientPrivateKeyRec; + +#define dri2ClientPrivateKey (dri2ClientPrivateKeyRec) + +#define dri2ClientPrivate(_pClient) (dixLookupPrivate((_pClient)-devPrivates, \ + dri2ClientPrivateKey)) + +typedef struct _DRI2Client { +int prime_id; +} DRI2ClientRec, *DRI2ClientPtr; + static RESTYPE dri2DrawableRes; typedef struct _DRI2Screen *DRI2ScreenPtr; @@ -87,6 +98,9 @@ typedef struct _DRI2Drawable { int swap_limit; /* for N-buffering */ unsigned long serialNumber; Bool needInvalidate; +int prime_id; +PixmapPtr prime_slave_pixmap; +PixmapPtr redirectpixmap; } DRI2DrawableRec, *DRI2DrawablePtr; typedef struct _DRI2Screen { @@ -113,14 +127,47 @@ typedef struct _DRI2Screen { HandleExposuresProcPtr HandleExposures; ConfigNotifyProcPtr ConfigNotify; +DRI2CreateBuffer2ProcPtr CreateBuffer2; +DRI2DestroyBuffer2ProcPtr DestroyBuffer2; +DRI2CopyRegion2ProcPtr CopyRegion2; } DRI2ScreenRec; +static void +destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, int prime_id); + static DRI2ScreenPtr DRI2GetScreen(ScreenPtr pScreen) { return dixLookupPrivate(pScreen-devPrivates, dri2ScreenPrivateKey); } +static ScreenPtr +GetScreenPrime(ScreenPtr master, int prime_id) +{ +ScreenPtr slave; +int i; + +if (prime_id == 0 || xorg_list_is_empty(master-offload_slave_list)) { +return master; +} +i = 0; +xorg_list_for_each_entry(slave, master-offload_slave_list, offload_head) { +if (i == (prime_id - 1)) +break; +i++; +} +if (!slave) +return master; +return slave; +} + +static DRI2ScreenPtr +DRI2GetScreenPrime(ScreenPtr master, int prime_id) +{ +ScreenPtr slave = GetScreenPrime(master, prime_id); +return DRI2GetScreen(slave); +} + static DRI2DrawablePtr DRI2GetDrawable(DrawablePtr pDraw) { @@ -187,7 +234,8 @@ DRI2AllocateDrawable(DrawablePtr pDraw) xorg_list_init(pPriv-reference_list); pPriv-serialNumber = DRI2DrawableSerial(pDraw); pPriv-needInvalidate = FALSE; - +pPriv-redirectpixmap = NULL; +pPriv-prime_slave_pixmap = NULL; if (pDraw-type == DRAWABLE_WINDOW) { pWin = (WindowPtr) pDraw; dixSetPrivate(pWin-devPrivates, dri2WindowPrivateKey, pPriv); @@ -286,6 +334,7 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id, DRI2InvalidateProcPtr invalidate, void *priv) { DRI2DrawablePtr pPriv; +DRI2ClientPtr dri2_client = dri2ClientPrivate(client); XID dri2_id; int rc; @@ -295,6 +344,8 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id, if (pPriv == NULL) return BadAlloc; +pPriv-prime_id = dri2_client-prime_id; + dri2_id = FakeClientID(client-index);
Re: [v2] [PATCH 1/1] XSELinux: When SELinux is enabled the xserver seg faults
Ok - I'll send an updated XSELinux patch [V3] as that will fix the crash plus a separate patch for the dix grab. I don't know the code that well but there are probably other places that may need checking. Richard --- On Thu, 5/7/12, Peter Hutterer peter.hutte...@who-t.net wrote: thanks for the update. The second part I'm not quite happy yet, I think it's the wrong approach. With passive grabs on XIAll(Master)Devices, the grab will activate on whichever device matches the grab. So if you issue such a grab and device 2 clicks, you'll get a grab on device 2. If device 3 clicks, you get a grab on device 3. For the SELinux case where some devices may not be permitted I think we should leave open the possibility that _some_ device in the future may be permitted. This means always return success from a XIAll*Devices passive grab request but then check for permissions when the grab actually activates. So the example above, if device 2 is restricted you'll be able to register a passive grab but it won't trigger for device 2, only for device 3. This needs some extra code in the dix, CheckPassiveGrab to be precise to return false for restricted devices. Cheers, Â Peter ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[V3] [PATCH 1/1] XSELinux: When SELinux is enabled the xserver seg faults
This patch was created using xorg-server-1.12.2 source. When using Fedora 17 with xorg-server-1.12.2 and SELinux is enabled ('setsebool xserver_object_manager on') the xserver will not load. The Xlog file has a seg fault pointing to XACE/SELinux. Bug 50641 was raised (https://bugs.freedesktop.org/show_bug.cgi?id=50641). The bug is caused by X calling XaceHook(XACE_DEVICE_ACCESS, client, ...) with a device ID of '1' that is XIAllMasterDevices. It would also happen if the device ID = 0 (XIAllDevices). The fix is to return if device is XIAll*Devices and let the permission be determined when a real device ID is presented. Signed-off-by: Richard Haines richard_c_hai...@btinternet.com --- Xext/xselinux_hooks.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Xext/xselinux_hooks.c b/Xext/xselinux_hooks.c index e9c7e93..82d3892 100644 --- a/Xext/xselinux_hooks.c +++ b/Xext/xselinux_hooks.c @@ -336,7 +336,15 @@ SELinuxDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata) int rc; subj = dixLookupPrivate(rec-client-devPrivates, subjectKey); -obj = dixLookupPrivate(rec-dev-devPrivates, objectKey); +/* + * The XIAllMasterDevices or XIAllDevices do not have devPrivates + * entries. If they are requested we just return as each device access + * will be checked individually. + */ +if (rec-dev-id != XIAllDevices rec-dev-id != XIAllMasterDevices) +obj = dixLookupPrivate(rec-dev-devPrivates, objectKey); +else +return; /* If this is a new object that needs labeling, do it now */ if (rec-access_mode DixCreateAccess) { -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 1/1] dix: Check whether grab allowed by security provider
This patch was created using xorg-server-1.12.2 source. Call XACE to verify if grab access is allowed. Signed-off-by: Richard Haines richard_c_hai...@btinternet.com --- dix/events.c |6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dix/events.c b/dix/events.c index 86336fe..0ce2140 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3807,7 +3807,11 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event, return FALSE; } -return TRUE; +/* Finally check whether grab allowed by security provider */ +if (XaceHook(XACE_DEVICE_ACCESS, rClient(grab), device, DixGrabAccess) == 0) +return TRUE; +else +return FALSE; } /** -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH] list.h: don't crash when removing an element from a NULL list
Peter Hutterer peter.hutte...@who-t.net writes: no, but the selinux fix will need it (partially out of laziness, partially to make the code nicer). Ok. I'll merged it in then. (the more I see of these twisty list macros, the more I prefer open-coded lists though; wow this is hard to understand). given how often we've found bugs in open-coded lists I disagree. yes, they're hairy but they're tested, the macro behaves the same everywhere. and if you really worry about the code being wrong, run it through the pre-processor and it will look like an open-coded list. It's all a tradeoff -- I just don't like having to learn a new programming language each time I see a new set of list macros (or other macro programming of this nature). Reminds me of how loathsome C++ templates are. -- keith.pack...@intel.com pgpMw7u14z701.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 1/9] glx: Don't request prototypes for GL extension functions
Ian Romanick i...@freedesktop.org writes: From: Ian Romanick ian.d.roman...@intel.com The server does not want GL extension prototypes. It never links with anything that could possibly provide implementations of these functions. It *is* the provide, and it does not provde these symbols. All this does is create hundreds of warnings like: I like this one -- eliminates 9665 lines of warnings from the compiler when building in the glx directory and other wise appears to have no effect on the server. Acked-by: Keith Packard kei...@keithp.com And Merged 258abbf..8aa6d49 master - master -- keith.pack...@intel.com pgpRgp8ukpl8K.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH] list.h: don't crash when removing an element from a NULL list
Peter Hutterer peter.hutte...@who-t.net writes: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- Keith, please merge this directly if you're happy with it. Merged. 8aa6d49..1679932 master - master -- keith.pack...@intel.com pgpEneA48ChhX.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH] dri2: add initial prime support. (v1.2)
On 03.07.2012, at 20:47, Dave Airlie wrote: On Tue, Jul 3, 2012 at 7:39 PM, Mario Kleiner mario.klei...@tuebingen.mpg.de wrote: On 03.07.2012, at 16:22, Dave Airlie wrote: From: Dave Airlie airl...@redhat.com This adds the initial prime support for dri2 offload. The main thing is when we get a connection from a prime client, we stored the information and mark all drawables from that client as prime. We then create all buffers for that drawable on the prime device dri2screen. ... +DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest) +{ +DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw); +PixmapPtr spix; +PixmapPtr mpix = GetDrawablePixmap(pDraw); +ScreenPtr master, slave; +Bool ret; + +master = mpix-drawable.pScreen; + +if (pDraw-type == DRAWABLE_WINDOW) { + WindowPtr pWin = (WindowPtr)pDraw; + PixmapPtr pPixmap = pDraw-pScreen-GetWindowPixmap(pWin); + + if (pDraw-pScreen-GetScreenPixmap(pDraw-pScreen) == pPixmap) { + if (pPriv-redirectpixmap + pPriv-redirectpixmap-drawable.width == pDraw-width + pPriv-redirectpixmap-drawable.height == pDraw-height + pPriv-redirectpixmap-drawable.depth == pDraw-depth) { + mpix = pPriv-redirectpixmap; + } else { +if (master-ReplaceScanoutPixmap) { +mpix = (*master-CreatePixmap)(master, pDraw-width, pDraw-height, + pDraw-depth, CREATE_PIXMAP_USAGE_SHARED); +if (!mpix) +return NULL; + +ret = (*master-ReplaceScanoutPixmap)(pDraw, mpix, TRUE); +if (ret == FALSE) { +(*master-DestroyPixmap)(mpix); +return NULL; +} The following bit ok? I probably just don't understand the code well enough, but is a ... if (pPriv-redirectpixmap) (*master-DestroyPixmap)(pPriv-redirectpixmap); … missing here before the assignment of the new mpix? +pPriv-redirectpixmap = mpix; +} else +return NULL; + } + } else if (pPriv-redirectpixmap) { +(*master-ReplaceScanoutPixmap)(pDraw, pPriv-redirectpixmap, FALSE); + (*master-DestroyPixmap)(pPriv-redirectpixmap); + pPriv-redirectpixmap = NULL; + } +} + … If you define a new CopyRegion2 hook, it would be good to now also pass along the pPriv- swap_interval parameter, or a bool vsync = pPriv-swap_interval ? true : false flag. That would allow the ddx CopyRegion2() to skip sync to vblank during copy if swap_interval is zero. Other OS'es and the NVidia/AMD binary blobs on Linux treat a zero swap interval as don't sync to retrace. DRI2SwapBuffers() currently skips all swap scheduling on zero swap interval and uses CopyRegion(), but CopyRegion doesn't know it is a zero swap interval/no-vsync swap, so it syncs anyway. All ddx'es have a SwapBuffersWait xorg.conf option to disable this behaviour, but i think that was added as a workaround, not really the amount of control that applications expect. I could do that but I really would prefer we do things in iterations and not confuse the interfaces, so add a CopyRegion3 with this sort of thing. Ok. Also Chris Wilson just posted an updated patch for an AsyncSwap hook, which would solve the same problem, depending on what gets in, in what order. The thing is I've not really considered timing because its really messy with two GPUs, current offload design is offload GPU calls CopyRegion2 which uses the hw copy engine to copy from the VRAM to GTT, the GTT object is shared with the other GPU and is the backing for the redirected window pixmap. So when the first driver copies to the second, it causes damage on the backing pixmap which gets sent to compositor which copies from it. Doing sync and flipping is a lot messier, since you probably want to sync everything on the displaying GPU. Thanks for the explanation. Posting damage at the current place could also cause composition of partially copied frames, right? Just a question to see if i understand the damage tracking correctly. If so, how does a compositor in the redirected case know when the offload slave has finished its blit to the redirectPixmap? How does the offload slave sync to vblank of the masters crtc in the unredirected case when its pPriv-redirectpixmap is set as a crtc's scanout pixmap? Again sync to vblank is definitely part 2, we've been looking at inter-gpu semaphores (by we I mean mlankhorst), but I'd appreciate any input you can give since you know this stuff fairly well ;-). Not so sure how well i know this stuff, but i totally agreed to the definitely part 2 thing :). I'm happy if your current patches get in soonish. I think i will just shut up and wait
Re: [PATCH 0/9] GLX features and minor cleanups
Ian Romanick i...@freedesktop.org writes: Patches 1 through 5 have previously been posted. The only change to patch 1 is the commit message. I'm merging this stuff with Dave Airlie's R-b added (acked on IRC). We will need to have glproto released with a new version so that the X server build will check for the new defines; feel free to do that when you have a minute and send along the obvious patch to the X server. Merged with Reviewed-by: Dave Airlie added to the newer patches. 1679932..ed6daa1 master - master -- keith.pack...@intel.com pgpobEHTMQ4Jb.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Bug 45623: tested patch available (was:Extending the merge window until monday)
Could somebody consider committing the patch from https://bugs.freedesktop.org/show_bug.cgi?id=45623 to the xserver tree? I posted it a month ago the list, but got no reaction. See: http://lists.freedesktop.org/archives/xorg-devel/2012-June/031660.html And Jeremy Huddleston suggest in the bug, that I should keep bothering the devel list... Why I think, it should be committed: It fixes two bugs, that are obious, if you look for them. And the patch should be well tested, as it is already getting shipped by Gentoo in their xorg-server-1.12.2. ( http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/x11-base/xorg-server/files/xorg-server-1.12-xf86edidmodes-array-bounds.patch?view=log ) That version has been marked stable for amd64 and x86 since 24.6. and I can't find any relevant bugs in the Gentoo bugtracker. (Except that someone yet again hit the compile error with the unpatched 1.11 version: https://bugs.gentoo.org/show_bug.cgi?id=420127 ) Thanks for considering to apply my patch. Torsten ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 03/29] xfree86: add framework for provider support in ddx. (v3)
From: Dave Airlie airl...@redhat.com This adds the framework for DDX provider support. v2: as per keithp's suggestion remove the xf86 provider object and just store it in the toplevel object. v3: update for new protocol Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86str.h|1 + hw/xfree86/modes/xf86Crtc.c| 17 +++ hw/xfree86/modes/xf86Crtc.h| 34 + hw/xfree86/modes/xf86RandR12.c | 47 4 files changed, 99 insertions(+) diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 6bd6a62..0590262 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -814,6 +814,7 @@ typedef struct _ScrnInfoRec { funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; Bool is_gpu; +uint32_t capabilities; } ScrnInfoRec; typedef struct { diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 2c8878f..62de5a0 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -3202,3 +3202,20 @@ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn) return FALSE; } + +void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec *funcs, const char *name) +{ +xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + +assert(!xf86_config-name); +assert(name); + +xf86_config-name = strdup(name); +xf86_config-provider_funcs = funcs; +#ifdef RANDR_12_INTERFACE +xf86_config-randr_provider = NULL; +#endif +} + diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index a6a3c2e..58d8cec 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -607,6 +607,29 @@ struct _xf86Output { INT16 initialBorder[4]; }; +typedef struct _xf86ProviderFuncs { +/** + * Called to allow the provider a chance to create properties after the + * RandR objects have been created. + */ +void +(*create_resources) (ScrnInfoPtr scrn); + +/** + * Callback when an provider's property has changed. + */ +Bool +(*set_property) (ScrnInfoPtr scrn, + Atom property, RRPropertyValuePtr value); + +/** + * Callback to get an updated property value + */ +Bool +(*get_property) (ScrnInfoPtr provider, Atom property); + +} xf86ProviderFuncsRec, *xf86ProviderFuncsPtr; + typedef struct _xf86CrtcConfigFuncs { /** * Requests that the driver resize the screen. @@ -681,6 +704,13 @@ typedef struct _xf86CrtcConfig { /* callback when crtc configuration changes */ xf86_crtc_notify_proc_ptr xf86_crtc_notify; +char *name; +const xf86ProviderFuncsRec *provider_funcs; +#ifdef RANDR_12_INTERFACE +RRProviderPtr randr_provider; +#else +void *randr_provider; +#endif } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern _X_EXPORT int xf86CrtcConfigPrivateIndex; @@ -975,4 +1005,8 @@ extern _X_EXPORT void extern _X_EXPORT Bool xf86_crtc_supports_gamma(ScrnInfoPtr pScrn); +extern _X_EXPORT void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec * funcs, const char *name); + #endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 59b6f82..1eaef9d 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1552,6 +1552,14 @@ xf86RandR12CreateObjects12(ScreenPtr pScreen) output-funcs-create_resources(output); RRPostPendingProperties(output-randr_output); } + +if (config-name) { +config-randr_provider = RRProviderCreate(pScreen, config-name, + strlen(config-name), config); + +RRProviderSetCapabilities(config-randr_provider, pScrn-capabilities); +} + return TRUE; } @@ -1746,6 +1754,41 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn) } static Bool +xf86RandR14ProviderSetProperty(ScreenPtr pScreen, + RRProviderPtr randr_provider, + Atom property, RRPropertyValuePtr value) +{ +xf86CrtcConfigPtr config = randr_provider-devPrivate; +ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + +/* If we don't have any property handler, then we don't care what the + * user is setting properties to. + */ +if (config-provider_funcs-set_property == NULL) +return TRUE; + +/* + * This function gets called even when vtSema is FALSE, as + * drivers will need to remember the correct value to apply + * when the VT switch occurs + */ +return config-provider_funcs-set_property(pScrn, property, value); +} + +static Bool +xf86RandR14ProviderGetProperty(ScreenPtr pScreen, + RRProviderPtr randr_provider, Atom property) +{ +xf86CrtcConfigPtr config = randr_provider-devPrivate; +ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); +
[PATCH 01/29] configure: bump randrproto min requirements to 1.4.0
From: Dave Airlie airl...@redhat.com Needed to build latest randr stuff. Signed-off-by: Dave Airlie airl...@redhat.com --- configure.ac |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d1358a2..2442bac 100644 --- a/configure.ac +++ b/configure.ac @@ -787,7 +787,7 @@ APPLEWMPROTO=applewmproto = 1.4 dnl Required modules XPROTO=xproto = 7.0.22 -RANDRPROTO=randrproto = 1.2.99.3 +RANDRPROTO=randrproto = 1.4.0 RENDERPROTO=renderproto = 0.11 XEXTPROTO=xextproto = 7.1.99 INPUTPROTO=inputproto = 2.1.99.6 -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 06/29] randr: expose unattached providers to the clients.
From: Dave Airlie airl...@redhat.com This provides the unattached provider list to the clients. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrprovider.c |8 1 file changed, 8 insertions(+) diff --git a/randr/rrprovider.c b/randr/rrprovider.c index b787b94..0a801d4 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -59,6 +59,7 @@ ProcRRGetProviders (ClientPtr client) unsigned int extraLen; RRProvider *providers; int total_providers = 0, count_providers = 0; +ScreenPtr iter; REQUEST_SIZE_MATCH(xRRGetProvidersReq); rc = dixLookupWindow(pWin, stuff-window, client, DixGetAttrAccess); @@ -71,6 +72,10 @@ ProcRRGetProviders (ClientPtr client) if (pScrPriv-provider) total_providers++; +xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { +pScrPriv = rrGetScrPriv(iter); +total_providers += pScrPriv-provider ? 1 : 0; +} pScrPriv = rrGetScrPriv(pScreen); rep.pad = 0; @@ -100,6 +105,9 @@ ProcRRGetProviders (ClientPtr client) providers = (RRProvider *)extra; ADD_PROVIDER(pScreen); +xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { +ADD_PROVIDER(iter); +} } if (client-swapped) { -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 05/29] dix: attach unbound screens to protocol screen 0
From: Dave Airlie airl...@redhat.com This is the default attachment, unbound gpu screens get attached to the 0 protocol screen. detach on hotunplug. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86Init.c |3 +++ hw/xfree86/modes/xf86Crtc.c |4 2 files changed, 7 insertions(+) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index aa17a58..058d09f 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -920,6 +920,9 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) #endif } +for (i = 0; i xf86NumGPUScreens; i++) +AttachUnboundGPU(xf86Screens[0]-pScreen, xf86GPUScreens[i]-pScreen); + xf86VGAarbiterWrapFunctions(); OsReleaseSIGIO(); diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 62de5a0..a8dc187 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -726,6 +726,10 @@ xf86CrtcCloseScreen(ScreenPtr screen) xf86RotateCloseScreen(screen); +/* detach any providers */ +if (config-randr_provider) { +DetachUnboundGPU(screen); +} for (o = 0; o config-num_output; o++) { xf86OutputPtr output = config-output[o]; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 08/29] dix: add ability to link output slave gpus to the current gpu (v1.1)
From: Dave Airlie airl...@redhat.com Just add the interfaces to attach/detach output slaves, and a linked list to keep track of them. Hook up the randr providers list to include these slaves. v1.1: add another assert to the add path. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 17 + include/screenint.h |6 ++ include/scrnintstr.h |3 +++ randr/rrprovider.c |7 +++ 4 files changed, 33 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index 9e84621..29ac5a4 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3743,6 +3743,7 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) pScreen-CreateScreenResources = 0; xorg_list_init(pScreen-unattached_list); +xorg_list_init(pScreen-output_slave_list); /* * This loop gets run once for every Screen that gets added, @@ -3909,3 +3910,19 @@ DetachUnboundGPU(ScreenPtr slave) slave-current_master = NULL; } +void +AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new) +{ +assert(new-isGPU); +assert(!new-current_master); +xorg_list_add(new-output_head, pScreen-output_slave_list); +new-current_master = pScreen; +} + +void +DetachOutputGPU(ScreenPtr slave) +{ +assert(slave-isGPU); +xorg_list_del(slave-output_head); +slave-current_master = NULL; +} diff --git a/include/screenint.h b/include/screenint.h index c0c60ef..b992cc2 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -76,6 +76,12 @@ AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new); extern _X_EXPORT void DetachUnboundGPU(ScreenPtr unbound); +extern _X_EXPORT void +AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new); + +extern _X_EXPORT void +DetachOutputGPU(ScreenPtr output); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 6b738de..7efc5c3 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -485,6 +485,9 @@ typedef struct _Screen { ScreenPtr current_master; +struct xorg_list output_slave_list; +struct xorg_list output_head; + } ScreenRec; static inline RegionPtr diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 0a801d4..33cb77d 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -72,6 +72,10 @@ ProcRRGetProviders (ClientPtr client) if (pScrPriv-provider) total_providers++; +xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { +pScrPriv = rrGetScrPriv(iter); +total_providers += pScrPriv-provider ? 1 : 0; +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { pScrPriv = rrGetScrPriv(iter); total_providers += pScrPriv-provider ? 1 : 0; @@ -105,6 +109,9 @@ ProcRRGetProviders (ClientPtr client) providers = (RRProvider *)extra; ADD_PROVIDER(pScreen); +xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { +ADD_PROVIDER(iter); +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { ADD_PROVIDER(iter); } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 07/29] xf86dga: handle DGAAvailable for gpu screens. (v2)
From: Dave Airlie airl...@redhat.com v2: Split out DGAAvailable into two interfaces, one for calls from protocol decoding and one for internal usage, after discussion with ajax and keithp. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86DGA.c | 15 --- hw/xfree86/dixmods/extmod/dgaproc.h |1 + hw/xfree86/modes/xf86DiDGA.c|2 +- hw/xfree86/vgahw/vgaCmap.c |2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 6416372..61612c3 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -521,18 +521,27 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode) } Bool -DGAAvailable(int index) +DGAScreenAvailable(ScreenPtr pScreen) { if (!DGAScreenKeyRegistered) return FALSE; -if (DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) +if (DGA_GET_SCREEN_PRIV(pScreen)) return TRUE; - return FALSE; } Bool +DGAAvailable(int index) +{ +ScreenPtr pScreen; + +assert(index MAXSCREENS); +pScreen = screenInfo.screens[index]; +return DGAScreenAvailable(pScreen); +} + +Bool DGAActive(int index) { DGAScreenPtr pScreenPriv; diff --git a/hw/xfree86/dixmods/extmod/dgaproc.h b/hw/xfree86/dixmods/extmod/dgaproc.h index b4e0ddf..2c2fae0 100644 --- a/hw/xfree86/dixmods/extmod/dgaproc.h +++ b/hw/xfree86/dixmods/extmod/dgaproc.h @@ -64,6 +64,7 @@ extern _X_EXPORT void DGASelectInput(int Index, ClientPtr client, long mask); extern _X_EXPORT Bool DGAAvailable(int Index); +extern _X_EXPORT Bool DGAScreenAvailable(ScreenPtr pScreen); extern _X_EXPORT Bool DGAActive(int Index); extern _X_EXPORT void DGAShutdown(void); extern _X_EXPORT void DGAInstallCmap(ColormapPtr cmap); diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c index bb954ac..3f1a330 100644 --- a/hw/xfree86/modes/xf86DiDGA.c +++ b/hw/xfree86/modes/xf86DiDGA.c @@ -178,7 +178,7 @@ _xf86_di_dga_reinit_internal(ScreenPtr pScreen) ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); -if (!DGAAvailable(pScreen-myNum)) +if (!DGAScreenAvailable(pScreen)) return TRUE; if (!xf86_dga_get_modes(pScreen)) diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c index a1aa405..e7a0d02 100644 --- a/hw/xfree86/vgahw/vgaCmap.c +++ b/hw/xfree86/vgahw/vgaCmap.c @@ -97,7 +97,7 @@ xColorItem *pdefs; } writeColormap = scrninfp-vtSema; -if (DGAAvailable(scrnIndex)) { +if (DGAScreenAvailable(pmap-pScreen)) { writeColormap = writeColormap || (DGAGetDirectMode(scrnIndex) !(DGAGetFlags(scrnIndex) XF86DGADirectColormap)) || -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 10/29] exa: pixmap sharing infrastructure (v3)
From: Dave Airlie airl...@redhat.com This just adds exa interfaces for mixed exa so drivers can share and set shared pixmaps up correctly. v2: update for passing slave screen. v3: update for void * Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- exa/exa.c |7 +++ exa/exa.h |6 +- exa/exa_mixed.c | 33 + exa/exa_priv.h |7 +++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/exa/exa.c b/exa/exa.c index 623ece0..d12344f 100644 --- a/exa/exa.c +++ b/exa/exa.c @@ -782,6 +782,10 @@ exaCloseScreen(ScreenPtr pScreen) unwrap(pExaScr, pScreen, ChangeWindowAttributes); unwrap(pExaScr, pScreen, BitmapToRegion); unwrap(pExaScr, pScreen, CreateScreenResources); +if (pExaScr-SavedSharePixmapBacking) +unwrap(pExaScr, pScreen, SharePixmapBacking); +if (pExaScr-SavedSetSharedPixmapBacking) +unwrap(pExaScr, pScreen, SetSharedPixmapBacking); unwrap(pExaScr, ps, Composite); if (pExaScr-SavedGlyphs) unwrap(pExaScr, ps, Glyphs); @@ -976,6 +980,9 @@ exaDriverInit(ScreenPtr pScreen, ExaDriverPtr pScreenInfo) wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_mixed); wrap(pExaScr, pScreen, ModifyPixmapHeader, exaModifyPixmapHeader_mixed); +wrap(pExaScr, pScreen, SharePixmapBacking, exaSharePixmapBacking_mixed); +wrap(pExaScr, pScreen, SetSharedPixmapBacking, exaSetSharedPixmapBacking_mixed); + pExaScr-do_migration = exaDoMigration_mixed; pExaScr-pixmap_has_gpu_copy = exaPixmapHasGpuCopy_mixed; pExaScr-do_move_in_pixmap = exaMoveInPixmap_mixed; diff --git a/exa/exa.h b/exa/exa.h index 8a6539f..be022b2 100644 --- a/exa/exa.h +++ b/exa/exa.h @@ -39,7 +39,7 @@ #include fb.h #define EXA_VERSION_MAJOR 2 -#define EXA_VERSION_MINOR 5 +#define EXA_VERSION_MINOR 6 #define EXA_VERSION_RELEASE 0 typedef struct _ExaOffscreenArea ExaOffscreenArea; @@ -694,6 +694,10 @@ typedef struct _ExaDriver { int depth, int usage_hint, int bitsPerPixel, int *new_fb_pitch); /** @} */ +Bool (*SharePixmapBacking)(PixmapPtr pPixmap, ScreenPtr slave, void **handle_p); + +Bool (*SetSharedPixmapBacking)(PixmapPtr pPixmap, void *handle); + } ExaDriverRec, *ExaDriverPtr; /** @name EXA driver flags diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c index 0681731..0fb4091 100644 --- a/exa/exa_mixed.c +++ b/exa/exa_mixed.c @@ -294,3 +294,36 @@ exaPixmapHasGpuCopy_mixed(PixmapPtr pPixmap) return ret; } + +Bool +exaSharePixmapBacking_mixed(PixmapPtr pPixmap, ScreenPtr slave, void **handle_p) +{ +ScreenPtr pScreen = pPixmap-drawable.pScreen; +ExaScreenPriv(pScreen); +Bool ret = FALSE; + +exaMoveInPixmap(pPixmap); +/* get the driver to give us a handle */ +if (pExaScr-info-SharePixmapBacking) +ret = pExaScr-info-SharePixmapBacking(pPixmap, slave, handle_p); + +return ret; +} + +Bool +exaSetSharedPixmapBacking_mixed(PixmapPtr pPixmap, void *handle) +{ +ScreenPtr pScreen = pPixmap-drawable.pScreen; +ExaScreenPriv(pScreen); +Bool ret = FALSE; + +if (pExaScr-info-SetSharedPixmapBacking) +ret = pExaScr-info-SetSharedPixmapBacking(pPixmap, handle); + +if (ret == TRUE) +exaMoveInPixmap(pPixmap); + +return ret; +} + + diff --git a/exa/exa_priv.h b/exa/exa_priv.h index 68eadc5..ea7e7fa 100644 --- a/exa/exa_priv.h +++ b/exa/exa_priv.h @@ -163,6 +163,8 @@ typedef struct { BitmapToRegionProcPtr SavedBitmapToRegion; CreateScreenResourcesProcPtr SavedCreateScreenResources; ModifyPixmapHeaderProcPtr SavedModifyPixmapHeader; +SharePixmapBackingProcPtr SavedSharePixmapBacking; +SetSharedPixmapBackingProcPtr SavedSetSharedPixmapBacking; SourceValidateProcPtr SavedSourceValidate; CompositeProcPtr SavedComposite; TrianglesProcPtr SavedTriangles; @@ -658,6 +660,11 @@ void void exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg); +Bool +exaSetSharedPixmapBacking_mixed(PixmapPtr pPixmap, void *handle); +Bool +exaSharePixmapBacking_mixed(PixmapPtr pPixmap, ScreenPtr slave, void **handle_p); + /* exa_render.c */ Bool exaOpReadsDestination(CARD8 op); -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 02/29] randr: add provider object and provider property support (v6)
From: Dave Airlie airl...@redhat.com This adds the initial provider object and provider property support to the randr dix code. v2: destroy provider in screen close v2.1: fix whitespace v3: update for latest rev of protocol + renumber after 1.4 tearout. v4: fix logic issue, thanks Samsagax on irc v5: keithp's review: fix current_role, fix copyrights, fix master reporting crtc/outputs. v6: port to new randr interface, drop all set role bits for now Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/common/xf86platformBus.c |9 +- randr/Makefile.am |2 + randr/randr.c | 57 ++- randr/randrstr.h| 103 - randr/rrdispatch.c | 14 +- randr/rrprovider.c | 280 ++ randr/rrproviderproperty.c | 716 +++ 7 files changed, 1175 insertions(+), 6 deletions(-) create mode 100644 randr/rrprovider.c create mode 100644 randr/rrproviderproperty.c diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 3bfb22e..24b9473 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -432,14 +432,17 @@ xf86platformAddDevice(int index) xf86DeleteScreen(xf86GPUScreens[i]); return -1; } - + scr_index = AddGPUScreen(xf86GPUScreens[i]-ScreenInit, 0, NULL); - + dixSetPrivate(xf86GPUScreens[i]-pScreen-devPrivates, xf86ScreenKey, xf86GPUScreens[i]); CreateScratchPixmapsForScreen(xf86GPUScreens[i]-pScreen); - + + /* attach unbound to 0 protocol screen */ + AttachUnboundGPU(xf86Screens[0]-pScreen, xf86GPUScreens[i]-pScreen); + return 0; } diff --git a/randr/Makefile.am b/randr/Makefile.am index de338b9..ccaff3f 100644 --- a/randr/Makefile.am +++ b/randr/Makefile.am @@ -18,6 +18,8 @@ librandr_la_SOURCES = \ rroutput.c \ rrpointer.c \ rrproperty.c\ + rrprovider.c\ + rrproviderproperty.c\ rrscreen.c \ rrsdispatch.c \ rrtransform.h \ diff --git a/randr/randr.c b/randr/randr.c index 103da48..103c31e 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -94,6 +94,9 @@ RRCloseScreen(ScreenPtr pScreen) for (j = pScrPriv-numOutputs - 1; j = 0; j--) RROutputDestroy(pScrPriv-outputs[j]); +if (pScrPriv-provider) +RRProviderDestroy(pScrPriv-provider); + free(pScrPriv-crtcs); free(pScrPriv-outputs); free(pScrPriv); @@ -176,6 +179,47 @@ SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent * from, } static void +SRRProviderChangeNotifyEvent(xRRProviderChangeNotifyEvent * from, + xRRProviderChangeNotifyEvent * to) +{ +to-type = from-type; +to-subCode = from-subCode; +cpswaps(from-sequenceNumber, to-sequenceNumber); +cpswapl(from-timestamp, to-timestamp); +cpswapl(from-window, to-window); +cpswapl(from-provider, to-provider); +} + +static void +SRRProviderPropertyNotifyEvent(xRRProviderPropertyNotifyEvent * from, + xRRProviderPropertyNotifyEvent * to) +{ +to-type = from-type; +to-subCode = from-subCode; +cpswaps(from-sequenceNumber, to-sequenceNumber); +cpswapl(from-window, to-window); +cpswapl(from-provider, to-provider); +cpswapl(from-atom, to-atom); +cpswapl(from-timestamp, to-timestamp); +to-state = from-state; +/* pad1 */ +/* pad2 */ +/* pad3 */ +/* pad4 */ +} + +static void +SRRResourceChangeNotifyEvent(xRRResourceChangeNotifyEvent * from, + xRRResourceChangeNotifyEvent * to) +{ +to-type = from-type; +to-subCode = from-subCode; +cpswaps(from-sequenceNumber, to-sequenceNumber); +cpswapl(from-timestamp, to-timestamp); +cpswapl(from-window, to-window); +} + +static void SRRNotifyEvent(xEvent *from, xEvent *to) { switch (from-u.u.detail) { @@ -191,6 +235,17 @@ SRRNotifyEvent(xEvent *from, xEvent *to) SRROutputPropertyNotifyEvent((xRROutputPropertyNotifyEvent *) from, (xRROutputPropertyNotifyEvent *) to); break; +case RRNotify_ProviderChange: +SRRProviderChangeNotifyEvent((xRRProviderChangeNotifyEvent *) from, + (xRRProviderChangeNotifyEvent *) to); +break; +case RRNotify_ProviderProperty: +SRRProviderPropertyNotifyEvent((xRRProviderPropertyNotifyEvent *) from, + (xRRProviderPropertyNotifyEvent *) to); +break; +case RRNotify_ResourceChange: +SRRResourceChangeNotifyEvent((xRRResourceChangeNotifyEvent *) from, + (xRRResourceChangeNotifyEvent *) to); default: break; } @@ -356,7 +411,7 @@ RRExtensionInit(void) RRModeInitErrorValue(); RRCrtcInitErrorValue();
[PATCH 12/29] xf86: add initial scanout pixmap support
From: Dave Airlie airl...@redhat.com Add the simple passthrough interface for drivers to use, so they can set scanout pixmaps. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.h|5 + hw/xfree86/modes/xf86RandR12.c | 10 ++ 2 files changed, 15 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 58d8cec..25fb34d 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -218,6 +218,11 @@ typedef struct _xf86CrtcFuncs { void (*set_origin) (xf86CrtcPtr crtc, int x, int y); +/** + */ +Bool +(*set_scanout_pixmap)(xf86CrtcPtr crtc, PixmapPtr pixmap); + } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; #define XF86_CRTC_VERSION 4 diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 1eaef9d..ca3388a 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1789,6 +1789,15 @@ xf86RandR14ProviderGetProperty(ScreenPtr pScreen, } static Bool +xf86CrtcSetScanoutPixmap(RRCrtcPtr randr_crtc, PixmapPtr pixmap) +{ +xf86CrtcPtr crtc = randr_crtc-devPrivate; +if (!crtc-funcs-set_scanout_pixmap) +return FALSE; +return crtc-funcs-set_scanout_pixmap(crtc, pixmap); +} + +static Bool xf86RandR12Init12(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); @@ -1813,6 +1822,7 @@ xf86RandR12Init12(ScreenPtr pScreen) rp-rrProviderSetProperty = xf86RandR14ProviderSetProperty; rp-rrProviderGetProperty = xf86RandR14ProviderGetProperty; +rp-rrCrtcSetScanoutPixmap = xf86CrtcSetScanoutPixmap; pScrn-PointerMoved = xf86RandR12PointerMoved; pScrn-ChangeGamma = xf86RandR12ChangeGamma; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 14/29] randr: fix tellchanged to work with slave scanouts
From: Dave Airlie airl...@redhat.com Tell changed need to tell only for the master pixmap, however it gets called from various places for slave screens, so convert to telling clients about changes on the master screen. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/randr.c | 26 +++--- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/randr/randr.c b/randr/randr.c index 103c31e..ae81166 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -467,25 +467,37 @@ TellChanged(WindowPtr pWin, pointer value) void RRTellChanged(ScreenPtr pScreen) { +ScreenPtr master; rrScrPriv(pScreen); +rrScrPrivPtr mastersp; int i; +if (pScreen-isGPU) { +master = pScreen-current_master; +mastersp = rrGetScrPriv(master); +} +else { +master = pScreen; +mastersp = pScrPriv; +} + if (pScrPriv-changed) { UpdateCurrentTimeIf(); -if (pScrPriv-configChanged) { -pScrPriv-lastConfigTime = currentTime; -pScrPriv-configChanged = FALSE; +if (mastersp-configChanged) { +mastersp-lastConfigTime = currentTime; +mastersp-configChanged = FALSE; } pScrPriv-changed = FALSE; -WalkTree(pScreen, TellChanged, (pointer) pScreen); +mastersp-changed = FALSE; +WalkTree(master, TellChanged, (pointer) master); for (i = 0; i pScrPriv-numOutputs; i++) pScrPriv-outputs[i]-changed = FALSE; for (i = 0; i pScrPriv-numCrtcs; i++) pScrPriv-crtcs[i]-changed = FALSE; -if (pScrPriv-layoutChanged) { +if (mastersp-layoutChanged) { pScrPriv-layoutChanged = FALSE; -RRPointerScreenConfigured(pScreen); -RRSendConfigNotify(pScreen); +RRPointerScreenConfigured(master); +RRSendConfigNotify(master); } } } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 15/29] randr: check the screen size bounds against the master
From: Dave Airlie airl...@redhat.com The master contains the complete screen size bounds, so check the width/height against it. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrcrtc.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index e5fe059..949ae60 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1125,6 +1125,16 @@ ProcRRSetCrtcConfig(ClientPtr client) int source_height; PictTransform transform; struct pixman_f_transform f_transform, f_inverse; +int width, height; + +if (pScreen-isGPU) { +width = pScreen-current_master-width; +height = pScreen-current_master-height; +} +else { +width = pScreen-width; +height = pScreen-height; +} RRTransformCompute(stuff-x, stuff-y, mode-mode.width, mode-mode.height, @@ -1134,13 +1144,13 @@ ProcRRSetCrtcConfig(ClientPtr client) RRModeGetScanoutSize(mode, transform, source_width, source_height); -if (stuff-x + source_width pScreen-width) { +if (stuff-x + source_width width) { client-errorValue = stuff-x; free(outputs); return BadValue; } -if (stuff-y + source_height pScreen-height) { +if (stuff-y + source_height height) { client-errorValue = stuff-y; free(outputs); return BadValue; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 16/29] dix/pixmap: track dirty pixmaps in server. (v3)
From: Dave Airlie airl...@redhat.com This adds two functions for drivers to use directly to keep a linked list of slave pixmaps to do damage tracking on and keep updated. It also adds a helper function that drivers may optionally call to do a simple copy area damage update. v2: use damage.h not damagestr.h, fixes ephyr build. v3: address ajax review: use slave_dst, drop unused dst member. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c |1 + dix/pixmap.c | 105 ++ include/pixmap.h | 16 include/pixmapstr.h |8 include/scrnintstr.h |2 + 5 files changed, 125 insertions(+), 7 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 29ac5a4..bc803d7 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3742,6 +3742,7 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) pScreen-ClipNotify = 0;/* for R4 ddx compatibility */ pScreen-CreateScreenResources = 0; +xorg_list_init(pScreen-pixmap_dirty_list); xorg_list_init(pScreen-unattached_list); xorg_list_init(pScreen-output_slave_list); diff --git a/dix/pixmap.c b/dix/pixmap.c index 7272098..01e1635 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -140,21 +140,112 @@ PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave) ret = master-SharePixmapBacking(pixmap, slave, handle); if (ret == FALSE) - return NULL; - +return NULL; + spix = slave-CreatePixmap(slave, 0, 0, depth, - CREATE_PIXMAP_USAGE_SHARED); + CREATE_PIXMAP_USAGE_SHARED); slave-ModifyPixmapHeader(spix, pixmap-drawable.width, - pixmap-drawable.height, depth, 0, - pixmap-devKind, NULL); + pixmap-drawable.height, depth, 0, + pixmap-devKind, NULL); spix-master_pixmap = pixmap; ret = slave-SetSharedPixmapBacking(spix, handle); if (ret == FALSE) { - slave-DestroyPixmap(spix); - return NULL; +slave-DestroyPixmap(spix); +return NULL; } return spix; } + +Bool +PixmapStartDirtyTracking(PixmapPtr src, + PixmapPtr slave_dst, + int x, int y) +{ +ScreenPtr screen = src-drawable.pScreen; +PixmapDirtyUpdatePtr dirty_update; + +dirty_update = calloc(1, sizeof(PixmapDirtyUpdateRec)); +if (!dirty_update) +return FALSE; + +dirty_update-src = src; +dirty_update-slave_dst = slave_dst; +dirty_update-x = x; +dirty_update-y = y; + +dirty_update-damage = DamageCreate(NULL, NULL, +DamageReportNone, +TRUE, src-drawable.pScreen, +src-drawable.pScreen); +DamageRegister(src-drawable, dirty_update-damage); +xorg_list_add(dirty_update-ent, screen-pixmap_dirty_list); +return TRUE; +} + +Bool +PixmapStopDirtyTracking(PixmapPtr src, PixmapPtr slave_dst) +{ +ScreenPtr screen = src-drawable.pScreen; +PixmapDirtyUpdatePtr ent, safe; + +xorg_list_for_each_entry_safe(ent, safe, screen-pixmap_dirty_list, ent) { +if (ent-src == src ent-slave_dst == slave_dst) { +DamageUnregister(src-drawable, ent-damage); +DamageDestroy(ent-damage); +xorg_list_del(ent-ent); +free(ent); +} +} +return TRUE; +} + +Bool PixmapSyncDirtyHelper(PixmapDirtyUpdatePtr dirty, RegionPtr dirty_region) +{ +ScreenPtr pScreen = dirty-src-drawable.pScreen; +int n; +BoxPtr b; +RegionPtr region = DamageRegion(dirty-damage); +GCPtr pGC; +PixmapPtr dst; +SourceValidateProcPtr SourceValidate; + +SourceValidate = pScreen-SourceValidate; +pScreen-SourceValidate = NULL; + +RegionTranslate(dirty_region, dirty-x, dirty-y); +RegionIntersect(dirty_region, dirty_region, region); + +if (RegionNil(dirty_region)) { +RegionUninit(dirty_region); +return FALSE; +} + +dst = dirty-slave_dst-master_pixmap; + +RegionTranslate(dirty_region, -dirty-x, -dirty-y); +n = RegionNumRects(dirty_region); +b = RegionRects(dirty_region); + +pGC = GetScratchGC(dirty-src-drawable.depth, pScreen); +ValidateGC(dst-drawable, pGC); + +while (n--) { +BoxRec dst_box; +int w, h; + +dst_box = *b; +w = dst_box.x2 - dst_box.x1; +h = dst_box.y2 - dst_box.y1; + +pGC-ops-CopyArea(dirty-src-drawable, dst-drawable, pGC, + dirty-x + dst_box.x1, dirty-y + dst_box.y1, w, h, dst_box.x1, dst_box.y1); +b++; +} +FreeScratchGC(pGC); + +pScreen-SourceValidate = SourceValidate; +return TRUE; +} diff --git a/include/pixmap.h b/include/pixmap.h index 8c523bd..921a94d 100644 --- a/include/pixmap.h +++
[PATCH 13/29] randr: fixup constrain to work with slave screens.
From: Dave Airlie airl...@redhat.com Current code constrains the cursor to the crtcs on the master device, for slave outputs to work we have to include their crtcs in the constrain calculations. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrcrtc.c | 57 +--- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 29b02a9..e5fe059 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1544,18 +1544,10 @@ ProcRRGetCrtcTransform(ClientPtr client) return Success; } -void -RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, -int *y) +static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y) { rrScrPriv(pScreen); int i; - -/* intentional dead space - let it float */ -if (pScrPriv-discontiguous) -return; - -/* if we're moving inside a crtc, we're fine */ for (i = 0; i pScrPriv-numCrtcs; i++) { RRCrtcPtr crtc = pScrPriv-crtcs[i]; @@ -1567,8 +1559,15 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, crtc_bounds(crtc, left, right, top, bottom); if ((*x = left) (*x right) (*y = top) (*y bottom)) -return; +return TRUE; } +return FALSE; +} + +static Bool constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y) +{ +rrScrPriv(pScreen); +int i; /* if we're trying to escape, clamp to the CRTC we're coming from */ for (i = 0; i pScrPriv-numCrtcs; i++) { @@ -1592,7 +1591,43 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, if (*y = bottom) *y = bottom - 1; -return; +return TRUE; } } +return FALSE; +} + +void +RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, +int *y) +{ +rrScrPriv(pScreen); +Bool ret; +ScreenPtr slave; + +/* intentional dead space - let it float */ +if (pScrPriv-discontiguous) +return; + +/* if we're moving inside a crtc, we're fine */ +ret = check_all_screen_crtcs(pScreen, x, y); +if (ret == TRUE) +return; + +xorg_list_for_each_entry(slave, pScreen-output_slave_list, output_head) { +ret = check_all_screen_crtcs(slave, x, y); +if (ret == TRUE) +return; +} + +/* if we're trying to escape, clamp to the CRTC we're coming from */ +ret = constrain_all_screen_crtcs(pDev, pScreen, x, y); +if (ret == TRUE) +return; + +xorg_list_for_each_entry(slave, pScreen-output_slave_list, output_head) { +ret = constrain_all_screen_crtcs(pDev, slave, x, y); +if (ret == TRUE) +return; +} } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 17/29] xf86/crtc: add new interface to detach slave crtcs
From: Dave Airlie airl...@redhat.com This will detach any scanout pixmaps attached to slave crtcs. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c | 20 hw/xfree86/modes/xf86Crtc.h |3 +++ 2 files changed, 23 insertions(+) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index a8dc187..5057eac 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -3223,3 +3223,23 @@ xf86ProviderSetup(ScrnInfoPtr scrn, #endif } +void +xf86DetachAllCrtc(ScrnInfoPtr scrn) +{ +xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); +int i; + +for (i = 0; i xf86_config-num_crtc; i++) { +xf86CrtcPtr crtc = xf86_config-crtc[i]; + +if (crtc-randr_crtc) +RRCrtcDetachScanoutPixmap(crtc-randr_crtc); + +/* dpms off */ +(*crtc-funcs-dpms) (crtc, DPMSModeOff); +/* force a reset the next time its used */ +crtc-randr_crtc-mode = NULL; +crtc-mode.HDisplay = 0; +crtc-x = crtc-y = 0; +} +} diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 25fb34d..38b9ea5 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -1014,4 +1014,7 @@ extern _X_EXPORT void xf86ProviderSetup(ScrnInfoPtr scrn, const xf86ProviderFuncsRec * funcs, const char *name); +extern _X_EXPORT void +xf86DetachAllCrtc(ScrnInfoPtr scrn); + #endif /* _XF86CRTC_H_ */ -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 18/29] randr: hook up output slave to screen resources return
From: Dave Airlie airl...@redhat.com When the client asks for the screen resources list, it will now get a list of crtc/outputs for the master + all attached slaves, this will let randr configure all attached slave devices properly. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/rrscreen.c | 169 ++ 1 file changed, 169 insertions(+) diff --git a/randr/rrscreen.c b/randr/rrscreen.c index c564d1f..9bf9316 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -292,6 +292,172 @@ ProcRRSetScreenSize(ClientPtr client) return Success; } + +#define update_totals(gpuscreen, pScrPriv) do { \ +total_crtcs += pScrPriv-numCrtcs;\ +total_outputs += pScrPriv-numOutputs;\ +modes = RRModesForScreen(gpuscreen, num_modes); \ +if (!modes) \ +return BadAlloc; \ +for (j = 0; j num_modes; j++) \ +total_name_len += modes[j]-mode.nameLength; \ +total_modes += num_modes; \ +free(modes); \ +} while(0) + +static inline void swap_modeinfos(xRRModeInfo *modeinfos, int i) +{ +swapl(modeinfos[i].id); +swaps(modeinfos[i].width); +swaps(modeinfos[i].height); +swapl(modeinfos[i].dotClock); +swaps(modeinfos[i].hSyncStart); +swaps(modeinfos[i].hSyncEnd); +swaps(modeinfos[i].hTotal); +swaps(modeinfos[i].hSkew); +swaps(modeinfos[i].vSyncStart); +swaps(modeinfos[i].vSyncEnd); +swaps(modeinfos[i].vTotal); +swaps(modeinfos[i].nameLength); +swapl(modeinfos[i].modeFlags); +} + +#define update_arrays(gpuscreen, pScrPriv) do {\ +for (j = 0; j pScrPriv-numCrtcs; j++) { \ +crtcs[crtc_count] = pScrPriv-crtcs[j]-id;\ +if (client-swapped) \ +swapl(crtcs[crtc_count]); \ +crtc_count++; \ +} \ +for (j = 0; j pScrPriv-numOutputs; j++) { \ +outputs[output_count] = pScrPriv-outputs[j]-id; \ +if (client-swapped) \ +swapl(outputs[output_count]); \ +output_count++;\ +} \ +{ \ +RRModePtr mode;\ +modes = RRModesForScreen(gpuscreen, num_modes); \ +for (j = 0; j num_modes; j++) { \ +mode = modes[j]; \ +modeinfos[mode_count] = mode-mode;\ +if (client-swapped) { \ +swap_modeinfos(modeinfos, mode_count); \ +} \ +memcpy(names, mode-name, mode-mode.nameLength); \ +names += mode-mode.nameLength;\ +mode_count++; \ +} \ +free(modes); \ +} \ +} while (0) + +static int +rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen) +{ +int j; +int total_crtcs, total_outputs, total_modes, total_name_len; +int crtc_count, output_count, mode_count; +ScreenPtr iter; +rrScrPrivPtr pScrPriv; +int num_modes; +RRModePtr *modes; +xRRGetScreenResourcesReply rep; +unsigned long extraLen; +CARD8 *extra; +RRCrtc *crtcs; +RROutput *outputs; +xRRModeInfo *modeinfos; +CARD8 *names; + +/* we need to iterate all the GPU masters and all their output slaves */ +total_crtcs = 0; +total_outputs = 0; +total_modes = 0; +total_name_len = 0; + +pScrPriv = rrGetScrPriv(pScreen); + +if (query pScrPriv) +if (!RRGetInfo(pScreen, query)) +return BadAlloc; + +update_totals(pScreen, pScrPriv); + +xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { +pScrPriv = rrGetScrPriv(iter); + +if (query) + if (!RRGetInfo(iter, query)) +return BadAlloc; +update_totals(iter, pScrPriv); +} + +ErrorF(reporting %d %d %d %d\n, total_crtcs, total_outputs, total_modes, total_name_len); + +pScrPriv = rrGetScrPriv(pScreen); +rep.pad = 0; +rep.type = X_Reply; +rep.sequenceNumber = client-sequence; +rep.length = 0; +rep.timestamp = pScrPriv-lastSetTime.milliseconds; +rep.configTimestamp = pScrPriv-lastConfigTime.milliseconds; +rep.nCrtcs = total_crtcs; +rep.nOutputs = total_outputs; +rep.nModes =
[PATCH 21/29] xf86/cursor: fallback to sw cursor if we have slaves present.
From: Dave Airlie airl...@redhat.com Current USB devices have no hw rendered cursors, so we need the master GPU to render the cursor, so whenever we plug in a slave device, fallback to sw rendered cursors. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/ramdac/xf86Cursor.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 8b91e05..8d48a75 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -336,7 +336,7 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, if (!infoPtr-pScrn-vtSema) ScreenPriv-SavedCursor = pCurs; -if (infoPtr-pScrn-vtSema +if (infoPtr-pScrn-vtSema xorg_list_is_empty(pScreen-pixmap_dirty_list) (ScreenPriv-ForceHWCursorCount || (( #ifdef ARGB_CURSOR -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 11/29] randr: add initial scanout pixmap support (v3)
From: Dave Airlie airl...@redhat.com When randr notices a crtc configuration request for a slave device, it checks if the slave allocated pixmap exists and is suitable, if not it allocates a new shared pixmap from the master, shares it to the slave, and starts the master tracking damage to it, to keep it updated from the current front pixmap. If the resize means the crtc is no longer used it will destroy the slave pixmap. This adds the concept of a scanout_pixmap to the randr_crtc object, and also adds a master pixmap pointer to the pixmap object, along with defining some pixmap helper functions for getting pixmap box/regions. v2: split out pixmap sharing to a separate function. v3: update for void * Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- dix/pixmap.c| 29 + include/pixmap.h|3 + include/pixmapstr.h | 22 +++ randr/randrstr.h| 12 randr/rrcrtc.c | 171 +++ 5 files changed, 237 insertions(+) diff --git a/dix/pixmap.c b/dix/pixmap.c index 0c85c3f..7272098 100644 --- a/dix/pixmap.c +++ b/dix/pixmap.c @@ -129,3 +129,32 @@ FreePixmap(PixmapPtr pPixmap) dixFiniPrivates(pPixmap, PRIVATE_PIXMAP); free(pPixmap); } + +PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave) +{ +PixmapPtr spix; +int ret; +void *handle; +ScreenPtr master = pixmap-drawable.pScreen; +int depth = pixmap-drawable.depth; + +ret = master-SharePixmapBacking(pixmap, slave, handle); +if (ret == FALSE) + return NULL; + +spix = slave-CreatePixmap(slave, 0, 0, depth, + CREATE_PIXMAP_USAGE_SHARED); +slave-ModifyPixmapHeader(spix, pixmap-drawable.width, + pixmap-drawable.height, depth, 0, + pixmap-devKind, NULL); + +spix-master_pixmap = pixmap; + +ret = slave-SetSharedPixmapBacking(spix, handle); +if (ret == FALSE) { + slave-DestroyPixmap(spix); + return NULL; +} + +return spix; +} diff --git a/include/pixmap.h b/include/pixmap.h index 9bb5bb7..8c523bd 100644 --- a/include/pixmap.h +++ b/include/pixmap.h @@ -109,4 +109,7 @@ extern _X_EXPORT PixmapPtr AllocatePixmap(ScreenPtr /*pScreen */ , extern _X_EXPORT void FreePixmap(PixmapPtr /*pPixmap */ ); +extern _X_EXPORT PixmapPtr +PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave); + #endif /* PIXMAP_H */ diff --git a/include/pixmapstr.h b/include/pixmapstr.h index 0800c62..40af5c4 100644 --- a/include/pixmapstr.h +++ b/include/pixmapstr.h @@ -80,6 +80,28 @@ typedef struct _Pixmap { short screen_y; #endif unsigned usage_hint;/* see CREATE_PIXMAP_USAGE_* */ + +PixmapPtr master_pixmap;/* pointer to master copy of pixmap for pixmap sharing */ } PixmapRec; +static inline void +PixmapBox(BoxPtr box, PixmapPtr pixmap) +{ +box-x1 = 0; +box-x2 = pixmap-drawable.width; + +box-y1 = 0; +box-y2 = pixmap-drawable.height; +} + + +static inline void +PixmapRegionInit(RegionPtr region, PixmapPtr pixmap) +{ +BoxRec box; + +PixmapBox(box, pixmap); +RegionInit(region, box, 1); +} + #endif /* PIXMAPSTRUCT_H */ diff --git a/randr/randrstr.h b/randr/randrstr.h index 0e04b74..4ed581d 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -127,6 +127,8 @@ struct _rrCrtc { PictTransform transform; struct pict_f_transform f_transform; struct pict_f_transform f_inverse; + +PixmapPtr scanout_pixmap; }; struct _rrOutput { @@ -247,6 +249,8 @@ typedef Bool (*RRSetConfigProcPtr) (ScreenPtr pScreen, #endif +typedef Bool (*RRCrtcSetScanoutPixmapProcPtr)(RRCrtcPtr crtc, PixmapPtr pixmap); + typedef struct _rrScrPriv { /* * 'public' part of the structure; DDXen fill this in @@ -270,6 +274,8 @@ typedef struct _rrScrPriv { RRGetPanningProcPtr rrGetPanning; RRSetPanningProcPtr rrSetPanning; #endif +/* TODO #if RANDR_15_INTERFACE */ +RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; RRProviderGetPropertyProcPtr rrProviderGetProperty; RRProviderSetPropertyProcPtr rrProviderSetProperty; @@ -654,6 +660,12 @@ extern _X_EXPORT void RRCrtcInitErrorValue(void); /* + * Detach and free a scanout pixmap + */ +extern _X_EXPORT void + RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc); + +/* * Crtc dispatch */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 0c596dd..29b02a9 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -367,6 +367,154 @@ RRComputeContiguity(ScreenPtr pScreen) pScrPriv-discontiguous = discontiguous; } +void +RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc) +{ +ScreenPtr master = crtc-pScreen-current_master; +int ret; +PixmapPtr mscreenpix; +rrScrPriv(crtc-pScreen); + +mscreenpix = master-GetScreenPixmap(master); + +ret = pScrPriv-rrCrtcSetScanoutPixmap(crtc, NULL); +if
[PATCH 20/29] xf86: add output source setting callback
From: Dave Airlie airl...@redhat.com This adds support for the randr callback for setting the output source for a device. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c|6 +- hw/xfree86/modes/xf86RandR12.c | 35 +++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 5057eac..9e43c40 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -728,7 +728,11 @@ xf86CrtcCloseScreen(ScreenPtr screen) /* detach any providers */ if (config-randr_provider) { -DetachUnboundGPU(screen); +if (config-randr_provider-output_source) { +DetachOutputGPU(screen); +config-randr_provider-output_source = NULL; +} else +DetachUnboundGPU(screen); } for (o = 0; o config-num_output; o++) { xf86OutputPtr output = config-output[o]; diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index ca3388a..01cc594 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1754,6 +1754,39 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn) } static Bool +xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr source_provider) +{ + + +if (!source_provider) { +if (provider-output_source) { +ScreenPtr cmScreen = pScreen-current_master; +SetRootClip(cmScreen, FALSE); + +DetachOutputGPU(pScreen); +AttachUnboundGPU(cmScreen, pScreen); +SetRootClip(cmScreen, TRUE); +} +provider-output_source = NULL; +return TRUE; +} + +if (provider-output_source == source_provider) +return TRUE; + +SetRootClip(source_provider-pScreen, FALSE); + +DetachUnboundGPU(pScreen); +AttachOutputGPU(source_provider-pScreen, pScreen); + +provider-output_source = source_provider; +SetRootClip(source_provider-pScreen, TRUE); +return TRUE; +} + +static Bool xf86RandR14ProviderSetProperty(ScreenPtr pScreen, RRProviderPtr randr_provider, Atom property, RRPropertyValuePtr value) @@ -1820,6 +1853,8 @@ xf86RandR12Init12(ScreenPtr pScreen) rp-rrModeDestroy = xf86RandR12ModeDestroy; rp-rrSetConfig = NULL; +rp-rrProviderSetOutputSource = xf86RandR14ProviderSetOutputSource; + rp-rrProviderSetProperty = xf86RandR14ProviderSetProperty; rp-rrProviderGetProperty = xf86RandR14ProviderGetProperty; rp-rrCrtcSetScanoutPixmap = xf86CrtcSetScanoutPixmap; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 19/29] randr: add output source setup
From: Dave Airlie airl...@redhat.com This adds the output sources to the associated list and adds the protocol handler for the randr SetProviderOutputSource. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/randrstr.h |8 randr/rrdispatch.c |2 +- randr/rrprovider.c | 58 +++- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/randr/randrstr.h b/randr/randrstr.h index 4ed581d..d7b0804 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -165,6 +165,7 @@ struct _rrProvider { int nameLength; RRPropertyPtr properties; Bool pendingProperties; +struct _rrProvider *output_source; }; #if RANDR_12_INTERFACE @@ -226,6 +227,10 @@ typedef Bool (*RRProviderSetPropertyProcPtr) (ScreenPtr pScreen, typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations); typedef Bool (*RRCloseScreenProcPtr) (ScreenPtr pscreen); +typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr output_source); + /* These are for 1.0 compatibility */ typedef struct _rrRefresh { @@ -277,6 +282,7 @@ typedef struct _rrScrPriv { /* TODO #if RANDR_15_INTERFACE */ RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; +RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource; RRProviderGetPropertyProcPtr rrProviderGetProperty; RRProviderSetPropertyProcPtr rrProviderSetProperty; /* @@ -884,6 +890,8 @@ ProcRRGetProviders(ClientPtr client); extern _X_EXPORT int ProcRRGetProviderInfo(ClientPtr client); +extern _X_EXPORT int +ProcRRSetProviderOutputSource(ClientPtr client); extern _X_EXPORT Bool RRProviderInit(void); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 054e47a..6fe51c7 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -246,7 +246,7 @@ int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = { ProcRRGetProviders, /* 32 */ ProcRRGetProviderInfo, /* 33 */ NULL, /* 34 */ -NULL, /* 35 */ +ProcRRSetProviderOutputSource, /* 35 */ ProcRRListProviderProperties,/* 36 */ ProcRRQueryProviderProperty, /* 37 */ ProcRRConfigureProviderProperty, /* 38 */ diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 33cb77d..9237860 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -137,7 +137,7 @@ ProcRRGetProviderInfo (ClientPtr client) { REQUEST(xRRGetProviderInfoReq); xRRGetProviderInfoReply rep; -rrScrPrivPtr pScrPriv; +rrScrPrivPtr pScrPriv, pScrProvPriv; RRProviderPtr provider; ScreenPtr pScreen; CARD8 *extra; @@ -168,6 +168,10 @@ ProcRRGetProviderInfo (ClientPtr client) /* count associated providers */ rep.nAssociatedProviders = 0; +if (provider-output_source) +rep.nAssociatedProviders++; +xorg_list_for_each_entry(provscreen, pScreen-output_slave_list, output_head) +rep.nAssociatedProviders++; rep.length = (pScrPriv-numCrtcs + pScrPriv-numOutputs + (rep.nAssociatedProviders * 2) + bytes_to_int32(rep.nameLength)); @@ -198,6 +202,26 @@ ProcRRGetProviderInfo (ClientPtr client) swapl(outputs[i]); } +i = 0; +if (provider-output_source) { +providers[i] = provider-output_source-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SourceOutput; +swapl(prov_cap[i]); +i++; +} +xorg_list_for_each_entry(provscreen, pScreen-output_slave_list, output_head) { +pScrProvPriv = rrGetScrPriv(provscreen); +providers[i] = pScrProvPriv-provider-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SinkOutput; +if (client-swapped) +swapl(prov_cap[i]); +i++; +} + memcpy(name, provider-name, rep.nameLength); if (client-swapped) { swaps(rep.sequenceNumber); @@ -216,6 +240,38 @@ ProcRRGetProviderInfo (ClientPtr client) return Success; } +int +ProcRRSetProviderOutputSource(ClientPtr client) +{ +REQUEST(xRRSetProviderOutputSourceReq); +rrScrPrivPtr pScrPriv; +RRProviderPtr provider, source_provider = NULL; +ScreenPtr pScreen; + +REQUEST_AT_LEAST_SIZE(xRRSetProviderOutputSourceReq); + +VERIFY_RR_PROVIDER(stuff-provider, provider, DixReadAccess); + +if (!(provider-capabilities RR_Capability_SinkOutput)) +return BadValue; + +if (stuff-source_provider) { +VERIFY_RR_PROVIDER(stuff-source_provider, source_provider, DixReadAccess); + +if (!(source_provider-capabilities RR_Capability_SourceOutput)) +return BadValue; +} + +pScreen = provider-pScreen; +pScrPriv = rrGetScrPriv(pScreen); + +pScrPriv-rrProviderSetOutputSource(pScreen, provider,
[PATCH 24/29] xf86: store scanout pixmap in the xf86 struct as well.
From: Dave Airlie airl...@redhat.com This is so we can tell the scanout pixmap has changed between calls to the crtc set function. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.h|6 +- hw/xfree86/modes/xf86RandR12.c |4 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 38b9ea5..802303f 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -225,7 +225,7 @@ typedef struct _xf86CrtcFuncs { } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr; -#define XF86_CRTC_VERSION 4 +#define XF86_CRTC_VERSION 5 struct _xf86Crtc { /** @@ -376,6 +376,10 @@ struct _xf86Crtc { * Added in ABI version 4 */ Bool driverIsPerformingTransform; + +/* Added in ABI version 5 + */ +PixmapPtr current_scanout; }; typedef struct _xf86OutputFuncs { diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 01cc594..ce1bfe3 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1157,6 +1157,9 @@ xf86RandR12CrtcSet(ScreenPtr pScreen, if (rotation != crtc-rotation) changed = TRUE; +if (crtc-current_scanout != randr_crtc-scanout_pixmap) +changed = TRUE; + transform = RRCrtcGetTransform(randr_crtc); if ((transform != NULL) != crtc-transformPresent) changed = TRUE; @@ -1218,6 +1221,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen, */ crtc-desiredMode = mode; crtc-desiredRotation = rotation; +crtc-current_scanout = randr_crtc-scanout_pixmap; if (transform) { crtc-desiredTransform = *transform; crtc-desiredTransformPresent = TRUE; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 22/29] dix/xf86: initial offload slave tracking (v1.1)
From: Dave Airlie airl...@redhat.com add the linked list and provider hooks. v1.1: add another assert in the add path. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 19 +++ include/screenint.h |6 ++ include/scrnintstr.h |3 +++ randr/rrprovider.c |7 +++ 4 files changed, 35 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index bc803d7..bcce22f 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3745,6 +3745,7 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) xorg_list_init(pScreen-pixmap_dirty_list); xorg_list_init(pScreen-unattached_list); xorg_list_init(pScreen-output_slave_list); +xorg_list_init(pScreen-offload_slave_list); /* * This loop gets run once for every Screen that gets added, @@ -3927,3 +3928,21 @@ DetachOutputGPU(ScreenPtr slave) xorg_list_del(slave-output_head); slave-current_master = NULL; } + +void +AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new) +{ +assert(new-isGPU); +assert(!new-current_master); +xorg_list_add(new-offload_head, pScreen-offload_slave_list); +new-current_master = pScreen; +} + +void +DetachOffloadGPU(ScreenPtr slave) +{ +assert(slave-isGPU); +xorg_list_del(slave-offload_head); +slave-current_master = NULL; +} + diff --git a/include/screenint.h b/include/screenint.h index b992cc2..e36b4d8 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -82,6 +82,12 @@ AttachOutputGPU(ScreenPtr pScreen, ScreenPtr new); extern _X_EXPORT void DetachOutputGPU(ScreenPtr output); +extern _X_EXPORT void +AttachOffloadGPU(ScreenPtr pScreen, ScreenPtr new); + +extern _X_EXPORT void +DetachOffloadGPU(ScreenPtr slave); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 5ef37ed..80601b9 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -507,6 +507,9 @@ typedef struct _Screen { StopPixmapTrackingProcPtr StopPixmapTracking; struct xorg_list pixmap_dirty_list; +struct xorg_list offload_slave_list; +struct xorg_list offload_head; + } ScreenRec; static inline RegionPtr diff --git a/randr/rrprovider.c b/randr/rrprovider.c index 9237860..bf53d8b 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -76,6 +76,10 @@ ProcRRGetProviders (ClientPtr client) pScrPriv = rrGetScrPriv(iter); total_providers += pScrPriv-provider ? 1 : 0; } +xorg_list_for_each_entry(iter, pScreen-offload_slave_list, offload_head) { +pScrPriv = rrGetScrPriv(iter); +total_providers += pScrPriv-provider ? 1 : 0; +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { pScrPriv = rrGetScrPriv(iter); total_providers += pScrPriv-provider ? 1 : 0; @@ -112,6 +116,9 @@ ProcRRGetProviders (ClientPtr client) xorg_list_for_each_entry(iter, pScreen-output_slave_list, output_head) { ADD_PROVIDER(iter); } +xorg_list_for_each_entry(iter, pScreen-offload_slave_list, offload_head) { +ADD_PROVIDER(iter); +} xorg_list_for_each_entry(iter, pScreen-unattached_list, unattached_head) { ADD_PROVIDER(iter); } -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 23/29] randr: add hooks for offload sink provider protocol
From: Dave Airlie airl...@redhat.com This adds the protocol handler and associated providers handling for the offload slaves, it allows two providers to be connected as offload sink/source. Signed-off-by: Dave Airlie airl...@redhat.com --- randr/randrstr.h | 10 ++ randr/rrdispatch.c |2 +- randr/rrprovider.c | 54 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/randr/randrstr.h b/randr/randrstr.h index d7b0804..64c9afb 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -165,6 +165,7 @@ struct _rrProvider { int nameLength; RRPropertyPtr properties; Bool pendingProperties; +struct _rrProvider *offload_sink; struct _rrProvider *output_source; }; @@ -231,6 +232,11 @@ typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen, RRProviderPtr provider, RRProviderPtr output_source); +typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr offload_sink); + + /* These are for 1.0 compatibility */ typedef struct _rrRefresh { @@ -283,6 +289,7 @@ typedef struct _rrScrPriv { RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap; RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource; +RRProviderSetOffloadSinkProcPtr rrProviderSetOffloadSink; RRProviderGetPropertyProcPtr rrProviderGetProperty; RRProviderSetPropertyProcPtr rrProviderSetProperty; /* @@ -893,6 +900,9 @@ ProcRRGetProviderInfo(ClientPtr client); extern _X_EXPORT int ProcRRSetProviderOutputSource(ClientPtr client); +extern _X_EXPORT int +ProcRRSetProviderOffloadSink(ClientPtr client); + extern _X_EXPORT Bool RRProviderInit(void); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index 6fe51c7..1942d74 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -245,7 +245,7 @@ int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = { /* V1.4 additions */ ProcRRGetProviders, /* 32 */ ProcRRGetProviderInfo, /* 33 */ -NULL, /* 34 */ +ProcRRSetProviderOffloadSink, /* 34 */ ProcRRSetProviderOutputSource, /* 35 */ ProcRRListProviderProperties,/* 36 */ ProcRRQueryProviderProperty, /* 37 */ diff --git a/randr/rrprovider.c b/randr/rrprovider.c index bf53d8b..cd353a0 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -175,10 +175,15 @@ ProcRRGetProviderInfo (ClientPtr client) /* count associated providers */ rep.nAssociatedProviders = 0; +if (provider-offload_sink) +rep.nAssociatedProviders++; if (provider-output_source) rep.nAssociatedProviders++; xorg_list_for_each_entry(provscreen, pScreen-output_slave_list, output_head) rep.nAssociatedProviders++; +xorg_list_for_each_entry(provscreen, pScreen-offload_slave_list, offload_head) +rep.nAssociatedProviders++; + rep.length = (pScrPriv-numCrtcs + pScrPriv-numOutputs + (rep.nAssociatedProviders * 2) + bytes_to_int32(rep.nameLength)); @@ -210,6 +215,15 @@ ProcRRGetProviderInfo (ClientPtr client) } i = 0; +if (provider-offload_sink) { +providers[i] = provider-offload_sink-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SinkOffload; +if (client-swapped) +swapl(prov_cap[i]); +i++; +} if (provider-output_source) { providers[i] = provider-output_source-id; if (client-swapped) @@ -228,6 +242,17 @@ ProcRRGetProviderInfo (ClientPtr client) swapl(prov_cap[i]); i++; } +xorg_list_for_each_entry(provscreen, pScreen-offload_slave_list, offload_head) { +pScrProvPriv = rrGetScrPriv(provscreen); +providers[i] = pScrProvPriv-provider-id; +if (client-swapped) +swapl(providers[i]); +prov_cap[i] = RR_Capability_SourceOffload; +if (client-swapped) +swapl(prov_cap[i]); +i++; +} + memcpy(name, provider-name, rep.nameLength); if (client-swapped) { @@ -279,6 +304,35 @@ ProcRRSetProviderOutputSource(ClientPtr client) return Success; } +int +ProcRRSetProviderOffloadSink(ClientPtr client) +{ +REQUEST(xRRSetProviderOffloadSinkReq); +rrScrPrivPtr pScrPriv; +RRProviderPtr provider, sink_provider = NULL; +ScreenPtr pScreen; + +REQUEST_AT_LEAST_SIZE(xRRSetProviderOffloadSinkReq); + +VERIFY_RR_PROVIDER(stuff-provider, provider, DixReadAccess); +if (!(provider-capabilities RR_Capability_SourceOffload)) +return BadValue; + +if (stuff-sink_provider) { +VERIFY_RR_PROVIDER(stuff-sink_provider, sink_provider, DixReadAccess); +if (!(sink_provider-capabilities
[PATCH 25/29] xf86: add callback for offloak sink setting support.
From: Dave Airlie airl...@redhat.com This adds support for setting the offload sink to the xf86 ddx. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c|5 - hw/xfree86/modes/xf86RandR12.c | 27 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 9e43c40..e5f58e7 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -728,7 +728,10 @@ xf86CrtcCloseScreen(ScreenPtr screen) /* detach any providers */ if (config-randr_provider) { -if (config-randr_provider-output_source) { +if (config-randr_provider-offload_sink) { +DetachOffloadGPU(screen); +config-randr_provider-offload_sink = NULL; +} else if (config-randr_provider-output_source) { DetachOutputGPU(screen); config-randr_provider-output_source = NULL; } else diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index ce1bfe3..079331f 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1791,6 +1791,32 @@ xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen, } static Bool +xf86RandR14ProviderSetOffloadSink(ScreenPtr pScreen, + RRProviderPtr provider, + RRProviderPtr sink_provider) +{ +if (!sink_provider) { +if (provider-offload_sink) { +ScreenPtr cmScreen = pScreen-current_master; +DetachOutputGPU(pScreen); +AttachUnboundGPU(cmScreen, pScreen); +} + +provider-offload_sink = NULL; +return TRUE; +} + +if (provider-offload_sink == sink_provider) +return TRUE; + +DetachUnboundGPU(pScreen); +AttachOffloadGPU(sink_provider-pScreen, pScreen); + +provider-offload_sink = sink_provider; +return TRUE; +} + +static Bool xf86RandR14ProviderSetProperty(ScreenPtr pScreen, RRProviderPtr randr_provider, Atom property, RRPropertyValuePtr value) @@ -1858,6 +1884,7 @@ xf86RandR12Init12(ScreenPtr pScreen) rp-rrSetConfig = NULL; rp-rrProviderSetOutputSource = xf86RandR14ProviderSetOutputSource; +rp-rrProviderSetOffloadSink = xf86RandR14ProviderSetOffloadSink; rp-rrProviderSetProperty = xf86RandR14ProviderSetProperty; rp-rrProviderGetProperty = xf86RandR14ProviderGetProperty; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 26/29] dix/randr: add a hook into screen to replace scanout pixmap
From: Dave Airlie airl...@redhat.com For DRI2 in some offload cases we need to set a new pixmap on the crtc, this hook allows dri2 to call into randr to do the necessary work to set a pixmap as the scanout pixmap for the crtc the drawable is currently on. This is really only to be used for unredirected full screen apps in composited environments. Signed-off-by: Dave Airlie airl...@redhat.com --- include/scrnintstr.h |3 +++ randr/randr.c|2 +- randr/randrstr.h |3 +++ randr/rrcrtc.c | 58 ++ 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 80601b9..df74073 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -351,6 +351,8 @@ typedef Bool (*StartPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr, typedef Bool (*StopPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr); +typedef Bool (*ReplaceScanoutPixmapProcPtr)(DrawablePtr, PixmapPtr, Bool); + typedef struct _Screen { int myNum; /* index of this instance in Screens[] */ ATOM id; @@ -510,6 +512,7 @@ typedef struct _Screen { struct xorg_list offload_slave_list; struct xorg_list offload_head; +ReplaceScanoutPixmapProcPtr ReplaceScanoutPixmap; } ScreenRec; static inline RegionPtr diff --git a/randr/randr.c b/randr/randr.c index ae81166..3050c54 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -324,7 +324,7 @@ RRScreenInit(ScreenPtr pScreen) wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen); pScreen-ConstrainCursorHarder = RRConstrainCursorHarder; - +pScreen-ReplaceScanoutPixmap = RRReplaceScanoutPixmap; pScrPriv-numOutputs = 0; pScrPriv-outputs = NULL; pScrPriv-numCrtcs = 0; diff --git a/randr/randrstr.h b/randr/randrstr.h index 64c9afb..968cd30 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -678,6 +678,9 @@ extern _X_EXPORT void extern _X_EXPORT void RRCrtcDetachScanoutPixmap(RRCrtcPtr crtc); +extern _X_EXPORT Bool + RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable); + /* * Crtc dispatch */ diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 949ae60..1a6e593 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1641,3 +1641,61 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x, return; } } + +Bool +RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable) +{ +rrScrPriv(pDrawable-pScreen); +int i; +Bool size_fits = FALSE; +Bool changed = FALSE; +Bool ret = TRUE; + +for (i = 0; i pScrPriv-numCrtcs; i++) { +RRCrtcPtr crtc = pScrPriv-crtcs[i]; + +if (!crtc-mode enable) +continue; + +changed = FALSE; +if (crtc-mode crtc-x == pDrawable-x +crtc-y == pDrawable-y +crtc-mode-mode.width == pDrawable-width +crtc-mode-mode.height == pDrawable-height) +size_fits = TRUE; + +/* is the pixmap already set? */ +if (crtc-scanout_pixmap == pPixmap) { +/* if its a disable then don't care about size */ +if (enable == FALSE) { +/* set scanout to NULL */ +crtc-scanout_pixmap = NULL; +changed = TRUE; +} else { +/* if the size fits then we are already setup */ +if (size_fits) +return TRUE; +/* if the size no longer fits then drop off */ +crtc-scanout_pixmap = NULL; +changed = TRUE; +ret = FALSE; +} +} else { +if (!size_fits) +return FALSE; +if (enable) { +crtc-scanout_pixmap = pPixmap; +pScrPriv-rrCrtcSetScanoutPixmap(crtc, pPixmap); +changed = TRUE; +} +} + +if (changed pScrPriv-rrCrtcSet) { +pScrPriv-rrCrtcSetScanoutPixmap(crtc, crtc-scanout_pixmap); + +(*pScrPriv-rrCrtcSet) (pDrawable-pScreen, crtc, crtc-mode, crtc-x, crtc-y, +crtc-rotation, crtc-numOutputs, crtc-outputs); +} +} +return ret; +} -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 28/29] xf86: make sure rotate calcs are done on the right screen boundaries
From: Dave Airlie airl...@redhat.com This fixes a segfault where this code believes we are outside the screen boundaries on a slave device, but we aren't. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Rotate.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 31e0372..a393747 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -322,6 +322,12 @@ xf86CrtcFitsScreen(xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb) /* When called before PreInit, the driver is * presumably doing load detect */ +if (pScrn-is_gpu) { + ScreenPtr pScreen = xf86ScrnToScreen(pScrn); + if (pScreen-current_master) + pScrn = xf86ScreenToScrn(pScreen-current_master); +} + if (pScrn-virtualX == 0 || pScrn-virtualY == 0) return TRUE; -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 29/29] xf86crtc: detach scanout pixmap before randr tries
From: Dave Airlie airl...@redhat.com this stops us trying to use the master after we've detached later. Signed-off-by: Dave Airlie airl...@redhat.com --- hw/xfree86/modes/xf86Crtc.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index e5f58e7..aebf67b 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -726,6 +726,19 @@ xf86CrtcCloseScreen(ScreenPtr screen) xf86RotateCloseScreen(screen); +for (o = 0; o config-num_output; o++) { +xf86OutputPtr output = config-output[o]; + +output-randr_output = NULL; +} +for (c = 0; c config-num_crtc; c++) { +xf86CrtcPtr crtc = config-crtc[c]; + +if (crtc-randr_crtc-scanout_pixmap) +RRCrtcDetachScanoutPixmap(crtc-randr_crtc); + +crtc-randr_crtc = NULL; +} /* detach any providers */ if (config-randr_provider) { if (config-randr_provider-offload_sink) { @@ -737,16 +750,6 @@ xf86CrtcCloseScreen(ScreenPtr screen) } else DetachUnboundGPU(screen); } -for (o = 0; o config-num_output; o++) { -xf86OutputPtr output = config-output[o]; - -output-randr_output = NULL; -} -for (c = 0; c config-num_crtc; c++) { -xf86CrtcPtr crtc = config-crtc[c]; - -crtc-randr_crtc = NULL; -} xf86RandR12CloseScreen(screen); return screen-CloseScreen(screen); -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 04/29] dix: add unattached list for attaching screens to initially. (v1.1)
From: Dave Airlie airl...@redhat.com This list is meant for attaching unbound gpu screens to initially, before the client side rebinds them. v1.1: add another assert in the add path. Signed-off-by: Dave Airlie airl...@redhat.com --- dix/dispatch.c | 20 include/screenint.h |5 + include/scrnintstr.h |6 ++ 3 files changed, 31 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index fa39728..9e84621 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3742,6 +3742,8 @@ static int init_screen(ScreenPtr pScreen, int i, Bool gpu) pScreen-ClipNotify = 0;/* for R4 ddx compatibility */ pScreen-CreateScreenResources = 0; +xorg_list_init(pScreen-unattached_list); + /* * This loop gets run once for every Screen that gets added, * but thats ok. If the ddx layer initializes the formats @@ -3889,3 +3891,21 @@ RemoveGPUScreen(ScreenPtr pScreen) free(pScreen); } + +void +AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new) +{ +assert(new-isGPU); +assert(!new-current_master); +xorg_list_add(new-unattached_head, pScreen-unattached_list); +new-current_master = pScreen; +} + +void +DetachUnboundGPU(ScreenPtr slave) +{ +assert(slave-isGPU); +xorg_list_del(slave-unattached_head); +slave-current_master = NULL; +} + diff --git a/include/screenint.h b/include/screenint.h index 8205f63..c0c60ef 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -71,6 +71,11 @@ extern _X_EXPORT int AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , extern _X_EXPORT void RemoveGPUScreen(ScreenPtr pScreen); +extern _X_EXPORT void +AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new); +extern _X_EXPORT void +DetachUnboundGPU(ScreenPtr unbound); + typedef struct _ColormapRec *ColormapPtr; #endif /* SCREENINT_H */ diff --git a/include/scrnintstr.h b/include/scrnintstr.h index bcac475..6b738de 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -479,6 +479,12 @@ typedef struct _Screen { Bool canDoBGNoneRoot; Bool isGPU; + +struct xorg_list unattached_list; +struct xorg_list unattached_head; + +ScreenPtr current_master; + } ScreenRec; static inline RegionPtr -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 09/36] xfree86: add platform bus hotplug support (v3)
Dave Airlie airl...@gmail.com writes: + +for (layout = xf86ConfigLayout.screens; layout-screen != NULL; + layout++) { +xf86GPUScreens[i]-confScreen = layout-screen; +break; +} This loop is insane. Otherwise, this is all Reviewed-by: Keith Packard kei...@keithp.com -- keith.pack...@intel.com pgp91fobDpqYv.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 10/36] xfree86: add autoAddGPU option (v2)
Dave Airlie airl...@gmail.com writes: From: Dave Airlie airl...@redhat.com This option is to stop the X server adding non-primary devices as gpu screens. v2: fix per Keith's suggestion. Reviewed-by: Keith Packard kei...@keithp.com -- keith.pack...@intel.com pgp5oxD3CJ2yJ.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 09/29] dix: pixmap sharing infrastructure (v3)
From: Dave Airlie airl...@redhat.com This is a hooks for pixmap sharing and tracking. The pixmap sharing ones get an integer handle for the pixmap and use a handle to be the backing for a pixmap. The tracker interface is to be used when a GPU needs to track pixmaps to be updated for another GPU. v2: pass slave to sharing so it can use it to work out driver. v3: use void * as per keithp's suggestion. Reviewed-by: Keith Packard kei...@keithp.com Signed-off-by: Dave Airlie airl...@redhat.com --- include/scrnintstr.h | 17 + 1 file changed, 17 insertions(+) diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 7efc5c3..3a738d3 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -179,6 +179,8 @@ typedef void (*ClipNotifyProcPtr) (WindowPtr /*pWindow */ , #define CREATE_PIXMAP_USAGE_BACKING_PIXMAP 2 /* pixmap will contain a glyph */ #define CREATE_PIXMAP_USAGE_GLYPH_PICTURE 3 +/* pixmap will be shared */ +#define CREATE_PIXMAP_USAGE_SHARED 4 typedef PixmapPtr (*CreatePixmapProcPtr) (ScreenPtr /*pScreen */ , int /*width */ , @@ -339,6 +341,16 @@ typedef void (*DeviceCursorCleanupProcPtr) (DeviceIntPtr /* pDev */ , typedef void (*ConstrainCursorHarderProcPtr) (DeviceIntPtr, ScreenPtr, int, int *, int *); + +typedef Bool (*SharePixmapBackingProcPtr)(PixmapPtr, ScreenPtr, void **); + +typedef Bool (*SetSharedPixmapBackingProcPtr)(PixmapPtr, void *); + +typedef Bool (*StartPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr, + int x, int y); + +typedef Bool (*StopPixmapTrackingProcPtr)(PixmapPtr, PixmapPtr); + typedef struct _Screen { int myNum; /* index of this instance in Screens[] */ ATOM id; @@ -488,6 +500,11 @@ typedef struct _Screen { struct xorg_list output_slave_list; struct xorg_list output_head; +SharePixmapBackingProcPtr SharePixmapBacking; +SetSharedPixmapBackingProcPtr SetSharedPixmapBacking; + +StartPixmapTrackingProcPtr StartPixmapTracking; +StopPixmapTrackingProcPtr StopPixmapTracking; } ScreenRec; static inline RegionPtr -- 1.7.10.2 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 05/16] xserver: move testing startup to the XServer object
On 07/03/2012 10:34 PM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 10:30:28AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net It makes sense to move the startup to the XServer object, but the environment should then contain an XServer object and start it. The point of the environment is that it starts up an xserver automatically. The xorg-gtest user is free to not use the environment. But when they use the environment, it should start a server. It still does, it's just cut off from the Environment::SetUp() hunk though. see below --- include/xorg/gtest/xorg-gtest-xserver.h |2 ++ src/environment.cpp | 35 --- src/xserver.cpp | 40 +++ 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h index 5c5ce99..52a2fd0 100644 --- a/include/xorg/gtest/xorg-gtest-xserver.h +++ b/include/xorg/gtest/xorg-gtest-xserver.h @@ -129,6 +129,8 @@ class XServer : public xorg::testing::Process { XServer(const XServer); XServer operator=(const XServer); +void TestStartup(void); + }; } // namespace testing } // namespace xorg diff --git a/src/environment.cpp b/src/environment.cpp index 7ed23b3..69972a4 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -106,41 +106,6 @@ void xorg::testing::Environment::SetUp() { static char display_string[6]; snprintf(display_string, 6, :%d, d_-display); - Display* test_display = XOpenDisplay(display_string); - if (test_display) { -XCloseDisplay(test_display); -std::string message; -message += A server is already running on ; -message += display_string; -message += .; -throw std::runtime_error(message); - } - - /* The Xorg server won't start unless the log file and the old log file are - * writable. */ - std::ofstream log_test; - log_test.open(d_-path_to_log_file.c_str(), std::ofstream::out); - log_test.close(); - if (log_test.fail()) { -std::string message; -message += X.org server log file ; -message += d_-path_to_log_file; -message += is not writable.; -throw std::runtime_error(message); - } - - std::string old_log_file = d_-path_to_log_file.c_str(); - old_log_file += .old; - log_test.open(old_log_file.c_str(), std::ofstream::out); - log_test.close(); - if (log_test.fail()) { -std::string message; -message += X.org old server log file ; -message += old_log_file; -message += is not writable.; -throw std::runtime_error(message); - } - d_-server.SetDisplayNumber(d_-display); d_-server.SetLogfilePath(d_-path_to_log_file); d_-server.SetConfigPath(d_-path_to_conf); is followed by d_-server.Start(d_-path_to_server); d_-server.WaitForConnections(); So nothing should change over the previous code. I haven't modified the xi2.cpp code in the server which uses this environment and it still works. Ahh, right, the code still starts the server, but shouldn't we be calling the server TestStartup() method before? As it is in this patch, we've removed a bunch of code, moved it to a method of a different object, and haven't called the method to ensure the same code is executed. Unless I'm misreading again :). diff --git a/src/xserver.cpp b/src/xserver.cpp index 38394f3..1a46dbb 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -41,6 +41,7 @@ #include cstring #include stdexcept #include vector +#include fstream #include X11/Xlib.h #include X11/extensions/XInput2.h @@ -250,7 +251,46 @@ void xorg::testing::XServer::WaitForConnections(void) { throw std::runtime_error(Unable to open connection to dummy X server); } +void xorg::testing::XServer::TestStartup(void) { + Display* test_display = XOpenDisplay(GetDisplayString()); + if (test_display) { +XCloseDisplay(test_display); +std::string message; +message += A server is already running on ; +message += GetDisplayString(); +message += .; +throw std::runtime_error(message); + } + + /* The Xorg server won't start unless the log file and the old log file are + * writable. */ + std::ofstream log_test; + log_test.open(d_-path_to_logfile.c_str(), std::ofstream::out); + log_test.close(); + if (log_test.fail()) { +std::string message; +message += X.org server log file ; +message += d_-path_to_logfile; +message += is not writable.; +throw std::runtime_error(message); + } + + std::string old_log_file = d_-path_to_logfile.c_str(); + old_log_file += .old; + log_test.open(old_log_file.c_str(), std::ofstream::out); + log_test.close(); + if (log_test.fail()) { +std::string message; +message += X.org old server log file ; +message += old_log_file; +message += is not writable.; +throw std::runtime_error(message); + } + +} + void
Re: [PATCH 1/3] Add screen-specific privates.
Keith Packard kei...@keithp.com writes: Screen-specific privates areas are only allocated for objects related to the target screen; objects allocated for other screens will not have the private space reserved. This saves memory in these objects while also allowing hot-plug screens to have additional private allocation space beyond what the core screens are using. Drivers are encouraged to switch to this mechanism as it will reduce memory usage in multi-GPU environments, but it is only required for drivers which will be loaded after the server starts, like modesetting. Objects providing screen-specific privates *must* be managed by the screen-specific private API when allocating or initializing privates so that the per-screen area can be initialized properly. The objects which support screen-specific privates are: Windows Pixmaps GCs Pictures Extending this list to include Colormaps would be possible, but require slightly more work as the default colormap is created before all colormap privates are allocated during server startup, and hence gets a bunch of special treatment. Of particular note, glyphs are *not* capable of supporting screen-specific privates as they are global objects, not allocated on a screen-specific basis, and so each driver must be able to see their privates within the glyph. Signed-off-by: Keith Packard kei...@keithp.com This sequence, including some patches to fix up midispcur to support GPU hotplug has been Merged, with Reviewed-by: Dave Airlie airl...@redhat.com: ed6daa1..9e4b8b7 master - master -- keith.pack...@intel.com pgpLDLZ5knNwL.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 06/16] xserver: move Terminate and Kill handling here
On 07/03/2012 10:42 PM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 10:33:50AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- include/xorg/gtest/xorg-gtest-xserver.h | 13 src/environment.cpp | 31 +++- src/xserver.cpp | 34 +++ 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h index 52a2fd0..821b01f 100644 --- a/include/xorg/gtest/xorg-gtest-xserver.h +++ b/include/xorg/gtest/xorg-gtest-xserver.h @@ -53,6 +53,19 @@ class XServer : public xorg::testing::Process { void Start(std::string program); /** + * Terminates this server process. Will signal the server to terminate + * multiple times before giving up. + * + * @return false if the server did not terminate, true otherwise + */ +bool Terminate(void); + +/** + * Kills the server. With a vengeance. + */ +bool Kill(void); We don't need to recreate these functions. We've already inherited them from xorg::testing::Process. Those implementations should work automatically if we set up the XServer class properly. The implementation is different to the one in Process, this one does the server-specific bits like waiting for the process to shut down and then complaining to the log. I read too quickly to realize the difference between the Environment/XServer implementation and the Process implementation, but I'm wondering if we should just move the extra stuff to the Process implementation. Then we won't need to do any redefinition or overriding. If we do still want separate implementations, I think we still want to override instead of redefine. The main reason you want to override rather than redefine is to ensure the correct method is always called for a given object. If you only have a superclass handle of an object, the subclass method is still called: Subclass sub; Superclass super = dynamic_castSuperclass(sub); super.Terminate(); // This still calls Subclass.Terminate() All you need to do to make the method override rather than redefine is to add the 'virtual' keyword in front of the method declaration in the base class (though most people also put it in front of the declaration in the derived class as book-keeping). You can also delete the documentation if you want, since the Doxygen config is set up to inherit the documentation :). + +/** * Waits until this server is ready to take connections. */ void WaitForConnections(void); diff --git a/src/environment.cpp b/src/environment.cpp index 69972a4..b041236 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -116,35 +116,10 @@ void xorg::testing::Environment::SetUp() { } void xorg::testing::Environment::TearDown() { - if (d_-server.Terminate()) { -for (int i = 0; i 10; i++) { - int status; - int pid = waitpid(d_-server.Pid(), status, WNOHANG); - - if (pid == d_-server.Pid()) -return; - - sleep(1); /* Give the dummy X server more time to shut down */ -} - } - - Kill(); + if (!d_-server.Terminate()) +Kill(); } void xorg::testing::Environment::Kill() { - if (!d_-server.Kill()) -std::cerr Warning: Failed to kill dummy Xorg server: - std::strerror(errno) \n; - - for (int i = 0; i 10; i++) { -int status; -int pid = waitpid(d_-server.Pid(), status, WNOHANG); - -if (pid == d_-server.Pid()) - return; - - sleep(1); /* Give the dummy X server more time to shut down */ - } - - std::cerr Warning: Dummy X server did not shut down\n; + d_-server.Kill(); } diff --git a/src/xserver.cpp b/src/xserver.cpp index 1a46dbb..bd1e2f9 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -298,3 +298,37 @@ void xorg::testing::XServer::Start(std::string program) { -config, d_-path_to_conf.c_str(), NULL); } + +bool xorg::testing::XServer::Terminate(void) { + if (Process::Terminate()) { +for (int i = 0; i 10; i++) { + int status; + int pid = waitpid(Pid(), status, WNOHANG); + + if (pid == Pid()) +return true; + + sleep(1); /* Give the dummy X server more time to shut down */ +} + } + return false; +} + +bool xorg::testing::XServer::Kill(void) { + if (!Process::Kill()) +std::cerr Warning: Failed to kill dummy Xorg server: + std::strerror(errno) \n; + + for (int i = 0; i 10; i++) { +int status; +int pid = waitpid(Pid(), status, WNOHANG); + +if (pid == Pid()) + return true; + + sleep(1); /* Give the dummy X server more time to shut down */ + } + + std::cerr Warning: Dummy X server did not shut down\n; + return false; +} ___
Re: [PATCH xorg-gtest 09/16] environment: remove default settings
On 07/04/2012 04:36 AM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 10:53:28AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: Keep those in the server only, not the environment. And only override the build-in ones when they've been set by main. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- src/environment.cpp | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index b041236..01b2148 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -28,7 +28,6 @@ #include xorg/gtest/xorg-gtest-environment.h #include xorg/gtest/xorg-gtest-process.h #include xorg/gtest/xorg-gtest-xserver.h -#include defines.h #include sys/types.h #include unistd.h @@ -44,11 +43,8 @@ #include X11/Xlib.h struct xorg::testing::Environment::Private { - Private() - : path_to_conf(DUMMY_CONF_PATH), path_to_log_file(DEFAULT_XORG_LOGFILE), -path_to_server(DEFAULT_XORG_SERVER), display(DEFAULT_DISPLAY) { + Private() : display(-1) { } - std::string path_to_conf; std::string path_to_log_file; std::string path_to_server; @@ -103,15 +99,23 @@ int xorg::testing::Environment::display() const } void xorg::testing::Environment::SetUp() { + unsigned int display_used; static char display_string[6]; snprintf(display_string, 6, :%d, d_-display); - d_-server.SetDisplayNumber(d_-display); - d_-server.SetLogfilePath(d_-path_to_log_file); - d_-server.SetConfigPath(d_-path_to_conf); - d_-server.Start(d_-path_to_server); + if (d_-display = 0) +d_-server.SetDisplayNumber(d_-display); + if (d_-path_to_log_file.length()) +d_-server.SetLogfilePath(d_-path_to_log_file); + if (d_-path_to_conf.length()) +d_-server.SetConfigPath(d_-path_to_conf); + if (d_-path_to_server.length()) +display_used = d_-server.Start(d_-path_to_server); + else +display_used = d_-server.Start(); d_-server.WaitForConnections(); + snprintf(display_string, 6, :%d, display_used); Process::SetEnv(DISPLAY, display_string, true); } Rather than store the values in two places (environment and server objects), we can simply remove the values from the environment and manipulate the server directly. Either: * The environment has a method like: XServer Environment::XServer(); And then you modify things like: environment.XServer().SetDisplayNumber(value); * Provide pass through functions like: void Environment::SetDisplayNumber(int value) { d_-server.SetDisplayNumber(value); } And then you modify things like: environment.SetDisplayNumber(value); The first approach is a bit easier to code (less boilerplate pass-through functions), but it violates the Tell, don't ask policy that many object-oriented APIs follow. I would prefer the second approach because I think it is easier for the end-user to follow and understand. They don't have to hunt around in multiple classes to do what they want to do. works for me, but what is your need for preserving API atm? Environment and XServer have two different naming conventions, I decided to stick with the googletest CamelCase one, environment partially uses the latter. The standard Google style guide says to use lowercase_underscore for variable and member names, and then to use set_variable() and variable() for setters and getters. This is one of my least favorite aspects of their style guide, but I tend to just try to conform rather than do my own thing, so I stuck with it. Things obviously get murkier when your getter and setter aren't actually getting and setting direct members, but maybe are passing the value on to another object's getter or setter. I'm fine with replacing those and align them with XServer, but it may break your other clients. If we want to continue using the Google style, then we should follow its spirit and use set_display_number(), for example. If we want to break with it for getters and setters, then lets do it now and define new methods for the old ones, and call the new methods from them. I'm about 60-40 on the decision to keep with the current format, just because it's easier not to have a transition :). But I won't throw a fight if you want to change it. -- Chase ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 16/16] Add Device::GetDeviceNode() to return device node path from an evemu device
On 07/03/2012 11:03 PM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 11:40:25AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: evemu doesn't export this information and even evemu-device just trawls through the file system to print this info. So do the same here, noting the time before evemu_create() and the ctime of the new device file. If the latter is later than the former and the device names match, we can assume this is our device. I just want to point out that it's a deficiency in uinput, not in evemu, in case anyone had any thoughts of trying to fix evemu instead. I did try. This could easily be part of evemu, running this exact same code right after the UI_DEV_CREATE call. Unfortunately evemu_create() takes a const struct so we can't save it easily without breaking ABI. Well, evemu could try to guess, just as this code does. What I meant was more that uinput is deficient in that there's no way to be 100% sure. That's the main reason why we didn't bother putting code like this into evemu directly. -- Chase ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xorg-gtest 1/2] Switch from utouch-evemu to evemu
The upstream project has been renamed. Signed-off-by: Chase Douglas chase.doug...@canonical.com --- aclocal/xorg-gtest.m4 |6 +++--- configure.ac |6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aclocal/xorg-gtest.m4 b/aclocal/xorg-gtest.m4 index 062842c..a8e0204 100644 --- a/aclocal/xorg-gtest.m4 +++ b/aclocal/xorg-gtest.m4 @@ -74,7 +74,7 @@ AC_DEFUN([CHECK_XORG_GTEST], PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no]) - # Check if we should include support for utouch-evemu + # Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback @@ -83,10 +83,10 @@ AC_DEFUN([CHECK_XORG_GTEST], [with_evemu=check]) AS_IF([test x$with_evemu = xyes], -[PKG_CHECK_MODULES(EVEMU, [utouch-evemu], [have_xorg_gtest_evemu=yes])], +[PKG_CHECK_MODULES(EVEMU, [evemu], [have_xorg_gtest_evemu=yes])], [test x$with_evemu = xcheck], [PKG_CHECK_MODULES(EVEMU, - [utouch-evemu], + [evemu], [have_xorg_gtest_evemu=yes], [have_xorg_gtest_evemu=no])]) AS_IF([test x$have_xorg_gtest_evemu = xyes], diff --git a/configure.ac b/configure.ac index 6e9e458..611df5a 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ AS_IF([test x$have_gtest != xyes], AC_SUBST([GTEST_CPPFLAGS]) -# Check if we should include support for utouch-evemu +# Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback (default: enabled if available)])], @@ -43,9 +43,9 @@ AC_ARG_WITH([evemu], [with_evemu=check]) AS_IF([test x$with_evemu == xyes], - [PKG_CHECK_MODULES(EVEMU, utouch-evemu, [have_evemu=yes])], + [PKG_CHECK_MODULES(EVEMU, evemu, [have_evemu=yes])], [test x$with_evemu == xcheck], - [PKG_CHECK_MODULES(EVEMU, utouch-evemu, [have_evemu=yes], [:])]) + [PKG_CHECK_MODULES(EVEMU, evemu, [have_evemu=yes], [:])]) AM_CONDITIONAL([HAVE_EVEMU], [test x$have_evemu = xyes]) AS_IF([test x$have_evemu = xyes], [AC_DEFINE([HAVE_EVEMU])]) -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 05/16] xserver: move testing startup to the XServer object
On Thu, Jul 05, 2012 at 01:46:42PM -0700, Chase Douglas wrote: On 07/03/2012 10:34 PM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 10:30:28AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net It makes sense to move the startup to the XServer object, but the environment should then contain an XServer object and start it. The point of the environment is that it starts up an xserver automatically. The xorg-gtest user is free to not use the environment. But when they use the environment, it should start a server. It still does, it's just cut off from the Environment::SetUp() hunk though. see below --- include/xorg/gtest/xorg-gtest-xserver.h |2 ++ src/environment.cpp | 35 --- src/xserver.cpp | 40 +++ 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h index 5c5ce99..52a2fd0 100644 --- a/include/xorg/gtest/xorg-gtest-xserver.h +++ b/include/xorg/gtest/xorg-gtest-xserver.h @@ -129,6 +129,8 @@ class XServer : public xorg::testing::Process { XServer(const XServer); XServer operator=(const XServer); +void TestStartup(void); + }; } // namespace testing } // namespace xorg diff --git a/src/environment.cpp b/src/environment.cpp index 7ed23b3..69972a4 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -106,41 +106,6 @@ void xorg::testing::Environment::SetUp() { static char display_string[6]; snprintf(display_string, 6, :%d, d_-display); - Display* test_display = XOpenDisplay(display_string); - if (test_display) { -XCloseDisplay(test_display); -std::string message; -message += A server is already running on ; -message += display_string; -message += .; -throw std::runtime_error(message); - } - - /* The Xorg server won't start unless the log file and the old log file are - * writable. */ - std::ofstream log_test; - log_test.open(d_-path_to_log_file.c_str(), std::ofstream::out); - log_test.close(); - if (log_test.fail()) { -std::string message; -message += X.org server log file ; -message += d_-path_to_log_file; -message += is not writable.; -throw std::runtime_error(message); - } - - std::string old_log_file = d_-path_to_log_file.c_str(); - old_log_file += .old; - log_test.open(old_log_file.c_str(), std::ofstream::out); - log_test.close(); - if (log_test.fail()) { -std::string message; -message += X.org old server log file ; -message += old_log_file; -message += is not writable.; -throw std::runtime_error(message); - } - d_-server.SetDisplayNumber(d_-display); d_-server.SetLogfilePath(d_-path_to_log_file); d_-server.SetConfigPath(d_-path_to_conf); is followed by d_-server.Start(d_-path_to_server); d_-server.WaitForConnections(); So nothing should change over the previous code. I haven't modified the xi2.cpp code in the server which uses this environment and it still works. Ahh, right, the code still starts the server, but shouldn't we be calling the server TestStartup() method before? As it is in this patch, we've removed a bunch of code, moved it to a method of a different object, and haven't called the method to ensure the same code is executed. Unless I'm misreading again :). hard to see from the patch I guess, but the new sequence is Environment::SetUp() ... XServer::Start() XServer::TestStartup() Process::Start() Cheers, Peter diff --git a/src/xserver.cpp b/src/xserver.cpp index 38394f3..1a46dbb 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -41,6 +41,7 @@ #include cstring #include stdexcept #include vector +#include fstream #include X11/Xlib.h #include X11/extensions/XInput2.h @@ -250,7 +251,46 @@ void xorg::testing::XServer::WaitForConnections(void) { throw std::runtime_error(Unable to open connection to dummy X server); } +void xorg::testing::XServer::TestStartup(void) { + Display* test_display = XOpenDisplay(GetDisplayString()); + if (test_display) { +XCloseDisplay(test_display); +std::string message; +message += A server is already running on ; +message += GetDisplayString(); +message += .; +throw std::runtime_error(message); + } + + /* The Xorg server won't start unless the log file and the old log file are + * writable. */ + std::ofstream log_test; + log_test.open(d_-path_to_logfile.c_str(), std::ofstream::out); + log_test.close(); + if (log_test.fail()) { +std::string message; +message += X.org server log file ; +message += d_-path_to_logfile; +message += is not writable.; +throw
Re: [PATCH xorg-gtest 16/16] Add Device::GetDeviceNode() to return device node path from an evemu device
On Thu, Jul 05, 2012 at 02:19:33PM -0700, Chase Douglas wrote: On 07/03/2012 11:03 PM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 11:40:25AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: evemu doesn't export this information and even evemu-device just trawls through the file system to print this info. So do the same here, noting the time before evemu_create() and the ctime of the new device file. If the latter is later than the former and the device names match, we can assume this is our device. I just want to point out that it's a deficiency in uinput, not in evemu, in case anyone had any thoughts of trying to fix evemu instead. I did try. This could easily be part of evemu, running this exact same code right after the UI_DEV_CREATE call. Unfortunately evemu_create() takes a const struct so we can't save it easily without breaking ABI. Well, evemu could try to guess, just as this code does. What I meant was more that uinput is deficient in that there's no way to be 100% sure. That's the main reason why we didn't bother putting code like this into evemu directly. the one advantage evemu has though is that it's in the best position to guess given that it just created the device and has easy access to all other information. plus, it wouldn't require duplicating the code across other projects. Cheers, Peter ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-server] Fix xf86EdidModes.c: array subscript is above array bounds
Torsten Kaiser just.for.l...@googlemail.com writes: With this optimization level gcc notices, that the loop in function DDCModesFromEstIII() would go until i=5 and j=1 which would result in m = (5 * 8) + (7 - 1) = 46, but the array EstIIIModes[] only contains 44 elements. I'd like Adam's opinion; he wrote the original code and is the best person to verify that this does what the spec requires. On the face of it, it looks right to me though... -- keith.pack...@intel.com pgppmgmhOGWr2.pgp Description: PGP signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 2/2] Upgrade dox/Doxyfile
On Thu, Jul 05, 2012 at 03:40:59PM -0700, Chase Douglas wrote: Upgraded by running doxygen -u. Most of the changes involve stripping whitespace at the end of lines. Some new options were added, all left at the default values. Three obsolete options were removed. Signed-off-by: Chase Douglas chase.doug...@canonical.com --- doc/Doxyfile | 1654 +++--- 1 file changed, 884 insertions(+), 770 deletions(-) cursory Reviewed-by: Peter Hutterer peter.hutte...@who-t.net Cheers, Peter ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 1/2] Switch from utouch-evemu to evemu
On Thu, Jul 05, 2012 at 03:40:58PM -0700, Chase Douglas wrote: The upstream project has been renamed. Signed-off-by: Chase Douglas chase.doug...@canonical.com Reviewed-by: Peter Hutterer peter.hutte...@who-t.net Cheers, Peter --- aclocal/xorg-gtest.m4 |6 +++--- configure.ac |6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aclocal/xorg-gtest.m4 b/aclocal/xorg-gtest.m4 index 062842c..a8e0204 100644 --- a/aclocal/xorg-gtest.m4 +++ b/aclocal/xorg-gtest.m4 @@ -74,7 +74,7 @@ AC_DEFUN([CHECK_XORG_GTEST], PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no]) - # Check if we should include support for utouch-evemu + # Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback @@ -83,10 +83,10 @@ AC_DEFUN([CHECK_XORG_GTEST], [with_evemu=check]) AS_IF([test x$with_evemu = xyes], -[PKG_CHECK_MODULES(EVEMU, [utouch-evemu], [have_xorg_gtest_evemu=yes])], +[PKG_CHECK_MODULES(EVEMU, [evemu], [have_xorg_gtest_evemu=yes])], [test x$with_evemu = xcheck], [PKG_CHECK_MODULES(EVEMU, - [utouch-evemu], + [evemu], [have_xorg_gtest_evemu=yes], [have_xorg_gtest_evemu=no])]) AS_IF([test x$have_xorg_gtest_evemu = xyes], diff --git a/configure.ac b/configure.ac index 6e9e458..611df5a 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ AS_IF([test x$have_gtest != xyes], AC_SUBST([GTEST_CPPFLAGS]) -# Check if we should include support for utouch-evemu +# Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback (default: enabled if available)])], @@ -43,9 +43,9 @@ AC_ARG_WITH([evemu], [with_evemu=check]) AS_IF([test x$with_evemu == xyes], - [PKG_CHECK_MODULES(EVEMU, utouch-evemu, [have_evemu=yes])], + [PKG_CHECK_MODULES(EVEMU, evemu, [have_evemu=yes])], [test x$with_evemu == xcheck], - [PKG_CHECK_MODULES(EVEMU, utouch-evemu, [have_evemu=yes], [:])]) + [PKG_CHECK_MODULES(EVEMU, evemu, [have_evemu=yes], [:])]) AM_CONDITIONAL([HAVE_EVEMU], [test x$have_evemu = xyes]) AS_IF([test x$have_evemu = xyes], [AC_DEFINE([HAVE_EVEMU])]) -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-server] Fix xf86EdidModes.c: array subscript is above array bounds
On Thu, Jul 05, 2012 at 04:37:39PM -0700, Keith Packard wrote: Torsten Kaiser just.for.l...@googlemail.com writes: With this optimization level gcc notices, that the loop in function DDCModesFromEstIII() would go until i=5 and j=1 which would result in m = (5 * 8) + (7 - 1) = 46, but the array EstIIIModes[] only contains 44 elements. I'd like Adam's opinion; he wrote the original code and is the best person to verify that this does what the spec requires. On the face of it, it looks right to me though... I'm not a big fan of fixing two separate bugs in one patches though, I'd prefer to split out the out-of-bounds from the skipping last mode issue. Reviewed-by: Peter Hutterer peter.hutte...@who-t.net otherwise Cheers, Peter ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 06/16] xserver: move Terminate and Kill handling here
On Thu, Jul 05, 2012 at 02:09:13PM -0700, Chase Douglas wrote: On 07/03/2012 10:42 PM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 10:33:50AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- include/xorg/gtest/xorg-gtest-xserver.h | 13 src/environment.cpp | 31 +++- src/xserver.cpp | 34 +++ 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h index 52a2fd0..821b01f 100644 --- a/include/xorg/gtest/xorg-gtest-xserver.h +++ b/include/xorg/gtest/xorg-gtest-xserver.h @@ -53,6 +53,19 @@ class XServer : public xorg::testing::Process { void Start(std::string program); /** + * Terminates this server process. Will signal the server to terminate + * multiple times before giving up. + * + * @return false if the server did not terminate, true otherwise + */ +bool Terminate(void); + +/** + * Kills the server. With a vengeance. + */ +bool Kill(void); We don't need to recreate these functions. We've already inherited them from xorg::testing::Process. Those implementations should work automatically if we set up the XServer class properly. The implementation is different to the one in Process, this one does the server-specific bits like waiting for the process to shut down and then complaining to the log. I read too quickly to realize the difference between the Environment/XServer implementation and the Process implementation, but I'm wondering if we should just move the extra stuff to the Process implementation. Then we won't need to do any redefinition or overriding. I think we should keep Process basic. For most processes failing to kill it should be an issue in itself, it's just the server that takes too long to shut down and needs special handling. If we do still want separate implementations, I think we still want to override instead of redefine. The main reason you want to override rather than redefine is to ensure the correct method is always called for a given object. If you only have a superclass handle of an object, the subclass method is still called: Subclass sub; Superclass super = dynamic_castSuperclass(sub); super.Terminate(); // This still calls Subclass.Terminate() All you need to do to make the method override rather than redefine is to add the 'virtual' keyword in front of the method declaration in the base class (though most people also put it in front of the declaration in the derived class as book-keeping). You can also delete the documentation if you want, since the Doxygen config is set up to inherit the documentation :). years of Java have skewed my understanding of inhertiance and I only wrapped my head around the C++ way yesterday. I'll fix this up. Cheers, Peter + +/** * Waits until this server is ready to take connections. */ void WaitForConnections(void); diff --git a/src/environment.cpp b/src/environment.cpp index 69972a4..b041236 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -116,35 +116,10 @@ void xorg::testing::Environment::SetUp() { } void xorg::testing::Environment::TearDown() { - if (d_-server.Terminate()) { -for (int i = 0; i 10; i++) { - int status; - int pid = waitpid(d_-server.Pid(), status, WNOHANG); - - if (pid == d_-server.Pid()) -return; - - sleep(1); /* Give the dummy X server more time to shut down */ -} - } - - Kill(); + if (!d_-server.Terminate()) +Kill(); } void xorg::testing::Environment::Kill() { - if (!d_-server.Kill()) -std::cerr Warning: Failed to kill dummy Xorg server: - std::strerror(errno) \n; - - for (int i = 0; i 10; i++) { -int status; -int pid = waitpid(d_-server.Pid(), status, WNOHANG); - -if (pid == d_-server.Pid()) - return; - - sleep(1); /* Give the dummy X server more time to shut down */ - } - - std::cerr Warning: Dummy X server did not shut down\n; + d_-server.Kill(); } diff --git a/src/xserver.cpp b/src/xserver.cpp index 1a46dbb..bd1e2f9 100644 --- a/src/xserver.cpp +++ b/src/xserver.cpp @@ -298,3 +298,37 @@ void xorg::testing::XServer::Start(std::string program) { -config, d_-path_to_conf.c_str(), NULL); } + +bool xorg::testing::XServer::Terminate(void) { + if (Process::Terminate()) { +for (int i = 0; i 10; i++) { + int status; + int pid = waitpid(Pid(), status, WNOHANG); + + if (pid == Pid()) +return true; + + sleep(1); /* Give the dummy X server more time to shut down */ +} + } + return false; +} + +bool
[PATCH] glx: Fix checking GL version
Signed-off-by: Bartosz Brachaczek b.brachac...@gmail.com --- Hi, I looked at Ian's patch out of curiosity and spotted this typo. Not sure if I am supposed to send a full-blown patch for this, but I didn't have a better idea. glx/glxdri2.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 1e99179..2db12b6 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -481,7 +481,7 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, * don't support OpenGL 3.2 may fail the request for a core profile. */ if (*api == __DRI_API_OPENGL_CORE - (*major_ver 3 || (*major_ver 3 *minor_ver 2))) { + (*major_ver 3 || (*major_ver == 3 *minor_ver 2))) { *api == __DRI_API_OPENGL; } -- 1.7.8.6 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest 09/16] environment: remove default settings
On Thu, Jul 05, 2012 at 02:17:30PM -0700, Chase Douglas wrote: On 07/04/2012 04:36 AM, Peter Hutterer wrote: On Tue, Jul 03, 2012 at 10:53:28AM -0700, Chase Douglas wrote: On 07/02/2012 11:44 PM, Peter Hutterer wrote: Keep those in the server only, not the environment. And only override the build-in ones when they've been set by main. Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- src/environment.cpp | 22 +- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index b041236..01b2148 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -28,7 +28,6 @@ #include xorg/gtest/xorg-gtest-environment.h #include xorg/gtest/xorg-gtest-process.h #include xorg/gtest/xorg-gtest-xserver.h -#include defines.h #include sys/types.h #include unistd.h @@ -44,11 +43,8 @@ #include X11/Xlib.h struct xorg::testing::Environment::Private { - Private() - : path_to_conf(DUMMY_CONF_PATH), path_to_log_file(DEFAULT_XORG_LOGFILE), -path_to_server(DEFAULT_XORG_SERVER), display(DEFAULT_DISPLAY) { + Private() : display(-1) { } - std::string path_to_conf; std::string path_to_log_file; std::string path_to_server; @@ -103,15 +99,23 @@ int xorg::testing::Environment::display() const } void xorg::testing::Environment::SetUp() { + unsigned int display_used; static char display_string[6]; snprintf(display_string, 6, :%d, d_-display); - d_-server.SetDisplayNumber(d_-display); - d_-server.SetLogfilePath(d_-path_to_log_file); - d_-server.SetConfigPath(d_-path_to_conf); - d_-server.Start(d_-path_to_server); + if (d_-display = 0) +d_-server.SetDisplayNumber(d_-display); + if (d_-path_to_log_file.length()) +d_-server.SetLogfilePath(d_-path_to_log_file); + if (d_-path_to_conf.length()) +d_-server.SetConfigPath(d_-path_to_conf); + if (d_-path_to_server.length()) +display_used = d_-server.Start(d_-path_to_server); + else +display_used = d_-server.Start(); d_-server.WaitForConnections(); + snprintf(display_string, 6, :%d, display_used); Process::SetEnv(DISPLAY, display_string, true); } Rather than store the values in two places (environment and server objects), we can simply remove the values from the environment and manipulate the server directly. Either: * The environment has a method like: XServer Environment::XServer(); And then you modify things like: environment.XServer().SetDisplayNumber(value); * Provide pass through functions like: void Environment::SetDisplayNumber(int value) { d_-server.SetDisplayNumber(value); } And then you modify things like: environment.SetDisplayNumber(value); The first approach is a bit easier to code (less boilerplate pass-through functions), but it violates the Tell, don't ask policy that many object-oriented APIs follow. I would prefer the second approach because I think it is easier for the end-user to follow and understand. They don't have to hunt around in multiple classes to do what they want to do. works for me, but what is your need for preserving API atm? Environment and XServer have two different naming conventions, I decided to stick with the googletest CamelCase one, environment partially uses the latter. The standard Google style guide says to use lowercase_underscore for variable and member names, and then to use set_variable() and variable() for setters and getters. This is one of my least favorite aspects of their style guide, but I tend to just try to conform rather than do my own thing, so I stuck with it. Things obviously get murkier when your getter and setter aren't actually getting and setting direct members, but maybe are passing the value on to another object's getter or setter. yes, this is just weird. I just looked at examples and they all had CamelCase. For reference, the style guide is here: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#General_Naming_Rules But here's me thinking the whole point of setters and getters is that you don't have to care what variable is actually set (e.g. SetDisplayNumber() vs SetDisplayString(), we may change the backend storage). I'm fine with replacing those and align them with XServer, but it may break your other clients. If we want to continue using the Google style, then we should follow its spirit and use set_display_number(), for example. If we want to break with it for getters and setters, then lets do it now and define new methods for the old ones, and call the new methods from them. I'm about 60-40 on the decision to keep with the current format, just because it's easier not to have a transition :). But I won't throw a fight if you want to change it. I'd rather stick to CamelCaseOnly. Inconsistent function naming is bad enough already, even worse so when encouraged by the style guide. I'll write
Re: [PATCH xorg-gtest 1/2] Switch from utouch-evemu to evemu
On Fri, Jul 06, 2012 at 10:24:22AM +1000, Peter Hutterer wrote: On Thu, Jul 05, 2012 at 03:40:58PM -0700, Chase Douglas wrote: The upstream project has been renamed. Signed-off-by: Chase Douglas chase.doug...@canonical.com Reviewed-by: Peter Hutterer peter.hutte...@who-t.net having thought about this some more, please update the pkg-config check to test for utouch-evemu if evemu cannot be found. we don't have a hard requirement on the latest version anyway, so we should check for both until utouch-evemu is truly superseeded. Cheers, Peter --- aclocal/xorg-gtest.m4 |6 +++--- configure.ac |6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aclocal/xorg-gtest.m4 b/aclocal/xorg-gtest.m4 index 062842c..a8e0204 100644 --- a/aclocal/xorg-gtest.m4 +++ b/aclocal/xorg-gtest.m4 @@ -74,7 +74,7 @@ AC_DEFUN([CHECK_XORG_GTEST], PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no]) - # Check if we should include support for utouch-evemu + # Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback @@ -83,10 +83,10 @@ AC_DEFUN([CHECK_XORG_GTEST], [with_evemu=check]) AS_IF([test x$with_evemu = xyes], -[PKG_CHECK_MODULES(EVEMU, [utouch-evemu], [have_xorg_gtest_evemu=yes])], +[PKG_CHECK_MODULES(EVEMU, [evemu], [have_xorg_gtest_evemu=yes])], [test x$with_evemu = xcheck], [PKG_CHECK_MODULES(EVEMU, - [utouch-evemu], + [evemu], [have_xorg_gtest_evemu=yes], [have_xorg_gtest_evemu=no])]) AS_IF([test x$have_xorg_gtest_evemu = xyes], diff --git a/configure.ac b/configure.ac index 6e9e458..611df5a 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ AS_IF([test x$have_gtest != xyes], AC_SUBST([GTEST_CPPFLAGS]) -# Check if we should include support for utouch-evemu +# Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback (default: enabled if available)])], @@ -43,9 +43,9 @@ AC_ARG_WITH([evemu], [with_evemu=check]) AS_IF([test x$with_evemu == xyes], - [PKG_CHECK_MODULES(EVEMU, utouch-evemu, [have_evemu=yes])], + [PKG_CHECK_MODULES(EVEMU, evemu, [have_evemu=yes])], [test x$with_evemu == xcheck], - [PKG_CHECK_MODULES(EVEMU, utouch-evemu, [have_evemu=yes], [:])]) + [PKG_CHECK_MODULES(EVEMU, evemu, [have_evemu=yes], [:])]) AM_CONDITIONAL([HAVE_EVEMU], [test x$have_evemu = xyes]) AS_IF([test x$have_evemu = xyes], [AC_DEFINE([HAVE_EVEMU])]) -- 1.7.10.4 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 05/36] dix: introduce gpu screens. (v4)
Dave Airlie airl...@gmail.com wrote: +int +AddGPUScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , + int /*argc */ , + char ** /*argv */ + ), + int argc, char **argv) +{ +int i; +ScreenPtr pScreen; +Bool ret; + +i = screenInfo.numGPUScreens; +if (i == MAXGPUSCREENS) +return -1; + +pScreen = (ScreenPtr) calloc(1, sizeof(ScreenRec)); +if (!pScreen) +return -1; + +ret = init_screen(pScreen, i, TRUE); +if (ret != 0) { +free(pScreen); +return ret; +} + +/* This is where screen specific stuff gets initialized. Load the + screen structure, call the hardware, whatever. + This is also where the default colormap should be allocated and + also pixel values for blackPixel, whitePixel, and the cursor + Note that InitScreen is NOT allowed to modify argc, argv, or + any of the strings pointed to by argv. They may be passed to + multiple screens. + */ +screenInfo.gpuscreens[i] = pScreen; +screenInfo.numGPUScreens++; +if (!(*pfnInit) (pScreen, argc, argv)) { +dixFreePrivates(pScreen-devPrivates, PRIVATE_SCREEN); +free(pScreen); +screenInfo.numGPUScreens--; +return -1; +} + +update_desktop_dimensions(); Don't we need to update_desktop_dimensions() also in RemoveGPUScreen? + +dixRegisterScreenPrivateKey(cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, +0); + +return i; +} + +void +RemoveGPUScreen(ScreenPtr pScreen) +{ +int idx, j; +if (!pScreen-isGPU) +return; + +idx = pScreen-myNum - GPU_SCREEN_OFFSET; +for (j = idx; j screenInfo.numGPUScreens - 1; j++) { +screenInfo.gpuscreens[j] = screenInfo.gpuscreens[j + 1]; +screenInfo.gpuscreens[j]-myNum = j + GPU_SCREEN_OFFSET; +} +screenInfo.numGPUScreens--; + +free(pScreen); + +} ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel