1706f2543Smrg
2706f2543Smrg/*
3706f2543Smrg * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
4706f2543Smrg *
5706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a
6706f2543Smrg * copy of this software and associated documentation files (the "Software"),
7706f2543Smrg * to deal in the Software without restriction, including without limitation
8706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the
10706f2543Smrg * Software is furnished to do so, subject to the following conditions:
11706f2543Smrg *
12706f2543Smrg * The above copyright notice and this permission notice shall be included in
13706f2543Smrg * all copies or substantial portions of the Software.
14706f2543Smrg *
15706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18706f2543Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19706f2543Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20706f2543Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21706f2543Smrg * OTHER DEALINGS IN THE SOFTWARE.
22706f2543Smrg *
23706f2543Smrg * Except as contained in this notice, the name of the copyright holder(s)
24706f2543Smrg * and author(s) shall not be used in advertising or otherwise to promote
25706f2543Smrg * the sale, use or other dealings in this Software without prior written
26706f2543Smrg * authorization from the copyright holder(s) and author(s).
27706f2543Smrg */
28706f2543Smrg
29706f2543Smrg#ifndef _XF86XV_H_
30706f2543Smrg#define _XF86XV_H_
31706f2543Smrg
32706f2543Smrg#include "xvdix.h"
33706f2543Smrg#include "xf86str.h"
34706f2543Smrg
35706f2543Smrg#define VIDEO_NO_CLIPPING			0x00000001
36706f2543Smrg#define VIDEO_INVERT_CLIPLIST			0x00000002
37706f2543Smrg#define VIDEO_OVERLAID_IMAGES			0x00000004
38706f2543Smrg#define VIDEO_OVERLAID_STILLS			0x00000008
39706f2543Smrg/*
40706f2543Smrg * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended.
41706f2543Smrg * It can make reput behaviour inconsistent.
42706f2543Smrg */
43706f2543Smrg#define VIDEO_CLIP_TO_VIEWPORT			0x00000010
44706f2543Smrg
45706f2543Smrgtypedef struct {
46706f2543Smrg  int id;
47706f2543Smrg  int type;
48706f2543Smrg  int byte_order;
49706f2543Smrg  unsigned char guid[16];
50706f2543Smrg  int bits_per_pixel;
51706f2543Smrg  int format;
52706f2543Smrg  int num_planes;
53706f2543Smrg
54706f2543Smrg  /* for RGB formats only */
55706f2543Smrg  int depth;
56706f2543Smrg  unsigned int red_mask;
57706f2543Smrg  unsigned int green_mask;
58706f2543Smrg  unsigned int blue_mask;
59706f2543Smrg
60706f2543Smrg  /* for YUV formats only */
61706f2543Smrg  unsigned int y_sample_bits;
62706f2543Smrg  unsigned int u_sample_bits;
63706f2543Smrg  unsigned int v_sample_bits;
64706f2543Smrg  unsigned int horz_y_period;
65706f2543Smrg  unsigned int horz_u_period;
66706f2543Smrg  unsigned int horz_v_period;
67706f2543Smrg  unsigned int vert_y_period;
68706f2543Smrg  unsigned int vert_u_period;
69706f2543Smrg  unsigned int vert_v_period;
70706f2543Smrg  char component_order[32];
71706f2543Smrg  int scanline_order;
72706f2543Smrg} XF86ImageRec, *XF86ImagePtr;
73706f2543Smrg
74706f2543Smrg
75706f2543Smrgtypedef struct {
76706f2543Smrg  ScrnInfoPtr pScrn;
77706f2543Smrg  int id;
78706f2543Smrg  unsigned short width, height;
79706f2543Smrg  int *pitches; /* bytes */
80706f2543Smrg  int *offsets; /* in bytes from start of framebuffer */
81706f2543Smrg  DevUnion devPrivate;
82706f2543Smrg} XF86SurfaceRec, *XF86SurfacePtr;
83706f2543Smrg
84706f2543Smrg
85706f2543Smrgtypedef int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
86706f2543Smrg	short vid_x, short vid_y, short drw_x, short drw_y,
87706f2543Smrg	short vid_w, short vid_h, short drw_w, short drw_h,
88706f2543Smrg	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
89706f2543Smrgtypedef int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
90706f2543Smrg	short vid_x, short vid_y, short drw_x, short drw_y,
91706f2543Smrg	short vid_w, short vid_h, short drw_w, short drw_h,
92706f2543Smrg	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
93706f2543Smrgtypedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
94706f2543Smrg	short vid_x, short vid_y, short drw_x, short drw_y,
95706f2543Smrg	short vid_w, short vid_h, short drw_w, short drw_h,
96706f2543Smrg	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
97706f2543Smrgtypedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
98706f2543Smrg	short vid_x, short vid_y, short drw_x, short drw_y,
99706f2543Smrg	short vid_w, short vid_h, short drw_w, short drw_h,
100706f2543Smrg	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
101706f2543Smrgtypedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn, pointer data, Bool Exit);
102706f2543Smrgtypedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
103706f2543Smrg	INT32 value, pointer data);
104706f2543Smrgtypedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn, Atom attribute,
105706f2543Smrg	INT32 *value, pointer data);
106706f2543Smrgtypedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn, Bool motion,
107706f2543Smrg	short vid_w, short vid_h, short drw_w, short drw_h,
108706f2543Smrg	unsigned int *p_w, unsigned int *p_h, pointer data);
109706f2543Smrgtypedef int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
110706f2543Smrg	short src_x, short src_y, short drw_x, short drw_y,
111706f2543Smrg	short src_w, short src_h, short drw_w, short drw_h,
112706f2543Smrg	int image, unsigned char* buf, short width, short height, Bool Sync,
113706f2543Smrg	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
114706f2543Smrgtypedef int (* ReputImageFuncPtr)( ScrnInfoPtr pScrn,
115706f2543Smrg	short src_x, short src_y, short drw_x, short drw_y,
116706f2543Smrg	short src_w, short src_h, short drw_w, short drw_h,
117706f2543Smrg	RegionPtr clipBoxes, pointer data, DrawablePtr pDraw );
118706f2543Smrgtypedef int (*QueryImageAttributesFuncPtr)(ScrnInfoPtr pScrn,
119706f2543Smrg	int image, unsigned short *width, unsigned short *height,
120706f2543Smrg	int *pitches, int *offsets);
121706f2543Smrgtypedef void (*ClipNotifyFuncPtr)(ScrnInfoPtr pScrn, pointer data,
122706f2543Smrg                                  WindowPtr window, int dx, int dy);
123706f2543Smrg
124706f2543Smrgtypedef enum {
125706f2543Smrg    XV_OFF,
126706f2543Smrg    XV_PENDING,
127706f2543Smrg    XV_ON
128706f2543Smrg} XvStatus;
129706f2543Smrg
130706f2543Smrg/*** this is what the driver needs to fill out ***/
131706f2543Smrg
132706f2543Smrgtypedef struct {
133706f2543Smrg  int id;
134706f2543Smrg  char *name;
135706f2543Smrg  unsigned short width, height;
136706f2543Smrg  XvRationalRec rate;
137706f2543Smrg} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
138706f2543Smrg
139706f2543Smrgtypedef struct {
140706f2543Smrg  char 	depth;
141706f2543Smrg  short class;
142706f2543Smrg} XF86VideoFormatRec, *XF86VideoFormatPtr;
143706f2543Smrg
144706f2543Smrgtypedef struct {
145706f2543Smrg  int   flags;
146706f2543Smrg  int   min_value;
147706f2543Smrg  int   max_value;
148706f2543Smrg  char  *name;
149706f2543Smrg} XF86AttributeRec, *XF86AttributePtr;
150706f2543Smrg
151706f2543Smrgtypedef struct {
152706f2543Smrg  unsigned int type;
153706f2543Smrg  int flags;
154706f2543Smrg  char *name;
155706f2543Smrg  int nEncodings;
156706f2543Smrg  XF86VideoEncodingPtr pEncodings;
157706f2543Smrg  int nFormats;
158706f2543Smrg  XF86VideoFormatPtr pFormats;
159706f2543Smrg  int nPorts;
160706f2543Smrg  DevUnion *pPortPrivates;
161706f2543Smrg  int nAttributes;
162706f2543Smrg  XF86AttributePtr pAttributes;
163706f2543Smrg  int nImages;
164706f2543Smrg  XF86ImagePtr pImages;
165706f2543Smrg  PutVideoFuncPtr PutVideo;
166706f2543Smrg  PutStillFuncPtr PutStill;
167706f2543Smrg  GetVideoFuncPtr GetVideo;
168706f2543Smrg  GetStillFuncPtr GetStill;
169706f2543Smrg  StopVideoFuncPtr StopVideo;
170706f2543Smrg  SetPortAttributeFuncPtr SetPortAttribute;
171706f2543Smrg  GetPortAttributeFuncPtr GetPortAttribute;
172706f2543Smrg  QueryBestSizeFuncPtr QueryBestSize;
173706f2543Smrg  PutImageFuncPtr PutImage;
174706f2543Smrg  ReputImageFuncPtr ReputImage; /* image/still */
175706f2543Smrg  QueryImageAttributesFuncPtr QueryImageAttributes;
176706f2543Smrg  ClipNotifyFuncPtr ClipNotify;
177706f2543Smrg} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
178706f2543Smrg
179706f2543Smrgtypedef struct {
180706f2543Smrg  XF86ImagePtr image;
181706f2543Smrg  int flags;
182706f2543Smrg  int (*alloc_surface)(ScrnInfoPtr pScrn,
183706f2543Smrg		  int id,
184706f2543Smrg		  unsigned short width,
185706f2543Smrg		  unsigned short height,
186706f2543Smrg		  XF86SurfacePtr surface);
187706f2543Smrg  int (*free_surface)(XF86SurfacePtr surface);
188706f2543Smrg  int (*display) (XF86SurfacePtr surface,
189706f2543Smrg		  short vid_x, short vid_y,
190706f2543Smrg		  short drw_x, short drw_y,
191706f2543Smrg		  short vid_w, short vid_h,
192706f2543Smrg		  short drw_w, short drw_h,
193706f2543Smrg		  RegionPtr clipBoxes);
194706f2543Smrg  int (*stop)    (XF86SurfacePtr surface);
195706f2543Smrg  int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
196706f2543Smrg  int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
197706f2543Smrg  int max_width;
198706f2543Smrg  int max_height;
199706f2543Smrg  int num_attributes;
200706f2543Smrg  XF86AttributePtr attributes;
201706f2543Smrg} XF86OffscreenImageRec, *XF86OffscreenImagePtr;
202706f2543Smrg
203706f2543Smrgextern _X_EXPORT Bool
204706f2543Smrgxf86XVScreenInit(
205706f2543Smrg   ScreenPtr pScreen,
206706f2543Smrg   XF86VideoAdaptorPtr 	*Adaptors,
207706f2543Smrg   int num
208706f2543Smrg);
209706f2543Smrg
210706f2543Smrgtypedef int (* xf86XVInitGenericAdaptorPtr)(ScrnInfoPtr pScrn,
211706f2543Smrg	XF86VideoAdaptorPtr **Adaptors);
212706f2543Smrg
213706f2543Smrgextern _X_EXPORT int
214706f2543Smrgxf86XVRegisterGenericAdaptorDriver(
215706f2543Smrg    xf86XVInitGenericAdaptorPtr InitFunc
216706f2543Smrg);
217706f2543Smrg
218706f2543Smrgextern _X_EXPORT int
219706f2543Smrgxf86XVListGenericAdaptors(
220706f2543Smrg    ScrnInfoPtr          pScrn,
221706f2543Smrg    XF86VideoAdaptorPtr  **Adaptors
222706f2543Smrg);
223706f2543Smrg
224706f2543Smrgextern _X_EXPORT Bool
225706f2543Smrgxf86XVRegisterOffscreenImages(
226706f2543Smrg   ScreenPtr pScreen,
227706f2543Smrg   XF86OffscreenImagePtr images,
228706f2543Smrg   int num
229706f2543Smrg);
230706f2543Smrg
231706f2543Smrgextern _X_EXPORT XF86OffscreenImagePtr
232706f2543Smrgxf86XVQueryOffscreenImages(
233706f2543Smrg   ScreenPtr pScreen,
234706f2543Smrg   int *num
235706f2543Smrg);
236706f2543Smrg
237706f2543Smrgextern _X_EXPORT XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn);
238706f2543Smrg
239706f2543Smrgextern _X_EXPORT void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
240706f2543Smrg
241706f2543Smrgextern _X_EXPORT void
242706f2543Smrgxf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
243706f2543Smrg
244706f2543Smrgextern _X_EXPORT void
245706f2543Smrgxf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
246706f2543Smrg
247706f2543Smrgextern _X_EXPORT void
248706f2543Smrgxf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything);
249706f2543Smrg
250706f2543Smrgextern _X_EXPORT Bool
251706f2543Smrgxf86XVClipVideoHelper(
252706f2543Smrg    BoxPtr dst,
253706f2543Smrg    INT32 *xa,
254706f2543Smrg    INT32 *xb,
255706f2543Smrg    INT32 *ya,
256706f2543Smrg    INT32 *yb,
257706f2543Smrg    RegionPtr reg,
258706f2543Smrg    INT32 width,
259706f2543Smrg    INT32 height
260706f2543Smrg);
261706f2543Smrg
262706f2543Smrgextern _X_EXPORT void
263706f2543Smrgxf86XVCopyYUV12ToPacked(
264706f2543Smrg    const void *srcy,
265706f2543Smrg    const void *srcv,
266706f2543Smrg    const void *srcu,
267706f2543Smrg    void *dst,
268706f2543Smrg    int srcPitchy,
269706f2543Smrg    int srcPitchuv,
270706f2543Smrg    int dstPitch,
271706f2543Smrg    int h,
272706f2543Smrg    int w
273706f2543Smrg);
274706f2543Smrg
275706f2543Smrgextern _X_EXPORT void
276706f2543Smrgxf86XVCopyPacked(
277706f2543Smrg    const void *src,
278706f2543Smrg    void *dst,
279706f2543Smrg    int srcPitch,
280706f2543Smrg    int dstPitch,
281706f2543Smrg    int h,
282706f2543Smrg    int w
283706f2543Smrg);
284706f2543Smrg
285706f2543Smrgextern _X_EXPORT DevPrivateKey (*XvGetScreenKeyProc)(void);
286706f2543Smrgextern _X_EXPORT unsigned long (*XvGetRTPortProc)(void);
287706f2543Smrgextern _X_EXPORT int (*XvScreenInitProc)(ScreenPtr);
288706f2543Smrg
289706f2543Smrg#endif  /* _XF86XV_H_ */
290