FILE
rkvdec.h
File preview with syntax highlighting.
linux-6.19.14/drivers/media/platform/rockchip/rkvdec/rkvdec.h
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Rockchip Video Decoder driver 4 * 5 * Copyright (C) 2019 Collabora, Ltd. 6 * 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. 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 25#define RKVDEC_CAPABILITY_HEVC BIT(0) 26#define RKVDEC_CAPABILITY_H264 BIT(1) 27#define RKVDEC_CAPABILITY_VP9 BIT(2) 28 29#define RKVDEC_QUIRK_DISABLE_QOS BIT(0) 30 31struct rkvdec_ctx; 32 33struct rkvdec_ctrl_desc { 34 struct v4l2_ctrl_config cfg; 35}; 36 37struct rkvdec_ctrls { 38 const struct rkvdec_ctrl_desc *ctrls; 39 unsigned int num_ctrls; 40}; 41 42struct rkvdec_run { 43 struct { 44 struct vb2_v4l2_buffer *src; 45 struct vb2_v4l2_buffer *dst; 46 } bufs; 47}; 48 49struct rkvdec_vp9_decoded_buffer_info { 50 /* Info needed when the decoded frame serves as a reference frame. */ 51 unsigned short width; 52 unsigned short height; 53 unsigned int bit_depth : 4; 54}; 55 56struct rkvdec_decoded_buffer { 57 /* Must be the first field in this struct. */ 58 struct v4l2_m2m_buffer base; 59 60 union { 61 struct rkvdec_vp9_decoded_buffer_info vp9; 62 }; 63}; 64 65static inline struct rkvdec_decoded_buffer * 66vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf) 67{ 68 return container_of(buf, struct rkvdec_decoded_buffer, 69 base.vb.vb2_buf); 70} 71 72struct rkvdec_variant { 73 unsigned int num_regs; 74 unsigned int capabilities; 75 unsigned int quirks; 76}; 77 78struct rkvdec_coded_fmt_ops { 79 int (*adjust_fmt)(struct rkvdec_ctx *ctx, 80 struct v4l2_format *f); 81 int (*start)(struct rkvdec_ctx *ctx); 82 void (*stop)(struct rkvdec_ctx *ctx); 83 int (*run)(struct rkvdec_ctx *ctx); 84 void (*done)(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf, 85 struct vb2_v4l2_buffer *dst_buf, 86 enum vb2_buffer_state result); 87 int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl); 88 enum rkvdec_image_fmt (*get_image_fmt)(struct rkvdec_ctx *ctx, 89 struct v4l2_ctrl *ctrl); 90}; 91 92enum rkvdec_image_fmt { 93 RKVDEC_IMG_FMT_ANY = 0, 94 RKVDEC_IMG_FMT_420_8BIT, 95 RKVDEC_IMG_FMT_420_10BIT, 96 RKVDEC_IMG_FMT_422_8BIT, 97 RKVDEC_IMG_FMT_422_10BIT, 98}; 99 100struct rkvdec_decoded_fmt_desc { 101 u32 fourcc; 102 enum rkvdec_image_fmt image_fmt; 103}; 104 105struct rkvdec_coded_fmt_desc { 106 u32 fourcc; 107 struct v4l2_frmsize_stepwise frmsize; 108 const struct rkvdec_ctrls *ctrls; 109 const struct rkvdec_coded_fmt_ops *ops; 110 unsigned int num_decoded_fmts; 111 const struct rkvdec_decoded_fmt_desc *decoded_fmts; 112 u32 subsystem_flags; 113 unsigned int capability; 114}; 115 116struct rkvdec_dev { 117 struct v4l2_device v4l2_dev; 118 struct media_device mdev; 119 struct video_device vdev; 120 struct v4l2_m2m_dev *m2m_dev; 121 struct device *dev; 122 struct clk_bulk_data *clocks; 123 void __iomem *regs; 124 struct mutex vdev_lock; /* serializes ioctls */ 125 struct delayed_work watchdog_work; 126 struct iommu_domain *empty_domain; 127 const struct rkvdec_variant *variant; 128}; 129 130struct rkvdec_ctx { 131 struct v4l2_fh fh; 132 struct v4l2_format coded_fmt; 133 struct v4l2_format decoded_fmt; 134 const struct rkvdec_coded_fmt_desc *coded_fmt_desc; 135 struct v4l2_ctrl_handler ctrl_hdl; 136 struct rkvdec_dev *dev; 137 enum rkvdec_image_fmt image_fmt; 138 void *priv; 139}; 140 141static inline struct rkvdec_ctx *file_to_rkvdec_ctx(struct file *filp) 142{ 143 return container_of(file_to_v4l2_fh(filp), struct rkvdec_ctx, fh); 144} 145 146struct rkvdec_aux_buf { 147 void *cpu; 148 dma_addr_t dma; 149 size_t size; 150}; 151 152void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run); 153void rkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run); 154 155void rkvdec_quirks_disable_qos(struct rkvdec_ctx *ctx); 156 157extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops; 158extern const struct rkvdec_coded_fmt_ops rkvdec_hevc_fmt_ops; 159extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops; 160 161#endif /* RKVDEC_H_ */
~/
Read-only file preview.