2 * Copyright © 2009 Intel Corporation
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 * Xiang Haihao <haihao.xiang@intel.com>
26 * Zou Nan hai <nanhai.zou@intel.com>
30 #ifndef _I965_DRV_VIDEO_H_
31 #define _I965_DRV_VIDEO_H_
34 #include <va/va_enc_h264.h>
35 #include <va/va_enc_mpeg2.h>
36 #include <va/va_vpp.h>
37 #include <va/va_backend.h>
38 #include <va/va_backend_vpp.h>
40 #include "i965_mutext.h"
41 #include "object_heap.h"
42 #include "intel_driver.h"
44 #define I965_MAX_PROFILES 11
45 #define I965_MAX_ENTRYPOINTS 5
46 #define I965_MAX_CONFIG_ATTRIBUTES 10
47 #define I965_MAX_IMAGE_FORMATS 10
48 #define I965_MAX_SUBPIC_FORMATS 6
49 #define I965_MAX_SUBPIC_SUM 4
50 #define I965_MAX_SURFACE_ATTRIBUTES 16
52 #define INTEL_STR_DRIVER_VENDOR "Intel"
53 #define INTEL_STR_DRIVER_NAME "i965"
55 #define I965_SURFACE_TYPE_IMAGE 0
56 #define I965_SURFACE_TYPE_SURFACE 1
58 #define I965_SURFACE_FLAG_FRAME 0x00000000
59 #define I965_SURFACE_FLAG_TOP_FIELD_FIRST 0x00000001
60 #define I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST 0x00000002
62 #define DEFAULT_BRIGHTNESS 0
63 #define DEFAULT_CONTRAST 10
65 #define DEFAULT_SATURATION 10
69 struct object_base *base;
78 const uint32_t (*bin)[4];
85 unsigned char *buffer;
93 struct object_base base;
95 VAEntrypoint entrypoint;
96 VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES];
100 #define NUM_SLICES 10
104 struct buffer_store *pic_param;
105 struct buffer_store **slice_params;
106 struct buffer_store *iq_matrix;
107 struct buffer_store *bit_plane;
108 struct buffer_store *huffman_table;
109 struct buffer_store **slice_datas;
110 VASurfaceID current_render_target;
111 int max_slice_params;
113 int num_slice_params;
116 struct object_surface *render_object;
117 struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/
122 struct buffer_store *seq_param;
123 struct buffer_store *pic_param;
124 struct buffer_store *pic_control;
125 struct buffer_store *iq_matrix;
126 struct buffer_store *q_matrix;
127 struct buffer_store **slice_params;
128 int max_slice_params;
129 int num_slice_params;
132 struct buffer_store *seq_param_ext;
133 struct buffer_store *pic_param_ext;
134 struct buffer_store *packed_header_param[4];
135 struct buffer_store *packed_header_data[4];
136 struct buffer_store **slice_params_ext;
137 int max_slice_params_ext;
138 int num_slice_params_ext;
139 int last_packed_header_type;
141 struct buffer_store *misc_param[8];
143 VASurfaceID current_render_target;
144 struct object_surface *input_yuv_object;
145 struct object_surface *reconstructed_object;
146 struct object_buffer *coded_buf_object;
147 struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/
152 struct buffer_store *pipeline_param;
154 VASurfaceID current_render_target;
163 struct decode_state decode;
164 struct encode_state encode;
165 struct proc_state proc;
170 VAStatus (*run)(VADriverContextP ctx,
172 union codec_state *codec_state,
173 struct hw_context *hw_context);
174 void (*destroy)(void *);
175 struct intel_batchbuffer *batch;
178 struct object_context
180 struct object_base base;
181 VAContextID context_id;
182 struct object_config *obj_config;
183 VASurfaceID *render_targets; //input->encode, output->decode
184 int num_render_targets;
189 union codec_state codec_state;
190 struct hw_context *hw_context;
193 #define SURFACE_REFERENCED (1 << 0)
194 #define SURFACE_DISPLAYED (1 << 1)
195 #define SURFACE_DERIVED (1 << 2)
196 #define SURFACE_REF_DIS_MASK ((SURFACE_REFERENCED) | \
198 #define SURFACE_ALL_MASK ((SURFACE_REFERENCED) | \
199 (SURFACE_DISPLAYED) | \
202 struct object_surface
204 struct object_base base;
205 VASurfaceStatus status;
206 VASubpictureID subpic[I965_MAX_SUBPIC_SUM];
207 struct object_subpic *obj_subpic[I965_MAX_SUBPIC_SUM];
208 unsigned int subpic_render_idx;
210 int width; /* the pitch of plane 0 in bytes in horizontal direction */
211 int height; /* the pitch of plane 0 in bytes in vertical direction */
213 int orig_width; /* the width of plane 0 in pixels */
214 int orig_height; /* the height of plane 0 in pixels */
218 VAImageID locked_image_id;
219 void (*free_private_data)(void **data);
221 unsigned int subsampling;
233 struct object_base base;
234 struct buffer_store *buffer_store;
235 int max_num_elements;
243 struct object_base base;
246 unsigned int *palette;
247 VASurfaceID derived_surface;
252 struct object_base base;
254 struct object_image *obj_image;
255 VARectangle src_rect;
256 VARectangle dst_rect;
266 #define I965_RING_NULL 0
267 #define I965_RING_BSD 1
268 #define I965_RING_BLT 2
269 #define I965_RING_VEBOX 3
273 VAProcFilterType type;
279 struct hw_context *(*dec_hw_context_init)(VADriverContextP, struct object_config *);
280 struct hw_context *(*enc_hw_context_init)(VADriverContextP, struct object_config *);
281 struct hw_context *(*proc_hw_context_init)(VADriverContextP, struct object_config *);
285 unsigned int has_mpeg2_decoding:1;
286 unsigned int has_mpeg2_encoding:1;
287 unsigned int has_h264_decoding:1;
288 unsigned int has_h264_encoding:1;
289 unsigned int has_vc1_decoding:1;
290 unsigned int has_vc1_encoding:1;
291 unsigned int has_jpeg_decoding:1;
292 unsigned int has_jpeg_encoding:1;
293 unsigned int has_vpp:1;
294 unsigned int has_accelerated_getimage:1;
295 unsigned int has_accelerated_putimage:1;
296 unsigned int has_tiled_surface:1;
297 unsigned int has_di_motion_adptive:1;
298 unsigned int has_di_motion_compensated:1;
300 unsigned int num_filters;
301 struct i965_filter filters[VAProcFilterCount];
305 #include "i965_render.h"
307 struct i965_driver_data
309 struct intel_driver_data intel;
310 struct object_heap config_heap;
311 struct object_heap context_heap;
312 struct object_heap surface_heap;
313 struct object_heap buffer_heap;
314 struct object_heap image_heap;
315 struct object_heap subpic_heap;
316 struct hw_codec_info *codec_info;
318 _I965Mutex render_mutex;
320 struct intel_batchbuffer *batch;
321 struct intel_batchbuffer *pp_batch;
322 struct i965_render_state render_state;
326 VADisplayAttribute *display_attributes;
327 unsigned int num_display_attributes;
328 VADisplayAttribute *rotation_attrib;
329 VADisplayAttribute *brightness_attrib;
330 VADisplayAttribute *contrast_attrib;
331 VADisplayAttribute *hue_attrib;
332 VADisplayAttribute *saturation_attrib;
333 VAContextID current_context_id;
335 /* VA/DRI (X11) specific data */
336 struct va_dri_output *dri_output;
338 /* VA/Wayland specific data */
339 struct va_wl_output *wl_output;
342 #define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap);
343 #define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap);
344 #define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap);
345 #define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap);
346 #define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap);
347 #define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap);
349 #define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id))
350 #define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id))
351 #define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id))
352 #define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id))
353 #define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id))
354 #define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id))
356 #define FOURCC_IA44 0x34344149
357 #define FOURCC_AI44 0x34344941
359 #define STRIDE(w) (((w) + 0xf) & ~0xf)
360 #define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1)))
362 static INLINE struct i965_driver_data *
363 i965_driver_data(VADriverContextP ctx)
365 return (struct i965_driver_data *)(ctx->pDriverData);
369 i965_check_alloc_surface_bo(VADriverContextP ctx,
370 struct object_surface *obj_surface,
373 unsigned int subsampling);
376 va_enc_packed_type_to_idx(int packed_type);
378 /* reserve 2 byte for internal using */
380 #define CODEC_MPEG2 1
382 #define H264_DELIMITER0 0x00
383 #define H264_DELIMITER1 0x00
384 #define H264_DELIMITER2 0x00
385 #define H264_DELIMITER3 0x00
386 #define H264_DELIMITER4 0x00
388 #define MPEG2_DELIMITER0 0x00
389 #define MPEG2_DELIMITER1 0x00
390 #define MPEG2_DELIMITER2 0x00
391 #define MPEG2_DELIMITER3 0x00
392 #define MPEG2_DELIMITER4 0xb0
394 struct i965_coded_buffer_segment
396 VACodedBufferSegment base;
397 unsigned char mapped;
401 #define I965_CODEDBUFFER_HEADER_SIZE ALIGN(sizeof(struct i965_coded_buffer_segment), 64)
403 extern VAStatus i965_MapBuffer(VADriverContextP ctx,
404 VABufferID buf_id, /* in */
405 void **pbuf); /* out */
407 extern VAStatus i965_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id);
409 #define I965_SURFACE_MEM_NATIVE 0
410 #define I965_SURFACE_MEM_GEM_FLINK 1
411 #define I965_SURFACE_MEM_DRM_PRIME 2
413 #endif /* _I965_DRV_VIDEO_H_ */