Merge tag 'v4.4-rc7'
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / rga / RGA_API.c
index 0b48f95c8e5a4fbc653c8dc513b23f4b31cec616..7055d858d8a47064c32c9412f1af564f541fbf2c 100755 (executable)
@@ -6,18 +6,18 @@
 \r
 #define IS_YUV_420(format) \\r
      ((format == RK_FORMAT_YCbCr_420_P) | (format == RK_FORMAT_YCbCr_420_SP) | \\r
-      (format == RK_FORMAT_YCrCb_420_P) | (format == RK_FORMAT_YCrCb_420_SP))  \r
+      (format == RK_FORMAT_YCrCb_420_P) | (format == RK_FORMAT_YCrCb_420_SP))\r
 \r
 #define IS_YUV_422(format) \\r
      ((format == RK_FORMAT_YCbCr_422_P) | (format == RK_FORMAT_YCbCr_422_SP) | \\r
-      (format == RK_FORMAT_YCrCb_422_P) | (format == RK_FORMAT_YCrCb_422_SP))   \r
+      (format == RK_FORMAT_YCrCb_422_P) | (format == RK_FORMAT_YCrCb_422_SP))\r
 \r
 #define IS_YUV(format) \\r
      ((format == RK_FORMAT_YCbCr_420_P) | (format == RK_FORMAT_YCbCr_420_SP) | \\r
       (format == RK_FORMAT_YCrCb_420_P) | (format == RK_FORMAT_YCrCb_420_SP) | \\r
       (format == RK_FORMAT_YCbCr_422_P) | (format == RK_FORMAT_YCbCr_422_SP) | \\r
       (format == RK_FORMAT_YCrCb_422_P) | (format == RK_FORMAT_YCrCb_422_SP))\r
-            \r
+\r
 \r
 extern rga_service_info rga_service;\r
 \r
@@ -42,7 +42,7 @@ matrix_cal(const struct rga_req *msg, TILE_INFO *tile)
 \r
     x_time = ((s_act_w - 1)<<16) / (d_act_w - 1);\r
     y_time = ((s_act_h - 1)<<16) / (d_act_h - 1);\r
-    \r
+\r
     sina = msg->sina;\r
     cosa = msg->cosa;\r
 \r
@@ -51,36 +51,36 @@ matrix_cal(const struct rga_req *msg, TILE_INFO *tile)
         /* 16.16 x 16.16 */\r
         /* matrix[] is 64 bit wide */\r
         case 1 :\r
-            tile->matrix[0] =  cosa*x_time;    \r
-            tile->matrix[1] = -sina*y_time;      \r
-            tile->matrix[2] =  sina*x_time;       \r
+            tile->matrix[0] =  cosa*x_time;\r
+            tile->matrix[1] = -sina*y_time;\r
+            tile->matrix[2] =  sina*x_time;\r
             tile->matrix[3] =  cosa*y_time;\r
             break;\r
         case 2 :\r
-            tile->matrix[0] = -(x_time<<16);       \r
-            tile->matrix[1] = 0;      \r
-            tile->matrix[2] = 0;       \r
+            tile->matrix[0] = -(x_time<<16);\r
+            tile->matrix[1] = 0;\r
+            tile->matrix[2] = 0;\r
             tile->matrix[3] = (y_time<<16);\r
             break;\r
         case 3 :\r
-            tile->matrix[0] = (x_time<<16);       \r
-            tile->matrix[1] = 0;      \r
-            tile->matrix[2] = 0;       \r
+            tile->matrix[0] = (x_time<<16);\r
+            tile->matrix[1] = 0;\r
+            tile->matrix[2] = 0;\r
             tile->matrix[3] = -(y_time<<16);\r
             break;\r
         default :\r
-            tile->matrix[0] =  (uint64_t)1<<32;       \r
-            tile->matrix[1] =  0;      \r
-            tile->matrix[2] =  0;       \r
+            tile->matrix[0] =  (uint64_t)1<<32;\r
+            tile->matrix[1] =  0;\r
+            tile->matrix[2] =  0;\r
             tile->matrix[3] =  (uint64_t)1<<32;\r
-            break;            \r
-    }    \r
+            break;\r
+    }\r
 }\r
 \r
 \r
 int32_t RGA_gen_two_pro(struct rga_req *msg, struct rga_req *msg1)\r
 {\r
-    \r
+\r
     struct rga_req *mp;\r
     uint32_t w_ratio, h_ratio;\r
     uint32_t stride;\r
@@ -89,10 +89,10 @@ int32_t RGA_gen_two_pro(struct rga_req *msg, struct rga_req *msg1)
     uint32_t pl;\r
 \r
     daw = dah = 0;\r
-            \r
+\r
     mp = msg1;\r
 \r
-    if(msg->dst.act_w == 0) \r
+    if(msg->dst.act_w == 0)\r
     {\r
         printk("%s, [%d] rga dst act_w is zero\n", __FUNCTION__, __LINE__);\r
         return -EINVAL;\r
@@ -105,57 +105,57 @@ int32_t RGA_gen_two_pro(struct rga_req *msg, struct rga_req *msg1)
     }\r
     w_ratio = (msg->src.act_w << 16) / msg->dst.act_w;\r
     h_ratio = (msg->src.act_h << 16) / msg->dst.act_h;\r
-    \r
+\r
     memcpy(msg1, msg, sizeof(struct rga_req));\r
 \r
     msg->dst.format = msg->src.format;\r
 \r
     /*pre_scale_w cal*/\r
-    if ((w_ratio >= (2<<16)) && (w_ratio < (4<<16))) {            \r
+    if ((w_ratio >= (2<<16)) && (w_ratio < (4<<16))) {\r
         daw = (msg->src.act_w + 1) >> 1;\r
         if((IS_YUV_420(msg->dst.format)) && (daw & 1)) {\r
             daw -= 1;\r
             msg->src.act_w = daw << 1;\r
-        }        \r
+        }\r
     }\r
     else if ((w_ratio >= (4<<16)) && (w_ratio < (8<<16))) {\r
-        daw = (msg->src.act_w + 3) >> 2;            \r
+        daw = (msg->src.act_w + 3) >> 2;\r
         if((IS_YUV_420(msg->dst.format)) && (daw & 1)) {\r
             daw -= 1;\r
-            msg->src.act_w = daw << 2;                                                                \r
+            msg->src.act_w = daw << 2;\r
         }\r
     }\r
     else if ((w_ratio >= (8<<16)) && (w_ratio < (16<<16))) {\r
         daw = (msg->src.act_w + 7) >> 3;\r
         if((IS_YUV_420(msg->dst.format)) && (daw & 1)) {\r
             daw -= 1;\r
-            msg->src.act_w = daw << 3;                                                                \r
+            msg->src.act_w = daw << 3;\r
         }\r
     }\r
     else\r
     {\r
         daw = msg->src.act_w;\r
     }\r
-    \r
+\r
     pl = (RGA_pixel_width_init(msg->src.format));\r
     stride = (pl * daw + 3) & (~3);\r
     msg->dst.act_w = daw;\r
     msg->dst.vir_w = stride / pl;\r
 \r
-    /*pre_scale_h cal*/        \r
-    if ((h_ratio >= (2<<16)) && (h_ratio < (4<<16))) {            \r
+    /*pre_scale_h cal*/\r
+    if ((h_ratio >= (2<<16)) && (h_ratio < (4<<16))) {\r
         dah = (msg->src.act_h + 1) >> 1;\r
         if((IS_YUV(msg->dst.format)) && (dah & 1)) {\r
             dah -= 1;\r
             msg->src.act_h = dah << 1;\r
-        }            \r
+        }\r
     }\r
     else if ((h_ratio >= (4<<16)) && (h_ratio < (8<<16))) {\r
         dah = (msg->src.act_h + 3) >> 2;\r
         if((IS_YUV(msg->dst.format)) && (dah & 1)) {\r
             dah -= 1;\r
             msg->src.act_h = dah << 2;\r
-            \r
+\r
         }\r
     }\r
     else if ((h_ratio >= (8<<16)) && (h_ratio < (16<<16))) {\r
@@ -169,14 +169,14 @@ int32_t RGA_gen_two_pro(struct rga_req *msg, struct rga_req *msg1)
     {\r
         dah = msg->src.act_h;\r
     }\r
-        \r
+\r
     msg->dst.act_h = dah;\r
     msg->dst.vir_h = dah;\r
 \r
     msg->dst.x_offset = 0;\r
     msg->dst.y_offset = 0;\r
-            \r
-    msg->dst.yrgb_addr = (u32)rga_service.pre_scale_buf;\r
+\r
+    msg->dst.yrgb_addr = (unsigned long)rga_service.pre_scale_buf;\r
     msg->dst.uv_addr = msg->dst.yrgb_addr + stride * dah;\r
     msg->dst.v_addr = msg->dst.uv_addr + ((stride * dah) >> 1);\r
 \r
@@ -193,7 +193,7 @@ int32_t RGA_gen_two_pro(struct rga_req *msg, struct rga_req *msg1)
 \r
     msg1->src.x_offset = 0;\r
     msg1->src.y_offset = 0;\r
-            \r
+\r
     return 0;\r
 }\r
 \r