From patchwork Sun Dec 6 10:27:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 338814 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1914741jai; Sun, 6 Dec 2020 02:30:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpjEReShPvsNmz7UTgv9Au0Ogx2wgLbtU0qU16ts/rVqma4b8MPpUpqcDOMEn+JBjuCnqX X-Received: by 2002:a50:8f64:: with SMTP id 91mr15411371edy.310.1607250615348; Sun, 06 Dec 2020 02:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607250615; cv=none; d=google.com; s=arc-20160816; b=W9pcHWEJhXSiS7le4DgrMRqyJuQbzNrhNvPYlxUIAxtgDe72kNMy4k512qMTrPaI09 F4f7v/EcFG2oRqLD6xIQVaDHSpuchneUCpl5RdM2agjxm+E6rSbHXKq5hrQrtC699eTI 6IQAnawfUj66YE1TU6S55cJMMk9YFWsKTS0J07HQtsXZ98HJ3s5uTi7Xp4LRv3yGg1TI Dqs/isqornmblTIUVRCQkKvI45D+ZI1dwkz6pS6AX+BozhcmzVeOXNFafjLBOQ9fTPnU jtRQGPGy7B5hs3v7trhnwoYN+0MMISipOzd74iKVkECJo5f7u743XE1F1TfUNoIR979h 4Amw== 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:dkim-signature; bh=gpWCIATGv89rtEwn8WYj4p89KgVT6vlvikurmyS46lU=; b=bU7kzfleaHqyP6sZqmblj6iXc2rpjH1VVfl42DjW3f9WgW4i6gARcx0dxS0Cw9EDwL LpzLpsK/PbvtsgHimQ/8o7cn9965AF61wk4agBq3S6+m09xT8Jx6PtsEtwCnHt6eYhNn GER3cndymuO/iSYKgG2qpTk7HOw6egn+A2gMwyz60dsudzpmh1SixTlC6UHpzTEONiPk oIfqmT4eBBQ54O1Yhj/AIOzWoOPv0rKUIJ7Guyb10IhZPLRceu0PBF7tZq02yGFnABBh dEDszqRIic5FIY+fp53dEctMoGj6/qpd+UEeg/aQcf9/gmgRPjq/we1gFYGwtwOt16sN hB5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aRW1kht+; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si6254944edj.6.2020.12.06.02.30.15; Sun, 06 Dec 2020 02:30:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aRW1kht+; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727661AbgLFK3K (ORCPT + 4 others); Sun, 6 Dec 2020 05:29:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727617AbgLFK3H (ORCPT ); Sun, 6 Dec 2020 05:29:07 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72138C061A56 for ; Sun, 6 Dec 2020 02:27:44 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id g20so15223766ejb.1 for ; Sun, 06 Dec 2020 02:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gpWCIATGv89rtEwn8WYj4p89KgVT6vlvikurmyS46lU=; b=aRW1kht+laMYeKxh8N6HFdBzECuxiRYidU7hlk2HwqfIXCw5Vv06B70a7Z1sQPzhZc BQgks5ec7jPCuUiXsKOQiH2/x4gK/ujk7gIn4LU+NA0vL2CnHOcfhvs5Ai7Rmf/+dVVV bM08NWvt/XDppUOBsOoGxH4om/5CVCLis6jMKVXBsZ6kcS4IRoT/Bs1PqrkHxqxL+Wdl pCZnvS98Q14inNQROJb7vh9/LlbdGE/LQ9aUkIEr06E9ipnR96cAImldsOzEM6xElnwq ZsW2ORo8ACf3HvS+LT0D1Za05LzH7CmOqR1fHbzpcpLNnfPnRlZGftfvnGSGXHwXKAmi krrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gpWCIATGv89rtEwn8WYj4p89KgVT6vlvikurmyS46lU=; b=jDPxSCDHEtNWA7wOVtfFK1QfK8xfTmvK1X/IOZqPcII2PMHC5T7uPDyUbw34W9HFkA gfYjl4X8X8ksGOGzmjFeJ3xVZMcu9BE4Js29DTIos/peO0oMUOoustq4zD6ALI+lygTF qVWEhGeBtzXNkYdG8OXonxFCS1TT7KETpCZ3m1tBx/pTVhzoXfKzaabhvgJZWE2tB/JZ LYxADtXc18iMj77CzA7Hb11d7qowaxsworqaRR1CoRs5WjnFEJeXig1S8h0p/fexDHH0 NhOPMrxJtk3FcLI6pEjX4qYNDlQgBv8Edxs++Hrx9iedLI2JaMsykBJcQtAzFVs3aOp9 SC4g== X-Gm-Message-State: AOAM5336cpoYHklg0FnbdpzcJLhbvLVddgljt3pJEcpe6iGssXxjCkhD qaIgbZVlFvANYQ9NZnG7h516j3araNiEK/y1 X-Received: by 2002:a17:906:2683:: with SMTP id t3mr14877061ejc.414.1607250462912; Sun, 06 Dec 2020 02:27:42 -0800 (PST) Received: from localhost.localdomain (hst-221-17.medicom.bg. [84.238.221.17]) by smtp.gmail.com with ESMTPSA id d4sm8464736edq.36.2020.12.06.02.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2020 02:27:42 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Ezequiel Garcia , Nicolas Dufresne , Maheshwar Ajja , Hans Verkuil , Stanimir Varbanov Subject: [PATCH v2 2/4] venus: venc: Add support for intra-refresh period Date: Sun, 6 Dec 2020 12:27:15 +0200 Message-Id: <20201206102717.19000-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201206102717.19000-1-stanimir.varbanov@linaro.org> References: <20201206102717.19000-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for intra-refresh period v4l2 control. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/venc.c | 28 +++++++++++++++++++ .../media/platform/qcom/venus/venc_ctrls.c | 9 +++++- 3 files changed, 37 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f03ed427accd..097fca39eb79 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -242,6 +242,7 @@ struct venc_controls { u32 multi_slice_max_mb; u32 header_mode; + u32 intra_refresh_period; struct { u32 h264; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 1c61602c5de1..615d90612ebc 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -536,6 +536,7 @@ static int venc_set_properties(struct venus_inst *inst) struct hfi_idr_period idrp; struct hfi_quantization quant; struct hfi_quantization_range quant_range; + struct hfi_intra_refresh intra_refresh = {}; u32 ptype, rate_control, bitrate; u32 profile, level; int ret; @@ -717,6 +718,33 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; + if ((inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || + inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) && + (rate_control == HFI_RATE_CONTROL_CBR_VFR || + rate_control == HFI_RATE_CONTROL_CBR_CFR)) { + intra_refresh.mode = HFI_INTRA_REFRESH_NONE; + intra_refresh.cir_mbs = 0; + + if (ctr->intra_refresh_period) { + u32 mbs; + + mbs = ALIGN(inst->width, 16) * ALIGN(inst->height, 16); + mbs /= 16 * 16; + if (mbs % ctr->intra_refresh_period) + mbs++; + mbs /= ctr->intra_refresh_period; + + intra_refresh.mode = HFI_INTRA_REFRESH_RANDOM; + intra_refresh.cir_mbs = mbs; + } + + ptype = HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH; + + ret = hfi_session_set_property(inst, ptype, &intra_refresh); + if (ret) + return ret; + } + return 0; } diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index cf860e6446c0..801026fab89d 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -208,6 +208,9 @@ 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_INTRA_REFRESH_PERIOD: + ctr->intra_refresh_period = ctrl->val; + break; default: return -EINVAL; } @@ -223,7 +226,7 @@ int venc_ctrl_init(struct venus_inst *inst) { int ret; - ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 33); + ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 34); if (ret) return ret; @@ -374,6 +377,10 @@ 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_INTRA_REFRESH_PERIOD, 0, + ((4096 * 2304) >> 8), 1, 0); + ret = inst->ctrl_handler.error; if (ret) goto err;