1848b8605Smrg/**************************************************************************
2848b8605Smrg *
3848b8605Smrg * Copyright 2013 Advanced Micro Devices, Inc.
4848b8605Smrg * All Rights Reserved.
5848b8605Smrg *
6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7848b8605Smrg * copy of this software and associated documentation files (the
8848b8605Smrg * "Software"), to deal in the Software without restriction, including
9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish,
10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to
11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to
12848b8605Smrg * the following conditions:
13848b8605Smrg *
14848b8605Smrg * The above copyright notice and this permission notice (including the
15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions
16848b8605Smrg * of the Software.
17848b8605Smrg *
18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21848b8605Smrg * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25848b8605Smrg *
26848b8605Smrg **************************************************************************/
27848b8605Smrg
28848b8605Smrg#ifndef RADEON_VIDEO_H
29848b8605Smrg#define RADEON_VIDEO_H
30848b8605Smrg
31b8e80941Smrg#include "radeon/radeon_winsys.h"
32848b8605Smrg#include "vl/vl_video_buffer.h"
33848b8605Smrg
34848b8605Smrg#define RVID_ERR(fmt, args...) \
35848b8605Smrg	fprintf(stderr, "EE %s:%d %s UVD - "fmt, __FILE__, __LINE__, __func__, ##args)
36848b8605Smrg
37b8e80941Smrg#define UVD_FW_1_66_16 ((1 << 24) | (66 << 16) | (16 << 8))
38b8e80941Smrg
39848b8605Smrg/* video buffer representation */
40848b8605Smrgstruct rvid_buffer
41848b8605Smrg{
42b8e80941Smrg	unsigned		usage;
43b8e80941Smrg	struct si_resource	*res;
44848b8605Smrg};
45848b8605Smrg
46848b8605Smrg/* generate an stream handle */
47b8e80941Smrgunsigned si_vid_alloc_stream_handle(void);
48848b8605Smrg
49848b8605Smrg/* create a buffer in the winsys */
50b8e80941Smrgbool si_vid_create_buffer(struct pipe_screen *screen, struct rvid_buffer *buffer,
51b8e80941Smrg			  unsigned size, unsigned usage);
52848b8605Smrg
53848b8605Smrg/* destroy a buffer */
54b8e80941Smrgvoid si_vid_destroy_buffer(struct rvid_buffer *buffer);
55848b8605Smrg
56848b8605Smrg/* reallocate a buffer, preserving its content */
57b8e80941Smrgbool si_vid_resize_buffer(struct pipe_screen *screen, struct radeon_cmdbuf *cs,
58b8e80941Smrg			  struct rvid_buffer *new_buf, unsigned new_size);
59848b8605Smrg
60848b8605Smrg/* clear the buffer with zeros */
61b8e80941Smrgvoid si_vid_clear_buffer(struct pipe_context *context, struct rvid_buffer* buffer);
62848b8605Smrg
63848b8605Smrg/* join surfaces into the same buffer with identical tiling params
64848b8605Smrg   sumup their sizes and replace the backend buffers with a single bo */
65b8e80941Smrgvoid si_vid_join_surfaces(struct si_context *sctx,
66b8e80941Smrg			  struct pb_buffer** buffers[VL_NUM_COMPONENTS],
67b8e80941Smrg			  struct radeon_surf *surfaces[VL_NUM_COMPONENTS]);
68848b8605Smrg
69848b8605Smrg#endif // RADEON_VIDEO_H
70