1bf215546Sopenharmony_ci/**************************************************************************
2bf215546Sopenharmony_ci *
3bf215546Sopenharmony_ci * Copyright 2017 Advanced Micro Devices, Inc.
4bf215546Sopenharmony_ci * All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the
8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to
11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
12bf215546Sopenharmony_ci * the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
16bf215546Sopenharmony_ci * of the Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21bf215546Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci **************************************************************************/
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#ifndef _RADEON_VCN_DEC_H
29bf215546Sopenharmony_ci#define _RADEON_VCN_DEC_H
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "radeon_vcn.h"
32bf215546Sopenharmony_ci#include "util/list.h"
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci#include "ac_vcn_dec.h"
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci#define NUM_BUFFERS                                         4
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_cistruct rvcn_dec_dynamic_dpb_t2 {
39bf215546Sopenharmony_ci   struct list_head list;
40bf215546Sopenharmony_ci   uint8_t index;
41bf215546Sopenharmony_ci   struct rvid_buffer dpb;
42bf215546Sopenharmony_ci};
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_cistruct radeon_decoder {
45bf215546Sopenharmony_ci   struct pipe_video_codec base;
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci   unsigned stream_handle;
48bf215546Sopenharmony_ci   unsigned stream_type;
49bf215546Sopenharmony_ci   unsigned frame_number;
50bf215546Sopenharmony_ci   unsigned db_alignment;
51bf215546Sopenharmony_ci   unsigned dpb_size;
52bf215546Sopenharmony_ci   unsigned last_width;
53bf215546Sopenharmony_ci   unsigned last_height;
54bf215546Sopenharmony_ci   unsigned addr_gfx_mode;
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci   struct pipe_screen *screen;
57bf215546Sopenharmony_ci   struct radeon_winsys *ws;
58bf215546Sopenharmony_ci   struct radeon_cmdbuf cs;
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci   void *msg;
61bf215546Sopenharmony_ci   uint32_t *fb;
62bf215546Sopenharmony_ci   uint8_t *it;
63bf215546Sopenharmony_ci   uint8_t *probs;
64bf215546Sopenharmony_ci   void *bs_ptr;
65bf215546Sopenharmony_ci   rvcn_decode_buffer_t *decode_buffer;
66bf215546Sopenharmony_ci   bool vcn_dec_sw_ring;
67bf215546Sopenharmony_ci   struct rvcn_sq_var sq;
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci   struct rvid_buffer msg_fb_it_probs_buffers[NUM_BUFFERS];
70bf215546Sopenharmony_ci   struct rvid_buffer bs_buffers[NUM_BUFFERS];
71bf215546Sopenharmony_ci   struct rvid_buffer dpb;
72bf215546Sopenharmony_ci   struct rvid_buffer ctx;
73bf215546Sopenharmony_ci   struct rvid_buffer sessionctx;
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   unsigned bs_size;
76bf215546Sopenharmony_ci   unsigned cur_buffer;
77bf215546Sopenharmony_ci   void *render_pic_list[32];
78bf215546Sopenharmony_ci   unsigned h264_valid_ref_num[17];
79bf215546Sopenharmony_ci   unsigned h264_valid_poc_num[34];
80bf215546Sopenharmony_ci   unsigned av1_version;
81bf215546Sopenharmony_ci   bool show_frame;
82bf215546Sopenharmony_ci   unsigned ref_idx;
83bf215546Sopenharmony_ci   bool tmz_ctx;
84bf215546Sopenharmony_ci   struct {
85bf215546Sopenharmony_ci      unsigned data0;
86bf215546Sopenharmony_ci      unsigned data1;
87bf215546Sopenharmony_ci      unsigned cmd;
88bf215546Sopenharmony_ci      unsigned cntl;
89bf215546Sopenharmony_ci   } reg;
90bf215546Sopenharmony_ci   struct jpeg_params jpg;
91bf215546Sopenharmony_ci   enum {
92bf215546Sopenharmony_ci      DPB_MAX_RES = 0,
93bf215546Sopenharmony_ci      DPB_DYNAMIC_TIER_1,
94bf215546Sopenharmony_ci      DPB_DYNAMIC_TIER_2
95bf215546Sopenharmony_ci   } dpb_type;
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci   struct {
98bf215546Sopenharmony_ci      enum {
99bf215546Sopenharmony_ci         CODEC_8_BITS = 0,
100bf215546Sopenharmony_ci         CODEC_10_BITS
101bf215546Sopenharmony_ci      } bts;
102bf215546Sopenharmony_ci      uint8_t index;
103bf215546Sopenharmony_ci      unsigned ref_size;
104bf215546Sopenharmony_ci      uint8_t ref_list[16];
105bf215546Sopenharmony_ci   } ref_codec;
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci   struct list_head dpb_ref_list;
108bf215546Sopenharmony_ci   struct list_head dpb_unref_list;
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci   void (*send_cmd)(struct radeon_decoder *dec, struct pipe_video_buffer *target,
111bf215546Sopenharmony_ci                    struct pipe_picture_desc *picture);
112bf215546Sopenharmony_ci   /* Additional contexts for mJPEG */
113bf215546Sopenharmony_ci   struct radeon_cmdbuf *jcs;
114bf215546Sopenharmony_ci   struct radeon_winsys_ctx **jctx;
115bf215546Sopenharmony_ci   unsigned cb_idx;
116bf215546Sopenharmony_ci   unsigned njctx;
117bf215546Sopenharmony_ci};
118bf215546Sopenharmony_ci
119bf215546Sopenharmony_civoid send_cmd_dec(struct radeon_decoder *dec, struct pipe_video_buffer *target,
120bf215546Sopenharmony_ci                  struct pipe_picture_desc *picture);
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_civoid send_cmd_jpeg(struct radeon_decoder *dec, struct pipe_video_buffer *target,
123bf215546Sopenharmony_ci                   struct pipe_picture_desc *picture);
124bf215546Sopenharmony_ci
125bf215546Sopenharmony_cistruct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
126bf215546Sopenharmony_ci                                               const struct pipe_video_codec *templat);
127bf215546Sopenharmony_ci
128bf215546Sopenharmony_ci#endif
129