Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1728480pxj; Wed, 19 May 2021 12:28:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9dtldZUzxUyP1EzkMnJ8KVfDifmx3aroCwPB9Kl+GBxCBgsLim9ZO6tDM1mRu24MTGJNM X-Received: by 2002:a05:6402:518f:: with SMTP id q15mr632021edd.345.1621452497679; Wed, 19 May 2021 12:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621452497; cv=none; d=google.com; s=arc-20160816; b=wzCyq4ufLCFpe/dDknXdkzRqGcZBr2ejNjserhMamdpCtWleAAldoh4z+qc6oWhSdj IF9CR7DR+6GpDGYLSdfTy65MdBtRQME3PXne0A+KgawGjlQNCEePLL3B3k5nSGYSJb6E P7NEcWmuOmuZcc5XzzOTz4GospGvabXkwxRvzFawjGQXCf9Robl5htx/xhffCiuPlaOF Yb7jdjXd4ygx473QX1GYMLk41j3tFyXQG8trWUURzXDn0GdFQDxSNMdbv0lBrjSWZBSf HrSley5vDGrezKhNf7KZ1J0f6qa31uvePVRVy+BHec6eSrfaMGIt3HrjEvzOuRWTTLlr 1QBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=3fW9DYY2kRht0741XI5qFM8eKShyMWgrr284UW/OSdg=; b=sOLi9xnxq3sP6ujaaPOOghMma8WTL79y1j6mJm6nVsZsNNTipk5PV8siK7J0qw8THN UUu5upwbHSJ0ZldDBpGZgHX2UupnwapfzQjT1Dh37pwXTG4eTU84jfA+MkJNPPcpa/tD EeHPoiKoJ7+aElKG1TYw7mRGDPHJ6T75LYhuJnhOrPSdMA5MERu7a8DV+l5MY2HTUp5b 4lIlbi9UCrisPIY/w3PVVXMZQHqC549dj5opanOh7eG8FuiGK9v6JcQhMBMIxYxjb+zJ Ze54MA5VWJLh0VZDbDgz5/7CBT447VKOgV2lErdMX/XJyHUrLPxgGp9rveX6Ydj6avq+ TWiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h93si90638edd.584.2021.05.19.12.27.53; Wed, 19 May 2021 12:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345869AbhESJjc (ORCPT + 99 others); Wed, 19 May 2021 05:39:32 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:31762 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346016AbhESJjS (ORCPT ); Wed, 19 May 2021 05:39:18 -0400 Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 19 May 2021 02:37:58 -0700 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 19 May 2021 02:37:57 -0700 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg02-blr.qualcomm.com with ESMTP; 19 May 2021 15:07:54 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id B4DAD219EB; Wed, 19 May 2021 15:07:45 +0530 (IST) From: Dikshita Agarwal To: linux-media@vger.kernel.org, stanimir.varbanov@linaro.org Cc: linux-kernel@vger.kernel.org, vgarodia@codeaurora.org, Dikshita Agarwal Subject: [PATCH 7/7] media: venus: Set buffer to FW based on FW min count requirement. Date: Wed, 19 May 2021 15:06:48 +0530 Message-Id: <1621417008-6117-8-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1621417008-6117-1-git-send-email-dikshita@codeaurora.org> References: <1621417008-6117-1-git-send-email-dikshita@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - Get the min buffer count required by FW from source event change and use the same value to decide actual buffer count and for buffer size calculation. - Setup DPB and OPB buffers after session continue incase of reconfig. Co-developed-by: Mansur Alisha Shaik Co-developed-by: Vikash Garodia Signed-off-by: Dikshita Agarwal --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/helpers.c | 11 ++++++++++- drivers/media/platform/qcom/venus/hfi.h | 1 + drivers/media/platform/qcom/venus/hfi_helper.h | 9 +++++++++ drivers/media/platform/qcom/venus/hfi_msgs.c | 7 +++++++ .../media/platform/qcom/venus/hfi_plat_bufs_v6.c | 3 ++- drivers/media/platform/qcom/venus/vdec.c | 22 ++++++++++++---------- 7 files changed, 42 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 1ff20d9..b2b023e 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -403,6 +403,7 @@ struct venus_inst { u32 width; u32 height; struct v4l2_rect crop; + u32 fw_min_cnt; u32 out_width; u32 out_height; u32 colorspace; diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index cbe653f..83c3009 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -576,6 +576,7 @@ static int platform_get_bufreq(struct venus_inst *inst, u32 buftype, struct hfi_plat_buffers_params params; bool is_dec = inst->session_type == VIDC_SESSION_TYPE_DEC; struct venc_controls *enc_ctr = &inst->controls.enc; + int ret = 0; hfi_plat = hfi_platform_get(version); @@ -610,7 +611,15 @@ static int platform_get_bufreq(struct venus_inst *inst, u32 buftype, params.enc.is_tenbit = inst->bit_depth == VIDC_BITDEPTH_10; } - return hfi_plat->bufreq(¶ms, inst->session_type, buftype, req); + if (buftype == HFI_BUFFER_OUTPUT || buftype == HFI_BUFFER_OUTPUT2 || + buftype == HFI_BUFFER_INTERNAL_SCRATCH_1(version)) + req->count_min = inst->fw_min_cnt; + + ret = hfi_plat->bufreq(¶ms, inst->session_type, buftype, req); + if (buftype == HFI_BUFFER_OUTPUT || buftype == HFI_BUFFER_OUTPUT2) + if (inst->fw_min_cnt != req->count_min) + inst->fw_min_cnt = req->count_min; + return ret; } int venus_helper_get_bufreq(struct venus_inst *inst, u32 type, diff --git a/drivers/media/platform/qcom/venus/hfi.h b/drivers/media/platform/qcom/venus/hfi.h index f25d412..287d544 100644 --- a/drivers/media/platform/qcom/venus/hfi.h +++ b/drivers/media/platform/qcom/venus/hfi.h @@ -75,6 +75,7 @@ struct hfi_event_data { u32 left, top; u32 width, height; } input_crop; + u32 fw_min_cnt; }; /* define core states */ diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 185c302..5162f09 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -167,6 +167,7 @@ #define HFI_PROPERTY_PARAM_VDEC_RECOVERY_POINT_SEI_EXTRADATA 0x120300c #define HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE 0x120300d #define HFI_PROPERTY_PARAM_VDEC_FRAME_ASSEMBLY 0x120300e +#define HFI_PROPERTY_PARAM_VDEC_DPB_COUNTS 0x120300e #define HFI_PROPERTY_PARAM_VDEC_VC1_FRAMEDISP_EXTRADATA 0x1203011 #define HFI_PROPERTY_PARAM_VDEC_VC1_SEQDISP_EXTRADATA 0x1203012 #define HFI_PROPERTY_PARAM_VDEC_TIMESTAMP_EXTRADATA 0x1203013 @@ -906,6 +907,14 @@ struct hfi_extradata_input_crop { u32 height; }; +struct hfi_dpb_counts { + u32 max_dpb_count; + u32 max_ref_frames; + u32 max_dec_buffering; + u32 max_reorder_frames; + u32 fw_min_cnt; +}; + #define HFI_COLOR_FORMAT_MONOCHROME 0x01 #define HFI_COLOR_FORMAT_NV12 0x02 #define HFI_COLOR_FORMAT_NV21 0x03 diff --git a/drivers/media/platform/qcom/venus/hfi_msgs.c b/drivers/media/platform/qcom/venus/hfi_msgs.c index a2d436d..2d207254 100644 --- a/drivers/media/platform/qcom/venus/hfi_msgs.c +++ b/drivers/media/platform/qcom/venus/hfi_msgs.c @@ -32,6 +32,7 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, struct hfi_colour_space *colour_info; struct hfi_buffer_requirements *bufreq; struct hfi_extradata_input_crop *crop; + struct hfi_dpb_counts *dpb_count; u8 *data_ptr; u32 ptype; @@ -110,6 +111,12 @@ static void event_seq_changed(struct venus_core *core, struct venus_inst *inst, event.input_crop.height = crop->height; data_ptr += sizeof(*crop); break; + case HFI_PROPERTY_PARAM_VDEC_DPB_COUNTS: + data_ptr += sizeof(u32); + dpb_count = (struct hfi_dpb_counts *)data_ptr; + event.fw_min_cnt = dpb_count->fw_min_cnt; + data_ptr += sizeof(*dpb_count); + break; default: break; } diff --git a/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c b/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c index 479178b..c7aea06 100644 --- a/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c +++ b/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c @@ -1164,7 +1164,7 @@ static int output_buffer_count(u32 session_type, u32 codec) output_min_count = 6; break; case V4L2_PIX_FMT_VP9: - output_min_count = 9; + output_min_count = 11; break; case V4L2_PIX_FMT_H264: case V4L2_PIX_FMT_HEVC: @@ -1213,6 +1213,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype, } out_min_count = output_buffer_count(VIDC_SESSION_TYPE_DEC, codec); + out_min_count = max(out_min_count, bufreq->count_min); bufreq->type = buftype; bufreq->region_size = 0; diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index a674281..d8f0529 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -977,7 +977,7 @@ static int vdec_start_capture(struct venus_inst *inst) return ret; ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, - VB2_MAX_FRAME, VB2_MAX_FRAME); + inst->num_output_bufs, inst->num_output_bufs); if (ret) return ret; @@ -985,6 +985,14 @@ static int vdec_start_capture(struct venus_inst *inst) if (ret) goto err; + venus_pm_load_scale(inst); + + inst->next_buf_last = false; + + ret = hfi_session_continue(inst); + if (ret) + goto err; + ret = venus_helper_alloc_dpb_bufs(inst); if (ret) goto err; @@ -997,14 +1005,6 @@ static int vdec_start_capture(struct venus_inst *inst) if (ret) goto free_dpb_bufs; - venus_pm_load_scale(inst); - - inst->next_buf_last = false; - - ret = hfi_session_continue(inst); - if (ret) - goto free_dpb_bufs; - inst->codec_state = VENUS_DEC_STATE_DECODING; if (inst->drain_active) @@ -1069,7 +1069,7 @@ static int vdec_start_output(struct venus_inst *inst) return ret; ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, - VB2_MAX_FRAME, VB2_MAX_FRAME); + inst->num_output_bufs, inst->num_output_bufs); if (ret) return ret; @@ -1410,6 +1410,7 @@ static void vdec_event_change(struct venus_inst *inst, inst->crop.height = ev_data->height; } + inst->fw_min_cnt = ev_data->fw_min_cnt; inst->out_width = ev_data->width; inst->out_height = ev_data->height; @@ -1513,6 +1514,7 @@ static void vdec_inst_init(struct venus_inst *inst) inst->crop.top = 0; inst->crop.width = inst->width; inst->crop.height = inst->height; + inst->fw_min_cnt = 8; inst->out_width = frame_width_min(inst); inst->out_height = frame_height_min(inst); inst->fps = 30; -- 2.7.4