Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1573883pxb; Thu, 4 Mar 2021 15:14:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwl50KOFW4aarhfD7InCkKzVrMKRHczTgGBubYYFqVJWxLCOtfI5MjOCpEUODq5DObnhy1+ X-Received: by 2002:a6b:6206:: with SMTP id f6mr5487456iog.18.1614899663394; Thu, 04 Mar 2021 15:14:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614899663; cv=none; d=google.com; s=arc-20160816; b=ggm/LmTiqWfz4VBCmgh9W32xhus0Pto9LSzKl0/IV0OycoMQYzAq6FZ5nXLZr98Xqd YDOgZMwFxzttdchNHrou0cxBTpuChH0B6tDGO8+zleEMPUu4j4q2AAoNjG5Zor9tbYFD rMWKqHYqpz3BOyIe0Mwj1YJrhsnvCbcABpWvf5s1L6DJDpyxA0L4y6YtyqMMbjkCwZqo N2j1Ph9S6M2pXmprWoQG3/8ZhH/h1jFV+wjwBqsQPArvtA8FyK4YgiP4wHPcseddhkYL 3Yq6G74Wxzu8RnwzDUxQwB2Dfsz6GJHeZI8uyDa1wyNqgPP/rRG1tQqnUiLTkF4HjutV tlSg== 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=gOFYs7jstNcK+OoUmtBnaxuB7Tt8c6sB4P0kbgvLcrA=; b=Gd06Re6VdmBwhxf5V+KlQCEpHw2LpGaD+MtQHjTqhWH1Av8iKkdSMkdwgLRFRngo33 m67nD7AH1SSNVyujID3vEPuNQE14yl8wcDO87tnp4XnfxTSfkVq0ci9V+00qYkUCoZKs kj2JR1oQeTTGl6Slq1SVhlW1O3FlvkygEwodixSfBKQCPTwcdc2se08nYzpOcuUISxeI sz59UdL0ckB6jQ/F3+/JA0utPV1XE0es4XSdQoKq+JLCAu5lu1AdZfTaovcPHmtIO5w5 +vpp60aIUR7ZG9eBzPFezpjYGmPcZ6X59297GEbyuIuEyw4BqK1xuc/gXfOD/Rz4dfRS 8iiQ== 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 t1si768367iog.2.2021.03.04.15.14.10; Thu, 04 Mar 2021 15:14:23 -0800 (PST) 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 S231243AbhCCPw7 (ORCPT + 99 others); Wed, 3 Mar 2021 10:52:59 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:43913 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357596AbhCCLLB (ORCPT ); Wed, 3 Mar 2021 06:11:01 -0500 Received: from ironmsg07-lv.qualcomm.com (HELO ironmsg07-lv.qulacomm.com) ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 03 Mar 2021 03:10:19 -0800 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg07-lv.qulacomm.com with ESMTP/TLS/AES256-SHA; 03 Mar 2021 03:10:16 -0800 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg01-blr.qualcomm.com with ESMTP; 03 Mar 2021 16:40:09 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id 2540F21308; Wed, 3 Mar 2021 16:40:08 +0530 (IST) From: Dikshita Agarwal To: linux-media@vger.kernel.org, hverkuil-cisco@xs4all.nl, stanimir.varbanov@linaro.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vgarodia@codeaurora.org, Dikshita Agarwal Subject: [PATCH v7 2/2] venus: venc: Add support for Long Term Reference (LTR) controls Date: Wed, 3 Mar 2021 16:39:47 +0530 Message-Id: <1614769787-26922-3-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614769787-26922-1-git-send-email-dikshita@codeaurora.org> References: <1614769787-26922-1-git-send-email-dikshita@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for below LTR controls in encoder: - V4L2_CID_MPEG_VIDEO_LTR_COUNT - V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX - V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES Signed-off-by: Dikshita Agarwal --- drivers/media/platform/qcom/venus/venc_ctrls.c | 49 +++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index a52b800..2e7a69b 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -20,6 +20,7 @@ #define INTRA_REFRESH_MBS_MAX 300 #define AT_SLICE_BOUNDARY \ V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY +#define MAX_LTR_FRAME_COUNT 4 static int venc_calc_bpframes(u32 gop_size, u32 conseq_b, u32 *bf, u32 *pf) { @@ -72,6 +73,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) struct venc_controls *ctr = &inst->controls.enc; struct hfi_enable en = { .enable = 1 }; struct hfi_bitrate brate; + struct hfi_ltr_use ltr_use; + struct hfi_ltr_mark ltr_mark; + struct hfi_ltr_mode ltr_mode; u32 bframes; u32 ptype; int ret; @@ -276,6 +280,37 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID: ctr->base_priority_id = ctrl->val; break; + case V4L2_CID_MPEG_VIDEO_LTR_COUNT: + ptype = HFI_PROPERTY_PARAM_VENC_LTRMODE; + ltr_mode.ltr_count = ctrl->val; + ltr_mode.ltr_mode = HFI_LTR_MODE_MANUAL; + ltr_mode.trust_mode = 1; + ret = hfi_session_set_property(inst, ptype, <r_mode); + if (ret) { + mutex_unlock(&inst->lock); + return ret; + } + break; + case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: + ptype = HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME; + ltr_mark.mark_frame = ctrl->val; + ret = hfi_session_set_property(inst, ptype, <r_mark); + if (ret) { + mutex_unlock(&inst->lock); + return ret; + } + break; + case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: + ptype = HFI_PROPERTY_CONFIG_VENC_USELTRFRAME; + ltr_use.ref_ltr = ctrl->val; + ltr_use.use_constrnt = true; + ltr_use.frames = 0; + ret = hfi_session_set_property(inst, ptype, <r_use); + if (ret) { + mutex_unlock(&inst->lock); + return ret; + } + break; default: return -EINVAL; } @@ -291,7 +326,7 @@ int venc_ctrl_init(struct venus_inst *inst) { int ret; - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 51); + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 54); if (ret) return ret; @@ -498,6 +533,18 @@ int venc_ctrl_init(struct venus_inst *inst) V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID, 0, 6, 1, 0); + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES, 0, + (MAX_LTR_FRAME_COUNT - 1), 1, 0); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_LTR_COUNT, 0, + MAX_LTR_FRAME_COUNT, 1, 0); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX, 0, + (MAX_LTR_FRAME_COUNT - 1), 1, 0); + ret = inst->ctrl_handler.error; if (ret) goto err; -- 2.7.4