kxv.h revision 05b261ec
1/*
2
3   XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
4   Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
5
6   Copyright (C) 2000, 2001 - Nokia Home Communications
7   Copyright (C) 1998, 1999 - The XFree86 Project Inc.
8
9All rights reserved.
10
11Permission is hereby granted, free of charge, to any person obtaining
12a copy of this software and associated documentation files (the
13"Software"), to deal in the Software without restriction, including
14without limitation the rights to use, copy, modify, merge, publish,
15distribute, and/or sell copies of the Software, and to permit persons
16to whom the Software is furnished to do so, provided that the above
17copyright notice(s) and this permission notice appear in all copies of
18the Software and that both the above copyright notice(s) and this
19permission notice appear in supporting documentation.
20
21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
24OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
26SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
27RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
28CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
29CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30
31Except as contained in this notice, the name of a copyright holder
32shall not be used in advertising or otherwise to promote the sale, use
33or other dealings in this Software without prior written authorization
34of the copyright holder.
35
36*/
37
38#ifndef _XVDIX_H_
39#define _XVDIX_H_
40
41#include "scrnintstr.h"
42#include "regionstr.h"
43#include "windowstr.h"
44#include "pixmapstr.h"
45#include "mivalidate.h"
46#include "validate.h"
47#include "resource.h"
48#include "gcstruct.h"
49#include "dixstruct.h"
50
51#include "../../Xext/xvdix.h"
52
53#define VIDEO_NO_CLIPPING			0x00000001
54#define VIDEO_INVERT_CLIPLIST			0x00000002
55#define VIDEO_OVERLAID_IMAGES			0x00000004
56#define VIDEO_OVERLAID_STILLS			0x00000008
57#define VIDEO_CLIP_TO_VIEWPORT			0x00000010
58
59typedef struct {
60  int id;
61  int type;
62  int byte_order;
63  unsigned char guid[16];
64  int bits_per_pixel;
65  int format;
66  int num_planes;
67
68  /* for RGB formats only */
69  int depth;
70  unsigned int red_mask;
71  unsigned int green_mask;
72  unsigned int blue_mask;
73
74  /* for YUV formats only */
75  unsigned int y_sample_bits;
76  unsigned int u_sample_bits;
77  unsigned int v_sample_bits;
78  unsigned int horz_y_period;
79  unsigned int horz_u_period;
80  unsigned int horz_v_period;
81  unsigned int vert_y_period;
82  unsigned int vert_u_period;
83  unsigned int vert_v_period;
84  char component_order[32];
85  int scanline_order;
86} KdImageRec, *KdImagePtr;
87
88
89typedef struct {
90  KdScreenInfo * screen;
91  int id;
92  unsigned short width, height;
93  int *pitches; /* bytes */
94  int *offsets; /* in bytes from start of framebuffer */
95  DevUnion devPrivate;
96} KdSurfaceRec, *KdSurfacePtr;
97
98
99typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
100	short vid_x, short vid_y, short drw_x, short drw_y,
101	short vid_w, short vid_h, short drw_w, short drw_h,
102	RegionPtr clipBoxes, pointer data );
103typedef int (* PutStillFuncPtr)( KdScreenInfo * screen,  DrawablePtr pDraw,
104	short vid_x, short vid_y, short drw_x, short drw_y,
105	short vid_w, short vid_h, short drw_w, short drw_h,
106	RegionPtr clipBoxes, pointer data );
107typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen,  DrawablePtr pDraw,
108	short vid_x, short vid_y, short drw_x, short drw_y,
109	short vid_w, short vid_h, short drw_w, short drw_h,
110	RegionPtr clipBoxes, pointer data );
111typedef int (* GetStillFuncPtr)( KdScreenInfo * screen,  DrawablePtr pDraw,
112	short vid_x, short vid_y, short drw_x, short drw_y,
113	short vid_w, short vid_h, short drw_w, short drw_h,
114	RegionPtr clipBoxes, pointer data );
115typedef void (* StopVideoFuncPtr)(KdScreenInfo * screen, pointer data, Bool Exit);
116typedef int (* SetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
117	int value, pointer data);
118typedef int (* GetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
119	int *value, pointer data);
120typedef void (* QueryBestSizeFuncPtr)(KdScreenInfo * screen, Bool motion,
121	short vid_w, short vid_h, short drw_w, short drw_h,
122	unsigned int *p_w, unsigned int *p_h, pointer data);
123typedef int (* PutImageFuncPtr)( KdScreenInfo * screen,  DrawablePtr pDraw,
124	short src_x, short src_y, short drw_x, short drw_y,
125	short src_w, short src_h, short drw_w, short drw_h,
126	int image, unsigned char* buf, short width, short height, Bool Sync,
127	RegionPtr clipBoxes, pointer data );
128typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
129				  short drw_x, short drw_y,
130				  RegionPtr clipBoxes, pointer data );
131typedef int (*QueryImageAttributesFuncPtr)(KdScreenInfo * screen,
132	int image, unsigned short *width, unsigned short *height,
133	int *pitches, int *offsets);
134
135typedef enum {
136    XV_OFF,
137    XV_PENDING,
138    XV_ON
139} XvStatus;
140
141/*** this is what the driver needs to fill out ***/
142
143typedef struct {
144  int id;
145  char *name;
146  unsigned short width, height;
147  XvRationalRec rate;
148} KdVideoEncodingRec, *KdVideoEncodingPtr;
149
150typedef struct {
151  char 	depth;
152  short class;
153} KdVideoFormatRec, *KdVideoFormatPtr;
154
155typedef struct {
156  int   flags;
157  int   min_value;
158  int   max_value;
159  char  *name;
160} KdAttributeRec, *KdAttributePtr;
161
162typedef struct {
163  unsigned int type;
164  int flags;
165  char *name;
166  int nEncodings;
167  KdVideoEncodingPtr pEncodings;
168  int nFormats;
169  KdVideoFormatPtr pFormats;
170  int nPorts;
171  DevUnion *pPortPrivates;
172  int nAttributes;
173  KdAttributePtr pAttributes;
174  int nImages;
175  KdImagePtr pImages;
176  PutVideoFuncPtr PutVideo;
177  PutStillFuncPtr PutStill;
178  GetVideoFuncPtr GetVideo;
179  GetStillFuncPtr GetStill;
180  StopVideoFuncPtr StopVideo;
181  SetPortAttributeFuncPtr SetPortAttribute;
182  GetPortAttributeFuncPtr GetPortAttribute;
183  QueryBestSizeFuncPtr QueryBestSize;
184  PutImageFuncPtr PutImage;
185  ReputImageFuncPtr ReputImage;
186  QueryImageAttributesFuncPtr QueryImageAttributes;
187} KdVideoAdaptorRec, *KdVideoAdaptorPtr;
188
189typedef struct {
190  KdImagePtr image;
191  int flags;
192  int (*alloc_surface)(KdScreenInfo * screen,
193		  int id,
194		  unsigned short width,
195		  unsigned short height,
196		  KdSurfacePtr surface);
197  int (*free_surface)(KdSurfacePtr surface);
198  int (*display) (KdSurfacePtr surface,
199		  short vid_x, short vid_y,
200		  short drw_x, short drw_y,
201		  short vid_w, short vid_h,
202		  short drw_w, short drw_h,
203		  RegionPtr clipBoxes);
204  int (*stop)    (KdSurfacePtr surface);
205  int (*getAttribute) (KdScreenInfo * screen, Atom attr, INT32 *value);
206  int (*setAttribute) (KdScreenInfo * screen, Atom attr, INT32 value);
207  int max_width;
208  int max_height;
209  int num_attributes;
210  KdAttributePtr attributes;
211} KdOffscreenImageRec, *KdOffscreenImagePtr;
212
213Bool
214KdXVScreenInit(
215   ScreenPtr pScreen,
216   KdVideoAdaptorPtr 	*Adaptors,
217   int num
218);
219
220typedef int (* KdXVInitGenericAdaptorPtr)(KdScreenInfo * screen,
221	KdVideoAdaptorPtr **Adaptors);
222
223int
224KdXVRegisterGenericAdaptorDriver(
225    KdXVInitGenericAdaptorPtr InitFunc
226);
227
228int
229KdXVListGenericAdaptors(
230    KdScreenInfo *          screen,
231    KdVideoAdaptorPtr  **Adaptors
232);
233
234Bool
235KdXVRegisterOffscreenImages(
236   ScreenPtr pScreen,
237   KdOffscreenImagePtr images,
238   int num
239);
240
241KdOffscreenImagePtr
242KdXVQueryOffscreenImages(
243   ScreenPtr pScreen,
244   int *num
245);
246
247void
248KdXVCopyPackedData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
249   int srcPitch, int dstPitch, int srcW, int srcH, int top, int left,
250   int h, int w);
251
252void
253KdXVCopyPlanarData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
254   int srcPitch, int srcPitch2, int dstPitch, int srcW, int srcH, int height,
255   int top, int left, int h, int w, int id);
256
257void
258KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg);
259
260KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen);
261
262void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr);
263
264/* Must be called from KdCardInfo functions, can be called without Xv enabled */
265Bool KdXVEnable(ScreenPtr);
266void KdXVDisable(ScreenPtr);
267
268/*** These are DDX layer privates ***/
269
270
271typedef struct {
272   CreateWindowProcPtr		CreateWindow;
273   DestroyWindowProcPtr		DestroyWindow;
274   ClipNotifyProcPtr		ClipNotify;
275   WindowExposuresProcPtr	WindowExposures;
276} KdXVScreenRec, *KdXVScreenPtr;
277
278typedef struct {
279  int flags;
280  PutVideoFuncPtr PutVideo;
281  PutStillFuncPtr PutStill;
282  GetVideoFuncPtr GetVideo;
283  GetStillFuncPtr GetStill;
284  StopVideoFuncPtr StopVideo;
285  SetPortAttributeFuncPtr SetPortAttribute;
286  GetPortAttributeFuncPtr GetPortAttribute;
287  QueryBestSizeFuncPtr QueryBestSize;
288  PutImageFuncPtr PutImage;
289  ReputImageFuncPtr ReputImage;
290  QueryImageAttributesFuncPtr QueryImageAttributes;
291} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
292
293typedef struct {
294   KdScreenInfo * screen;
295   DrawablePtr pDraw;
296   unsigned char type;
297   unsigned int subWindowMode;
298   DDXPointRec clipOrg;
299   RegionPtr clientClip;
300   RegionPtr pCompositeClip;
301   Bool FreeCompositeClip;
302   XvAdaptorRecPrivatePtr AdaptorRec;
303   XvStatus isOn;
304   Bool moved;
305   int vid_x, vid_y, vid_w, vid_h;
306   int drw_x, drw_y, drw_w, drw_h;
307   DevUnion DevPriv;
308} XvPortRecPrivate, *XvPortRecPrivatePtr;
309
310typedef struct _KdXVWindowRec{
311   XvPortRecPrivatePtr PortRec;
312   struct _KdXVWindowRec *next;
313} KdXVWindowRec, *KdXVWindowPtr;
314
315#endif  /* _XVDIX_H_ */
316
317