From nobody Tue Nov 26 03:41:48 2024 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B666E1BE22D for ; Tue, 22 Oct 2024 17:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729618849; cv=none; b=SLd2KdycQ7LY9aK8fghVV3GiaaG85fZYf3F8xUu0BCWal2CtFkD9kdtGrhqwPhqI6nN0ZZYPlxHYDO7tq8TZmZr0iVo8TmmD+cQzdvFJRwyfWps41noM/BcUpwiy00HzlueaOw3p63DgUs3cjPxDGZBFvUsNalcPNMNdmr7Dpxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729618849; c=relaxed/simple; bh=lLem3laeKL8UeOhfLirfjJxHjmZMmH0EUmK6QvTIEx4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZBj7PzOx+SW+jDkQzf+aJiCQK+57pvafK69kXBoJ073jDy1v2P4bqXTWbHtctRvnqwvg1ElZHHaUJQjfGAKMHTu8U2FQBKYjKqdIKja8YFGQwOxikat+MlHeuwcQSk7Qt3UDMdr4ARvQbK4hhiheJuDSrHNAPl9jpPeuYMZG+CI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=jsYH1X9Y; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jsYH1X9Y" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-71e953f4e7cso4011320b3a.3 for ; Tue, 22 Oct 2024 10:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729618847; x=1730223647; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wX3duO21HOsFDaiwe4mIm4X5Ap6AOGPc9nHXMPlpy5k=; b=jsYH1X9YY1HcPY7Dmnx+9tMf9GBPbryTe+9AYiZBDxXZpoYbOMo/60L0Or5Xpggllu BnXY4ni6KTnhhsOAQqSsms8Iai4vW7qCq+cYVrbSC6ZvShuJQ6c/xR1tMgHL8Zy/W/2h +YaCbV0DG2lTXBM8pQhe9IsavvQwRevgu4LLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729618847; x=1730223647; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wX3duO21HOsFDaiwe4mIm4X5Ap6AOGPc9nHXMPlpy5k=; b=dr3cdPpYYbF7QZU+J5gE7OHpCrZwwtBN+D2BrxfrAXIC3dvYsWwjQYiVahSO6+0tkg CfgcUnCn3qHdUABXNRudWGNr+gzmyDOAFNExsI4kaoHRA4sYXpcHm/AabMmh0+/CZuUN yV+0+sUnTgQsgOoxoHJzLcCfxabFwovQxYVJDm8Mj9kxBOdOb24n1hXK3rNiA2DteNMu sxVYTCxR7/+DH6whaS1Vr312ETuLD9jpcTEJvjJl8lUhBJMdwhJD7T/BR1HxDrHQkOGt NAgaAJW0i4blOITRDz2+tPZmBlmvwmpW2cusNkdl0Ob1dX8aOZDHcCqGbMUzm3Chsy5Q LkgA== X-Forwarded-Encrypted: i=1; AJvYcCWQOoPhi8OlpIM8ulQcwnEWkWi93wCuy7zpeY6tbVrDEBeXTiPbWD7XG7p2F6daDAcTfTegb1iTzSAMEc8=@vger.kernel.org X-Gm-Message-State: AOJu0YzvbuSPIBlYq1x2gV2Zx44MsDgB/GUyCe+Z6mdF0ilU/4LeyqwO 5iz2fD7tlaWBtx7TydBEQhi3lEGH+tbhypOnhXvGpNYRyaLLFrA4h631BbbVAQ== X-Google-Smtp-Source: AGHT+IHoREl6JeUhcssYmlq0ORHRKXFTwH0EtndpoCpy318oyfYCUkDthUhsNjBEGavkJtZb6ld5Iw== X-Received: by 2002:a05:6a00:1303:b0:71d:f012:6ddc with SMTP id d2e1a72fcca58-72030be7339mr18366b3a.16.1729618846876; Tue, 22 Oct 2024 10:40:46 -0700 (PDT) Received: from zipper.pdx.corp.google.com ([2a00:79e0:2e13:6:158a:d1d:c077:7770]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1312d6bsm4992423b3a.29.2024.10.22.10.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 10:40:46 -0700 (PDT) From: Fritz Koenig Date: Tue, 22 Oct 2024 10:40:42 -0700 Subject: [PATCH v5 1/2] media: venus: Helper function for dynamically updating bitrate Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241022-submit-v5-1-552f0fec8cba@chromium.org> References: <20241022-submit-v5-0-552f0fec8cba@chromium.org> In-Reply-To: <20241022-submit-v5-0-552f0fec8cba@chromium.org> To: Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Mauro Carvalho Chehab , Dikshita Agarwal Cc: Nathan Hebert , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Fritz Koenig X-Mailer: b4 0.15-dev-37811 Move the dynamic bitrate updating functionality to a separate function so that it can be shared. No functionality changes. Signed-off-by: Fritz Koenig Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/venus/venc_ctrls.c | 34 +++++++++++++++-------= ---- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media= /platform/qcom/venus/venc_ctrls.c index d9d2a293f3ef..3e1f6f26eddf 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -67,12 +67,28 @@ static int venc_calc_bpframes(u32 gop_size, u32 conseq_= b, u32 *bf, u32 *pf) return 0; } =20 +static int dynamic_bitrate_update(struct venus_inst *inst, u32 bitrate, + u32 layer_id) +{ + int ret =3D 0; + + mutex_lock(&inst->lock); + if (inst->streamon_out && inst->streamon_cap) { + u32 ptype =3D HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; + struct hfi_bitrate brate =3D { .bitrate =3D bitrate, .layer_id =3D layer= _id }; + + ret =3D hfi_session_set_property(inst, ptype, &brate); + } + mutex_unlock(&inst->lock); + + return ret; +} + static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) { struct venus_inst *inst =3D ctrl_to_inst(ctrl); struct venc_controls *ctr =3D &inst->controls.enc; struct hfi_enable en =3D { .enable =3D 1 }; - struct hfi_bitrate brate; struct hfi_ltr_use ltr_use; struct hfi_ltr_mark ltr_mark; u32 bframes; @@ -85,19 +101,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) break; case V4L2_CID_MPEG_VIDEO_BITRATE: ctr->bitrate =3D ctrl->val; - mutex_lock(&inst->lock); - if (inst->streamon_out && inst->streamon_cap) { - ptype =3D HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; - brate.bitrate =3D ctr->bitrate; - brate.layer_id =3D 0; - - ret =3D hfi_session_set_property(inst, ptype, &brate); - if (ret) { - mutex_unlock(&inst->lock); - return ret; - } - } - mutex_unlock(&inst->lock); + ret =3D dynamic_bitrate_update(inst, ctr->bitrate, 0); + if (ret) + return ret; break; case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: ctr->bitrate_peak =3D ctrl->val; --=20 2.47.0.105.g07ac214952-goog