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
51 #define INTEL_STR_DRIVER_VENDOR "Intel"
52 #define INTEL_STR_DRIVER_NAME "i965"
54 #define I965_SURFACE_TYPE_IMAGE 0
55 #define I965_SURFACE_TYPE_SURFACE 1
57 #define I965_SURFACE_FLAG_FRAME 0x00000000
58 #define I965_SURFACE_FLAG_TOP_FIELD_FIRST 0x00000001
59 #define I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST 0x00000002
72 const uint32_t (*bin)[4];
79 unsigned char *buffer;
87 struct object_base base;
89 VAEntrypoint entrypoint;
90 VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES];
98 struct buffer_store *pic_param;
99 struct buffer_store **slice_params;
100 struct buffer_store *iq_matrix;
101 struct buffer_store *bit_plane;
102 struct buffer_store *huffman_table;
103 struct buffer_store **slice_datas;
104 VASurfaceID current_render_target;
105 int max_slice_params;
107 int num_slice_params;
113 struct buffer_store *seq_param;
114 struct buffer_store *pic_param;
115 struct buffer_store *pic_control;
116 struct buffer_store *iq_matrix;
117 struct buffer_store *q_matrix;
118 struct buffer_store **slice_params;
119 int max_slice_params;
120 int num_slice_params;
123 struct buffer_store *seq_param_ext;
124 struct buffer_store *pic_param_ext;
125 struct buffer_store *packed_header_param[4];
126 struct buffer_store *packed_header_data[4];
127 struct buffer_store **slice_params_ext;
128 int max_slice_params_ext;
129 int num_slice_params_ext;
130 int last_packed_header_type;
132 struct buffer_store *misc_param[8];
134 VASurfaceID current_render_target;
135 struct object_surface *input_yuv_object;
140 struct buffer_store *pipeline_param;
142 VASurfaceID current_render_target;
151 struct decode_state decode;
152 struct encode_state encode;
153 struct proc_state proc;
158 VAStatus (*run)(VADriverContextP ctx,
160 union codec_state *codec_state,
161 struct hw_context *hw_context);
162 void (*destroy)(void *);
163 struct intel_batchbuffer *batch;
166 struct object_context
168 struct object_base base;
169 VAContextID context_id;
170 VAConfigID config_id;
171 VASurfaceID *render_targets; //input->encode, output->decode
172 int num_render_targets;
177 union codec_state codec_state;
178 struct hw_context *hw_context;
181 #define SURFACE_REFERENCED (1 << 0)
182 #define SURFACE_DISPLAYED (1 << 1)
183 #define SURFACE_DERIVED (1 << 2)
184 #define SURFACE_REF_DIS_MASK ((SURFACE_REFERENCED) | \
186 #define SURFACE_ALL_MASK ((SURFACE_REFERENCED) | \
187 (SURFACE_DISPLAYED) | \
190 struct object_surface
192 struct object_base base;
193 VASurfaceStatus status;
194 VASubpictureID subpic[I965_MAX_SUBPIC_SUM];
195 unsigned int subpic_render_idx;
205 VAImageID locked_image_id;
206 void (*free_private_data)(void **data);
208 unsigned int subsampling;
220 struct object_base base;
221 struct buffer_store *buffer_store;
222 int max_num_elements;
230 struct object_base base;
233 unsigned int *palette;
234 VASurfaceID derived_surface;
239 struct object_base base;
241 VARectangle src_rect;
242 VARectangle dst_rect;
254 struct hw_context *(*dec_hw_context_init)(VADriverContextP, struct object_config *);
255 struct hw_context *(*enc_hw_context_init)(VADriverContextP, struct object_config *);
256 struct hw_context *(*proc_hw_context_init)(VADriverContextP, struct object_config *);
260 unsigned int has_mpeg2_decoding:1;
261 unsigned int has_mpeg2_encoding:1;
262 unsigned int has_h264_decoding:1;
263 unsigned int has_h264_encoding:1;
264 unsigned int has_vc1_decoding:1;
265 unsigned int has_vc1_encoding:1;
266 unsigned int has_jpeg_decoding:1;
267 unsigned int has_jpeg_encoding:1;
268 unsigned int has_vpp:1;
269 unsigned int has_accelerated_getimage:1;
270 unsigned int has_accelerated_putimage:1;
271 unsigned int has_tiled_surface:1;
275 #include "i965_render.h"
277 struct i965_driver_data
279 struct intel_driver_data intel;
280 struct object_heap config_heap;
281 struct object_heap context_heap;
282 struct object_heap surface_heap;
283 struct object_heap buffer_heap;
284 struct object_heap image_heap;
285 struct object_heap subpic_heap;
286 struct hw_codec_info *codec_info;
288 _I965Mutex render_mutex;
290 struct intel_batchbuffer *batch;
291 struct i965_render_state render_state;
295 VADisplayAttribute *display_attributes;
296 unsigned int num_display_attributes;
297 VADisplayAttribute *rotation_attrib;
299 VAContextID current_context_id;
301 /* VA/DRI (X11) specific data */
302 struct va_dri_output *dri_output;
304 /* VA/Wayland specific data */
305 struct va_wl_output *wl_output;
308 #define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap);
309 #define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap);
310 #define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap);
311 #define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap);
312 #define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap);
313 #define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap);
315 #define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id))
316 #define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id))
317 #define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id))
318 #define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id))
319 #define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id))
320 #define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id))
322 #define FOURCC_IA44 0x34344149
323 #define FOURCC_AI44 0x34344941
325 #define STRIDE(w) (((w) + 0xf) & ~0xf)
326 #define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1)))
328 static INLINE struct i965_driver_data *
329 i965_driver_data(VADriverContextP ctx)
331 return (struct i965_driver_data *)(ctx->pDriverData);
335 i965_check_alloc_surface_bo(VADriverContextP ctx,
336 struct object_surface *obj_surface,
339 unsigned int subsampling);
342 va_enc_packed_type_to_idx(int packed_type);
344 /* reserve 2 byte for internal using */
346 #define CODED_MPEG2 1
348 #define H264_DELIMITER0 0x00
349 #define H264_DELIMITER1 0x00
350 #define H264_DELIMITER2 0x00
351 #define H264_DELIMITER3 0x00
352 #define H264_DELIMITER4 0x00
354 #define MPEG2_DELIMITER0 0x00
355 #define MPEG2_DELIMITER1 0x00
356 #define MPEG2_DELIMITER2 0x00
357 #define MPEG2_DELIMITER3 0x00
358 #define MPEG2_DELIMITER4 0xb0
360 struct i965_coded_buffer_segment
362 VACodedBufferSegment base;
363 unsigned char mapped;
367 #define I965_CODEDBUFFER_HEADER_SIZE ALIGN(sizeof(struct i965_coded_buffer_segment), 64)
370 extern VAStatus i965_MapBuffer(VADriverContextP ctx,
371 VABufferID buf_id, /* in */
372 void **pbuf); /* out */
374 extern VAStatus i965_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id);
376 #endif /* _I965_DRV_VIDEO_H_ */