1 /* 2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sub license, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial portions 14 * of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: 25 * Shengquan Yuan <shengquan.yuan (at) intel.com> 26 * Zhaohan Ren <zhaohan.ren (at) intel.com> 27 * Jason Hu <jason.hu (at) intel.com> 28 * 29 */ 30 31 #ifndef _PSB_OUTPUT_H_ 32 #define _PSB_OUTPUT_H_ 33 #include <inttypes.h> 34 #include "psb_drv_video.h" 35 #include "psb_surface.h" 36 #include "hwdefs/img_types.h" 37 #include <va/va.h> 38 #include <linux/fb.h> 39 #include <fcntl.h> 40 41 #define IMG_VIDEO_IED_STATE 0 42 #ifndef ANDROID 43 #include <va/va_x11.h> 44 #else 45 #define Drawable unsigned int 46 #define Bool int 47 #define LOG_TAG "pvr_drv_video" 48 #endif 49 50 #define PSB_MAX_IMAGE_FORMATS 4 /* sizeof(psb__CreateImageFormat)/sizeof(VAImageFormat) */ 51 #define PSB_MAX_SUBPIC_FORMATS 3 /* sizeof(psb__SubpicFormat)/sizeof(VAImageFormat) */ 52 #define PSB_MAX_DISPLAY_ATTRIBUTES 14 /* sizeof(psb__DisplayAttribute)/sizeof(VADisplayAttribute) */ 53 54 #define VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD 0x0004 55 #define PSB_SUPPORTED_SUBPIC_FLAGS VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD /* No alpha or chroma key support */ 56 57 58 #define CLAMP(_X) ( (_X)= ((_X)<0?0:((_X)>255?255:(_X)) ) ) 59 60 #define HUE_DEFAULT_VALUE 0 61 #define HUE_MIN -180 62 #define HUE_MAX 180 63 #define HUE_STEPSIZE 0.1 64 65 #define BRIGHTNESS_DEFAULT_VALUE 0 66 #define BRIGHTNESS_MIN -100 67 #define BRIGHTNESS_MAX 100 68 #define BRIGHTNESS_STEPSIZE 0.1 69 70 #define CONTRAST_DEFAULT_VALUE 1 71 #define CONTRAST_MIN 0 72 #define CONTRAST_MAX 2 73 #define CONTRAST_STEPSIZE 0.0001 74 75 #define SATURATION_DEFAULT_VALUE 1 76 #define SATURATION_MIN 0 77 #define SATURATION_MAX 3 78 #define SATURATION_STEPSIZE 0.0001 79 80 #define VA_RENDER_MODE_MASK 0x0f 81 #define VA_RENDER_DEVICE_MASK 0x03 82 83 #define PSB_DRIDDX_VERSION_MAJOR 0 84 #define PSB_DRIDDX_VERSION_MINOR 1 85 #define PSB_DRIDDX_VERSION_PATCH 0 86 87 #define psb__ImageNV12 \ 88 { \ 89 VA_FOURCC_NV12, \ 90 VA_LSB_FIRST, \ 91 16, \ 92 0, \ 93 0, \ 94 0, \ 95 0, \ 96 0 \ 97 } 98 99 #define psb__ImageAYUV \ 100 { \ 101 VA_FOURCC_AYUV, \ 102 VA_LSB_FIRST, \ 103 32, \ 104 0, \ 105 0, \ 106 0, \ 107 0, \ 108 0 \ 109 } 110 111 #define psb__ImageAI44 \ 112 { \ 113 VA_FOURCC_AI44, \ 114 VA_LSB_FIRST, \ 115 16, \ 116 0, \ 117 0, \ 118 0, \ 119 0, \ 120 0, \ 121 } 122 123 #define psb__ImageRGBA \ 124 { \ 125 VA_FOURCC_RGBA, \ 126 VA_LSB_FIRST, \ 127 32, \ 128 32, \ 129 0xff, \ 130 0xff00, \ 131 0xff0000, \ 132 0xff000000 \ 133 } 134 135 #define psb__ImageYV16 \ 136 { \ 137 VA_FOURCC_YV16, \ 138 VA_LSB_FIRST, \ 139 16, \ 140 0, \ 141 0, \ 142 0, \ 143 0, \ 144 0, \ 145 } 146 147 #define psb__ImageYV32 \ 148 { \ 149 VA_FOURCC_YV32, \ 150 VA_LSB_FIRST, \ 151 32, \ 152 0, \ 153 0, \ 154 0, \ 155 0, \ 156 0, \ 157 } 158 159 VAStatus psb__destroy_subpicture(psb_driver_data_p driver_data, object_subpic_p obj_subpic); 160 VAStatus psb__destroy_image(psb_driver_data_p driver_data, object_image_p obj_image); 161 162 /* 163 * VAImage call these buffer routines 164 */ 165 VAStatus psb__CreateBuffer( 166 psb_driver_data_p driver_data, 167 object_context_p obj_context, /* in */ 168 VABufferType type, /* in */ 169 unsigned int size, /* in */ 170 unsigned int num_elements, /* in */ 171 unsigned char *data, /* in */ 172 VABufferID *buf_desc /* out */ 173 ); 174 175 VAStatus psb_DestroyBuffer( 176 VADriverContextP ctx, 177 VABufferID buffer_id 178 ); 179 180 VAStatus psb_initOutput( 181 VADriverContextP ctx 182 ); 183 184 185 VAStatus psb_deinitOutput( 186 VADriverContextP ctx 187 ); 188 189 VAStatus psb_PutSurfaceBuf( 190 VADriverContextP ctx, 191 VASurfaceID surface, 192 unsigned char* data, 193 int* data_len, 194 short srcx, 195 short srcy, 196 unsigned short srcw, 197 unsigned short srch, 198 short destx, 199 short desty, 200 unsigned short destw, 201 unsigned short desth, 202 VARectangle *cliprects, /* client supplied clip list */ 203 unsigned int number_cliprects, /* number of clip rects in the clip list */ 204 unsigned int flags /* de-interlacing flags */ 205 ); 206 207 VAStatus psb_SetTimestampForSurface( 208 VADriverContextP ctx, 209 VASurfaceID surface, 210 long long timestamp 211 ); 212 213 VAStatus psb_PutSurface( 214 VADriverContextP ctx, 215 VASurfaceID surface, 216 void* draw, /* X Drawable */ 217 short srcx, 218 short srcy, 219 unsigned short srcw, 220 unsigned short srch, 221 short destx, 222 short desty, 223 unsigned short destw, 224 unsigned short desth, 225 VARectangle *cliprects, /* client supplied clip list */ 226 unsigned int number_cliprects, /* number of clip rects in the clip list */ 227 unsigned int flags /* de-interlacing flags */ 228 ); 229 230 VAStatus psb_QueryImageFormats( 231 VADriverContextP ctx, 232 VAImageFormat *format_list, /* out */ 233 int *num_formats /* out */ 234 ); 235 236 VAStatus psb_CreateImage( 237 VADriverContextP ctx, 238 VAImageFormat *format, 239 int width, 240 int height, 241 VAImage *image /* out */ 242 ); 243 244 VAStatus psb_DeriveImage( 245 VADriverContextP ctx, 246 VASurfaceID surface, 247 VAImage *image /* out */ 248 ); 249 250 VAStatus psb_DestroyImage( 251 VADriverContextP ctx, 252 VAImageID image 253 ); 254 255 VAStatus psb_SetImagePalette( 256 VADriverContextP ctx, 257 VAImageID image, 258 /* 259 * pointer to an array holding the palette data. The size of the array is 260 * num_palette_entries * entry_bytes in size. The order of the components 261 * in the palette is described by the component_order in VAImage struct 262 */ 263 unsigned char *palette 264 ); 265 266 VAStatus psb_GetImage( 267 VADriverContextP ctx, 268 VASurfaceID surface, 269 int x, /* coordinates of the upper left source pixel */ 270 int y, 271 unsigned int width, /* width and height of the region */ 272 unsigned int height, 273 VAImageID image 274 ); 275 276 VAStatus psb_PutImage( 277 VADriverContextP ctx, 278 VASurfaceID surface, 279 VAImageID image, 280 int src_x, 281 int src_y, 282 unsigned int src_width, 283 unsigned int src_height, 284 int dest_x, 285 int dest_y, 286 unsigned int dest_width, 287 unsigned int dest_height 288 ); 289 290 VAStatus psb_QuerySubpictureFormats( 291 VADriverContextP ctx, 292 VAImageFormat *format_list, /* out */ 293 unsigned int *flags, /* out */ 294 unsigned int *num_formats /* out */ 295 ); 296 297 VAStatus psb_CreateSubpicture( 298 VADriverContextP ctx, 299 VAImageID image, 300 VASubpictureID *subpicture /* out */ 301 ); 302 303 VAStatus psb_DestroySubpicture( 304 VADriverContextP ctx, 305 VASubpictureID subpicture 306 ); 307 308 VAStatus psb_SetSubpictureImage( 309 VADriverContextP ctx, 310 VASubpictureID subpicture, 311 VAImageID image 312 ); 313 314 315 VAStatus psb_SetSubpictureChromakey( 316 VADriverContextP ctx, 317 VASubpictureID subpicture, 318 unsigned int chromakey_min, 319 unsigned int chromakey_max, 320 unsigned int chromakey_mask 321 ); 322 323 VAStatus psb_SetSubpictureGlobalAlpha( 324 VADriverContextP ctx, 325 VASubpictureID subpicture, 326 float global_alpha 327 ); 328 329 VAStatus psb_AssociateSubpicture( 330 VADriverContextP ctx, 331 VASubpictureID subpicture, 332 VASurfaceID *target_surfaces, 333 int num_surfaces, 334 short src_x, /* upper left offset in subpicture */ 335 short src_y, 336 unsigned short src_width, 337 unsigned short src_height, 338 short dest_x, /* upper left offset in surface */ 339 short dest_y, 340 unsigned short dest_width, 341 unsigned short dest_height, 342 /* 343 * whether to enable chroma-keying or global-alpha 344 * see VA_SUBPICTURE_XXX values 345 */ 346 unsigned int flags 347 ); 348 349 VAStatus psb_DeassociateSubpicture( 350 VADriverContextP ctx, 351 VASubpictureID subpicture, 352 VASurfaceID *target_surfaces, 353 int num_surfaces 354 ); 355 356 void psb_SurfaceDeassociateSubpict( 357 psb_driver_data_p driver_data, 358 object_surface_p obj_surface 359 ); 360 361 /* 362 * Query display attributes 363 * The caller must provide a "attr_list" array that can hold at 364 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes 365 * returned in "attr_list" is returned in "num_attributes". 366 */ 367 VAStatus psb_QueryDisplayAttributes( 368 VADriverContextP ctx, 369 VADisplayAttribute *attr_list, /* out */ 370 int *num_attributes /* out */ 371 ); 372 373 /* 374 * Get display attributes 375 * This function returns the current attribute values in "attr_list". 376 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field 377 * from vaQueryDisplayAttributes() can have their values retrieved. 378 */ 379 VAStatus psb_GetDisplayAttributes( 380 VADriverContextP ctx, 381 VADisplayAttribute *attr_list, /* in/out */ 382 int num_attributes 383 ); 384 385 /* 386 * Set display attributes 387 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field 388 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or 389 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 390 */ 391 VAStatus psb_SetDisplayAttributes( 392 VADriverContextP ctx, 393 VADisplayAttribute *attr_list, 394 int num_attributes 395 ); 396 397 #endif /* _PSB_OUTPUT_H_ */ 398