video/rockchip: rga2: fix rga timeout when do scaling
authorMark Yao <mark.yao@rock-chips.com>
Thu, 20 Apr 2017 01:34:26 +0000 (09:34 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 20 Apr 2017 04:03:48 +0000 (12:03 +0800)
rk3368 rga sometime may timeout when do scaling, and it can't
be restore until do a non-scale rga work.

So hack that, if timeout with scaling work, do a tiny non-scale rga
work before normal work.

Change-Id: I4598741347c44a1ff3c2272270f4c6a1def36177
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/video/rockchip/rga2/rga2_drv.c

index 850d20f33f348b8208387f9b479cea4e5e175e2a..2ab9d881e9296343a23db0a6115fca23f9105f40 100644 (file)
@@ -919,6 +919,7 @@ static int rga2_blit_async(rga2_session *session, struct rga2_req *req)
 static int rga2_blit_sync(rga2_session *session, struct rga2_req *req)
 {
        struct rga2_req req_bak;
+       int restore = 0;
        int try = 10;
        int ret = -1;
        int ret_timeout = 0;
@@ -969,11 +970,30 @@ retry:
 #endif
        if (ret == -ETIMEDOUT && try--) {
                memcpy(req, &req_bak, sizeof(req_bak));
+               /*
+                * if rga work timeout with scaling, need do a non-scale work
+                * first, restore hardware status, then do actually work.
+                */
+               if (req->src.act_w != req->dst.act_w ||
+                   req->src.act_h != req->dst.act_h) {
+                       req->src.act_w = MIN(320, MIN(req->src.act_w,
+                                                     req->dst.act_w));
+                       req->src.act_h = MIN(240, MIN(req->src.act_h,
+                                                     req->dst.act_h));
+                       req->dst.act_w = req->src.act_w;
+                       req->dst.act_h = req->src.act_h;
+                       restore = 1;
+               }
+               goto retry;
+       }
+       if (!ret && restore) {
+               memcpy(req, &req_bak, sizeof(req_bak));
+               restore = 0;
                goto retry;
        }
 
        return ret;
-       }
+}
 
 static long rga_ioctl(struct file *file, uint32_t cmd, unsigned long arg)
 {