add rga clk contorl
authorzsq <zsq@rock-chips.com>
Wed, 28 Mar 2012 22:57:24 +0000 (15:57 -0700)
committerzsq <zsq@rock-chips.com>
Wed, 28 Mar 2012 22:57:24 +0000 (15:57 -0700)
drivers/video/rockchip/rga/rga_drv.c

index da86236711e0b2c1b5b795447cf271b225961611..e5e5ebb3384a4fb184fc4fc597cdf3b6a38daba1 100755 (executable)
@@ -80,15 +80,8 @@ struct rga_drvdata {
        void *rga_base;\r
        int irq0;\r
 \r
-       struct clk *pd_display;\r
-       struct clk *aclk_lcdc;\r
-       struct clk *hclk_lcdc;\r
-       struct clk *aclk_ddr_lcdc;\r
-       struct clk *hclk_cpu_display;\r
-       struct clk *aclk_disp_matrix;\r
-       struct clk *hclk_disp_matrix;\r
-       struct clk *axi_clk;\r
-       struct clk *ahb_clk;\r
+       struct clk *aclk_rga;\r
+       struct clk *hclk_rga;\r
        \r
        struct mutex    mutex;  // mutex\r
        \r
@@ -222,16 +215,9 @@ static void rga_power_on(void)
        cancel_delayed_work_sync(&drvdata->power_off_work);\r
        if (drvdata->enable)\r
                return;\r
-    \r
-       clk_enable(drvdata->pd_display);\r
-       clk_enable(drvdata->aclk_lcdc);\r
-       clk_enable(drvdata->hclk_lcdc);\r
-       clk_enable(drvdata->aclk_ddr_lcdc);\r
-       clk_enable(drvdata->hclk_cpu_display);\r
-       clk_enable(drvdata->aclk_disp_matrix);\r
-       clk_enable(drvdata->hclk_disp_matrix);\r
-       clk_enable(drvdata->axi_clk);\r
-       clk_enable(drvdata->ahb_clk);\r
+   \r
+       clk_enable(drvdata->aclk_rga);\r
+       clk_enable(drvdata->hclk_rga);\r
 \r
        drvdata->enable = true;\r
 }\r
@@ -253,15 +239,8 @@ static void rga_power_off(struct work_struct *work)
         rga_dump();\r
        }\r
     \r
-       clk_disable(drvdata->pd_display);\r
-       clk_disable(drvdata->aclk_lcdc);\r
-       clk_disable(drvdata->hclk_lcdc);\r
-       clk_disable(drvdata->aclk_ddr_lcdc);\r
-       clk_disable(drvdata->hclk_cpu_display);\r
-       clk_disable(drvdata->aclk_disp_matrix);\r
-       clk_disable(drvdata->hclk_disp_matrix);\r
-       clk_disable(drvdata->axi_clk);\r
-       clk_disable(drvdata->ahb_clk);\r
+       clk_disable(drvdata->aclk_rga);\r
+       clk_disable(drvdata->hclk_rga);\r
 \r
        drvdata->enable = false;\r
 }\r
@@ -548,8 +527,10 @@ static void rga_try_set_reg(uint32_t num)
             struct rga_reg *reg = list_entry(rga_service.waiting.next, struct rga_reg, status_link);\r
             if((rga_read(RGA_STATUS) & 0x1)) \r
             {            \r
+                #if RGA_TEST\r
                 /* RGA is busy */\r
                 printk("no idel is here \n");\r
+                #endif\r
                 \r
                 if((atomic_read(&rga_service.cmd_num) <= 0xf) && (atomic_read(&rga_service.int_disable) == 0)) \r
                 {\r
@@ -654,6 +635,7 @@ static void rga_try_set_reg(uint32_t num)
 static int rga_blit_async(rga_session *session, struct rga_req *req)\r
 {\r
        int ret = -1;\r
+    int num = 0; \r
     struct rga_reg *reg;\r
     struct rga_req *req2;\r
 \r
@@ -681,14 +663,11 @@ static int rga_blit_async(rga_session *session, struct rga_req *req)
             reg = rga_reg_init_2(session, req, req2);\r
             if(reg == NULL) {\r
                 break;\r
-            }\r
-            \r
-            atomic_set(&reg->int_enable, 1);\r
-\r
-            rga_try_set_reg(2);\r
-            \r
+            }            \r
+            num = 2;\r
         }\r
-        else {\r
+        else \r
+        {\r
             /* check value if legal */\r
             ret = rga_check_param(req);\r
                if(ret == -EINVAL) {\r
@@ -698,10 +677,15 @@ static int rga_blit_async(rga_session *session, struct rga_req *req)
             reg = rga_reg_init(session, req);\r
             if(reg == NULL) {\r
                 return -EFAULT;\r
-            }\r
-            \r
-            rga_try_set_reg(1);        \r
+            }            \r
+            num = 1;       \r
         }        \r
+\r
+        rga_power_on();\r
+        atomic_set(&reg->int_enable, 1);        \r
+        rga_try_set_reg(num);\r
+\r
+        return 0; \r
     }\r
     while(0);\r
 \r
@@ -709,24 +693,15 @@ static int rga_blit_async(rga_session *session, struct rga_req *req)
     {\r
         kfree(req2);\r
     }\r
-   \r
-       //printk("rga_blit_async done******************\n");\r
-\r
-#if 0  \r
-error_status:\r
-error_scale:\r
-       ret = -EINVAL;\r
-       rga_soft_reset();\r
-       rga_power_off();\r
-#endif    \r
-       return ret;    \r
 \r
+    return ret;\r
 }\r
 \r
 static int rga_blit_sync(rga_session *session, struct rga_req *req)\r
 {\r
     int ret = 0;\r
     int ret_timeout = 0;\r
+    int num = 0;\r
     struct rga_reg *reg;\r
     struct rga_req *req2;\r
 \r
@@ -737,67 +712,72 @@ static int rga_blit_sync(rga_session *session, struct rga_req *req)
     daw = req->dst.act_w;\r
     dah = req->dst.act_h;\r
 \r
-    printk("req->rotate_mode = %.8x, req->scale_mode = %.8x\n", req->rotate_mode, req->scale_mode);\r
-\r
-    if((req->render_mode == bitblt_mode) && (((saw>>1) >= daw) || ((sah>>1) >= dah))) \r
+    do\r
     {\r
-        /* generate 2 cmd for pre scale */\r
-        \r
-        req2 = kmalloc(sizeof(struct rga_req), GFP_KERNEL);\r
-        if (NULL == req2) \r
+        if((req->render_mode == bitblt_mode) && (((saw>>1) >= daw) || ((sah>>1) >= dah))) \r
         {\r
-            return -EINVAL;            \r
-        }\r
-        memset(req2, 0, sizeof(struct rga_req));\r
-        \r
-        RGA_gen_two_pro(req, req2);\r
+            /* generate 2 cmd for pre scale */\r
+            \r
+            req2 = kmalloc(sizeof(struct rga_req), GFP_KERNEL);\r
+            if (NULL == req2) \r
+            {\r
+                return -EINVAL;            \r
+            }\r
+            memset(req2, 0, sizeof(struct rga_req));\r
+            \r
+            RGA_gen_two_pro(req, req2);\r
 \r
-        reg = rga_reg_init_2(session, req, req2);\r
-        if (NULL == reg) \r
-        {\r
-            return -EFAULT;\r
+            reg = rga_reg_init_2(session, req, req2);\r
+            if (NULL == reg)  \r
+            {\r
+                break;\r
+            }\r
+            num = 2;        \r
         }\r
-                \r
-        atomic_set(&reg->int_enable, 1);\r
+        else \r
+        {\r
+            /* check value if legal */        \r
+            ret = rga_check_param(req);\r
+               if(ret == -EINVAL) \r
+            {\r
+                       return -EFAULT;\r
+               }\r
+          \r
+            reg = rga_reg_init(session, req);\r
+            if(reg == NULL) \r
+            {            \r
+                return -EFAULT;\r
+            }\r
+            num = 1;        \r
+        }    \r
 \r
-        rga_try_set_reg(2);        \r
+        rga_power_on();\r
+        atomic_set(&reg->int_enable, 1);        \r
+        rga_try_set_reg(num);\r
 \r
-    }\r
-    else \r
-    {\r
-        /* check value if legal */        \r
-        ret = rga_check_param(req);\r
-       if(ret == -EINVAL) \r
+        ret_timeout = wait_event_interruptible_timeout(session->wait, atomic_read(&session->done), RGA_TIMEOUT_DELAY);\r
+        if (unlikely(ret_timeout< 0)) \r
         {\r
-               return -EFAULT;\r
+               pr_err("pid %d wait task ret %d\n", session->pid, ret_timeout);\r
+       } \r
+        else if (0 == ret_timeout)\r
+        {\r
+               pr_err("pid %d wait %d task done timeout\n", session->pid, atomic_read(&session->task_running));\r
+               ret = -ETIMEDOUT;\r
        }\r
-      \r
-        reg = rga_reg_init(session, req);\r
-        if(reg == NULL) \r
-        {            \r
-            return -EFAULT;\r
-        }\r
-        \r
-        atomic_set(&reg->int_enable, 1);        \r
-        rga_try_set_reg(1);\r
-    }    \r
+\r
+        #if RGA_TEST_TIME\r
+        rga_end = ktime_get();\r
+        rga_end = ktime_sub(rga_end, rga_start);\r
+        printk("one cmd end time %d\n", (int)ktime_to_us(rga_end));\r
+        #endif\r
+    }\r
+    while(0);\r
             \r
-    ret_timeout = wait_event_interruptible_timeout(session->wait, atomic_read(&session->done), RGA_TIMEOUT_DELAY);\r
-    if (unlikely(ret_timeout< 0)) \r
-    {\r
-               pr_err("pid %d wait task ret %d\n", session->pid, ret_timeout);\r
-       } \r
-    else if (0 == ret_timeout)\r
+    if(NULL != req2)\r
     {\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_TIME\r
-    rga_end = ktime_get();\r
-    rga_end = ktime_sub(rga_end, rga_start);\r
-    printk("one cmd end time %d\n", (int)ktime_to_us(rga_end));\r
-    #endif\r
+        kfree(req2);\r
+    }\r
         \r
     return ret;   \r
 }\r
@@ -810,7 +790,6 @@ static long rga_ioctl(struct file *file, uint32_t cmd, unsigned long arg)
     rga_session *session = (rga_session *)file->private_data;\r
 \r
     \r
-\r
        if (NULL == session) \r
     {\r
         printk("%s [%d] rga thread session is null\n",__FUNCTION__,__LINE__);\r
@@ -1099,7 +1078,7 @@ static int __devinit rga_drv_probe(struct platform_device *pdev)
 \r
     \r
        \r
-       data->axi_clk = clk_get(NULL, "aclk_rga");\r
+       data->aclk_rga = clk_get(NULL, "aclk_rga");\r
     \r
        if (IS_ERR(data->axi_clk))\r
        {\r
@@ -1108,7 +1087,7 @@ static int __devinit rga_drv_probe(struct platform_device *pdev)
                goto err_clock;\r
        }\r
 \r
-       data->ahb_clk = clk_get(&pdev->dev, "hclk_rga");\r
+       data->hclk_rga = clk_get(NULL, "hclk_rga");\r
        if (IS_ERR(data->ahb_clk))\r
        {\r
                ERR("failed to find rga ahb clock source\n");\r