1 /* 2 * vidix.h 3 * VIDIX - VIDeo Interface for *niX 4 * This interface is introduced as universal one to MPEG decoder, 5 * BES == Back End Scaler and YUV2RGB hw accelerators. 6 * In the future it may be expanded up to capturing and audio things. 7 * Main goal of this this interface imlpementation is providing DGA 8 * everywhere where it's possible (unlike X11 and other). 9 * Copyright 2002 Nick Kurshev 10 * Licence: GPL 11 * This interface is based on v4l2, fbvid.h, mga_vid.h projects 12 * and personally my ideas. 13 * NOTE: This interface is introduces as driver interface. 14 * Don't use it for APP. 15 */ 16 #ifndef VIDIX_H 17 #define VIDIX_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #define VIDIX_VERSION 100 24 25 /* returns driver version */ 26 extern unsigned vixGetVersion( void ); 27 28 #define PROBE_NORMAL 0 /* normal probing */ 29 #define PROBE_FORCE 1 /* ignore device_id but recognize device if it's known */ 30 /* Probes video hw. 31 verbose - specifies verbose level. 32 force - specifies force mode - driver should ignore 33 device_id (danger but useful for new devices) 34 Returns 0 if ok else errno */ 35 extern int vixProbe( int verbose, int force ); 36 /* Initializes driver. 37 args - specifies driver specific parameters 38 Returns 0 if ok else errno */ 39 extern int vixInit( const char *args ); 40 /* Destroys driver */ 41 extern void vixDestroy( void ); 42 43 typedef struct vidix_capability_s 44 { 45 char name[64]; /* Driver name */ 46 char author[64]; /* Author name */ 47 #define TYPE_OUTPUT 0x00000000 /* Is a video playback device */ 48 #define TYPE_CAPTURE 0x00000001 /* Is a capture device */ 49 #define TYPE_CODEC 0x00000002 /* Device supports hw (de)coding */ 50 #define TYPE_FX 0x00000004 /* Is a video effects device */ 51 int type; /* Device type, see below */ 52 unsigned reserved0[4]; 53 int maxwidth; 54 int maxheight; 55 int minwidth; 56 int minheight; 57 int maxframerate; /* -1 if unlimited */ 58 #define FLAG_NONE 0x00000000 /* No flags defined */ 59 #define FLAG_DMA 0x00000001 /* Card can use DMA */ 60 #define FLAG_EQ_DMA 0x00000002 /* Card can use DMA only if src pitch == dest pitch */ 61 #define FLAG_SYNC_DMA 0x00000004 /* Possible to wait for DMA 62 * to finish. See 63 * BM_DMA_SYNC and 64 * BM_DMA_BLOCK below */ 65 #define FLAG_UPSCALER 0x00000010 /* Card supports hw upscaling */ 66 #define FLAG_DOWNSCALER 0x00000020 /* Card supports hw downscaling */ 67 #define FLAG_SUBPIC 0x00001000 /* Card supports DVD subpictures */ 68 #define FLAG_EQUALIZER 0x00002000 /* Card supports equalizer */ 69 unsigned flags; /* Feature flags, see above */ 70 unsigned short vendor_id; 71 unsigned short device_id; 72 unsigned reserved1[4]; 73 }vidix_capability_t; 74 75 /* Should fill at least type before init. 76 Returns 0 if ok else errno */ 77 extern int vixGetCapability(vidix_capability_t *); 78 79 typedef struct vidix_fourcc_s 80 { 81 unsigned fourcc; /* input: requested fourcc */ 82 unsigned srcw; /* input: hint: width of source */ 83 unsigned srch; /* input: hint: height of source */ 84 #define VID_DEPTH_NONE 0x0000 85 #define VID_DEPTH_1BPP 0x0001 86 #define VID_DEPTH_2BPP 0x0002 87 #define VID_DEPTH_4BPP 0x0004 88 #define VID_DEPTH_8BPP 0x0008 89 #define VID_DEPTH_12BPP 0x0010 90 #define VID_DEPTH_15BPP 0x0020 91 #define VID_DEPTH_16BPP 0x0040 92 #define VID_DEPTH_24BPP 0x0080 93 #define VID_DEPTH_32BPP 0x0100 94 unsigned depth; /* output: screen depth for given fourcc */ 95 #define VID_CAP_NONE 0x0000 96 #define VID_CAP_EXPAND 0x0001 /* if overlay can be bigger than source */ 97 #define VID_CAP_SHRINK 0x0002 /* if overlay can be smaller than source */ 98 #define VID_CAP_BLEND 0x0004 /* if overlay can be blended with framebuffer */ 99 #define VID_CAP_COLORKEY 0x0008 /* if overlay can be restricted to a colorkey */ 100 #define VID_CAP_ALPHAKEY 0x0010 /* if overlay can be restricted to an alpha channel */ 101 #define VID_CAP_COLORKEY_ISRANGE 0x0020 /* if the colorkey can be a range */ 102 #define VID_CAP_ALPHAKEY_ISRANGE 0x0040 /* if the alphakey can be a range */ 103 #define VID_CAP_COLORKEY_ISMAIN 0x0080 /* colorkey is checked against framebuffer */ 104 #define VID_CAP_COLORKEY_ISOVERLAY 0x0100 /* colorkey is checked against overlay */ 105 #define VID_CAP_ALPHAKEY_ISMAIN 0x0200 /* alphakey is checked against framebuffer */ 106 #define VID_CAP_ALPHAKEY_ISOVERLAY 0x0400 /* alphakey is checked against overlay */ 107 unsigned flags; /* output: capability */ 108 }vidix_fourcc_t; 109 110 /* Returns 0 if ok else errno */ 111 extern int vixQueryFourcc(vidix_fourcc_t *); 112 113 typedef struct vidix_yuv_s 114 { 115 unsigned y,u,v,a; 116 }vidix_yuv_t; 117 118 typedef struct vidix_rect_s 119 { 120 unsigned x,y,w,h; /* in pixels */ 121 vidix_yuv_t pitch; /* line-align in bytes */ 122 }vidix_rect_t; 123 124 typedef struct vidix_color_key_s 125 { 126 #define CKEY_FALSE 0 127 #define CKEY_TRUE 1 128 #define CKEY_EQ 2 129 #define CKEY_NEQ 3 130 unsigned op; /* defines logical operation */ 131 unsigned char red; 132 unsigned char green; 133 unsigned char blue; 134 unsigned char reserved; 135 }vidix_ckey_t; 136 137 typedef struct vidix_video_key_s 138 { 139 #define VKEY_FALSE 0 140 #define VKEY_TRUE 1 141 #define VKEY_EQ 2 142 #define VKEY_NEQ 3 143 unsigned op; /* defines logical operation */ 144 unsigned char key[8]; 145 }vidix_vkey_t; 146 147 typedef struct vidix_playback_s 148 { 149 unsigned fourcc; /* app -> driver: movies's fourcc */ 150 unsigned capability; /* app -> driver: what capability to use */ 151 unsigned blend_factor; /* app -> driver: blending factor */ 152 vidix_rect_t src; /* app -> driver: original movie size */ 153 vidix_rect_t dest; /* app -> driver: destinition movie size. driver->app dest_pitch */ 154 #define VID_PLAY_INTERLEAVED_UV 0x00000001 /* driver -> app: interleaved UV planes */ 155 #define INTERLEAVING_UV 0x00001000 /* UVUVUVUVUV used by Matrox G200 */ 156 #define INTERLEAVING_VU 0x00001001 /* VUVUVUVUVU */ 157 int flags; 158 /* memory model */ 159 unsigned frame_size; /* driver -> app: destinition frame size */ 160 unsigned num_frames; /* app -> driver: after call: driver -> app */ 161 #define VID_PLAY_MAXFRAMES 1024 /* unreal limitation */ 162 unsigned offsets[VID_PLAY_MAXFRAMES]; /* driver -> app */ 163 vidix_yuv_t offset; /* driver -> app: relative offsets within frame for yuv planes */ 164 void* dga_addr; /* driver -> app: linear address */ 165 }vidix_playback_t; 166 167 /* Returns 0 if ok else errno */ 168 extern int vixConfigPlayback(vidix_playback_t *); 169 170 /* Returns 0 if ok else errno */ 171 extern int vixPlaybackOn( void ); 172 173 /* Returns 0 if ok else errno */ 174 extern int vixPlaybackOff( void ); 175 176 /* Returns 0 if ok else errno */ 177 extern int vixPlaybackFrameSelect( unsigned frame_idx ); 178 179 typedef struct vidix_grkey_s 180 { 181 vidix_ckey_t ckey; /* app -> driver: color key */ 182 vidix_vkey_t vkey; /* app -> driver: video key */ 183 #define KEYS_PUT 0 184 #define KEYS_AND 1 185 #define KEYS_OR 2 186 #define KEYS_XOR 3 187 unsigned key_op; /* app -> driver: keys operations */ 188 }vidix_grkey_t; 189 190 /* Returns 0 if ok else errno */ 191 extern int vixGetGrKeys( vidix_grkey_t * ); 192 193 /* Returns 0 if ok else errno */ 194 extern int vixSetGrKeys( const vidix_grkey_t * ); 195 196 197 typedef struct vidix_video_eq_s 198 { 199 #define VEQ_CAP_NONE 0x00000000UL 200 #define VEQ_CAP_BRIGHTNESS 0x00000001UL 201 #define VEQ_CAP_CONTRAST 0x00000002UL 202 #define VEQ_CAP_SATURATION 0x00000004UL 203 #define VEQ_CAP_HUE 0x00000008UL 204 #define VEQ_CAP_RGB_INTENSITY 0x00000010UL 205 int cap; /* on get_eq should contain capability of equalizer 206 on set_eq should contain using fields */ 207 /* end-user app can have presets like: cold-normal-hot picture and so on */ 208 int brightness; /* -1000 : +1000 */ 209 int contrast; /* -1000 : +1000 */ 210 int saturation; /* -1000 : +1000 */ 211 int hue; /* -1000 : +1000 */ 212 int red_intensity; /* -1000 : +1000 */ 213 int green_intensity;/* -1000 : +1000 */ 214 int blue_intensity; /* -1000 : +1000 */ 215 #define VEQ_FLG_ITU_R_BT_601 0x00000000 /* ITU-R BT.601 colour space (default) */ 216 #define VEQ_FLG_ITU_R_BT_709 0x00000001 /* ITU-R BT.709 colour space */ 217 #define VEQ_FLG_ITU_MASK 0x0000000f 218 int flags; /* currently specifies ITU YCrCb color space to use */ 219 }vidix_video_eq_t; 220 221 /* Returns 0 if ok else errno */ 222 extern int vixPlaybackGetEq( vidix_video_eq_t * ); 223 224 /* Returns 0 if ok else errno */ 225 extern int vixPlaybackSetEq( const vidix_video_eq_t * ); 226 227 typedef struct vidix_deinterlace_s 228 { 229 #define CFG_NON_INTERLACED 0x00000000 /* stream is not interlaced */ 230 #define CFG_INTERLACED 0x00000001 /* stream is interlaced */ 231 #define CFG_EVEN_ODD_INTERLACING 0x00000002 /* first frame contains even fields but second - odd */ 232 #define CFG_ODD_EVEN_INTERLACING 0x00000004 /* first frame contains odd fields but second - even */ 233 #define CFG_UNIQUE_INTERLACING 0x00000008 /* field deinterlace_pattern is valid */ 234 #define CFG_UNKNOWN_INTERLACING 0x0000000f /* unknown deinterlacing - use adaptive if it's possible */ 235 unsigned flags; 236 unsigned deinterlace_pattern; /* app -> driver: deinterlace pattern if flag CFG_UNIQUE_INTERLACING is set */ 237 }vidix_deinterlace_t; 238 239 /* Returns 0 if ok else errno */ 240 extern int vixPlaybackGetDeint( vidix_deinterlace_t * ); 241 242 /* Returns 0 if ok else errno */ 243 extern int vixPlaybackSetDeint( const vidix_deinterlace_t * ); 244 245 typedef struct vidix_slice_s 246 { 247 void* address; /* app -> driver */ 248 unsigned size; /* app -> driver */ 249 vidix_rect_t slice; /* app -> driver */ 250 }vidix_slice_t; 251 252 typedef struct vidix_dma_s 253 { 254 void * src; /* app -> driver. Virtual address of source */ 255 unsigned dest_offset; /* app -> driver. Destinition offset within of video memory */ 256 unsigned size; /* app -> driver. Size of transaction */ 257 #define BM_DMA_ASYNC 0 258 #define BM_DMA_SYNC 1 /* await previous dma transfer completion */ 259 #define BM_DMA_FIXED_BUFFS 2 /* app -> driver: app uses buffers which are fixed in memory */ 260 #define BM_DMA_BLOCK 4 /* block until the transfer is complete */ 261 unsigned flags; /* app -> driver */ 262 unsigned idx; /* app -> driver: idx of src buffer */ 263 void * internal[VID_PLAY_MAXFRAMES]; /* for internal use by driver */ 264 }vidix_dma_t; 265 266 /* Returns 0 if ok else errno */ 267 extern int vixPlaybackCopyFrame( vidix_dma_t * ); 268 269 /* Returns 0 if DMA is available else errno (EBUSY) */ 270 extern int vixQueryDMAStatus( void ); 271 /* 272 This structure is introdused to support OEM effects like: 273 - sharpness 274 - exposure 275 - (auto)gain 276 - H(V)flip 277 - black level 278 - white balance 279 and many other 280 */ 281 typedef struct vidix_oem_fx_s 282 { 283 #define FX_TYPE_BOOLEAN 0x00000000 284 #define FX_TYPE_INTEGER 0x00000001 285 int type; /* type of effects */ 286 int num; /* app -> driver: effect number. From 0 to max number of effects */ 287 int minvalue; /* min value of effect. 0 - for boolean */ 288 int maxvalue; /* max value of effect. 1 - for boolean */ 289 int value; /* current value of effect on 'get'; required on set */ 290 char * name[80]; /* effect name to display */ 291 }vidix_oem_fx_t; 292 293 /* Returns 0 if ok else errno */ 294 extern int vixQueryNumOemEffects( unsigned * number ); 295 296 /* Returns 0 if ok else errno */ 297 extern int vixGetOemEffect( vidix_oem_fx_t * ); 298 299 /* Returns 0 if ok else errno */ 300 extern int vixSetOemEffect( const vidix_oem_fx_t * ); 301 302 #ifdef VIDIX_BUILD_STATIC 303 #define VIDIX_NAME(name) VIDIX_STATIC##name 304 #else 305 #define VIDIX_NAME(name) name 306 #endif 307 308 #ifdef __cplusplus 309 } 310 #endif 311 312 #endif 313