xserver-multidpi/Xext/xvmain.c

1087 lines
28 KiB
C
Raw Normal View History

2003-11-14 17:48:57 +01:00
/***********************************************************
Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
2003-11-14 17:48:57 +01:00
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
2003-11-14 17:48:57 +01:00
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
2003-11-14 17:48:57 +01:00
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR 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.
******************************************************************/
/*
** File:
2003-11-14 17:48:57 +01:00
**
** xvmain.c --- Xv server extension main device independent module.
**
** Author:
2003-11-14 17:48:57 +01:00
**
** David Carver (Digital Workstation Engineering/Project Athena)
**
** Revisions:
**
** 04.09.91 Carver
** - change: stop video always generates an event even when video
** wasn't active
**
** 29.08.91 Carver
** - change: unrealizing windows no longer preempts video
**
** 11.06.91 Carver
** - changed SetPortControl to SetPortAttribute
** - changed GetPortControl to GetPortAttribute
** - changed QueryBestSize
**
** 28.05.91 Carver
** - fixed Put and Get requests to not preempt operations to same drawable
**
** 15.05.91 Carver
** - version 2.0 upgrade
**
** 19.03.91 Carver
** - fixed Put and Get requests to honor grabbed ports.
** - fixed Video requests to update di structure with new drawable, and
** client after calling ddx.
**
** 24.01.91 Carver
** - version 1.4 upgrade
**
2003-11-14 17:48:57 +01:00
** Notes:
**
** Port structures reference client structures in a two different
** ways: when grabs, or video is active. Each reference is encoded
** as fake client resources and thus when the client is goes away so
** does the reference (it is zeroed). No other action is taken, so
** video doesn't necessarily stop. It probably will as a result of
** other resources going away, but if a client starts video using
** none of its own resources, then the video will continue to play
** after the client disappears.
**
**
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <string.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
2003-11-14 17:48:57 +01:00
#include "scrnintstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "gcstruct.h"
2003-11-14 17:48:57 +01:00
#include "extnsionst.h"
#include "extinit.h"
2003-11-14 17:48:57 +01:00
#include "dixstruct.h"
#include "resource.h"
#include "opaque.h"
#include "input.h"
#define GLOBAL
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
2003-11-14 17:48:57 +01:00
#include "xvdix.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
#include "xvdisp.h"
2003-11-14 17:48:57 +01:00
static DevPrivateKeyRec XvScreenKeyRec;
#define XvScreenKey (&XvScreenKeyRec)
unsigned long XvExtensionGeneration = 0;
unsigned long XvScreenGeneration = 0;
unsigned long XvResourceGeneration = 0;
2003-11-14 17:48:57 +01:00
int XvReqCode;
int XvEventBase;
int XvErrorBase;
2003-11-14 17:48:57 +01:00
RESTYPE XvRTPort;
RESTYPE XvRTEncoding;
RESTYPE XvRTGrab;
RESTYPE XvRTVideoNotify;
RESTYPE XvRTVideoNotifyList;
RESTYPE XvRTPortNotify;
2003-11-14 17:48:57 +01:00
/* EXTERNAL */
static void WriteSwappedVideoNotifyEvent(xvEvent *, xvEvent *);
static void WriteSwappedPortNotifyEvent(xvEvent *, xvEvent *);
static Bool CreateResourceTypes(void);
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 XvCloseScreen(ScreenPtr);
2003-11-14 17:48:57 +01:00
static Bool XvDestroyPixmap(PixmapPtr);
static Bool XvDestroyWindow(WindowPtr);
static void XvResetProc(ExtensionEntry *);
static int XvdiDestroyGrab(void *, XID);
static int XvdiDestroyEncoding(void *, XID);
static int XvdiDestroyVideoNotify(void *, XID);
static int XvdiDestroyPortNotify(void *, XID);
static int XvdiDestroyVideoNotifyList(void *, XID);
static int XvdiDestroyPort(void *, XID);
2003-11-14 17:48:57 +01:00
static int XvdiSendVideoNotify(XvPortPtr, DrawablePtr, int);
/*
** XvExtensionInit
**
**
*/
void
XvExtensionInit(void)
2003-11-14 17:48:57 +01:00
{
ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
return;
/* Look to see if any screens were initialized; if not then
init global variables so the extension can function */
if (XvScreenGeneration != serverGeneration) {
if (!CreateResourceTypes()) {
ErrorF("XvExtensionInit: Unable to allocate resource types\n");
return;
}
2003-11-14 17:48:57 +01:00
#ifdef PANORAMIX
XineramaRegisterConnectionBlockCallback(XineramifyXv);
#endif
XvScreenGeneration = serverGeneration;
2003-11-14 17:48:57 +01:00
}
if (XvExtensionGeneration != serverGeneration) {
XvExtensionGeneration = serverGeneration;
2003-11-14 17:48:57 +01:00
extEntry = AddExtension(XvName, XvNumEvents, XvNumErrors,
ProcXvDispatch, SProcXvDispatch,
XvResetProc, StandardMinorOpcode);
if (!extEntry) {
FatalError("XvExtensionInit: AddExtensions failed\n");
}
2003-11-14 17:48:57 +01:00
XvReqCode = extEntry->base;
XvEventBase = extEntry->eventBase;
XvErrorBase = extEntry->errorBase;
2003-11-14 17:48:57 +01:00
EventSwapVector[XvEventBase + XvVideoNotify] =
(EventSwapPtr) WriteSwappedVideoNotifyEvent;
EventSwapVector[XvEventBase + XvPortNotify] =
(EventSwapPtr) WriteSwappedPortNotifyEvent;
2003-11-14 17:48:57 +01:00
SetResourceTypeErrorValue(XvRTPort, _XvBadPort);
(void) MakeAtom(XvName, strlen(XvName), xTrue);
2003-11-14 17:48:57 +01:00
}
}
static Bool
CreateResourceTypes(void)
2003-11-14 17:48:57 +01:00
{
if (XvResourceGeneration == serverGeneration)
return TRUE;
XvResourceGeneration = serverGeneration;
2003-11-14 17:48:57 +01:00
if (!(XvRTPort = CreateNewResourceType(XvdiDestroyPort, "XvRTPort"))) {
ErrorF("CreateResourceTypes: failed to allocate port resource.\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
if (!(XvRTGrab = CreateNewResourceType(XvdiDestroyGrab, "XvRTGrab"))) {
ErrorF("CreateResourceTypes: failed to allocate grab resource.\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
if (!(XvRTEncoding = CreateNewResourceType(XvdiDestroyEncoding,
"XvRTEncoding"))) {
ErrorF("CreateResourceTypes: failed to allocate encoding resource.\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
if (!(XvRTVideoNotify = CreateNewResourceType(XvdiDestroyVideoNotify,
"XvRTVideoNotify"))) {
ErrorF
("CreateResourceTypes: failed to allocate video notify resource.\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
if (!
(XvRTVideoNotifyList =
CreateNewResourceType(XvdiDestroyVideoNotifyList,
"XvRTVideoNotifyList"))) {
ErrorF
("CreateResourceTypes: failed to allocate video notify list resource.\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
if (!(XvRTPortNotify = CreateNewResourceType(XvdiDestroyPortNotify,
"XvRTPortNotify"))) {
ErrorF
("CreateResourceTypes: failed to allocate port notify resource.\n");
return FALSE;
2003-11-14 17:48:57 +01:00
}
return TRUE;
2003-11-14 17:48:57 +01:00
}
int
2003-11-14 17:48:57 +01:00
XvScreenInit(ScreenPtr pScreen)
{
XvScreenPtr pxvs;
if (XvScreenGeneration != serverGeneration) {
if (!CreateResourceTypes()) {
ErrorF("XvScreenInit: Unable to allocate resource types\n");
return BadAlloc;
}
2003-11-14 17:48:57 +01:00
#ifdef PANORAMIX
XineramaRegisterConnectionBlockCallback(XineramifyXv);
#endif
XvScreenGeneration = serverGeneration;
2003-11-14 17:48:57 +01:00
}
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc;
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey)) {
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
2003-11-14 17:48:57 +01:00
}
/* ALLOCATE SCREEN PRIVATE RECORD */
pxvs = malloc(sizeof(XvScreenRec));
if (!pxvs) {
ErrorF("XvScreenInit: Unable to allocate screen private structure\n");
return BadAlloc;
2003-11-14 17:48:57 +01:00
}
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
pxvs->DestroyWindow = pScreen->DestroyWindow;
pxvs->CloseScreen = pScreen->CloseScreen;
pScreen->DestroyPixmap = XvDestroyPixmap;
pScreen->DestroyWindow = XvDestroyWindow;
pScreen->CloseScreen = XvCloseScreen;
return Success;
2003-11-14 17:48:57 +01:00
}
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
XvCloseScreen(ScreenPtr pScreen)
{
2003-11-14 17:48:57 +01:00
XvScreenPtr pxvs;
2003-11-14 17:48:57 +01:00
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
2003-11-14 17:48:57 +01:00
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
pScreen->DestroyWindow = pxvs->DestroyWindow;
pScreen->CloseScreen = pxvs->CloseScreen;
2003-11-14 17:48:57 +01:00
free(pxvs);
2003-11-14 17:48:57 +01:00
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
2003-11-14 17:48:57 +01:00
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
return (*pScreen->CloseScreen) (pScreen);
2003-11-14 17:48:57 +01:00
}
static void
XvResetProc(ExtensionEntry * extEntry)
2003-11-14 17:48:57 +01:00
{
XvResetProcVector();
2003-11-14 17:48:57 +01:00
}
DevPrivateKey
XvGetScreenKey(void)
2003-11-14 17:48:57 +01:00
{
return XvScreenKey;
2003-11-14 17:48:57 +01:00
}
unsigned long
XvGetRTPort(void)
2003-11-14 17:48:57 +01:00
{
return XvRTPort;
2003-11-14 17:48:57 +01:00
}
static void
XvStopAdaptors(DrawablePtr pDrawable)
2003-11-14 17:48:57 +01:00
{
ScreenPtr pScreen = pDrawable->pScreen;
XvScreenPtr pxvs = dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
XvAdaptorPtr pa = pxvs->pAdaptors;
int na = pxvs->nAdaptors;
/* CHECK TO SEE IF THIS PORT IS IN USE */
while (na--) {
XvPortPtr pp = pa->pPorts;
int np = pa->nPorts;
while (np--) {
if (pp->pDraw == pDrawable) {
XvdiSendVideoNotify(pp, pDrawable, XvPreempted);
(void) (*pp->pAdaptor->ddStopVideo) (pp, pDrawable);
pp->pDraw = NULL;
pp->client = NULL;
pp->time = currentTime;
}
pp++;
}
pa++;
2003-11-14 17:48:57 +01:00
}
}
2003-11-14 17:48:57 +01:00
static Bool
XvDestroyPixmap(PixmapPtr pPix)
{
ScreenPtr pScreen = pPix->drawable.pScreen;
Bool status;
if (pPix->refcnt == 1)
XvStopAdaptors(&pPix->drawable);
SCREEN_PROLOGUE(pScreen, DestroyPixmap);
status = (*pScreen->DestroyPixmap) (pPix);
SCREEN_EPILOGUE(pScreen, DestroyPixmap, XvDestroyPixmap);
2003-11-14 17:48:57 +01:00
return status;
2003-11-14 17:48:57 +01:00
}
static Bool
XvDestroyWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
Bool status;
XvStopAdaptors(&pWin->drawable);
SCREEN_PROLOGUE(pScreen, DestroyWindow);
status = (*pScreen->DestroyWindow) (pWin);
SCREEN_EPILOGUE(pScreen, DestroyWindow, XvDestroyWindow);
2003-11-14 17:48:57 +01:00
return status;
2003-11-14 17:48:57 +01:00
}
static int
XvdiDestroyPort(void *pPort, XID id)
2003-11-14 17:48:57 +01:00
{
return Success;
2003-11-14 17:48:57 +01:00
}
static int
XvdiDestroyGrab(void *pGrab, XID id)
2003-11-14 17:48:57 +01:00
{
((XvGrabPtr) pGrab)->client = NULL;
return Success;
2003-11-14 17:48:57 +01:00
}
static int
XvdiDestroyVideoNotify(void *pn, XID id)
2003-11-14 17:48:57 +01:00
{
/* JUST CLEAR OUT THE client POINTER FIELD */
2003-11-14 17:48:57 +01:00
((XvVideoNotifyPtr) pn)->client = NULL;
return Success;
2003-11-14 17:48:57 +01:00
}
static int
XvdiDestroyPortNotify(void *pn, XID id)
2003-11-14 17:48:57 +01:00
{
/* JUST CLEAR OUT THE client POINTER FIELD */
2003-11-14 17:48:57 +01:00
((XvPortNotifyPtr) pn)->client = NULL;
return Success;
2003-11-14 17:48:57 +01:00
}
static int
XvdiDestroyVideoNotifyList(void *pn, XID id)
2003-11-14 17:48:57 +01:00
{
XvVideoNotifyPtr npn, cpn;
2003-11-14 17:48:57 +01:00
/* ACTUALLY DESTROY THE NOTITY LIST */
2003-11-14 17:48:57 +01:00
cpn = (XvVideoNotifyPtr) pn;
2003-11-14 17:48:57 +01:00
while (cpn) {
npn = cpn->next;
if (cpn->client)
FreeResource(cpn->id, XvRTVideoNotify);
free(cpn);
cpn = npn;
2003-11-14 17:48:57 +01:00
}
return Success;
2003-11-14 17:48:57 +01:00
}
static int
XvdiDestroyEncoding(void *value, XID id)
2003-11-14 17:48:57 +01:00
{
return Success;
2003-11-14 17:48:57 +01:00
}
static int
2009-01-11 08:16:12 +01:00
XvdiSendVideoNotify(XvPortPtr pPort, DrawablePtr pDraw, int reason)
2003-11-14 17:48:57 +01:00
{
XvVideoNotifyPtr pn;
dixLookupResourceByType((void **) &pn, pDraw->id, XvRTVideoNotifyList,
serverClient, DixReadAccess);
while (pn) {
xvEvent event = {
.u.videoNotify.reason = reason,
.u.videoNotify.time = currentTime.milliseconds,
.u.videoNotify.drawable = pDraw->id,
.u.videoNotify.port = pPort->id
};
event.u.u.type = XvEventBase + XvVideoNotify;
WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
pn = pn->next;
2003-11-14 17:48:57 +01:00
}
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiSendPortNotify(XvPortPtr pPort, Atom attribute, INT32 value)
{
XvPortNotifyPtr pn;
pn = pPort->pNotify;
while (pn) {
xvEvent event = {
.u.portNotify.time = currentTime.milliseconds,
.u.portNotify.port = pPort->id,
.u.portNotify.attribute = attribute,
.u.portNotify.value = value
};
event.u.u.type = XvEventBase + XvPortNotify;
WriteEventsToClient(pn->client, 1, (xEventPtr) &event);
pn = pn->next;
2003-11-14 17:48:57 +01:00
}
return Success;
2003-11-14 17:48:57 +01:00
}
#define CHECK_SIZE(dw, dh, sw, sh) { \
if(!dw || !dh || !sw || !sh) return Success; \
/* The region code will break these if they are too large */ \
if((dw > 32767) || (dh > 32767) || (sw > 32767) || (sh > 32767)) \
return BadValue; \
}
int
XvdiPutVideo(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)
{
DrawablePtr pOldDraw;
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
UpdateCurrentTime();
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
INFORM CLIENT OF ITS FAILURE */
if (pPort->grab.client && (pPort->grab.client != client)) {
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
return Success;
2003-11-14 17:48:57 +01:00
}
/* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
EVENTS TO ANY CLIENTS WHO WANT THEM */
2003-11-14 17:48:57 +01:00
pOldDraw = pPort->pDraw;
if ((pOldDraw) && (pOldDraw != pDraw)) {
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
2003-11-14 17:48:57 +01:00
}
(void) (*pPort->pAdaptor->ddPutVideo) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
2003-11-14 17:48:57 +01:00
if ((pPort->pDraw) && (pOldDraw != pDraw)) {
pPort->client = client;
XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
2003-11-14 17:48:57 +01:00
}
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiPutStill(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)
{
int status;
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
UpdateCurrentTime();
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
INFORM CLIENT OF ITS FAILURE */
if (pPort->grab.client && (pPort->grab.client != client)) {
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
return Success;
2003-11-14 17:48:57 +01:00
}
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
status = (*pPort->pAdaptor->ddPutStill) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
2003-11-14 17:48:57 +01:00
return status;
2003-11-14 17:48:57 +01:00
}
int
XvdiPutImage(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 image,
unsigned char *data, Bool sync, CARD16 width, CARD16 height)
{
CHECK_SIZE(drw_w, drw_h, src_w, src_h);
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
UpdateCurrentTime();
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
INFORM CLIENT OF ITS FAILURE */
if (pPort->grab.client && (pPort->grab.client != client)) {
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
return Success;
2003-11-14 17:48:57 +01:00
}
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
return (*pPort->pAdaptor->ddPutImage) (pDraw, pPort, pGC,
src_x, src_y, src_w, src_h,
drw_x, drw_y, drw_w, drw_h,
image, data, sync, width, height);
2003-11-14 17:48:57 +01:00
}
int
XvdiGetVideo(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)
{
DrawablePtr pOldDraw;
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
UpdateCurrentTime();
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
INFORM CLIENT OF ITS FAILURE */
if (pPort->grab.client && (pPort->grab.client != client)) {
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
return Success;
2003-11-14 17:48:57 +01:00
}
/* CHECK TO SEE IF PORT IS IN USE; IF SO THEN WE MUST DELIVER INTERRUPTED
EVENTS TO ANY CLIENTS WHO WANT THEM */
2003-11-14 17:48:57 +01:00
pOldDraw = pPort->pDraw;
if ((pOldDraw) && (pOldDraw != pDraw)) {
XvdiSendVideoNotify(pPort, pPort->pDraw, XvPreempted);
2003-11-14 17:48:57 +01:00
}
(void) (*pPort->pAdaptor->ddGetVideo) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
2003-11-14 17:48:57 +01:00
if ((pPort->pDraw) && (pOldDraw != pDraw)) {
pPort->client = client;
XvdiSendVideoNotify(pPort, pPort->pDraw, XvStarted);
2003-11-14 17:48:57 +01:00
}
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiGetStill(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)
{
int status;
CHECK_SIZE(drw_w, drw_h, vid_w, vid_h);
/* UPDATE TIME VARIABLES FOR USE IN EVENTS */
UpdateCurrentTime();
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
INFORM CLIENT OF ITS FAILURE */
if (pPort->grab.client && (pPort->grab.client != client)) {
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
return Success;
2003-11-14 17:48:57 +01:00
}
status = (*pPort->pAdaptor->ddGetStill) (pDraw, pPort, pGC,
vid_x, vid_y, vid_w, vid_h,
drw_x, drw_y, drw_w, drw_h);
2003-11-14 17:48:57 +01:00
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
return status;
2003-11-14 17:48:57 +01:00
}
int
XvdiGrabPort(ClientPtr client, XvPortPtr pPort, Time ctime, int *p_result)
{
unsigned long id;
TimeStamp time;
UpdateCurrentTime();
time = ClientTimeToServerTime(ctime);
if (pPort->grab.client && (client != pPort->grab.client)) {
*p_result = XvAlreadyGrabbed;
return Success;
2003-11-14 17:48:57 +01:00
}
if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, pPort->time) == EARLIER)) {
*p_result = XvInvalidTime;
return Success;
2003-11-14 17:48:57 +01:00
}
if (client == pPort->grab.client) {
*p_result = Success;
return Success;
2003-11-14 17:48:57 +01:00
}
id = FakeClientID(client->index);
2003-11-14 17:48:57 +01:00
if (!AddResource(id, XvRTGrab, &pPort->grab)) {
return BadAlloc;
2003-11-14 17:48:57 +01:00
}
/* IF THERE IS ACTIVE VIDEO THEN STOP IT */
2003-11-14 17:48:57 +01:00
if ((pPort->pDraw) && (client != pPort->client)) {
XvdiStopVideo(NULL, pPort, pPort->pDraw);
2003-11-14 17:48:57 +01:00
}
pPort->grab.client = client;
pPort->grab.id = id;
2003-11-14 17:48:57 +01:00
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
*p_result = Success;
2003-11-14 17:48:57 +01:00
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiUngrabPort(ClientPtr client, XvPortPtr pPort, Time ctime)
{
TimeStamp time;
UpdateCurrentTime();
time = ClientTimeToServerTime(ctime);
if ((!pPort->grab.client) || (client != pPort->grab.client)) {
return Success;
2003-11-14 17:48:57 +01:00
}
if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, pPort->time) == EARLIER)) {
return Success;
2003-11-14 17:48:57 +01:00
}
/* FREE THE GRAB RESOURCE; AND SET THE GRAB CLIENT TO NULL */
2003-11-14 17:48:57 +01:00
FreeResource(pPort->grab.id, XvRTGrab);
pPort->grab.client = NULL;
2003-11-14 17:48:57 +01:00
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiSelectVideoNotify(ClientPtr client, DrawablePtr pDraw, BOOL onoff)
{
XvVideoNotifyPtr pn, tpn, fpn;
int rc;
/* FIND VideoNotify LIST */
rc = dixLookupResourceByType((void **) &pn, pDraw->id,
XvRTVideoNotifyList, client, DixWriteAccess);
if (rc != Success && rc != BadValue)
return rc;
/* IF ONE DONES'T EXIST AND NO MASK, THEN JUST RETURN */
if (!onoff && !pn)
return Success;
/* IF ONE DOESN'T EXIST CREATE IT AND ADD A RESOURCE SO THAT THE LIST
WILL BE DELETED WHEN THE DRAWABLE IS DESTROYED */
if (!pn) {
if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
return BadAlloc;
tpn->next = NULL;
tpn->client = NULL;
if (!AddResource(pDraw->id, XvRTVideoNotifyList, tpn))
return BadAlloc;
2003-11-14 17:48:57 +01:00
}
else {
/* LOOK TO SEE IF ENTRY ALREADY EXISTS */
fpn = NULL;
tpn = pn;
while (tpn) {
if (tpn->client == client) {
if (!onoff)
tpn->client = NULL;
return Success;
}
if (!tpn->client)
fpn = tpn; /* TAKE NOTE OF FREE ENTRY */
tpn = tpn->next;
}
/* IF TUNNING OFF, THEN JUST RETURN */
if (!onoff)
return Success;
/* IF ONE ISN'T FOUND THEN ALLOCATE ONE AND LINK IT INTO THE LIST */
if (fpn) {
tpn = fpn;
}
else {
if (!(tpn = malloc(sizeof(XvVideoNotifyRec))))
return BadAlloc;
tpn->next = pn->next;
pn->next = tpn;
}
2003-11-14 17:48:57 +01:00
}
/* INIT CLIENT PTR IN CASE WE CAN'T ADD RESOURCE */
/* ADD RESOURCE SO THAT IF CLIENT EXITS THE CLIENT PTR WILL BE CLEARED */
2003-11-14 17:48:57 +01:00
tpn->client = NULL;
tpn->id = FakeClientID(client->index);
if (!AddResource(tpn->id, XvRTVideoNotify, tpn))
return BadAlloc;
2003-11-14 17:48:57 +01:00
tpn->client = client;
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiSelectPortNotify(ClientPtr client, XvPortPtr pPort, BOOL onoff)
{
XvPortNotifyPtr pn, tpn;
/* SEE IF CLIENT IS ALREADY IN LIST */
tpn = NULL;
pn = pPort->pNotify;
while (pn) {
if (!pn->client)
tpn = pn; /* TAKE NOTE OF FREE ENTRY */
if (pn->client == client)
break;
pn = pn->next;
2003-11-14 17:48:57 +01:00
}
/* IS THE CLIENT ALREADY ON THE LIST? */
2003-11-14 17:48:57 +01:00
if (pn) {
/* REMOVE IT? */
2003-11-14 17:48:57 +01:00
if (!onoff) {
pn->client = NULL;
FreeResource(pn->id, XvRTPortNotify);
}
2003-11-14 17:48:57 +01:00
return Success;
2003-11-14 17:48:57 +01:00
}
/* DIDN'T FIND IT; SO REUSE LIST ELEMENT IF ONE IS FREE OTHERWISE
CREATE A NEW ONE AND ADD IT TO THE BEGINNING OF THE LIST */
2003-11-14 17:48:57 +01:00
if (!tpn) {
if (!(tpn = malloc(sizeof(XvPortNotifyRec))))
return BadAlloc;
tpn->next = pPort->pNotify;
pPort->pNotify = tpn;
2003-11-14 17:48:57 +01:00
}
tpn->client = client;
tpn->id = FakeClientID(client->index);
if (!AddResource(tpn->id, XvRTPortNotify, tpn))
return BadAlloc;
2003-11-14 17:48:57 +01:00
return Success;
2003-11-14 17:48:57 +01:00
}
int
XvdiStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
{
int status;
/* IF PORT ISN'T ACTIVE THEN WE'RE DONE */
if (!pPort->pDraw || (pPort->pDraw != pDraw)) {
XvdiSendVideoNotify(pPort, pDraw, XvStopped);
return Success;
2003-11-14 17:48:57 +01:00
}
/* CHECK FOR GRAB; IF THIS CLIENT DOESN'T HAVE THE PORT GRABBED THEN
INFORM CLIENT OF ITS FAILURE */
2003-11-14 17:48:57 +01:00
if ((client) && (pPort->grab.client) && (pPort->grab.client != client)) {
XvdiSendVideoNotify(pPort, pDraw, XvBusy);
return Success;
2003-11-14 17:48:57 +01:00
}
XvdiSendVideoNotify(pPort, pDraw, XvStopped);
2003-11-14 17:48:57 +01:00
status = (*pPort->pAdaptor->ddStopVideo) (pPort, pDraw);
2003-11-14 17:48:57 +01:00
pPort->pDraw = NULL;
pPort->client = (ClientPtr) client;
pPort->time = currentTime;
2003-11-14 17:48:57 +01:00
return status;
2003-11-14 17:48:57 +01:00
}
int
XvdiMatchPort(XvPortPtr pPort, DrawablePtr pDraw)
{
2003-11-14 17:48:57 +01:00
XvAdaptorPtr pa;
XvFormatPtr pf;
int nf;
2003-11-14 17:48:57 +01:00
pa = pPort->pAdaptor;
2003-11-14 17:48:57 +01:00
if (pa->pScreen != pDraw->pScreen)
return BadMatch;
2003-11-14 17:48:57 +01:00
nf = pa->nFormats;
pf = pa->pFormats;
2003-11-14 17:48:57 +01:00
while (nf--) {
if (pf->depth == pDraw->depth)
return Success;
pf++;
2003-11-14 17:48:57 +01:00
}
return BadMatch;
2003-11-14 17:48:57 +01:00
}
int
XvdiSetPortAttribute(ClientPtr client,
XvPortPtr pPort, Atom attribute, INT32 value)
{
int status;
status =
(*pPort->pAdaptor->ddSetPortAttribute) (pPort, attribute,
value);
if (status == Success)
XvdiSendPortNotify(pPort, attribute, value);
return status;
2003-11-14 17:48:57 +01:00
}
int
XvdiGetPortAttribute(ClientPtr client,
XvPortPtr pPort, Atom attribute, INT32 *p_value)
{
2003-11-14 17:48:57 +01:00
return
(*pPort->pAdaptor->ddGetPortAttribute) (pPort, attribute,
p_value);
2003-11-14 17:48:57 +01:00
}
static void _X_COLD
WriteSwappedVideoNotifyEvent(xvEvent * from, xvEvent * to)
2003-11-14 17:48:57 +01:00
{
to->u.u.type = from->u.u.type;
to->u.u.detail = from->u.u.detail;
cpswaps(from->u.videoNotify.sequenceNumber,
to->u.videoNotify.sequenceNumber);
cpswapl(from->u.videoNotify.time, to->u.videoNotify.time);
cpswapl(from->u.videoNotify.drawable, to->u.videoNotify.drawable);
cpswapl(from->u.videoNotify.port, to->u.videoNotify.port);
2003-11-14 17:48:57 +01:00
}
static void _X_COLD
WriteSwappedPortNotifyEvent(xvEvent * from, xvEvent * to)
2003-11-14 17:48:57 +01:00
{
to->u.u.type = from->u.u.type;
to->u.u.detail = from->u.u.detail;
cpswaps(from->u.portNotify.sequenceNumber, to->u.portNotify.sequenceNumber);
cpswapl(from->u.portNotify.time, to->u.portNotify.time);
cpswapl(from->u.portNotify.port, to->u.portNotify.port);
cpswapl(from->u.portNotify.value, to->u.portNotify.value);
2003-11-14 17:48:57 +01:00
}
void
XvFreeAdaptor(XvAdaptorPtr pAdaptor)
{
int i;
free(pAdaptor->name);
pAdaptor->name = NULL;
if (pAdaptor->pEncodings) {
XvEncodingPtr pEncode = pAdaptor->pEncodings;
for (i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
free(pEncode->name);
free(pAdaptor->pEncodings);
pAdaptor->pEncodings = NULL;
}
free(pAdaptor->pFormats);
pAdaptor->pFormats = NULL;
free(pAdaptor->pPorts);
pAdaptor->pPorts = NULL;
if (pAdaptor->pAttributes) {
XvAttributePtr pAttribute = pAdaptor->pAttributes;
for (i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
free(pAttribute->name);
free(pAdaptor->pAttributes);
pAdaptor->pAttributes = NULL;
}
free(pAdaptor->pImages);
pAdaptor->pImages = NULL;
free(pAdaptor->devPriv.ptr);
pAdaptor->devPriv.ptr = NULL;
}
void
XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
{
ScreenPtr pScreen = pDraw->pScreen;
ChangeGCVal pval[2];
BoxPtr pbox = RegionRects(region);
int i, nbox = RegionNumRects(region);
xRectangle *rects;
GCPtr gc;
gc = GetScratchGC(pDraw->depth, pScreen);
if (!gc)
return;
pval[0].val = key;
pval[1].val = IncludeInferiors;
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
ValidateGC(pDraw, gc);
rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) {
for (i = 0; i < nbox; i++, pbox++) {
rects[i].x = pbox->x1 - pDraw->x;
rects[i].y = pbox->y1 - pDraw->y;
rects[i].width = pbox->x2 - pbox->x1;
rects[i].height = pbox->y2 - pbox->y1;
}
(*gc->ops->PolyFillRect) (pDraw, gc, nbox, rects);
free(rects);
}
FreeScratchGC(gc);
}