| 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_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 | |
| 59 | typedef 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 | typedef struct { |
| 89 | KdScreenInfo *screen; |
| 90 | int id; |
| 91 | unsigned short width, height; |
| 92 | int *pitches; /* bytes */ |
| 93 | int *offsets; /* in bytes from start of framebuffer */ |
| 94 | DevUnion devPrivate; |
| 95 | } KdSurfaceRec, *KdSurfacePtr; |
| 96 | |
| 97 | typedef int (*PutVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw, |
| 98 | short vid_x, short vid_y, short drw_x, |
| 99 | short drw_y, short vid_w, short vid_h, |
| 100 | short drw_w, short drw_h, RegionPtr clipBoxes, |
| 101 | pointer data); |
| 102 | typedef int (*PutStillFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw, |
| 103 | short vid_x, short vid_y, short drw_x, |
| 104 | short drw_y, short vid_w, short vid_h, |
| 105 | short drw_w, short drw_h, RegionPtr clipBoxes, |
| 106 | pointer data); |
| 107 | typedef int (*GetVideoFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw, |
| 108 | short vid_x, short vid_y, short drw_x, |
| 109 | short drw_y, short vid_w, short vid_h, |
| 110 | short drw_w, short drw_h, RegionPtr clipBoxes, |
| 111 | pointer data); |
| 112 | typedef int (*GetStillFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw, |
| 113 | short vid_x, short vid_y, short drw_x, |
| 114 | short drw_y, short vid_w, short vid_h, |
| 115 | short drw_w, short drw_h, RegionPtr clipBoxes, |
| 116 | pointer data); |
| 117 | typedef void (*StopVideoFuncPtr) (KdScreenInfo * screen, pointer data, |
| 118 | Bool Exit); |
| 119 | typedef int (*SetPortAttributeFuncPtr) (KdScreenInfo * screen, Atom attribute, |
| 120 | int value, pointer data); |
| 121 | typedef int (*GetPortAttributeFuncPtr) (KdScreenInfo * screen, Atom attribute, |
| 122 | int *value, pointer data); |
| 123 | typedef void (*QueryBestSizeFuncPtr) (KdScreenInfo * screen, Bool motion, |
| 124 | short vid_w, short vid_h, short drw_w, |
| 125 | short drw_h, unsigned int *p_w, |
| 126 | unsigned int *p_h, pointer data); |
| 127 | typedef int (*PutImageFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw, |
| 128 | short src_x, short src_y, short drw_x, |
| 129 | short drw_y, short src_w, short src_h, |
| 130 | short drw_w, short drw_h, int image, |
| 131 | unsigned char *buf, short width, short height, |
| 132 | Bool Sync, RegionPtr clipBoxes, pointer data); |
| 133 | typedef int (*ReputImageFuncPtr) (KdScreenInfo * screen, DrawablePtr pDraw, |
| 134 | short drw_x, short drw_y, RegionPtr clipBoxes, |
| 135 | pointer data); |
| 136 | typedef int (*QueryImageAttributesFuncPtr) (KdScreenInfo * screen, int image, |
| 137 | unsigned short *width, |
| 138 | unsigned short *height, |
| 139 | int *pitches, int *offsets); |
| 140 | |
| 141 | typedef enum { |
| 142 | XV_OFF, |
| 143 | XV_PENDING, |
| 144 | XV_ON |
| 145 | } XvStatus; |
| 146 | |
| 147 | /*** this is what the driver needs to fill out ***/ |
| 148 | |
| 149 | typedef struct { |
| 150 | int id; |
| 151 | char *name; |
| 152 | unsigned short width, height; |
| 153 | XvRationalRec rate; |
| 154 | } KdVideoEncodingRec, *KdVideoEncodingPtr; |
| 155 | |
| 156 | typedef struct { |
| 157 | char depth; |
| 158 | short class; |
| 159 | } KdVideoFormatRec, *KdVideoFormatPtr; |
| 160 | |
| 161 | typedef struct { |
| 162 | int flags; |
| 163 | int min_value; |
| 164 | int max_value; |
| 165 | char *name; |
| 166 | } KdAttributeRec, *KdAttributePtr; |
| 167 | |
| 168 | typedef struct { |
| 169 | unsigned int type; |
| 170 | int flags; |
| 171 | char *name; |
| 172 | int nEncodings; |
| 173 | KdVideoEncodingPtr pEncodings; |
| 174 | int nFormats; |
| 175 | KdVideoFormatPtr pFormats; |
| 176 | int nPorts; |
| 177 | DevUnion *pPortPrivates; |
| 178 | int nAttributes; |
| 179 | KdAttributePtr pAttributes; |
| 180 | int nImages; |
| 181 | KdImagePtr pImages; |
| 182 | PutVideoFuncPtr PutVideo; |
| 183 | PutStillFuncPtr PutStill; |
| 184 | GetVideoFuncPtr GetVideo; |
| 185 | GetStillFuncPtr GetStill; |
| 186 | StopVideoFuncPtr StopVideo; |
| 187 | SetPortAttributeFuncPtr SetPortAttribute; |
| 188 | GetPortAttributeFuncPtr GetPortAttribute; |
| 189 | QueryBestSizeFuncPtr QueryBestSize; |
| 190 | PutImageFuncPtr PutImage; |
| 191 | ReputImageFuncPtr ReputImage; |
| 192 | QueryImageAttributesFuncPtr QueryImageAttributes; |
| 193 | } KdVideoAdaptorRec, *KdVideoAdaptorPtr; |
| 194 | |
| 195 | Bool |
| 196 | KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr * Adaptors, int num); |
| 197 | |
| 198 | typedef int (*KdXVInitGenericAdaptorPtr) (KdScreenInfo * screen, |
| 199 | KdVideoAdaptorPtr ** Adaptors); |
| 200 | |
| 201 | int |
| 202 | KdXVRegisterGenericAdaptorDriver(KdXVInitGenericAdaptorPtr InitFunc); |
| 203 | |
| 204 | int |
| 205 | KdXVListGenericAdaptors(KdScreenInfo * screen, KdVideoAdaptorPtr ** Adaptors); |
| 206 | |
| 207 | void |
| 208 | |
| 209 | KdXVCopyPackedData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr, |
| 210 | int srcPitch, int dstPitch, int srcW, int srcH, int top, |
| 211 | int left, int h, int w); |
| 212 | |
| 213 | void |
| 214 | |
| 215 | KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr, |
| 216 | int srcPitch, int srcPitch2, int dstPitch, int srcW, |
| 217 | int srcH, int height, int top, int left, int h, int w, |
| 218 | int id); |
| 219 | |
| 220 | void |
| 221 | KXVPaintRegion(DrawablePtr pDraw, RegionPtr pRgn, Pixel fg); |
| 222 | |
| 223 | KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen); |
| 224 | |
| 225 | void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr); |
| 226 | |
| 227 | /* Must be called from KdCardInfo functions, can be called without Xv enabled */ |
| 228 | Bool KdXVEnable(ScreenPtr); |
| 229 | void KdXVDisable(ScreenPtr); |
| 230 | |
| 231 | /*** These are DDX layer privates ***/ |
| 232 | |
| 233 | typedef struct { |
| 234 | CreateWindowProcPtr CreateWindow; |
| 235 | DestroyWindowProcPtr DestroyWindow; |
| 236 | ClipNotifyProcPtr ClipNotify; |
| 237 | WindowExposuresProcPtr WindowExposures; |
| 238 | } KdXVScreenRec, *KdXVScreenPtr; |
| 239 | |
| 240 | typedef struct { |
| 241 | int flags; |
| 242 | PutVideoFuncPtr PutVideo; |
| 243 | PutStillFuncPtr PutStill; |
| 244 | GetVideoFuncPtr GetVideo; |
| 245 | GetStillFuncPtr GetStill; |
| 246 | StopVideoFuncPtr StopVideo; |
| 247 | SetPortAttributeFuncPtr SetPortAttribute; |
| 248 | GetPortAttributeFuncPtr GetPortAttribute; |
| 249 | QueryBestSizeFuncPtr QueryBestSize; |
| 250 | PutImageFuncPtr PutImage; |
| 251 | ReputImageFuncPtr ReputImage; |
| 252 | QueryImageAttributesFuncPtr QueryImageAttributes; |
| 253 | } XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr; |
| 254 | |
| 255 | typedef struct { |
| 256 | KdScreenInfo *screen; |
| 257 | DrawablePtr pDraw; |
| 258 | unsigned char type; |
| 259 | unsigned int subWindowMode; |
| 260 | DDXPointRec clipOrg; |
| 261 | RegionPtr clientClip; |
| 262 | RegionPtr pCompositeClip; |
| 263 | Bool FreeCompositeClip; |
| 264 | XvAdaptorRecPrivatePtr AdaptorRec; |
| 265 | XvStatus isOn; |
| 266 | Bool moved; |
| 267 | int vid_x, vid_y, vid_w, vid_h; |
| 268 | int drw_x, drw_y, drw_w, drw_h; |
| 269 | DevUnion DevPriv; |
| 270 | } XvPortRecPrivate, *XvPortRecPrivatePtr; |
| 271 | |
| 272 | typedef struct _KdXVWindowRec { |
| 273 | XvPortRecPrivatePtr PortRec; |
| 274 | struct _KdXVWindowRec *next; |
| 275 | } KdXVWindowRec, *KdXVWindowPtr; |
| 276 | |
| 277 | #endif /* _XVDIX_H_ */ |