media: venus: Introduce accessors for remapped hfi_buffer_reqs members
authorKonrad Dybcio <konrad.dybcio@linaro.org>
Tue, 30 May 2023 12:30:49 +0000 (14:30 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Thu, 10 Aug 2023 05:58:35 +0000 (07:58 +0200)
Currently we have macros to access these, but they don't provide a
way to override the remapped fields. Replace the macros with actual
get/set pairs to fix that.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/hfi_helper.h
drivers/media/platform/qcom/venus/hfi_msgs.c
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/vdec_ctrls.c
drivers/media/platform/qcom/venus/venc.c
drivers/media/platform/qcom/venus/venc_ctrls.c

index 1822e85ab6bf829990504c196555c26e482f02fd..b70bd3dac4df06a8e58dd30f77e4df96823efd83 100644 (file)
@@ -189,7 +189,7 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst)
        if (ret)
                return ret;
 
-       count = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+       count = hfi_bufreq_get_count_min(&bufreq, ver);
 
        for (i = 0; i < count; i++) {
                buf = kzalloc(sizeof(*buf), GFP_KERNEL);
index 0abbc50c586424d8bc381efb49fd03bdc8f83302..e4c05d62cfc7444401dd432eccf627c0b475dcd6 100644 (file)
@@ -1170,14 +1170,6 @@ struct hfi_buffer_display_hold_count_actual {
        u32 hold_count;
 };
 
-/* HFI 4XX reorder the fields, use these macros */
-#define HFI_BUFREQ_HOLD_COUNT(bufreq, ver)     \
-       ((ver) == HFI_VERSION_4XX ? 0 : (bufreq)->hold_count)
-#define HFI_BUFREQ_COUNT_MIN(bufreq, ver)      \
-       ((ver) == HFI_VERSION_4XX ? (bufreq)->hold_count : (bufreq)->count_min)
-#define HFI_BUFREQ_COUNT_MIN_HOST(bufreq, ver) \
-       ((ver) == HFI_VERSION_4XX ? (bufreq)->count_min : 0)
-
 struct hfi_buffer_requirements {
        u32 type;
        u32 size;
@@ -1189,6 +1181,59 @@ struct hfi_buffer_requirements {
        u32 alignment;
 };
 
+/* On HFI 4XX, some of the struct members have been swapped. */
+static inline u32 hfi_bufreq_get_hold_count(struct hfi_buffer_requirements *req,
+                                           u32 ver)
+{
+       if (ver == HFI_VERSION_4XX)
+               return 0;
+
+       return req->hold_count;
+};
+
+static inline u32 hfi_bufreq_get_count_min(struct hfi_buffer_requirements *req,
+                                          u32 ver)
+{
+       if (ver == HFI_VERSION_4XX)
+               return req->hold_count;
+
+       return req->count_min;
+};
+
+static inline u32 hfi_bufreq_get_count_min_host(struct hfi_buffer_requirements *req,
+                                               u32 ver)
+{
+       if (ver == HFI_VERSION_4XX)
+               return req->count_min;
+
+       return 0;
+};
+
+static inline void hfi_bufreq_set_hold_count(struct hfi_buffer_requirements *req,
+                                            u32 ver, u32 val)
+{
+       if (ver == HFI_VERSION_4XX)
+               return;
+
+       req->hold_count = val;
+};
+
+static inline void hfi_bufreq_set_count_min(struct hfi_buffer_requirements *req,
+                                           u32 ver, u32 val)
+{
+       if (ver == HFI_VERSION_4XX)
+               req->hold_count = val;
+
+       req->count_min = val;
+};
+
+static inline void hfi_bufreq_set_count_min_host(struct hfi_buffer_requirements *req,
+                                                u32 ver, u32 val)
+{
+       if (ver == HFI_VERSION_4XX)
+               req->count_min = val;
+};
+
 struct hfi_data_payload {
        u32 size;
        u8 data[1];
index 3d5dadfa19009ee8dffbd49e93f6d2912314f600..7cab685a2ec804e0cf2a1dbc54df47eeceb49fcc 100644 (file)
@@ -99,7 +99,7 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst,
                case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS:
                        data_ptr += sizeof(u32);
                        bufreq = (struct hfi_buffer_requirements *)data_ptr;
-                       event.buf_count = HFI_BUFREQ_COUNT_MIN(bufreq, ver);
+                       event.buf_count = hfi_bufreq_get_count_min(bufreq, ver);
                        data_ptr += sizeof(*bufreq);
                        break;
                case HFI_INDEX_EXTRADATA_INPUT_CROP:
index 085f6967e7ab843808feda5344c211adc761c5e0..dbf305cec12024a41523ae73143a4ea55cd60246 100644 (file)
@@ -899,13 +899,13 @@ static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num,
        if (ret)
                return ret;
 
-       *in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+       *in_num = hfi_bufreq_get_count_min(&bufreq, ver);
 
        ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
        if (ret)
                return ret;
 
-       *out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+       *out_num = hfi_bufreq_get_count_min(&bufreq, ver);
 
        return 0;
 }
@@ -1019,14 +1019,14 @@ static int vdec_verify_conf(struct venus_inst *inst)
                return ret;
 
        if (inst->num_output_bufs < bufreq.count_actual ||
-           inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+           inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
                return -EINVAL;
 
        ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
        if (ret)
                return ret;
 
-       if (inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+       if (inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
                return -EINVAL;
 
        return 0;
index fbe12a608b216b582ccf580ba19bbee51fedef7a..7e0f29bf7fae067ef1c2caa9b49a823552c37ca5 100644 (file)
@@ -79,7 +79,7 @@ static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
        case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
                ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
                if (!ret)
-                       ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+                       ctrl->val = hfi_bufreq_get_count_min(&bufreq, ver);
                break;
        default:
                return -EINVAL;
index 6d773b000e8a7eef8d213d58099f81f1fc3bb4be..44b13696cf82a5c941a5487b3141eec0b4820165 100644 (file)
@@ -1207,7 +1207,7 @@ static int venc_verify_conf(struct venus_inst *inst)
                return ret;
 
        if (inst->num_output_bufs < bufreq.count_actual ||
-           inst->num_output_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+           inst->num_output_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
                return -EINVAL;
 
        ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
@@ -1215,7 +1215,7 @@ static int venc_verify_conf(struct venus_inst *inst)
                return ret;
 
        if (inst->num_input_bufs < bufreq.count_actual ||
-           inst->num_input_bufs < HFI_BUFREQ_COUNT_MIN(&bufreq, ver))
+           inst->num_input_bufs < hfi_bufreq_get_count_min(&bufreq, ver))
                return -EINVAL;
 
        return 0;
index 7468e43800a94d95d52d12af16886c049433c594..d9d2a293f3ef3aebc204f8a1e4307488c7e3ede4 100644 (file)
@@ -358,7 +358,7 @@ static int venc_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
        case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
                ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
                if (!ret)
-                       ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
+                       ctrl->val = hfi_bufreq_get_count_min(&bufreq, ver);
                break;
        default:
                return -EINVAL;