media: venus: add firmware version based check
authorDikshita Agarwal <quic_dikshita@quicinc.com>
Mon, 22 May 2023 06:02:50 +0000 (07:02 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 9 Jun 2023 12:46:45 +0000 (13:46 +0100)
Add firmware version based checks to enable/disable
features for different SOCs.

Tested-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/qcom/venus/core.h
drivers/media/platform/qcom/venus/hfi_msgs.c

index 4f81669986ba7f3ff0a6a09079f619311629ae20..12a42fbeda479407ed72178bb3c77c8d14b34f60 100644 (file)
@@ -201,6 +201,11 @@ struct venus_core {
        unsigned int core0_usage_count;
        unsigned int core1_usage_count;
        struct dentry *root;
+       struct venus_img_version {
+               u32 major;
+               u32 minor;
+               u32 rev;
+       } venus_ver;
 };
 
 struct vdec_controls {
@@ -508,4 +513,19 @@ venus_caps_by_codec(struct venus_core *core, u32 codec, u32 domain)
        return NULL;
 }
 
+static inline bool
+is_fw_rev_or_newer(struct venus_core *core, u32 vmajor, u32 vminor, u32 vrev)
+{
+       return ((core)->venus_ver.major == vmajor &&
+               (core)->venus_ver.minor == vminor &&
+               (core)->venus_ver.rev >= vrev);
+}
+
+static inline bool
+is_fw_rev_or_older(struct venus_core *core, u32 vmajor, u32 vminor, u32 vrev)
+{
+       return ((core)->venus_ver.major == vmajor &&
+               (core)->venus_ver.minor == vminor &&
+               (core)->venus_ver.rev <= vrev);
+}
 #endif
index 6efd78606d9b4499a45aceea2fd9b786f07bf596..3d5dadfa19009ee8dffbd49e93f6d2912314f600 100644 (file)
@@ -248,13 +248,15 @@ done:
 }
 
 static void
-sys_get_prop_image_version(struct device *dev,
+sys_get_prop_image_version(struct venus_core *core,
                           struct hfi_msg_sys_property_info_pkt *pkt)
 {
+       struct device *dev = core->dev;
        u8 *smem_tbl_ptr;
        u8 *img_ver;
        int req_bytes;
        size_t smem_blk_sz;
+       int ret;
 
        req_bytes = pkt->hdr.size - sizeof(*pkt);
 
@@ -263,8 +265,30 @@ sys_get_prop_image_version(struct device *dev,
                return;
 
        img_ver = pkt->data;
+       if (!img_ver)
+               return;
+
+       ret = sscanf(img_ver, "14:video-firmware.%u.%u-%u",
+                    &core->venus_ver.major, &core->venus_ver.minor, &core->venus_ver.rev);
+       if (ret)
+               goto done;
+
+       ret = sscanf(img_ver, "14:VIDEO.VPU.%u.%u-%u",
+                    &core->venus_ver.major, &core->venus_ver.minor, &core->venus_ver.rev);
+       if (ret)
+               goto done;
+
+       ret = sscanf(img_ver, "14:VIDEO.VE.%u.%u-%u",
+                    &core->venus_ver.major, &core->venus_ver.minor, &core->venus_ver.rev);
+       if (ret)
+               goto done;
 
-       dev_dbg(dev, VDBGL "F/W version: %s\n", img_ver);
+       dev_err(dev, VDBGL "error reading F/W version\n");
+       return;
+
+done:
+       dev_dbg(dev, VDBGL "F/W version: %s, major %u, minor %u, revision %u\n",
+               img_ver, core->venus_ver.major, core->venus_ver.minor, core->venus_ver.rev);
 
        smem_tbl_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
                SMEM_IMG_VER_TBL, &smem_blk_sz);
@@ -286,7 +310,7 @@ static void hfi_sys_property_info(struct venus_core *core,
 
        switch (pkt->property) {
        case HFI_PROPERTY_SYS_IMAGE_VERSION:
-               sys_get_prop_image_version(dev, pkt);
+               sys_get_prop_image_version(core, pkt);
                break;
        default:
                dev_dbg(dev, VDBGL "unknown property data\n");