1
2
3
4
5
6
7
8
9
10
11#ifndef RKVDEC_H_
12#define RKVDEC_H_
13
14#include <linux/platform_device.h>
15#include <linux/videodev2.h>
16#include <linux/wait.h>
17#include <linux/clk.h>
18
19#include <media/v4l2-ctrls.h>
20#include <media/v4l2-device.h>
21#include <media/v4l2-ioctl.h>
22#include <media/videobuf2-core.h>
23#include <media/videobuf2-dma-contig.h>
24
25struct rkvdec_ctx;
26
27struct rkvdec_ctrl_desc {
28 u32 mandatory : 1;
29 struct v4l2_ctrl_config cfg;
30};
31
32struct rkvdec_ctrls {
33 const struct rkvdec_ctrl_desc *ctrls;
34 unsigned int num_ctrls;
35};
36
37struct rkvdec_run {
38 struct {
39 struct vb2_v4l2_buffer *src;
40 struct vb2_v4l2_buffer *dst;
41 } bufs;
42};
43
44struct rkvdec_vp9_decoded_buffer_info {
45
46 u16 width;
47 u16 height;
48 u32 bit_depth : 4;
49};
50
51struct rkvdec_decoded_buffer {
52
53 struct v4l2_m2m_buffer base;
54};
55
56static inline struct rkvdec_decoded_buffer *
57vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf)
58{
59 return container_of(buf, struct rkvdec_decoded_buffer,
60 base.vb.vb2_buf);
61}
62
63struct rkvdec_coded_fmt_ops {
64 int (*adjust_fmt)(struct rkvdec_ctx *ctx,
65 struct v4l2_format *f);
66 int (*start)(struct rkvdec_ctx *ctx);
67 void (*stop)(struct rkvdec_ctx *ctx);
68 int (*run)(struct rkvdec_ctx *ctx);
69 void (*done)(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf,
70 struct vb2_v4l2_buffer *dst_buf,
71 enum vb2_buffer_state result);
72};
73
74struct rkvdec_coded_fmt_desc {
75 u32 fourcc;
76 struct v4l2_frmsize_stepwise frmsize;
77 const struct rkvdec_ctrls *ctrls;
78 const struct rkvdec_coded_fmt_ops *ops;
79 unsigned int num_decoded_fmts;
80 const u32 *decoded_fmts;
81};
82
83struct rkvdec_dev {
84 struct v4l2_device v4l2_dev;
85 struct media_device mdev;
86 struct video_device vdev;
87 struct v4l2_m2m_dev *m2m_dev;
88 struct device *dev;
89 struct clk_bulk_data *clocks;
90 void __iomem *regs;
91 struct mutex vdev_lock;
92 struct delayed_work watchdog_work;
93};
94
95struct rkvdec_ctx {
96 struct v4l2_fh fh;
97 struct v4l2_format coded_fmt;
98 struct v4l2_format decoded_fmt;
99 const struct rkvdec_coded_fmt_desc *coded_fmt_desc;
100 struct v4l2_ctrl_handler ctrl_hdl;
101 struct rkvdec_dev *dev;
102 void *priv;
103};
104
105static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh)
106{
107 return container_of(fh, struct rkvdec_ctx, fh);
108}
109
110struct rkvdec_aux_buf {
111 void *cpu;
112 dma_addr_t dma;
113 size_t size;
114};
115
116void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run);
117void rkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run);
118
119extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops;
120#endif
121