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
189Bool
190KdXVScreenInit(
191   ScreenPtr pScreen,
192   KdVideoAdaptorPtr 	*Adaptors,
193   int num
194);
195
196typedef int (* KdXVInitGenericAdaptorPtr)(KdScreenInfo * screen,
197	KdVideoAdaptorPtr **Adaptors);
198
199int
200KdXVRegisterGenericAdaptorDriver(
201    KdXVInitGenericAdaptorPtr InitFunc
202);
203
204int
205KdXVListGenericAdaptors(
206    KdScreenInfo *          screen,
207    KdVideoAdaptorPtr  **Adaptors
208);
209
210void
211KdXVCopyPackedData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
212   int srcPitch, int dstPitch, int srcW, int srcH, int top, int left,
213   int h, int w);
214
215void
216KdXVCopyPlanarData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
217   int srcPitch, int srcPitch2, int dstPitch, int srcW, int srcH, int height,
218   int top, int left, int h, int w, int id);
219
220void
221KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg);
222
223KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen);
224
225void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr);
226
227/* Must be called from KdCardInfo functions, can be called without Xv enabled */
228Bool KdXVEnable(ScreenPtr);
229void KdXVDisable(ScreenPtr);
230
231/*** These are DDX layer privates ***/
232
233
234typedef struct {
235   CreateWindowProcPtr		CreateWindow;
236   DestroyWindowProcPtr		DestroyWindow;
237   ClipNotifyProcPtr		ClipNotify;
238   WindowExposuresProcPtr	WindowExposures;
239} KdXVScreenRec, *KdXVScreenPtr;
240
241typedef struct {
242  int flags;
243  PutVideoFuncPtr PutVideo;
244  PutStillFuncPtr PutStill;
245  GetVideoFuncPtr GetVideo;
246  GetStillFuncPtr GetStill;
247  StopVideoFuncPtr StopVideo;
248  SetPortAttributeFuncPtr SetPortAttribute;
249  GetPortAttributeFuncPtr GetPortAttribute;
250  QueryBestSizeFuncPtr QueryBestSize;
251  PutImageFuncPtr PutImage;
252  ReputImageFuncPtr ReputImage;
253  QueryImageAttributesFuncPtr QueryImageAttributes;
254} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
255
256typedef struct {
257   KdScreenInfo * screen;
258   DrawablePtr pDraw;
259   unsigned char type;
260   unsigned int subWindowMode;
261   DDXPointRec clipOrg;
262   RegionPtr clientClip;
263   RegionPtr pCompositeClip;
264   Bool FreeCompositeClip;
265   XvAdaptorRecPrivatePtr AdaptorRec;
266   XvStatus isOn;
267   Bool moved;
268   int vid_x, vid_y, vid_w, vid_h;
269   int drw_x, drw_y, drw_w, drw_h;
270   DevUnion DevPriv;
271} XvPortRecPrivate, *XvPortRecPrivatePtr;
272
273typedef struct _KdXVWindowRec{
274   XvPortRecPrivatePtr PortRec;
275   struct _KdXVWindowRec *next;
276} KdXVWindowRec, *KdXVWindowPtr;
277
278#endif  /* _XVDIX_H_ */
279
280