From patchwork Wed Jun 2 09:47:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 452482 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp412643jao; Wed, 2 Jun 2021 02:47:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi8wTKTAtKxshBRdd/BirRFe4KT9mI6VRH6lV5M7sgBa864lFmP2dswhC7VFIpCQofGM5y X-Received: by 2002:a17:906:c00f:: with SMTP id e15mr35703735ejz.458.1622627271116; Wed, 02 Jun 2021 02:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622627271; cv=none; d=google.com; s=arc-20160816; b=JkJ3bZeFDmZcif+PZ5Qql+roLoJKehlOAV2PuzCutBPebq40a/1I0QZjwZRyq5Q4Tn g9spQLAKiC2tBv6A3ZAr4HLFviOPUU0Ci1NkTPtPzGq5GkDzfw4eUet+qESaRtiRIJHo 8F5JxkLcPsilD8lcbZ0XUDmNdSPsVFpjwzenWyU3fbd/q+Vf/mVm2fnmrwaSLbUnKUoc GX8NQdE6p3b31VCp23p/fJfSO8Y7c1LsyLJzN9hznxukpvc5wz7LVJTL7NLgAJhdn1M4 ruFc615NUr3WlYbgoNiAEOyz7VuPb8GIWguVXixWCPDLmztzafDrd6eePFdrDu+IEb4g dBdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zH7lA6Cr+wpWCWC/PirgaqY3xGbxUDhMzBZE+tSDOkw=; b=lnGLM6hUybqr0i7MosGgHU9Z9lfy7RzB1KRMccJHP+x4zWIaI4OxR6WI9kjWA5GZUV FlTLOs0J7NjPVK12HoOkmZIr+68ocv27OPfmsLvHgLtswReGMhuxlu40Uhq41L1iS6pF Kppnhn3c+YfGE+CBO0j5zX7drnJQFah/Tepr8BOnTVXRfrBpdKasdVcf40M3DOWDj1ba 7JS1PSrI5oGrvxaZRDCc96v7oCTKyRbMgYk0rvfwCV9oq0yQ0x43kItOSxnyE82CDyYk 1//0OlfrpTxmnBYZg3J2lAdOs3PwIt6Ae4wi42kHIhEje05Niz1jTXM5p3bfzZZUxry6 lbQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jh7HJ2aY; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 g18si1738427edb.157.2021.06.02.02.47.50; Wed, 02 Jun 2021 02:47:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=Jh7HJ2aY; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S232226AbhFBJtb (ORCPT + 17 others); Wed, 2 Jun 2021 05:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbhFBJtN (ORCPT ); Wed, 2 Jun 2021 05:49:13 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2BDEC061760 for ; Wed, 2 Jun 2021 02:47:28 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id c10so2863938eja.11 for ; Wed, 02 Jun 2021 02:47:28 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=zH7lA6Cr+wpWCWC/PirgaqY3xGbxUDhMzBZE+tSDOkw=; b=Jh7HJ2aYoQMVHQnt5M5ybt+e4WCjzsXrIgIaR84P0mOlzCnmx2Y5B5QnKwCo0Bcz47 PkMt68nFtdXxt5vIB1asdssZS6As/1WPySXmwfMBelTuA29/S+CCmpHqup5f+h+f2He1 MASceVPCxYm00I25AVr+HW6KqwrU8i/WpvF+xikveRXTMPvvFuoIu8ldH6uJi8uIbXfP ZFfGvj36/2FImqNLHGmdlIwuibc+uah9twkmO4VlsuXe33dH0nFihosX7w+3pkXe0PKX DkuBdG0UbvpThqWbKXMCeXsPX6R7qxu0Bf6dpPLUcMJ5YHAESYAbRsCIQHTY3HtHAFEN C3nw== 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:mime-version:content-transfer-encoding; bh=zH7lA6Cr+wpWCWC/PirgaqY3xGbxUDhMzBZE+tSDOkw=; b=kxQ3QeOqMSPvVkIlTJ1wllgWsqmdnXFmoGqzXi7adn0rPVBzmCOohJn4xSms/xpwhF Zcb8OSwou4bP/GRORC3ECD2lqrqkJH/g42wgLSFOje0C4I7sdGKR+wSnyHuGMuGe9U2r vHRKZfuVUJIPHq7Ew50SAzP94y3vbLq5Wn0gpciO2ishrRdxSkHxDIzFNEYDs01AZL99 hOqg437IfDyJxWeiWi2LIZgpGPfp+36Jqrt+g+ZGpbWU3+F/o+oUujCPniK1VIIMn+tM 8GsJahjf7Ydvge+d2YGtOt04WBj8iyzLqcpwuP3mjWhXkavHm1MYgXC9D3CeJJC689zT UBgA== X-Gm-Message-State: AOAM530qs62sDb8ue8QiLauZS+UYHTRh4qXDzND78+bzsxaTYzMuBhqO lgFlPCnsQMj6res7k2UEUmSUlA== X-Received: by 2002:a17:906:2b85:: with SMTP id m5mr34214365ejg.141.1622627247351; Wed, 02 Jun 2021 02:47:27 -0700 (PDT) Received: from localhost.localdomain (hst-221-100.medicom.bg. [84.238.221.100]) by smtp.gmail.com with ESMTPSA id q18sm945138edd.3.2021.06.02.02.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 02:47:27 -0700 (PDT) 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@collabora.com, Hans Verkuil , Stanimir Varbanov Subject: [PATCH v4 1/2] media: v4l2-ctrls: Add intra-refresh period control Date: Wed, 2 Jun 2021 12:47:13 +0300 Message-Id: <20210602094714.607828-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602094714.607828-1-stanimir.varbanov@linaro.org> References: <20210602094714.607828-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add a control to set intra-refresh period. Signed-off-by: Stanimir Varbanov --- .../media/v4l/ext-ctrls-codec.rst | 18 +++++++++++++++++- drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++ include/uapi/linux/v4l2-controls.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst index 0b8061666c57..803fb655af1c 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-codec.rst @@ -1174,7 +1174,23 @@ enum v4l2_mpeg_video_h264_entropy_mode - Cyclic intra macroblock refresh. This is the number of continuous macroblocks refreshed every frame. Each frame a successive set of macroblocks is refreshed until the cycle completes and starts from - the top of the frame. Applicable to H264, H263 and MPEG4 encoder. + the top of the frame. Note that intra-refresh period is + mutually exclusive with V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD + control, aka the client must set this one or the other but not both. + Applicable to H264, H263 and MPEG4 encoder. + +``V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (integer)`` + Intra macroblock refresh period. This sets the period to refresh + the whole frame. In other words, this defines the number of frames + for which the whole frame will be intra-refreshed. An example: + setting period to 1 means that the whole frame will be refreshed, + setting period to 2 means that the half of macroblocks will be + intra-refreshed on frameX and the other half of macroblocks + will be refreshed in frameX + 1 and so on. Setting period to zero + means no period is specified. Note that intra-refresh period is + mutually exclusive with V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB + control, aka the client must set this one or the other but not both. + Applicable to H264 and HEVC encoders. ``V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE (boolean)`` Frame level rate control enable. If this control is disabled then diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 7963c7b43450..3d73c28bafa7 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -833,6 +833,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE: return "Decoder Slice Interface"; case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: return "MPEG4 Loop Filter Enable"; case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: return "Number of Intra Refresh MBs"; + case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD: return "Intra Refresh Period"; case V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE: return "Frame Level Rate Control Enable"; case V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE: return "H264 MB Level Rate Control"; case V4L2_CID_MPEG_VIDEO_HEADER_MODE: return "Sequence Header Mode"; @@ -1257,6 +1258,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE: case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY: + case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD: *type = V4L2_CTRL_TYPE_INTEGER; break; case V4L2_CID_MPEG_VIDEO_LTR_COUNT: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index f96bea19c991..a34a18ec7f69 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -434,6 +434,7 @@ enum v4l2_mpeg_video_multi_slice_mode { #define V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (V4L2_CID_CODEC_BASE+233) #define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (V4L2_CID_CODEC_BASE+234) #define V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR (V4L2_CID_CODEC_BASE+235) +#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+236) /* CIDs for the MPEG-2 Part 2 (H.262) codec */ #define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270) From patchwork Wed Jun 2 09:47:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 452483 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp412661jao; Wed, 2 Jun 2021 02:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxop6gZ6d0ixkoDLETf7mtrdh0k9zQiPLe/cUBg0w1G2qf+8CwYn3oxeuGNkpj3EZ9d/tPD X-Received: by 2002:aa7:c042:: with SMTP id k2mr28349822edo.21.1622627272737; Wed, 02 Jun 2021 02:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622627272; cv=none; d=google.com; s=arc-20160816; b=dTdVo/jcPjzw/5HDej7ROMT7sZqeXOE3sYu4Hl33jRl/2IthyjqgJOsg2Krvuj6Sv6 QhzMbwlLZCjNnsiZFZPySUM4+XTsziHbyy+ZpWHMMPZ6j7pV5Q3f4BDc9EREurNhtWh2 HUr3vCdAsCi0zDIU3Nkr3Ke2cHrcmyGggqqUdGv7el/eCZAR/sUpzRvqFUcipuJL5l8/ S3KMCjgt+L5iMKgLXnfbLRgqX3HLdeM6zd2L4226TMDBF11bufLccCvXjox6fFbb5ljL 80LbcvM9PRNPgT3NsRELw1LdJcP8XzC0Yu8mT82DDPfnDidaMGGuUJpgF7q6MRRg9CG5 eHRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jUBkBWWpavQfJ/XXZFQzGX0EU9d+FGRKZtwFN9vG+OA=; b=adV/VrSmMOxp1LtFBoXASOTBpuokocrTReiOAGJqb5OJS/Rtv80IRbQJzZZwurz2Hv OZzUsKYPBEtVXJdOpcFkYfUuwQbQREIprN76V1669dFUrXmqLvqaaN0ANaLy6DtPvwRV Z6hLSu1ANoJzZeOZys4D+06Ow+KBZ1ZKRvh/wo71J2BuHOJwOaQNbDo9iU7Ue0V/rpz7 cvUzgyhrwO4GR9khI5sUUO/f0A239MGTeGsaz4vdljqEjCYaYX83THg1PQQGYtSUcN60 yv/3WcTRmM0Hb8uXRPuBRkg6An4ZKcCqcICxfsxIu0ykUHp8S0U8JwsORLFajTOHpacE O1YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dqlp68Xg; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 g18si1738427edb.157.2021.06.02.02.47.52; Wed, 02 Jun 2021 02:47:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=dqlp68Xg; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S232248AbhFBJtc (ORCPT + 17 others); Wed, 2 Jun 2021 05:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbhFBJtN (ORCPT ); Wed, 2 Jun 2021 05:49:13 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7A94C061763 for ; Wed, 2 Jun 2021 02:47:29 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id t3so2151971edc.7 for ; Wed, 02 Jun 2021 02:47:29 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=jUBkBWWpavQfJ/XXZFQzGX0EU9d+FGRKZtwFN9vG+OA=; b=dqlp68XgwnH/5WSR5prdBJfKu54+bYTh6b6Qs1yT8pMAeZHV0aKwW0wG4T4UePvFXd GIkXP07Z5R78TWifQtE/khIDPSNkr0M3jIQ8OvFtCBCED52CtyXxo6cVX+mKboKM3jt2 Hk23I+zzjBAVxpobLMa7lZeBKd+kke2iP3dNanaqn5MoW0UhwH6gmse7Wu+q6P0fsD6r NTSIagw+J7hInOkrKC4Ldl1rvPu345COOaCinwq7AZarccx74UTjcXdtTR9iDW11+A2v Ie7lOBsrvRCGdTeebHEmvGDTM8bbNdFQ1fS3Ks3PNIQlIZT7gzvJyzgmJQs1O+DW6GAg c8pQ== 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:mime-version:content-transfer-encoding; bh=jUBkBWWpavQfJ/XXZFQzGX0EU9d+FGRKZtwFN9vG+OA=; b=W5Dw8EVuouyyi0rv57azJWpc4yqL8EN9wNRk9B7F+Yh9eXVK2sL0PRTuNGGxYZnQDR xm9HrdEe+eRtWCAroja1jV1p/J9r/WcRESlcRvqsRjgQRQQSSmM754BXlsT87ljAw/LE EFk35p+sTI5RSwhYfVtz9PJvsag9wZFeL+rhbJScQyeke2KYb23scJBYixCOZhwDZ6A6 nJkCFCmK0aB/jU8y6Kl7+Z+wN4N5PsBCMOxEUEN/qu7S2OYqeE8srMD9O8BIbB44PjFx BsuNHP8sjydWIW+ILXcH+aYvDkNnG5nzCt7Pskmp8dJrO5tfz+jTAVw1fX4USy3Il+bw JzXw== X-Gm-Message-State: AOAM531W3sBkzVEuCwcPJeDRMfdsGzr3X+dhDledoXrIStIojbemFocH SJauQNkMwk1hqiayH1podIf1PA== X-Received: by 2002:aa7:d5d6:: with SMTP id d22mr8777514eds.302.1622627248235; Wed, 02 Jun 2021 02:47:28 -0700 (PDT) Received: from localhost.localdomain (hst-221-100.medicom.bg. [84.238.221.100]) by smtp.gmail.com with ESMTPSA id q18sm945138edd.3.2021.06.02.02.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 02:47:27 -0700 (PDT) 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@collabora.com, Hans Verkuil , Stanimir Varbanov Subject: [PATCH v4 2/2] venus: venc: Add support for intra-refresh period Date: Wed, 2 Jun 2021 12:47:14 +0300 Message-Id: <20210602094714.607828-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602094714.607828-1-stanimir.varbanov@linaro.org> References: <20210602094714.607828-1-stanimir.varbanov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add support for intra-refresh period v4l2 control and drop cyclic intra-refresh macroblock control in the same time. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/venc.c | 26 +++++++++++++++++++ .../media/platform/qcom/venus/venc_ctrls.c | 14 +++++----- 3 files changed, 34 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 8df2d497d706..df9f79f5b164 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -256,6 +256,7 @@ struct venc_controls { u32 header_mode; bool aud_enable; + 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 8dd49d4f124c..718ce3578be8 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -547,6 +547,7 @@ static int venc_set_properties(struct venus_inst *inst) struct hfi_quantization_range quant_range; struct hfi_enable en; struct hfi_ltr_mode ltr_mode; + struct hfi_intra_refresh intra_refresh = {}; u32 ptype, rate_control, bitrate; u32 profile, level; int ret; @@ -802,6 +803,31 @@ static int venc_set_properties(struct venus_inst *inst) en.enable = 1; ret = hfi_session_set_property(inst, ptype, &en); + } + + 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; } diff --git a/drivers/media/platform/qcom/venus/venc_ctrls.c b/drivers/media/platform/qcom/venus/venc_ctrls.c index 637c92f6c5be..eb10affc6277 100644 --- a/drivers/media/platform/qcom/venus/venc_ctrls.c +++ b/drivers/media/platform/qcom/venus/venc_ctrls.c @@ -17,7 +17,6 @@ #define SLICE_BYTE_SIZE_MAX 1024 #define SLICE_BYTE_SIZE_MIN 1024 #define SLICE_MB_SIZE_MAX 300 -#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 @@ -227,8 +226,6 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) } mutex_unlock(&inst->lock); break; - case V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB: - break; case V4L2_CID_MPEG_VIDEO_GOP_SIZE: ret = venc_calc_bpframes(ctrl->val, ctr->num_b_frames, &bframes, &ctr->num_p_frames); @@ -319,6 +316,9 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY: ctr->mastering = *ctrl->p_new.p_hdr10_mastering; break; + case V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD: + ctr->intra_refresh_period = ctrl->val; + break; default: return -EINVAL; } @@ -502,10 +502,6 @@ int venc_ctrl_init(struct venus_inst *inst) v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA, -6, 6, 1, 0); - v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, - V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB, - 0, INTRA_REFRESH_MBS_MAX, 1, 0); - v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops, V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, (1 << 16) - 1, 1, 30); @@ -564,6 +560,10 @@ int venc_ctrl_init(struct venus_inst *inst) V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY, v4l2_ctrl_ptr_create(NULL)); + 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;