Browse Source

fix[osal]: rv1109/rv1126 vcodec_type mismatch problem

RV1126/RV1109 JPEG decoder has no PP. This will be conflict with
vcodec_type queried from kernel. Also VPU_CLIENT_VEPU2_JPEG is defined
and used only for multi-core JPEG encoder at kernel. So the following
changes is made to fix this problem:

1. This reverts commit 9b860cd250c99ea473ef0dd54d9c26ce1c4d3ad4.
2. Define a new MppDecHwCap to distinguish normal VPU with only JPEG
   supported from multi-core JPEG encoder.
3. Correct vcodec_type queried from kernel when there is no PP for
   VDPU2.

Change-Id: I58a1abe708721f725a9cf487e8f870dd5820844f
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
Johnson Ding 11 months ago
parent
commit
45f2fcbcf0
3 changed files with 49 additions and 6 deletions
  1. 4 0
      osal/inc/mpp_dev_defs.h
  2. 28 1
      osal/mpp_platform.cpp
  3. 17 5
      osal/mpp_soc.cpp

+ 4 - 0
osal/inc/mpp_dev_defs.h

@@ -48,6 +48,10 @@ typedef enum MppClientType_e {
     VPU_CLIENT_BUTT,
 } MppClientType;
 
+#define CLIENT_TYPE_MASK_DEC    0x0000ffff
+#define CLIENT_TYPE_MASK_ENC    0x0fff0000
+#define CLIENT_TYPE_MASK_VPROC  0xf0000000
+
 /* RK combined codec */
 #define HAVE_VDPU1          (1 << VPU_CLIENT_VDPU1)         /* 0x00000001 */
 #define HAVE_VDPU2          (1 << VPU_CLIENT_VDPU2)         /* 0x00000002 */

+ 28 - 1
osal/mpp_platform.cpp

@@ -133,10 +133,37 @@ MppPlatformService::MppPlatformService()
     if (mpp_get_mpp_service_name()) {
         ioctl_version = IOCTL_MPP_SERVICE_V1;
         check_mpp_service_cap(&vcodec_type, hw_ids, cap);
+        mpp_dbg_platform("vcodec_type from kernel 0x%08x, vs from soc info 0x%08x\n",
+                         vcodec_type, soc_info->vcodec_type);
     }
     kernel_version = check_kernel_version();
-    if (!vcodec_type)
+    if (!vcodec_type) {
         vcodec_type = soc_info->vcodec_type;
+    } else {
+        // Compare kernel result with soc infomation.
+        RK_U32 diff_type = vcodec_type ^ soc_info->vcodec_type;
+        RK_U32 i;
+
+        for (i = 0; i <= VPU_CLIENT_VEPU22; i++) {
+            RK_U32 mask = 1 << i;
+
+            if (diff_type & mask) {
+                MppClientType client_type = (MppClientType) i;
+
+                mpp_dbg_platform("confliction found at client_type %d\n", client_type);
+
+                if (soc_info->vcodec_type & mask) {
+                    mpp_err("client %d driver is not ready!\n", client_type);
+                } else {
+                    mpp_dbg_platform("client %d driver is ready but not declared!\n", client_type);
+                    if (client_type == VPU_CLIENT_VDPU2_PP)
+                        vcodec_type &= ~mask;
+                }
+            }
+        }
+
+        mpp_dbg_platform("vcode_type 0x%08x\n", vcodec_type);
+    }
 }
 
 RK_U32 MppPlatformService::get_hw_id(RK_S32 client_type)

+ 17 - 5
osal/mpp_soc.cpp

@@ -528,7 +528,7 @@ static const MppEncHwCap vepu2_no_jpeg = {
 
 static const MppEncHwCap vepu2_jpeg = {
     .cap_coding         = HAVE_MJPEG,
-    .type               = VPU_CLIENT_VEPU2_JPEG,
+    .type               = VPU_CLIENT_VEPU2,
     .cap_fbc            = 0,
     .cap_4k             = 0,
     .cap_8k             = 0,
@@ -537,6 +537,17 @@ static const MppEncHwCap vepu2_jpeg = {
     .reserved           = 0,
 };
 
+static const MppEncHwCap vepu2_jpeg_enhanced = {
+    .cap_coding         = HAVE_MJPEG,
+    .type               = VPU_CLIENT_VEPU2_JPEG,
+    .cap_fbc            = 0,
+    .cap_4k             = 1,
+    .cap_8k             = 0,
+    .cap_hw_osd         = 0,
+    .cap_hw_roi         = 0,
+    .reserved           = 0,
+};
+
 static const MppEncHwCap vepu22 = {
     .cap_coding         = CAP_CODING_HEVC,
     .type               = VPU_CLIENT_VEPU22,
@@ -806,7 +817,7 @@ static const MppSocInfo mpp_soc_infos[] = {
          */
         "rv1109",
         ROCKCHIP_SOC_RV1109,
-        HAVE_VDPU2 | HAVE_VEPU2_JPEG | HAVE_RKVDEC | HAVE_RKVENC,
+        HAVE_VDPU2 | HAVE_VEPU2 | HAVE_RKVDEC | HAVE_RKVENC,
         {   &vdpu2_jpeg_fix, &vdpu341_lite, NULL, NULL, NULL, NULL, },
         {   &vepu2_jpeg, &vepu541, NULL, NULL, },
     },
@@ -818,7 +829,7 @@ static const MppSocInfo mpp_soc_infos[] = {
          */
         "rv1126",
         ROCKCHIP_SOC_RV1126,
-        HAVE_VDPU2 | HAVE_VEPU2_JPEG | HAVE_RKVDEC | HAVE_RKVENC,
+        HAVE_VDPU2 | HAVE_VEPU2 | HAVE_RKVDEC | HAVE_RKVENC,
         {   &vdpu2_jpeg_fix, &vdpu341_lite, NULL, NULL, NULL, NULL, },
         {   &vepu2_jpeg, &vepu541, NULL, NULL, },
     },
@@ -904,7 +915,7 @@ static const MppSocInfo mpp_soc_infos[] = {
         HAVE_VDPU2 | HAVE_VDPU2_PP | HAVE_VEPU2 | HAVE_RKVDEC | HAVE_RKVENC |
         HAVE_JPEG_DEC | HAVE_AV1DEC | HAVE_AVSDEC | HAVE_VEPU2_JPEG,
         {   &vdpu38x, &rkjpegd, &vdpu2, &vdpu2_jpeg_pp_fix, &av1d, &avspd},
-        {   &vepu58x, &vepu2, &vepu2_jpeg, NULL, },
+        {   &vepu58x, &vepu2, &vepu2_jpeg_enhanced, NULL, },
     },
     {   /*
          * rk3528a has codec:
@@ -1073,7 +1084,8 @@ MppSocService::MppSocService()
 
     mpp_dbg_platform("coding caps: dec %08x enc %08x\n",
                      dec_coding_cap, enc_coding_cap);
-    mpp_dbg_platform("vcodec type: %08x\n", soc_info->vcodec_type);
+    mpp_dbg_platform("vcodec type from cap: %08x, from soc_info %08x\n",
+                     vcodec_type, soc_info->vcodec_type);
     mpp_assert(soc_info->vcodec_type == vcodec_type);
 }