| 1 |
/* |
| 2 |
* Copyright ?2009 Intel Corporation |
| 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 |
* Xiang Haihao <[email protected]> |
| 26 |
* Zou Nan hai <[email protected]> |
| 27 |
* |
| 28 |
*/ |
| 29 |
|
| 30 |
#ifndef _I965_DRV_VIDEO_H_ |
| 31 |
#define _I965_DRV_VIDEO_H_ |
| 32 |
|
| 33 |
#include <va/va.h> |
| 34 |
#include <va/va_enc_h264.h> |
| 35 |
#include <va/va_enc_mpeg2.h> |
| 36 |
#include <va/va_enc_hevc.h> |
| 37 |
#include <va/va_enc_jpeg.h> |
| 38 |
#include <va/va_enc_vp8.h> |
| 39 |
#include <va/va_vpp.h> |
| 40 |
#include <va/va_backend.h> |
| 41 |
#include <va/va_backend_vpp.h> |
| 42 |
#include <va/va_fei.h> |
| 43 |
#include <va/va_fei_h264.h> |
| 44 |
|
| 45 |
#include "va_backend_compat.h" |
| 46 |
|
| 47 |
#include "i965_mutext.h" |
| 48 |
#include "object_heap.h" |
| 49 |
#include "intel_driver.h" |
| 50 |
#include "i965_fourcc.h" |
| 51 |
|
| 52 |
#define I965_MAX_PROFILES 20 |
| 53 |
#define I965_MAX_ENTRYPOINTS 7 |
| 54 |
#define I965_MAX_CONFIG_ATTRIBUTES 32 |
| 55 |
#define I965_MAX_IMAGE_FORMATS 10 |
| 56 |
#define I965_MAX_SUBPIC_FORMATS 6 |
| 57 |
#define I965_MAX_SUBPIC_SUM 4 |
| 58 |
#define I965_MAX_SURFACE_ATTRIBUTES 32 |
| 59 |
|
| 60 |
#define INTEL_STR_DRIVER_VENDOR "Intel" |
| 61 |
#define INTEL_STR_DRIVER_NAME "i965" |
| 62 |
|
| 63 |
#define I965_SURFACE_TYPE_IMAGE 0 |
| 64 |
#define I965_SURFACE_TYPE_SURFACE 1 |
| 65 |
|
| 66 |
#define I965_SURFACE_FLAG_FRAME 0x00000000 |
| 67 |
#define I965_SURFACE_FLAG_TOP_FIELD_FIRST 0x00000001 |
| 68 |
#define I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST 0x00000002 |
| 69 |
|
| 70 |
#define DEFAULT_BRIGHTNESS 0 |
| 71 |
#define DEFAULT_CONTRAST 50 |
| 72 |
#define DEFAULT_HUE 0 |
| 73 |
#define DEFAULT_SATURATION 50 |
| 74 |
|
| 75 |
#define ENCODER_QUALITY_RANGE 2 |
| 76 |
#define ENCODER_QUALITY_RANGE_AVC 7 |
| 77 |
#define ENCODER_QUALITY_RANGE_HEVC 7 |
| 78 |
#define ENCODER_QUALITY_RANGE_VP9 7 |
| 79 |
#define ENCODER_DEFAULT_QUALITY 1 |
| 80 |
#define ENCODER_DEFAULT_QUALITY_AVC 4 |
| 81 |
#define ENCODER_DEFAULT_QUALITY_HEVC 4 |
| 82 |
#define ENCODER_DEFAULT_QUALITY_VP9 4 |
| 83 |
#define ENCODER_HIGH_QUALITY ENCODER_DEFAULT_QUALITY |
| 84 |
#define ENCODER_LOW_QUALITY 2 |
| 85 |
|
| 86 |
#define I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT 32 |
| 87 |
#define I965_MAX_NUM_ROI_REGIONS 8 |
| 88 |
#define I965_MAX_NUM_SLICE 32 |
| 89 |
|
| 90 |
#define ENCODER_LP_QUALITY_RANGE 8 |
| 91 |
|
| 92 |
#define STATS_MAX_NUM_PAST_REFS 1 |
| 93 |
#define STATS_MAX_NUM_FUTURE_REFS 1 |
| 94 |
#define STATS_MAX_NUM_OUTPUTS 2 |
| 95 |
#define STATS_INTERLACED_SUPPORT 0 |
| 96 |
|
| 97 |
#define HAS_MPEG2_DECODING(ctx) ((ctx)->codec_info->has_mpeg2_decoding && \ |
| 98 |
(ctx)->intel.has_bsd) |
| 99 |
|
| 100 |
#define HAS_MPEG2_ENCODING(ctx) ((ctx)->codec_info->has_mpeg2_encoding && \ |
| 101 |
(ctx)->intel.has_bsd) |
| 102 |
|
| 103 |
#define HAS_H264_DECODING(ctx) ((ctx)->codec_info->has_h264_decoding && \ |
| 104 |
(ctx)->intel.has_bsd) |
| 105 |
|
| 106 |
#define HAS_H264_ENCODING(ctx) ((ctx)->codec_info->has_h264_encoding && \ |
| 107 |
(ctx)->intel.has_bsd) |
| 108 |
|
| 109 |
#define HAS_LP_H264_ENCODING(ctx) ((ctx)->codec_info->has_lp_h264_encoding && \ |
| 110 |
(ctx)->intel.has_bsd) |
| 111 |
|
| 112 |
#define HAS_FEI_H264_ENCODING(ctx) ((ctx)->codec_info->has_fei_h264_encoding && \ |
| 113 |
(ctx)->intel.has_bsd) |
| 114 |
|
| 115 |
#define HAS_H264_PREENC(ctx) ((ctx)->codec_info->has_h264_preenc) |
| 116 |
|
| 117 |
#define HAS_VC1_DECODING(ctx) ((ctx)->codec_info->has_vc1_decoding && \ |
| 118 |
(ctx)->intel.has_bsd) |
| 119 |
|
| 120 |
#define HAS_JPEG_DECODING(ctx) ((ctx)->codec_info->has_jpeg_decoding && \ |
| 121 |
(ctx)->intel.has_bsd) |
| 122 |
|
| 123 |
#define HAS_JPEG_ENCODING(ctx) ((ctx)->codec_info->has_jpeg_encoding && \ |
| 124 |
(ctx)->intel.has_bsd) |
| 125 |
|
| 126 |
#define HAS_VPP(ctx) ((ctx)->codec_info->has_vpp) |
| 127 |
|
| 128 |
#define HAS_ACCELERATED_GETIMAGE(ctx) ((ctx)->codec_info->has_accelerated_getimage) |
| 129 |
|
| 130 |
#define HAS_ACCELERATED_PUTIMAGE(ctx) ((ctx)->codec_info->has_accelerated_putimage) |
| 131 |
|
| 132 |
#define HAS_TILED_SURFACE(ctx) ((ctx)->codec_info->has_tiled_surface) |
| 133 |
|
| 134 |
#define HAS_VP8_DECODING(ctx) ((ctx)->codec_info->has_vp8_decoding && \ |
| 135 |
(ctx)->intel.has_bsd) |
| 136 |
|
| 137 |
#define HAS_VP8_ENCODING(ctx) ((ctx)->codec_info->has_vp8_encoding && \ |
| 138 |
(ctx)->intel.has_bsd) |
| 139 |
|
| 140 |
#define HAS_H264_MVC_DECODING(ctx) \ |
| 141 |
(HAS_H264_DECODING(ctx) && (ctx)->codec_info->h264_mvc_dec_profiles) |
| 142 |
|
| 143 |
#define HAS_H264_MVC_DECODING_PROFILE(ctx, profile) \ |
| 144 |
(HAS_H264_MVC_DECODING(ctx) && \ |
| 145 |
((ctx)->codec_info->h264_mvc_dec_profiles & (1U << profile))) |
| 146 |
|
| 147 |
#define HAS_H264_MVC_ENCODING(ctx) ((ctx)->codec_info->has_h264_mvc_encoding && \ |
| 148 |
(ctx)->intel.has_bsd) |
| 149 |
|
| 150 |
#define HAS_HEVC_DECODING(ctx) ((ctx)->codec_info->has_hevc_decoding && \ |
| 151 |
(ctx)->intel.has_bsd) |
| 152 |
|
| 153 |
#define HAS_HEVC_ENCODING(ctx) ((ctx)->codec_info->has_hevc_encoding && \ |
| 154 |
(ctx)->intel.has_bsd) |
| 155 |
|
| 156 |
#define HAS_VP9_DECODING(ctx) ((ctx)->codec_info->has_vp9_decoding && \ |
| 157 |
(ctx)->intel.has_bsd) |
| 158 |
|
| 159 |
#define HAS_VP9_DECODING_PROFILE(ctx, profile) \ |
| 160 |
(HAS_VP9_DECODING(ctx) && \ |
| 161 |
((ctx)->codec_info->vp9_dec_profiles & (1U << (profile - VAProfileVP9Profile0)))) |
| 162 |
|
| 163 |
#define HAS_HEVC10_DECODING(ctx) ((ctx)->codec_info->has_hevc10_decoding && \ |
| 164 |
(ctx)->intel.has_bsd) |
| 165 |
#define HAS_HEVC10_ENCODING(ctx) ((ctx)->codec_info->has_hevc10_encoding && \ |
| 166 |
(ctx)->intel.has_bsd) |
| 167 |
|
| 168 |
#define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \ |
| 169 |
(ctx)->intel.has_bsd) |
| 170 |
|
| 171 |
#define HAS_VP9_ENCODING(ctx) ((ctx)->codec_info->has_vp9_encoding && \ |
| 172 |
(ctx)->intel.has_bsd) |
| 173 |
|
| 174 |
#define HAS_LP_VP9_ENCODING(ctx) ((ctx)->codec_info->has_lp_vp9_encoding && \ |
| 175 |
(ctx)->intel.has_huc) |
| 176 |
|
| 177 |
#define HAS_VP9_ENCODING_PROFILE(ctx, profile) \ |
| 178 |
(HAS_VP9_ENCODING(ctx) && \ |
| 179 |
((ctx)->codec_info->vp9_enc_profiles & (1U << (profile - VAProfileVP9Profile0)))) |
| 180 |
|
| 181 |
struct i965_surface { |
| 182 |
struct object_base *base; |
| 183 |
int type; |
| 184 |
int flags; |
| 185 |
}; |
| 186 |
|
| 187 |
struct i965_kernel { |
| 188 |
char *name; |
| 189 |
int interface; |
| 190 |
const uint32_t (*bin)[4]; |
| 191 |
int size; |
| 192 |
dri_bo *bo; |
| 193 |
unsigned int kernel_offset; |
| 194 |
}; |
| 195 |
|
| 196 |
struct buffer_store { |
| 197 |
unsigned char *buffer; |
| 198 |
dri_bo *bo; |
| 199 |
int ref_count; |
| 200 |
int num_elements; |
| 201 |
}; |
| 202 |
|
| 203 |
struct object_config { |
| 204 |
struct object_base base; |
| 205 |
VAProfile profile; |
| 206 |
VAEntrypoint entrypoint; |
| 207 |
VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES]; |
| 208 |
int num_attribs; |
| 209 |
|
| 210 |
VAGenericID wrapper_config; |
| 211 |
}; |
| 212 |
|
| 213 |
#define NUM_SLICES 10 |
| 214 |
|
| 215 |
struct codec_state_base { |
| 216 |
uint32_t chroma_formats; |
| 217 |
}; |
| 218 |
|
| 219 |
struct decode_state { |
| 220 |
struct codec_state_base base; |
| 221 |
struct buffer_store *pic_param; |
| 222 |
struct buffer_store **slice_params; |
| 223 |
struct buffer_store *iq_matrix; |
| 224 |
struct buffer_store *bit_plane; |
| 225 |
struct buffer_store *huffman_table; |
| 226 |
struct buffer_store **slice_datas; |
| 227 |
struct buffer_store *probability_data; |
| 228 |
VASurfaceID current_render_target; |
| 229 |
int max_slice_params; |
| 230 |
int max_slice_datas; |
| 231 |
int num_slice_params; |
| 232 |
int num_slice_datas; |
| 233 |
|
| 234 |
struct object_surface *render_object; |
| 235 |
struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/ |
| 236 |
}; |
| 237 |
|
| 238 |
#define SLICE_PACKED_DATA_INDEX_TYPE 0x80000000 |
| 239 |
#define SLICE_PACKED_DATA_INDEX_MASK 0x00FFFFFF |
| 240 |
|
| 241 |
struct encode_state { |
| 242 |
struct codec_state_base base; |
| 243 |
struct buffer_store *iq_matrix; |
| 244 |
struct buffer_store *q_matrix; |
| 245 |
struct buffer_store *huffman_table; |
| 246 |
|
| 247 |
/* for ext */ |
| 248 |
struct buffer_store *seq_param_ext; |
| 249 |
struct buffer_store *pic_param_ext; |
| 250 |
struct buffer_store *packed_header_param[5]; |
| 251 |
struct buffer_store *packed_header_data[5]; |
| 252 |
struct buffer_store **slice_params_ext; |
| 253 |
struct buffer_store *encmb_map; |
| 254 |
int max_slice_params_ext; |
| 255 |
int num_slice_params_ext; |
| 256 |
|
| 257 |
/* Check the user-configurable packed_header attribute. |
| 258 |
* Currently it is mainly used to check whether the packed slice_header data |
| 259 |
* is provided by user or the driver. |
| 260 |
* TBD: It will check for the packed SPS/PPS/MISC/RAWDATA and so on. |
| 261 |
*/ |
| 262 |
unsigned int packed_header_flag; |
| 263 |
/* For the packed data that needs to be inserted into video clip */ |
| 264 |
/* currently it is mainly to track packed raw data and packed slice_header data. */ |
| 265 |
struct buffer_store **packed_header_params_ext; |
| 266 |
int max_packed_header_params_ext; |
| 267 |
int num_packed_header_params_ext; |
| 268 |
struct buffer_store **packed_header_data_ext; |
| 269 |
int max_packed_header_data_ext; |
| 270 |
int num_packed_header_data_ext; |
| 271 |
|
| 272 |
/* the index of current vps and sps ,special for HEVC*/ |
| 273 |
int vps_sps_seq_index; |
| 274 |
/* the index of current slice */ |
| 275 |
int slice_index; |
| 276 |
/* the array is determined by max_slice_params_ext */ |
| 277 |
int max_slice_num; |
| 278 |
/* This is to store the first index of packed data for one slice */ |
| 279 |
int *slice_rawdata_index; |
| 280 |
/* This is to store the number of packed data for one slice. |
| 281 |
* Both packed rawdata and slice_header data are tracked by this |
| 282 |
* variable. That is to say: When one packed slice_header is parsed, |
| 283 |
* this variable will also be increased. |
| 284 |
*/ |
| 285 |
int *slice_rawdata_count; |
| 286 |
|
| 287 |
/* This is to store the index of packed slice header for one slice */ |
| 288 |
int *slice_header_index; |
| 289 |
|
| 290 |
int last_packed_header_type; |
| 291 |
|
| 292 |
int has_layers; |
| 293 |
|
| 294 |
struct buffer_store *misc_param[19][8]; |
| 295 |
|
| 296 |
/* To store the VAStatsStatisticsParameterBufferType buffers */ |
| 297 |
struct buffer_store *stat_param_ext; |
| 298 |
|
| 299 |
VASurfaceID current_render_target; |
| 300 |
struct object_surface *input_yuv_object; |
| 301 |
struct object_surface *reconstructed_object; |
| 302 |
struct object_buffer *coded_buf_object; |
| 303 |
struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/ |
| 304 |
}; |
| 305 |
|
| 306 |
struct proc_state { |
| 307 |
struct codec_state_base base; |
| 308 |
struct buffer_store *pipeline_param; |
| 309 |
|
| 310 |
VASurfaceID current_render_target; |
| 311 |
}; |
| 312 |
|
| 313 |
#define CODEC_DEC 0 |
| 314 |
#define CODEC_ENC 1 |
| 315 |
#define CODEC_PROC 2 |
| 316 |
#define CODEC_PREENC 3 |
| 317 |
|
| 318 |
union codec_state { |
| 319 |
struct codec_state_base base; |
| 320 |
struct decode_state decode; |
| 321 |
struct encode_state encode; |
| 322 |
struct proc_state proc; |
| 323 |
}; |
| 324 |
|
| 325 |
struct hw_context { |
| 326 |
VAStatus(*run)(VADriverContextP ctx, |
| 327 |
VAProfile profile, |
| 328 |
union codec_state *codec_state, |
| 329 |
struct hw_context *hw_context); |
| 330 |
void (*destroy)(void *); |
| 331 |
VAStatus(*get_status)(VADriverContextP ctx, |
| 332 |
struct hw_context *hw_context, |
| 333 |
void *buffer); |
| 334 |
struct intel_batchbuffer *batch; |
| 335 |
}; |
| 336 |
|
| 337 |
struct object_context { |
| 338 |
struct object_base base; |
| 339 |
VAContextID context_id; |
| 340 |
struct object_config *obj_config; |
| 341 |
VASurfaceID *render_targets; //input->encode, output->decode |
| 342 |
int num_render_targets; |
| 343 |
int picture_width; |
| 344 |
int picture_height; |
| 345 |
int flags; |
| 346 |
int codec_type; |
| 347 |
union codec_state codec_state; |
| 348 |
struct hw_context *hw_context; |
| 349 |
|
| 350 |
VAGenericID wrapper_context; |
| 351 |
}; |
| 352 |
|
| 353 |
#define SURFACE_REFERENCED (1 << 0) |
| 354 |
#define SURFACE_DERIVED (1 << 2) |
| 355 |
#define SURFACE_ALL_MASK ((SURFACE_REFERENCED) | \ |
| 356 |
(SURFACE_DERIVED)) |
| 357 |
|
| 358 |
struct object_surface { |
| 359 |
struct object_base base; |
| 360 |
VASurfaceStatus status; |
| 361 |
VASubpictureID subpic[I965_MAX_SUBPIC_SUM]; |
| 362 |
struct object_subpic *obj_subpic[I965_MAX_SUBPIC_SUM]; |
| 363 |
unsigned int subpic_render_idx; |
| 364 |
|
| 365 |
int width; /* the pitch of plane 0 in bytes in horizontal direction */ |
| 366 |
int height; /* the pitch of plane 0 in bytes in vertical direction */ |
| 367 |
int size; |
| 368 |
int orig_width; /* the width of plane 0 in pixels */ |
| 369 |
int orig_height; /* the height of plane 0 in pixels */ |
| 370 |
int flags; |
| 371 |
unsigned int fourcc; |
| 372 |
dri_bo *bo; |
| 373 |
unsigned int expected_format; |
| 374 |
VAImageID locked_image_id; |
| 375 |
VAImageID derived_image_id; |
| 376 |
void (*free_private_data)(void **data); |
| 377 |
void *private_data; |
| 378 |
unsigned int subsampling; |
| 379 |
int x_cb_offset; |
| 380 |
int y_cb_offset; |
| 381 |
int x_cr_offset; |
| 382 |
int y_cr_offset; |
| 383 |
int cb_cr_width; |
| 384 |
int cb_cr_height; |
| 385 |
int cb_cr_pitch; |
| 386 |
/* user specified attributes see: VASurfaceAttribExternalBuffers/VA_SURFACE_ATTRIB_MEM_TYPE_VA */ |
| 387 |
uint32_t user_disable_tiling : 1; |
| 388 |
uint32_t user_h_stride_set : 1; |
| 389 |
uint32_t user_v_stride_set : 1; |
| 390 |
/* we need clear right and bottom border for NV12. |
| 391 |
* to avoid encode run to run issue*/ |
| 392 |
uint32_t border_cleared : 1; |
| 393 |
|
| 394 |
VAGenericID wrapper_surface; |
| 395 |
|
| 396 |
int exported_primefd; |
| 397 |
}; |
| 398 |
|
| 399 |
struct object_buffer { |
| 400 |
struct object_base base; |
| 401 |
struct buffer_store *buffer_store; |
| 402 |
int max_num_elements; |
| 403 |
int num_elements; |
| 404 |
int size_element; |
| 405 |
VABufferType type; |
| 406 |
|
| 407 |
/* Export state */ |
| 408 |
unsigned int export_refcount; |
| 409 |
VABufferInfo export_state; |
| 410 |
|
| 411 |
VAGenericID wrapper_buffer; |
| 412 |
VAContextID context_id; |
| 413 |
}; |
| 414 |
|
| 415 |
struct object_image { |
| 416 |
struct object_base base; |
| 417 |
VAImage image; |
| 418 |
dri_bo *bo; |
| 419 |
unsigned int *palette; |
| 420 |
VASurfaceID derived_surface; |
| 421 |
}; |
| 422 |
|
| 423 |
struct object_subpic { |
| 424 |
struct object_base base; |
| 425 |
VAImageID image; |
| 426 |
struct object_image *obj_image; |
| 427 |
VARectangle src_rect; |
| 428 |
VARectangle dst_rect; |
| 429 |
unsigned int format; |
| 430 |
int width; |
| 431 |
int height; |
| 432 |
int pitch; |
| 433 |
float global_alpha; |
| 434 |
dri_bo *bo; |
| 435 |
unsigned int flags; |
| 436 |
}; |
| 437 |
|
| 438 |
#define I965_RING_NULL 0 |
| 439 |
#define I965_RING_BSD 1 |
| 440 |
#define I965_RING_BLT 2 |
| 441 |
#define I965_RING_VEBOX 3 |
| 442 |
|
| 443 |
struct i965_filter { |
| 444 |
VAProcFilterType type; |
| 445 |
int ring; |
| 446 |
}; |
| 447 |
|
| 448 |
struct i965_driver_data; |
| 449 |
|
| 450 |
struct hw_codec_info { |
| 451 |
struct hw_context *(*dec_hw_context_init)(VADriverContextP, struct object_config *); |
| 452 |
struct hw_context *(*enc_hw_context_init)(VADriverContextP, struct object_config *); |
| 453 |
struct hw_context *(*proc_hw_context_init)(VADriverContextP, struct object_config *); |
| 454 |
bool (*render_init)(VADriverContextP); |
| 455 |
void (*post_processing_context_init)(VADriverContextP, void *, struct intel_batchbuffer *); |
| 456 |
void (*preinit_hw_codec)(VADriverContextP, struct hw_codec_info *); |
| 457 |
|
| 458 |
/** |
| 459 |
* Allows HW info to support per-codec max resolution. If this functor is |
| 460 |
* not initialized, then @max_width and @max_height will be used as the |
| 461 |
* default maximum resolution for all codecs on this HW info. |
| 462 |
*/ |
| 463 |
void (*max_resolution)(struct i965_driver_data *, struct object_config *, int *, int *); |
| 464 |
|
| 465 |
int max_width; |
| 466 |
int max_height; |
| 467 |
int min_linear_wpitch; |
| 468 |
int min_linear_hpitch; |
| 469 |
|
| 470 |
unsigned int h264_mvc_dec_profiles; |
| 471 |
unsigned int vp9_dec_profiles; |
| 472 |
unsigned int vp9_enc_profiles; |
| 473 |
|
| 474 |
unsigned int h264_dec_chroma_formats; |
| 475 |
unsigned int jpeg_dec_chroma_formats; |
| 476 |
unsigned int jpeg_enc_chroma_formats; |
| 477 |
unsigned int hevc_dec_chroma_formats; |
| 478 |
unsigned int vp9_dec_chroma_formats; |
| 479 |
|
| 480 |
unsigned int has_mpeg2_decoding: 1; |
| 481 |
unsigned int has_mpeg2_encoding: 1; |
| 482 |
unsigned int has_h264_decoding: 1; |
| 483 |
unsigned int has_h264_encoding: 1; |
| 484 |
unsigned int has_vc1_decoding: 1; |
| 485 |
unsigned int has_vc1_encoding: 1; |
| 486 |
unsigned int has_jpeg_decoding: 1; |
| 487 |
unsigned int has_jpeg_encoding: 1; |
| 488 |
unsigned int has_vpp: 1; |
| 489 |
unsigned int has_accelerated_getimage: 1; |
| 490 |
unsigned int has_accelerated_putimage: 1; |
| 491 |
unsigned int has_tiled_surface: 1; |
| 492 |
unsigned int has_di_motion_adptive: 1; |
| 493 |
unsigned int has_di_motion_compensated: 1; |
| 494 |
unsigned int has_vp8_decoding: 1; |
| 495 |
unsigned int has_vp8_encoding: 1; |
| 496 |
unsigned int has_h264_mvc_encoding: 1; |
| 497 |
unsigned int has_hevc_decoding: 1; |
| 498 |
unsigned int has_hevc_encoding: 1; |
| 499 |
unsigned int has_hevc10_encoding: 1; |
| 500 |
unsigned int has_hevc10_decoding: 1; |
| 501 |
unsigned int has_vp9_decoding: 1; |
| 502 |
unsigned int has_vpp_p010: 1; |
| 503 |
unsigned int has_lp_h264_encoding: 1; |
| 504 |
unsigned int has_vp9_encoding: 1; |
| 505 |
unsigned int has_fei_h264_encoding: 1; |
| 506 |
unsigned int has_h264_preenc: 1; |
| 507 |
unsigned int has_lp_vp9_encoding: 1; |
| 508 |
|
| 509 |
unsigned int lp_h264_brc_mode; |
| 510 |
unsigned int lp_vp9_brc_mode; |
| 511 |
|
| 512 |
unsigned int h264_brc_mode; |
| 513 |
unsigned int vp9_brc_mode; |
| 514 |
|
| 515 |
unsigned int num_filters; |
| 516 |
struct i965_filter filters[VAProcFilterCount]; |
| 517 |
}; |
| 518 |
|
| 519 |
|
| 520 |
#include "i965_render.h" |
| 521 |
#include "i965_gpe_utils.h" |
| 522 |
|
| 523 |
struct i965_driver_data { |
| 524 |
struct intel_driver_data intel; |
| 525 |
struct object_heap config_heap; |
| 526 |
struct object_heap context_heap; |
| 527 |
struct object_heap surface_heap; |
| 528 |
struct object_heap buffer_heap; |
| 529 |
struct object_heap image_heap; |
| 530 |
struct object_heap subpic_heap; |
| 531 |
struct hw_codec_info *codec_info; |
| 532 |
|
| 533 |
_I965Mutex render_mutex; |
| 534 |
_I965Mutex pp_mutex; |
| 535 |
struct intel_batchbuffer *batch; |
| 536 |
struct intel_batchbuffer *pp_batch; |
| 537 |
struct i965_render_state render_state; |
| 538 |
void *pp_context; |
| 539 |
char va_vendor[256]; |
| 540 |
|
| 541 |
VADisplayAttribute *display_attributes; |
| 542 |
unsigned int num_display_attributes; |
| 543 |
VADisplayAttribute *rotation_attrib; |
| 544 |
VADisplayAttribute *brightness_attrib; |
| 545 |
VADisplayAttribute *contrast_attrib; |
| 546 |
VADisplayAttribute *hue_attrib; |
| 547 |
VADisplayAttribute *saturation_attrib; |
| 548 |
VAContextID current_context_id; |
| 549 |
|
| 550 |
/* VA/DRI (X11) specific data */ |
| 551 |
struct va_dri_output *dri_output; |
| 552 |
|
| 553 |
/* VA/Wayland specific data */ |
| 554 |
struct va_wl_output *wl_output; |
| 555 |
|
| 556 |
VADriverContextP wrapper_pdrvctx; |
| 557 |
|
| 558 |
struct i965_gpe_table gpe_table; |
| 559 |
}; |
| 560 |
|
| 561 |
#define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap); |
| 562 |
#define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap); |
| 563 |
#define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap); |
| 564 |
#define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap); |
| 565 |
#define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap); |
| 566 |
#define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap); |
| 567 |
|
| 568 |
#define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id)) |
| 569 |
#define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id)) |
| 570 |
#define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id)) |
| 571 |
#define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id)) |
| 572 |
#define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id)) |
| 573 |
#define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id)) |
| 574 |
|
| 575 |
#define FOURCC_IA44 0x34344149 |
| 576 |
#define FOURCC_AI44 0x34344941 |
| 577 |
|
| 578 |
#define STRIDE(w) (((w) + 0xf) & ~0xf) |
| 579 |
#define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1))) |
| 580 |
|
| 581 |
static INLINE struct i965_driver_data * |
| 582 |
i965_driver_data(VADriverContextP ctx) |
| 583 |
{ |
| 584 |
return (struct i965_driver_data *)(ctx->pDriverData); |
| 585 |
} |
| 586 |
|
| 587 |
VAStatus |
| 588 |
i965_check_alloc_surface_bo(VADriverContextP ctx, |
| 589 |
struct object_surface *obj_surface, |
| 590 |
int tiled, |
| 591 |
unsigned int fourcc, |
| 592 |
unsigned int subsampling); |
| 593 |
|
| 594 |
int |
| 595 |
va_enc_packed_type_to_idx(int packed_type); |
| 596 |
|
| 597 |
/* reserve 2 byte for internal using */ |
| 598 |
#define CODEC_H264 0 |
| 599 |
#define CODEC_MPEG2 1 |
| 600 |
#define CODEC_H264_MVC 2 |
| 601 |
#define CODEC_JPEG 3 |
| 602 |
#define CODEC_VP8 4 |
| 603 |
#define CODEC_HEVC 5 |
| 604 |
#define CODEC_VP9 6 |
| 605 |
|
| 606 |
#define H264_DELIMITER0 0x00 |
| 607 |
#define H264_DELIMITER1 0x00 |
| 608 |
#define H264_DELIMITER2 0x00 |
| 609 |
#define H264_DELIMITER3 0x00 |
| 610 |
#define H264_DELIMITER4 0x00 |
| 611 |
|
| 612 |
#define MPEG2_DELIMITER0 0x00 |
| 613 |
#define MPEG2_DELIMITER1 0x00 |
| 614 |
#define MPEG2_DELIMITER2 0x00 |
| 615 |
#define MPEG2_DELIMITER3 0x00 |
| 616 |
#define MPEG2_DELIMITER4 0xb0 |
| 617 |
|
| 618 |
#define HEVC_DELIMITER0 0x00 |
| 619 |
#define HEVC_DELIMITER1 0x00 |
| 620 |
#define HEVC_DELIMITER2 0x00 |
| 621 |
#define HEVC_DELIMITER3 0x00 |
| 622 |
#define HEVC_DELIMITER4 0x00 |
| 623 |
|
| 624 |
struct i965_coded_buffer_segment { |
| 625 |
union { |
| 626 |
VACodedBufferSegment base; |
| 627 |
unsigned char pad0[64]; /* change the size if sizeof(VACodedBufferSegment) > 64 */ |
| 628 |
}; |
| 629 |
|
| 630 |
unsigned int mapped; |
| 631 |
unsigned int codec; |
| 632 |
unsigned int status_support; |
| 633 |
unsigned int pad1; |
| 634 |
|
| 635 |
unsigned int codec_private_data[512]; /* Store codec private data, must be 16-bytes aligned */ |
| 636 |
}; |
| 637 |
|
| 638 |
#define I965_CODEDBUFFER_HEADER_SIZE ALIGN(sizeof(struct i965_coded_buffer_segment), 0x1000) |
| 639 |
|
| 640 |
extern VAStatus i965_MapBuffer(VADriverContextP ctx, |
| 641 |
VABufferID buf_id, /* in */ |
| 642 |
void **pbuf); /* out */ |
| 643 |
|
| 644 |
extern VAStatus i965_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id); |
| 645 |
|
| 646 |
extern VAStatus i965_DestroySurfaces(VADriverContextP ctx, |
| 647 |
VASurfaceID *surface_list, |
| 648 |
int num_surfaces); |
| 649 |
|
| 650 |
extern VAStatus i965_CreateSurfaces(VADriverContextP ctx, |
| 651 |
int width, |
| 652 |
int height, |
| 653 |
int format, |
| 654 |
int num_surfaces, |
| 655 |
VASurfaceID *surfaces); |
| 656 |
|
| 657 |
#define I965_SURFACE_MEM_NATIVE 0 |
| 658 |
#define I965_SURFACE_MEM_GEM_FLINK 1 |
| 659 |
#define I965_SURFACE_MEM_DRM_PRIME 2 |
| 660 |
|
| 661 |
void |
| 662 |
i965_destroy_surface_storage(struct object_surface *obj_surface); |
| 663 |
|
| 664 |
// Logging functions for errors (to be shown to users) and info (useful for developers). |
| 665 |
void i965_log_error(VADriverContextP ctx, const char *format, ...); |
| 666 |
void i965_log_info(VADriverContextP ctx, const char *format, ...); |
| 667 |
|
| 668 |
#endif /* _I965_DRV_VIDEO_H_ */ |