1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Rockchip Video Decoder driver
5 * Copyright (C) 2019 Collabora, Ltd.
7 * Based on rkvdec driver by Google LLC. (Tomasz Figa <tfiga@chromium.org>)
8 * Based on s5p-mfc driver by Samsung Electronics Co., Ltd.
9 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
14 #include <linux/platform_device.h>
15 #include <linux/videodev2.h>
16 #include <linux/wait.h>
17 #include <linux/clk.h>
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>
27 struct rkvdec_ctrl_desc {
29 struct v4l2_ctrl_config cfg;
33 const struct rkvdec_ctrl_desc *ctrls;
34 unsigned int num_ctrls;
39 struct vb2_v4l2_buffer *src;
40 struct vb2_v4l2_buffer *dst;
44 struct rkvdec_vp9_decoded_buffer_info {
45 /* Info needed when the decoded frame serves as a reference frame. */
51 struct rkvdec_decoded_buffer {
52 /* Must be the first field in this struct. */
53 struct v4l2_m2m_buffer base;
56 static inline struct rkvdec_decoded_buffer *
57 vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf)
59 return container_of(buf, struct rkvdec_decoded_buffer,
63 struct 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);
74 struct rkvdec_coded_fmt_desc {
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;
84 struct v4l2_device v4l2_dev;
85 struct media_device mdev;
86 struct video_device vdev;
87 struct v4l2_m2m_dev *m2m_dev;
89 struct clk_bulk_data *clocks;
91 struct mutex vdev_lock; /* serializes ioctls */
92 struct delayed_work watchdog_work;
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;
105 static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh)
107 return container_of(fh, struct rkvdec_ctx, fh);
110 struct rkvdec_aux_buf {
116 void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run);
117 void rkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run);
119 extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops;
120 #endif /* RKVDEC_H_ */