| 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_UPSCALER 0x00000010 /* Card supports hw upscaling */ |
| 62 |
#define FLAG_DOWNSCALER 0x00000020 /* Card supports hw downscaling */ |
| 63 |
#define FLAG_SUBPIC 0x00001000 /* Card supports DVD subpictures */ |
| 64 |
#define FLAG_EQUALIZER 0x00002000 /* Card supports equalizer */ |
| 65 |
unsigned flags; /* Feature flags, see above */ |
| 66 |
unsigned short vendor_id; |
| 67 |
unsigned short device_id; |
| 68 |
unsigned reserved1[4]; |
| 69 |
}vidix_capability_t; |
| 70 |
|
| 71 |
/* Should fill at least type before init. |
| 72 |
Returns 0 if ok else errno */ |
| 73 |
extern int vixGetCapability(vidix_capability_t *); |
| 74 |
|
| 75 |
typedef struct vidix_fourcc_s |
| 76 |
{ |
| 77 |
unsigned fourcc; /* input: requested fourcc */ |
| 78 |
unsigned srcw; /* input: hint: width of source */ |
| 79 |
unsigned srch; /* input: hint: height of source */ |
| 80 |
#define VID_DEPTH_NONE 0x0000 |
| 81 |
#define VID_DEPTH_1BPP 0x0001 |
| 82 |
#define VID_DEPTH_2BPP 0x0002 |
| 83 |
#define VID_DEPTH_4BPP 0x0004 |
| 84 |
#define VID_DEPTH_8BPP 0x0008 |
| 85 |
#define VID_DEPTH_12BPP 0x0010 |
| 86 |
#define VID_DEPTH_15BPP 0x0020 |
| 87 |
#define VID_DEPTH_16BPP 0x0040 |
| 88 |
#define VID_DEPTH_24BPP 0x0080 |
| 89 |
#define VID_DEPTH_32BPP 0x0100 |
| 90 |
unsigned depth; /* output: screen depth for given fourcc */ |
| 91 |
#define VID_CAP_NONE 0x0000 |
| 92 |
#define VID_CAP_EXPAND 0x0001 /* if overlay can be bigger than source */ |
| 93 |
#define VID_CAP_SHRINK 0x0002 /* if overlay can be smaller than source */ |
| 94 |
#define VID_CAP_BLEND 0x0004 /* if overlay can be blended with framebuffer */ |
| 95 |
#define VID_CAP_COLORKEY 0x0008 /* if overlay can be restricted to a colorkey */ |
| 96 |
#define VID_CAP_ALPHAKEY 0x0010 /* if overlay can be restricted to an alpha channel */ |
| 97 |
#define VID_CAP_COLORKEY_ISRANGE 0x0020 /* if the colorkey can be a range */ |
| 98 |
#define VID_CAP_ALPHAKEY_ISRANGE 0x0040 /* if the alphakey can be a range */ |
| 99 |
#define VID_CAP_COLORKEY_ISMAIN 0x0080 /* colorkey is checked against framebuffer */ |
| 100 |
#define VID_CAP_COLORKEY_ISOVERLAY 0x0100 /* colorkey is checked against overlay */ |
| 101 |
#define VID_CAP_ALPHAKEY_ISMAIN 0x0200 /* alphakey is checked against framebuffer */ |
| 102 |
#define VID_CAP_ALPHAKEY_ISOVERLAY 0x0400 /* alphakey is checked against overlay */ |
| 103 |
unsigned flags; /* output: capability */ |
| 104 |
}vidix_fourcc_t; |
| 105 |
|
| 106 |
/* Returns 0 if ok else errno */ |
| 107 |
extern int vixQueryFourcc(vidix_fourcc_t *); |
| 108 |
|
| 109 |
typedef struct vidix_yuv_s |
| 110 |
{ |
| 111 |
unsigned y,u,v,a; |
| 112 |
}vidix_yuv_t; |
| 113 |
|
| 114 |
typedef struct vidix_rect_s |
| 115 |
{ |
| 116 |
unsigned x,y,w,h; /* in pixels */ |
| 117 |
vidix_yuv_t pitch; /* line-align in bytes */ |
| 118 |
}vidix_rect_t; |
| 119 |
|
| 120 |
typedef struct vidix_color_key_s |
| 121 |
{ |
| 122 |
#define CKEY_FALSE 0 |
| 123 |
#define CKEY_TRUE 1 |
| 124 |
#define CKEY_EQ 2 |
| 125 |
#define CKEY_NEQ 3 |
| 126 |
unsigned op; /* defines logical operation */ |
| 127 |
unsigned char red; |
| 128 |
unsigned char green; |
| 129 |
unsigned char blue; |
| 130 |
unsigned char reserved; |
| 131 |
}vidix_ckey_t; |
| 132 |
|
| 133 |
typedef struct vidix_video_key_s |
| 134 |
{ |
| 135 |
#define VKEY_FALSE 0 |
| 136 |
#define VKEY_TRUE 1 |
| 137 |
#define VKEY_EQ 2 |
| 138 |
#define VKEY_NEQ 3 |
| 139 |
unsigned op; /* defines logical operation */ |
| 140 |
unsigned char key[8]; |
| 141 |
}vidix_vkey_t; |
| 142 |
|
| 143 |
typedef struct vidix_playback_s |
| 144 |
{ |
| 145 |
unsigned fourcc; /* app -> driver: movies's fourcc */ |
| 146 |
unsigned capability; /* app -> driver: what capability to use */ |
| 147 |
unsigned blend_factor; /* app -> driver: blending factor */ |
| 148 |
vidix_rect_t src; /* app -> driver: original movie size */ |
| 149 |
vidix_rect_t dest; /* app -> driver: destinition movie size. driver->app dest_pitch */ |
| 150 |
#define VID_PLAY_INTERLEAVED_UV 0x00000001 /* driver -> app: interleaved UV planes */ |
| 151 |
#define INTERLEAVING_UV 0x00001000 /* UVUVUVUVUV used by Matrox G200 */ |
| 152 |
#define INTERLEAVING_VU 0x00001001 /* VUVUVUVUVU */ |
| 153 |
int flags; |
| 154 |
/* memory model */ |
| 155 |
unsigned frame_size; /* driver -> app: destinition frame size */ |
| 156 |
unsigned num_frames; /* app -> driver: after call: driver -> app */ |
| 157 |
#define VID_PLAY_MAXFRAMES 1024 /* unreal limitation */ |
| 158 |
unsigned offsets[VID_PLAY_MAXFRAMES]; /* driver -> app */ |
| 159 |
vidix_yuv_t offset; /* driver -> app: relative offsets within frame for yuv planes */ |
| 160 |
void* dga_addr; /* driver -> app: linear address */ |
| 161 |
}vidix_playback_t; |
| 162 |
|
| 163 |
/* Returns 0 if ok else errno */ |
| 164 |
extern int vixConfigPlayback(vidix_playback_t *); |
| 165 |
|
| 166 |
/* Returns 0 if ok else errno */ |
| 167 |
extern int vixPlaybackOn( void ); |
| 168 |
|
| 169 |
/* Returns 0 if ok else errno */ |
| 170 |
extern int vixPlaybackOff( void ); |
| 171 |
|
| 172 |
/* Returns 0 if ok else errno */ |
| 173 |
extern int vixPlaybackFrameSelect( unsigned frame_idx ); |
| 174 |
|
| 175 |
typedef struct vidix_grkey_s |
| 176 |
{ |
| 177 |
vidix_ckey_t ckey; /* app -> driver: color key */ |
| 178 |
vidix_vkey_t vkey; /* app -> driver: video key */ |
| 179 |
#define KEYS_PUT 0 |
| 180 |
#define KEYS_AND 1 |
| 181 |
#define KEYS_OR 2 |
| 182 |
#define KEYS_XOR 3 |
| 183 |
unsigned key_op; /* app -> driver: keys operations */ |
| 184 |
}vidix_grkey_t; |
| 185 |
|
| 186 |
/* Returns 0 if ok else errno */ |
| 187 |
extern int vixGetGrKeys( vidix_grkey_t * ); |
| 188 |
|
| 189 |
/* Returns 0 if ok else errno */ |
| 190 |
extern int vixSetGrKeys( const vidix_grkey_t * ); |
| 191 |
|
| 192 |
|
| 193 |
typedef struct vidix_video_eq_s |
| 194 |
{ |
| 195 |
#define VEQ_CAP_NONE 0x00000000UL |
| 196 |
#define VEQ_CAP_BRIGHTNESS 0x00000001UL |
| 197 |
#define VEQ_CAP_CONTRAST 0x00000002UL |
| 198 |
#define VEQ_CAP_SATURATION 0x00000004UL |
| 199 |
#define VEQ_CAP_HUE 0x00000008UL |
| 200 |
#define VEQ_CAP_RGB_INTENSITY 0x00000010UL |
| 201 |
int cap; /* on get_eq should contain capability of equalizer |
| 202 |
on set_eq should contain using fields */ |
| 203 |
/* end-user app can have presets like: cold-normal-hot picture and so on */ |
| 204 |
int brightness; /* -1000 : +1000 */ |
| 205 |
int contrast; /* -1000 : +1000 */ |
| 206 |
int saturation; /* -1000 : +1000 */ |
| 207 |
int hue; /* -1000 : +1000 */ |
| 208 |
int red_intensity; /* -1000 : +1000 */ |
| 209 |
int green_intensity;/* -1000 : +1000 */ |
| 210 |
int blue_intensity; /* -1000 : +1000 */ |
| 211 |
#define VEQ_FLG_ITU_R_BT_601 0x00000000 /* ITU-R BT.601 colour space (default) */ |
| 212 |
#define VEQ_FLG_ITU_R_BT_709 0x00000001 /* ITU-R BT.709 colour space */ |
| 213 |
#define VEQ_FLG_ITU_MASK 0x0000000f |
| 214 |
int flags; /* currently specifies ITU YCrCb color space to use */ |
| 215 |
}vidix_video_eq_t; |
| 216 |
|
| 217 |
/* Returns 0 if ok else errno */ |
| 218 |
extern int vixPlaybackGetEq( vidix_video_eq_t * ); |
| 219 |
|
| 220 |
/* Returns 0 if ok else errno */ |
| 221 |
extern int vixPlaybackSetEq( const vidix_video_eq_t * ); |
| 222 |
|
| 223 |
typedef struct vidix_deinterlace_s |
| 224 |
{ |
| 225 |
#define CFG_NON_INTERLACED 0x00000000 /* stream is not interlaced */ |
| 226 |
#define CFG_INTERLACED 0x00000001 /* stream is interlaced */ |
| 227 |
#define CFG_EVEN_ODD_INTERLACING 0x00000002 /* first frame contains even fields but second - odd */ |
| 228 |
#define CFG_ODD_EVEN_INTERLACING 0x00000004 /* first frame contains odd fields but second - even */ |
| 229 |
#define CFG_UNIQUE_INTERLACING 0x00000008 /* field deinterlace_pattern is valid */ |
| 230 |
#define CFG_UNKNOWN_INTERLACING 0x0000000f /* unknown deinterlacing - use adaptive if it's possible */ |
| 231 |
unsigned flags; |
| 232 |
unsigned deinterlace_pattern; /* app -> driver: deinterlace pattern if flag CFG_UNIQUE_INTERLACING is set */ |
| 233 |
}vidix_deinterlace_t; |
| 234 |
|
| 235 |
/* Returns 0 if ok else errno */ |
| 236 |
extern int vixPlaybackGetDeint( vidix_deinterlace_t * ); |
| 237 |
|
| 238 |
/* Returns 0 if ok else errno */ |
| 239 |
extern int vixPlaybackSetDeint( const vidix_deinterlace_t * ); |
| 240 |
|
| 241 |
typedef struct vidix_slice_s |
| 242 |
{ |
| 243 |
void* address; /* app -> driver */ |
| 244 |
unsigned size; /* app -> driver */ |
| 245 |
vidix_rect_t slice; /* app -> driver */ |
| 246 |
}vidix_slice_t; |
| 247 |
|
| 248 |
typedef struct vidix_dma_s |
| 249 |
{ |
| 250 |
void * src; /* app -> driver. Virtual address of source */ |
| 251 |
unsigned dest_offset; /* app -> driver. Destinition offset within of video memory */ |
| 252 |
unsigned size; /* app -> driver. Size of transaction */ |
| 253 |
#define BM_DMA_ASYNC 0 |
| 254 |
#define BM_DMA_SYNC 1 /* means: wait dma transfer completion */ |
| 255 |
#define BM_DMA_FIXED_BUFFS 2 /* app -> driver: app uses buffers which are fixed in memory */ |
| 256 |
unsigned flags; /* app -> driver */ |
| 257 |
unsigned idx; /* app -> driver: idx of src buffer */ |
| 258 |
void * internal[VID_PLAY_MAXFRAMES]; /* for internal use by driver */ |
| 259 |
}vidix_dma_t; |
| 260 |
|
| 261 |
/* Returns 0 if ok else errno */ |
| 262 |
extern int vixPlaybackCopyFrame( vidix_dma_t * ); |
| 263 |
|
| 264 |
/* Returns 0 if DMA is available else errno (EBUSY) */ |
| 265 |
extern int vixQueryDMAStatus( void ); |
| 266 |
/* |
| 267 |
This structure is introdused to support OEM effects like: |
| 268 |
- sharpness |
| 269 |
- exposure |
| 270 |
- (auto)gain |
| 271 |
- H(V)flip |
| 272 |
- black level |
| 273 |
- white balance |
| 274 |
and many other |
| 275 |
*/ |
| 276 |
typedef struct vidix_oem_fx_s |
| 277 |
{ |
| 278 |
#define FX_TYPE_BOOLEAN 0x00000000 |
| 279 |
#define FX_TYPE_INTEGER 0x00000001 |
| 280 |
int type; /* type of effects */ |
| 281 |
int num; /* app -> driver: effect number. From 0 to max number of effects */ |
| 282 |
int minvalue; /* min value of effect. 0 - for boolean */ |
| 283 |
int maxvalue; /* max value of effect. 1 - for boolean */ |
| 284 |
int value; /* current value of effect on 'get'; required on set */ |
| 285 |
char * name[80]; /* effect name to display */ |
| 286 |
}vidix_oem_fx_t; |
| 287 |
|
| 288 |
/* Returns 0 if ok else errno */ |
| 289 |
extern int vixQueryNumOemEffects( unsigned * number ); |
| 290 |
|
| 291 |
/* Returns 0 if ok else errno */ |
| 292 |
extern int vixGetOemEffect( vidix_oem_fx_t * ); |
| 293 |
|
| 294 |
/* Returns 0 if ok else errno */ |
| 295 |
extern int vixSetOemEffect( const vidix_oem_fx_t * ); |
| 296 |
|
| 297 |
#ifdef VIDIX_BUILD_STATIC |
| 298 |
#define VIDIX_NAME(name) VIDIX_STATIC##name |
| 299 |
#else |
| 300 |
#define VIDIX_NAME(name) name |
| 301 |
#endif |
| 302 |
|
| 303 |
#ifdef __cplusplus |
| 304 |
} |
| 305 |
#endif |
| 306 |
|
| 307 |
#endif |