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