1
2/*
3 * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Except as contained in this notice, the name of the copyright holder(s)
24 * and author(s) shall not be used in advertising or otherwise to promote
25 * the sale, use or other dealings in this Software without prior written
26 * authorization from the copyright holder(s) and author(s).
27 */
28
29#ifndef _XF86XV_H_
30#define _XF86XV_H_
31
32#include "xvdix.h"
33#include "xf86str.h"
34
35#define VIDEO_NO_CLIPPING			0x00000001
36#define VIDEO_INVERT_CLIPLIST			0x00000002
37#define VIDEO_OVERLAID_IMAGES			0x00000004
38#define VIDEO_OVERLAID_STILLS			0x00000008
39/*
40 * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended.
41 * It can make reput behaviour inconsistent.
42 */
43#define VIDEO_CLIP_TO_VIEWPORT			0x00000010
44
45typedef struct {
46  int id;
47  int type;
48  int byte_order;
49  unsigned char guid[16];
50  int bits_per_pixel;
51  int format;
52  int num_planes;
53
54  /* for RGB formats only */
55  int depth;
56  unsigned int red_mask;
57  unsigned int green_mask;
58  unsigned int blue_mask;
59
60  /* for YUV formats only */
61  unsigned int y_sample_bits;
62  unsigned int u_sample_bits;
63  unsigned int v_sample_bits;
64  unsigned int horz_y_period;
65  unsigned int horz_u_period;
66  unsigned int horz_v_period;
67  unsigned int vert_y_period;
68  unsigned int vert_u_period;
69  unsigned int vert_v_period;
70  char component_order[32];
71  int scanline_order;
72} XF86ImageRec, *XF86ImagePtr;
73
74
75typedef struct {
76  ScrnInfoPtr pScrn;
77  int id;
78  unsigned short width, height;
79  int *pitches; /* bytes */
80  int *offsets; /* in bytes from start of framebuffer */
81  DevUnion devPrivate;
82} XF86SurfaceRec, *XF86SurfacePtr;
83
84
85typedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
86	short vid_x, short vid_y, short drw_x, short drw_y,
87	short vid_w, short vid_h, short drw_w, short drw_h,
88	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
89typedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
90	short vid_x, short vid_y, short drw_x, short drw_y,
91	short vid_w, short vid_h, short drw_w, short drw_h,
92	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
93typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
94	short vid_x, short vid_y, short drw_x, short drw_y,
95	short vid_w, short vid_h, short drw_w, short drw_h,
96	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
97typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
98	short vid_x, short vid_y, short drw_x, short drw_y,
99	short vid_w, short vid_h, short drw_w, short drw_h,
100	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
101typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit);
102typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
103	INT32 value, pointer data);
104typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
105	INT32 *value, pointer data);
106typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion,
107	short vid_w, short vid_h, short drw_w, short drw_h,
108	unsigned int *p_w, unsigned int *p_h, pointer data);
109typedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
110	short src_x, short src_y, short drw_x, short drw_y,
111	short src_w, short src_h, short drw_w, short drw_h,
112	int image, unsigned char* buf, short width, short height, Bool Sync,
113	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
114typedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn,
115	short src_x, short src_y, short drw_x, short drw_y,
116	short src_w, short src_h, short drw_w, short drw_h,
117	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
118typedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn,
119	int image, unsigned short *width, unsigned short *height,
120	int *pitches, int *offsets);
121typedef void (*ClipNotifyFuncPtr)(ScrnInfoPtr pScrn, pointer data,
122                                  WindowPtr window, int dx, int dy);
123
124typedef enum {
125    XV_OFF,
126    XV_PENDING,
127    XV_ON
128} XvStatus;
129
130/*** this is what the driver needs to fill out ***/
131
132typedef struct {
133  int id;
134  char *name;
135  unsigned short width, height;
136  XvRationalRec rate;
137} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
138
139typedef struct {
140  char 	depth;
141  short class;
142} XF86VideoFormatRec, *XF86VideoFormatPtr;
143
144typedef struct {
145  int   flags;
146  int   min_value;
147  int   max_value;
148  char  *name;
149} XF86AttributeRec, *XF86AttributePtr;
150
151typedef struct {
152  unsigned int type;
153  int flags;
154  char *name;
155  int nEncodings;
156  XF86VideoEncodingPtr pEncodings;
157  int nFormats;
158  XF86VideoFormatPtr pFormats;
159  int nPorts;
160  DevUnion *pPortPrivates;
161  int nAttributes;
162  XF86AttributePtr pAttributes;
163  int nImages;
164  XF86ImagePtr pImages;
165  PutVideoFuncPtr PutVideo;
166  PutStillFuncPtr PutStill;
167  GetVideoFuncPtr GetVideo;
168  GetStillFuncPtr GetStill;
169  StopVideoFuncPtr StopVideo;
170  SetPortAttributeFuncPtr SetPortAttribute;
171  GetPortAttributeFuncPtr GetPortAttribute;
172  QueryBestSizeFuncPtr QueryBestSize;
173  PutImageFuncPtr PutImage;
174  ReputImageFuncPtr ReputImage; /* image/still */
175  QueryImageAttributesFuncPtr QueryImageAttributes;
176  ClipNotifyFuncPtr ClipNotify;
177} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
178
179typedef struct {
180  XF86ImagePtr image;
181  int flags;
182  int (*alloc_surface)(ScrnInfoPtr pScrn,
183		  int id,
184		  unsigned short width,
185		  unsigned short height,
186		  XF86SurfacePtr surface);
187  int (*free_surface)(XF86SurfacePtr surface);
188  int (*display) (XF86SurfacePtr surface,
189		  short vid_x, short vid_y,
190		  short drw_x, short drw_y,
191		  short vid_w, short vid_h,
192		  short drw_w, short drw_h,
193		  RegionPtr clipBoxes);
194  int (*stop)    (XF86SurfacePtr surface);
195  int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
196  int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
197  int max_width;
198  int max_height;
199  int num_attributes;
200  XF86AttributePtr attributes;
201} XF86OffscreenImageRec, *XF86OffscreenImagePtr;
202
203extern _X_EXPORT Bool
204xf86XVScreenInit(
205   ScreenPtr pScreen,
206   XF86VideoAdaptorPtr 	*Adaptors,
207   int num
208);
209
210typedef int (* xf86XVInitGenericAdaptorPtr)(ScrnInfoPtr pScrn,
211	XF86VideoAdaptorPtr **Adaptors);
212
213extern _X_EXPORT int
214xf86XVRegisterGenericAdaptorDriver(
215    xf86XVInitGenericAdaptorPtr InitFunc
216);
217
218extern _X_EXPORT int
219xf86XVListGenericAdaptors(
220    ScrnInfoPtr          pScrn,
221    XF86VideoAdaptorPtr  **Adaptors
222);
223
224extern _X_EXPORT Bool
225xf86XVRegisterOffscreenImages(
226   ScreenPtr pScreen,
227   XF86OffscreenImagePtr images,
228   int num
229);
230
231extern _X_EXPORT XF86OffscreenImagePtr
232xf86XVQueryOffscreenImages(
233   ScreenPtr pScreen,
234   int *num
235);
236
237extern _X_EXPORT XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn);
238
239extern _X_EXPORT void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
240
241extern _X_EXPORT void
242xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
243
244extern _X_EXPORT void
245xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
246
247extern _X_EXPORT void
248xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything);
249
250extern _X_EXPORT Bool
251xf86XVClipVideoHelper(
252    BoxPtr dst,
253    INT32 *xa,
254    INT32 *xb,
255    INT32 *ya,
256    INT32 *yb,
257    RegionPtr reg,
258    INT32 width,
259    INT32 height
260);
261
262extern _X_EXPORT void
263xf86XVCopyYUV12ToPacked(
264    const void *srcy,
265    const void *srcv,
266    const void *srcu,
267    void *dst,
268    int srcPitchy,
269    int srcPitchuv,
270    int dstPitch,
271    int h,
272    int w
273);
274
275extern _X_EXPORT void
276xf86XVCopyPacked(
277    const void *src,
278    void *dst,
279    int srcPitch,
280    int dstPitch,
281    int h,
282    int w
283);
284
285extern _X_EXPORT DevPrivateKey (*XvGetScreenKeyProc)(void);
286extern _X_EXPORT unsigned long (*XvGetRTPortProc)(void);
287extern _X_EXPORT int (*XvScreenInitProc)(ScreenPtr);
288
289#endif  /* _XF86XV_H_ */
290