xserver-multidpi/hw/kdrive/src/kxv.c

1863 lines
56 KiB
C
Raw Normal View History

/*
2001-03-30 04:18:41 +02:00
XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
2001-03-30 04:18:41 +02:00
Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
Copyright (C) 2000, 2001 - Nokia Home Communications
Copyright (C) 1998, 1999 - The XFree86 Project Inc.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
*/
2003-09-11 07:15:08 +02:00
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
2003-09-11 07:15:08 +02:00
#endif
2001-03-30 04:18:41 +02:00
#include "kdrive.h"
#include "scrnintstr.h"
#include "regionstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "mivalidate.h"
#include "validate.h"
#include "resource.h"
#include "gcstruct.h"
#include "dixstruct.h"
2003-09-11 02:47:36 +02:00
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
2001-03-30 04:18:41 +02:00
#include "kxv.h"
#include "fourcc.h"
2001-03-30 04:18:41 +02:00
/* XvScreenRec fields */
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
static Bool KdXVCloseScreen(ScreenPtr);
2001-03-30 04:18:41 +02:00
static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
/* XvAdaptorRec fields */
static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr *);
2001-03-30 04:18:41 +02:00
static int KdXVFreePort(XvPortPtr);
static int KdXVPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
2001-03-30 04:18:41 +02:00
static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
CARD16, CARD16, CARD16, CARD16,
unsigned int *, unsigned int *);
2001-03-30 04:18:41 +02:00
static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char *, Bool, CARD16, CARD16);
static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
CARD16 *, CARD16 *, int *, int *);
2001-03-30 04:18:41 +02:00
/* ScreenRec fields */
static Bool KdXVCreateWindow(WindowPtr pWin);
static Bool KdXVDestroyWindow(WindowPtr pWin);
static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
/* misc */
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr *, int);
2001-03-30 04:18:41 +02:00
static DevPrivateKeyRec KdXVWindowKeyRec;
#define KdXVWindowKey (&KdXVWindowKeyRec)
static DevPrivateKey KdXvScreenKey;
static unsigned long KdXVGeneration = 0;
2001-03-30 04:18:41 +02:00
static unsigned long PortResource = 0;
#define GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
2001-03-30 04:18:41 +02:00
#define GET_KDXV_SCREEN(pScreen) \
((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
2001-03-30 04:18:41 +02:00
static KdXVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
int
KdXVRegisterGenericAdaptorDriver(KdXVInitGenericAdaptorPtr InitFunc)
{
KdXVInitGenericAdaptorPtr *newdrivers;
2001-03-30 04:18:41 +02:00
/* fprintf(stderr,"KdXVRegisterGenericAdaptorDriver\n"); */
newdrivers = realloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) *
(1 + NumGenDrivers));
if (!newdrivers)
return 0;
GenDrivers = newdrivers;
GenDrivers[NumGenDrivers++] = InitFunc;
2001-03-30 04:18:41 +02:00
return 1;
2001-03-30 04:18:41 +02:00
}
int
KdXVListGenericAdaptors(KdScreenInfo * screen, KdVideoAdaptorPtr ** adaptors)
{
int i, j, n, num;
KdVideoAdaptorPtr *DrivAdap, *new;
2001-03-30 04:18:41 +02:00
num = 0;
*adaptors = NULL;
for (i = 0; i < NumGenDrivers; i++) {
n = GenDrivers[i] (screen, &DrivAdap);
if (0 == n)
continue;
new = realloc(*adaptors, sizeof(KdVideoAdaptorPtr) * (num + n));
if (NULL == new)
continue;
*adaptors = new;
for (j = 0; j < n; j++, num++)
(*adaptors)[num] = DrivAdap[j];
2001-03-30 04:18:41 +02:00
}
return num;
}
KdVideoAdaptorPtr
KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen)
{
return calloc(1, sizeof(KdVideoAdaptorRec));
2001-03-30 04:18:41 +02:00
}
void
KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr)
{
free(ptr);
2001-03-30 04:18:41 +02:00
}
Bool
KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr * adaptors, int num)
{
KdXVScreenPtr ScreenPriv;
XvScreenPtr pxvs;
2001-03-30 04:18:41 +02:00
/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
if (KdXVGeneration != serverGeneration)
KdXVGeneration = serverGeneration;
if (noXvExtension)
return FALSE;
2001-03-30 04:18:41 +02:00
if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
2001-03-30 04:18:41 +02:00
if (Success != XvScreenInit(pScreen))
return FALSE;
2001-03-30 04:18:41 +02:00
KdXvScreenKey = XvGetScreenKey();
PortResource = XvGetRTPort();
2001-03-30 04:18:41 +02:00
pxvs = GET_XV_SCREEN(pScreen);
2001-03-30 04:18:41 +02:00
/* Anyone initializing the Xv layer must provide these two.
The Xv di layer calls them without even checking if they exist! */
2001-03-30 04:18:41 +02:00
pxvs->ddCloseScreen = KdXVCloseScreen;
pxvs->ddQueryAdaptors = KdXVQueryAdaptors;
2001-03-30 04:18:41 +02:00
/* The Xv di layer provides us with a private hook so that we don't
have to allocate our own screen private. They also provide
a CloseScreen hook so that we don't have to wrap it. I'm not
sure that I appreciate that. */
2001-03-30 04:18:41 +02:00
ScreenPriv = malloc(sizeof(KdXVScreenRec));
pxvs->devPriv.ptr = (void *) ScreenPriv;
2001-03-30 04:18:41 +02:00
if (!ScreenPriv)
return FALSE;
2001-03-30 04:18:41 +02:00
ScreenPriv->CreateWindow = pScreen->CreateWindow;
ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
ScreenPriv->WindowExposures = pScreen->WindowExposures;
ScreenPriv->ClipNotify = pScreen->ClipNotify;
2001-03-30 04:18:41 +02:00
/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */
2001-03-30 04:18:41 +02:00
pScreen->CreateWindow = KdXVCreateWindow;
pScreen->DestroyWindow = KdXVDestroyWindow;
pScreen->WindowExposures = KdXVWindowExposures;
pScreen->ClipNotify = KdXVClipNotify;
2001-03-30 04:18:41 +02:00
if (!KdXVInitAdaptors(pScreen, adaptors, num))
return FALSE;
2001-03-30 04:18:41 +02:00
return TRUE;
2001-03-30 04:18:41 +02:00
}
static void
KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
{
int i;
2001-03-30 04:18:41 +02:00
free(pAdaptor->name);
2001-03-30 04:18:41 +02:00
if (pAdaptor->pEncodings) {
XvEncodingPtr pEncode = pAdaptor->pEncodings;
2001-03-30 04:18:41 +02:00
for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
free(pEncode->name);
}
free(pAdaptor->pEncodings);
}
2001-03-30 04:18:41 +02:00
free(pAdaptor->pFormats);
if (pAdaptor->pPorts) {
XvPortPtr pPort = pAdaptor->pPorts;
XvPortRecPrivatePtr pPriv;
for (i = 0; i < pAdaptor->nPorts; i++, pPort++) {
pPriv = (XvPortRecPrivatePtr) pPort->devPriv.ptr;
if (pPriv) {
if (pPriv->clientClip)
RegionDestroy(pPriv->clientClip);
if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
RegionDestroy(pPriv->pCompositeClip);
free(pPriv);
}
}
free(pAdaptor->pPorts);
}
2001-03-30 04:18:41 +02:00
if (pAdaptor->nAttributes) {
XvAttributePtr pAttribute = pAdaptor->pAttributes;
2001-03-30 04:18:41 +02:00
for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
free(pAttribute->name);
}
2001-03-30 04:18:41 +02:00
free(pAdaptor->pAttributes);
}
2001-03-30 04:18:41 +02:00
free(pAdaptor->pImages);
free(pAdaptor->devPriv.ptr);
2001-03-30 04:18:41 +02:00
}
static Bool
KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr * infoPtr, int number)
{
2001-03-30 04:18:41 +02:00
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
KdVideoAdaptorPtr adaptorPtr;
XvAdaptorPtr pAdaptor, pa;
XvAdaptorRecPrivatePtr adaptorPriv;
int na, numAdaptor;
XvPortRecPrivatePtr portPriv;
XvPortPtr pPort, pp;
int numPort;
KdAttributePtr attributePtr;
XvAttributePtr pAttribute, pat;
KdVideoFormatPtr formatPtr;
XvFormatPtr pFormat, pf;
int numFormat, totFormat;
KdVideoEncodingPtr encodingPtr;
XvEncodingPtr pEncode, pe;
KdImagePtr imagePtr;
XvImagePtr pImage, pi;
int numVisuals;
VisualPtr pVisual;
int i;
pxvs->nAdaptors = 0;
pxvs->pAdaptors = NULL;
if (!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
return FALSE;
for (pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
adaptorPtr = infoPtr[na];
if (!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
!adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
continue;
/* client libs expect at least one encoding */
if (!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
continue;
pa->type = adaptorPtr->type;
if (!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
pa->type &= ~XvVideoMask;
if (!adaptorPtr->PutStill && !adaptorPtr->GetStill)
pa->type &= ~XvStillMask;
if (!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
pa->type &= ~XvImageMask;
if (!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
!adaptorPtr->PutStill)
pa->type &= ~XvInputMask;
if (!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
pa->type &= ~XvOutputMask;
if (!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
continue;
if (!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
continue;
pa->pScreen = pScreen;
pa->ddAllocatePort = KdXVAllocatePort;
pa->ddFreePort = KdXVFreePort;
pa->ddPutVideo = KdXVPutVideo;
pa->ddPutStill = KdXVPutStill;
pa->ddGetVideo = KdXVGetVideo;
pa->ddGetStill = KdXVGetStill;
pa->ddStopVideo = KdXVStopVideo;
pa->ddPutImage = KdXVPutImage;
pa->ddSetPortAttribute = KdXVSetPortAttribute;
pa->ddGetPortAttribute = KdXVGetPortAttribute;
pa->ddQueryBestSize = KdXVQueryBestSize;
pa->ddQueryImageAttributes = KdXVQueryImageAttributes;
pa->name = strdup(adaptorPtr->name);
if (adaptorPtr->nEncodings &&
(pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
for (pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) {
pe->id = encodingPtr->id;
pe->pScreen = pScreen;
pe->name = strdup(encodingPtr->name);
pe->width = encodingPtr->width;
pe->height = encodingPtr->height;
pe->rate.numerator = encodingPtr->rate.numerator;
pe->rate.denominator = encodingPtr->rate.denominator;
}
pa->nEncodings = adaptorPtr->nEncodings;
pa->pEncodings = pEncode;
}
if (adaptorPtr->nImages &&
(pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
for (i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
i < adaptorPtr->nImages; i++, pi++, imagePtr++) {
memcpy(pi, imagePtr, sizeof(*pi));
}
pa->nImages = adaptorPtr->nImages;
pa->pImages = pImage;
}
if (adaptorPtr->nAttributes &&
(pAttribute =
calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) {
for (pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i =
0; i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) {
memcpy(pat, attributePtr, sizeof(*pat));
pat->name = strdup(attributePtr->name);
}
pa->nAttributes = adaptorPtr->nAttributes;
pa->pAttributes = pAttribute;
}
totFormat = adaptorPtr->nFormats;
if (!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
KdXVFreeAdaptor(pa);
continue;
}
for (pf = pFormat, i = 0, numFormat = 0, formatPtr =
adaptorPtr->pFormats; i < adaptorPtr->nFormats; i++, formatPtr++) {
numVisuals = pScreen->numVisuals;
pVisual = pScreen->visuals;
while (numVisuals--) {
if ((pVisual->class == formatPtr->class) &&
(pVisual->nplanes == formatPtr->depth)) {
if (numFormat >= totFormat) {
void *moreSpace;
totFormat *= 2;
moreSpace = realloc(pFormat,
totFormat * sizeof(XvFormatRec));
if (!moreSpace)
break;
pFormat = moreSpace;
pf = pFormat + numFormat;
}
pf->visual = pVisual->vid;
pf->depth = formatPtr->depth;
pf++;
numFormat++;
}
pVisual++;
}
}
pa->nFormats = numFormat;
pa->pFormats = pFormat;
if (!numFormat) {
KdXVFreeAdaptor(pa);
continue;
}
if (!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
KdXVFreeAdaptor(pa);
continue;
}
adaptorPriv->flags = adaptorPtr->flags;
adaptorPriv->PutVideo = adaptorPtr->PutVideo;
adaptorPriv->PutStill = adaptorPtr->PutStill;
adaptorPriv->GetVideo = adaptorPtr->GetVideo;
adaptorPriv->GetStill = adaptorPtr->GetStill;
adaptorPriv->StopVideo = adaptorPtr->StopVideo;
adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
adaptorPriv->PutImage = adaptorPtr->PutImage;
adaptorPriv->ReputImage = adaptorPtr->ReputImage;
pa->devPriv.ptr = (void *) adaptorPriv;
if (!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
KdXVFreeAdaptor(pa);
continue;
}
for (pp = pPort, i = 0, numPort = 0; i < adaptorPtr->nPorts; i++) {
if (!(pp->id = FakeClientID(0)))
continue;
if (!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
continue;
if (!AddResource(pp->id, PortResource, pp)) {
free(portPriv);
continue;
}
pp->pAdaptor = pa;
pp->pNotify = (XvPortNotifyPtr) NULL;
pp->pDraw = (DrawablePtr) NULL;
pp->client = (ClientPtr) NULL;
pp->grab.client = (ClientPtr) NULL;
pp->time = currentTime;
pp->devPriv.ptr = portPriv;
portPriv->screen = screen;
portPriv->AdaptorRec = adaptorPriv;
portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
pp++;
numPort++;
}
pa->nPorts = numPort;
pa->pPorts = pPort;
if (!numPort) {
KdXVFreeAdaptor(pa);
continue;
}
pa->base_id = pPort->id;
pa++;
numAdaptor++;
}
if (numAdaptor) {
pxvs->nAdaptors = numAdaptor;
pxvs->pAdaptors = pAdaptor;
}
else {
free(pAdaptor);
return FALSE;
}
return TRUE;
2001-03-30 04:18:41 +02:00
}
/* Video should be clipped to the intersection of the window cliplist
and the client cliplist specified in the GC for which the video was
initialized. When we need to reclip a window, the GC that started
the video may not even be around anymore. That's why we save the
client clip from the GC when the video is initialized. We then
use KdXVUpdateCompositeClip to calculate the new composite clip
when we need it. This is different from what DEC did. They saved
the GC and used it's clip list when they needed to reclip the window,
even if the client clip was different from the one the video was
initialized with. If the original GC was destroyed, they had to stop
the video. I like the new method better (MArk).
2001-03-30 04:18:41 +02:00
This function only works for windows. Will need to rewrite when
(if) we support pixmap rendering.
*/
static void
2001-03-30 04:18:41 +02:00
KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
{
RegionPtr pregWin, pCompositeClip;
WindowPtr pWin;
Bool freeCompClip = FALSE;
if (portPriv->pCompositeClip)
return;
pWin = (WindowPtr) portPriv->pDraw;
/* get window clip list */
if (portPriv->subWindowMode == IncludeInferiors) {
pregWin = NotClippedByChildren(pWin);
freeCompClip = TRUE;
}
else
pregWin = &pWin->clipList;
if (!portPriv->clientClip) {
portPriv->pCompositeClip = pregWin;
portPriv->FreeCompositeClip = freeCompClip;
return;
}
pCompositeClip = RegionCreate(NullBox, 1);
RegionCopy(pCompositeClip, portPriv->clientClip);
RegionTranslate(pCompositeClip,
portPriv->pDraw->x + portPriv->clipOrg.x,
portPriv->pDraw->y + portPriv->clipOrg.y);
RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
portPriv->pCompositeClip = pCompositeClip;
portPriv->FreeCompositeClip = TRUE;
if (freeCompClip) {
RegionDestroy(pregWin);
}
2001-03-30 04:18:41 +02:00
}
/* Save the current clientClip and update the CompositeClip whenever
we have a fresh GC */
static void
KdXVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
{
2001-03-30 04:18:41 +02:00
/* copy the new clip if it exists */
if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
if (!portPriv->clientClip)
portPriv->clientClip = RegionCreate(NullBox, 1);
/* Note: this is in window coordinates */
RegionCopy(portPriv->clientClip, pGC->clientClip);
}
else if (portPriv->clientClip) { /* free the old clientClip */
RegionDestroy(portPriv->clientClip);
portPriv->clientClip = NULL;
2001-03-30 04:18:41 +02:00
}
/* get rid of the old clip list */
if (portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
RegionDestroy(portPriv->pCompositeClip);
2001-03-30 04:18:41 +02:00
}
portPriv->clipOrg = pGC->clipOrg;
portPriv->pCompositeClip = pGC->pCompositeClip;
portPriv->FreeCompositeClip = FALSE;
portPriv->subWindowMode = pGC->subWindowMode;
}
static int
KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
{
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
int ret = Success;
Bool clippedAway = FALSE;
KdXVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
RegionInit(&WinRegion, &WinBox, 1);
RegionInit(&ClipRegion, NullBox, 1);
RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* that's all if it's totally obscured */
if (!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetVideo) (portPriv->screen, portPriv->pDraw,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
portPriv->vid_w, portPriv->vid_h,
portPriv->drw_w, portPriv->drw_h,
&ClipRegion,
portPriv->DevPriv.ptr);
if (ret == Success)
portPriv->isOn = XV_ON;
CLIP_VIDEO_BAILOUT:
if ((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, FALSE);
portPriv->isOn = XV_PENDING;
}
2001-03-30 04:18:41 +02:00
/* This clip was copied and only good for one shot */
if (!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
RegionUninit(&WinRegion);
RegionUninit(&ClipRegion);
return ret;
}
2001-03-30 04:18:41 +02:00
static int
KdXVReputVideo(XvPortRecPrivatePtr portPriv)
{
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
ScreenPtr pScreen = portPriv->pDraw->pScreen;
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
int ret = Success;
Bool clippedAway = FALSE;
KdXVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
RegionInit(&WinRegion, &WinBox, 1);
RegionInit(&ClipRegion, NullBox, 1);
RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
BoxRec VPBox;
VPBox.x1 = 0;
VPBox.y1 = 0;
VPBox.x2 = screen->width;
VPBox.y2 = screen->height;
RegionInit(&VPReg, &VPBox, 1);
RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
if (!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = RegionRects(&ClipRegion);
if ((RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
}
if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutVideo) (portPriv->screen, portPriv->pDraw,
portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
portPriv->vid_w, portPriv->vid_h,
portPriv->drw_w, portPriv->drw_h,
&ClipRegion,
portPriv->DevPriv.ptr);
if (ret == Success)
portPriv->isOn = XV_ON;
CLIP_VIDEO_BAILOUT:
if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, FALSE);
portPriv->isOn = XV_PENDING;
}
/* This clip was copied and only good for one shot */
if (!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
RegionUninit(&WinRegion);
RegionUninit(&ClipRegion);
return ret;
2001-03-30 04:18:41 +02:00
}
static int
KdXVReputImage(XvPortRecPrivatePtr portPriv)
{
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
ScreenPtr pScreen = portPriv->pDraw->pScreen;
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
int ret = Success;
Bool clippedAway = FALSE;
KdXVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
RegionInit(&WinRegion, &WinBox, 1);
RegionInit(&ClipRegion, NullBox, 1);
RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
BoxRec VPBox;
VPBox.x1 = 0;
VPBox.y1 = 0;
VPBox.x2 = screen->width;
VPBox.y2 = screen->height;
RegionInit(&VPReg, &VPBox, 1);
RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
if (!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = RegionRects(&ClipRegion);
if ((RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
}
if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
2001-03-30 04:18:41 +02:00
ret =
(*portPriv->AdaptorRec->ReputImage) (portPriv->screen, portPriv->pDraw,
WinBox.x1, WinBox.y1, &ClipRegion,
portPriv->DevPriv.ptr);
portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
CLIP_VIDEO_BAILOUT:
if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, FALSE);
portPriv->isOn = XV_PENDING;
}
/* This clip was copied and only good for one shot */
if (!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
RegionUninit(&WinRegion);
RegionUninit(&ClipRegion);
return ret;
}
2001-03-30 04:18:41 +02:00
static int
KdXVReputAllVideo(WindowPtr pWin, void *data)
2001-03-30 04:18:41 +02:00
{
KdXVWindowPtr WinPriv;
if (pWin->drawable.type != DRAWABLE_WINDOW)
return WT_DONTWALKCHILDREN;
WinPriv = GET_KDXV_WINDOW(pWin);
2001-03-30 04:18:41 +02:00
while (WinPriv) {
if (WinPriv->PortRec->type == XvInputMask)
KdXVReputVideo(WinPriv->PortRec);
else
KdXVRegetVideo(WinPriv->PortRec);
WinPriv = WinPriv->next;
2001-03-30 04:18:41 +02:00
}
return WT_WALKCHILDREN;
}
static int
KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
KdXVWindowPtr winPriv, PrivRoot;
winPriv = PrivRoot = GET_KDXV_WINDOW(pWin);
/* Enlist our port in the window private */
while (winPriv) {
if (winPriv->PortRec == portPriv) /* we're already listed */
break;
winPriv = winPriv->next;
}
2001-03-30 04:18:41 +02:00
if (!winPriv) {
winPriv = malloc(sizeof(KdXVWindowRec));
if (!winPriv)
return BadAlloc;
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
}
return Success;
}
2001-03-30 04:18:41 +02:00
static void
KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
KdXVWindowPtr winPriv, prevPriv = NULL;
winPriv = GET_KDXV_WINDOW(pWin);
while (winPriv) {
if (winPriv->PortRec == portPriv) {
if (prevPriv)
prevPriv->next = winPriv->next;
else
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
free(winPriv);
break;
}
prevPriv = winPriv;
winPriv = winPriv->next;
}
portPriv->pDraw = NULL;
2001-03-30 04:18:41 +02:00
}
/**** ScreenRec fields ****/
static Bool
KdXVCreateWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
int ret;
2001-03-30 04:18:41 +02:00
pScreen->CreateWindow = ScreenPriv->CreateWindow;
ret = (*pScreen->CreateWindow) (pWin);
pScreen->CreateWindow = KdXVCreateWindow;
2001-03-30 04:18:41 +02:00
if (ret)
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
2001-03-30 04:18:41 +02:00
return ret;
2001-03-30 04:18:41 +02:00
}
static Bool
KdXVDestroyWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin);
int ret;
while (WinPriv) {
XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
if (pPriv->isOn > XV_OFF) {
(*pPriv->AdaptorRec->StopVideo) (pPriv->screen, pPriv->DevPriv.ptr,
TRUE);
pPriv->isOn = XV_OFF;
}
pPriv->pDraw = NULL;
tmp = WinPriv;
WinPriv = WinPriv->next;
free(tmp);
}
2001-03-30 04:18:41 +02:00
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
2001-03-30 04:18:41 +02:00
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow) (pWin);
pScreen->DestroyWindow = KdXVDestroyWindow;
2001-03-30 04:18:41 +02:00
return ret;
2001-03-30 04:18:41 +02:00
}
static void
KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
KdXVWindowPtr pPrev;
XvPortRecPrivatePtr pPriv;
Bool AreasExposed;
AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
pScreen->WindowExposures = ScreenPriv->WindowExposures;
(*pScreen->WindowExposures) (pWin, reg1, reg2);
pScreen->WindowExposures = KdXVWindowExposures;
/* filter out XClearWindow/Area */
if (!pWin->valdata)
return;
pPrev = NULL;
while (WinPriv) {
pPriv = WinPriv->PortRec;
/* Reput anyone with a reput function */
switch (pPriv->type) {
case XvInputMask:
KdXVReputVideo(pPriv);
break;
case XvOutputMask:
KdXVRegetVideo(pPriv);
break;
default: /* overlaid still/image */
if (pPriv->AdaptorRec->ReputImage)
KdXVReputImage(pPriv);
else if (AreasExposed) {
KdXVWindowPtr tmp;
if (pPriv->isOn == XV_ON) {
(*pPriv->AdaptorRec->StopVideo) (pPriv->screen,
pPriv->DevPriv.ptr, FALSE);
pPriv->isOn = XV_PENDING;
}
pPriv->pDraw = NULL;
if (!pPrev)
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey,
WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
WinPriv = WinPriv->next;
free(tmp);
continue;
}
break;
}
pPrev = WinPriv;
WinPriv = WinPriv->next;
}
2001-03-30 04:18:41 +02:00
}
static void
2001-03-30 04:18:41 +02:00
KdXVClipNotify(WindowPtr pWin, int dx, int dy)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
KdXVWindowPtr tmp, pPrev = NULL;
XvPortRecPrivatePtr pPriv;
Bool visible = (pWin->visibility == VisibilityUnobscured) ||
(pWin->visibility == VisibilityPartiallyObscured);
while (WinPriv) {
pPriv = WinPriv->PortRec;
if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
/* Stop everything except images, but stop them too if the
window isn't visible. But we only remove the images. */
if (pPriv->type || !visible) {
if (pPriv->isOn == XV_ON) {
(*pPriv->AdaptorRec->StopVideo) (pPriv->screen,
pPriv->DevPriv.ptr, FALSE);
pPriv->isOn = XV_PENDING;
}
if (!pPriv->type) { /* overlaid still/image */
pPriv->pDraw = NULL;
if (!pPrev)
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey,
WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
WinPriv = WinPriv->next;
free(tmp);
continue;
}
}
pPrev = WinPriv;
WinPriv = WinPriv->next;
}
2001-03-30 04:18:41 +02:00
if (ScreenPriv->ClipNotify) {
pScreen->ClipNotify = ScreenPriv->ClipNotify;
(*pScreen->ClipNotify) (pWin, dx, dy);
pScreen->ClipNotify = KdXVClipNotify;
}
}
2001-03-30 04:18:41 +02:00
/**** Required XvScreenRec fields ****/
static Bool
api: rework the X server driver API to avoid global arrays. This is a squash merge containing all the API changes, as well as the video ABI bump. Its been squashed to make bisection easier. Full patch log below: commit b202738bbf0c5a1c1172767119c2c71f1e7f8070 Author: Aaron Plattner <aplattner@nvidia.com> Date: Mon May 14 15:16:11 2012 -0700 xfree86: Bump video ABI to 13.0 The ABI was broken by changes to convert from screen index numbers to ScreenPtr / ScrnInfoPtr in various structures and function signatures. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 10:56:57 2012 +0100 xf86: xf86ClearEntityListForScreen should take a pScrn When adding GPU screens this make life easier. (also fix comment, as pointed out by Alan) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Dave Airlie <airlied@redhat.com> commit afee8b5ab4501597ecc1ade34124d7ca227ab055 Author: Dave Airlie <airlied@redhat.com> Date: Thu May 24 07:07:32 2012 +0100 xf86i2c: add pscrn for drivers to use This just adds a pScrn pointer into the struct for the drivers to use instead of scrnIndex. Mostly scrnIndex is used for logging, but some drivers use it to lookup xf86Screens, so let them stash a pScrn instead. Removing the scrnIndex is a bit more involved and I'm not sure its worth the effort. Doing i2c in the X server is legacy code as far as I'm concerned. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit ea5092f1f679691d187f1eee9427e6057beec56e Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 19:25:20 2012 +0100 dix/gc: consolidate GC object creation in one place The standard GC create and scratch GC create were 90% the same really, and I have a need in the future for creating GC objects without the other bits, so wanted to avoid a third copy. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 10:24:06 2012 +0100 xf86: add a define to denote the new non-index interfaces are being used This can be used by drivers to provide compatible APIs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 15:09:12 2012 +0100 dix: make Create/Free scratch pixmaps take a ScreenPtr While technically an API/ABI change I doubt anyone uses it, but it helps in splitting screens up. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:57:55 2012 +0100 xf86/xv: remove scrnIndexfrom xf86FindXvOptions. Move this interface to taking an ScrnInfoPtr. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:53:59 2012 +0100 xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2) stop passing indices into this function. v2: drop flags argument. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 58824e414f35682435f15bfe6c4b656bd90b9235 Author: Dave Airlie <airlied@redhat.com> Date: Wed May 23 14:48:09 2012 +0100 xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI) Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:18:59 2012 +0100 xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2) Instead of passing an index, pass the actual ScreenPtr. This allows more moving towards not abusing xf86Screens + screenInfo. v2: drop the blockData/wakeupData args as per ajax's suggestion., fix docs. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 790d003de20fb47674420a24dadd92412d78620d Author: Dave Airlie <airlied@gmail.com> Date: Wed Apr 11 09:53:14 2012 +0100 xf86/common: remove some more pScrn->pScreen uses remove some more conversions that appeared after api cleanups. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:34:53 2012 +0100 ddc: change API to take ScrnInfoPtr (v2) This removes all xf86Screens usage from ddc code, it modifies the API for some functions to avoid taking indices. v2: address Alan's comments about dropping DDC2Init parameter. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit fe3f57b6eaf6860a33876a54f9439f69578f03a5 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:31:26 2012 +0100 vbe: don't use index for VBEInterpretPanelID (API) Remove use of xf86screens from vbe module. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit abf1965f4ed91529036d3fdb470d6a3ce6f29675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 16:25:11 2012 +0100 int10/vbe: don't use xf86Screens. (ABI) (v3) Pass the ScrnInfoPtr instead of the index in the int10 struct. This saves us using it to dereference xf86Screens. v2: address Alan's comment to fix struct alignment. v3: squash in all the int10 fixes, test the vm86 code builds, after comments by Keith. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 23cca612b4fb5efc33683c7624b803b457387e3d Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:30:18 2012 +0100 xserver: drop index argument to ScreenInit (ABI/API) (v2) This drops the index argument, its the same as pScreen->myNum, and its the last major index abuse I can find. v2: address Alan's review - update docs, fix xwin/xnest/darwin Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:23:01 2012 +0100 xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API) This migrates PointerMoved from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:20:46 2012 +0100 xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API) This migrates the PMEvent from index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:18:30 2012 +0100 xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API) This migrates the SetDGAMode callback from an index to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit baf5e4818a74f2b68c3dfdcc56f54322351039a0 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:14:11 2012 +0100 xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2) This migrates the ChangeGamma interface to avoid passing a index. v2: fix xf86RandR12.c + xf86cmap.c call Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 51e5f90ada929d6b23176090badbb42fdb3fa550 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:11:09 2012 +0100 xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API) The EXA interface migrates to ScreenPtr, and the xf86 interface migrated to ScrnInfoPtr. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 94f1f21d17e86f96d4a54292a399160950087675 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 15:02:11 2012 +0100 xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API) This migrates the ValidMode to passing a ScrnInfoPtr instead of an index. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 3f8f18198fed4f39ec805b508a3482e91eea26b2 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:59:46 2012 +0100 xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2) This migrate the SwitchMode interface to take a ScrnInfoPtr instead of an index. v2: drop flags. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit d06a038a5c49328ab3a8d969d24f9fcd22c63202 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:50:37 2012 +0100 xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2) This converts AdjustFrame code paths to passing a ScrnInfoPtr instead of an integer index. v2: drop flags args. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:41:27 2012 +0100 xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2) Another index->pScrn conversion. v2: drop flags arg. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3 Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:35:41 2012 +0100 xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2) This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr instead of an index into xf86Screens. This allows dropping more public dereferences of the xf86Screens and screenInfo. v2: drop flags args as suggested by Keith, fix docs. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> commit 06729dbbc804a20242e6499f446acb5d94023c3c Author: Dave Airlie <airlied@gmail.com> Date: Tue Apr 10 14:04:59 2012 +0100 xserver: remove index from CloseScreen (API/ABI breakage) This drops the index from the CloseScreen callback, its always been useless really, since the pScreen contains it. Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Acked-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 14:22:18 +02:00
KdXVCloseScreen(ScreenPtr pScreen)
2001-03-30 04:18:41 +02:00
{
XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
XvAdaptorPtr pa;
int c;
2001-03-30 04:18:41 +02:00
if (!ScreenPriv)
return TRUE;
2001-03-30 04:18:41 +02:00
pScreen->CreateWindow = ScreenPriv->CreateWindow;
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
pScreen->WindowExposures = ScreenPriv->WindowExposures;
pScreen->ClipNotify = ScreenPriv->ClipNotify;
2001-03-30 04:18:41 +02:00
/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */
2001-03-30 04:18:41 +02:00
for (c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
KdXVFreeAdaptor(pa);
}
2001-03-30 04:18:41 +02:00
free(pxvs->pAdaptors);
free(ScreenPriv);
2001-03-30 04:18:41 +02:00
return TRUE;
2001-03-30 04:18:41 +02:00
}
static int
KdXVQueryAdaptors(ScreenPtr pScreen,
XvAdaptorPtr * p_pAdaptors, int *p_nAdaptors)
{
XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
2001-03-30 04:18:41 +02:00
*p_nAdaptors = pxvs->nAdaptors;
*p_pAdaptors = pxvs->pAdaptors;
2001-03-30 04:18:41 +02:00
return Success;
2001-03-30 04:18:41 +02:00
}
static Bool
KdXVRunning(ScreenPtr pScreen)
2001-03-30 04:18:41 +02:00
{
return (KdXVGeneration == serverGeneration && GET_XV_SCREEN(pScreen) != 0);
}
2001-03-30 04:18:41 +02:00
Bool
KdXVEnable(ScreenPtr pScreen)
{
if (!KdXVRunning(pScreen))
return TRUE;
WalkTree(pScreen, KdXVReputAllVideo, 0);
return TRUE;
2001-03-30 04:18:41 +02:00
}
void
2001-03-30 04:18:41 +02:00
KdXVDisable(ScreenPtr pScreen)
{
XvScreenPtr pxvs;
2001-03-30 04:18:41 +02:00
XvAdaptorPtr pAdaptor;
XvPortPtr pPort;
XvPortRecPrivatePtr pPriv;
int i, j;
if (!KdXVRunning(pScreen))
return;
pxvs = GET_XV_SCREEN(pScreen);
for (i = 0; i < pxvs->nAdaptors; i++) {
pAdaptor = &pxvs->pAdaptors[i];
for (j = 0; j < pAdaptor->nPorts; j++) {
pPort = &pAdaptor->pPorts[j];
pPriv = (XvPortRecPrivatePtr) pPort->devPriv.ptr;
if (pPriv->isOn > XV_OFF) {
2001-03-30 04:18:41 +02:00
(*pPriv->AdaptorRec->StopVideo) (pPriv->screen,
pPriv->DevPriv.ptr, TRUE);
pPriv->isOn = XV_OFF;
2001-03-30 04:18:41 +02:00
if (pPriv->pCompositeClip && pPriv->FreeCompositeClip)
RegionDestroy(pPriv->pCompositeClip);
2001-03-30 04:18:41 +02:00
pPriv->pCompositeClip = NULL;
2001-03-30 04:18:41 +02:00
if (!pPriv->type && pPriv->pDraw) { /* still */
KdXVRemovePortFromWindow((WindowPtr) pPriv->pDraw, pPriv);
}
}
}
2001-03-30 04:18:41 +02:00
}
}
/**** XvAdaptorRec fields ****/
static int
KdXVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
{
*ppPort = pPort;
return Success;
2001-03-30 04:18:41 +02:00
}
static int
KdXVFreePort(XvPortPtr pPort)
{
return Success;
2001-03-30 04:18:41 +02:00
}
static int
KdXVPutVideo(ClientPtr client,
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
KdScreenPriv(portPriv->screen->pScreen);
int result;
/* No dumping video to pixmaps... For now anyhow */
if (pDraw->type != DRAWABLE_WINDOW) {
pPort->pDraw = (DrawablePtr) NULL;
return BadAlloc;
}
/* If we are changing windows, unregister our port in the old window */
if (portPriv->pDraw && (portPriv->pDraw != pDraw))
KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
/* Register our port with the new window */
result = KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
if (result != Success)
return result;
portPriv->pDraw = pDraw;
portPriv->type = XvInputMask;
/* save a copy of these parameters */
portPriv->vid_x = vid_x;
portPriv->vid_y = vid_y;
portPriv->vid_w = vid_w;
portPriv->vid_h = vid_h;
portPriv->drw_x = drw_x;
portPriv->drw_y = drw_y;
portPriv->drw_w = drw_w;
portPriv->drw_h = drw_h;
/* make sure we have the most recent copy of the clientClip */
KdXVCopyClip(portPriv, pGC);
/* To indicate to the DI layer that we were successful */
pPort->pDraw = pDraw;
if (!pScreenPriv->enabled)
return Success;
return (KdXVReputVideo(portPriv));
2001-03-30 04:18:41 +02:00
}
static int
KdXVPutStill(ClientPtr client,
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
ScreenPtr pScreen = pDraw->pScreen;
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
int ret = Success;
Bool clippedAway = FALSE;
if (pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
if (!pScreenPriv->enabled)
return Success;
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
RegionInit(&WinRegion, &WinBox, 1);
RegionInit(&ClipRegion, NullBox, 1);
RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
BoxRec VPBox;
VPBox.x1 = 0;
VPBox.y1 = 0;
VPBox.x2 = screen->width;
VPBox.y2 = screen->height;
RegionInit(&VPReg, &VPBox, 1);
RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
RegionUninit(&VPReg);
}
if (portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
}
if (!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_STILL_BAILOUT;
}
if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = RegionRects(&ClipRegion);
if ((RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
clippedAway = TRUE;
goto PUT_STILL_BAILOUT;
}
}
if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutStill) (portPriv->screen, pDraw,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
&ClipRegion,
portPriv->DevPriv.ptr);
if ((ret == Success) &&
(portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
portPriv->isOn = XV_ON;
portPriv->pDraw = pDraw;
portPriv->drw_x = drw_x;
portPriv->drw_y = drw_y;
portPriv->drw_w = drw_w;
portPriv->drw_h = drw_h;
portPriv->type = 0; /* no mask means it's transient and should
not be reput once it's removed */
pPort->pDraw = pDraw; /* make sure we can get stop requests */
}
PUT_STILL_BAILOUT:
if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, FALSE);
2001-03-30 04:18:41 +02:00
portPriv->isOn = XV_PENDING;
}
2001-03-30 04:18:41 +02:00
RegionUninit(&WinRegion);
RegionUninit(&ClipRegion);
2001-03-30 04:18:41 +02:00
return ret;
2001-03-30 04:18:41 +02:00
}
static int
KdXVGetVideo(ClientPtr client,
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
int result;
KdScreenPriv(portPriv->screen->pScreen);
/* No pixmaps... For now anyhow */
if (pDraw->type != DRAWABLE_WINDOW) {
pPort->pDraw = (DrawablePtr) NULL;
return BadAlloc;
}
/* If we are changing windows, unregister our port in the old window */
if (portPriv->pDraw && (portPriv->pDraw != pDraw))
KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
/* Register our port with the new window */
result = KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
if (result != Success)
return result;
portPriv->pDraw = pDraw;
portPriv->type = XvOutputMask;
/* save a copy of these parameters */
portPriv->vid_x = vid_x;
portPriv->vid_y = vid_y;
portPriv->vid_w = vid_w;
portPriv->vid_h = vid_h;
portPriv->drw_x = drw_x;
portPriv->drw_y = drw_y;
portPriv->drw_w = drw_w;
portPriv->drw_h = drw_h;
/* make sure we have the most recent copy of the clientClip */
KdXVCopyClip(portPriv, pGC);
/* To indicate to the DI layer that we were successful */
pPort->pDraw = pDraw;
if (!pScreenPriv->enabled)
return Success;
return (KdXVRegetVideo(portPriv));
2001-03-30 04:18:41 +02:00
}
static int
KdXVGetStill(ClientPtr client,
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 vid_x, INT16 vid_y,
CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
ScreenPtr pScreen = pDraw->pScreen;
2001-03-30 04:18:41 +02:00
KdScreenPriv(pScreen);
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
int ret = Success;
Bool clippedAway = FALSE;
2001-03-30 04:18:41 +02:00
if (pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
2001-03-30 04:18:41 +02:00
if (!pScreenPriv->enabled)
return Success;
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
2001-03-30 04:18:41 +02:00
RegionInit(&WinRegion, &WinBox, 1);
RegionInit(&ClipRegion, NullBox, 1);
RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if (portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
}
2001-03-30 04:18:41 +02:00
if (!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto GET_STILL_BAILOUT;
}
if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
2001-03-30 04:18:41 +02:00
ret = (*portPriv->AdaptorRec->GetStill) (portPriv->screen, pDraw,
vid_x, vid_y, WinBox.x1, WinBox.y1,
vid_w, vid_h, drw_w, drw_h,
&ClipRegion,
portPriv->DevPriv.ptr);
2001-03-30 04:18:41 +02:00
GET_STILL_BAILOUT:
2001-03-30 04:18:41 +02:00
if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, FALSE);
portPriv->isOn = XV_PENDING;
}
2001-03-30 04:18:41 +02:00
RegionUninit(&WinRegion);
RegionUninit(&ClipRegion);
return ret;
2001-03-30 04:18:41 +02:00
}
static int
KdXVStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
2001-03-30 04:18:41 +02:00
KdScreenPriv(portPriv->screen->pScreen);
2001-03-30 04:18:41 +02:00
if (pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
KdXVRemovePortFromWindow((WindowPtr) pDraw, portPriv);
if (!pScreenPriv->enabled)
return Success;
/* Must free resources. */
if (portPriv->isOn > XV_OFF) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, TRUE);
portPriv->isOn = XV_OFF;
}
return Success;
2001-03-30 04:18:41 +02:00
}
static int
KdXVSetPortAttribute(ClientPtr client,
XvPortPtr pPort, Atom attribute, INT32 value)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
2001-03-30 04:18:41 +02:00
return ((*portPriv->AdaptorRec->SetPortAttribute) (portPriv->screen,
attribute, value,
portPriv->DevPriv.ptr));
}
2001-03-30 04:18:41 +02:00
static int
KdXVGetPortAttribute(ClientPtr client,
XvPortPtr pPort, Atom attribute, INT32 *p_value)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
return ((*portPriv->AdaptorRec->GetPortAttribute) (portPriv->screen,
attribute,
(int *) p_value,
portPriv->DevPriv.ptr));
2001-03-30 04:18:41 +02:00
}
static int
KdXVQueryBestSize(ClientPtr client,
XvPortPtr pPort,
CARD8 motion,
CARD16 vid_w, CARD16 vid_h,
CARD16 drw_w, CARD16 drw_h,
unsigned int *p_w, unsigned int *p_h)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
(*portPriv->AdaptorRec->QueryBestSize) (portPriv->screen,
(Bool) motion, vid_w, vid_h, drw_w,
drw_h, p_w, p_h,
portPriv->DevPriv.ptr);
return Success;
}
2001-03-30 04:18:41 +02:00
static int
KdXVPutImage(ClientPtr client,
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
INT16 src_x, INT16 src_y,
CARD16 src_w, CARD16 src_h,
INT16 drw_x, INT16 drw_y,
CARD16 drw_w, CARD16 drw_h,
XvImagePtr format,
unsigned char *data, Bool sync, CARD16 width, CARD16 height)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
ScreenPtr pScreen = pDraw->pScreen;
KdScreenPriv(pScreen);
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
int ret = Success;
Bool clippedAway = FALSE;
if (pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
if (!pScreenPriv->enabled)
return Success;
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
RegionInit(&WinRegion, &WinBox, 1);
RegionInit(&ClipRegion, NullBox, 1);
RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if (portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
BoxRec VPBox;
VPBox.x1 = 0;
VPBox.y1 = 0;
VPBox.x2 = pScreen->width;
VPBox.y2 = pScreen->height;
RegionInit(&VPReg, &VPBox, 1);
RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
RegionUninit(&VPReg);
}
if (portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr) (portPriv->pDraw), portPriv);
}
if (!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_IMAGE_BAILOUT;
}
if (portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = RegionRects(&ClipRegion);
if ((RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) {
clippedAway = TRUE;
goto PUT_IMAGE_BAILOUT;
}
}
if (portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutImage) (portPriv->screen, pDraw,
src_x, src_y, WinBox.x1, WinBox.y1,
src_w, src_h, drw_w, drw_h,
format->id, data, width, height,
sync, &ClipRegion,
portPriv->DevPriv.ptr);
if ((ret == Success) &&
(portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
KdXVEnlistPortInWindow((WindowPtr) pDraw, portPriv);
portPriv->isOn = XV_ON;
portPriv->pDraw = pDraw;
portPriv->drw_x = drw_x;
portPriv->drw_y = drw_y;
portPriv->drw_w = drw_w;
portPriv->drw_h = drw_h;
portPriv->type = 0; /* no mask means it's transient and should
not be reput once it's removed */
pPort->pDraw = pDraw; /* make sure we can get stop requests */
}
PUT_IMAGE_BAILOUT:
if ((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
(*portPriv->AdaptorRec->StopVideo) (portPriv->screen,
portPriv->DevPriv.ptr, FALSE);
2001-03-30 04:18:41 +02:00
portPriv->isOn = XV_PENDING;
}
2001-03-30 04:18:41 +02:00
RegionUninit(&WinRegion);
RegionUninit(&ClipRegion);
2001-03-30 04:18:41 +02:00
return ret;
2001-03-30 04:18:41 +02:00
}
static int
KdXVQueryImageAttributes(ClientPtr client,
XvPortPtr pPort,
XvImagePtr format,
CARD16 *width,
CARD16 *height, int *pitches, int *offsets)
{
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
2001-03-30 04:18:41 +02:00
return (*portPriv->AdaptorRec->QueryImageAttributes) (portPriv->screen,
format->id, width,
height, pitches,
offsets);
2001-03-30 04:18:41 +02:00
}
/**************** Common video manipulation functions *******************/
void
KdXVCopyPackedData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
int srcPitch, int dstPitch, int srcW, int srcH, int top,
int left, int h, int w)
{
int srcDown = srcPitch, srcRight = 2, srcNext;
int p;
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
srcDown = srcPitch;
srcRight = 2;
break;
case RR_Rotate_90:
src += (srcH - 1) * 2;
srcDown = -2;
srcRight = srcPitch;
break;
case RR_Rotate_180:
src += srcPitch * (srcH - 1) + (srcW - 1) * 2;
srcDown = -srcPitch;
srcRight = -2;
break;
case RR_Rotate_270:
src += srcPitch * (srcW - 1);
srcDown = 2;
srcRight = -srcPitch;
break;
}
src = src + top * srcDown + left * srcRight;
w >>= 1;
/* srcRight >>= 1; */
srcNext = srcRight >> 1;
while (h--) {
CARD16 *s = (CARD16 *) src;
CARD32 *d = (CARD32 *) dst;
p = w;
while (p--) {
*d++ = s[0] | (s[srcNext] << 16);
s += srcRight;
}
src += srcPitch;
dst += dstPitch;
}
}
void
KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
int srcPitch, int srcPitch2, int dstPitch, int srcW,
int srcH, int height, int top, int left, int h, int w,
int id)
{
int i, j;
CARD8 *src1, *src2, *src3, *dst1;
int srcDown = srcPitch, srcDown2 = srcPitch2;
int srcRight = 2, srcRight2 = 1, srcNext = 1;
/* compute source data pointers */
src1 = src;
src2 = src1 + height * srcPitch;
src3 = src2 + (height >> 1) * srcPitch2;
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
srcDown = srcPitch;
srcDown2 = srcPitch2;
srcRight = 2;
srcRight2 = 1;
srcNext = 1;
break;
case RR_Rotate_90:
src1 = src1 + srcH - 1;
src2 = src2 + (srcH >> 1) - 1;
src3 = src3 + (srcH >> 1) - 1;
srcDown = -1;
srcDown2 = -1;
srcRight = srcPitch * 2;
srcRight2 = srcPitch2;
srcNext = srcPitch;
break;
case RR_Rotate_180:
src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
srcDown = -srcPitch;
srcDown2 = -srcPitch2;
srcRight = -2;
srcRight2 = -1;
srcNext = -1;
break;
case RR_Rotate_270:
src1 = src1 + srcPitch * (srcW - 1);
src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
srcDown = 1;
srcDown2 = 1;
srcRight = -srcPitch * 2;
srcRight2 = -srcPitch2;
srcNext = -srcPitch;
break;
}
/* adjust for origin */
src1 += top * srcDown + left * srcNext;
src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
if (id == FOURCC_I420) {
CARD8 *srct = src2;
src2 = src3;
src3 = srct;
}
dst1 = dst;
w >>= 1;
for (j = 0; j < h; j++) {
CARD32 *dst32 = (CARD32 *) dst1;
CARD8 *s1l = src1;
CARD8 *s1r = src1 + srcNext;
CARD8 *s2 = src2;
CARD8 *s3 = src3;
for (i = 0; i < w; i++) {
*dst32++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
s1l += srcRight;
s1r += srcRight;
s2 += srcRight2;
s3 += srcRight2;
}
src1 += srcDown;
dst1 += dstPitch;
if (j & 1) {
src2 += srcDown2;
src3 += srcDown2;
}
}
}
void
KXVPaintRegion(DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
{
GCPtr pGC;
ChangeGCVal val[2];
xRectangle *rects, *r;
BoxPtr pBox = RegionRects(pRgn);
int nBox = RegionNumRects(pRgn);
rects = malloc(nBox * sizeof(xRectangle));
if (!rects)
goto bail0;
r = rects;
while (nBox--) {
r->x = pBox->x1 - pDraw->x;
r->y = pBox->y1 - pDraw->y;
r->width = pBox->x2 - pBox->x1;
r->height = pBox->y2 - pBox->y1;
r++;
pBox++;
}
pGC = GetScratchGC(pDraw->depth, pDraw->pScreen);
if (!pGC)
goto bail1;
val[0].val = fg;
val[1].val = IncludeInferiors;
ChangeGC(NullClient, pGC, GCForeground | GCSubwindowMode, val);
ValidateGC(pDraw, pGC);
(*pGC->ops->PolyFillRect) (pDraw, pGC, RegionNumRects(pRgn), rects);
FreeScratchGC(pGC);
bail1:
free(rects);
bail0:
;
}