\r
#define RGA_TEST 0\r
#define RGA_TEST_TIME 0\r
+#define RGA_TEST_FLUSH_TIME 0\r
+\r
\r
#define PRE_SCALE_BUF_SIZE 2048*1024*4\r
\r
static void rga_power_on(void)\r
{\r
//printk("rga_power_on\n");\r
- cancel_delayed_work_sync(&drvdata->power_off_work);\r
+ //cancel_delayed_work_sync(&drvdata->power_off_work);\r
if (drvdata->enable)\r
return;\r
\r
}\r
\r
\r
-static void rga_power_off(struct work_struct *work)\r
+static void rga_power_off(void)\r
{\r
int total_running;\r
\r
{\r
//printk("rga_get_result %d\n",drvdata->rga_result);\r
\r
- int ret;\r
+ int ret = 0;\r
+ int ret_timeout;\r
\r
- ret = wait_event_interruptible_timeout(session->wait, atomic_read(&session->done), RGA_TIMEOUT_DELAY);\r
\r
- if (unlikely(ret < 0)) {\r
+ #if RGA_TEST_FLUSH_TIME\r
+ ktime_t start;\r
+ ktime_t end;\r
+ start = ktime_get();\r
+ #endif\r
+\r
+ ret_timeout = wait_event_interruptible_timeout(session->wait, atomic_read(&session->done), RGA_TIMEOUT_DELAY);\r
+ \r
+ if (unlikely(ret_timeout < 0)) {\r
pr_err("pid %d wait task ret %d\n", session->pid, ret);\r
- } else if (0 == ret) {\r
+ ret = -ETIMEDOUT;\r
+ } else if (0 == ret_timeout) {\r
pr_err("pid %d wait %d task done timeout\n", session->pid, atomic_read(&session->task_running));\r
ret = -ETIMEDOUT;\r
}\r
+\r
+ #if RGA_TEST_FLUSH_TIME\r
+ end = ktime_get();\r
+ end = ktime_sub(end, start);\r
+ printk("one flush wait time %d\n", (int)ktime_to_us(end));\r
+ #endif\r
\r
return ret;\r
}\r
ERR("copy_to_user failed\n");\r
ret = -EFAULT; \r
}\r
- //idle_condition = 1;\r
- //dmac_clean_range((const void*)&idle_condition,(const void*)&idle_condition+4);\r
- //wake_up_interruptible_sync(&blit_wait_queue);\r
return ret;\r
}\r
\r
\r
return;\r
}\r
- \r
+ \r
spin_lock_irqsave(&rga_service.lock, flag);\r
if (!list_empty(&rga_service.waiting)) \r
{\r
do\r
{ \r
struct rga_reg *reg = list_entry(rga_service.waiting.next, struct rga_reg, status_link);\r
+ \r
+ //if(((reg->cmd_reg[0] & 0xf0) >= 3) && ((reg->cmd_reg[0] & 0xf0) <= 7) && rga_service.last_prc_src_format == 0) \r
+ \r
offset = atomic_read(&rga_service.cmd_num);\r
if((rga_read(RGA_STATUS) & 0x1)) \r
- { \r
+ { \r
+ #if 0\r
#if RGA_TEST\r
/* RGA is busy */\r
- printk("no idel is here \n");\r
+ printk(" rga try set reg while rga is working \n");\r
#endif\r
\r
if((atomic_read(&rga_service.cmd_num) <= 0xf) && (atomic_read(&rga_service.int_disable) == 0)) \r
if(atomic_read(®->int_enable))\r
atomic_set(&rga_service.int_disable, 1);\r
}\r
+ #endif\r
+ break;\r
}\r
else \r
{ \r
}\r
\r
\r
+static void print_info(struct rga_req *req)\r
+{\r
+ #if RGA_TEST \r
+ printk("src.yrgb_addr = %.8x, src.uv_addr = %.8x, src.v_addr = %.8x\n", \r
+ req->src.yrgb_addr, req->src.uv_addr, req->src.v_addr);\r
+ printk("src : act_w = %d, act_h = %d, vir_w = %d, vir_h = %d\n", \r
+ req->src.act_w, req->src.act_h, req->src.vir_w, req->src.vir_h);\r
+ printk("src : x_offset = %.8x y_offset = %.8x\n", req->src.x_offset, req->src.y_offset);\r
+ \r
+ printk("dst.yrgb_addr = %.8x, dst.uv_addr = %.8x, dst.v_addr = %.8x\n", \r
+ req->dst.yrgb_addr, req->dst.uv_addr, req->dst.v_addr); \r
+ printk("dst : x_offset = %.8x y_offset = %.8x\n", req->dst.x_offset, req->dst.y_offset);\r
+ printk("dst : act_w = %d, act_h = %d, vir_w = %d, vir_h = %d\n", \r
+ req->dst.act_w, req->dst.act_h, req->dst.vir_w, req->dst.vir_h);\r
+\r
+ printk("clip.xmin = %d, clip.xmax = %d. clip.ymin = %d, clip.ymax = %d\n", \r
+ req->clip.xmin, req->clip.xmax, req->clip.ymin, req->clip.ymax);\r
+ #endif\r
+}\r
+\r
\r
static int rga_blit_async(rga_session *session, struct rga_req *req)\r
{\r
req2 = NULL;\r
\r
#if RGA_TEST\r
- printk("src.yrgb_addr = %.8x, src.uv_addr = %.8x, src.v_addr = %.8x\n", \r
- req->src.yrgb_addr, req->src.uv_addr, req->src.v_addr);\r
- printk("dst.yrgb_addr = %.8x, dst.uv_addr = %.8x, dst.v_addr = %.8x\n", \r
- req->dst.yrgb_addr, req->dst.uv_addr, req->dst.v_addr); \r
+ printk("*** rga_blit_async proc ***\n");\r
+ print_info(req);\r
#endif\r
\r
saw = req->src.act_w;\r
daw = req->dst.act_w;\r
dah = req->dst.act_h;\r
\r
+ /* special case proc */\r
+ if(req->src.act_w == 360 && req->src.act_h == 64 && req->rotate_mode == 0)\r
+ req->rotate_mode = 1;\r
+\r
do\r
{\r
if((req->render_mode == bitblt_mode) && (((saw>>1) >= daw) || ((sah>>1) >= dah))) \r
if(NULL == req2) {\r
return -EINVAL; \r
}\r
+\r
+ ret = rga_check_param(req);\r
+ if(ret == -EINVAL) {\r
+ break;\r
+ }\r
+\r
+ ret = rga_check_param(req2);\r
+ if(ret == -EINVAL) {\r
+ break;\r
+ }\r
\r
RGA_gen_two_pro(req, req2);\r
\r
kfree(req2);\r
}\r
\r
- return ret;\r
+ return -EFAULT;\r
}\r
\r
static int rga_blit_sync(rga_session *session, struct rga_req *req)\r
dah = req->dst.act_h;\r
\r
#if RGA_TEST\r
-\r
- printk("src.yrgb_addr = %.8x, src.uv_addr = %.8x, src.v_addr = %.8x\n", \r
- req->src.yrgb_addr, req->src.uv_addr, req->src.v_addr);\r
- printk("dst.yrgb_addr = %.8x, dst.uv_addr = %.8x, dst.v_addr = %.8x\n", \r
- req->dst.yrgb_addr, req->dst.uv_addr, req->dst.v_addr); \r
+ printk("*** rga_blit_sync proc ***\n");\r
+ print_info(req);\r
#endif\r
\r
+ /* special case proc*/\r
+ if(req->src.act_w == 360 && req->src.act_h == 64 && req->rotate_mode == 0)\r
+ req->rotate_mode = 1;\r
+ \r
+\r
do\r
{\r
if((req->render_mode == bitblt_mode) && (((saw>>1) >= daw) || ((sah>>1) >= dah))) \r
ret_timeout = wait_event_interruptible_timeout(session->wait, atomic_read(&session->done), RGA_TIMEOUT_DELAY);\r
\r
rga_soft_reset();\r
+ \r
if (unlikely(ret_timeout< 0)) \r
{\r
pr_err("pid %d wait task ret %d\n", session->pid, ret_timeout);\r
printk("one cmd end time %d\n", (int)ktime_to_us(rga_end));\r
#endif\r
\r
- return 0;\r
+ return ret;\r
}\r
while(0);\r
\r
struct rga_req *req;\r
int ret = 0;\r
rga_session *session = (rga_session *)file->private_data;\r
-\r
\r
if (NULL == session) \r
{\r
ERR("copy_from_user failed\n");\r
ret = -EFAULT;\r
}\r
- ret = rga_blit_async(session, req); \r
+ ret = rga_blit_async(session, req); \r
break;\r
case RGA_FLUSH:\r
ret = rga_flush(session, arg);\r
struct list_head *next;\r
int int_enable = 0;\r
\r
- DBG("rga_irq %d \n", irq);\r
+ //DBG("rga_irq %d \n", irq);\r
\r
#if RGA_TEST\r
printk("rga_irq is valid\n");\r
\r
if(((rga_read(RGA_STATUS) & 0x1) != 0))// idle\r
{ \r
- printk(" INT ERROR RGA is not idle!\n");\r
+ printk(" irq ERROR : RGA is not idle!\n");\r
rga_soft_reset();\r
}\r
\r
static void rga_shutdown(struct platform_device *pdev)\r
{\r
pr_cont("shutdown..."); \r
- //rga_power_off(NULL); \r
+ //rga_power_off(); \r
pr_cont("done\n");\r
}\r
\r
\r
data = kmalloc(sizeof(struct rga_drvdata), GFP_KERNEL);\r
\r
+ memset(data, 0x0, sizeof(struct rga_drvdata));\r
+\r
INIT_LIST_HEAD(&rga_service.waiting);\r
INIT_LIST_HEAD(&rga_service.running);\r
INIT_LIST_HEAD(&rga_service.done);\r
INIT_LIST_HEAD(&rga_service.session);\r
spin_lock_init(&rga_service.lock);\r
atomic_set(&rga_service.total_running, 0);\r
- rga_service.enabled = false; \r
+ atomic_set(&rga_service.src_format_swt, 0);\r
+ rga_service.last_prc_src_format = 1; /* default is yuv first*/\r
+ rga_service.enabled = false; \r
\r
if(NULL == data)\r
{\r
ERR("failed to allocate driver data.\n");\r
return -ENOMEM;\r
}\r
-\r
- #if 0\r
- /* get the clock */\r
- data->pd_display = clk_get(&pdev->dev, "pd_display");\r
- if (IS_ERR(data->pd_display))\r
- {\r
- ERR("failed to find rga pd_display source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
-\r
- data->aclk_lcdc = clk_get(&pdev->dev, "aclk_lcdc");\r
- if (IS_ERR(data->aclk_lcdc))\r
- {\r
- ERR("failed to find rga aclk_lcdc source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
- \r
- data->hclk_lcdc = clk_get(&pdev->dev, "hclk_lcdc");\r
- if (IS_ERR(data->hclk_lcdc))\r
- {\r
- ERR("failed to find rga hclk_lcdc source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
-\r
- data->aclk_ddr_lcdc = clk_get(&pdev->dev, "aclk_ddr_lcdc");\r
- if (IS_ERR(data->aclk_ddr_lcdc))\r
- {\r
- ERR("failed to find rga aclk_ddr_lcdc source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
-\r
- data->hclk_cpu_display = clk_get(&pdev->dev, "hclk_cpu_display");\r
- if (IS_ERR(data->hclk_cpu_display))\r
- {\r
- ERR("failed to find rga hclk_cpu_display source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
-\r
- data->aclk_disp_matrix = clk_get(&pdev->dev, "aclk_disp_matrix");\r
- if (IS_ERR(data->aclk_disp_matrix))\r
- {\r
- ERR("failed to find rga aclk_disp_matrix source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
-\r
- data->hclk_disp_matrix = clk_get(&pdev->dev, "hclk_disp_matrix");\r
- if (IS_ERR(data->hclk_disp_matrix))\r
- {\r
- ERR("failed to find rga hclk_disp_matrix source\n");\r
- ret = -ENOENT;\r
- goto err_clock;\r
- }\r
-\r
- #endif\r
\r
data->aclk_rga = clk_get(NULL, "aclk_rga"); \r
if (IS_ERR(data->aclk_rga))\r
{\r
- ERR("failed to find rga axi clock source\n");\r
+ ERR("failed to find rga axi clock source.\n");\r
ret = -ENOENT;\r
goto err_clock;\r
}\r
data->hclk_rga = clk_get(NULL, "hclk_rga");\r
if (IS_ERR(data->hclk_rga))\r
{\r
- ERR("failed to find rga ahb clock source\n");\r
+ ERR("failed to find rga ahb clock source.\n");\r
ret = -ENOENT;\r
goto err_clock;\r
- } \r
+ }\r
+\r
+ //rga_power_on();\r
\r
/* map the memory */\r
if (!request_mem_region(RK30_RGA_PHYS, RK30_RGA_SIZE, "rga_io")) \r
ERR("cannot register miscdev (%d)\n", ret);\r
goto err_misc_register;\r
}\r
+\r
+ //rga_power_off();\r
+ \r
DBG("RGA Driver loaded succesfully\n");\r
\r
return 0; \r
\r
misc_deregister(&(data->miscdev));\r
free_irq(data->irq0, &data->miscdev);\r
- iounmap((void __iomem *)(data->rga_base));\r
- \r
- #if 0 \r
- if(data->axi_clk) {\r
- clk_put(data->axi_clk);\r
- }\r
- \r
- if(data->ahb_clk) {\r
- clk_put(data->ahb_clk);\r
- }\r
- \r
- if(data->aclk_disp_matrix) {\r
- clk_put(data->aclk_disp_matrix);\r
- }\r
-\r
- if(data->hclk_disp_matrix) {\r
- clk_put(data->hclk_disp_matrix);\r
- }\r
- \r
- \r
-\r
- if(data->aclk_lcdc) {\r
- clk_put(data->aclk_lcdc);\r
- }\r
- \r
- if(data->hclk_cpu_display) {\r
- clk_put(data->hclk_cpu_display);\r
- }\r
-\r
- if(data->pd_display){\r
- clk_put(data->pd_display);\r
- }\r
- #endif\r
+ iounmap((void __iomem *)(data->rga_base)); \r
\r
if(data->aclk_rga) {\r
clk_put(data->aclk_rga);\r
{\r
uint32_t i;\r
\r
+ rga_power_off();\r
+\r
for(i=0; i<2048; i++)\r
{\r
if((uint32_t *)rga_service.pre_scale_buf[i] != NULL)\r
#if 0\r
\r
#include "320x240_swap0_Y4200.h"\r
+#include "320x240_swap0_U4200.h"\r
+#include "320x240_swap0_V4200.h"\r
#include "320x240_swap0_UV4200.h"\r
#include "320x240_swap0_ABGR8888.h"\r
\r
extern void rk_direct_fb_show(struct fb_info * fbi);\r
EXPORT_SYMBOL(rk_direct_fb_show);\r
\r
+unsigned int src_buf[360*64];\r
unsigned int dst_buf[1280*800];\r
\r
void rga_test_0(void)\r
fb = rk_get_fb(0);\r
\r
memset(&req, 0, sizeof(struct rga_req));\r
- src = Y4200_320_240_swap0;\r
+ src = src_buf;\r
dst = dst_buf;\r
+\r
+ memset(src_buf, 0x80, 360*64*4);\r
+\r
+ dmac_flush_range(&src_buf[0], &src_buf[360*64]);\r
+ outer_flush_range(virt_to_phys(&src_buf[0]),virt_to_phys(&src_buf[360*64]));\r
\r
#if 0\r
memset(src_buf, 0x80, 800*480*4);\r
memset(dst_buf, 0xcc, 800*480*4);\r
-\r
- dmac_flush_range(&src_buf[0], &src_buf[800*480]);\r
- outer_flush_range(virt_to_phys(&src_buf[0]),virt_to_phys(&src_buf[800*480]));\r
- \r
+ \r
dmac_flush_range(&dst_buf[0], &dst_buf[800*480]);\r
outer_flush_range(virt_to_phys(&dst_buf[0]),virt_to_phys(&dst_buf[800*480]));\r
#endif\r
\r
req.src.vir_w = 320;\r
req.src.vir_h = 240;\r
- req.src.yrgb_addr = (uint32_t)src;\r
- req.src.uv_addr = (uint32_t)UV4200_320_240_swap0;\r
- req.src.format = 0xa;\r
+ req.src.yrgb_addr = (uint32_t)Y4200_320_240_swap0;\r
+ req.src.uv_addr = (uint32_t)U4200_320_240_swap0;\r
+ req.src.v_addr = (uint32_t)V4200_320_240_swap0;\r
+ req.src.format = RK_FORMAT_YCbCr_420_P;\r
\r
- req.dst.act_w = 100;\r
- req.dst.act_h = 80;\r
+ req.dst.act_w = 320;\r
+ req.dst.act_h = 240;\r
\r
req.dst.vir_w = 1280;\r
req.dst.vir_h = 800;\r
- req.dst.x_offset = 0;\r
- req.dst.y_offset = 000;\r
+ req.dst.x_offset = 100;\r
+ req.dst.y_offset = 100;\r
req.dst.yrgb_addr = (uint32_t)dst;\r
\r
req.clip.xmin = 0;\r
req.clip.ymin = 0;\r
req.clip.ymax = 799;\r
\r
- req.rotate_mode = 1;\r
- req.scale_mode = 2;\r
+ req.rotate_mode = 0;\r
+ req.scale_mode = 0;\r
\r
req.alpha_rop_flag = 0;\r
\r