From patchwork Thu Oct 17 20:04:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fritz Koenig X-Patchwork-Id: 13840768 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.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 ED761227395 for ; Thu, 17 Oct 2024 20:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729195496; cv=none; b=UZ4qbdOuj5grX17HuIGGAqm8VV17QF55y1O04/v0JhX3uDlkcIAsEtgFNNYXKavbtb87qqamyWho1sBIfP7CicV5pRZyiFzWVOIIHOqaFI8bsk70yEk5cUoSN7UfgbnYOsx8qY+urVXouxBNbRkFbgJf1b54XTo0O4Mc4BlCEME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729195496; c=relaxed/simple; bh=i7sFO9JgUncK4+2BlaPMkoSHyIae7c3UHjJksnNmA7k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ART5PUNkj4Pgx260yp1aHvDBD+348zOCN0E+bcYPuGWFn4kahKbvKihmebYiJ4hc0jRw4/tKiQOIRmi+1i5ozUCJzmJaoamOfCdDE3VIHJXCB/Nmnd14bQMxHNwAl0V8rGKrTPyGha6QqmalWXxCLlHlKls+H5VyOur/b6khIB0= 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=KB1u3RJ8; arc=none smtp.client-ip=209.85.215.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="KB1u3RJ8" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-7ea7e2ff5ceso1133134a12.2 for ; Thu, 17 Oct 2024 13:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729195491; x=1729800291; 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=usMSdKeptnG7ur7TVHyDplRNxOUvxLx0LIpwZM+f2fM=; b=KB1u3RJ84tLiiVCjQ2JDF4Ey7lVdhTXKIQXRPGyW/Vk/slNrS6IbBjIGEizzV/hhtt jWNeTn7jBGdtgTl6DeRK+J2OcK4Pt1kcRBP5TbHLpFa8HlCoZnYryEeZrZYAKT1K5beQ Bx1RIIr6hve1ZuUNi1i+Dfxqm+I/1acKeX2BQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729195491; x=1729800291; 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=usMSdKeptnG7ur7TVHyDplRNxOUvxLx0LIpwZM+f2fM=; b=KJy6zrVlRMYEf7RjgI8t4J0cBx5CtF+8vXFiCJzo3UjlSefkGFp7uh/AvARhm+FilU Ifud3sS8CWPjmhgk2MZthsgs7JCdNGUUJgsLFvJDogGRCoWXWl8jgQT3TLtE7JK2PJw2 4o86YX2hdVg5yD/WjUENRWy3/elfUt5EuFCooptHuSmu/gCgJunfM6r/QYdaawsJHCLx QPXr+UeK+mSMo0lpGPxZ7mDWAOdHm1TdXKM6I8dRK2A7qFintSJ/WtdhOH3/I7PByusQ nDUVVvirY4t7jI7HNPrfuF0NWRaChFwqWDI1tkH3QNcH3fQKmytxQFHLwx6cXIzsPcQ5 ILTw== X-Forwarded-Encrypted: i=1; AJvYcCXVO7NhUj3453LU5o9osSUVKea2+C4hIsm9wKAonXlnOKh3rprJ3OS0FpghNGsv/el6yKffFKCtEw07GZpQ@vger.kernel.org X-Gm-Message-State: AOJu0YzgvH8WNov+YgLC8S/12aXKq3bGNN4rnhpX5HVW7N4i5Mnqc90d 1gt74mCNExS32s7g2tFfnHDk8iwh5ygqksu+w3InY6kbRWv5YAjMN0tjLah0Qw== X-Google-Smtp-Source: AGHT+IG28PbY56IoTsp4T0yBURVl1jqVtYGXY/1+pYGLu8KDfB4yM4GH6HSfnkh2AmLC7tKXvr72Ug== X-Received: by 2002:a17:90b:4c52:b0:2e2:8c75:b45 with SMTP id 98e67ed59e1d1-2e56171a966mr176562a91.11.1729195491345; Thu, 17 Oct 2024 13:04:51 -0700 (PDT) Received: from zipper.pdx.corp.google.com ([2a00:79e0:2e13:6:ab92:55d4:ae5d:528a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e56129dccesm110088a91.38.2024.10.17.13.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 13:04:50 -0700 (PDT) From: Fritz Koenig Date: Thu, 17 Oct 2024 13:04:30 -0700 Subject: [PATCH v4 1/2] media: venus: Helper function for dynamically updating bitrate Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241017-submit-v4-1-d852bc7f7fdc@chromium.org> References: <20241017-submit-v4-0-d852bc7f7fdc@chromium.org> In-Reply-To: <20241017-submit-v4-0-d852bc7f7fdc@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 Reviewed-by: Dikshita Agarwal --- 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; } +static int dynamic_bitrate_update(struct venus_inst *inst, u32 bitrate, + u32 layer_id) +{ + int ret = 0; + + mutex_lock(&inst->lock); + if (inst->streamon_out && inst->streamon_cap) { + u32 ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; + struct hfi_bitrate brate = { .bitrate = bitrate, .layer_id = layer_id }; + + ret = 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 = ctrl_to_inst(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; 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 = ctrl->val; - mutex_lock(&inst->lock); - if (inst->streamon_out && inst->streamon_cap) { - ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; - brate.bitrate = ctr->bitrate; - brate.layer_id = 0; - - ret = hfi_session_set_property(inst, ptype, &brate); - if (ret) { - mutex_unlock(&inst->lock); - return ret; - } - } - mutex_unlock(&inst->lock); + ret = dynamic_bitrate_update(inst, ctr->bitrate, 0); + if (ret) + return ret; break; case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: ctr->bitrate_peak = ctrl->val; From patchwork Thu Oct 17 20:04:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fritz Koenig X-Patchwork-Id: 13840767 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 CD975227B9F for ; Thu, 17 Oct 2024 20:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729195496; cv=none; b=q7INOyKFuhBZMc9Jc1CAm8oBXy34k5ZShuW6bY0ScZ4mon5xGx1+EOPnJLmSzdceXchIyk66Gv57lLy6zUqN0+oFbMKJNXmiSXUxc6lLkVlJUn+HRYlWYJ/jugOhRi21rD47wKTJFvP9DOOlk9lRxHxqQDj7esE4B3fUM4Zqjx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729195496; c=relaxed/simple; bh=12O16X5m6L4TMZ4PbeKs96jQJ/iS228yoW4rZ8SI9eo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AsOfe3WPKm2m02ORVYyR2nM/CPPXvYI/udAalBHTXbM9fyMT/ryFlr8fnrmc9glunAF6OYNNjcbbcgUwyD3korboCmdLFrAti9j0n2eRaZ6wdxbWcHmC7HT9NLvAGqe+MSMKaZNGoEOripfcVLAbEmCg05L0+5bGgW4WlbAoKQk= 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=R0298k++; arc=none smtp.client-ip=209.85.214.180 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="R0298k++" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20caccadbeeso15207185ad.2 for ; Thu, 17 Oct 2024 13:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729195492; x=1729800292; 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=78oVIU4gxI+xMIbzD9bO4K9p/Czsp4tG3FVUEj/GjcI=; b=R0298k++0FHoo2UOvZVzr5AsEhHQ0s5j1IvL9aIx+x5RdX0jeLajxu2rG1PwOD0kF3 /NSvDM7dES+3i7lvkt0I2edsYQtoHzRY+RbpR5xOFcvzbBziC0+C67TSEi3vgcc20Cwo +cSFs3wMIhFj/3828zatub1BbK8xRIZPNevW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729195492; x=1729800292; 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=78oVIU4gxI+xMIbzD9bO4K9p/Czsp4tG3FVUEj/GjcI=; b=V82UW4Xkp9sflN4cPss+NQLolHXC0+00gFWpCodB2nXgwUvvl+MLyEoIdF2BKQX1KP Ef/2rA7nVrZTvn7gnBXE3mFJHGHreXIeLzYeAeRX11BLUBLWsGC9tvO7pVUP9rYEin9r Xkfhm+JEIFbMZ+wiFdOVMUggVTjniYw9fdPBXWWAB0W3hwm5opnOV+lo8x1xQsa0Vtmk ACkV0A1vsfu0i1EIigAzEPY9UD3oemXXXgF+nSg/yhEnJKlyEcRB0Qp9nGDj1cRCMKdH Cxoj8QIRIm8UDdpcJeDuiaxUhI5h7vFOruaAR8phyl4rFVtniOEsIKD8s0hTMRgvBWhi AC8g== X-Forwarded-Encrypted: i=1; AJvYcCVFu3ks5Q3V7Ju93PSiwBswHxcIEFaFXEoLjettYA66wp3WfvTa25kFnIzvK+lLgOE3+ryh2BtsIpLnivPZ@vger.kernel.org X-Gm-Message-State: AOJu0YweuAxasorVTp46iDbH/lfzYc7u5rrwd6w14hZrkxST2h25+sGp BSg2vq4kJFlDDjxWNRuFLF7zz+0ZEP8WaZWYKIsaVgIeXbEr4Et3vEn1OtxKIQ== X-Google-Smtp-Source: AGHT+IHzPeXhgWDyIXpmlQORpJn8DNHSXWCs0phXrOp91LeLuJepEHcJ4i/UFxzjfJ7MobSc0wiMhg== X-Received: by 2002:a17:90b:2785:b0:2e0:a77e:82ff with SMTP id 98e67ed59e1d1-2e561a168d1mr158327a91.33.1729195492077; Thu, 17 Oct 2024 13:04:52 -0700 (PDT) Received: from zipper.pdx.corp.google.com ([2a00:79e0:2e13:6:ab92:55d4:ae5d:528a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e56129dccesm110088a91.38.2024.10.17.13.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 13:04:51 -0700 (PDT) From: Fritz Koenig Date: Thu, 17 Oct 2024 13:04:31 -0700 Subject: [PATCH v4 2/2] media: venus: Enable h.264 hierarchical coding Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241017-submit-v4-2-d852bc7f7fdc@chromium.org> References: <20241017-submit-v4-0-d852bc7f7fdc@chromium.org> In-Reply-To: <20241017-submit-v4-0-d852bc7f7fdc@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 HFI supports hierarchical P encoding and the ability to specify the bitrate for the different layers. Connect the controls that V4L2 provides and HFI supports. Signed-off-by: Fritz Koenig Reviewed-by: Dikshita Agarwal --- drivers/media/platform/qcom/venus/core.h | 4 ++ drivers/media/platform/qcom/venus/venc.c | 73 +++++++++++++------- drivers/media/platform/qcom/venus/venc_ctrls.c | 92 ++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 55202b89e1b9..fd46a7778d8c 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -26,6 +26,7 @@ #define VIDC_CLKS_NUM_MAX 4 #define VIDC_VCODEC_CLKS_NUM_MAX 2 #define VIDC_RESETS_NUM_MAX 2 +#define VIDC_MAX_HIER_CODING_LAYER 6 extern int venus_fw_debug; @@ -255,6 +256,7 @@ struct venc_controls { u32 rc_enable; u32 const_quality; u32 frame_skip_mode; + u32 layer_bitrate; u32 h264_i_period; u32 h264_entropy_mode; @@ -273,6 +275,8 @@ struct venc_controls { s32 h264_loop_filter_alpha; s32 h264_loop_filter_beta; u32 h264_8x8_transform; + u32 h264_hier_layers; + u32 h264_hier_layer_bitrate[VIDC_MAX_HIER_CODING_LAYER]; u32 hevc_i_qp; u32 hevc_p_qp; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 3ec2fb8d9fab..d717e5dd6a39 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -734,6 +734,29 @@ static int venc_set_properties(struct venus_inst *inst) if (ret) return ret; + if (ctr->layer_bitrate) { + unsigned int i; + + ptype = HFI_PROPERTY_PARAM_VENC_HIER_P_MAX_NUM_ENH_LAYER; + ret = hfi_session_set_property(inst, ptype, &ctr->h264_hier_layers); + if (ret) + return ret; + + ptype = HFI_PROPERTY_CONFIG_VENC_HIER_P_ENH_LAYER; + ret = hfi_session_set_property(inst, ptype, &ctr->layer_bitrate); + if (ret) + return ret; + + for (i = 0; i < ctr->h264_hier_layers; ++i) { + ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; + brate.bitrate = ctr->h264_hier_layer_bitrate[i]; + brate.layer_id = i; + + ret = hfi_session_set_property(inst, ptype, &brate); + if (ret) + return ret; + } + } } if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || @@ -823,21 +846,36 @@ static int venc_set_properties(struct venus_inst *inst) return ret; } - if (!ctr->bitrate) - bitrate = 64000; - else - bitrate = ctr->bitrate; + if (!ctr->layer_bitrate) { + if (!ctr->bitrate) + bitrate = 64000; + else + bitrate = ctr->bitrate; - ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; - brate.bitrate = bitrate; - brate.layer_id = 0; + ptype = HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; + brate.bitrate = bitrate; + brate.layer_id = 0; - ret = hfi_session_set_property(inst, ptype, &brate); - if (ret) - return ret; + ret = hfi_session_set_property(inst, ptype, &brate); + if (ret) + return ret; + + if (!ctr->bitrate_peak) + bitrate *= 2; + else + bitrate = ctr->bitrate_peak; + + ptype = HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE; + brate.bitrate = bitrate; + brate.layer_id = 0; + + ret = hfi_session_set_property(inst, ptype, &brate); + if (ret) + return ret; + } if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_H264 || - inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { + inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { ptype = HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER; if (ctr->header_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) en.enable = 0; @@ -849,19 +887,6 @@ static int venc_set_properties(struct venus_inst *inst) return ret; } - if (!ctr->bitrate_peak) - bitrate *= 2; - else - bitrate = ctr->bitrate_peak; - - ptype = HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE; - brate.bitrate = bitrate; - brate.layer_id = 0; - - ret = hfi_session_set_property(inst, ptype, &brate); - if (ret) - return ret; - ptype = HFI_PROPERTY_PARAM_VENC_SESSION_QP; if (inst->fmt_cap->pixfmt == V4L2_PIX_FMT_HEVC) { quant.qp_i = ctr->hevc_i_qp; diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index 3e1f6f26eddf..e340783a4ef2 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -346,6 +346,55 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) ctr->h264_8x8_transform = ctrl->val; break; + case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE: + if (ctrl->val != V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P) + return -EINVAL; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING: + ctr->layer_bitrate = ctrl->val; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER: + if (ctrl->val > VIDC_MAX_HIER_CODING_LAYER) + return -EINVAL; + ctr->h264_hier_layers = ctrl->val; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR: + ctr->h264_hier_layer_bitrate[0] = ctrl->val; + ret = dynamic_bitrate_update(inst, ctr->h264_hier_layer_bitrate[0], 0); + if (ret) + return ret; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR: + ctr->h264_hier_layer_bitrate[1] = ctrl->val; + ret = dynamic_bitrate_update(inst, ctr->h264_hier_layer_bitrate[1], 1); + if (ret) + return ret; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR: + ctr->h264_hier_layer_bitrate[2] = ctrl->val; + ret = dynamic_bitrate_update(inst, ctr->h264_hier_layer_bitrate[2], 2); + if (ret) + return ret; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR: + ctr->h264_hier_layer_bitrate[3] = ctrl->val; + ret = dynamic_bitrate_update(inst, ctr->h264_hier_layer_bitrate[3], 3); + if (ret) + return ret; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR: + ctr->h264_hier_layer_bitrate[4] = ctrl->val; + ret = dynamic_bitrate_update(inst, ctr->h264_hier_layer_bitrate[4], 4); + if (ret) + return ret; + break; + case V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR: + ctr->h264_hier_layer_bitrate[5] = ctrl->val; + ret = dynamic_bitrate_update(inst, ctr->h264_hier_layer_bitrate[5], 5); + if (ret) + return ret; + break; + default: return -EINVAL; } @@ -628,6 +677,49 @@ int venc_ctrl_init(struct venus_inst *inst) V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD, 0, ((4096 * 2304) >> 8), 1, 0); + if (IS_V4(inst->core) || IS_V6(inst->core)) { + v4l2_ctrl_new_std_menu(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE, + V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P, + 1, V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_P); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING, 0, 1, 1, 0); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER, 0, + VIDC_MAX_HIER_CODING_LAYER, 1, 0); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR, + BITRATE_MIN, BITRATE_MAX, BITRATE_STEP, BITRATE_DEFAULT); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR, + BITRATE_MIN, BITRATE_MAX, + BITRATE_STEP, BITRATE_DEFAULT); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR, + BITRATE_MIN, BITRATE_MAX, + BITRATE_STEP, BITRATE_DEFAULT); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR, + BITRATE_MIN, BITRATE_MAX, + BITRATE_STEP, BITRATE_DEFAULT); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR, + BITRATE_MIN, BITRATE_MAX, + BITRATE_STEP, BITRATE_DEFAULT); + + v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR, + BITRATE_MIN, BITRATE_MAX, + BITRATE_STEP, BITRATE_DEFAULT); + } + ret = inst->ctrl_handler.error; if (ret) goto err;