Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp265577pxf; Thu, 11 Mar 2021 03:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxT2oqGrsEdGcne4Jejr0KG0QuNxcb+/0KpMreV7o9qrRUiNd3K90li3ZRqFtaVxOoKxK1 X-Received: by 2002:a05:6402:30b9:: with SMTP id df25mr8156302edb.136.1615462033050; Thu, 11 Mar 2021 03:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462033; cv=none; d=google.com; s=arc-20160816; b=IYJpgJDvOBFZhzOiOKvGi5u06+v046+6E23VmGToPmqBgNdANYvSpedKtf+S/HqonP gV815V9MgZT88g1gk8Ba5tDK4jlL8TnccnZCrTNyeVF4Qy1TVJ+016JbHo5KxQlkjfop 3EhA0lNRvGP1N+c/aYiYi5ruY4zD7IxS3GXNzmC0bm+Al4p3Tp6H5W8qX6ZKczj9JZBr JXYyKpqXXMO5iu8zGP+47BKMCL2PQpyLn99FHOqmN0PAw25AsS0ee8XsSr7khXSrUqXL E7LOtMQsS5m8ocM8HMTHjZAvrX7GvNlowhrv3aemJFyZNjAvgQk8WOR987rBrk/cbk98 uOtg== 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=Nh84YO5+POR7aDPCoRatbvTVdhgQvGs13rmMvgiEIqTMwa1n8W+lSuJmGVP4JYuFEH kDirZLX3TKBqwk3llWCfLZRO6zK3uNj24trYoJxczdQ4W04xKpO4gnlYct+Zl8/RdN0x n7TrRrvygajEl9IqW5Jf9GkfuG9/YUHRUxVu0oU1qFpiaJtOKxOLTEvuSXfkSm8+NXeg m08KUgfHQKpWj+ZsIb0CmDCSPPa4pt5pi3HZmzyA8wH6QPZi8zQHhSWOAZpHXO0cEIjm hAqnbnhO8Slt780D2kRb+S7ZOTgfv81fsCGGxazcS9RpGS6CRBJgxFY97gR4va8AWfU7 mYpw== 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 k7si1516113ejs.165.2021.03.11.03.26.50; Thu, 11 Mar 2021 03:27:13 -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 S232629AbhCKLZ5 (ORCPT + 99 others); Thu, 11 Mar 2021 06:25:57 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:31885 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232644AbhCKLZ3 (ORCPT ); Thu, 11 Mar 2021 06:25:29 -0500 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 11 Mar 2021 03:25:29 -0800 X-QCInternal: smtphost Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 11 Mar 2021 03:25:27 -0800 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg02-blr.qualcomm.com with ESMTP; 11 Mar 2021 16:55:11 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id 1EB55212F0; Thu, 11 Mar 2021 16:55:11 +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 v8 2/2] venus: venc: Add support for Long Term Reference (LTR) controls Date: Thu, 11 Mar 2021 16:55:01 +0530 Message-Id: <1615461901-16675-3-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1615461901-16675-1-git-send-email-dikshita@codeaurora.org> References: <1615461901-16675-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