2 * Rockchip RK3288 VPU codec driver
4 * Copyright (C) 2014 Google, Inc.
5 * Tomasz Figa <tfiga@chromium.org>
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #ifndef RK3288_VPU_HW_H_
18 #define RK3288_VPU_HW_H_
20 #include <media/videobuf2-core.h>
22 #define RK3288_HEADER_SIZE 256
23 #define RK3288_HW_PARAMS_SIZE 5487
24 #define RK3288_RET_PARAMS_SIZE 488
26 struct rk3288_vpu_dev;
27 struct rk3288_vpu_ctx;
28 struct rk3288_vpu_buf;
30 struct rk3288_vpu_h264d_priv_tbl;
33 * enum rk3288_vpu_enc_fmt - source format ID for hardware registers.
35 enum rk3288_vpu_enc_fmt {
36 RK3288_VPU_ENC_FMT_YUV420P = 0,
37 RK3288_VPU_ENC_FMT_YUV420SP = 1,
38 RK3288_VPU_ENC_FMT_YUYV422 = 2,
39 RK3288_VPU_ENC_FMT_UYVY422 = 3,
43 * struct rk3288_vp8e_reg_params - low level encoding parameters
44 * TODO: Create abstract structures for more generic controls or just
45 * remove unused fields.
47 struct rk3288_vp8e_reg_params {
82 u32 dmv_4p_1p_penalty[32];
83 u32 dmv_qpel_penalty[32];
86 u32 loop_flt_delta[2];
90 * struct rk3288_vpu_aux_buf - auxiliary DMA buffer for hardware data
91 * @cpu: CPU pointer to the buffer.
92 * @dma: DMA address of the buffer.
93 * @size: Size of the buffer.
95 struct rk3288_vpu_aux_buf {
102 * struct rk3288_vpu_vp8e_hw_ctx - Context private data specific to codec mode.
103 * @ctrl_buf: VP8 control buffer.
104 * @ext_buf: VP8 ext data buffer.
105 * @mv_buf: VP8 motion vector buffer.
106 * @ref_rec_ptr: Bit flag for swapping ref and rec buffers every frame.
108 struct rk3288_vpu_vp8e_hw_ctx {
109 struct rk3288_vpu_aux_buf ctrl_buf;
110 struct rk3288_vpu_aux_buf ext_buf;
111 struct rk3288_vpu_aux_buf mv_buf;
116 * struct rk3288_vpu_vp8d_hw_ctx - Context private data of VP8 decoder.
117 * @segment_map: Segment map buffer.
118 * @prob_tbl: Probability table buffer.
120 struct rk3288_vpu_vp8d_hw_ctx {
121 struct rk3288_vpu_aux_buf segment_map;
122 struct rk3288_vpu_aux_buf prob_tbl;
126 * struct rk3288_vpu_h264d_hw_ctx - Per context data specific to H264 decoding.
127 * @priv_tbl: Private auxiliary buffer for hardware.
129 struct rk3288_vpu_h264d_hw_ctx {
130 struct rk3288_vpu_aux_buf priv_tbl;
134 * struct rk3288_vpu_hw_ctx - Context private data of hardware code.
135 * @codec_ops: Set of operations associated with current codec mode.
137 struct rk3288_vpu_hw_ctx {
138 const struct rk3288_vpu_codec_ops *codec_ops;
140 /* Specific for particular codec modes. */
142 struct rk3288_vpu_vp8e_hw_ctx vp8e;
143 struct rk3288_vpu_vp8d_hw_ctx vp8d;
144 struct rk3288_vpu_h264d_hw_ctx h264d;
145 /* Other modes will need different data. */
149 int rk3288_vpu_hw_probe(struct rk3288_vpu_dev *vpu);
150 void rk3288_vpu_hw_remove(struct rk3288_vpu_dev *vpu);
152 int rk3288_vpu_init(struct rk3288_vpu_ctx *ctx);
153 void rk3288_vpu_deinit(struct rk3288_vpu_ctx *ctx);
155 void rk3288_vpu_run(struct rk3288_vpu_ctx *ctx);
157 /* Run ops for H264 decoder */
158 int rk3288_vpu_h264d_init(struct rk3288_vpu_ctx *ctx);
159 void rk3288_vpu_h264d_exit(struct rk3288_vpu_ctx *ctx);
160 void rk3288_vpu_h264d_run(struct rk3288_vpu_ctx *ctx);
161 void rk3288_vpu_power_on(struct rk3288_vpu_dev *vpu);
163 /* Run ops for VP8 decoder */
164 int rk3288_vpu_vp8d_init(struct rk3288_vpu_ctx *ctx);
165 void rk3288_vpu_vp8d_exit(struct rk3288_vpu_ctx *ctx);
166 void rk3288_vpu_vp8d_run(struct rk3288_vpu_ctx *ctx);
168 /* Run ops for VP8 encoder */
169 int rk3288_vpu_vp8e_init(struct rk3288_vpu_ctx *ctx);
170 void rk3288_vpu_vp8e_exit(struct rk3288_vpu_ctx *ctx);
171 void rk3288_vpu_vp8e_run(struct rk3288_vpu_ctx *ctx);
172 void rk3288_vpu_vp8e_done(struct rk3288_vpu_ctx *ctx,
173 enum vb2_buffer_state result);
175 void rk3288_vpu_vp8e_assemble_bitstream(struct rk3288_vpu_ctx *ctx,
176 struct rk3288_vpu_buf *dst_buf);
178 #endif /* RK3288_VPU_HW_H_ */