Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4366210pxf; Tue, 23 Mar 2021 08:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSK87zZYunD9mg+qY0kwj7qUegXnmZ/xIpDDRbv6I5CNlbDYuO4FkDl6S1d7BdqkT7sK0A X-Received: by 2002:a17:906:39cf:: with SMTP id i15mr5563055eje.534.1616515044568; Tue, 23 Mar 2021 08:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616515044; cv=none; d=google.com; s=arc-20160816; b=CRYC8M6rChXo6CdocJNe5Lz16hkCp2QLIyLNcJKWK8xRql9I8xTMT8TsUWH/lDkNrg V9527ePHr4w+Yps9FJze12lyEhnZL5Huyah8hR1brP+F7XBAcA7SrL01OJM1GCkh2R0B s58VuppPxhDC40Zm0fqyIM0cm6KHmIrX/wvpzTRj2BCTbZMW38jw37ANeF6eP8bGSKXS 9Smc4xfD0fOHkx2mrTLsrZHKuJQdwAzBJlUmSLzPoxjpO87tL8ZY5FdKckUs5LPx76ZO wEVHGAKz3AvwHO68yKKt5p/5BjY4N9akA7rAJyt8sZTqnut3txFQZzyxs4RB0gutmpMz cJrw== 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=et39x0xn+94Q+6SQ4e+hG39f0Ta8sBEbZs7JdA/XNEg=; b=dD6q3JnKWo5pNjcPkNY46MVlhFg1zqWa9Gy/fujrTQGkOb03eIlYt9b2F4RG9p9lhC D7EC9oBGia4ebl0tbW1pFJ1+tJNKffFGnAG+P+pV7AE6R2E+Gql0QyZL9TR88V2R93Kt cDSbD8WqlfkUfS0iNWrYPe6sT6O8cp5Dp2y/+Ww7gXRdj4Vz30k3e4kKpr4m/9BN36OF 6EJG+kggv/iVKfVm0Xgt9XG0WWz3hQafIwpV1qDiE0jQP123/3qbcvjITjreNIUv6pfJ TlarC9uffgSH7gO6gclSEtscSEfU6mM5z348EHbWjUTV8xSW2NHmQGjYqagDb94u9LL/ 7HEg== 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 hr30si13488868ejc.545.2021.03.23.08.57.01; Tue, 23 Mar 2021 08:57:24 -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 S232972AbhCWPzV (ORCPT + 99 others); Tue, 23 Mar 2021 11:55:21 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:23082 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232909AbhCWPy6 (ORCPT ); Tue, 23 Mar 2021 11:54:58 -0400 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 23 Mar 2021 08:54:58 -0700 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 23 Mar 2021 08:54:56 -0700 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg01-blr.qualcomm.com with ESMTP; 23 Mar 2021 21:24:41 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id 3B6752168C; Tue, 23 Mar 2021 21:24:39 +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 v9 2/2] venus: venc: Add support for Long Term Reference (LTR) controls Date: Tue, 23 Mar 2021 21:24:27 +0530 Message-Id: <1616514867-16496-3-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1616514867-16496-1-git-send-email-dikshita@codeaurora.org> References: <1616514867-16496-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 | 55 +++++++++++++++++++++++++- 1 file changed, 54 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..bb4261b 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,43 @@ 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) + return ret; + break; + case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX: + mutex_lock(&inst->lock); + if (inst->streamon_out && inst->streamon_cap) { + 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; + } + } + mutex_unlock(&inst->lock); + break; + case V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES: + mutex_lock(&inst->lock); + if (inst->streamon_out && inst->streamon_cap) { + 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; + } + } + mutex_unlock(&inst->lock); + break; default: return -EINVAL; } @@ -291,7 +332,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 +539,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