2 * Copyright (C) 2012 ROCKCHIP, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #define pr_fmt(fmt) "rga: " fmt
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/sched.h>
21 #include <linux/mutex.h>
22 #include <linux/err.h>
23 #include <linux/clk.h>
24 #include <asm/delay.h>
25 #include <linux/dma-mapping.h>
26 #include <linux/delay.h>
28 #include <linux/irq.h>
29 #include <linux/interrupt.h>
31 #include <asm/uaccess.h>
32 #include <linux/miscdevice.h>
33 #include <linux/poll.h>
34 #include <linux/delay.h>
35 #include <linux/wait.h>
36 #include <linux/syscalls.h>
37 #include <linux/timer.h>
38 #include <linux/time.h>
39 #include <asm/cacheflush.h>
40 #include <linux/slab.h>
42 #include <linux/wakelock.h>
43 #include <linux/scatterlist.h>
44 #include <linux/rockchip_ion.h>
45 #include <linux/version.h>
46 #include <linux/pm_runtime.h>
47 #include <linux/dma-buf.h>
50 #include "rga2_reg_info.h"
51 #include "rga2_mmu_info.h"
55 #if defined(CONFIG_RK_IOMMU) && defined(CONFIG_ION_ROCKCHIP)
56 #define CONFIG_RGA_IOMMU
59 #define RGA2_TEST_FLUSH_TIME 0
60 #define RGA2_INFO_BUS_ERROR 1
61 #define RGA2_POWER_OFF_DELAY 4*HZ /* 4s */
62 #define RGA2_TIMEOUT_DELAY (HZ / 10) /* 100ms */
63 #define RGA2_MAJOR 255
64 #define RGA2_RESET_TIMEOUT 1000
66 /* Driver information */
67 #define DRIVER_DESC "RGA2 Device Driver"
68 #define DRIVER_NAME "rga2"
69 #define RGA2_VERSION "2.000"
76 rga2_session rga2_session_global;
77 long (*rga_ioctl_kernel_p)(struct rga_req *);
79 struct rga2_drvdata_t {
80 struct miscdevice miscdev;
85 struct delayed_work power_off_work;
86 struct wake_lock wake_lock;
87 void (*rga_irq_callback)(int rga_retval);
89 struct clk *aclk_rga2;
90 struct clk *hclk_rga2;
93 struct ion_client * ion_client;
97 struct rga2_drvdata_t *rga2_drvdata;
98 struct rga2_service_info rga2_service;
99 struct rga2_mmu_buf_t rga2_mmu_buf;
101 static int rga2_blit_async(rga2_session *session, struct rga2_req *req);
102 static void rga2_del_running_list(void);
103 static void rga2_del_running_list_timeout(void);
104 static void rga2_try_set_reg(void);
110 #define DBG(format, args...) printk(KERN_DEBUG "%s: " format, DRIVER_NAME, ## args)
111 #define ERR(format, args...) printk(KERN_ERR "%s: " format, DRIVER_NAME, ## args)
112 #define WARNING(format, args...) printk(KERN_WARN "%s: " format, DRIVER_NAME, ## args)
113 #define INFO(format, args...) printk(KERN_INFO "%s: " format, DRIVER_NAME, ## args)
115 #define DBG(format, args...)
116 #define ERR(format, args...)
117 #define WARNING(format, args...)
118 #define INFO(format, args...)
122 static void print_info(struct rga2_req *req)
124 printk("render_mode=%d bitblt_mode=%d rotate_mode=%.8x\n",
125 req->render_mode, req->bitblt_mode, req->rotate_mode);
126 printk("src : y=%.lx uv=%.lx v=%.lx format=%d aw=%d ah=%d vw=%d vh=%d xoff=%d yoff=%d \n",
127 req->src.yrgb_addr, req->src.uv_addr, req->src.v_addr, req->src.format,
128 req->src.act_w, req->src.act_h, req->src.vir_w, req->src.vir_h,
129 req->src.x_offset, req->src.y_offset);
130 printk("dst : y=%lx uv=%lx v=%lx format=%d aw=%d ah=%d vw=%d vh=%d xoff=%d yoff=%d \n",
131 req->dst.yrgb_addr, req->dst.uv_addr, req->dst.v_addr, req->dst.format,
132 req->dst.act_w, req->dst.act_h, req->dst.vir_w, req->dst.vir_h,
133 req->dst.x_offset, req->dst.y_offset);
134 printk("mmu : src=%.2x src1=%.2x dst=%.2x els=%.2x\n",
135 req->mmu_info.src0_mmu_flag, req->mmu_info.src1_mmu_flag,
136 req->mmu_info.dst_mmu_flag, req->mmu_info.els_mmu_flag);
137 printk("alpha : flag %.8x mode0=%.8x mode1=%.8x\n",
138 req->alpha_rop_flag, req->alpha_mode_0, req->alpha_mode_1);
142 static inline void rga2_write(u32 b, u32 r)
144 *((volatile unsigned int *)(rga2_drvdata->rga_base + r)) = b;
147 static inline u32 rga2_read(u32 r)
149 return *((volatile unsigned int *)(rga2_drvdata->rga_base + r));
152 static inline int rga2_init_version(void)
154 struct rga2_drvdata_t *rga = rga2_drvdata;
155 u32 major_version, minor_version;
159 pr_err("rga2_drvdata is null\n");
162 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
163 pm_runtime_get_sync(rga2_drvdata->dev);
166 clk_prepare_enable(rga2_drvdata->aclk_rga2);
167 clk_prepare_enable(rga2_drvdata->hclk_rga2);
169 reg_version = rga2_read(0x028);
171 clk_disable_unprepare(rga2_drvdata->aclk_rga2);
172 clk_disable_unprepare(rga2_drvdata->hclk_rga2);
174 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
175 pm_runtime_put(rga2_drvdata->dev);
178 major_version = (reg_version & RGA2_MAJOR_VERSION_MASK) >> 24;
179 minor_version = (reg_version & RGA2_MINOR_VERSION_MASK) >> 20;
181 sprintf(rga->version, "%d.%02d", major_version, minor_version);
186 static void rga2_soft_reset(void)
191 rga2_write((1 << 3) | (1 << 4) | (1 << 6), RGA2_SYS_CTRL);
193 for(i = 0; i < RGA2_RESET_TIMEOUT; i++)
195 reg = rga2_read(RGA2_SYS_CTRL) & 1; //RGA_SYS_CTRL
203 if(i == RGA2_RESET_TIMEOUT)
204 ERR("soft reset timeout.\n");
207 static void rga2_dump(void)
210 struct rga2_reg *reg, *reg_tmp;
211 rga2_session *session, *session_tmp;
213 running = atomic_read(&rga2_service.total_running);
214 printk("rga total_running %d\n", running);
215 list_for_each_entry_safe(session, session_tmp, &rga2_service.session,
218 printk("session pid %d:\n", session->pid);
219 running = atomic_read(&session->task_running);
220 printk("task_running %d\n", running);
221 list_for_each_entry_safe(reg, reg_tmp, &session->waiting, session_link)
223 printk("waiting register set 0x%.lu\n", (unsigned long)reg);
225 list_for_each_entry_safe(reg, reg_tmp, &session->running, session_link)
227 printk("running register set 0x%.lu\n", (unsigned long)reg);
232 static inline void rga2_queue_power_off_work(void)
234 queue_delayed_work(system_wq, &rga2_drvdata->power_off_work,
235 RGA2_POWER_OFF_DELAY);
238 /* Caller must hold rga_service.lock */
239 static void rga2_power_on(void)
242 ktime_t now = ktime_get();
244 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
245 pm_runtime_get_sync(rga2_drvdata->dev);
248 if (ktime_to_ns(ktime_sub(now, last)) > NSEC_PER_SEC) {
249 cancel_delayed_work_sync(&rga2_drvdata->power_off_work);
250 rga2_queue_power_off_work();
254 if (rga2_service.enable)
257 clk_prepare_enable(rga2_drvdata->rga2);
258 clk_prepare_enable(rga2_drvdata->aclk_rga2);
259 clk_prepare_enable(rga2_drvdata->hclk_rga2);
260 wake_lock(&rga2_drvdata->wake_lock);
261 rga2_service.enable = true;
264 /* Caller must hold rga_service.lock */
265 static void rga2_power_off(void)
269 if (!rga2_service.enable) {
273 total_running = atomic_read(&rga2_service.total_running);
275 pr_err("power off when %d task running!!\n", total_running);
277 pr_err("delay 50 ms for running task\n");
281 clk_disable_unprepare(rga2_drvdata->rga2);
282 clk_disable_unprepare(rga2_drvdata->aclk_rga2);
283 clk_disable_unprepare(rga2_drvdata->hclk_rga2);
285 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
286 pm_runtime_put(rga2_drvdata->dev);
289 wake_unlock(&rga2_drvdata->wake_lock);
291 rga2_service.enable = false;
294 static void rga2_power_off_work(struct work_struct *work)
296 if (mutex_trylock(&rga2_service.lock)) {
298 mutex_unlock(&rga2_service.lock);
300 /* Come back later if the device is busy... */
301 rga2_queue_power_off_work();
305 static int rga2_flush(rga2_session *session, unsigned long arg)
310 #if RGA2_TEST_FLUSH_TIME
316 ret_timeout = wait_event_timeout(session->wait, atomic_read(&session->done), RGA2_TIMEOUT_DELAY);
318 if (unlikely(ret_timeout < 0)) {
319 //pr_err("flush pid %d wait task ret %d\n", session->pid, ret);
320 mutex_lock(&rga2_service.lock);
321 rga2_del_running_list();
322 mutex_unlock(&rga2_service.lock);
324 } else if (0 == ret_timeout) {
325 //pr_err("flush pid %d wait %d task done timeout\n", session->pid, atomic_read(&session->task_running));
326 //printk("bus = %.8x\n", rga_read(RGA_INT));
327 mutex_lock(&rga2_service.lock);
328 rga2_del_running_list_timeout();
330 mutex_unlock(&rga2_service.lock);
334 #if RGA2_TEST_FLUSH_TIME
336 end = ktime_sub(end, start);
337 printk("one flush wait time %d\n", (int)ktime_to_us(end));
344 static int rga2_get_result(rga2_session *session, unsigned long arg)
349 num_done = atomic_read(&session->num_done);
350 if (unlikely(copy_to_user((void __user *)arg, &num_done, sizeof(int)))) {
351 printk("copy_to_user failed\n");
358 static int rga2_check_param(const struct rga2_req *req)
360 if(!((req->render_mode == color_fill_mode)))
362 if (unlikely((req->src.act_w <= 0) || (req->src.act_w > 8191) || (req->src.act_h <= 0) || (req->src.act_h > 8191)))
364 printk("invalid source resolution act_w = %d, act_h = %d\n", req->src.act_w, req->src.act_h);
369 if(!((req->render_mode == color_fill_mode)))
371 if (unlikely((req->src.vir_w <= 0) || (req->src.vir_w > 8191) || (req->src.vir_h <= 0) || (req->src.vir_h > 8191)))
373 printk("invalid source resolution vir_w = %d, vir_h = %d\n", req->src.vir_w, req->src.vir_h);
378 //check dst width and height
379 if (unlikely((req->dst.act_w <= 0) || (req->dst.act_w > 4096) || (req->dst.act_h <= 0) || (req->dst.act_h > 4096)))
381 printk("invalid destination resolution act_w = %d, act_h = %d\n", req->dst.act_w, req->dst.act_h);
385 if (unlikely((req->dst.vir_w <= 0) || (req->dst.vir_w > 4096) || (req->dst.vir_h <= 0) || (req->dst.vir_h > 4096)))
387 printk("invalid destination resolution vir_w = %d, vir_h = %d\n", req->dst.vir_w, req->dst.vir_h);
392 if(unlikely(req->src.vir_w < req->src.act_w)){
393 printk("invalid src_vir_w act_w = %d, vir_w = %d\n", req->src.act_w, req->src.vir_w);
398 if(unlikely(req->dst.vir_w < req->dst.act_w)){
399 if(req->rotate_mode != 1)
401 printk("invalid dst_vir_w act_h = %d, vir_h = %d\n", req->dst.act_w, req->dst.vir_w);
409 static void rga2_copy_reg(struct rga2_reg *reg, uint32_t offset)
415 if(atomic_read(®->session->task_running) != 0)
416 printk(KERN_ERR "task_running is no zero\n");
418 atomic_add(1, &rga2_service.cmd_num);
419 atomic_add(1, ®->session->task_running);
421 cmd_buf = (uint32_t *)rga2_service.cmd_buff + offset*32;
422 reg_p = (uint32_t *)reg->cmd_reg;
425 cmd_buf[i] = reg_p[i];
429 static struct rga2_reg * rga2_reg_init(rga2_session *session, struct rga2_req *req)
432 struct rga2_reg *reg = kzalloc(sizeof(struct rga2_reg), GFP_KERNEL);
434 pr_err("kmalloc fail in rga_reg_init\n");
438 reg->session = session;
439 INIT_LIST_HEAD(®->session_link);
440 INIT_LIST_HEAD(®->status_link);
442 reg->MMU_base = NULL;
444 if ((req->mmu_info.src0_mmu_flag & 1) || (req->mmu_info.src1_mmu_flag & 1)
445 || (req->mmu_info.dst_mmu_flag & 1) || (req->mmu_info.els_mmu_flag & 1))
447 ret = rga2_set_mmu_info(reg, req);
449 printk("%s, [%d] set mmu info error \n", __FUNCTION__, __LINE__);
457 if(RGA2_gen_reg_info((uint8_t *)reg->cmd_reg, req) == -1) {
458 printk("gen reg info error\n");
465 reg->sg_src0 = req->sg_src0;
466 reg->sg_dst = req->sg_dst;
467 reg->sg_src1 = req->sg_src1;
468 reg->attach_src0 = req->attach_src0;
469 reg->attach_dst = req->attach_dst;
470 reg->attach_src1 = req->attach_src1;
472 mutex_lock(&rga2_service.lock);
473 list_add_tail(®->status_link, &rga2_service.waiting);
474 list_add_tail(®->session_link, &session->waiting);
475 mutex_unlock(&rga2_service.lock);
481 /* Caller must hold rga_service.lock */
482 static void rga2_reg_deinit(struct rga2_reg *reg)
484 list_del_init(®->session_link);
485 list_del_init(®->status_link);
489 /* Caller must hold rga_service.lock */
490 static void rga2_reg_from_wait_to_run(struct rga2_reg *reg)
492 list_del_init(®->status_link);
493 list_add_tail(®->status_link, &rga2_service.running);
495 list_del_init(®->session_link);
496 list_add_tail(®->session_link, ®->session->running);
499 /* Caller must hold rga_service.lock */
500 static void rga2_service_session_clear(rga2_session *session)
502 struct rga2_reg *reg, *n;
504 list_for_each_entry_safe(reg, n, &session->waiting, session_link)
506 rga2_reg_deinit(reg);
509 list_for_each_entry_safe(reg, n, &session->running, session_link)
511 rga2_reg_deinit(reg);
515 /* Caller must hold rga_service.lock */
516 static void rga2_try_set_reg(void)
518 struct rga2_reg *reg ;
520 if (list_empty(&rga2_service.running))
522 if (!list_empty(&rga2_service.waiting))
525 reg = list_entry(rga2_service.waiting.next, struct rga2_reg, status_link);
530 rga2_copy_reg(reg, 0);
531 rga2_reg_from_wait_to_run(reg);
534 dmac_flush_range(&rga2_service.cmd_buff[0], &rga2_service.cmd_buff[32]);
535 outer_flush_range(virt_to_phys(&rga2_service.cmd_buff[0]),virt_to_phys(&rga2_service.cmd_buff[32]));
536 #elif defined(CONFIG_ARM64)
537 __dma_flush_range(&rga2_service.cmd_buff[0], &rga2_service.cmd_buff[32]);
542 rga2_write(0x0, RGA2_SYS_CTRL);
545 rga2_write(virt_to_phys(rga2_service.cmd_buff), RGA2_CMD_BASE);
550 p = rga2_service.cmd_buff;
553 printk("%.8x %.8x %.8x %.8x\n", p[0 + i*4], p[1+i*4], p[2 + i*4], p[3 + i*4]);
558 rga2_write((0x1<<1)|(0x1<<2)|(0x1<<5)|(0x1<<6), RGA2_SYS_CTRL);
560 /* All CMD finish int */
561 rga2_write(rga2_read(RGA2_INT)|(0x1<<10)|(0x1<<9)|(0x1<<8), RGA2_INT);
564 rga2_start = ktime_get();
568 atomic_set(®->session->done, 0);
569 rga2_write(0x1, RGA2_CMD_CTRL);
574 printk("CMD_READ_BACK_REG\n");
576 printk("%.8x %.8x %.8x %.8x\n", rga2_read(0x100 + i*16 + 0),
577 rga2_read(0x100 + i*16 + 4), rga2_read(0x100 + i*16 + 8), rga2_read(0x100 + i*16 + 12));
584 static int rga2_put_dma_buf(struct rga2_req *req, struct rga2_reg *reg)
586 struct dma_buf_attachment *attach = NULL;
587 struct sg_table *sgt = NULL;
588 struct dma_buf *dma_buf = NULL;
593 attach = (!reg) ? req->attach_src0 : reg->attach_src0;
594 sgt = (!reg) ? req->sg_src0 : reg->sg_src0;
596 dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
598 dma_buf = attach->dmabuf;
599 dma_buf_detach(dma_buf, attach);
600 dma_buf_put(dma_buf);
603 attach = (!reg) ? req->attach_dst : reg->attach_dst;
604 sgt = (!reg) ? req->sg_dst : reg->sg_dst;
606 dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
608 dma_buf = attach->dmabuf;
609 dma_buf_detach(dma_buf, attach);
610 dma_buf_put(dma_buf);
613 attach = (!reg) ? req->attach_src1 : reg->attach_src1;
614 sgt = (!reg) ? req->sg_src1 : reg->sg_src1;
616 dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
618 dma_buf = attach->dmabuf;
619 dma_buf_detach(dma_buf, attach);
620 dma_buf_put(dma_buf);
626 static void rga2_del_running_list(void)
628 struct rga2_mmu_buf_t *tbuf = &rga2_mmu_buf;
629 struct rga2_reg *reg;
631 while (!list_empty(&rga2_service.running)) {
632 reg = list_entry(rga2_service.running.next, struct rga2_reg,
634 if (reg->MMU_len && tbuf) {
635 if (tbuf->back + reg->MMU_len > 2 * tbuf->size)
636 tbuf->back = reg->MMU_len + tbuf->size;
638 tbuf->back += reg->MMU_len;
641 rga2_put_dma_buf(NULL, reg);
643 atomic_sub(1, ®->session->task_running);
644 atomic_sub(1, &rga2_service.total_running);
646 if(list_empty(®->session->waiting))
648 atomic_set(®->session->done, 1);
649 wake_up(®->session->wait);
652 rga2_reg_deinit(reg);
656 static void rga2_del_running_list_timeout(void)
658 struct rga2_mmu_buf_t *tbuf = &rga2_mmu_buf;
659 struct rga2_reg *reg;
661 while (!list_empty(&rga2_service.running)) {
662 reg = list_entry(rga2_service.running.next, struct rga2_reg,
664 kfree(reg->MMU_base);
665 if (reg->MMU_len && tbuf) {
666 if (tbuf->back + reg->MMU_len > 2 * tbuf->size)
667 tbuf->back = reg->MMU_len + tbuf->size;
669 tbuf->back += reg->MMU_len;
672 rga2_put_dma_buf(NULL, reg);
674 atomic_sub(1, ®->session->task_running);
675 atomic_sub(1, &rga2_service.total_running);
677 if (list_empty(®->session->waiting)) {
678 atomic_set(®->session->done, 1);
679 wake_up(®->session->wait);
681 rga2_reg_deinit(reg);
686 static int rga2_get_img_info(rga_img_info_t *img,
689 struct sg_table **psgt,
690 struct dma_buf_attachment **pattach)
692 struct dma_buf_attachment *attach = NULL;
693 struct ion_client *ion_client = NULL;
694 struct ion_handle *hdl = NULL;
695 struct device *rga_dev = NULL;
696 struct sg_table *sgt = NULL;
697 struct dma_buf *dma_buf = NULL;
699 ion_phys_addr_t phy_addr;
704 ion_client = rga2_drvdata->ion_client;
705 rga_dev = rga2_drvdata->dev;
706 yrgb_addr = (int)img->yrgb_addr;
711 if (buf_gem_type_dma) {
712 dma_buf = dma_buf_get(img->yrgb_addr);
713 if (IS_ERR(dma_buf)) {
715 pr_err("dma_buf_get fail fd[%d]\n", yrgb_addr);
719 attach = dma_buf_attach(dma_buf, rga_dev);
720 if (IS_ERR(attach)) {
721 dma_buf_put(dma_buf);
723 pr_err("Failed to attach dma_buf\n");
728 sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
731 pr_err("Failed to map src attachment\n");
736 pr_err("Fix it please enable iommu flag\n");
740 hdl = ion_import_dma_buf(ion_client, img->yrgb_addr);
743 pr_err("RGA2 ERROR ion buf handle\n");
747 sgt = ion_sg_table(ion_client, hdl);
750 pr_err("Fail map src attachment\n");
758 img->yrgb_addr = img->uv_addr;
759 img->uv_addr = img->yrgb_addr + (vir_w * vir_h);
760 img->v_addr = img->uv_addr + (vir_w * vir_h) / 4;
762 ion_phys(ion_client, hdl, &phy_addr, &len);
763 img->yrgb_addr = phy_addr;
764 img->uv_addr = img->yrgb_addr + (vir_w * vir_h);
765 img->v_addr = img->uv_addr + (vir_w * vir_h) / 4;
768 img->yrgb_addr = img->uv_addr;
769 img->uv_addr = img->yrgb_addr + (vir_w * vir_h);
770 img->v_addr = img->uv_addr + (vir_w * vir_h) / 4;
774 ion_free(ion_client, hdl);
780 ion_free(ion_client, hdl);
781 if (sgt && buf_gem_type_dma)
782 dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
784 dma_buf = attach->dmabuf;
785 dma_buf_detach(dma_buf, attach);
787 dma_buf_put(dma_buf);
792 static int rga2_get_dma_buf(struct rga2_req *req)
794 struct dma_buf *dma_buf = NULL;
795 u8 buf_gem_type_dma = 0;
799 buf_gem_type_dma = req->buf_type & RGA_BUF_GEM_TYPE_DMA;
804 req->attach_src0 = NULL;
805 req->attach_dst = NULL;
806 req->attach_src1 = NULL;
807 mmu_flag = req->mmu_info.src0_mmu_flag;
808 ret = rga2_get_img_info(&req->src, mmu_flag, buf_gem_type_dma,
809 &req->sg_src0, &req->attach_src0);
811 pr_err("src:rga2_get_img_info fail\n");
815 mmu_flag = req->mmu_info.dst_mmu_flag;
816 ret = rga2_get_img_info(&req->dst, mmu_flag, buf_gem_type_dma,
817 &req->sg_dst, &req->attach_dst);
819 pr_err("dst:rga2_get_img_info fail\n");
823 mmu_flag = req->mmu_info.src1_mmu_flag;
824 ret = rga2_get_img_info(&req->src1, mmu_flag, buf_gem_type_dma,
825 &req->sg_src1, &req->attach_src1);
827 pr_err("src1:rga2_get_img_info fail\n");
834 if (buf_gem_type_dma && req->sg_dst && req->attach_dst) {
835 dma_buf_unmap_attachment(req->attach_dst,
836 req->sg_dst, DMA_BIDIRECTIONAL);
837 dma_buf = req->attach_dst->dmabuf;
838 dma_buf_detach(dma_buf, req->attach_dst);
839 dma_buf_put(dma_buf);
842 if (buf_gem_type_dma && req->sg_src0 && req->attach_src0) {
843 dma_buf_unmap_attachment(req->attach_src0,
844 req->sg_src0, DMA_BIDIRECTIONAL);
845 dma_buf = req->attach_src0->dmabuf;
846 dma_buf_detach(dma_buf, req->attach_src0);
847 dma_buf_put(dma_buf);
854 static int rga2_blit(rga2_session *session, struct rga2_req *req)
858 struct rga2_reg *reg;
860 if (rga2_get_dma_buf(req)) {
861 pr_err("RGA2 : DMA buf copy error\n");
866 /* check value if legal */
867 ret = rga2_check_param(req);
869 pr_err("req argument is inval\n");
870 goto err_put_dma_buf;
873 reg = rga2_reg_init(session, req);
875 pr_err("init reg fail\n");
876 goto err_put_dma_buf;
880 mutex_lock(&rga2_service.lock);
881 atomic_add(num, &rga2_service.total_running);
883 mutex_unlock(&rga2_service.lock);
890 rga2_put_dma_buf(req, NULL);
895 static int rga2_blit_async(rga2_session *session, struct rga2_req *req)
900 if (1) {//req->src.format >= 0x10) {
903 printk("*** rga_blit_async proc ***\n");
908 atomic_set(&session->done, 0);
909 ret = rga2_blit(session, req);
914 static int rga2_blit_sync(rga2_session *session, struct rga2_req *req)
916 struct rga2_req req_bak;
921 memcpy(&req_bak, req, sizeof(req_bak));
925 if (1) {//req->bitblt_mode == 0x2) {
928 printk("*** rga2_blit_sync proc ***\n");
934 atomic_set(&session->done, 0);
936 ret = rga2_blit(session, req);
940 ret_timeout = wait_event_timeout(session->wait, atomic_read(&session->done), RGA2_TIMEOUT_DELAY);
942 if (unlikely(ret_timeout< 0))
944 //pr_err("sync pid %d wait task ret %d\n", session->pid, ret_timeout);
945 mutex_lock(&rga2_service.lock);
946 rga2_del_running_list();
947 mutex_unlock(&rga2_service.lock);
950 else if (0 == ret_timeout)
952 //pr_err("sync pid %d wait %d task done timeout\n", session->pid, atomic_read(&session->task_running));
953 mutex_lock(&rga2_service.lock);
954 rga2_del_running_list_timeout();
956 mutex_unlock(&rga2_service.lock);
961 rga2_end = ktime_get();
962 rga2_end = ktime_sub(rga2_end, rga2_start);
963 printk("sync one cmd end time %d\n", (int)ktime_to_us(rga2_end));
965 if (ret == -ETIMEDOUT && try--) {
966 memcpy(req, &req_bak, sizeof(req_bak));
973 static long rga_ioctl(struct file *file, uint32_t cmd, unsigned long arg)
975 struct rga2_drvdata_t *rga = rga2_drvdata;
976 struct rga2_req req, req_first;
977 struct rga_req req_rga;
979 rga2_session *session;
982 pr_err("rga2_drvdata is null, rga2 is not init\n");
985 memset(&req, 0x0, sizeof(req));
987 mutex_lock(&rga2_service.mutex);
989 session = (rga2_session *)file->private_data;
993 printk("%s [%d] rga thread session is null\n",__FUNCTION__,__LINE__);
994 mutex_unlock(&rga2_service.mutex);
998 memset(&req, 0x0, sizeof(req));
1003 if (unlikely(copy_from_user(&req_rga, (struct rga_req*)arg, sizeof(struct rga_req))))
1005 ERR("copy_from_user failed\n");
1009 RGA_MSG_2_RGA2_MSG(&req_rga, &req);
1011 if (first_RGA2_proc == 0 && req.bitblt_mode == bitblt_mode && rga2_service.dev_mode == 1) {
1012 memcpy(&req_first, &req, sizeof(struct rga2_req));
1013 if ((req_first.src.act_w != req_first.dst.act_w)
1014 || (req_first.src.act_h != req_first.dst.act_h)) {
1015 req_first.src.act_w = MIN(320, MIN(req_first.src.act_w, req_first.dst.act_w));
1016 req_first.src.act_h = MIN(240, MIN(req_first.src.act_h, req_first.dst.act_h));
1017 req_first.dst.act_w = req_first.src.act_w;
1018 req_first.dst.act_h = req_first.src.act_h;
1019 ret = rga2_blit_async(session, &req_first);
1021 ret = rga2_blit_sync(session, &req);
1022 first_RGA2_proc = 1;
1025 ret = rga2_blit_sync(session, &req);
1028 case RGA_BLIT_ASYNC:
1029 if (unlikely(copy_from_user(&req_rga, (struct rga_req*)arg, sizeof(struct rga_req))))
1031 ERR("copy_from_user failed\n");
1036 RGA_MSG_2_RGA2_MSG(&req_rga, &req);
1038 if (first_RGA2_proc == 0 && req.bitblt_mode == bitblt_mode && rga2_service.dev_mode == 1) {
1039 memcpy(&req_first, &req, sizeof(struct rga2_req));
1040 if ((req_first.src.act_w != req_first.dst.act_w)
1041 || (req_first.src.act_h != req_first.dst.act_h)) {
1042 req_first.src.act_w = MIN(320, MIN(req_first.src.act_w, req_first.dst.act_w));
1043 req_first.src.act_h = MIN(240, MIN(req_first.src.act_h, req_first.dst.act_h));
1044 req_first.dst.act_w = req_first.src.act_w;
1045 req_first.dst.act_h = req_first.src.act_h;
1046 ret = rga2_blit_async(session, &req_first);
1048 ret = rga2_blit_async(session, &req);
1049 first_RGA2_proc = 1;
1052 ret = rga2_blit_async(session, &req);
1055 case RGA2_BLIT_SYNC:
1056 if (unlikely(copy_from_user(&req, (struct rga2_req*)arg, sizeof(struct rga2_req))))
1058 ERR("copy_from_user failed\n");
1062 ret = rga2_blit_sync(session, &req);
1064 case RGA2_BLIT_ASYNC:
1065 if (unlikely(copy_from_user(&req, (struct rga2_req*)arg, sizeof(struct rga2_req))))
1067 ERR("copy_from_user failed\n");
1072 if((atomic_read(&rga2_service.total_running) > 16))
1074 ret = rga2_blit_sync(session, &req);
1078 ret = rga2_blit_async(session, &req);
1083 ret = rga2_flush(session, arg);
1085 case RGA_GET_RESULT:
1086 case RGA2_GET_RESULT:
1087 ret = rga2_get_result(session, arg);
1089 case RGA_GET_VERSION:
1090 case RGA2_GET_VERSION:
1091 ret = copy_to_user((void *)arg, rga->version, 16);
1094 ERR("unknown ioctl cmd!\n");
1099 mutex_unlock(&rga2_service.mutex);
1104 #ifdef CONFIG_COMPAT
1105 static long compat_rga_ioctl(struct file *file, uint32_t cmd, unsigned long arg)
1107 struct rga2_drvdata_t *rga = rga2_drvdata;
1108 struct rga2_req req, req_first;
1109 struct rga_req_32 req_rga;
1111 rga2_session *session;
1114 pr_err("rga2_drvdata is null, rga2 is not init\n");
1117 memset(&req, 0x0, sizeof(req));
1119 mutex_lock(&rga2_service.mutex);
1121 session = (rga2_session *)file->private_data;
1124 printk("use compat_rga_ioctl\n");
1127 if (NULL == session) {
1128 printk("%s [%d] rga thread session is null\n",__FUNCTION__,__LINE__);
1129 mutex_unlock(&rga2_service.mutex);
1133 memset(&req, 0x0, sizeof(req));
1137 if (unlikely(copy_from_user(&req_rga, compat_ptr((compat_uptr_t)arg), sizeof(struct rga_req_32))))
1139 ERR("copy_from_user failed\n");
1144 RGA_MSG_2_RGA2_MSG_32(&req_rga, &req);
1146 if (first_RGA2_proc == 0 && req.bitblt_mode == bitblt_mode && rga2_service.dev_mode == 1) {
1147 memcpy(&req_first, &req, sizeof(struct rga2_req));
1148 if ((req_first.src.act_w != req_first.dst.act_w)
1149 || (req_first.src.act_h != req_first.dst.act_h)) {
1150 req_first.src.act_w = MIN(320, MIN(req_first.src.act_w, req_first.dst.act_w));
1151 req_first.src.act_h = MIN(240, MIN(req_first.src.act_h, req_first.dst.act_h));
1152 req_first.dst.act_w = req_first.src.act_w;
1153 req_first.dst.act_h = req_first.src.act_h;
1154 ret = rga2_blit_async(session, &req_first);
1156 ret = rga2_blit_sync(session, &req);
1157 first_RGA2_proc = 1;
1160 ret = rga2_blit_sync(session, &req);
1163 case RGA_BLIT_ASYNC:
1164 if (unlikely(copy_from_user(&req_rga, compat_ptr((compat_uptr_t)arg), sizeof(struct rga_req_32))))
1166 ERR("copy_from_user failed\n");
1170 RGA_MSG_2_RGA2_MSG_32(&req_rga, &req);
1172 if (first_RGA2_proc == 0 && req.bitblt_mode == bitblt_mode && rga2_service.dev_mode == 1) {
1173 memcpy(&req_first, &req, sizeof(struct rga2_req));
1174 if ((req_first.src.act_w != req_first.dst.act_w)
1175 || (req_first.src.act_h != req_first.dst.act_h)) {
1176 req_first.src.act_w = MIN(320, MIN(req_first.src.act_w, req_first.dst.act_w));
1177 req_first.src.act_h = MIN(240, MIN(req_first.src.act_h, req_first.dst.act_h));
1178 req_first.dst.act_w = req_first.src.act_w;
1179 req_first.dst.act_h = req_first.src.act_h;
1180 ret = rga2_blit_async(session, &req_first);
1182 ret = rga2_blit_sync(session, &req);
1183 first_RGA2_proc = 1;
1186 ret = rga2_blit_sync(session, &req);
1189 //if((atomic_read(&rga2_service.total_running) > 8))
1190 // ret = rga2_blit_sync(session, &req);
1192 // ret = rga2_blit_async(session, &req);
1195 case RGA2_BLIT_SYNC:
1196 if (unlikely(copy_from_user(&req, compat_ptr((compat_uptr_t)arg), sizeof(struct rga2_req))))
1198 ERR("copy_from_user failed\n");
1202 ret = rga2_blit_sync(session, &req);
1204 case RGA2_BLIT_ASYNC:
1205 if (unlikely(copy_from_user(&req, compat_ptr((compat_uptr_t)arg), sizeof(struct rga2_req))))
1207 ERR("copy_from_user failed\n");
1212 if((atomic_read(&rga2_service.total_running) > 16))
1213 ret = rga2_blit_sync(session, &req);
1215 ret = rga2_blit_async(session, &req);
1220 ret = rga2_flush(session, arg);
1222 case RGA_GET_RESULT:
1223 case RGA2_GET_RESULT:
1224 ret = rga2_get_result(session, arg);
1226 case RGA_GET_VERSION:
1227 case RGA2_GET_VERSION:
1228 ret = copy_to_user((void *)arg, rga->version, 16);
1231 ERR("unknown ioctl cmd!\n");
1236 mutex_unlock(&rga2_service.mutex);
1243 long rga2_ioctl_kernel(struct rga_req *req_rga)
1246 rga2_session *session;
1247 struct rga2_req req;
1249 memset(&req, 0x0, sizeof(req));
1250 mutex_lock(&rga2_service.mutex);
1251 session = &rga2_session_global;
1252 if (NULL == session)
1254 printk("%s [%d] rga thread session is null\n",__FUNCTION__,__LINE__);
1255 mutex_unlock(&rga2_service.mutex);
1259 RGA_MSG_2_RGA2_MSG(req_rga, &req);
1260 ret = rga2_blit_sync(session, &req);
1261 mutex_unlock(&rga2_service.mutex);
1267 static int rga2_open(struct inode *inode, struct file *file)
1269 rga2_session *session = kzalloc(sizeof(rga2_session), GFP_KERNEL);
1271 if (NULL == session) {
1272 pr_err("unable to allocate memory for rga_session.");
1276 session->pid = current->pid;
1277 INIT_LIST_HEAD(&session->waiting);
1278 INIT_LIST_HEAD(&session->running);
1279 INIT_LIST_HEAD(&session->list_session);
1280 init_waitqueue_head(&session->wait);
1281 mutex_lock(&rga2_service.lock);
1282 list_add_tail(&session->list_session, &rga2_service.session);
1283 mutex_unlock(&rga2_service.lock);
1284 atomic_set(&session->task_running, 0);
1285 atomic_set(&session->num_done, 0);
1286 file->private_data = (void *)session;
1288 return nonseekable_open(inode, file);
1291 static int rga2_release(struct inode *inode, struct file *file)
1294 rga2_session *session = (rga2_session *)file->private_data;
1296 if (NULL == session)
1299 task_running = atomic_read(&session->task_running);
1302 pr_err("rga2_service session %d still has %d task running when closing\n", session->pid, task_running);
1306 wake_up(&session->wait);
1307 mutex_lock(&rga2_service.lock);
1308 list_del(&session->list_session);
1309 rga2_service_session_clear(session);
1311 mutex_unlock(&rga2_service.lock);
1316 static irqreturn_t rga2_irq_thread(int irq, void *dev_id)
1318 mutex_lock(&rga2_service.lock);
1319 if (rga2_service.enable) {
1320 rga2_del_running_list();
1323 mutex_unlock(&rga2_service.lock);
1328 static irqreturn_t rga2_irq(int irq, void *dev_id)
1331 rga2_write(rga2_read(RGA2_INT) | (0x1<<4) | (0x1<<5) | (0x1<<6) | (0x1<<7), RGA2_INT);
1333 return IRQ_WAKE_THREAD;
1336 struct file_operations rga2_fops = {
1337 .owner = THIS_MODULE,
1339 .release = rga2_release,
1340 .unlocked_ioctl = rga_ioctl,
1341 #ifdef CONFIG_COMPAT
1342 .compat_ioctl = compat_rga_ioctl,
1346 static struct miscdevice rga2_dev ={
1347 .minor = RGA2_MAJOR,
1352 static const struct of_device_id rockchip_rga_dt_ids[] = {
1353 { .compatible = "rockchip,rga2", },
1357 static int rga2_drv_probe(struct platform_device *pdev)
1359 struct rga2_drvdata_t *data;
1360 struct resource *res;
1362 struct device_node *np = pdev->dev.of_node;
1364 mutex_init(&rga2_service.lock);
1365 mutex_init(&rga2_service.mutex);
1366 atomic_set(&rga2_service.total_running, 0);
1367 atomic_set(&rga2_service.src_format_swt, 0);
1368 rga2_service.last_prc_src_format = 1; /* default is yuv first*/
1369 rga2_service.enable = false;
1371 rga_ioctl_kernel_p = rga2_ioctl_kernel;
1373 data = devm_kzalloc(&pdev->dev, sizeof(struct rga2_drvdata_t), GFP_KERNEL);
1376 ERR("failed to allocate driver data.\n");
1380 INIT_DELAYED_WORK(&data->power_off_work, rga2_power_off_work);
1381 wake_lock_init(&data->wake_lock, WAKE_LOCK_SUSPEND, "rga");
1383 data->rga2 = devm_clk_get(&pdev->dev, "clk_rga");
1384 data->aclk_rga2 = devm_clk_get(&pdev->dev, "aclk_rga");
1385 data->hclk_rga2 = devm_clk_get(&pdev->dev, "hclk_rga");
1387 /* map the registers */
1388 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1389 data->rga_base = devm_ioremap_resource(&pdev->dev, res);
1390 if (!data->rga_base) {
1391 ERR("rga ioremap failed\n");
1397 data->irq = platform_get_irq(pdev, 0);
1398 if (data->irq <= 0) {
1399 ERR("failed to get rga irq resource (%d).\n", data->irq);
1404 /* request the IRQ */
1405 ret = devm_request_threaded_irq(&pdev->dev, data->irq, rga2_irq, rga2_irq_thread, 0, "rga", pdev);
1408 ERR("rga request_irq failed (%d).\n", ret);
1412 platform_set_drvdata(pdev, data);
1413 data->dev = &pdev->dev;
1414 rga2_drvdata = data;
1415 of_property_read_u32(np, "dev_mode", &rga2_service.dev_mode);
1417 #if defined(CONFIG_ION_ROCKCHIP)
1418 data->ion_client = rockchip_ion_client_create("rga");
1419 if (IS_ERR(data->ion_client)) {
1420 dev_err(&pdev->dev, "failed to create ion client for rga");
1421 return PTR_ERR(data->ion_client);
1423 dev_info(&pdev->dev, "rga ion client create success!\n");
1427 ret = misc_register(&rga2_dev);
1430 ERR("cannot register miscdev (%d)\n", ret);
1431 goto err_misc_register;
1433 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
1434 pm_runtime_enable(&pdev->dev);
1436 rga2_init_version();
1437 pr_info("Driver loaded successfully ver:%s\n", rga2_drvdata->version);
1442 free_irq(data->irq, pdev);
1444 iounmap(data->rga_base);
1446 wake_lock_destroy(&data->wake_lock);
1452 static int rga2_drv_remove(struct platform_device *pdev)
1454 struct rga2_drvdata_t *data = platform_get_drvdata(pdev);
1455 DBG("%s [%d]\n",__FUNCTION__,__LINE__);
1457 wake_lock_destroy(&data->wake_lock);
1458 misc_deregister(&(data->miscdev));
1459 free_irq(data->irq, &data->miscdev);
1460 iounmap((void __iomem *)(data->rga_base));
1462 devm_clk_put(&pdev->dev, data->rga2);
1463 devm_clk_put(&pdev->dev, data->aclk_rga2);
1464 devm_clk_put(&pdev->dev, data->hclk_rga2);
1466 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
1467 pm_runtime_disable(&pdev->dev);
1474 static struct platform_driver rga2_driver = {
1475 .probe = rga2_drv_probe,
1476 .remove = rga2_drv_remove,
1478 .owner = THIS_MODULE,
1480 .of_match_table = of_match_ptr(rockchip_rga_dt_ids),
1485 void rga2_test_0(void);
1487 static int __init rga2_init(void)
1492 /* malloc pre scale mid buf mmu table */
1493 buf_p = kmalloc(1024*256, GFP_KERNEL);
1494 rga2_mmu_buf.buf_virtual = buf_p;
1495 rga2_mmu_buf.buf = (uint32_t *)virt_to_phys((void *)((unsigned long)buf_p));
1496 rga2_mmu_buf.front = 0;
1497 rga2_mmu_buf.back = 64*1024;
1498 rga2_mmu_buf.size = 64*1024;
1500 rga2_mmu_buf.pages = kmalloc(32768 * sizeof(struct page *), GFP_KERNEL);
1502 ret = platform_driver_register(&rga2_driver);
1504 printk(KERN_ERR "Platform device register failed (%d).\n", ret);
1508 rga2_session_global.pid = 0x0000ffff;
1509 INIT_LIST_HEAD(&rga2_session_global.waiting);
1510 INIT_LIST_HEAD(&rga2_session_global.running);
1511 INIT_LIST_HEAD(&rga2_session_global.list_session);
1513 INIT_LIST_HEAD(&rga2_service.waiting);
1514 INIT_LIST_HEAD(&rga2_service.running);
1515 INIT_LIST_HEAD(&rga2_service.done);
1516 INIT_LIST_HEAD(&rga2_service.session);
1517 init_waitqueue_head(&rga2_session_global.wait);
1518 //mutex_lock(&rga_service.lock);
1519 list_add_tail(&rga2_session_global.list_session, &rga2_service.session);
1520 //mutex_unlock(&rga_service.lock);
1521 atomic_set(&rga2_session_global.task_running, 0);
1522 atomic_set(&rga2_session_global.num_done, 0);
1528 INFO("Module initialized.\n");
1533 static void __exit rga2_exit(void)
1537 if (rga2_mmu_buf.buf_virtual)
1538 kfree(rga2_mmu_buf.buf_virtual);
1540 platform_driver_unregister(&rga2_driver);
1546 void rga2_test_0(void)
1548 struct rga2_req req;
1549 rga2_session session;
1550 unsigned int *src, *dst;
1552 session.pid = current->pid;
1553 INIT_LIST_HEAD(&session.waiting);
1554 INIT_LIST_HEAD(&session.running);
1555 INIT_LIST_HEAD(&session.list_session);
1556 init_waitqueue_head(&session.wait);
1557 /* no need to protect */
1558 list_add_tail(&session.list_session, &rga2_service.session);
1559 atomic_set(&session.task_running, 0);
1560 atomic_set(&session.num_done, 0);
1562 memset(&req, 0, sizeof(struct rga2_req));
1563 src = kmalloc(800*480*4, GFP_KERNEL);
1564 dst = kmalloc(800*480*4, GFP_KERNEL);
1566 printk("\n********************************\n");
1567 printk("************ RGA2_TEST ************\n");
1568 printk("********************************\n\n");
1571 memset(src, 0x80, 800 * 480 * 4);
1572 memset(dst, 0xcc, 800 * 480 * 4);
1575 dmac_flush_range(src, &src[800 * 480]);
1576 outer_flush_range(virt_to_phys(src), virt_to_phys(&src[800 * 480]));
1578 dmac_flush_range(dst, &dst[800 * 480]);
1579 outer_flush_range(virt_to_phys(dst), virt_to_phys(&dst[800 * 480]));
1587 req.pat.yrgb_addr = virt_to_phys(src);
1588 req.render_mode = 0;
1589 rga2_blit_sync(&session, &req);
1595 sp = (uint8_t *)src;
1596 for (j = 0; j < 240; j++) {
1597 sp = (uint8_t *)src + j * 320 * 10 / 8;
1598 for (i = 0; i < 320; i++) {
1601 sp[i * 5 / 4+1] = 0x1;
1602 } else if ((i & 3) == 1) {
1603 sp[i * 5 / 4+1] = 0x4;
1604 } else if ((i & 3) == 2) {
1605 sp[i * 5 / 4+1] = 0x10;
1606 } else if ((i & 3) == 3) {
1607 sp[i * 5 / 4+1] = 0x40;
1611 sp = (uint8_t *)src;
1612 for (j = 0; j < 100; j++)
1613 printk("src %.2x\n", sp[j]);
1615 req.src.act_w = 320;
1616 req.src.act_h = 240;
1618 req.src.vir_w = 320;
1619 req.src.vir_h = 240;
1620 req.src.yrgb_addr = 0;//(uint32_t)virt_to_phys(src);
1621 req.src.uv_addr = (unsigned long)virt_to_phys(src);
1623 req.src.format = RGA2_FORMAT_YCbCr_420_SP_10B;
1625 req.dst.act_w = 320;
1626 req.dst.act_h = 240;
1627 req.dst.x_offset = 0;
1628 req.dst.y_offset = 0;
1630 req.dst.vir_w = 320;
1631 req.dst.vir_h = 240;
1633 req.dst.yrgb_addr = 0;//((uint32_t)virt_to_phys(dst));
1634 req.dst.uv_addr = (unsigned long)virt_to_phys(dst);
1635 req.dst.format = RGA2_FORMAT_YCbCr_420_SP;
1639 //req.render_mode = color_fill_mode;
1640 //req.fg_color = 0x80ffffff;
1642 req.rotate_mode = 0;
1643 req.scale_bicu_mode = 2;
1646 //req.alpha_rop_flag = 0;
1647 //req.alpha_rop_mode = 0x19;
1650 //req.mmu_info.mmu_flag = 0x21;
1651 //req.mmu_info.mmu_en = 1;
1653 //printk("src = %.8x\n", req.src.yrgb_addr);
1654 //printk("src = %.8x\n", req.src.uv_addr);
1655 //printk("dst = %.8x\n", req.dst.yrgb_addr);
1658 rga2_blit_sync(&session, &req);
1662 for (j = 0; j < 320 * 240 * 10 / 8; j++) {
1663 if (src[j] != dst[j])
1664 printk("error value dst not equal src j %d, s %.2x d %.2x\n",
1672 uint8_t *dp = (uint8_t *)dst;
1674 for (j = 0; j < 100; j++)
1675 printk("%d %.2x\n", j, dp[j]);
1686 module_init(rga2_init);
1687 module_exit(rga2_exit);
1689 /* Module information */
1690 MODULE_AUTHOR("zsq@rock-chips.com");
1691 MODULE_DESCRIPTION("Driver for rga device");
1692 MODULE_LICENSE("GPL");