1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Hantro VPU codec driver
5 * Copyright 2018 Google LLC.
6 * Tomasz Figa <tfiga@chromium.org>
12 #include <linux/interrupt.h>
13 #include <linux/v4l2-controls.h>
14 #include <media/mpeg2-ctrls.h>
15 #include <media/videobuf2-core.h>
20 struct hantro_variant;
23 * struct hantro_aux_buf - auxiliary DMA buffer for hardware data
24 * @cpu: CPU pointer to the buffer.
25 * @dma: DMA address of the buffer.
26 * @size: Size of the buffer.
28 struct hantro_aux_buf {
35 * struct hantro_jpeg_enc_hw_ctx
36 * @bounce_buffer: Bounce buffer
38 struct hantro_jpeg_enc_hw_ctx {
39 struct hantro_aux_buf bounce_buffer;
43 * struct hantro_mpeg2_dec_hw_ctx
44 * @qtable: Quantization table
46 struct hantro_mpeg2_dec_hw_ctx {
47 struct hantro_aux_buf qtable;
51 * struct hantro_codec_ops - codec mode specific operations
53 * @init: If needed, can be used for initialization.
54 * Optional and called from process context.
55 * @exit: If needed, can be used to undo the .init phase.
56 * Optional and called from process context.
57 * @run: Start single {en,de)coding job. Called from atomic context
58 * to indicate that a pair of buffers is ready and the hardware
59 * should be programmed and started.
60 * @done: Read back processing results and additional data from hardware.
61 * @reset: Reset the hardware in case of a timeout.
63 struct hantro_codec_ops {
64 int (*init)(struct hantro_ctx *ctx);
65 void (*exit)(struct hantro_ctx *ctx);
66 void (*run)(struct hantro_ctx *ctx);
67 void (*done)(struct hantro_ctx *ctx, enum vb2_buffer_state);
68 void (*reset)(struct hantro_ctx *ctx);
72 * enum hantro_enc_fmt - source format ID for hardware registers.
75 RK3288_VPU_ENC_FMT_YUV420P = 0,
76 RK3288_VPU_ENC_FMT_YUV420SP = 1,
77 RK3288_VPU_ENC_FMT_YUYV422 = 2,
78 RK3288_VPU_ENC_FMT_UYVY422 = 3,
81 extern const struct hantro_variant rk3399_vpu_variant;
82 extern const struct hantro_variant rk3328_vpu_variant;
83 extern const struct hantro_variant rk3288_vpu_variant;
85 void hantro_watchdog(struct work_struct *work);
86 void hantro_run(struct hantro_ctx *ctx);
87 void hantro_irq_done(struct hantro_dev *vpu, unsigned int bytesused,
88 enum vb2_buffer_state result);
90 void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx);
91 void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx);
92 int hantro_jpeg_enc_init(struct hantro_ctx *ctx);
93 void hantro_jpeg_enc_exit(struct hantro_ctx *ctx);
95 void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx);
96 void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx);
97 void hantro_mpeg2_dec_copy_qtable(u8 *qtable,
98 const struct v4l2_ctrl_mpeg2_quantization *ctrl);
99 int hantro_mpeg2_dec_init(struct hantro_ctx *ctx);
100 void hantro_mpeg2_dec_exit(struct hantro_ctx *ctx);
102 #endif /* HANTRO_HW_H_ */