2 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
3 * Author: Jacob Chen <jacob-chen@iotwrt.com>
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 #include <linux/platform_device.h>
18 #include <media/videobuf2-v4l2.h>
19 #include <media/v4l2-ctrls.h>
20 #include <media/v4l2-device.h>
22 #define RGA_NAME "rockchip-rga"
35 /* Original dimensions */
41 struct v4l2_rect crop
;
46 /* Variables that can calculated once and reused */
51 struct rockchip_rga_version
{
58 struct rockchip_rga
*rga
;
61 struct v4l2_ctrl_handler ctrl_handler
;
72 struct v4l2_device v4l2_dev
;
73 struct v4l2_m2m_dev
*m2m_dev
;
74 struct video_device
*vfd
;
82 struct rockchip_rga_version version
;
89 wait_queue_head_t irq_queue
;
92 dma_addr_t cmdbuf_phy
;
94 unsigned int *src_mmu_pages
;
95 unsigned int *dst_mmu_pages
;
98 struct rga_frame
*rga_get_frame(struct rga_ctx
*ctx
, enum v4l2_buf_type type
);
100 /* RGA Buffers Manage */
101 extern const struct vb2_ops rga_qops
;
102 void rga_buf_map(struct vb2_buffer
*vb
);
105 static inline void rga_write(struct rockchip_rga
*rga
, u32 reg
, u32 value
)
107 writel(value
, rga
->regs
+ reg
);
110 static inline u32
rga_read(struct rockchip_rga
*rga
, u32 reg
)
112 return readl(rga
->regs
+ reg
);
115 static inline void rga_mod(struct rockchip_rga
*rga
, u32 reg
, u32 val
, u32 mask
)
117 u32 temp
= rga_read(rga
, reg
) & ~(mask
);
120 rga_write(rga
, reg
, temp
);
123 void rga_hw_start(struct rockchip_rga
*rga
);