1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
4 * Author: Jacob Chen <jacob-chen@iotwrt.com>
9 #include <linux/platform_device.h>
10 #include <media/videobuf2-v4l2.h>
11 #include <media/v4l2-ctrls.h>
12 #include <media/v4l2-device.h>
14 #define RGA_NAME "rockchip-rga"
27 /* Original dimensions */
33 struct v4l2_rect crop
;
38 /* Variables that can calculated once and reused */
43 struct rockchip_rga_version
{
50 struct rockchip_rga
*rga
;
53 struct v4l2_ctrl_handler ctrl_handler
;
64 struct v4l2_device v4l2_dev
;
65 struct v4l2_m2m_dev
*m2m_dev
;
66 struct video_device
*vfd
;
74 struct rockchip_rga_version version
;
82 dma_addr_t cmdbuf_phy
;
84 unsigned int *src_mmu_pages
;
85 unsigned int *dst_mmu_pages
;
88 struct rga_frame
*rga_get_frame(struct rga_ctx
*ctx
, enum v4l2_buf_type type
);
90 /* RGA Buffers Manage */
91 extern const struct vb2_ops rga_qops
;
92 void rga_buf_map(struct vb2_buffer
*vb
);
95 static inline void rga_write(struct rockchip_rga
*rga
, u32 reg
, u32 value
)
97 writel(value
, rga
->regs
+ reg
);
100 static inline u32
rga_read(struct rockchip_rga
*rga
, u32 reg
)
102 return readl(rga
->regs
+ reg
);
105 static inline void rga_mod(struct rockchip_rga
*rga
, u32 reg
, u32 val
, u32 mask
)
107 u32 temp
= rga_read(rga
, reg
) & ~(mask
);
110 rga_write(rga
, reg
, temp
);
113 void rga_hw_start(struct rockchip_rga
*rga
);