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 #include "config_android.h"
41 # include "i965_output_dri.h"
44 #ifdef HAVE_VA_WAYLAND
45 # include "i965_output_wayland.h"
48 #include "intel_driver.h"
49 #include "intel_memman.h"
50 #include "intel_batchbuffer.h"
51 #include "i965_defines.h"
52 #include "i965_drv_video.h"
53 #include "i965_decoder.h"
54 #include "i965_encoder.h"
56 #define CONFIG_ID_OFFSET 0x01000000
57 #define CONTEXT_ID_OFFSET 0x02000000
58 #define SURFACE_ID_OFFSET 0x04000000
59 #define BUFFER_ID_OFFSET 0x08000000
60 #define IMAGE_ID_OFFSET 0x0a000000
61 #define SUBPIC_ID_OFFSET 0x10000000
63 #define HAS_MPEG2_DECODING(ctx) ((ctx)->codec_info->has_mpeg2_decoding && \
66 #define HAS_MPEG2_ENCODING(ctx) ((ctx)->codec_info->has_mpeg2_encoding && \
69 #define HAS_H264_DECODING(ctx) ((ctx)->codec_info->has_h264_decoding && \
72 #define HAS_H264_ENCODING(ctx) ((ctx)->codec_info->has_h264_encoding && \
75 #define HAS_VC1_DECODING(ctx) ((ctx)->codec_info->has_vc1_decoding && \
78 #define HAS_JPEG_DECODING(ctx) ((ctx)->codec_info->has_jpeg_decoding && \
81 #define HAS_VPP(ctx) ((ctx)->codec_info->has_vpp)
83 #define HAS_ACCELERATED_GETIMAGE(ctx) ((ctx)->codec_info->has_accelerated_getimage)
85 #define HAS_ACCELERATED_PUTIMAGE(ctx) ((ctx)->codec_info->has_accelerated_putimage)
87 #define HAS_TILED_SURFACE(ctx) ((ctx)->codec_info->has_tiled_surface)
89 static int get_sampling_from_fourcc(unsigned int fourcc);
91 /* Check whether we are rendering to X11 (VA/X11 or VA/GLX API) */
92 #define IS_VA_X11(ctx) \
93 (((ctx)->display_type & VA_DISPLAY_MAJOR_MASK) == VA_DISPLAY_X11)
95 /* Check whether we are rendering to Wayland */
96 #define IS_VA_WAYLAND(ctx) \
97 (((ctx)->display_type & VA_DISPLAY_MAJOR_MASK) == VA_DISPLAY_WAYLAND)
100 I965_SURFACETYPE_RGBA = 1,
101 I965_SURFACETYPE_YUV,
102 I965_SURFACETYPE_INDEXED
105 /* List of supported display attributes */
106 static const VADisplayAttribute i965_display_attributes[] = {
108 VADisplayAttribRotation,
109 0, 3, VA_ROTATION_NONE,
110 VA_DISPLAY_ATTRIB_GETTABLE|VA_DISPLAY_ATTRIB_SETTABLE
114 /* List of supported image formats */
117 VAImageFormat va_format;
118 } i965_image_format_map_t;
120 static const i965_image_format_map_t
121 i965_image_formats_map[I965_MAX_IMAGE_FORMATS + 1] = {
122 { I965_SURFACETYPE_YUV,
123 { VA_FOURCC('Y','V','1','2'), VA_LSB_FIRST, 12, } },
124 { I965_SURFACETYPE_YUV,
125 { VA_FOURCC('I','4','2','0'), VA_LSB_FIRST, 12, } },
126 { I965_SURFACETYPE_YUV,
127 { VA_FOURCC('N','V','1','2'), VA_LSB_FIRST, 12, } },
128 { I965_SURFACETYPE_YUV,
129 { VA_FOURCC('Y','U','Y','2'), VA_LSB_FIRST, 16, } },
130 { I965_SURFACETYPE_YUV,
131 { VA_FOURCC('U','Y','V','Y'), VA_LSB_FIRST, 16, } },
132 { I965_SURFACETYPE_RGBA,
133 { VA_FOURCC('R','G','B','X'), VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000 } },
134 { I965_SURFACETYPE_RGBA,
135 { VA_FOURCC('B','G','R','X'), VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff } },
138 /* List of supported subpicture formats */
142 VAImageFormat va_format;
143 unsigned int va_flags;
144 } i965_subpic_format_map_t;
146 static const i965_subpic_format_map_t
147 i965_subpic_formats_map[I965_MAX_SUBPIC_FORMATS + 1] = {
148 { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_P4A4_UNORM,
149 { VA_FOURCC('I','A','4','4'), VA_MSB_FIRST, 8, },
150 VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD },
151 { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_A4P4_UNORM,
152 { VA_FOURCC('A','I','4','4'), VA_MSB_FIRST, 8, },
153 VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD },
154 { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_P8A8_UNORM,
155 { VA_FOURCC('I','A','8','8'), VA_MSB_FIRST, 16, },
156 VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD },
157 { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_A8P8_UNORM,
158 { VA_FOURCC('A','I','8','8'), VA_MSB_FIRST, 16, },
159 VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD },
160 { I965_SURFACETYPE_RGBA, I965_SURFACEFORMAT_B8G8R8A8_UNORM,
161 { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32,
162 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 },
163 VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD },
164 { I965_SURFACETYPE_RGBA, I965_SURFACEFORMAT_R8G8B8A8_UNORM,
165 { VA_FOURCC('R','G','B','A'), VA_LSB_FIRST, 32,
166 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 },
167 VA_SUBPICTURE_DESTINATION_IS_SCREEN_COORD },
170 static const i965_subpic_format_map_t *
171 get_subpic_format(const VAImageFormat *va_format)
174 for (i = 0; i965_subpic_formats_map[i].type != 0; i++) {
175 const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[i];
176 if (m->va_format.fourcc == va_format->fourcc &&
177 (m->type == I965_SURFACETYPE_RGBA ?
178 (m->va_format.byte_order == va_format->byte_order &&
179 m->va_format.red_mask == va_format->red_mask &&
180 m->va_format.green_mask == va_format->green_mask &&
181 m->va_format.blue_mask == va_format->blue_mask &&
182 m->va_format.alpha_mask == va_format->alpha_mask) : 1))
188 extern struct hw_context *i965_proc_context_init(VADriverContextP, struct object_config *);
189 extern struct hw_context *g4x_dec_hw_context_init(VADriverContextP, struct object_config *);
190 static struct hw_codec_info g4x_hw_codec_info = {
191 .dec_hw_context_init = g4x_dec_hw_context_init,
192 .enc_hw_context_init = NULL,
193 .proc_hw_context_init = NULL,
197 .has_mpeg2_decoding = 1,
200 extern struct hw_context *ironlake_dec_hw_context_init(VADriverContextP, struct object_config *);
201 static struct hw_codec_info ironlake_hw_codec_info = {
202 .dec_hw_context_init = ironlake_dec_hw_context_init,
203 .enc_hw_context_init = NULL,
204 .proc_hw_context_init = i965_proc_context_init,
208 .has_mpeg2_decoding = 1,
209 .has_h264_decoding = 1,
211 .has_accelerated_putimage = 1,
214 extern struct hw_context *gen6_dec_hw_context_init(VADriverContextP, struct object_config *);
215 extern struct hw_context *gen6_enc_hw_context_init(VADriverContextP, struct object_config *);
216 static struct hw_codec_info gen6_hw_codec_info = {
217 .dec_hw_context_init = gen6_dec_hw_context_init,
218 .enc_hw_context_init = gen6_enc_hw_context_init,
219 .proc_hw_context_init = i965_proc_context_init,
223 .has_mpeg2_decoding = 1,
224 .has_h264_decoding = 1,
225 .has_h264_encoding = 1,
226 .has_vc1_decoding = 1,
228 .has_accelerated_getimage = 1,
229 .has_accelerated_putimage = 1,
230 .has_tiled_surface = 1,
233 extern struct hw_context *gen7_dec_hw_context_init(VADriverContextP, struct object_config *);
234 extern struct hw_context *gen7_enc_hw_context_init(VADriverContextP, struct object_config *);
235 static struct hw_codec_info gen7_hw_codec_info = {
236 .dec_hw_context_init = gen7_dec_hw_context_init,
237 .enc_hw_context_init = gen7_enc_hw_context_init,
238 .proc_hw_context_init = i965_proc_context_init,
242 .has_mpeg2_decoding = 1,
243 .has_h264_decoding = 1,
244 .has_h264_encoding = 1,
245 .has_vc1_decoding = 1,
246 .has_jpeg_decoding = 1,
248 .has_accelerated_getimage = 1,
249 .has_accelerated_putimage = 1,
250 .has_tiled_surface = 1,
253 extern struct hw_context *gen75_proc_context_init(VADriverContextP, struct object_config *);
254 static struct hw_codec_info gen75_hw_codec_info = {
255 .dec_hw_context_init = gen75_dec_hw_context_init,
256 .enc_hw_context_init = gen75_enc_hw_context_init,
257 .proc_hw_context_init = gen75_proc_context_init,
261 .has_mpeg2_decoding = 1,
262 .has_h264_decoding = 1,
263 .has_h264_encoding = 1,
264 .has_vc1_decoding = 1,
265 .has_jpeg_decoding = 1,
267 .has_accelerated_getimage = 1,
268 .has_accelerated_putimage = 1,
269 .has_tiled_surface = 1,
272 #define I965_PACKED_HEADER_BASE 0
273 #define I965_PACKED_MISC_HEADER_BASE 3
276 va_enc_packed_type_to_idx(int packed_type)
280 if (packed_type & VAEncPackedHeaderMiscMask) {
281 idx = I965_PACKED_MISC_HEADER_BASE;
282 packed_type = (~VAEncPackedHeaderMiscMask & packed_type);
283 assert(packed_type > 0);
284 idx += (packed_type - 1);
286 idx = I965_PACKED_HEADER_BASE;
288 switch (packed_type) {
289 case VAEncPackedHeaderSequence:
290 idx = I965_PACKED_HEADER_BASE + 0;
293 case VAEncPackedHeaderPicture:
294 idx = I965_PACKED_HEADER_BASE + 1;
297 case VAEncPackedHeaderSlice:
298 idx = I965_PACKED_HEADER_BASE + 2;
302 /* Should not get here */
314 i965_QueryConfigProfiles(VADriverContextP ctx,
315 VAProfile *profile_list, /* out */
316 int *num_profiles) /* out */
318 struct i965_driver_data * const i965 = i965_driver_data(ctx);
321 if (HAS_MPEG2_DECODING(i965) ||
322 HAS_MPEG2_ENCODING(i965)) {
323 profile_list[i++] = VAProfileMPEG2Simple;
324 profile_list[i++] = VAProfileMPEG2Main;
327 if (HAS_H264_DECODING(i965) ||
328 HAS_H264_ENCODING(i965)) {
329 profile_list[i++] = VAProfileH264Baseline;
330 profile_list[i++] = VAProfileH264Main;
331 profile_list[i++] = VAProfileH264High;
334 if (HAS_VC1_DECODING(i965)) {
335 profile_list[i++] = VAProfileVC1Simple;
336 profile_list[i++] = VAProfileVC1Main;
337 profile_list[i++] = VAProfileVC1Advanced;
341 profile_list[i++] = VAProfileNone;
344 if (HAS_JPEG_DECODING(i965)) {
345 profile_list[i++] = VAProfileJPEGBaseline;
348 /* If the assert fails then I965_MAX_PROFILES needs to be bigger */
349 assert(i <= I965_MAX_PROFILES);
352 return VA_STATUS_SUCCESS;
356 i965_QueryConfigEntrypoints(VADriverContextP ctx,
358 VAEntrypoint *entrypoint_list, /* out */
359 int *num_entrypoints) /* out */
361 struct i965_driver_data * const i965 = i965_driver_data(ctx);
365 case VAProfileMPEG2Simple:
366 case VAProfileMPEG2Main:
367 if (HAS_MPEG2_DECODING(i965))
368 entrypoint_list[n++] = VAEntrypointVLD;
370 if (HAS_MPEG2_ENCODING(i965))
371 entrypoint_list[n++] = VAEntrypointEncSlice;
375 case VAProfileH264Baseline:
376 case VAProfileH264Main:
377 case VAProfileH264High:
378 if (HAS_H264_DECODING(i965))
379 entrypoint_list[n++] = VAEntrypointVLD;
381 if (HAS_H264_ENCODING(i965))
382 entrypoint_list[n++] = VAEntrypointEncSlice;
386 case VAProfileVC1Simple:
387 case VAProfileVC1Main:
388 case VAProfileVC1Advanced:
389 if (HAS_VC1_DECODING(i965))
390 entrypoint_list[n++] = VAEntrypointVLD;
395 entrypoint_list[n++] = VAEntrypointVideoProc;
398 case VAProfileJPEGBaseline:
399 if (HAS_JPEG_DECODING(i965))
400 entrypoint_list[n++] = VAEntrypointVLD;
407 /* If the assert fails then I965_MAX_ENTRYPOINTS needs to be bigger */
408 assert(n <= I965_MAX_ENTRYPOINTS);
409 *num_entrypoints = n;
410 return n > 0 ? VA_STATUS_SUCCESS : VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
414 i965_GetConfigAttributes(VADriverContextP ctx,
416 VAEntrypoint entrypoint,
417 VAConfigAttrib *attrib_list, /* in/out */
422 /* Other attributes don't seem to be defined */
423 /* What to do if we don't know the attribute? */
424 for (i = 0; i < num_attribs; i++) {
425 switch (attrib_list[i].type) {
426 case VAConfigAttribRTFormat:
427 attrib_list[i].value = VA_RT_FORMAT_YUV420;
430 case VAConfigAttribRateControl:
431 if (entrypoint == VAEntrypointEncSlice) {
432 attrib_list[i].value = VA_RC_CBR | VA_RC_CQP;
436 case VAConfigAttribEncPackedHeaders:
437 if (entrypoint == VAEntrypointEncSlice) {
438 attrib_list[i].value = VA_ENC_PACKED_HEADER_SEQUENCE | VA_ENC_PACKED_HEADER_PICTURE | VA_ENC_PACKED_HEADER_MISC;
444 attrib_list[i].value = VA_ATTRIB_NOT_SUPPORTED;
449 return VA_STATUS_SUCCESS;
453 i965_destroy_config(struct object_heap *heap, struct object_base *obj)
455 object_heap_free(heap, obj);
459 i965_update_attribute(struct object_config *obj_config, VAConfigAttrib *attrib)
463 /* Check existing attrbiutes */
464 for (i = 0; i < obj_config->num_attribs; i++) {
465 if (obj_config->attrib_list[i].type == attrib->type) {
466 /* Update existing attribute */
467 obj_config->attrib_list[i].value = attrib->value;
468 return VA_STATUS_SUCCESS;
472 if (obj_config->num_attribs < I965_MAX_CONFIG_ATTRIBUTES) {
473 i = obj_config->num_attribs;
474 obj_config->attrib_list[i].type = attrib->type;
475 obj_config->attrib_list[i].value = attrib->value;
476 obj_config->num_attribs++;
477 return VA_STATUS_SUCCESS;
480 return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
484 i965_CreateConfig(VADriverContextP ctx,
486 VAEntrypoint entrypoint,
487 VAConfigAttrib *attrib_list,
489 VAConfigID *config_id) /* out */
491 struct i965_driver_data * const i965 = i965_driver_data(ctx);
492 struct object_config *obj_config;
497 /* Validate profile & entrypoint */
499 case VAProfileMPEG2Simple:
500 case VAProfileMPEG2Main:
501 if ((HAS_MPEG2_DECODING(i965) && VAEntrypointVLD == entrypoint) ||
502 (HAS_MPEG2_ENCODING(i965) && VAEntrypointEncSlice == entrypoint)) {
503 vaStatus = VA_STATUS_SUCCESS;
505 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
509 case VAProfileH264Baseline:
510 case VAProfileH264Main:
511 case VAProfileH264High:
512 if ((HAS_H264_DECODING(i965) && VAEntrypointVLD == entrypoint) ||
513 (HAS_H264_ENCODING(i965) && VAEntrypointEncSlice == entrypoint)) {
514 vaStatus = VA_STATUS_SUCCESS;
516 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
521 case VAProfileVC1Simple:
522 case VAProfileVC1Main:
523 case VAProfileVC1Advanced:
524 if (HAS_VC1_DECODING(i965) && VAEntrypointVLD == entrypoint) {
525 vaStatus = VA_STATUS_SUCCESS;
527 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
533 if (HAS_VPP(i965) && VAEntrypointVideoProc == entrypoint) {
534 vaStatus = VA_STATUS_SUCCESS;
536 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
541 case VAProfileJPEGBaseline:
542 if (HAS_JPEG_DECODING(i965) && VAEntrypointVLD == entrypoint) {
543 vaStatus = VA_STATUS_SUCCESS;
545 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
551 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
555 if (VA_STATUS_SUCCESS != vaStatus) {
559 configID = NEW_CONFIG_ID();
560 obj_config = CONFIG(configID);
562 if (NULL == obj_config) {
563 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
567 obj_config->profile = profile;
568 obj_config->entrypoint = entrypoint;
569 obj_config->attrib_list[0].type = VAConfigAttribRTFormat;
570 obj_config->attrib_list[0].value = VA_RT_FORMAT_YUV420;
571 obj_config->num_attribs = 1;
573 for(i = 0; i < num_attribs; i++) {
574 vaStatus = i965_update_attribute(obj_config, &(attrib_list[i]));
576 if (VA_STATUS_SUCCESS != vaStatus) {
582 if (VA_STATUS_SUCCESS != vaStatus) {
583 i965_destroy_config(&i965->config_heap, (struct object_base *)obj_config);
585 *config_id = configID;
592 i965_DestroyConfig(VADriverContextP ctx, VAConfigID config_id)
594 struct i965_driver_data *i965 = i965_driver_data(ctx);
595 struct object_config *obj_config = CONFIG(config_id);
598 if (NULL == obj_config) {
599 vaStatus = VA_STATUS_ERROR_INVALID_CONFIG;
603 i965_destroy_config(&i965->config_heap, (struct object_base *)obj_config);
604 return VA_STATUS_SUCCESS;
607 VAStatus i965_QueryConfigAttributes(VADriverContextP ctx,
608 VAConfigID config_id,
609 VAProfile *profile, /* out */
610 VAEntrypoint *entrypoint, /* out */
611 VAConfigAttrib *attrib_list, /* out */
612 int *num_attribs) /* out */
614 struct i965_driver_data *i965 = i965_driver_data(ctx);
615 struct object_config *obj_config = CONFIG(config_id);
616 VAStatus vaStatus = VA_STATUS_SUCCESS;
620 *profile = obj_config->profile;
621 *entrypoint = obj_config->entrypoint;
622 *num_attribs = obj_config->num_attribs;
624 for(i = 0; i < obj_config->num_attribs; i++) {
625 attrib_list[i] = obj_config->attrib_list[i];
632 i965_destroy_surface(struct object_heap *heap, struct object_base *obj)
634 struct object_surface *obj_surface = (struct object_surface *)obj;
636 dri_bo_unreference(obj_surface->bo);
637 obj_surface->bo = NULL;
639 if (obj_surface->free_private_data != NULL) {
640 obj_surface->free_private_data(&obj_surface->private_data);
641 obj_surface->private_data = NULL;
644 object_heap_free(heap, obj);
648 i965_CreateSurfaces2(
649 VADriverContextP ctx,
653 VASurfaceID *surfaces,
654 unsigned int num_surfaces,
655 VASurfaceAttrib *attrib_list,
656 unsigned int num_attribs
659 struct i965_driver_data *i965 = i965_driver_data(ctx);
661 VAStatus vaStatus = VA_STATUS_SUCCESS;
662 int expected_fourcc = 0;
664 for (i = 0; i < num_attribs && attrib_list; i++) {
665 if ((attrib_list[i].type == VASurfaceAttribPixelFormat) &&
666 (attrib_list[i].flags & VA_SURFACE_ATTRIB_SETTABLE)) {
667 assert(attrib_list[i].value.type == VAGenericValueTypeInteger);
668 expected_fourcc = attrib_list[i].value.value.i;
673 /* support 420 & 422 & RGB32 format, 422 and RGB32 are only used
674 * for post-processing (including color conversion) */
675 if (VA_RT_FORMAT_YUV420 != format &&
676 VA_RT_FORMAT_YUV422 != format &&
677 VA_RT_FORMAT_RGB32 != format) {
678 return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
681 for (i = 0; i < num_surfaces; i++) {
682 int surfaceID = NEW_SURFACE_ID();
683 struct object_surface *obj_surface = SURFACE(surfaceID);
685 if (NULL == obj_surface) {
686 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
690 surfaces[i] = surfaceID;
691 obj_surface->status = VASurfaceReady;
692 obj_surface->orig_width = width;
693 obj_surface->orig_height = height;
695 obj_surface->subpic_render_idx = 0;
696 for(j = 0; j < I965_MAX_SUBPIC_SUM; j++){
697 obj_surface->subpic[j] = VA_INVALID_ID;
700 obj_surface->width = ALIGN(width, 16);
701 obj_surface->height = ALIGN(height, 16);
702 obj_surface->flags = SURFACE_REFERENCED;
703 obj_surface->fourcc = 0;
704 obj_surface->bo = NULL;
705 obj_surface->locked_image_id = VA_INVALID_ID;
706 obj_surface->private_data = NULL;
707 obj_surface->free_private_data = NULL;
708 obj_surface->subsampling = SUBSAMPLE_YUV420;
710 if (expected_fourcc) {
711 int tiling = HAS_TILED_SURFACE(i965);
713 if (expected_fourcc != VA_FOURCC('N', 'V', '1', '2') &&
714 expected_fourcc != VA_FOURCC('R', 'G', 'B', 'X') &&
715 expected_fourcc != VA_FOURCC('R', 'G', 'B', 'A') )
717 // todo, should we disable tiling for 422 format?
719 if (VA_RT_FORMAT_YUV420 == format) {
720 obj_surface->subsampling = SUBSAMPLE_YUV420;
722 else if (VA_RT_FORMAT_YUV422 == format) {
723 obj_surface->subsampling = SUBSAMPLE_YUV422H;
725 else if (VA_RT_FORMAT_RGB32 == format) {
726 obj_surface->subsampling = SUBSAMPLE_RGBX;
732 i965_check_alloc_surface_bo(ctx, obj_surface, tiling, expected_fourcc, obj_surface->subsampling);
737 if (VA_STATUS_SUCCESS != vaStatus) {
738 /* surfaces[i-1] was the last successful allocation */
740 struct object_surface *obj_surface = SURFACE(surfaces[i]);
742 surfaces[i] = VA_INVALID_SURFACE;
744 i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface);
752 i965_CreateSurfaces(VADriverContextP ctx,
757 VASurfaceID *surfaces) /* out */
759 return i965_CreateSurfaces2(ctx,
770 i965_DestroySurfaces(VADriverContextP ctx,
771 VASurfaceID *surface_list,
774 struct i965_driver_data *i965 = i965_driver_data(ctx);
777 for (i = num_surfaces; i--; ) {
778 struct object_surface *obj_surface = SURFACE(surface_list[i]);
781 i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface);
784 return VA_STATUS_SUCCESS;
788 i965_QueryImageFormats(VADriverContextP ctx,
789 VAImageFormat *format_list, /* out */
790 int *num_formats) /* out */
794 for (n = 0; i965_image_formats_map[n].va_format.fourcc != 0; n++) {
795 const i965_image_format_map_t * const m = &i965_image_formats_map[n];
797 format_list[n] = m->va_format;
803 return VA_STATUS_SUCCESS;
807 * Guess the format when the usage of a VA surface is unknown
808 * 1. Without a valid context: YV12
809 * 2. The current context is valid:
810 * a) always NV12 on GEN6 and later
811 * b) I420 for MPEG-2 and NV12 for other codec on GEN4 & GEN5
814 i965_guess_surface_format(VADriverContextP ctx,
816 unsigned int *fourcc,
817 unsigned int *is_tiled)
819 struct i965_driver_data *i965 = i965_driver_data(ctx);
820 struct object_context *obj_context = NULL;
821 struct object_config *obj_config = NULL;
823 *fourcc = VA_FOURCC('Y', 'V', '1', '2');
826 if (i965->current_context_id == VA_INVALID_ID)
829 obj_context = CONTEXT(i965->current_context_id);
831 if (!obj_context || obj_context->config_id == VA_INVALID_ID)
834 obj_config = CONFIG(obj_context->config_id);
839 if (IS_GEN6(i965->intel.device_id) || IS_GEN7(i965->intel.device_id)) {
840 *fourcc = VA_FOURCC('N', 'V', '1', '2');
845 switch (obj_config->profile) {
846 case VAProfileMPEG2Simple:
847 case VAProfileMPEG2Main:
848 *fourcc = VA_FOURCC('I', '4', '2', '0');
853 *fourcc = VA_FOURCC('N', 'V', '1', '2');
860 i965_QuerySubpictureFormats(VADriverContextP ctx,
861 VAImageFormat *format_list, /* out */
862 unsigned int *flags, /* out */
863 unsigned int *num_formats) /* out */
867 for (n = 0; i965_subpic_formats_map[n].va_format.fourcc != 0; n++) {
868 const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[n];
870 format_list[n] = m->va_format;
872 flags[n] = m->va_flags;
878 return VA_STATUS_SUCCESS;
882 i965_destroy_subpic(struct object_heap *heap, struct object_base *obj)
884 // struct object_subpic *obj_subpic = (struct object_subpic *)obj;
886 object_heap_free(heap, obj);
890 i965_CreateSubpicture(VADriverContextP ctx,
892 VASubpictureID *subpicture) /* out */
894 struct i965_driver_data *i965 = i965_driver_data(ctx);
895 VASubpictureID subpicID = NEW_SUBPIC_ID()
896 struct object_subpic *obj_subpic = SUBPIC(subpicID);
899 return VA_STATUS_ERROR_ALLOCATION_FAILED;
901 struct object_image *obj_image = IMAGE(image);
903 return VA_STATUS_ERROR_INVALID_IMAGE;
905 const i965_subpic_format_map_t * const m = get_subpic_format(&obj_image->image.format);
907 return VA_STATUS_ERROR_UNKNOWN; /* XXX: VA_STATUS_ERROR_UNSUPPORTED_FORMAT? */
909 *subpicture = subpicID;
910 obj_subpic->image = image;
911 obj_subpic->format = m->format;
912 obj_subpic->width = obj_image->image.width;
913 obj_subpic->height = obj_image->image.height;
914 obj_subpic->pitch = obj_image->image.pitches[0];
915 obj_subpic->bo = obj_image->bo;
916 obj_subpic->global_alpha = 1.0;
918 return VA_STATUS_SUCCESS;
922 i965_DestroySubpicture(VADriverContextP ctx,
923 VASubpictureID subpicture)
925 struct i965_driver_data *i965 = i965_driver_data(ctx);
926 struct object_subpic *obj_subpic = SUBPIC(subpicture);
927 i965_destroy_subpic(&i965->subpic_heap, (struct object_base *)obj_subpic);
928 return VA_STATUS_SUCCESS;
932 i965_SetSubpictureImage(VADriverContextP ctx,
933 VASubpictureID subpicture,
937 return VA_STATUS_ERROR_UNIMPLEMENTED;
941 i965_SetSubpictureChromakey(VADriverContextP ctx,
942 VASubpictureID subpicture,
943 unsigned int chromakey_min,
944 unsigned int chromakey_max,
945 unsigned int chromakey_mask)
948 return VA_STATUS_ERROR_UNIMPLEMENTED;
952 i965_SetSubpictureGlobalAlpha(VADriverContextP ctx,
953 VASubpictureID subpicture,
956 struct i965_driver_data *i965 = i965_driver_data(ctx);
957 struct object_subpic *obj_subpic = SUBPIC(subpicture);
959 if(global_alpha > 1.0 || global_alpha < 0.0){
960 return VA_STATUS_ERROR_INVALID_PARAMETER;
962 obj_subpic->global_alpha = global_alpha;
964 return VA_STATUS_SUCCESS;
968 i965_AssociateSubpicture(VADriverContextP ctx,
969 VASubpictureID subpicture,
970 VASurfaceID *target_surfaces,
972 short src_x, /* upper left offset in subpicture */
974 unsigned short src_width,
975 unsigned short src_height,
976 short dest_x, /* upper left offset in surface */
978 unsigned short dest_width,
979 unsigned short dest_height,
981 * whether to enable chroma-keying or global-alpha
982 * see VA_SUBPICTURE_XXX values
986 struct i965_driver_data *i965 = i965_driver_data(ctx);
987 struct object_subpic *obj_subpic = SUBPIC(subpicture);
990 obj_subpic->src_rect.x = src_x;
991 obj_subpic->src_rect.y = src_y;
992 obj_subpic->src_rect.width = src_width;
993 obj_subpic->src_rect.height = src_height;
994 obj_subpic->dst_rect.x = dest_x;
995 obj_subpic->dst_rect.y = dest_y;
996 obj_subpic->dst_rect.width = dest_width;
997 obj_subpic->dst_rect.height = dest_height;
998 obj_subpic->flags = flags;
1000 for (i = 0; i < num_surfaces; i++) {
1001 struct object_surface *obj_surface = SURFACE(target_surfaces[i]);
1003 return VA_STATUS_ERROR_INVALID_SURFACE;
1005 for(j = 0; j < I965_MAX_SUBPIC_SUM; j ++){
1006 if(obj_surface->subpic[j] == VA_INVALID_ID){
1007 obj_surface->subpic[j] = subpicture;
1012 if(j == I965_MAX_SUBPIC_SUM){
1013 return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
1017 return VA_STATUS_SUCCESS;
1022 i965_DeassociateSubpicture(VADriverContextP ctx,
1023 VASubpictureID subpicture,
1024 VASurfaceID *target_surfaces,
1027 struct i965_driver_data *i965 = i965_driver_data(ctx);
1030 for (i = 0; i < num_surfaces; i++) {
1031 struct object_surface *obj_surface = SURFACE(target_surfaces[i]);
1033 return VA_STATUS_ERROR_INVALID_SURFACE;
1035 for(j = 0; j < I965_MAX_SUBPIC_SUM; j ++){
1036 if(obj_surface->subpic[j] == subpicture){
1037 obj_surface->subpic[j] = VA_INVALID_ID;
1042 if(j == I965_MAX_SUBPIC_SUM){
1043 return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
1046 return VA_STATUS_SUCCESS;
1050 i965_reference_buffer_store(struct buffer_store **ptr,
1051 struct buffer_store *buffer_store)
1053 assert(*ptr == NULL);
1056 buffer_store->ref_count++;
1057 *ptr = buffer_store;
1062 i965_release_buffer_store(struct buffer_store **ptr)
1064 struct buffer_store *buffer_store = *ptr;
1066 if (buffer_store == NULL)
1069 assert(buffer_store->bo || buffer_store->buffer);
1070 assert(!(buffer_store->bo && buffer_store->buffer));
1071 buffer_store->ref_count--;
1073 if (buffer_store->ref_count == 0) {
1074 dri_bo_unreference(buffer_store->bo);
1075 free(buffer_store->buffer);
1076 buffer_store->bo = NULL;
1077 buffer_store->buffer = NULL;
1085 i965_destroy_context(struct object_heap *heap, struct object_base *obj)
1087 struct object_context *obj_context = (struct object_context *)obj;
1090 if (obj_context->hw_context) {
1091 obj_context->hw_context->destroy(obj_context->hw_context);
1092 obj_context->hw_context = NULL;
1095 if (obj_context->codec_type == CODEC_PROC) {
1096 i965_release_buffer_store(&obj_context->codec_state.proc.pipeline_param);
1098 } else if (obj_context->codec_type == CODEC_ENC) {
1099 assert(obj_context->codec_state.encode.num_slice_params <= obj_context->codec_state.encode.max_slice_params);
1100 i965_release_buffer_store(&obj_context->codec_state.encode.pic_param);
1101 i965_release_buffer_store(&obj_context->codec_state.encode.seq_param);
1103 for (i = 0; i < obj_context->codec_state.encode.num_slice_params; i++)
1104 i965_release_buffer_store(&obj_context->codec_state.encode.slice_params[i]);
1106 free(obj_context->codec_state.encode.slice_params);
1108 assert(obj_context->codec_state.encode.num_slice_params_ext <= obj_context->codec_state.encode.max_slice_params_ext);
1109 i965_release_buffer_store(&obj_context->codec_state.encode.pic_param_ext);
1110 i965_release_buffer_store(&obj_context->codec_state.encode.seq_param_ext);
1112 for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.packed_header_param); i++)
1113 i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_param[i]);
1115 for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.packed_header_data); i++)
1116 i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_data[i]);
1118 for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.misc_param); i++)
1119 i965_release_buffer_store(&obj_context->codec_state.encode.misc_param[i]);
1121 for (i = 0; i < obj_context->codec_state.encode.num_slice_params_ext; i++)
1122 i965_release_buffer_store(&obj_context->codec_state.encode.slice_params_ext[i]);
1124 free(obj_context->codec_state.encode.slice_params_ext);
1126 assert(obj_context->codec_state.decode.num_slice_params <= obj_context->codec_state.decode.max_slice_params);
1127 assert(obj_context->codec_state.decode.num_slice_datas <= obj_context->codec_state.decode.max_slice_datas);
1129 i965_release_buffer_store(&obj_context->codec_state.decode.pic_param);
1130 i965_release_buffer_store(&obj_context->codec_state.decode.iq_matrix);
1131 i965_release_buffer_store(&obj_context->codec_state.decode.bit_plane);
1133 for (i = 0; i < obj_context->codec_state.decode.num_slice_params; i++)
1134 i965_release_buffer_store(&obj_context->codec_state.decode.slice_params[i]);
1136 for (i = 0; i < obj_context->codec_state.decode.num_slice_datas; i++)
1137 i965_release_buffer_store(&obj_context->codec_state.decode.slice_datas[i]);
1139 free(obj_context->codec_state.decode.slice_params);
1140 free(obj_context->codec_state.decode.slice_datas);
1143 free(obj_context->render_targets);
1144 object_heap_free(heap, obj);
1148 i965_CreateContext(VADriverContextP ctx,
1149 VAConfigID config_id,
1153 VASurfaceID *render_targets,
1154 int num_render_targets,
1155 VAContextID *context) /* out */
1157 struct i965_driver_data *i965 = i965_driver_data(ctx);
1158 struct i965_render_state *render_state = &i965->render_state;
1159 struct object_config *obj_config = CONFIG(config_id);
1160 struct object_context *obj_context = NULL;
1161 VAStatus vaStatus = VA_STATUS_SUCCESS;
1165 if (NULL == obj_config) {
1166 vaStatus = VA_STATUS_ERROR_INVALID_CONFIG;
1170 if (picture_width > i965->codec_info->max_width ||
1171 picture_height > i965->codec_info->max_height) {
1172 vaStatus = VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED;
1177 /* Validate picture dimensions */
1178 contextID = NEW_CONTEXT_ID();
1179 obj_context = CONTEXT(contextID);
1181 if (NULL == obj_context) {
1182 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
1186 render_state->inited = 1;
1188 switch (obj_config->profile) {
1189 case VAProfileH264Baseline:
1190 case VAProfileH264Main:
1191 case VAProfileH264High:
1192 if (!HAS_H264_DECODING(i965) &&
1193 !HAS_H264_ENCODING(i965))
1194 return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
1195 render_state->interleaved_uv = 1;
1198 render_state->interleaved_uv = !!(IS_GEN6(i965->intel.device_id) || IS_GEN7(i965->intel.device_id));
1202 *context = contextID;
1203 obj_context->flags = flag;
1204 obj_context->context_id = contextID;
1205 obj_context->config_id = config_id;
1206 obj_context->picture_width = picture_width;
1207 obj_context->picture_height = picture_height;
1208 obj_context->num_render_targets = num_render_targets;
1209 obj_context->render_targets =
1210 (VASurfaceID *)calloc(num_render_targets, sizeof(VASurfaceID));
1211 obj_context->hw_context = NULL;
1213 for(i = 0; i < num_render_targets; i++) {
1214 if (NULL == SURFACE(render_targets[i])) {
1215 vaStatus = VA_STATUS_ERROR_INVALID_SURFACE;
1219 obj_context->render_targets[i] = render_targets[i];
1222 if (VA_STATUS_SUCCESS == vaStatus) {
1223 if (VAEntrypointVideoProc == obj_config->entrypoint) {
1224 obj_context->codec_type = CODEC_PROC;
1225 memset(&obj_context->codec_state.proc, 0, sizeof(obj_context->codec_state.proc));
1226 obj_context->codec_state.proc.current_render_target = VA_INVALID_ID;
1227 assert(i965->codec_info->proc_hw_context_init);
1228 obj_context->hw_context = i965->codec_info->proc_hw_context_init(ctx, obj_config);
1229 } else if (VAEntrypointEncSlice == obj_config->entrypoint) { /*encode routin only*/
1230 obj_context->codec_type = CODEC_ENC;
1231 memset(&obj_context->codec_state.encode, 0, sizeof(obj_context->codec_state.encode));
1232 obj_context->codec_state.encode.current_render_target = VA_INVALID_ID;
1233 obj_context->codec_state.encode.max_slice_params = NUM_SLICES;
1234 obj_context->codec_state.encode.slice_params = calloc(obj_context->codec_state.encode.max_slice_params,
1235 sizeof(*obj_context->codec_state.encode.slice_params));
1236 assert(i965->codec_info->enc_hw_context_init);
1237 obj_context->hw_context = i965->codec_info->enc_hw_context_init(ctx, obj_config);
1239 obj_context->codec_type = CODEC_DEC;
1240 memset(&obj_context->codec_state.decode, 0, sizeof(obj_context->codec_state.decode));
1241 obj_context->codec_state.decode.current_render_target = -1;
1242 obj_context->codec_state.decode.max_slice_params = NUM_SLICES;
1243 obj_context->codec_state.decode.max_slice_datas = NUM_SLICES;
1244 obj_context->codec_state.decode.slice_params = calloc(obj_context->codec_state.decode.max_slice_params,
1245 sizeof(*obj_context->codec_state.decode.slice_params));
1246 obj_context->codec_state.decode.slice_datas = calloc(obj_context->codec_state.decode.max_slice_datas,
1247 sizeof(*obj_context->codec_state.decode.slice_datas));
1249 assert(i965->codec_info->dec_hw_context_init);
1250 obj_context->hw_context = i965->codec_info->dec_hw_context_init(ctx, obj_config);
1254 /* Error recovery */
1255 if (VA_STATUS_SUCCESS != vaStatus) {
1256 i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context);
1259 i965->current_context_id = contextID;
1265 i965_DestroyContext(VADriverContextP ctx, VAContextID context)
1267 struct i965_driver_data *i965 = i965_driver_data(ctx);
1268 struct object_context *obj_context = CONTEXT(context);
1270 assert(obj_context);
1272 if (i965->current_context_id == context)
1273 i965->current_context_id = VA_INVALID_ID;
1275 i965_destroy_context(&i965->context_heap, (struct object_base *)obj_context);
1277 return VA_STATUS_SUCCESS;
1281 i965_destroy_buffer(struct object_heap *heap, struct object_base *obj)
1283 struct object_buffer *obj_buffer = (struct object_buffer *)obj;
1285 assert(obj_buffer->buffer_store);
1286 i965_release_buffer_store(&obj_buffer->buffer_store);
1287 object_heap_free(heap, obj);
1291 i965_create_buffer_internal(VADriverContextP ctx,
1292 VAContextID context,
1295 unsigned int num_elements,
1300 struct i965_driver_data *i965 = i965_driver_data(ctx);
1301 struct object_buffer *obj_buffer = NULL;
1302 struct buffer_store *buffer_store = NULL;
1307 case VAPictureParameterBufferType:
1308 case VAIQMatrixBufferType:
1309 case VAQMatrixBufferType:
1310 case VABitPlaneBufferType:
1311 case VASliceGroupMapBufferType:
1312 case VASliceParameterBufferType:
1313 case VASliceDataBufferType:
1314 case VAMacroblockParameterBufferType:
1315 case VAResidualDataBufferType:
1316 case VADeblockingParameterBufferType:
1317 case VAImageBufferType:
1318 case VAEncCodedBufferType:
1319 case VAEncSequenceParameterBufferType:
1320 case VAEncPictureParameterBufferType:
1321 case VAEncSliceParameterBufferType:
1322 case VAEncPackedHeaderParameterBufferType:
1323 case VAEncPackedHeaderDataBufferType:
1324 case VAEncMiscParameterBufferType:
1325 case VAProcPipelineParameterBufferType:
1326 case VAProcFilterParameterBufferType:
1327 case VAHuffmanTableBufferType:
1332 return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
1335 bufferID = NEW_BUFFER_ID();
1336 obj_buffer = BUFFER(bufferID);
1338 if (NULL == obj_buffer) {
1339 return VA_STATUS_ERROR_ALLOCATION_FAILED;
1342 if (type == VAEncCodedBufferType) {
1343 size += I965_CODEDBUFFER_HEADER_SIZE;
1344 size += 0x1000; /* for upper bound check */
1347 obj_buffer->max_num_elements = num_elements;
1348 obj_buffer->num_elements = num_elements;
1349 obj_buffer->size_element = size;
1350 obj_buffer->type = type;
1351 obj_buffer->buffer_store = NULL;
1352 buffer_store = calloc(1, sizeof(struct buffer_store));
1353 assert(buffer_store);
1354 buffer_store->ref_count = 1;
1356 if (store_bo != NULL) {
1357 buffer_store->bo = store_bo;
1358 dri_bo_reference(buffer_store->bo);
1361 dri_bo_subdata(buffer_store->bo, 0, size * num_elements, data);
1362 } else if (type == VASliceDataBufferType ||
1363 type == VAImageBufferType ||
1364 type == VAEncCodedBufferType) {
1365 buffer_store->bo = dri_bo_alloc(i965->intel.bufmgr,
1367 size * num_elements, 64);
1368 assert(buffer_store->bo);
1370 if (type == VAEncCodedBufferType) {
1371 struct i965_coded_buffer_segment *coded_buffer_segment;
1373 dri_bo_map(buffer_store->bo, 1);
1374 coded_buffer_segment = (struct i965_coded_buffer_segment *)buffer_store->bo->virtual;
1375 coded_buffer_segment->base.size = size - I965_CODEDBUFFER_HEADER_SIZE;
1376 coded_buffer_segment->base.bit_offset = 0;
1377 coded_buffer_segment->base.status = 0;
1378 coded_buffer_segment->base.buf = NULL;
1379 coded_buffer_segment->base.next = NULL;
1380 coded_buffer_segment->mapped = 0;
1381 coded_buffer_segment->codec = 0;
1382 dri_bo_unmap(buffer_store->bo);
1384 dri_bo_subdata(buffer_store->bo, 0, size * num_elements, data);
1390 if (type == VAEncPackedHeaderDataBufferType) {
1391 msize = ALIGN(size, 4);
1394 buffer_store->buffer = malloc(msize * num_elements);
1395 assert(buffer_store->buffer);
1398 memcpy(buffer_store->buffer, data, size * num_elements);
1401 buffer_store->num_elements = obj_buffer->num_elements;
1402 i965_reference_buffer_store(&obj_buffer->buffer_store, buffer_store);
1403 i965_release_buffer_store(&buffer_store);
1406 return VA_STATUS_SUCCESS;
1410 i965_CreateBuffer(VADriverContextP ctx,
1411 VAContextID context, /* in */
1412 VABufferType type, /* in */
1413 unsigned int size, /* in */
1414 unsigned int num_elements, /* in */
1415 void *data, /* in */
1416 VABufferID *buf_id) /* out */
1418 return i965_create_buffer_internal(ctx, context, type, size, num_elements, data, NULL, buf_id);
1423 i965_BufferSetNumElements(VADriverContextP ctx,
1424 VABufferID buf_id, /* in */
1425 unsigned int num_elements) /* in */
1427 struct i965_driver_data *i965 = i965_driver_data(ctx);
1428 struct object_buffer *obj_buffer = BUFFER(buf_id);
1429 VAStatus vaStatus = VA_STATUS_SUCCESS;
1433 if ((num_elements < 0) ||
1434 (num_elements > obj_buffer->max_num_elements)) {
1435 vaStatus = VA_STATUS_ERROR_UNKNOWN;
1437 obj_buffer->num_elements = num_elements;
1438 if (obj_buffer->buffer_store != NULL) {
1439 obj_buffer->buffer_store->num_elements = num_elements;
1447 i965_MapBuffer(VADriverContextP ctx,
1448 VABufferID buf_id, /* in */
1449 void **pbuf) /* out */
1451 struct i965_driver_data *i965 = i965_driver_data(ctx);
1452 struct object_buffer *obj_buffer = BUFFER(buf_id);
1453 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
1455 assert(obj_buffer && obj_buffer->buffer_store);
1456 assert(obj_buffer->buffer_store->bo || obj_buffer->buffer_store->buffer);
1457 assert(!(obj_buffer->buffer_store->bo && obj_buffer->buffer_store->buffer));
1459 if (NULL != obj_buffer->buffer_store->bo) {
1460 unsigned int tiling, swizzle;
1462 dri_bo_get_tiling(obj_buffer->buffer_store->bo, &tiling, &swizzle);
1464 if (tiling != I915_TILING_NONE)
1465 drm_intel_gem_bo_map_gtt(obj_buffer->buffer_store->bo);
1467 dri_bo_map(obj_buffer->buffer_store->bo, 1);
1469 assert(obj_buffer->buffer_store->bo->virtual);
1470 *pbuf = obj_buffer->buffer_store->bo->virtual;
1472 if (obj_buffer->type == VAEncCodedBufferType) {
1474 unsigned char *buffer = NULL;
1475 struct i965_coded_buffer_segment *coded_buffer_segment = (struct i965_coded_buffer_segment *)(obj_buffer->buffer_store->bo->virtual);
1477 if (!coded_buffer_segment->mapped) {
1478 unsigned char delimiter0, delimiter1, delimiter2, delimiter3, delimiter4;
1480 coded_buffer_segment->base.buf = buffer = (unsigned char *)(obj_buffer->buffer_store->bo->virtual) + I965_CODEDBUFFER_HEADER_SIZE;
1482 if (coded_buffer_segment->codec == CODED_H264) {
1483 delimiter0 = H264_DELIMITER0;
1484 delimiter1 = H264_DELIMITER1;
1485 delimiter2 = H264_DELIMITER2;
1486 delimiter3 = H264_DELIMITER3;
1487 delimiter4 = H264_DELIMITER4;
1488 } else if (coded_buffer_segment->codec == CODED_MPEG2) {
1489 delimiter0 = MPEG2_DELIMITER0;
1490 delimiter1 = MPEG2_DELIMITER1;
1491 delimiter2 = MPEG2_DELIMITER2;
1492 delimiter3 = MPEG2_DELIMITER3;
1493 delimiter4 = MPEG2_DELIMITER4;
1498 for (i = 0; i < obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000; i++) {
1499 if ((buffer[i] == delimiter0) &&
1500 (buffer[i + 1] == delimiter1) &&
1501 (buffer[i + 2] == delimiter2) &&
1502 (buffer[i + 3] == delimiter3) &&
1503 (buffer[i + 4] == delimiter4))
1507 if (i == obj_buffer->size_element - I965_CODEDBUFFER_HEADER_SIZE - 3 - 0x1000) {
1508 coded_buffer_segment->base.status |= VA_CODED_BUF_STATUS_SLICE_OVERFLOW_MASK;
1511 coded_buffer_segment->base.size = i;
1512 coded_buffer_segment->mapped = 1;
1514 assert(coded_buffer_segment->base.buf);
1518 vaStatus = VA_STATUS_SUCCESS;
1519 } else if (NULL != obj_buffer->buffer_store->buffer) {
1520 *pbuf = obj_buffer->buffer_store->buffer;
1521 vaStatus = VA_STATUS_SUCCESS;
1528 i965_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id)
1530 struct i965_driver_data *i965 = i965_driver_data(ctx);
1531 struct object_buffer *obj_buffer = BUFFER(buf_id);
1532 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
1534 assert(obj_buffer && obj_buffer->buffer_store);
1535 assert(obj_buffer->buffer_store->bo || obj_buffer->buffer_store->buffer);
1536 assert(!(obj_buffer->buffer_store->bo && obj_buffer->buffer_store->buffer));
1538 if (NULL != obj_buffer->buffer_store->bo) {
1539 unsigned int tiling, swizzle;
1541 dri_bo_get_tiling(obj_buffer->buffer_store->bo, &tiling, &swizzle);
1543 if (tiling != I915_TILING_NONE)
1544 drm_intel_gem_bo_unmap_gtt(obj_buffer->buffer_store->bo);
1546 dri_bo_unmap(obj_buffer->buffer_store->bo);
1548 vaStatus = VA_STATUS_SUCCESS;
1549 } else if (NULL != obj_buffer->buffer_store->buffer) {
1551 vaStatus = VA_STATUS_SUCCESS;
1558 i965_DestroyBuffer(VADriverContextP ctx, VABufferID buffer_id)
1560 struct i965_driver_data *i965 = i965_driver_data(ctx);
1561 struct object_buffer *obj_buffer = BUFFER(buffer_id);
1564 i965_destroy_buffer(&i965->buffer_heap, (struct object_base *)obj_buffer);
1566 return VA_STATUS_SUCCESS;
1570 i965_BeginPicture(VADriverContextP ctx,
1571 VAContextID context,
1572 VASurfaceID render_target)
1574 struct i965_driver_data *i965 = i965_driver_data(ctx);
1575 struct object_context *obj_context = CONTEXT(context);
1576 struct object_surface *obj_surface = SURFACE(render_target);
1577 struct object_config *obj_config;
1582 assert(obj_context);
1583 assert(obj_surface);
1585 config = obj_context->config_id;
1586 obj_config = CONFIG(config);
1589 switch (obj_config->profile) {
1590 case VAProfileMPEG2Simple:
1591 case VAProfileMPEG2Main:
1592 vaStatus = VA_STATUS_SUCCESS;
1595 case VAProfileH264Baseline:
1596 case VAProfileH264Main:
1597 case VAProfileH264High:
1598 vaStatus = VA_STATUS_SUCCESS;
1601 case VAProfileVC1Simple:
1602 case VAProfileVC1Main:
1603 case VAProfileVC1Advanced:
1604 vaStatus = VA_STATUS_SUCCESS;
1607 case VAProfileJPEGBaseline:
1608 vaStatus = VA_STATUS_SUCCESS;
1612 vaStatus = VA_STATUS_SUCCESS;
1617 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
1621 if (obj_context->codec_type == CODEC_PROC) {
1622 obj_context->codec_state.proc.current_render_target = render_target;
1623 } else if (obj_context->codec_type == CODEC_ENC) {
1624 i965_release_buffer_store(&obj_context->codec_state.encode.pic_param);
1626 for (i = 0; i < obj_context->codec_state.encode.num_slice_params; i++) {
1627 i965_release_buffer_store(&obj_context->codec_state.encode.slice_params[i]);
1630 obj_context->codec_state.encode.num_slice_params = 0;
1633 i965_release_buffer_store(&obj_context->codec_state.encode.pic_param_ext);
1635 for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.packed_header_param); i++)
1636 i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_param[i]);
1638 for (i = 0; i < ARRAY_ELEMS(obj_context->codec_state.encode.packed_header_data); i++)
1639 i965_release_buffer_store(&obj_context->codec_state.encode.packed_header_data[i]);
1641 for (i = 0; i < obj_context->codec_state.encode.num_slice_params_ext; i++)
1642 i965_release_buffer_store(&obj_context->codec_state.encode.slice_params_ext[i]);
1644 obj_context->codec_state.encode.num_slice_params_ext = 0;
1645 obj_context->codec_state.encode.current_render_target = render_target; /*This is input new frame*/
1646 obj_context->codec_state.encode.last_packed_header_type = 0;
1648 obj_context->codec_state.decode.current_render_target = render_target;
1649 i965_release_buffer_store(&obj_context->codec_state.decode.pic_param);
1650 i965_release_buffer_store(&obj_context->codec_state.decode.iq_matrix);
1651 i965_release_buffer_store(&obj_context->codec_state.decode.bit_plane);
1652 i965_release_buffer_store(&obj_context->codec_state.decode.huffman_table);
1654 for (i = 0; i < obj_context->codec_state.decode.num_slice_params; i++) {
1655 i965_release_buffer_store(&obj_context->codec_state.decode.slice_params[i]);
1656 i965_release_buffer_store(&obj_context->codec_state.decode.slice_datas[i]);
1659 obj_context->codec_state.decode.num_slice_params = 0;
1660 obj_context->codec_state.decode.num_slice_datas = 0;
1666 #define I965_RENDER_BUFFER(category, name) i965_render_##category##_##name##_buffer(ctx, obj_context, obj_buffer)
1668 #define DEF_RENDER_SINGLE_BUFFER_FUNC(category, name, member) \
1670 i965_render_##category##_##name##_buffer(VADriverContextP ctx, \
1671 struct object_context *obj_context, \
1672 struct object_buffer *obj_buffer) \
1674 struct category##_state *category = &obj_context->codec_state.category; \
1675 assert(obj_buffer->buffer_store->bo == NULL); \
1676 assert(obj_buffer->buffer_store->buffer); \
1677 i965_release_buffer_store(&category->member); \
1678 i965_reference_buffer_store(&category->member, obj_buffer->buffer_store); \
1679 return VA_STATUS_SUCCESS; \
1682 #define DEF_RENDER_MULTI_BUFFER_FUNC(category, name, member) \
1684 i965_render_##category##_##name##_buffer(VADriverContextP ctx, \
1685 struct object_context *obj_context, \
1686 struct object_buffer *obj_buffer) \
1688 struct category##_state *category = &obj_context->codec_state.category; \
1689 if (category->num_##member == category->max_##member) { \
1690 category->member = realloc(category->member, (category->max_##member + NUM_SLICES) * sizeof(*category->member)); \
1691 memset(category->member + category->max_##member, 0, NUM_SLICES * sizeof(*category->member)); \
1692 category->max_##member += NUM_SLICES; \
1694 i965_release_buffer_store(&category->member[category->num_##member]); \
1695 i965_reference_buffer_store(&category->member[category->num_##member], obj_buffer->buffer_store); \
1696 category->num_##member++; \
1697 return VA_STATUS_SUCCESS; \
1700 #define I965_RENDER_DECODE_BUFFER(name) I965_RENDER_BUFFER(decode, name)
1702 #define DEF_RENDER_DECODE_SINGLE_BUFFER_FUNC(name, member) DEF_RENDER_SINGLE_BUFFER_FUNC(decode, name, member)
1703 DEF_RENDER_DECODE_SINGLE_BUFFER_FUNC(picture_parameter, pic_param)
1704 DEF_RENDER_DECODE_SINGLE_BUFFER_FUNC(iq_matrix, iq_matrix)
1705 DEF_RENDER_DECODE_SINGLE_BUFFER_FUNC(bit_plane, bit_plane)
1706 DEF_RENDER_DECODE_SINGLE_BUFFER_FUNC(huffman_table, huffman_table)
1708 #define DEF_RENDER_DECODE_MULTI_BUFFER_FUNC(name, member) DEF_RENDER_MULTI_BUFFER_FUNC(decode, name, member)
1709 DEF_RENDER_DECODE_MULTI_BUFFER_FUNC(slice_parameter, slice_params)
1710 DEF_RENDER_DECODE_MULTI_BUFFER_FUNC(slice_data, slice_datas)
1713 i965_decoder_render_picture(VADriverContextP ctx,
1714 VAContextID context,
1715 VABufferID *buffers,
1718 struct i965_driver_data *i965 = i965_driver_data(ctx);
1719 struct object_context *obj_context = CONTEXT(context);
1720 VAStatus vaStatus = VA_STATUS_SUCCESS;
1723 for (i = 0; i < num_buffers && vaStatus == VA_STATUS_SUCCESS; i++) {
1724 struct object_buffer *obj_buffer = BUFFER(buffers[i]);
1727 switch (obj_buffer->type) {
1728 case VAPictureParameterBufferType:
1729 vaStatus = I965_RENDER_DECODE_BUFFER(picture_parameter);
1732 case VAIQMatrixBufferType:
1733 vaStatus = I965_RENDER_DECODE_BUFFER(iq_matrix);
1736 case VABitPlaneBufferType:
1737 vaStatus = I965_RENDER_DECODE_BUFFER(bit_plane);
1740 case VASliceParameterBufferType:
1741 vaStatus = I965_RENDER_DECODE_BUFFER(slice_parameter);
1744 case VASliceDataBufferType:
1745 vaStatus = I965_RENDER_DECODE_BUFFER(slice_data);
1748 case VAHuffmanTableBufferType:
1749 vaStatus = I965_RENDER_DECODE_BUFFER(huffman_table);
1753 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
1761 #define I965_RENDER_ENCODE_BUFFER(name) I965_RENDER_BUFFER(encode, name)
1763 #define DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(name, member) DEF_RENDER_SINGLE_BUFFER_FUNC(encode, name, member)
1764 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(sequence_parameter, seq_param)
1765 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(picture_parameter, pic_param)
1766 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(picture_control, pic_control)
1767 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(qmatrix, q_matrix)
1768 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(iqmatrix, iq_matrix)
1769 /* extended buffer */
1770 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(sequence_parameter_ext, seq_param_ext)
1771 DEF_RENDER_ENCODE_SINGLE_BUFFER_FUNC(picture_parameter_ext, pic_param_ext)
1773 #define DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(name, member) DEF_RENDER_MULTI_BUFFER_FUNC(encode, name, member)
1774 DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(slice_parameter, slice_params)
1775 DEF_RENDER_ENCODE_MULTI_BUFFER_FUNC(slice_parameter_ext, slice_params_ext)
1778 i965_encoder_render_packed_header_parameter_buffer(VADriverContextP ctx,
1779 struct object_context *obj_context,
1780 struct object_buffer *obj_buffer,
1783 struct encode_state *encode = &obj_context->codec_state.encode;
1785 assert(obj_buffer->buffer_store->bo == NULL);
1786 assert(obj_buffer->buffer_store->buffer);
1787 i965_release_buffer_store(&encode->packed_header_param[type_index]);
1788 i965_reference_buffer_store(&encode->packed_header_param[type_index], obj_buffer->buffer_store);
1790 return VA_STATUS_SUCCESS;
1794 i965_encoder_render_packed_header_data_buffer(VADriverContextP ctx,
1795 struct object_context *obj_context,
1796 struct object_buffer *obj_buffer,
1799 struct encode_state *encode = &obj_context->codec_state.encode;
1801 assert(obj_buffer->buffer_store->bo == NULL);
1802 assert(obj_buffer->buffer_store->buffer);
1803 i965_release_buffer_store(&encode->packed_header_data[type_index]);
1804 i965_reference_buffer_store(&encode->packed_header_data[type_index], obj_buffer->buffer_store);
1806 return VA_STATUS_SUCCESS;
1810 i965_encoder_render_misc_parameter_buffer(VADriverContextP ctx,
1811 struct object_context *obj_context,
1812 struct object_buffer *obj_buffer)
1814 struct encode_state *encode = &obj_context->codec_state.encode;
1815 VAEncMiscParameterBuffer *param = NULL;
1817 assert(obj_buffer->buffer_store->bo == NULL);
1818 assert(obj_buffer->buffer_store->buffer);
1820 param = (VAEncMiscParameterBuffer *)obj_buffer->buffer_store->buffer;
1821 i965_release_buffer_store(&encode->misc_param[param->type]);
1822 i965_reference_buffer_store(&encode->misc_param[param->type], obj_buffer->buffer_store);
1824 return VA_STATUS_SUCCESS;
1828 i965_encoder_render_picture(VADriverContextP ctx,
1829 VAContextID context,
1830 VABufferID *buffers,
1833 struct i965_driver_data *i965 = i965_driver_data(ctx);
1834 struct object_context *obj_context = CONTEXT(context);
1835 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
1838 for (i = 0; i < num_buffers; i++) {
1839 struct object_buffer *obj_buffer = BUFFER(buffers[i]);
1842 switch (obj_buffer->type) {
1843 case VAQMatrixBufferType:
1844 vaStatus = I965_RENDER_ENCODE_BUFFER(qmatrix);
1847 case VAIQMatrixBufferType:
1848 vaStatus = I965_RENDER_ENCODE_BUFFER(iqmatrix);
1851 case VAEncSequenceParameterBufferType:
1852 vaStatus = I965_RENDER_ENCODE_BUFFER(sequence_parameter_ext);
1855 case VAEncPictureParameterBufferType:
1856 vaStatus = I965_RENDER_ENCODE_BUFFER(picture_parameter_ext);
1859 case VAEncSliceParameterBufferType:
1860 vaStatus = I965_RENDER_ENCODE_BUFFER(slice_parameter_ext);
1863 case VAEncPackedHeaderParameterBufferType:
1865 struct encode_state *encode = &obj_context->codec_state.encode;
1866 VAEncPackedHeaderParameterBuffer *param = (VAEncPackedHeaderParameterBuffer *)obj_buffer->buffer_store->buffer;
1867 encode->last_packed_header_type = param->type;
1869 vaStatus = i965_encoder_render_packed_header_parameter_buffer(ctx,
1872 va_enc_packed_type_to_idx(encode->last_packed_header_type));
1876 case VAEncPackedHeaderDataBufferType:
1878 struct encode_state *encode = &obj_context->codec_state.encode;
1880 assert(encode->last_packed_header_type == VAEncPackedHeaderSequence ||
1881 encode->last_packed_header_type == VAEncPackedHeaderPicture ||
1882 encode->last_packed_header_type == VAEncPackedHeaderSlice ||
1883 ((encode->last_packed_header_type & VAEncPackedHeaderMiscMask == VAEncPackedHeaderMiscMask) &&
1884 (encode->last_packed_header_type & (~VAEncPackedHeaderMiscMask) != 0)));
1885 vaStatus = i965_encoder_render_packed_header_data_buffer(ctx,
1888 va_enc_packed_type_to_idx(encode->last_packed_header_type));
1892 case VAEncMiscParameterBufferType:
1893 vaStatus = i965_encoder_render_misc_parameter_buffer(ctx,
1899 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
1907 #define I965_RENDER_PROC_BUFFER(name) I965_RENDER_BUFFER(proc, name)
1909 #define DEF_RENDER_PROC_SINGLE_BUFFER_FUNC(name, member) DEF_RENDER_SINGLE_BUFFER_FUNC(proc, name, member)
1910 DEF_RENDER_PROC_SINGLE_BUFFER_FUNC(pipeline_parameter, pipeline_param)
1913 i965_proc_render_picture(VADriverContextP ctx,
1914 VAContextID context,
1915 VABufferID *buffers,
1918 struct i965_driver_data *i965 = i965_driver_data(ctx);
1919 struct object_context *obj_context = CONTEXT(context);
1920 VAStatus vaStatus = VA_STATUS_SUCCESS;
1923 for (i = 0; i < num_buffers && vaStatus == VA_STATUS_SUCCESS; i++) {
1924 struct object_buffer *obj_buffer = BUFFER(buffers[i]);
1927 switch (obj_buffer->type) {
1928 case VAProcPipelineParameterBufferType:
1929 vaStatus = I965_RENDER_PROC_BUFFER(pipeline_parameter);
1933 vaStatus = VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
1942 i965_RenderPicture(VADriverContextP ctx,
1943 VAContextID context,
1944 VABufferID *buffers,
1947 struct i965_driver_data *i965 = i965_driver_data(ctx);
1948 struct object_context *obj_context;
1949 struct object_config *obj_config;
1951 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
1953 obj_context = CONTEXT(context);
1954 assert(obj_context);
1956 config = obj_context->config_id;
1957 obj_config = CONFIG(config);
1960 if (VAEntrypointVideoProc == obj_config->entrypoint) {
1961 vaStatus = i965_proc_render_picture(ctx, context, buffers, num_buffers);
1962 } else if (VAEntrypointEncSlice == obj_config->entrypoint ) {
1963 vaStatus = i965_encoder_render_picture(ctx, context, buffers, num_buffers);
1965 vaStatus = i965_decoder_render_picture(ctx, context, buffers, num_buffers);
1972 i965_EndPicture(VADriverContextP ctx, VAContextID context)
1974 struct i965_driver_data *i965 = i965_driver_data(ctx);
1975 struct object_context *obj_context = CONTEXT(context);
1976 struct object_config *obj_config;
1979 assert(obj_context);
1980 config = obj_context->config_id;
1981 obj_config = CONFIG(config);
1984 if (obj_context->codec_type == CODEC_PROC) {
1985 assert(VAEntrypointVideoProc == obj_config->entrypoint);
1986 } else if (obj_context->codec_type == CODEC_ENC) {
1987 assert(VAEntrypointEncSlice == obj_config->entrypoint);
1989 assert(obj_context->codec_state.encode.pic_param ||
1990 obj_context->codec_state.encode.pic_param_ext);
1991 assert(obj_context->codec_state.encode.seq_param ||
1992 obj_context->codec_state.encode.seq_param_ext);
1993 assert(obj_context->codec_state.encode.num_slice_params >= 1 ||
1994 obj_context->codec_state.encode.num_slice_params_ext >= 1);
1996 assert(obj_context->codec_state.decode.pic_param);
1997 assert(obj_context->codec_state.decode.num_slice_params >= 1);
1998 assert(obj_context->codec_state.decode.num_slice_datas >= 1);
1999 assert(obj_context->codec_state.decode.num_slice_params == obj_context->codec_state.decode.num_slice_datas);
2002 assert(obj_context->hw_context->run);
2003 obj_context->hw_context->run(ctx, obj_config->profile, &obj_context->codec_state, obj_context->hw_context);
2005 return VA_STATUS_SUCCESS;
2009 i965_SyncSurface(VADriverContextP ctx,
2010 VASurfaceID render_target)
2012 struct i965_driver_data *i965 = i965_driver_data(ctx);
2013 struct object_surface *obj_surface = SURFACE(render_target);
2015 assert(obj_surface);
2018 drm_intel_bo_wait_rendering(obj_surface->bo);
2020 return VA_STATUS_SUCCESS;
2024 i965_QuerySurfaceStatus(VADriverContextP ctx,
2025 VASurfaceID render_target,
2026 VASurfaceStatus *status) /* out */
2028 struct i965_driver_data *i965 = i965_driver_data(ctx);
2029 struct object_surface *obj_surface = SURFACE(render_target);
2031 assert(obj_surface);
2033 if (obj_surface->bo) {
2034 if (drm_intel_bo_busy(obj_surface->bo)){
2035 *status = VASurfaceRendering;
2038 *status = VASurfaceReady;
2041 *status = VASurfaceReady;
2044 return VA_STATUS_SUCCESS;
2047 static VADisplayAttribute *
2048 get_display_attribute(VADriverContextP ctx, VADisplayAttribType type)
2050 struct i965_driver_data * const i965 = i965_driver_data(ctx);
2053 if (!i965->display_attributes)
2056 for (i = 0; i < i965->num_display_attributes; i++) {
2057 if (i965->display_attributes[i].type == type)
2058 return &i965->display_attributes[i];
2064 i965_display_attributes_init(VADriverContextP ctx)
2066 struct i965_driver_data * const i965 = i965_driver_data(ctx);
2068 i965->num_display_attributes = ARRAY_ELEMS(i965_display_attributes);
2069 i965->display_attributes = malloc(
2070 i965->num_display_attributes * sizeof(i965->display_attributes[0]));
2071 if (!i965->display_attributes)
2075 i965->display_attributes,
2076 i965_display_attributes,
2077 sizeof(i965_display_attributes)
2080 i965->rotation_attrib = get_display_attribute(ctx, VADisplayAttribRotation);
2081 if (!i965->rotation_attrib)
2087 i965_display_attributes_terminate(VADriverContextP ctx)
2089 struct i965_driver_data * const i965 = i965_driver_data(ctx);
2091 if (i965->display_attributes) {
2092 free(i965->display_attributes);
2093 i965->display_attributes = NULL;
2094 i965->num_display_attributes = 0;
2099 * Query display attributes
2100 * The caller must provide a "attr_list" array that can hold at
2101 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
2102 * returned in "attr_list" is returned in "num_attributes".
2105 i965_QueryDisplayAttributes(
2106 VADriverContextP ctx,
2107 VADisplayAttribute *attribs, /* out */
2108 int *num_attribs_ptr /* out */
2111 const int num_attribs = ARRAY_ELEMS(i965_display_attributes);
2113 if (attribs && num_attribs > 0)
2114 memcpy(attribs, i965_display_attributes, sizeof(i965_display_attributes));
2116 if (num_attribs_ptr)
2117 *num_attribs_ptr = num_attribs;
2119 return VA_STATUS_SUCCESS;
2123 * Get display attributes
2124 * This function returns the current attribute values in "attr_list".
2125 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
2126 * from vaQueryDisplayAttributes() can have their values retrieved.
2129 i965_GetDisplayAttributes(
2130 VADriverContextP ctx,
2131 VADisplayAttribute *attribs, /* inout */
2132 int num_attribs /* in */
2137 for (i = 0; i < num_attribs; i++) {
2138 VADisplayAttribute *src_attrib, * const dst_attrib = &attribs[i];
2140 src_attrib = get_display_attribute(ctx, dst_attrib->type);
2141 if (src_attrib && (src_attrib->flags & VA_DISPLAY_ATTRIB_GETTABLE)) {
2142 dst_attrib->min_value = src_attrib->min_value;
2143 dst_attrib->max_value = src_attrib->max_value;
2144 dst_attrib->value = src_attrib->value;
2147 dst_attrib->flags = VA_DISPLAY_ATTRIB_NOT_SUPPORTED;
2149 return VA_STATUS_SUCCESS;
2153 * Set display attributes
2154 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
2155 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
2156 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
2159 i965_SetDisplayAttributes(
2160 VADriverContextP ctx,
2161 VADisplayAttribute *attribs, /* in */
2162 int num_attribs /* in */
2167 for (i = 0; i < num_attribs; i++) {
2168 VADisplayAttribute *dst_attrib, * const src_attrib = &attribs[i];
2170 dst_attrib = get_display_attribute(ctx, src_attrib->type);
2172 return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
2174 if (!(dst_attrib->flags & VA_DISPLAY_ATTRIB_SETTABLE))
2177 if (src_attrib->value < dst_attrib->min_value ||
2178 src_attrib->value > dst_attrib->max_value)
2179 return VA_STATUS_ERROR_INVALID_PARAMETER;
2181 dst_attrib->value = src_attrib->value;
2182 /* XXX: track modified attributes through timestamps */
2184 return VA_STATUS_SUCCESS;
2188 i965_DbgCopySurfaceToBuffer(VADriverContextP ctx,
2189 VASurfaceID surface,
2190 void **buffer, /* out */
2191 unsigned int *stride) /* out */
2194 return VA_STATUS_ERROR_UNIMPLEMENTED;
2198 i965_Init(VADriverContextP ctx)
2200 struct i965_driver_data *i965 = i965_driver_data(ctx);
2202 if (intel_driver_init(ctx) == False)
2203 return VA_STATUS_ERROR_UNKNOWN;
2205 if (IS_HASWELL(i965->intel.device_id))
2206 i965->codec_info = &gen75_hw_codec_info;
2207 else if (IS_G4X(i965->intel.device_id))
2208 i965->codec_info = &g4x_hw_codec_info;
2209 else if (IS_IRONLAKE(i965->intel.device_id))
2210 i965->codec_info = &ironlake_hw_codec_info;
2211 else if (IS_GEN6(i965->intel.device_id))
2212 i965->codec_info = &gen6_hw_codec_info;
2213 else if (IS_GEN7(i965->intel.device_id))
2214 i965->codec_info = &gen7_hw_codec_info;
2216 return VA_STATUS_ERROR_UNKNOWN;
2218 i965->batch = intel_batchbuffer_new(&i965->intel, I915_EXEC_RENDER, 0);
2220 if (!i965_display_attributes_init(ctx))
2221 return VA_STATUS_ERROR_UNKNOWN;
2223 if (i965_post_processing_init(ctx) == False)
2224 return VA_STATUS_ERROR_UNKNOWN;
2226 if (i965_render_init(ctx) == False)
2227 return VA_STATUS_ERROR_UNKNOWN;
2229 #ifdef HAVE_VA_WAYLAND
2230 if (IS_VA_WAYLAND(ctx) && !i965_output_wayland_init(ctx))
2231 return VA_STATUS_ERROR_UNKNOWN;
2235 if (IS_VA_X11(ctx) && !i965_output_dri_init(ctx))
2236 return VA_STATUS_ERROR_UNKNOWN;
2239 _i965InitMutex(&i965->render_mutex);
2240 _i965InitMutex(&i965->pp_mutex);
2242 return VA_STATUS_SUCCESS;
2246 i965_destroy_heap(struct object_heap *heap,
2247 void (*func)(struct object_heap *heap, struct object_base *object))
2249 struct object_base *object;
2250 object_heap_iterator iter;
2252 object = object_heap_first(heap, &iter);
2258 object = object_heap_next(heap, &iter);
2261 object_heap_destroy(heap);
2266 i965_DestroyImage(VADriverContextP ctx, VAImageID image);
2269 i965_CreateImage(VADriverContextP ctx,
2270 VAImageFormat *format,
2273 VAImage *out_image) /* out */
2275 struct i965_driver_data *i965 = i965_driver_data(ctx);
2276 struct object_image *obj_image;
2277 VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED;
2279 unsigned int width2, height2, size2, size;
2281 out_image->image_id = VA_INVALID_ID;
2282 out_image->buf = VA_INVALID_ID;
2284 image_id = NEW_IMAGE_ID();
2285 if (image_id == VA_INVALID_ID)
2286 return VA_STATUS_ERROR_ALLOCATION_FAILED;
2288 obj_image = IMAGE(image_id);
2290 return VA_STATUS_ERROR_ALLOCATION_FAILED;
2291 obj_image->bo = NULL;
2292 obj_image->palette = NULL;
2293 obj_image->derived_surface = VA_INVALID_ID;
2295 VAImage * const image = &obj_image->image;
2296 image->image_id = image_id;
2297 image->buf = VA_INVALID_ID;
2299 size = width * height;
2300 width2 = (width + 1) / 2;
2301 height2 = (height + 1) / 2;
2302 size2 = width2 * height2;
2304 image->num_palette_entries = 0;
2305 image->entry_bytes = 0;
2306 memset(image->component_order, 0, sizeof(image->component_order));
2308 switch (format->fourcc) {
2309 case VA_FOURCC('I','A','4','4'):
2310 case VA_FOURCC('A','I','4','4'):
2311 image->num_planes = 1;
2312 image->pitches[0] = width;
2313 image->offsets[0] = 0;
2314 image->data_size = image->offsets[0] + image->pitches[0] * height;
2315 image->num_palette_entries = 16;
2316 image->entry_bytes = 3;
2317 image->component_order[0] = 'R';
2318 image->component_order[1] = 'G';
2319 image->component_order[2] = 'B';
2321 case VA_FOURCC('B','G','R','A'):
2322 case VA_FOURCC('R','G','B','A'):
2323 case VA_FOURCC('B','G','R','X'):
2324 case VA_FOURCC('R','G','B','X'):
2325 image->num_planes = 1;
2326 image->pitches[0] = width * 4;
2327 image->offsets[0] = 0;
2328 image->data_size = image->offsets[0] + image->pitches[0] * height;
2330 case VA_FOURCC('Y','V','1','2'):
2331 image->num_planes = 3;
2332 image->pitches[0] = width;
2333 image->offsets[0] = 0;
2334 image->pitches[1] = width2;
2335 image->offsets[1] = size + size2;
2336 image->pitches[2] = width2;
2337 image->offsets[2] = size;
2338 image->data_size = size + 2 * size2;
2340 case VA_FOURCC('I','4','2','0'):
2341 image->num_planes = 3;
2342 image->pitches[0] = width;
2343 image->offsets[0] = 0;
2344 image->pitches[1] = width2;
2345 image->offsets[1] = size;
2346 image->pitches[2] = width2;
2347 image->offsets[2] = size + size2;
2348 image->data_size = size + 2 * size2;
2350 case VA_FOURCC('N','V','1','2'):
2351 image->num_planes = 2;
2352 image->pitches[0] = width;
2353 image->offsets[0] = 0;
2354 image->pitches[1] = width;
2355 image->offsets[1] = size;
2356 image->data_size = size + 2 * size2;
2358 case VA_FOURCC('Y','U','Y','2'):
2359 case VA_FOURCC('U','Y','V','Y'):
2360 image->num_planes = 1;
2361 image->pitches[0] = width * 2;
2362 image->offsets[0] = 0;
2363 image->data_size = size * 2;
2369 va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType,
2370 image->data_size, 1, NULL, &image->buf);
2371 if (va_status != VA_STATUS_SUCCESS)
2374 obj_image->bo = BUFFER(image->buf)->buffer_store->bo;
2375 dri_bo_reference(obj_image->bo);
2377 if (image->num_palette_entries > 0 && image->entry_bytes > 0) {
2378 obj_image->palette = malloc(image->num_palette_entries * sizeof(obj_image->palette));
2379 if (!obj_image->palette)
2383 image->image_id = image_id;
2384 image->format = *format;
2385 image->width = width;
2386 image->height = height;
2388 *out_image = *image;
2389 return VA_STATUS_SUCCESS;
2392 i965_DestroyImage(ctx, image_id);
2397 i965_check_alloc_surface_bo(VADriverContextP ctx,
2398 struct object_surface *obj_surface,
2400 unsigned int fourcc,
2401 unsigned int subsampling)
2403 struct i965_driver_data *i965 = i965_driver_data(ctx);
2404 int region_width, region_height;
2406 if (obj_surface->bo) {
2407 assert(obj_surface->fourcc);
2408 assert(obj_surface->fourcc == fourcc);
2409 assert(obj_surface->subsampling == subsampling);
2413 obj_surface->x_cb_offset = 0; /* X offset is always 0 */
2414 obj_surface->x_cr_offset = 0;
2417 assert(fourcc == VA_FOURCC('N', 'V', '1', '2') ||
2418 fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
2419 fourcc == VA_FOURCC('I', 'M', 'C', '3') ||
2420 fourcc == VA_FOURCC('R', 'G', 'B', 'A') ||
2421 fourcc == VA_FOURCC('R', 'G', 'B', 'X') ||
2422 fourcc == VA_FOURCC('B', 'G', 'R', 'A') ||
2423 fourcc == VA_FOURCC('B', 'G', 'R', 'X') ||
2424 fourcc == VA_FOURCC('Y', 'U', 'Y', '2'));
2426 obj_surface->width = ALIGN(obj_surface->orig_width, 128);
2427 obj_surface->height = ALIGN(obj_surface->orig_height, 32);
2428 region_height = obj_surface->height;
2430 if (fourcc == VA_FOURCC('N', 'V', '1', '2') ||
2431 fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
2432 fourcc == VA_FOURCC('I', 'M', 'C', '3')) {
2433 obj_surface->cb_cr_pitch = obj_surface->width;
2434 region_width = obj_surface->width;
2436 else if (fourcc == VA_FOURCC('Y','U', 'Y', '2')) {
2437 obj_surface->cb_cr_pitch = obj_surface->width * 2;
2438 region_width = obj_surface->width * 2;
2440 else if (fourcc == VA_FOURCC('R', 'G', 'B', 'A') ||
2441 fourcc == VA_FOURCC('R', 'G', 'B', 'X') ||
2442 fourcc == VA_FOURCC('B', 'G', 'R', 'A') ||
2443 fourcc == VA_FOURCC('B', 'G', 'R', 'X')) {
2444 region_width = obj_surface->width * 4;
2451 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
2452 assert(subsampling == SUBSAMPLE_YUV420);
2453 obj_surface->y_cb_offset = obj_surface->height;
2454 obj_surface->y_cr_offset = obj_surface->height;
2455 obj_surface->cb_cr_width = obj_surface->orig_width / 2;
2456 obj_surface->cb_cr_height = obj_surface->orig_height / 2;
2457 region_height = obj_surface->height + ALIGN(obj_surface->cb_cr_height, 32);
2458 } else if (fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
2459 fourcc == VA_FOURCC('I', 'M', 'C', '3') ||
2460 fourcc == VA_FOURCC('R', 'G', 'B', 'A') ||
2461 fourcc == VA_FOURCC('R', 'G', 'B', 'X') ||
2462 fourcc == VA_FOURCC('B', 'G', 'R', 'A') ||
2463 fourcc == VA_FOURCC('B', 'G', 'R', 'X') ||
2464 fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
2465 switch (subsampling) {
2466 case SUBSAMPLE_YUV400:
2467 obj_surface->cb_cr_width = 0;
2468 obj_surface->cb_cr_height = 0;
2471 case SUBSAMPLE_YUV420:
2472 obj_surface->cb_cr_width = obj_surface->orig_width / 2;
2473 obj_surface->cb_cr_height = obj_surface->orig_height / 2;
2476 case SUBSAMPLE_YUV422H:
2477 obj_surface->cb_cr_width = obj_surface->orig_width / 2;
2478 obj_surface->cb_cr_height = obj_surface->orig_height;
2481 case SUBSAMPLE_YUV422V:
2482 obj_surface->cb_cr_width = obj_surface->orig_width;
2483 obj_surface->cb_cr_height = obj_surface->orig_height / 2;
2486 case SUBSAMPLE_YUV444:
2487 obj_surface->cb_cr_width = obj_surface->orig_width;
2488 obj_surface->cb_cr_height = obj_surface->orig_height;
2491 case SUBSAMPLE_YUV411:
2492 obj_surface->cb_cr_width = obj_surface->orig_width / 4;
2493 obj_surface->cb_cr_height = obj_surface->orig_height;
2495 case SUBSAMPLE_RGBX:
2502 region_height = obj_surface->height + ALIGN(obj_surface->cb_cr_height, 32) * 2;
2504 if (fourcc == VA_FOURCC('I', 'M', 'C', '1')) {
2505 obj_surface->y_cr_offset = obj_surface->height;
2506 obj_surface->y_cb_offset = obj_surface->y_cr_offset + ALIGN(obj_surface->cb_cr_height, 32);
2507 } else if (fourcc == VA_FOURCC('I', 'M', 'C', '3')){
2508 obj_surface->y_cb_offset = obj_surface->height;
2509 obj_surface->y_cr_offset = obj_surface->y_cb_offset + ALIGN(obj_surface->cb_cr_height, 32);
2511 else if (fourcc == VA_FOURCC('Y','U', 'Y', '2')) {
2512 obj_surface->y_cb_offset = 0;
2513 obj_surface->y_cr_offset = 0;
2514 region_height = obj_surface->height;
2516 else if (fourcc == VA_FOURCC('R', 'G', 'B', 'A') ||
2517 fourcc == VA_FOURCC('R', 'G', 'B', 'X') ||
2518 fourcc == VA_FOURCC('B', 'G', 'R', 'A') ||
2519 fourcc == VA_FOURCC('B', 'G', 'R', 'X')) {
2520 region_height = obj_surface->height;
2524 assert(fourcc != VA_FOURCC('I', 'M', 'C', '1') &&
2525 fourcc != VA_FOURCC('I', 'M', 'C', '3'));
2526 assert(subsampling == SUBSAMPLE_YUV420 ||
2527 subsampling == SUBSAMPLE_YUV422H ||
2528 subsampling == SUBSAMPLE_YUV422V ||
2529 subsampling == SUBSAMPLE_RGBX);
2531 region_width = obj_surface->width;
2532 region_height = obj_surface->height;
2535 case VA_FOURCC('N', 'V', '1', '2'):
2536 obj_surface->y_cb_offset = obj_surface->height;
2537 obj_surface->y_cr_offset = obj_surface->height;
2538 obj_surface->cb_cr_width = obj_surface->orig_width / 2;
2539 obj_surface->cb_cr_height = obj_surface->orig_height / 2;
2540 obj_surface->cb_cr_pitch = obj_surface->width;
2541 region_height = obj_surface->height + obj_surface->height / 2;
2544 case VA_FOURCC('Y', 'V', '1', '2'):
2545 case VA_FOURCC('I', '4', '2', '0'):
2546 if (fourcc == VA_FOURCC('Y', 'V', '1', '2')) {
2547 obj_surface->y_cr_offset = obj_surface->height;
2548 obj_surface->y_cb_offset = obj_surface->height + obj_surface->height / 4;
2550 obj_surface->y_cb_offset = obj_surface->height;
2551 obj_surface->y_cr_offset = obj_surface->height + obj_surface->height / 4;
2554 obj_surface->cb_cr_width = obj_surface->orig_width / 2;
2555 obj_surface->cb_cr_height = obj_surface->orig_height / 2;
2556 obj_surface->cb_cr_pitch = obj_surface->width / 2;
2557 region_height = obj_surface->height + obj_surface->height / 2;
2560 case VA_FOURCC('Y','U', 'Y', '2'):
2561 obj_surface->y_cb_offset = 0;
2562 obj_surface->y_cr_offset = 0;
2563 obj_surface->cb_cr_width = obj_surface->orig_width / 2;
2564 obj_surface->cb_cr_height = obj_surface->orig_height;
2565 obj_surface->cb_cr_pitch = obj_surface->width * 2;
2566 region_width = obj_surface->width * 2;
2567 region_height = obj_surface->height;
2569 case VA_FOURCC('R', 'G', 'B', 'A'):
2570 case VA_FOURCC('R', 'G', 'B', 'X'):
2571 case VA_FOURCC('B', 'G', 'R', 'A'):
2572 case VA_FOURCC('B', 'G', 'R', 'X'):
2573 region_width = obj_surface->width * 4;
2574 region_height = obj_surface->height;
2583 obj_surface->size = ALIGN(region_width * region_height, 0x1000);
2586 uint32_t tiling_mode = I915_TILING_Y; /* always uses Y-tiled format */
2587 unsigned long pitch;
2589 obj_surface->bo = drm_intel_bo_alloc_tiled(i965->intel.bufmgr,
2597 assert(tiling_mode == I915_TILING_Y);
2598 assert(pitch == obj_surface->width ||
2599 pitch == obj_surface->width * 2 ||
2600 pitch == obj_surface->width * 4) ;
2602 obj_surface->bo = dri_bo_alloc(i965->intel.bufmgr,
2608 obj_surface->fourcc = fourcc;
2609 obj_surface->subsampling = subsampling;
2610 assert(obj_surface->bo);
2613 VAStatus i965_DeriveImage(VADriverContextP ctx,
2614 VASurfaceID surface,
2615 VAImage *out_image) /* out */
2617 struct i965_driver_data *i965 = i965_driver_data(ctx);
2618 struct object_image *obj_image;
2619 struct object_surface *obj_surface;
2621 unsigned int w_pitch, h_pitch;
2622 VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED;
2624 out_image->image_id = VA_INVALID_ID;
2625 obj_surface = SURFACE(surface);
2628 return VA_STATUS_ERROR_INVALID_SURFACE;
2630 if (!obj_surface->bo) {
2631 unsigned int is_tiled = 0;
2632 unsigned int fourcc = VA_FOURCC('Y', 'V', '1', '2');
2633 i965_guess_surface_format(ctx, surface, &fourcc, &is_tiled);
2634 int sampling = get_sampling_from_fourcc(fourcc);
2635 i965_check_alloc_surface_bo(ctx, obj_surface, is_tiled, fourcc, sampling);
2638 assert(obj_surface->fourcc);
2640 w_pitch = obj_surface->width;
2641 h_pitch = obj_surface->height;
2643 image_id = NEW_IMAGE_ID();
2645 if (image_id == VA_INVALID_ID)
2646 return VA_STATUS_ERROR_ALLOCATION_FAILED;
2648 obj_image = IMAGE(image_id);
2651 return VA_STATUS_ERROR_ALLOCATION_FAILED;
2653 obj_image->bo = NULL;
2654 obj_image->palette = NULL;
2655 obj_image->derived_surface = VA_INVALID_ID;
2657 VAImage * const image = &obj_image->image;
2659 memset(image, 0, sizeof(*image));
2660 image->image_id = image_id;
2661 image->buf = VA_INVALID_ID;
2662 image->num_palette_entries = 0;
2663 image->entry_bytes = 0;
2664 image->width = obj_surface->orig_width;
2665 image->height = obj_surface->orig_height;
2666 image->data_size = obj_surface->size;
2668 image->format.fourcc = obj_surface->fourcc;
2669 image->format.byte_order = VA_LSB_FIRST;
2670 image->format.bits_per_pixel = 12;
2672 switch (image->format.fourcc) {
2673 case VA_FOURCC('Y', 'V', '1', '2'):
2674 image->num_planes = 3;
2675 image->pitches[0] = w_pitch; /* Y */
2676 image->offsets[0] = 0;
2677 image->pitches[1] = obj_surface->cb_cr_pitch; /* V */
2678 image->offsets[1] = w_pitch * obj_surface->y_cr_offset;
2679 image->pitches[2] = obj_surface->cb_cr_pitch; /* U */
2680 image->offsets[2] = w_pitch * obj_surface->y_cb_offset;
2683 case VA_FOURCC('N', 'V', '1', '2'):
2684 image->num_planes = 2;
2685 image->pitches[0] = w_pitch; /* Y */
2686 image->offsets[0] = 0;
2687 image->pitches[1] = obj_surface->cb_cr_pitch; /* UV */
2688 image->offsets[1] = w_pitch * obj_surface->y_cb_offset;
2691 case VA_FOURCC('I', '4', '2', '0'):
2692 image->num_planes = 3;
2693 image->pitches[0] = w_pitch; /* Y */
2694 image->offsets[0] = 0;
2695 image->pitches[1] = obj_surface->cb_cr_pitch; /* U */
2696 image->offsets[1] = w_pitch * obj_surface->y_cb_offset;
2697 image->pitches[2] = obj_surface->cb_cr_pitch; /* V */
2698 image->offsets[2] = w_pitch * obj_surface->y_cr_offset;
2700 case VA_FOURCC('Y', 'U', 'Y', '2'):
2701 image->num_planes = 1;
2702 image->pitches[0] = obj_surface->width * 2; /* Y, width is aligned already */
2703 image->offsets[0] = 0;
2704 image->pitches[1] = obj_surface->width * 2; /* U */
2705 image->offsets[1] = 0;
2706 image->pitches[2] = obj_surface->width * 2; /* V */
2707 image->offsets[2] = 0;
2709 case VA_FOURCC('R', 'G', 'B', 'A'):
2710 case VA_FOURCC('R', 'G', 'B', 'X'):
2711 case VA_FOURCC('B', 'G', 'R', 'A'):
2712 case VA_FOURCC('B', 'G', 'R', 'X'):
2713 image->num_planes = 1;
2714 image->pitches[0] = obj_surface->width * 4;
2720 va_status = i965_create_buffer_internal(ctx, 0, VAImageBufferType,
2721 obj_surface->size, 1, NULL, obj_surface->bo, &image->buf);
2722 if (va_status != VA_STATUS_SUCCESS)
2725 obj_image->bo = BUFFER(image->buf)->buffer_store->bo;
2726 dri_bo_reference(obj_image->bo);
2728 if (image->num_palette_entries > 0 && image->entry_bytes > 0) {
2729 obj_image->palette = malloc(image->num_palette_entries * sizeof(obj_image->palette));
2730 if (!obj_image->palette) {
2731 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
2736 *out_image = *image;
2737 obj_surface->flags |= SURFACE_DERIVED;
2738 obj_image->derived_surface = surface;
2740 return VA_STATUS_SUCCESS;
2743 i965_DestroyImage(ctx, image_id);
2748 i965_destroy_image(struct object_heap *heap, struct object_base *obj)
2750 object_heap_free(heap, obj);
2755 i965_DestroyImage(VADriverContextP ctx, VAImageID image)
2757 struct i965_driver_data *i965 = i965_driver_data(ctx);
2758 struct object_image *obj_image = IMAGE(image);
2759 struct object_surface *obj_surface;
2762 return VA_STATUS_SUCCESS;
2764 dri_bo_unreference(obj_image->bo);
2765 obj_image->bo = NULL;
2767 if (obj_image->image.buf != VA_INVALID_ID) {
2768 i965_DestroyBuffer(ctx, obj_image->image.buf);
2769 obj_image->image.buf = VA_INVALID_ID;
2772 if (obj_image->palette) {
2773 free(obj_image->palette);
2774 obj_image->palette = NULL;
2777 obj_surface = SURFACE(obj_image->derived_surface);
2780 obj_surface->flags &= ~SURFACE_DERIVED;
2783 i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image);
2785 return VA_STATUS_SUCCESS;
2789 * pointer to an array holding the palette data. The size of the array is
2790 * num_palette_entries * entry_bytes in size. The order of the components
2791 * in the palette is described by the component_order in VASubpicture struct
2794 i965_SetImagePalette(VADriverContextP ctx,
2796 unsigned char *palette)
2798 struct i965_driver_data *i965 = i965_driver_data(ctx);
2801 struct object_image *obj_image = IMAGE(image);
2803 return VA_STATUS_ERROR_INVALID_IMAGE;
2805 if (!obj_image->palette)
2806 return VA_STATUS_ERROR_ALLOCATION_FAILED; /* XXX: unpaletted/error */
2808 for (i = 0; i < obj_image->image.num_palette_entries; i++)
2809 obj_image->palette[i] = (((unsigned int)palette[3*i + 0] << 16) |
2810 ((unsigned int)palette[3*i + 1] << 8) |
2811 (unsigned int)palette[3*i + 2]);
2812 return VA_STATUS_SUCCESS;
2816 get_sampling_from_fourcc(unsigned int fourcc)
2818 int surface_sampling = -1;
2820 case VA_FOURCC('N', 'V', '1', '2'):
2821 case VA_FOURCC('Y', 'V', '1', '2'):
2822 case VA_FOURCC('I', '4', '2', '0'):
2823 case VA_FOURCC('I', 'M', 'C', '1'):
2824 case VA_FOURCC('I', 'M', 'C', '3'):
2825 surface_sampling = SUBSAMPLE_YUV420;
2827 case VA_FOURCC('Y', 'U', 'Y', '2'):
2828 surface_sampling = SUBSAMPLE_YUV422H;
2830 case VA_FOURCC('R','G','B','A'):
2831 case VA_FOURCC('R','G','B','X'):
2832 case VA_FOURCC('B','G','R','A'):
2833 case VA_FOURCC('B','G','R','X'):
2834 surface_sampling = SUBSAMPLE_RGBX;
2839 return surface_sampling;
2843 memcpy_pic(uint8_t *dst, unsigned int dst_stride,
2844 const uint8_t *src, unsigned int src_stride,
2845 unsigned int len, unsigned int height)
2849 for (i = 0; i < height; i++) {
2850 memcpy(dst, src, len);
2857 get_image_i420(struct object_image *obj_image, uint8_t *image_data,
2858 struct object_surface *obj_surface,
2859 const VARectangle *rect)
2861 uint8_t *dst[3], *src[3];
2863 const int U = obj_image->image.format.fourcc == obj_surface->fourcc ? 1 : 2;
2864 const int V = obj_image->image.format.fourcc == obj_surface->fourcc ? 2 : 1;
2865 unsigned int tiling, swizzle;
2867 if (!obj_surface->bo)
2870 assert(obj_surface->fourcc);
2871 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
2873 if (tiling != I915_TILING_NONE)
2874 drm_intel_gem_bo_map_gtt(obj_surface->bo);
2876 dri_bo_map(obj_surface->bo, 0);
2878 if (!obj_surface->bo->virtual)
2881 /* Dest VA image has either I420 or YV12 format.
2882 Source VA surface alway has I420 format */
2883 dst[Y] = image_data + obj_image->image.offsets[Y];
2884 src[0] = (uint8_t *)obj_surface->bo->virtual;
2885 dst[U] = image_data + obj_image->image.offsets[U];
2886 src[1] = src[0] + obj_surface->width * obj_surface->height;
2887 dst[V] = image_data + obj_image->image.offsets[V];
2888 src[2] = src[1] + (obj_surface->width / 2) * (obj_surface->height / 2);
2891 dst[Y] += rect->y * obj_image->image.pitches[Y] + rect->x;
2892 src[0] += rect->y * obj_surface->width + rect->x;
2893 memcpy_pic(dst[Y], obj_image->image.pitches[Y],
2894 src[0], obj_surface->width,
2895 rect->width, rect->height);
2898 dst[U] += (rect->y / 2) * obj_image->image.pitches[U] + rect->x / 2;
2899 src[1] += (rect->y / 2) * obj_surface->width / 2 + rect->x / 2;
2900 memcpy_pic(dst[U], obj_image->image.pitches[U],
2901 src[1], obj_surface->width / 2,
2902 rect->width / 2, rect->height / 2);
2905 dst[V] += (rect->y / 2) * obj_image->image.pitches[V] + rect->x / 2;
2906 src[2] += (rect->y / 2) * obj_surface->width / 2 + rect->x / 2;
2907 memcpy_pic(dst[V], obj_image->image.pitches[V],
2908 src[2], obj_surface->width / 2,
2909 rect->width / 2, rect->height / 2);
2911 if (tiling != I915_TILING_NONE)
2912 drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
2914 dri_bo_unmap(obj_surface->bo);
2918 get_image_nv12(struct object_image *obj_image, uint8_t *image_data,
2919 struct object_surface *obj_surface,
2920 const VARectangle *rect)
2922 uint8_t *dst[2], *src[2];
2923 unsigned int tiling, swizzle;
2925 if (!obj_surface->bo)
2928 assert(obj_surface->fourcc);
2929 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
2931 if (tiling != I915_TILING_NONE)
2932 drm_intel_gem_bo_map_gtt(obj_surface->bo);
2934 dri_bo_map(obj_surface->bo, 0);
2936 if (!obj_surface->bo->virtual)
2939 /* Both dest VA image and source surface have NV12 format */
2940 dst[0] = image_data + obj_image->image.offsets[0];
2941 src[0] = (uint8_t *)obj_surface->bo->virtual;
2942 dst[1] = image_data + obj_image->image.offsets[1];
2943 src[1] = src[0] + obj_surface->width * obj_surface->height;
2946 dst[0] += rect->y * obj_image->image.pitches[0] + rect->x;
2947 src[0] += rect->y * obj_surface->width + rect->x;
2948 memcpy_pic(dst[0], obj_image->image.pitches[0],
2949 src[0], obj_surface->width,
2950 rect->width, rect->height);
2953 dst[1] += (rect->y / 2) * obj_image->image.pitches[1] + (rect->x & -2);
2954 src[1] += (rect->y / 2) * obj_surface->width + (rect->x & -2);
2955 memcpy_pic(dst[1], obj_image->image.pitches[1],
2956 src[1], obj_surface->width,
2957 rect->width, rect->height / 2);
2959 if (tiling != I915_TILING_NONE)
2960 drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
2962 dri_bo_unmap(obj_surface->bo);
2966 get_image_yuy2(struct object_image *obj_image, uint8_t *image_data,
2967 struct object_surface *obj_surface,
2968 const VARectangle *rect)
2971 unsigned int tiling, swizzle;
2973 if (!obj_surface->bo)
2976 assert(obj_surface->fourcc);
2977 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
2979 if (tiling != I915_TILING_NONE)
2980 drm_intel_gem_bo_map_gtt(obj_surface->bo);
2982 dri_bo_map(obj_surface->bo, 0);
2984 if (!obj_surface->bo->virtual)
2987 /* Both dest VA image and source surface have YUYV format */
2988 dst = image_data + obj_image->image.offsets[0];
2989 src = (uint8_t *)obj_surface->bo->virtual;
2992 dst += rect->y * obj_image->image.pitches[0] + rect->x*2;
2993 src += rect->y * obj_surface->width + rect->x*2;
2994 memcpy_pic(dst, obj_image->image.pitches[0],
2995 src, obj_surface->width*2,
2996 rect->width*2, rect->height);
2998 if (tiling != I915_TILING_NONE)
2999 drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
3001 dri_bo_unmap(obj_surface->bo);
3005 i965_sw_getimage(VADriverContextP ctx,
3006 VASurfaceID surface,
3007 int x, /* coordinates of the upper left source pixel */
3009 unsigned int width, /* width and height of the region */
3010 unsigned int height,
3013 struct i965_driver_data *i965 = i965_driver_data(ctx);
3014 struct i965_render_state *render_state = &i965->render_state;
3016 struct object_surface *obj_surface = SURFACE(surface);
3018 return VA_STATUS_ERROR_INVALID_SURFACE;
3020 struct object_image *obj_image = IMAGE(image);
3022 return VA_STATUS_ERROR_INVALID_IMAGE;
3025 return VA_STATUS_ERROR_INVALID_PARAMETER;
3026 if (x + width > obj_surface->orig_width ||
3027 y + height > obj_surface->orig_height)
3028 return VA_STATUS_ERROR_INVALID_PARAMETER;
3029 if (x + width > obj_image->image.width ||
3030 y + height > obj_image->image.height)
3031 return VA_STATUS_ERROR_INVALID_PARAMETER;
3033 if (obj_surface->fourcc != obj_image->image.format.fourcc)
3034 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
3037 void *image_data = NULL;
3039 va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data);
3040 if (va_status != VA_STATUS_SUCCESS)
3047 rect.height = height;
3049 switch (obj_image->image.format.fourcc) {
3050 case VA_FOURCC('Y','V','1','2'):
3051 case VA_FOURCC('I','4','2','0'):
3052 /* I420 is native format for MPEG-2 decoded surfaces */
3053 if (render_state->interleaved_uv)
3054 goto operation_failed;
3055 get_image_i420(obj_image, image_data, obj_surface, &rect);
3057 case VA_FOURCC('N','V','1','2'):
3058 /* NV12 is native format for H.264 decoded surfaces */
3059 if (!render_state->interleaved_uv)
3060 goto operation_failed;
3061 get_image_nv12(obj_image, image_data, obj_surface, &rect);
3063 case VA_FOURCC('Y','U','Y','2'):
3064 /* YUY2 is the format supported by overlay plane */
3065 get_image_yuy2(obj_image, image_data, obj_surface, &rect);
3069 va_status = VA_STATUS_ERROR_OPERATION_FAILED;
3073 i965_UnmapBuffer(ctx, obj_image->image.buf);
3078 i965_hw_getimage(VADriverContextP ctx,
3079 VASurfaceID surface,
3080 int x, /* coordinates of the upper left source pixel */
3082 unsigned int width, /* width and height of the region */
3083 unsigned int height,
3086 struct i965_driver_data *i965 = i965_driver_data(ctx);
3087 struct i965_surface src_surface;
3088 struct i965_surface dst_surface;
3091 struct object_surface *obj_surface = SURFACE(surface);
3092 struct object_image *obj_image = IMAGE(image);
3095 return VA_STATUS_ERROR_INVALID_SURFACE;
3098 return VA_STATUS_ERROR_INVALID_IMAGE;
3101 return VA_STATUS_ERROR_INVALID_PARAMETER;
3102 if (x + width > obj_surface->orig_width ||
3103 y + height > obj_surface->orig_height)
3104 return VA_STATUS_ERROR_INVALID_PARAMETER;
3105 if (x + width > obj_image->image.width ||
3106 y + height > obj_image->image.height)
3107 return VA_STATUS_ERROR_INVALID_PARAMETER;
3109 if (!obj_surface->bo)
3110 return VA_STATUS_SUCCESS;
3111 assert(obj_image->bo); // image bo is always created, see i965_CreateImage()
3116 rect.height = height;
3118 src_surface.id = surface;
3119 src_surface.type = I965_SURFACE_TYPE_SURFACE;
3120 src_surface.flags = I965_SURFACE_FLAG_FRAME;
3122 dst_surface.id = image;
3123 dst_surface.type = I965_SURFACE_TYPE_IMAGE;
3124 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
3126 va_status = i965_image_processing(ctx,
3137 i965_GetImage(VADriverContextP ctx,
3138 VASurfaceID surface,
3139 int x, /* coordinates of the upper left source pixel */
3141 unsigned int width, /* width and height of the region */
3142 unsigned int height,
3145 struct i965_driver_data * const i965 = i965_driver_data(ctx);
3148 if (HAS_ACCELERATED_GETIMAGE(i965))
3149 va_status = i965_hw_getimage(ctx,
3155 va_status = i965_sw_getimage(ctx,
3165 put_image_i420(struct object_surface *obj_surface,
3166 const VARectangle *dst_rect,
3167 struct object_image *obj_image, uint8_t *image_data,
3168 const VARectangle *src_rect)
3170 uint8_t *dst[3], *src[3];
3172 const int U = obj_image->image.format.fourcc == obj_surface->fourcc ? 1 : 2;
3173 const int V = obj_image->image.format.fourcc == obj_surface->fourcc ? 2 : 1;
3174 unsigned int tiling, swizzle;
3176 if (!obj_surface->bo)
3179 assert(obj_surface->fourcc);
3180 assert(dst_rect->width == src_rect->width);
3181 assert(dst_rect->height == src_rect->height);
3182 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
3184 if (tiling != I915_TILING_NONE)
3185 drm_intel_gem_bo_map_gtt(obj_surface->bo);
3187 dri_bo_map(obj_surface->bo, 0);
3189 if (!obj_surface->bo->virtual)
3192 /* Dest VA image has either I420 or YV12 format.
3193 Source VA surface alway has I420 format */
3194 dst[0] = (uint8_t *)obj_surface->bo->virtual;
3195 src[Y] = image_data + obj_image->image.offsets[Y];
3196 dst[1] = dst[0] + obj_surface->width * obj_surface->height;
3197 src[U] = image_data + obj_image->image.offsets[U];
3198 dst[2] = dst[1] + (obj_surface->width / 2) * (obj_surface->height / 2);
3199 src[V] = image_data + obj_image->image.offsets[V];
3202 dst[0] += dst_rect->y * obj_surface->width + dst_rect->x;
3203 src[Y] += src_rect->y * obj_image->image.pitches[Y] + src_rect->x;
3204 memcpy_pic(dst[0], obj_surface->width,
3205 src[Y], obj_image->image.pitches[Y],
3206 src_rect->width, src_rect->height);
3209 dst[1] += (dst_rect->y / 2) * obj_surface->width / 2 + dst_rect->x / 2;
3210 src[U] += (src_rect->y / 2) * obj_image->image.pitches[U] + src_rect->x / 2;
3211 memcpy_pic(dst[1], obj_surface->width / 2,
3212 src[U], obj_image->image.pitches[U],
3213 src_rect->width / 2, src_rect->height / 2);
3216 dst[2] += (dst_rect->y / 2) * obj_surface->width / 2 + dst_rect->x / 2;
3217 src[V] += (src_rect->y / 2) * obj_image->image.pitches[V] + src_rect->x / 2;
3218 memcpy_pic(dst[2], obj_surface->width / 2,
3219 src[V], obj_image->image.pitches[V],
3220 src_rect->width / 2, src_rect->height / 2);
3222 if (tiling != I915_TILING_NONE)
3223 drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
3225 dri_bo_unmap(obj_surface->bo);
3229 put_image_nv12(struct object_surface *obj_surface,
3230 const VARectangle *dst_rect,
3231 struct object_image *obj_image, uint8_t *image_data,
3232 const VARectangle *src_rect)
3234 uint8_t *dst[2], *src[2];
3235 unsigned int tiling, swizzle;
3237 if (!obj_surface->bo)
3240 assert(obj_surface->fourcc);
3241 assert(dst_rect->width == src_rect->width);
3242 assert(dst_rect->height == src_rect->height);
3243 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
3245 if (tiling != I915_TILING_NONE)
3246 drm_intel_gem_bo_map_gtt(obj_surface->bo);
3248 dri_bo_map(obj_surface->bo, 0);
3250 if (!obj_surface->bo->virtual)
3253 /* Both dest VA image and source surface have NV12 format */
3254 dst[0] = (uint8_t *)obj_surface->bo->virtual;
3255 src[0] = image_data + obj_image->image.offsets[0];
3256 dst[1] = dst[0] + obj_surface->width * obj_surface->height;
3257 src[1] = image_data + obj_image->image.offsets[1];
3260 dst[0] += dst_rect->y * obj_surface->width + dst_rect->x;
3261 src[0] += src_rect->y * obj_image->image.pitches[0] + src_rect->x;
3262 memcpy_pic(dst[0], obj_surface->width,
3263 src[0], obj_image->image.pitches[0],
3264 src_rect->width, src_rect->height);
3267 dst[1] += (dst_rect->y / 2) * obj_surface->width + (dst_rect->x & -2);
3268 src[1] += (src_rect->y / 2) * obj_image->image.pitches[1] + (src_rect->x & -2);
3269 memcpy_pic(dst[1], obj_surface->width,
3270 src[1], obj_image->image.pitches[1],
3271 src_rect->width, src_rect->height / 2);
3273 if (tiling != I915_TILING_NONE)
3274 drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
3276 dri_bo_unmap(obj_surface->bo);
3280 put_image_yuy2(struct object_surface *obj_surface,
3281 const VARectangle *dst_rect,
3282 struct object_image *obj_image, uint8_t *image_data,
3283 const VARectangle *src_rect)
3286 unsigned int tiling, swizzle;
3288 if (!obj_surface->bo)
3291 assert(obj_surface->fourcc);
3292 assert(dst_rect->width == src_rect->width);
3293 assert(dst_rect->height == src_rect->height);
3294 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
3296 if (tiling != I915_TILING_NONE)
3297 drm_intel_gem_bo_map_gtt(obj_surface->bo);
3299 dri_bo_map(obj_surface->bo, 0);
3301 if (!obj_surface->bo->virtual)
3304 /* Both dest VA image and source surface have YUY2 format */
3305 dst = (uint8_t *)obj_surface->bo->virtual;
3306 src = image_data + obj_image->image.offsets[0];
3308 /* YUYV packed plane */
3309 dst += dst_rect->y * obj_surface->width + dst_rect->x*2;
3310 src += src_rect->y * obj_image->image.pitches[0] + src_rect->x*2;
3311 memcpy_pic(dst, obj_surface->width*2,
3312 src, obj_image->image.pitches[0],
3313 src_rect->width*2, src_rect->height);
3315 if (tiling != I915_TILING_NONE)
3316 drm_intel_gem_bo_unmap_gtt(obj_surface->bo);
3318 dri_bo_unmap(obj_surface->bo);
3323 i965_sw_putimage(VADriverContextP ctx,
3324 VASurfaceID surface,
3328 unsigned int src_width,
3329 unsigned int src_height,
3332 unsigned int dest_width,
3333 unsigned int dest_height)
3335 struct i965_driver_data *i965 = i965_driver_data(ctx);
3336 struct object_surface *obj_surface = SURFACE(surface);
3339 return VA_STATUS_ERROR_INVALID_SURFACE;
3341 struct object_image *obj_image = IMAGE(image);
3343 return VA_STATUS_ERROR_INVALID_IMAGE;
3345 if (src_x < 0 || src_y < 0)
3346 return VA_STATUS_ERROR_INVALID_PARAMETER;
3347 if (src_x + src_width > obj_image->image.width ||
3348 src_y + src_height > obj_image->image.height)
3349 return VA_STATUS_ERROR_INVALID_PARAMETER;
3350 if (dest_x < 0 || dest_y < 0)
3351 return VA_STATUS_ERROR_INVALID_PARAMETER;
3352 if (dest_x + dest_width > obj_surface->orig_width ||
3353 dest_y + dest_height > obj_surface->orig_height)
3354 return VA_STATUS_ERROR_INVALID_PARAMETER;
3356 /* XXX: don't allow scaling */
3357 if (src_width != dest_width || src_height != dest_height)
3358 return VA_STATUS_ERROR_INVALID_PARAMETER;
3360 if (obj_surface->fourcc) {
3361 /* Don't allow format mismatch */
3362 if (obj_surface->fourcc != obj_image->image.format.fourcc)
3363 return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
3367 /* VA is surface not used for decoding, use same VA image format */
3368 i965_check_alloc_surface_bo(
3371 0, /* XXX: don't use tiled surface */
3372 obj_image->image.format.fourcc,
3373 get_sampling_from_fourcc (obj_image->image.format.fourcc));
3377 void *image_data = NULL;
3379 va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data);
3380 if (va_status != VA_STATUS_SUCCESS)
3383 VARectangle src_rect, dest_rect;
3386 src_rect.width = src_width;
3387 src_rect.height = src_height;
3388 dest_rect.x = dest_x;
3389 dest_rect.y = dest_y;
3390 dest_rect.width = dest_width;
3391 dest_rect.height = dest_height;
3393 switch (obj_image->image.format.fourcc) {
3394 case VA_FOURCC('Y','V','1','2'):
3395 case VA_FOURCC('I','4','2','0'):
3396 put_image_i420(obj_surface, &dest_rect, obj_image, image_data, &src_rect);
3398 case VA_FOURCC('N','V','1','2'):
3399 put_image_nv12(obj_surface, &dest_rect, obj_image, image_data, &src_rect);
3401 case VA_FOURCC('Y','U','Y','2'):
3402 put_image_yuy2(obj_surface, &dest_rect, obj_image, image_data, &src_rect);
3405 va_status = VA_STATUS_ERROR_OPERATION_FAILED;
3409 i965_UnmapBuffer(ctx, obj_image->image.buf);
3414 i965_hw_putimage(VADriverContextP ctx,
3415 VASurfaceID surface,
3419 unsigned int src_width,
3420 unsigned int src_height,
3423 unsigned int dest_width,
3424 unsigned int dest_height)
3426 struct i965_driver_data *i965 = i965_driver_data(ctx);
3427 struct object_surface *obj_surface = SURFACE(surface);
3428 struct object_image *obj_image = IMAGE(image);
3429 struct i965_surface src_surface, dst_surface;
3430 VAStatus va_status = VA_STATUS_SUCCESS;
3431 VARectangle src_rect, dst_rect;
3434 return VA_STATUS_ERROR_INVALID_SURFACE;
3436 if (!obj_image || !obj_image->bo)
3437 return VA_STATUS_ERROR_INVALID_IMAGE;
3441 src_x + src_width > obj_image->image.width ||
3442 src_y + src_height > obj_image->image.height)
3443 return VA_STATUS_ERROR_INVALID_PARAMETER;
3447 dest_x + dest_width > obj_surface->orig_width ||
3448 dest_y + dest_height > obj_surface->orig_height)
3449 return VA_STATUS_ERROR_INVALID_PARAMETER;
3451 if (!obj_surface->bo) {
3452 unsigned int tiling, swizzle;
3453 int surface_sampling = get_sampling_from_fourcc (obj_image->image.format.fourcc);;
3454 dri_bo_get_tiling(obj_image->bo, &tiling, &swizzle);
3456 i965_check_alloc_surface_bo(ctx,
3459 obj_image->image.format.fourcc,
3463 assert(obj_surface->fourcc);
3465 src_surface.id = image;
3466 src_surface.type = I965_SURFACE_TYPE_IMAGE;
3467 src_surface.flags = I965_SURFACE_FLAG_FRAME;
3470 src_rect.width = src_width;
3471 src_rect.height = src_height;
3473 dst_surface.id = surface;
3474 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
3475 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
3476 dst_rect.x = dest_x;
3477 dst_rect.y = dest_y;
3478 dst_rect.width = dest_width;
3479 dst_rect.height = dest_height;
3481 va_status = i965_image_processing(ctx,
3491 i965_PutImage(VADriverContextP ctx,
3492 VASurfaceID surface,
3496 unsigned int src_width,
3497 unsigned int src_height,
3500 unsigned int dest_width,
3501 unsigned int dest_height)
3503 struct i965_driver_data *i965 = i965_driver_data(ctx);
3504 VAStatus va_status = VA_STATUS_SUCCESS;
3506 if (HAS_ACCELERATED_PUTIMAGE(i965))
3507 va_status = i965_hw_putimage(ctx,
3519 va_status = i965_sw_putimage(ctx,
3535 i965_PutSurface(VADriverContextP ctx,
3536 VASurfaceID surface,
3537 void *draw, /* X Drawable */
3540 unsigned short srcw,
3541 unsigned short srch,
3544 unsigned short destw,
3545 unsigned short desth,
3546 VARectangle *cliprects, /* client supplied clip list */
3547 unsigned int number_cliprects, /* number of clip rects in the clip list */
3548 unsigned int flags) /* de-interlacing flags */
3551 if (IS_VA_X11(ctx)) {
3552 VARectangle src_rect, dst_rect;
3556 src_rect.width = srcw;
3557 src_rect.height = srch;
3561 dst_rect.width = destw;
3562 dst_rect.height = desth;
3564 return i965_put_surface_dri(ctx, surface, draw, &src_rect, &dst_rect,
3565 cliprects, number_cliprects, flags);
3568 return VA_STATUS_ERROR_UNIMPLEMENTED;
3572 i965_Terminate(VADriverContextP ctx)
3574 struct i965_driver_data *i965 = i965_driver_data(ctx);
3577 intel_batchbuffer_free(i965->batch);
3579 _i965DestroyMutex(&i965->pp_mutex);
3580 _i965DestroyMutex(&i965->render_mutex);
3584 i965_output_dri_terminate(ctx);
3587 #ifdef HAVE_VA_WAYLAND
3588 if (IS_VA_WAYLAND(ctx))
3589 i965_output_wayland_terminate(ctx);
3592 if (i965_render_terminate(ctx) == False)
3593 return VA_STATUS_ERROR_UNKNOWN;
3595 if (i965_post_processing_terminate(ctx) == False)
3596 return VA_STATUS_ERROR_UNKNOWN;
3598 i965_display_attributes_terminate(ctx);
3600 i965_destroy_heap(&i965->buffer_heap, i965_destroy_buffer);
3601 i965_destroy_heap(&i965->image_heap, i965_destroy_image);
3602 i965_destroy_heap(&i965->subpic_heap, i965_destroy_subpic);
3603 i965_destroy_heap(&i965->surface_heap, i965_destroy_surface);
3604 i965_destroy_heap(&i965->context_heap, i965_destroy_context);
3605 i965_destroy_heap(&i965->config_heap, i965_destroy_config);
3607 if (intel_driver_terminate(ctx) == False)
3608 return VA_STATUS_ERROR_UNKNOWN;
3610 free(ctx->pDriverData);
3611 ctx->pDriverData = NULL;
3613 return VA_STATUS_SUCCESS;
3618 VADriverContextP ctx, /* in */
3619 VABufferID buf_id, /* in */
3620 VABufferType *type, /* out */
3621 unsigned int *size, /* out */
3622 unsigned int *num_elements /* out */
3625 struct i965_driver_data *i965 = NULL;
3626 struct object_buffer *obj_buffer = NULL;
3628 i965 = i965_driver_data(ctx);
3629 obj_buffer = BUFFER(buf_id);
3631 *type = obj_buffer->type;
3632 *size = obj_buffer->size_element;
3633 *num_elements = obj_buffer->num_elements;
3635 return VA_STATUS_SUCCESS;
3640 VADriverContextP ctx, /* in */
3641 VASurfaceID surface, /* in */
3642 unsigned int *fourcc, /* out */
3643 unsigned int *luma_stride, /* out */
3644 unsigned int *chroma_u_stride, /* out */
3645 unsigned int *chroma_v_stride, /* out */
3646 unsigned int *luma_offset, /* out */
3647 unsigned int *chroma_u_offset, /* out */
3648 unsigned int *chroma_v_offset, /* out */
3649 unsigned int *buffer_name, /* out */
3650 void **buffer /* out */
3653 VAStatus vaStatus = VA_STATUS_SUCCESS;
3654 struct i965_driver_data *i965 = i965_driver_data(ctx);
3655 struct object_surface *obj_surface = NULL;
3659 assert(luma_stride);
3660 assert(chroma_u_stride);
3661 assert(chroma_v_stride);
3662 assert(luma_offset);
3663 assert(chroma_u_offset);
3664 assert(chroma_v_offset);
3665 assert(buffer_name);
3668 tmpImage.image_id = VA_INVALID_ID;
3670 obj_surface = SURFACE(surface);
3671 if (obj_surface == NULL) {
3672 // Surface is absent.
3673 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
3677 // Lock functionality is absent now.
3678 if (obj_surface->locked_image_id != VA_INVALID_ID) {
3679 // Surface is locked already.
3680 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
3684 vaStatus = i965_DeriveImage(
3688 if (vaStatus != VA_STATUS_SUCCESS) {
3692 obj_surface->locked_image_id = tmpImage.image_id;
3694 vaStatus = i965_MapBuffer(
3698 if (vaStatus != VA_STATUS_SUCCESS) {
3702 *fourcc = tmpImage.format.fourcc;
3703 *luma_offset = tmpImage.offsets[0];
3704 *luma_stride = tmpImage.pitches[0];
3705 *chroma_u_offset = tmpImage.offsets[1];
3706 *chroma_u_stride = tmpImage.pitches[1];
3707 *chroma_v_offset = tmpImage.offsets[2];
3708 *chroma_v_stride = tmpImage.pitches[2];
3709 *buffer_name = tmpImage.buf;
3712 if (vaStatus != VA_STATUS_SUCCESS) {
3721 VADriverContextP ctx, /* in */
3722 VASurfaceID surface /* in */
3725 VAStatus vaStatus = VA_STATUS_SUCCESS;
3726 struct i965_driver_data *i965 = i965_driver_data(ctx);
3727 struct object_image *locked_img = NULL;
3728 struct object_surface *obj_surface = NULL;
3730 obj_surface = SURFACE(surface);
3732 if (obj_surface == NULL) {
3733 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; // Surface is absent
3736 if (obj_surface->locked_image_id == VA_INVALID_ID) {
3737 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; // Surface is not locked
3741 locked_img = IMAGE(obj_surface->locked_image_id);
3742 if (locked_img == NULL || (locked_img->image.image_id == VA_INVALID_ID)) {
3743 // Work image was deallocated before i965_UnlockSurface()
3744 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
3748 vaStatus = i965_UnmapBuffer(
3750 locked_img->image.buf);
3751 if (vaStatus != VA_STATUS_SUCCESS) {
3755 vaStatus = i965_DestroyImage(
3757 locked_img->image.image_id);
3758 if (vaStatus != VA_STATUS_SUCCESS) {
3762 locked_img->image.image_id = VA_INVALID_ID;
3765 obj_surface->locked_image_id = VA_INVALID_ID;
3771 i965_GetSurfaceAttributes(
3772 VADriverContextP ctx,
3774 VASurfaceAttrib *attrib_list,
3775 unsigned int num_attribs
3778 VAStatus vaStatus = VA_STATUS_SUCCESS;
3779 struct i965_driver_data *i965 = i965_driver_data(ctx);
3780 struct object_config *obj_config;
3783 if (config == VA_INVALID_ID)
3784 return VA_STATUS_ERROR_INVALID_CONFIG;
3786 obj_config = CONFIG(config);
3788 if (obj_config == NULL)
3789 return VA_STATUS_ERROR_INVALID_CONFIG;
3791 if (attrib_list == NULL || num_attribs == 0)
3792 return VA_STATUS_ERROR_INVALID_PARAMETER;
3794 for (i = 0; i < num_attribs; i++) {
3795 switch (attrib_list[i].type) {
3796 case VASurfaceAttribPixelFormat:
3797 attrib_list[i].value.type = VAGenericValueTypeInteger;
3798 attrib_list[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
3800 if (attrib_list[i].value.value.i == 0) {
3801 if (IS_G4X(i965->intel.device_id)) {
3802 if (obj_config->profile == VAProfileMPEG2Simple ||
3803 obj_config->profile == VAProfileMPEG2Main) {
3804 attrib_list[i].value.value.i = VA_FOURCC('I', '4', '2', '0');
3807 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3809 } else if (IS_IRONLAKE(i965->intel.device_id)) {
3810 if (obj_config->profile == VAProfileMPEG2Simple ||
3811 obj_config->profile == VAProfileMPEG2Main) {
3812 attrib_list[i].value.value.i = VA_FOURCC('I', '4', '2', '0');
3813 } else if (obj_config->profile == VAProfileH264Baseline ||
3814 obj_config->profile == VAProfileH264Main ||
3815 obj_config->profile == VAProfileH264High) {
3816 attrib_list[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
3817 } else if (obj_config->profile == VAProfileNone) {
3818 attrib_list[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
3821 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3823 } else if (IS_GEN6(i965->intel.device_id)) {
3824 attrib_list[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
3825 } else if (IS_GEN7(i965->intel.device_id)) {
3826 if (obj_config->profile == VAProfileJPEGBaseline)
3827 attrib_list[i].value.value.i = 0; /* internal format */
3829 attrib_list[i].value.value.i = VA_FOURCC('N', 'V', '1', '2');
3832 if (IS_G4X(i965->intel.device_id)) {
3833 if (obj_config->profile == VAProfileMPEG2Simple ||
3834 obj_config->profile == VAProfileMPEG2Main) {
3835 if (attrib_list[i].value.value.i != VA_FOURCC('I', '4', '2', '0')) {
3836 attrib_list[i].value.value.i = 0;
3837 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3841 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3843 } else if (IS_IRONLAKE(i965->intel.device_id)) {
3844 if (obj_config->profile == VAProfileMPEG2Simple ||
3845 obj_config->profile == VAProfileMPEG2Main) {
3846 if (attrib_list[i].value.value.i != VA_FOURCC('I', '4', '2', '0')) {
3847 attrib_list[i].value.value.i = 0;
3848 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3850 } else if (obj_config->profile == VAProfileH264Baseline ||
3851 obj_config->profile == VAProfileH264Main ||
3852 obj_config->profile == VAProfileH264High) {
3853 if (attrib_list[i].value.value.i != VA_FOURCC('N', 'V', '1', '2')) {
3854 attrib_list[i].value.value.i = 0;
3855 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3857 } else if (obj_config->profile == VAProfileNone) {
3858 switch (attrib_list[i].value.value.i) {
3859 case VA_FOURCC('N', 'V', '1', '2'):
3860 case VA_FOURCC('I', '4', '2', '0'):
3861 case VA_FOURCC('Y', 'V', '1', '2'):
3862 case VA_FOURCC('Y', 'U', 'Y', '2'):
3863 case VA_FOURCC('B', 'G', 'R', 'A'):
3864 case VA_FOURCC('B', 'G', 'R', 'X'):
3865 case VA_FOURCC('R', 'G', 'B', 'X'):
3866 case VA_FOURCC('R', 'G', 'B', 'A'):
3869 attrib_list[i].value.value.i = 0;
3870 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3875 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3877 } else if (IS_GEN6(i965->intel.device_id)) {
3878 if (obj_config->entrypoint == VAEntrypointEncSlice ||
3879 obj_config->entrypoint == VAEntrypointVideoProc) {
3880 switch (attrib_list[i].value.value.i) {
3881 case VA_FOURCC('N', 'V', '1', '2'):
3882 case VA_FOURCC('I', '4', '2', '0'):
3883 case VA_FOURCC('Y', 'V', '1', '2'):
3884 case VA_FOURCC('Y', 'U', 'Y', '2'):
3885 case VA_FOURCC('B', 'G', 'R', 'A'):
3886 case VA_FOURCC('B', 'G', 'R', 'X'):
3887 case VA_FOURCC('R', 'G', 'B', 'X'):
3888 case VA_FOURCC('R', 'G', 'B', 'A'):
3891 attrib_list[i].value.value.i = 0;
3892 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3896 if (attrib_list[i].value.value.i != VA_FOURCC('N', 'V', '1', '2')) {
3897 attrib_list[i].value.value.i = 0;
3898 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3901 } else if (IS_GEN7(i965->intel.device_id)) {
3902 if (obj_config->entrypoint == VAEntrypointEncSlice ||
3903 obj_config->entrypoint == VAEntrypointVideoProc) {
3904 switch (attrib_list[i].value.value.i) {
3905 case VA_FOURCC('N', 'V', '1', '2'):
3906 case VA_FOURCC('I', '4', '2', '0'):
3907 case VA_FOURCC('Y', 'V', '1', '2'):
3910 attrib_list[i].value.value.i = 0;
3911 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3915 if (obj_config->profile == VAProfileJPEGBaseline) {
3916 attrib_list[i].value.value.i = 0; /* JPEG decoding always uses an internal format */
3917 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3919 if (attrib_list[i].value.value.i != VA_FOURCC('N', 'V', '1', '2')) {
3920 attrib_list[i].value.value.i = 0;
3921 attrib_list[i].flags &= ~VA_SURFACE_ATTRIB_SETTABLE;
3929 case VASurfaceAttribMinWidth:
3930 /* FIXME: add support for it later */
3931 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3933 case VASurfaceAttribMaxWidth:
3934 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3936 case VASurfaceAttribMinHeight:
3937 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3939 case VASurfaceAttribMaxHeight:
3940 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3943 attrib_list[i].flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
3952 * Query video processing pipeline
3954 VAStatus i965_QueryVideoProcFilters(
3955 VADriverContextP ctx,
3956 VAContextID context,
3957 VAProcFilterType *filters,
3958 unsigned int *num_filters
3961 struct i965_driver_data *const i965 = i965_driver_data(ctx);
3964 if (HAS_VPP(i965)) {
3965 filters[i++] = VAProcFilterNoiseReduction;
3966 filters[i++] = VAProcFilterDeinterlacing;
3969 if(IS_HASWELL(i965->intel.device_id)){
3970 filters[i++] = VAProcFilterNone;
3971 filters[i++] = VAProcFilterSharpening;
3972 filters[i++] = VAProcFilterColorBalance;
3973 filters[i++] = VAProcFilterColorStandard;
3978 return VA_STATUS_SUCCESS;
3981 VAStatus i965_QueryVideoProcFilterCaps(
3982 VADriverContextP ctx,
3983 VAContextID context,
3984 VAProcFilterType type,
3986 unsigned int *num_filter_caps
3989 struct i965_driver_data *const i965 = i965_driver_data(ctx);
3992 if (type == VAProcFilterNoiseReduction) {
3993 VAProcFilterCap *cap = filter_caps;
3995 cap->range.min_value = 0.0;
3996 cap->range.max_value = 1.0;
3997 cap->range.default_value = 0.5;
3998 cap->range.step = 0.03125; /* 1.0 / 32 */
4000 } else if (type == VAProcFilterDeinterlacing) {
4001 VAProcFilterCapDeinterlacing *cap = filter_caps;
4003 cap->type = VAProcDeinterlacingBob;
4008 if(IS_HASWELL(i965->intel.device_id)){
4009 if(type == VAProcFilterColorBalance){
4010 VAProcFilterCapColorBalance *cap = filter_caps;
4011 cap->type = VAProcColorBalanceHue;
4012 cap->range.min_value = -180.0;
4013 cap->range.max_value = 180.0;
4014 cap->range.default_value = 0.0;
4015 cap->range.step = 1.0;
4019 cap->type = VAProcColorBalanceSaturation;
4020 cap->range.min_value = 0.0;
4021 cap->range.max_value = 10.0;
4022 cap->range.default_value = 0.0;
4023 cap->range.step = 0.1;
4027 cap->type = VAProcColorBalanceBrightness;
4028 cap->range.min_value = -100.0;
4029 cap->range.max_value = 100.0;
4030 cap->range.default_value = 0.0;
4031 cap->range.step = 1.0;
4035 cap->type = VAProcColorBalanceContrast;
4036 cap->range.min_value = 0.0;
4037 cap->range.max_value = 10.0;
4038 cap->range.default_value = 0.0;
4039 cap->range.step = 0.1;
4046 *num_filter_caps = i;
4048 return VA_STATUS_SUCCESS;
4051 static VAProcColorStandardType vpp_input_color_standards[VAProcColorStandardCount] = {
4052 VAProcColorStandardBT601,
4055 static VAProcColorStandardType vpp_output_color_standards[VAProcColorStandardCount] = {
4056 VAProcColorStandardBT601,
4059 VAStatus i965_QueryVideoProcPipelineCaps(
4060 VADriverContextP ctx,
4061 VAContextID context,
4062 VABufferID *filters,
4063 unsigned int num_filters,
4064 VAProcPipelineCaps *pipeline_cap /* out */
4067 struct i965_driver_data * const i965 = i965_driver_data(ctx);
4070 pipeline_cap->pipeline_flags = 0;
4071 pipeline_cap->filter_flags = 0;
4072 pipeline_cap->num_forward_references = 0;
4073 pipeline_cap->num_backward_references = 0;
4074 pipeline_cap->num_input_color_standards = 1;
4075 pipeline_cap->input_color_standards = vpp_input_color_standards;
4076 pipeline_cap->num_output_color_standards = 1;
4077 pipeline_cap->output_color_standards = vpp_output_color_standards;
4079 for (i = 0; i < num_filters; i++) {
4080 struct object_buffer *obj_buffer = BUFFER(filters[i]);
4081 VAProcFilterParameterBufferBase *base = (VAProcFilterParameterBufferBase *)obj_buffer->buffer_store->buffer;
4083 if (base->type == VAProcFilterNoiseReduction) {
4084 VAProcFilterParameterBuffer *denoise = (VAProcFilterParameterBuffer *)base;
4086 } else if (base->type == VAProcFilterDeinterlacing) {
4087 VAProcFilterParameterBufferDeinterlacing *deint = (VAProcFilterParameterBufferDeinterlacing *)base;
4089 assert(deint->algorithm == VAProcDeinterlacingWeave ||
4090 deint->algorithm == VAProcDeinterlacingBob);
4094 return VA_STATUS_SUCCESS;
4098 VA_DRIVER_INIT_FUNC(VADriverContextP ctx);
4101 VA_DRIVER_INIT_FUNC( VADriverContextP ctx )
4103 struct VADriverVTable * const vtable = ctx->vtable;
4104 struct VADriverVTableVPP * const vtable_vpp = ctx->vtable_vpp;
4106 struct i965_driver_data *i965;
4109 ctx->version_major = VA_MAJOR_VERSION;
4110 ctx->version_minor = VA_MINOR_VERSION;
4111 ctx->max_profiles = I965_MAX_PROFILES;
4112 ctx->max_entrypoints = I965_MAX_ENTRYPOINTS;
4113 ctx->max_attributes = I965_MAX_CONFIG_ATTRIBUTES;
4114 ctx->max_image_formats = I965_MAX_IMAGE_FORMATS;
4115 ctx->max_subpic_formats = I965_MAX_SUBPIC_FORMATS;
4116 ctx->max_display_attributes = 1 + ARRAY_ELEMS(i965_display_attributes);
4118 vtable->vaTerminate = i965_Terminate;
4119 vtable->vaQueryConfigEntrypoints = i965_QueryConfigEntrypoints;
4120 vtable->vaQueryConfigProfiles = i965_QueryConfigProfiles;
4121 vtable->vaQueryConfigEntrypoints = i965_QueryConfigEntrypoints;
4122 vtable->vaQueryConfigAttributes = i965_QueryConfigAttributes;
4123 vtable->vaCreateConfig = i965_CreateConfig;
4124 vtable->vaDestroyConfig = i965_DestroyConfig;
4125 vtable->vaGetConfigAttributes = i965_GetConfigAttributes;
4126 vtable->vaCreateSurfaces = i965_CreateSurfaces;
4127 vtable->vaDestroySurfaces = i965_DestroySurfaces;
4128 vtable->vaCreateContext = i965_CreateContext;
4129 vtable->vaDestroyContext = i965_DestroyContext;
4130 vtable->vaCreateBuffer = i965_CreateBuffer;
4131 vtable->vaBufferSetNumElements = i965_BufferSetNumElements;
4132 vtable->vaMapBuffer = i965_MapBuffer;
4133 vtable->vaUnmapBuffer = i965_UnmapBuffer;
4134 vtable->vaDestroyBuffer = i965_DestroyBuffer;
4135 vtable->vaBeginPicture = i965_BeginPicture;
4136 vtable->vaRenderPicture = i965_RenderPicture;
4137 vtable->vaEndPicture = i965_EndPicture;
4138 vtable->vaSyncSurface = i965_SyncSurface;
4139 vtable->vaQuerySurfaceStatus = i965_QuerySurfaceStatus;
4140 vtable->vaPutSurface = i965_PutSurface;
4141 vtable->vaQueryImageFormats = i965_QueryImageFormats;
4142 vtable->vaCreateImage = i965_CreateImage;
4143 vtable->vaDeriveImage = i965_DeriveImage;
4144 vtable->vaDestroyImage = i965_DestroyImage;
4145 vtable->vaSetImagePalette = i965_SetImagePalette;
4146 vtable->vaGetImage = i965_GetImage;
4147 vtable->vaPutImage = i965_PutImage;
4148 vtable->vaQuerySubpictureFormats = i965_QuerySubpictureFormats;
4149 vtable->vaCreateSubpicture = i965_CreateSubpicture;
4150 vtable->vaDestroySubpicture = i965_DestroySubpicture;
4151 vtable->vaSetSubpictureImage = i965_SetSubpictureImage;
4152 vtable->vaSetSubpictureChromakey = i965_SetSubpictureChromakey;
4153 vtable->vaSetSubpictureGlobalAlpha = i965_SetSubpictureGlobalAlpha;
4154 vtable->vaAssociateSubpicture = i965_AssociateSubpicture;
4155 vtable->vaDeassociateSubpicture = i965_DeassociateSubpicture;
4156 vtable->vaQueryDisplayAttributes = i965_QueryDisplayAttributes;
4157 vtable->vaGetDisplayAttributes = i965_GetDisplayAttributes;
4158 vtable->vaSetDisplayAttributes = i965_SetDisplayAttributes;
4159 vtable->vaBufferInfo = i965_BufferInfo;
4160 vtable->vaLockSurface = i965_LockSurface;
4161 vtable->vaUnlockSurface = i965_UnlockSurface;
4162 vtable->vaGetSurfaceAttributes = i965_GetSurfaceAttributes;
4163 vtable->vaCreateSurfaces2 = i965_CreateSurfaces2;
4165 vtable_vpp->vaQueryVideoProcFilters = i965_QueryVideoProcFilters;
4166 vtable_vpp->vaQueryVideoProcFilterCaps = i965_QueryVideoProcFilterCaps;
4167 vtable_vpp->vaQueryVideoProcPipelineCaps = i965_QueryVideoProcPipelineCaps;
4169 i965 = (struct i965_driver_data *)calloc(1, sizeof(*i965));
4171 ctx->pDriverData = (void *)i965;
4173 result = object_heap_init(&i965->config_heap,
4174 sizeof(struct object_config),
4176 assert(result == 0);
4178 result = object_heap_init(&i965->context_heap,
4179 sizeof(struct object_context),
4181 assert(result == 0);
4183 result = object_heap_init(&i965->surface_heap,
4184 sizeof(struct object_surface),
4186 assert(result == 0);
4188 result = object_heap_init(&i965->buffer_heap,
4189 sizeof(struct object_buffer),
4191 assert(result == 0);
4193 result = object_heap_init(&i965->image_heap,
4194 sizeof(struct object_image),
4196 assert(result == 0);
4198 result = object_heap_init(&i965->subpic_heap,
4199 sizeof(struct object_subpic),
4201 assert(result == 0);
4203 sprintf(i965->va_vendor, "%s %s driver - %d.%d.%d",
4204 INTEL_STR_DRIVER_VENDOR,
4205 INTEL_STR_DRIVER_NAME,
4206 INTEL_DRIVER_MAJOR_VERSION,
4207 INTEL_DRIVER_MINOR_VERSION,
4208 INTEL_DRIVER_MICRO_VERSION);
4210 if (INTEL_DRIVER_PRE_VERSION > 0) {
4211 const int len = strlen(i965->va_vendor);
4212 sprintf(&i965->va_vendor[len], ".pre%d", INTEL_DRIVER_PRE_VERSION);
4215 i965->current_context_id = VA_INVALID_ID;
4217 ctx->str_vendor = i965->va_vendor;
4219 return i965_Init(ctx);