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 
9 All rights reserved.
10 
11 Permission is hereby granted, free of charge, to any person obtaining
12 a copy of this software and associated documentation files (the
13 "Software"), to deal in the Software without restriction, including
14 without limitation the rights to use, copy, modify, merge, publish,
15 distribute, and/or sell copies of the Software, and to permit persons
16 to whom the Software is furnished to do so, provided that the above
17 copyright notice(s) and this permission notice appear in all copies of
18 the Software and that both the above copyright notice(s) and this
19 permission notice appear in supporting documentation.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
24 OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
26 SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
27 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
28 CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
29 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 
31 Except as contained in this notice, the name of a copyright holder
32 shall not be used in advertising or otherwise to promote the sale, use
33 or other dealings in this Software without prior written authorization
34 of 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_OVERLAID_IMAGES			0x00000004
54 #define VIDEO_OVERLAID_STILLS			0x00000008
55 #define VIDEO_CLIP_TO_VIEWPORT			0x00000010
56 
57 typedef int (*PutVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
58                                 short vid_x, short vid_y, short drw_x,
59                                 short drw_y, short vid_w, short vid_h,
60                                 short drw_w, short drw_h, RegionPtr clipBoxes,
61                                 void *data);
62 typedef int (*PutStillFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
63                                 short vid_x, short vid_y, short drw_x,
64                                 short drw_y, short vid_w, short vid_h,
65                                 short drw_w, short drw_h, RegionPtr clipBoxes,
66                                 void *data);
67 typedef int (*GetVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
68                                 short vid_x, short vid_y, short drw_x,
69                                 short drw_y, short vid_w, short vid_h,
70                                 short drw_w, short drw_h, RegionPtr clipBoxes,
71                                 void *data);
72 typedef int (*GetStillFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
73                                 short vid_x, short vid_y, short drw_x,
74                                 short drw_y, short vid_w, short vid_h,
75                                 short drw_w, short drw_h, RegionPtr clipBoxes,
76                                 void *data);
77 typedef void (*StopVideoFuncPtr) (KdScreenInfo * screen, void *data,
78                                   Bool Exit);
79 typedef int (*SetPortAttributeFuncPtr) (KdScreenInfo * screen, Atom attribute,
80                                         int value, void *data);
81 typedef int (*GetPortAttributeFuncPtr) (KdScreenInfo * screen, Atom attribute,
82                                         int *value, void *data);
83 typedef void (*QueryBestSizeFuncPtr) (KdScreenInfo * screen, Bool motion,
84                                       short vid_w, short vid_h, short drw_w,
85                                       short drw_h, unsigned int *p_w,
86                                       unsigned int *p_h, void *data);
87 typedef int (*PutImageFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
88                                 short src_x, short src_y, short drw_x,
89                                 short drw_y, short src_w, short src_h,
90                                 short drw_w, short drw_h, int image,
91                                 unsigned char *buf, short width, short height,
92                                 Bool Sync, RegionPtr clipBoxes, void *data);
93 typedef int (*ReputImageFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw,
94                                   short drw_x, short drw_y, RegionPtr clipBoxes,
95                                   void *data);
96 typedef int (*QueryImageAttributesFuncPtr) (KdScreenInfo * screen, int image,
97                                             unsigned short *width,
98                                             unsigned short *height,
99                                             int *pitches, int *offsets);
100 
101 typedef enum {
102     XV_OFF,
103     XV_PENDING,
104     XV_ON
105 } XvStatus;
106 
107 /*** this is what the driver needs to fill out ***/
108 
109 typedef struct {
110     int id;
111     const char *name;
112     unsigned short width, height;
113     XvRationalRec rate;
114 } KdVideoEncodingRec, *KdVideoEncodingPtr;
115 
116 typedef struct {
117     char depth;
118     short class;
119 } KdVideoFormatRec, *KdVideoFormatPtr;
120 
121 typedef struct {
122     unsigned int type;
123     int flags;
124     const char *name;
125     int nEncodings;
126     KdVideoEncodingPtr pEncodings;
127     int nFormats;
128     KdVideoFormatPtr pFormats;
129     int nPorts;
130     DevUnion *pPortPrivates;
131     int nAttributes;
132     XvAttributePtr pAttributes;
133     int nImages;
134     XvImagePtr 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;
145     QueryImageAttributesFuncPtr QueryImageAttributes;
146 } KdVideoAdaptorRec, *KdVideoAdaptorPtr;
147 
148 Bool
149  KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr Adaptors, int num);
150 
151 /*** These are DDX layer privates ***/
152 
153 typedef struct {
154     DestroyWindowProcPtr DestroyWindow;
155     ClipNotifyProcPtr ClipNotify;
156     WindowExposuresProcPtr WindowExposures;
157     CloseScreenProcPtr CloseScreen;
158 } KdXVScreenRec, *KdXVScreenPtr;
159 
160 typedef struct {
161     int flags;
162     PutVideoFuncPtr PutVideo;
163     PutStillFuncPtr PutStill;
164     GetVideoFuncPtr GetVideo;
165     GetStillFuncPtr GetStill;
166     StopVideoFuncPtr StopVideo;
167     SetPortAttributeFuncPtr SetPortAttribute;
168     GetPortAttributeFuncPtr GetPortAttribute;
169     QueryBestSizeFuncPtr QueryBestSize;
170     PutImageFuncPtr PutImage;
171     ReputImageFuncPtr ReputImage;
172     QueryImageAttributesFuncPtr QueryImageAttributes;
173 } XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
174 
175 typedef struct {
176     KdScreenInfo *screen;
177     DrawablePtr pDraw;
178     unsigned char type;
179     unsigned int subWindowMode;
180     DDXPointRec clipOrg;
181     RegionPtr clientClip;
182     RegionPtr pCompositeClip;
183     Bool FreeCompositeClip;
184     XvAdaptorRecPrivatePtr AdaptorRec;
185     XvStatus isOn;
186     Bool moved;
187     int vid_x, vid_y, vid_w, vid_h;
188     int drw_x, drw_y, drw_w, drw_h;
189     DevUnion DevPriv;
190 } XvPortRecPrivate, *XvPortRecPrivatePtr;
191 
192 typedef struct _KdXVWindowRec {
193     XvPortRecPrivatePtr PortRec;
194     struct _KdXVWindowRec *next;
195 } KdXVWindowRec, *KdXVWindowPtr;
196 
197 #endif                          /* _XVDIX_H_ */
198