Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2811401pxb; Sun, 24 Jan 2021 22:02:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJy9gFQivwMFT6XGuuD8l9YIuYViuvr33xac3swnSAHVTVEKpvd17cRZhevSitu+KhoABb X-Received: by 2002:a17:906:dbe7:: with SMTP id yd7mr333103ejb.71.1611554540984; Sun, 24 Jan 2021 22:02:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611554540; cv=none; d=google.com; s=arc-20160816; b=PDXaSaZtV7mN4l2UIKgpt8qM2EgTp6WzwW1vEo2l7Tnsqnpd2ZYeNjv2JHWhMzP4De S4Rzp1JRhK/A6KC0ynfRxXZolb2DMQsCDgWqRhsWMIlBaD0lDY8ZGnjfCIw1mm+O4HiV eTN9GQcIwfg+EMohPvRBCqFPupKEAxs8iKW/95hv3kTG9+Z+x59tRON5aysQ+yF1Bra5 TwF2ymQBQ2hh+BivTOt+Sy/p46JkFY0B/ktoLWe1FkkfDQGg6eNCioIlFuVpdGrsT4Xi GpU6iwJnatcf+1IZLPyyUvhicgEOy5cw4kAm6uMV8L+OeDcZj5TpBrWAy23yv8D3tE9S Nzhg== 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=dCi6450BMQpXbnvA00JqB78qNI9NOe5np1bE55IVcf4=; b=Fz/7qZFFG/ofbD+vUgaYC9sxDhdqbWC2HaigEaODc+Tjbh+g9a4yxkUykgURdln/CO G+PI6u1Ulv//WjOu8OHjzsd54oRRCJkPqdf4fKM00ji+bq9i7GdX8/8wZqy1XKi+Y+SX Pkk7i2fXIR7cAc7qnqyFwFr6kMEw8v+A82xu3JD6Re2Mb96MJJ8hKOCaiyu9Nv7NHK3O A8SN4daC0PBSDaNoagMdcmZ+3Sf0aTts0DAcmJupik5jUpoaFk637ocDbwKSZYRbdzRI 8Ic86AaxyoTp4XnCH3iHmGdQQLroQPfylAewcPtwTVO8GKlugDQndATANKrdkTLJOZ7D j8lQ== 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 lr15si4223493ejb.706.2021.01.24.22.01.56; Sun, 24 Jan 2021 22:02:20 -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 S1726929AbhAYF6u (ORCPT + 99 others); Mon, 25 Jan 2021 00:58:50 -0500 Received: from alexa-out.qualcomm.com ([129.46.98.28]:4444 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbhAYFxJ (ORCPT ); Mon, 25 Jan 2021 00:53:09 -0500 Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 24 Jan 2021 21:52:28 -0800 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 24 Jan 2021 21:52:26 -0800 X-QCInternal: smtphost Received: from dikshita-linux.qualcomm.com ([10.204.65.237]) by ironmsg01-blr.qualcomm.com with ESMTP; 25 Jan 2021 11:22:25 +0530 Received: by dikshita-linux.qualcomm.com (Postfix, from userid 347544) id 9C09621578; Mon, 25 Jan 2021 11:22:24 +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 v6 2/2] venus: venc: Add support for Long Term Reference (LTR) controls Date: Mon, 25 Jan 2021 11:21:59 +0530 Message-Id: <1611553919-17919-3-git-send-email-dikshita@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611553919-17919-1-git-send-email-dikshita@codeaurora.org> References: <1611553919-17919-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 496ad4d..7d010d8 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; @@ -259,6 +263,37 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE: ctr->frame_skip_mode = 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; } @@ -274,7 +309,7 @@ int venc_ctrl_init(struct venus_inst *inst) { int ret; - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 50); + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 53); if (ret) return ret; @@ -476,6 +511,18 @@ int venc_ctrl_init(struct venus_inst *inst) (1 << V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT)), V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED); + 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