1 /**************************************************************************
3 * Copyright 2015 Advanced Micro Devices, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "util/u_handle_table.h"
30 #include "va_private.h"
32 static const VARectangle
*
33 vlVaRegionDefault(const VARectangle
*region
, struct pipe_video_buffer
*buf
,
41 def
->width
= buf
->width
;
42 def
->height
= buf
->height
;
48 vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver
*drv
, vlVaContext
*context
, vlVaBuffer
*buf
)
50 VARectangle def_src_region
, def_dst_region
;
51 const VARectangle
*src_region
, *dst_region
;
52 struct u_rect src_rect
;
53 struct u_rect dst_rect
;
54 vlVaSurface
*src_surface
;
55 VAProcPipelineParameterBuffer
*pipeline_param
;
56 struct pipe_surface
**surfaces
;
57 struct pipe_surface
*psurf
;
60 return VA_STATUS_ERROR_INVALID_CONTEXT
;
62 if (!buf
|| !buf
->data
)
63 return VA_STATUS_ERROR_INVALID_BUFFER
;
66 return VA_STATUS_ERROR_INVALID_SURFACE
;
68 pipeline_param
= (VAProcPipelineParameterBuffer
*)buf
->data
;
70 src_surface
= handle_table_get(drv
->htab
, pipeline_param
->surface
);
71 if (!src_surface
|| !src_surface
->buffer
)
72 return VA_STATUS_ERROR_INVALID_SURFACE
;
74 surfaces
= context
->target
->get_surfaces(context
->target
);
76 if (!surfaces
|| !surfaces
[0])
77 return VA_STATUS_ERROR_INVALID_SURFACE
;
81 src_region
= vlVaRegionDefault(pipeline_param
->surface_region
, src_surface
->buffer
, &def_src_region
);
82 dst_region
= vlVaRegionDefault(pipeline_param
->output_region
, context
->target
, &def_dst_region
);
84 src_rect
.x0
= src_region
->x
;
85 src_rect
.y0
= src_region
->y
;
86 src_rect
.x1
= src_region
->x
+ src_region
->width
;
87 src_rect
.y1
= src_region
->y
+ src_region
->height
;
89 dst_rect
.x0
= dst_region
->x
;
90 dst_rect
.y0
= dst_region
->y
;
91 dst_rect
.x1
= dst_region
->x
+ dst_region
->width
;
92 dst_rect
.y1
= dst_region
->y
+ dst_region
->height
;
94 vl_compositor_clear_layers(&drv
->cstate
);
95 vl_compositor_set_buffer_layer(&drv
->cstate
, &drv
->compositor
, 0, src_surface
->buffer
, &src_rect
, NULL
, VL_COMPOSITOR_WEAVE
);
96 vl_compositor_set_layer_dst_area(&drv
->cstate
, 0, &dst_rect
);
97 vl_compositor_render(&drv
->cstate
, &drv
->compositor
, psurf
, NULL
, false);
99 // TODO: figure out why this is necessary for DMA-buf sharing
100 drv
->pipe
->flush(drv
->pipe
, NULL
, 0);
102 return VA_STATUS_SUCCESS
;