]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/staging/media/hantro/hantro_hw.h
Linux 5.3-rc4
[linux.git] / drivers / staging / media / hantro / hantro_hw.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Hantro VPU codec driver
4  *
5  * Copyright 2018 Google LLC.
6  *      Tomasz Figa <tfiga@chromium.org>
7  */
8
9 #ifndef HANTRO_HW_H_
10 #define HANTRO_HW_H_
11
12 #include <linux/interrupt.h>
13 #include <linux/v4l2-controls.h>
14 #include <media/mpeg2-ctrls.h>
15 #include <media/videobuf2-core.h>
16
17 struct hantro_dev;
18 struct hantro_ctx;
19 struct hantro_buf;
20 struct hantro_variant;
21
22 /**
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.
27  */
28 struct hantro_aux_buf {
29         void *cpu;
30         dma_addr_t dma;
31         size_t size;
32 };
33
34 /**
35  * struct hantro_jpeg_enc_hw_ctx
36  * @bounce_buffer:      Bounce buffer
37  */
38 struct hantro_jpeg_enc_hw_ctx {
39         struct hantro_aux_buf bounce_buffer;
40 };
41
42 /**
43  * struct hantro_mpeg2_dec_hw_ctx
44  * @qtable:             Quantization table
45  */
46 struct hantro_mpeg2_dec_hw_ctx {
47         struct hantro_aux_buf qtable;
48 };
49
50 /**
51  * struct hantro_codec_ops - codec mode specific operations
52  *
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.
62  */
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);
69 };
70
71 /**
72  * enum hantro_enc_fmt - source format ID for hardware registers.
73  */
74 enum hantro_enc_fmt {
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,
79 };
80
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;
84
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);
89
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);
94
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);
101
102 #endif /* HANTRO_HW_H_ */