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_OVERLAID_IMAGES			0x00000004
36 #define VIDEO_OVERLAID_STILLS			0x00000008
37 /*
38  * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended.
39  * It can make reput behaviour inconsistent.
40  */
41 #define VIDEO_CLIP_TO_VIEWPORT			0x00000010
42 
43 typedef XvImageRec XF86ImageRec, *XF86ImagePtr;
44 
45 typedef struct {
46     ScrnInfoPtr pScrn;
47     int id;
48     unsigned short width, height;
49     int *pitches;               /* bytes */
50     int *offsets;               /* in bytes from start of framebuffer */
51     DevUnion devPrivate;
52 } XF86SurfaceRec, *XF86SurfacePtr;
53 
54 typedef int (*PutVideoFuncPtr) (ScrnInfoPtr pScrn,
55                                 short vid_x, short vid_y, short drw_x,
56                                 short drw_y, short vid_w, short vid_h,
57                                 short drw_w, short drw_h, RegionPtr clipBoxes,
58                                 void *data, DrawablePtr pDraw);
59 typedef int (*PutStillFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
60                                 short drw_x, short drw_y, short vid_w,
61                                 short vid_h, short drw_w, short drw_h,
62                                 RegionPtr clipBoxes, void *data,
63                                 DrawablePtr pDraw);
64 typedef int (*GetVideoFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
65                                 short drw_x, short drw_y, short vid_w,
66                                 short vid_h, short drw_w, short drw_h,
67                                 RegionPtr clipBoxes, void *data,
68                                 DrawablePtr pDraw);
69 typedef int (*GetStillFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
70                                 short drw_x, short drw_y, short vid_w,
71                                 short vid_h, short drw_w, short drw_h,
72                                 RegionPtr clipBoxes, void *data,
73                                 DrawablePtr pDraw);
74 typedef void (*StopVideoFuncPtr) (ScrnInfoPtr pScrn, void *data, Bool Exit);
75 typedef int (*SetPortAttributeFuncPtr) (ScrnInfoPtr pScrn, Atom attribute,
76                                         INT32 value, void *data);
77 typedef int (*GetPortAttributeFuncPtr) (ScrnInfoPtr pScrn, Atom attribute,
78                                         INT32 *value, void *data);
79 typedef void (*QueryBestSizeFuncPtr) (ScrnInfoPtr pScrn, Bool motion,
80                                       short vid_w, short vid_h, short drw_w,
81                                       short drw_h, unsigned int *p_w,
82                                       unsigned int *p_h, void *data);
83 typedef int (*PutImageFuncPtr) (ScrnInfoPtr pScrn, short src_x, short src_y,
84                                 short drw_x, short drw_y, short src_w,
85                                 short src_h, short drw_w, short drw_h,
86                                 int image, unsigned char *buf, short width,
87                                 short height, Bool Sync, RegionPtr clipBoxes,
88                                 void *data, DrawablePtr pDraw);
89 typedef int (*ReputImageFuncPtr) (ScrnInfoPtr pScrn, short src_x, short src_y,
90                                   short drw_x, short drw_y, short src_w,
91                                   short src_h, short drw_w, short drw_h,
92                                   RegionPtr clipBoxes, void *data,
93                                   DrawablePtr pDraw);
94 typedef int (*QueryImageAttributesFuncPtr) (ScrnInfoPtr pScrn, int image,
95                                             unsigned short *width,
96                                             unsigned short *height,
97                                             int *pitches, int *offsets);
98 
99 typedef enum {
100     XV_OFF,
101     XV_PENDING,
102     XV_ON
103 } XvStatus;
104 
105 /*** this is what the driver needs to fill out ***/
106 
107 typedef struct {
108     int id;
109     const char *name;
110     unsigned short width, height;
111     XvRationalRec rate;
112 } XF86VideoEncodingRec, *XF86VideoEncodingPtr;
113 
114 typedef struct {
115     char depth;
116     short class;
117 } XF86VideoFormatRec, *XF86VideoFormatPtr;
118 
119 typedef XvAttributeRec XF86AttributeRec, *XF86AttributePtr;
120 
121 typedef struct {
122     unsigned int type;
123     int flags;
124     const char *name;
125     int nEncodings;
126     XF86VideoEncodingPtr pEncodings;
127     int nFormats;
128     XF86VideoFormatPtr pFormats;
129     int nPorts;
130     DevUnion *pPortPrivates;
131     int nAttributes;
132     XF86AttributePtr pAttributes;
133     int nImages;
134     XF86ImagePtr pImages;
135     PutVideoFuncPtr PutVideo;
136     PutStillFuncPtr PutStill;
137     GetVideoFuncPtr GetVideo;
138     GetStillFuncPtr GetStill;
139     StopVideoFuncPtr StopVideo;
140     SetPortAttributeFuncPtr SetPortAttribute;
141     GetPortAttributeFuncPtr GetPortAttribute;
142     QueryBestSizeFuncPtr QueryBestSize;
143     PutImageFuncPtr PutImage;
144     ReputImageFuncPtr ReputImage;       /* image/still */
145     QueryImageAttributesFuncPtr QueryImageAttributes;
146 } XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
147 
148 typedef struct {
149     XF86ImagePtr image;
150     int flags;
151     int (*alloc_surface) (ScrnInfoPtr pScrn,
152                           int id,
153                           unsigned short width,
154                           unsigned short height, XF86SurfacePtr surface);
155     int (*free_surface) (XF86SurfacePtr surface);
156     int (*display) (XF86SurfacePtr surface,
157                     short vid_x, short vid_y,
158                     short drw_x, short drw_y,
159                     short vid_w, short vid_h,
160                     short drw_w, short drw_h, RegionPtr clipBoxes);
161     int (*stop) (XF86SurfacePtr surface);
162     int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
163     int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
164     int max_width;
165     int max_height;
166     int num_attributes;
167     XF86AttributePtr attributes;
168 } XF86OffscreenImageRec, *XF86OffscreenImagePtr;
169 
170 extern _X_EXPORT Bool
171  xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * Adaptors, int num);
172 
173 typedef int (*xf86XVInitGenericAdaptorPtr) (ScrnInfoPtr pScrn,
174                                             XF86VideoAdaptorPtr ** Adaptors);
175 
176 extern _X_EXPORT int
177  xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc);
178 
179 extern _X_EXPORT int
180  xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** Adaptors);
181 
182 extern _X_EXPORT Bool
183 
184 xf86XVRegisterOffscreenImages(ScreenPtr pScreen,
185                               XF86OffscreenImagePtr images, int num);
186 
187 extern _X_EXPORT XF86OffscreenImagePtr
188 xf86XVQueryOffscreenImages(ScreenPtr pScreen, int *num);
189 
190 extern _X_EXPORT XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr
191                                                                    pScrn);
192 
193 extern _X_EXPORT void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
194 
195 extern _X_EXPORT void
196  xf86XVFillKeyHelper(ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
197 
198 extern _X_EXPORT void
199 
200 xf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
201 
202 extern _X_EXPORT void
203 
204 xf86XVFillKeyHelperPort(DrawablePtr pDraw, void *data, CARD32 key,
205                         RegionPtr clipboxes, Bool fillEverything);
206 
207 extern _X_EXPORT Bool
208 
209 xf86XVClipVideoHelper(BoxPtr dst,
210                       INT32 *xa,
211                       INT32 *xb,
212                       INT32 *ya,
213                       INT32 *yb, RegionPtr reg, INT32 width, INT32 height);
214 
215 extern _X_EXPORT void
216 
217 xf86XVCopyYUV12ToPacked(const void *srcy,
218                         const void *srcv,
219                         const void *srcu,
220                         void *dst,
221                         int srcPitchy,
222                         int srcPitchuv, int dstPitch, int h, int w);
223 
224 extern _X_EXPORT void
225 
226 xf86XVCopyPacked(const void *src,
227                  void *dst, int srcPitch, int dstPitch, int h, int w);
228 
229 #endif                          /* _XF86XV_H_ */
230