media: venus: update calculation for dpb buffers
authorDikshita Agarwal <quic_dikshita@quicinc.com>
Mon, 22 May 2023 06:48:16 +0000 (07:48 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 9 Jun 2023 13:03:37 +0000 (14:03 +0100)
Use dpb color format, width and height of output port
for calculating buffer size of dpb buffers.

Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
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/helpers.c
drivers/media/platform/qcom/venus/hfi_plat_bufs.h
drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c

index 5e8cf67b69d56768d13df9c920106e130ed56770..d02060ffe558a1eeb68d95d6a085f5b11fab797e 100644 (file)
@@ -636,12 +636,16 @@ static int platform_get_bufreq(struct venus_inst *inst, u32 buftype,
        if (is_dec) {
                params.width = inst->width;
                params.height = inst->height;
+               params.out_width = inst->out_width;
+               params.out_height = inst->out_height;
                params.codec = inst->fmt_out->pixfmt;
                params.hfi_color_fmt = to_hfi_raw_fmt(inst->fmt_cap->pixfmt);
                params.dec.max_mbs_per_frame = mbs_per_frame_max(inst);
                params.dec.buffer_size_limit = 0;
                params.dec.is_secondary_output =
                        inst->opb_buftype == HFI_BUFFER_OUTPUT2;
+               if (params.dec.is_secondary_output)
+                       params.hfi_dpb_color_fmt = inst->dpb_fmt;
                params.dec.is_interlaced =
                        inst->pic_struct != HFI_INTERLACE_FRAME_PROGRESSIVE;
        } else {
index 52a51a3b964a7e5349a529c775467524aa077ad4..25e607452096a143dec521d93616812c28e6f779 100644 (file)
 struct hfi_plat_buffers_params {
        u32 width;
        u32 height;
+       u32 out_width;
+       u32 out_height;
        u32 codec;
        u32 hfi_color_fmt;
+       u32 hfi_dpb_color_fmt;
        enum hfi_version version;
        u32 num_vpp_pipes;
        union {
index a9be31ec6927038336ff504718bd95c92f523ac9..e97ff8cf6d64a994e076232a3cd5db22928347a9 100644 (file)
@@ -1185,6 +1185,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
        enum hfi_version version = params->version;
        u32 codec = params->codec;
        u32 width = params->width, height = params->height, out_min_count;
+       u32 out_width = params->out_width, out_height = params->out_height;
        struct dec_bufsize_ops *dec_ops;
        bool is_secondary_output = params->dec.is_secondary_output;
        bool is_interlaced = params->dec.is_interlaced;
@@ -1230,12 +1231,16 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
                        calculate_dec_input_frame_size(width, height, codec,
                                                       max_mbs_per_frame,
                                                       buffer_size_limit);
-       } else if (buftype == HFI_BUFFER_OUTPUT ||
-                  buftype == HFI_BUFFER_OUTPUT2) {
+       } else if (buftype == HFI_BUFFER_OUTPUT || buftype == HFI_BUFFER_OUTPUT2) {
                bufreq->count_min = out_min_count;
                bufreq->size =
                        venus_helper_get_framesz_raw(params->hfi_color_fmt,
-                                                    width, height);
+                                                    out_width, out_height);
+               if (buftype == HFI_BUFFER_OUTPUT &&
+                   params->dec.is_secondary_output)
+                       bufreq->size =
+                               venus_helper_get_framesz_raw(params->hfi_dpb_color_fmt,
+                                                            out_width, out_height);
        } else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH(version)) {
                bufreq->size = dec_ops->scratch(width, height, is_interlaced);
        } else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH_1(version)) {