radeon/video: directly create buffers in the right domain
[mesa.git] / src / gallium / drivers / radeon / radeon_video.h
1 /**************************************************************************
2 *
3 * Copyright 2013 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Christian König <christian.koenig@amd.com>
31 *
32 */
33
34 #ifndef RADEON_VIDEO_H
35 #define RADEON_VIDEO_H
36
37 #include "../../winsys/radeon/drm/radeon_winsys.h"
38 #include "vl/vl_video_buffer.h"
39
40 #define RVID_ERR(fmt, args...) \
41 fprintf(stderr, "EE %s:%d %s UVD - "fmt, __FILE__, __LINE__, __func__, ##args)
42
43 /* video buffer representation */
44 struct rvid_buffer
45 {
46 enum radeon_bo_domain domain;
47 struct pb_buffer* buf;
48 struct radeon_winsys_cs_handle* cs_handle;
49 };
50
51 /* generate an stream handle */
52 unsigned rvid_alloc_stream_handle(void);
53
54 /* create a buffer in the winsys */
55 bool rvid_create_buffer(struct radeon_winsys *ws, struct rvid_buffer *buffer,
56 unsigned size, enum radeon_bo_domain domain);
57
58 /* destroy a buffer */
59 void rvid_destroy_buffer(struct rvid_buffer *buffer);
60
61 /* reallocate a buffer, preserving its content */
62 bool rvid_resize_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs,
63 struct rvid_buffer *new_buf, unsigned new_size);
64
65 /* clear the buffer with zeros */
66 void rvid_clear_buffer(struct radeon_winsys *ws, struct radeon_winsys_cs *cs, struct rvid_buffer* buffer);
67
68 /* join surfaces into the same buffer with identical tiling params
69 sumup their sizes and replace the backend buffers with a single bo */
70 void rvid_join_surfaces(struct radeon_winsys* ws, unsigned bind,
71 struct pb_buffer** buffers[VL_NUM_COMPONENTS],
72 struct radeon_surface *surfaces[VL_NUM_COMPONENTS]);
73
74 /* returns supported codecs and other parameters */
75 int rvid_get_video_param(struct pipe_screen *screen,
76 enum pipe_video_profile profile,
77 enum pipe_video_entrypoint entrypoint,
78 enum pipe_video_cap param);
79
80 /* the hardware only supports NV12 */
81 boolean rvid_is_format_supported(struct pipe_screen *screen,
82 enum pipe_format format,
83 enum pipe_video_profile profile,
84 enum pipe_video_entrypoint entrypoint);
85
86 #endif // RADEON_VIDEO_H