1706f2543Smrg/***********************************************************
2706f2543SmrgCopyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
3706f2543Smrgand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
4706f2543Smrg
5706f2543Smrg                        All Rights Reserved
6706f2543Smrg
7706f2543SmrgPermission to use, copy, modify, and distribute this software and its
8706f2543Smrgdocumentation for any purpose and without fee is hereby granted,
9706f2543Smrgprovided that the above copyright notice appear in all copies and that
10706f2543Smrgboth that copyright notice and this permission notice appear in
11706f2543Smrgsupporting documentation, and that the names of Digital or MIT not be
12706f2543Smrgused in advertising or publicity pertaining to distribution of the
13706f2543Smrgsoftware without specific, written prior permission.
14706f2543Smrg
15706f2543SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16706f2543SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17706f2543SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18706f2543SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19706f2543SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20706f2543SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21706f2543SmrgSOFTWARE.
22706f2543Smrg
23706f2543Smrg******************************************************************/
24706f2543Smrg
25706f2543Smrg#ifndef XVDIX_H
26706f2543Smrg#define XVDIX_H
27706f2543Smrg/*
28706f2543Smrg** File:
29706f2543Smrg**
30706f2543Smrg**   xvdix.h --- Xv device independent header file
31706f2543Smrg**
32706f2543Smrg** Author:
33706f2543Smrg**
34706f2543Smrg**   David Carver (Digital Workstation Engineering/Project Athena)
35706f2543Smrg**
36706f2543Smrg** Revisions:
37706f2543Smrg**
38706f2543Smrg**   29.08.91 Carver
39706f2543Smrg**     - removed UnrealizeWindow wrapper unrealizing windows no longer
40706f2543Smrg**       preempts video
41706f2543Smrg**
42706f2543Smrg**   11.06.91 Carver
43706f2543Smrg**     - changed SetPortControl to SetPortAttribute
44706f2543Smrg**     - changed GetPortControl to GetPortAttribute
45706f2543Smrg**     - changed QueryBestSize
46706f2543Smrg**
47706f2543Smrg**   15.05.91 Carver
48706f2543Smrg**     - version 2.0 upgrade
49706f2543Smrg**
50706f2543Smrg**   24.01.91 Carver
51706f2543Smrg**     - version 1.4 upgrade
52706f2543Smrg**
53706f2543Smrg*/
54706f2543Smrg
55706f2543Smrg#include "scrnintstr.h"
56706f2543Smrg#include <X11/extensions/Xvproto.h>
57706f2543Smrg
58706f2543Smrg#ifndef XorgLoader
59706f2543Smrgextern _X_EXPORT unsigned long XvExtensionGeneration;
60706f2543Smrgextern _X_EXPORT unsigned long XvScreenGeneration;
61706f2543Smrgextern _X_EXPORT unsigned long XvResourceGeneration;
62706f2543Smrg
63706f2543Smrgextern _X_EXPORT int XvReqCode;
64706f2543Smrgextern _X_EXPORT int XvEventBase;
65706f2543Smrgextern _X_EXPORT int XvErrorBase;
66706f2543Smrg
67706f2543Smrgextern _X_EXPORT unsigned long XvRTPort;
68706f2543Smrgextern _X_EXPORT unsigned long XvRTEncoding;
69706f2543Smrgextern _X_EXPORT unsigned long XvRTGrab;
70706f2543Smrgextern _X_EXPORT unsigned long XvRTVideoNotify;
71706f2543Smrgextern _X_EXPORT unsigned long XvRTVideoNotifyList;
72706f2543Smrgextern _X_EXPORT unsigned long XvRTPortNotify;
73706f2543Smrg#endif
74706f2543Smrg
75706f2543Smrgtypedef struct {
76706f2543Smrg  int numerator;
77706f2543Smrg  int denominator;
78706f2543Smrg} XvRationalRec, *XvRationalPtr;
79706f2543Smrg
80706f2543Smrgtypedef struct {
81706f2543Smrg  char depth;
82706f2543Smrg  unsigned long visual;
83706f2543Smrg} XvFormatRec, *XvFormatPtr;
84706f2543Smrg
85706f2543Smrgtypedef struct {
86706f2543Smrg  unsigned long id;
87706f2543Smrg  ClientPtr client;
88706f2543Smrg} XvGrabRec, *XvGrabPtr;
89706f2543Smrg
90706f2543Smrgtypedef struct _XvVideoNotifyRec {
91706f2543Smrg  struct _XvVideoNotifyRec *next;
92706f2543Smrg  ClientPtr client;
93706f2543Smrg  unsigned long id;
94706f2543Smrg  unsigned long mask;
95706f2543Smrg} XvVideoNotifyRec, *XvVideoNotifyPtr;
96706f2543Smrg
97706f2543Smrgtypedef struct _XvPortNotifyRec {
98706f2543Smrg  struct _XvPortNotifyRec *next;
99706f2543Smrg  ClientPtr client;
100706f2543Smrg  unsigned long id;
101706f2543Smrg} XvPortNotifyRec, *XvPortNotifyPtr;
102706f2543Smrg
103706f2543Smrgtypedef struct {
104706f2543Smrg  int id;
105706f2543Smrg  ScreenPtr pScreen;
106706f2543Smrg  char *name;
107706f2543Smrg  unsigned short width, height;
108706f2543Smrg  XvRationalRec rate;
109706f2543Smrg} XvEncodingRec, *XvEncodingPtr;
110706f2543Smrg
111706f2543Smrgtypedef struct _XvAttributeRec {
112706f2543Smrg  int flags;
113706f2543Smrg  int min_value;
114706f2543Smrg  int max_value;
115706f2543Smrg  char *name;
116706f2543Smrg} XvAttributeRec, *XvAttributePtr;
117706f2543Smrg
118706f2543Smrgtypedef struct {
119706f2543Smrg  int id;
120706f2543Smrg  int type;
121706f2543Smrg  int byte_order;
122706f2543Smrg  char guid[16];
123706f2543Smrg  int bits_per_pixel;
124706f2543Smrg  int format;
125706f2543Smrg  int num_planes;
126706f2543Smrg
127706f2543Smrg  /* for RGB formats only */
128706f2543Smrg  int depth;
129706f2543Smrg  unsigned int red_mask;
130706f2543Smrg  unsigned int green_mask;
131706f2543Smrg  unsigned int blue_mask;
132706f2543Smrg
133706f2543Smrg  /* for YUV formats only */
134706f2543Smrg  unsigned int y_sample_bits;
135706f2543Smrg  unsigned int u_sample_bits;
136706f2543Smrg  unsigned int v_sample_bits;
137706f2543Smrg  unsigned int horz_y_period;
138706f2543Smrg  unsigned int horz_u_period;
139706f2543Smrg  unsigned int horz_v_period;
140706f2543Smrg  unsigned int vert_y_period;
141706f2543Smrg  unsigned int vert_u_period;
142706f2543Smrg  unsigned int vert_v_period;
143706f2543Smrg  char component_order[32];
144706f2543Smrg  int scanline_order;
145706f2543Smrg} XvImageRec, *XvImagePtr;
146706f2543Smrg
147706f2543Smrgtypedef struct {
148706f2543Smrg  unsigned long base_id;
149706f2543Smrg  unsigned char type;
150706f2543Smrg  char *name;
151706f2543Smrg  int nEncodings;
152706f2543Smrg  XvEncodingPtr pEncodings;
153706f2543Smrg  int nFormats;
154706f2543Smrg  XvFormatPtr pFormats;
155706f2543Smrg  int nAttributes;
156706f2543Smrg  XvAttributePtr pAttributes;
157706f2543Smrg  int nImages;
158706f2543Smrg  XvImagePtr pImages;
159706f2543Smrg  int nPorts;
160706f2543Smrg  struct _XvPortRec *pPorts;
161706f2543Smrg  ScreenPtr pScreen;
162706f2543Smrg  int (* ddAllocatePort)(unsigned long, struct _XvPortRec*,
163706f2543Smrg				struct _XvPortRec**);
164706f2543Smrg  int (* ddFreePort)(struct _XvPortRec*);
165706f2543Smrg  int (* ddPutVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
166706f2543Smrg   				INT16, INT16, CARD16, CARD16,
167706f2543Smrg				INT16, INT16, CARD16, CARD16);
168706f2543Smrg  int (* ddPutStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
169706f2543Smrg   				INT16, INT16, CARD16, CARD16,
170706f2543Smrg				INT16, INT16, CARD16, CARD16);
171706f2543Smrg  int (* ddGetVideo)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
172706f2543Smrg   				INT16, INT16, CARD16, CARD16,
173706f2543Smrg				INT16, INT16, CARD16, CARD16);
174706f2543Smrg  int (* ddGetStill)(ClientPtr, DrawablePtr,struct _XvPortRec*, GCPtr,
175706f2543Smrg   				INT16, INT16, CARD16, CARD16,
176706f2543Smrg				INT16, INT16, CARD16, CARD16);
177706f2543Smrg  int (* ddStopVideo)(ClientPtr, struct _XvPortRec*, DrawablePtr);
178706f2543Smrg  int (* ddSetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32);
179706f2543Smrg  int (* ddGetPortAttribute)(ClientPtr, struct _XvPortRec*, Atom, INT32*);
180706f2543Smrg  int (* ddQueryBestSize)(ClientPtr, struct _XvPortRec*, CARD8,
181706f2543Smrg   				CARD16, CARD16,CARD16, CARD16,
182706f2543Smrg				unsigned int*, unsigned int*);
183706f2543Smrg  int (* ddPutImage)(ClientPtr, DrawablePtr, struct _XvPortRec*, GCPtr,
184706f2543Smrg   				INT16, INT16, CARD16, CARD16,
185706f2543Smrg				INT16, INT16, CARD16, CARD16,
186706f2543Smrg				XvImagePtr, unsigned char*, Bool,
187706f2543Smrg				CARD16, CARD16);
188706f2543Smrg  int (* ddQueryImageAttributes)(ClientPtr, struct _XvPortRec*, XvImagePtr,
189706f2543Smrg				CARD16*, CARD16*, int*, int*);
190706f2543Smrg  DevUnion devPriv;
191706f2543Smrg} XvAdaptorRec, *XvAdaptorPtr;
192706f2543Smrg
193706f2543Smrgtypedef struct _XvPortRec {
194706f2543Smrg  unsigned long id;
195706f2543Smrg  XvAdaptorPtr pAdaptor;
196706f2543Smrg  XvPortNotifyPtr pNotify;
197706f2543Smrg  DrawablePtr pDraw;
198706f2543Smrg  ClientPtr client;
199706f2543Smrg  XvGrabRec grab;
200706f2543Smrg  TimeStamp time;
201706f2543Smrg  DevUnion devPriv;
202706f2543Smrg} XvPortRec, *XvPortPtr;
203706f2543Smrg
204706f2543Smrg#define VALIDATE_XV_PORT(portID, pPort, mode)\
205706f2543Smrg    {\
206706f2543Smrg	int rc = dixLookupResourceByType((pointer *)&(pPort), portID,\
207706f2543Smrg	                                 XvRTPort, client, mode);\
208706f2543Smrg	if (rc != Success)\
209706f2543Smrg	    return rc;\
210706f2543Smrg    }
211706f2543Smrg
212706f2543Smrgtypedef struct {
213706f2543Smrg  int version, revision;
214706f2543Smrg  int nAdaptors;
215706f2543Smrg  XvAdaptorPtr pAdaptors;
216706f2543Smrg  DestroyWindowProcPtr DestroyWindow;
217706f2543Smrg  DestroyPixmapProcPtr DestroyPixmap;
218706f2543Smrg  CloseScreenProcPtr CloseScreen;
219706f2543Smrg  Bool (* ddCloseScreen)(int, ScreenPtr);
220706f2543Smrg  int (* ddQueryAdaptors)(ScreenPtr, XvAdaptorPtr*, int*);
221706f2543Smrg  DevUnion devPriv;
222706f2543Smrg} XvScreenRec, *XvScreenPtr;
223706f2543Smrg
224706f2543Smrg#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
225706f2543Smrg    dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field)
226706f2543Smrg
227706f2543Smrg#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
228706f2543Smrg    ((pScreen)->field = wrapper)
229706f2543Smrg
230706f2543Smrg/* Errors */
231706f2543Smrg
232706f2543Smrg#define _XvBadPort (XvBadPort+XvErrorBase)
233706f2543Smrg#define _XvBadEncoding (XvBadEncoding+XvErrorBase)
234706f2543Smrg
235706f2543Smrg#ifndef XorgLoader
236706f2543Smrgextern _X_EXPORT int ProcXvDispatch(ClientPtr);
237706f2543Smrgextern _X_EXPORT int SProcXvDispatch(ClientPtr);
238706f2543Smrg
239706f2543Smrgextern _X_EXPORT void XvExtensionInit(void);
240706f2543Smrgextern _X_EXPORT int XvScreenInit(ScreenPtr);
241706f2543Smrgextern _X_EXPORT DevPrivateKey XvGetScreenKey(void);
242706f2543Smrgextern _X_EXPORT unsigned long XvGetRTPort(void);
243706f2543Smrgextern _X_EXPORT int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
244706f2543Smrgextern _X_EXPORT int XvdiVideoStopped(XvPortPtr, int);
245706f2543Smrg
246706f2543Smrgextern _X_EXPORT int XvdiPutVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
247706f2543Smrg   				INT16, INT16, CARD16, CARD16,
248706f2543Smrg				INT16, INT16, CARD16, CARD16);
249706f2543Smrgextern _X_EXPORT int XvdiPutStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
250706f2543Smrg   				INT16, INT16, CARD16, CARD16,
251706f2543Smrg				INT16, INT16, CARD16, CARD16);
252706f2543Smrgextern _X_EXPORT int XvdiGetVideo(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
253706f2543Smrg   				INT16, INT16, CARD16, CARD16,
254706f2543Smrg				INT16, INT16, CARD16, CARD16);
255706f2543Smrgextern _X_EXPORT int XvdiGetStill(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
256706f2543Smrg   				INT16, INT16, CARD16, CARD16,
257706f2543Smrg				INT16, INT16, CARD16, CARD16);
258706f2543Smrgextern _X_EXPORT int XvdiPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
259706f2543Smrg   				INT16, INT16, CARD16, CARD16,
260706f2543Smrg				INT16, INT16, CARD16, CARD16,
261706f2543Smrg				XvImagePtr, unsigned char*, Bool,
262706f2543Smrg				CARD16, CARD16);
263706f2543Smrgextern _X_EXPORT int XvdiSelectVideoNotify(ClientPtr, DrawablePtr, BOOL);
264706f2543Smrgextern _X_EXPORT int XvdiSelectPortNotify(ClientPtr, XvPortPtr, BOOL);
265706f2543Smrgextern _X_EXPORT int XvdiSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
266706f2543Smrgextern _X_EXPORT int XvdiGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
267706f2543Smrgextern _X_EXPORT int XvdiStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
268706f2543Smrgextern _X_EXPORT int XvdiPreemptVideo(ClientPtr, XvPortPtr, DrawablePtr);
269706f2543Smrgextern _X_EXPORT int XvdiMatchPort(XvPortPtr, DrawablePtr);
270706f2543Smrgextern _X_EXPORT int XvdiGrabPort(ClientPtr, XvPortPtr, Time, int *);
271706f2543Smrgextern _X_EXPORT int XvdiUngrabPort( ClientPtr, XvPortPtr, Time);
272706f2543Smrg#endif /* XorgLoader */
273706f2543Smrg
274706f2543Smrg#endif /* XVDIX_H */
275706f2543Smrg
276