2 * Copyright (C) 2012 Intel Corporation. All Rights Reserved.
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.
28 #include <va/va_dricommon.h>
29 #include "i965_drv_video.h"
30 #include "i965_output_dri.h"
33 i965_output_dri_init(VADriverContextP ctx)
39 i965_output_dri_terminate(VADriverContextP ctx)
48 const VARectangle *src_rect,
49 const VARectangle *dst_rect,
50 const VARectangle *cliprects,
51 unsigned int num_cliprects,
55 struct i965_driver_data * const i965 = i965_driver_data(ctx);
56 struct dri_state * const dri_state = (struct dri_state *)ctx->drm_state;
57 struct i965_render_state * const render_state = &i965->render_state;
58 struct dri_drawable *dri_drawable;
59 union dri_buffer *buffer;
60 struct intel_region *dest_region;
61 struct object_surface *obj_surface;
62 unsigned int pp_flag = 0;
63 bool new_region = false;
67 /* Currently don't support DRI1 */
68 if (dri_state->base.auth_type != VA_DRM_AUTH_DRI2)
69 return VA_STATUS_ERROR_UNKNOWN;
71 /* Some broken sources such as H.264 conformance case FM2_SVA_C
74 obj_surface = SURFACE(surface);
75 if (!obj_surface || !obj_surface->bo)
76 return VA_STATUS_SUCCESS;
78 _i965LockMutex(&i965->render_mutex);
80 dri_drawable = dri_get_drawable(ctx, (Drawable)draw);
83 buffer = dri_get_rendering_buffer(ctx, dri_drawable);
86 dest_region = render_state->draw_region;
89 assert(dest_region->bo);
90 dri_bo_flink(dest_region->bo, &name);
92 if (buffer->dri2.name != name) {
94 dri_bo_unreference(dest_region->bo);
97 dest_region = (struct intel_region *)calloc(1, sizeof(*dest_region));
99 render_state->draw_region = dest_region;
104 dest_region->x = dri_drawable->x;
105 dest_region->y = dri_drawable->y;
106 dest_region->width = dri_drawable->width;
107 dest_region->height = dri_drawable->height;
108 dest_region->cpp = buffer->dri2.cpp;
109 dest_region->pitch = buffer->dri2.pitch;
111 dest_region->bo = intel_bo_gem_create_from_name(i965->intel.bufmgr, "rendering buffer", buffer->dri2.name);
112 assert(dest_region->bo);
114 ret = dri_bo_get_tiling(dest_region->bo, &(dest_region->tiling), &(dest_region->swizzle));
118 if ((flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC)
119 pp_flag |= I965_PP_FLAG_AVS;
121 if (flags & VA_TOP_FIELD)
122 pp_flag |= I965_PP_FLAG_TOP_FIELD;
123 else if (flags & VA_BOTTOM_FIELD)
124 pp_flag |= I965_PP_FLAG_BOTTOM_FIELD;
126 intel_render_put_surface(ctx, surface, src_rect, dst_rect, pp_flag);
128 if(obj_surface->subpic != VA_INVALID_ID) {
129 intel_render_put_subpicture(ctx, surface, src_rect, dst_rect);
132 dri_swap_buffer(ctx, dri_drawable);
133 obj_surface->flags |= SURFACE_DISPLAYED;
135 if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
136 dri_bo_unreference(obj_surface->bo);
137 obj_surface->bo = NULL;
138 obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
140 if (obj_surface->free_private_data)
141 obj_surface->free_private_data(&obj_surface->private_data);
144 _i965UnlockMutex(&i965->render_mutex);
146 return VA_STATUS_SUCCESS;