From patchwork Mon Jun 17 10:41:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 805074 Received: from SLXP216CU001.outbound.protection.outlook.com (mail-koreacentralazon11020003.outbound.protection.outlook.com [52.101.154.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 290AE194ACD; Mon, 17 Jun 2024 10:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.154.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718620932; cv=fail; b=uLPMw+PDpHEBoNCE2ewK/crr8xo5J+rLRHf56iOhkRO6+LTOyfZ0CPj8IeeGNd6OLcCo5QWWyadzYeONFsIbpRxN609X+SJLzshyAN/maDIbcHZKtgZVcn/99pJ3cC1NEmvHEU3BodfpgejTQqiD31t+NCNj9XA+PWlonzif9T8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718620932; c=relaxed/simple; bh=Jh7NMn5Ffi08bvNN1CoE3ShnyByaBguMtO82WgWG96c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=sRHddX6JgejWnQSzGQoqOHFGsR6Ba/c1h8C6dQhDfxKPzMMI0vw2tVxQc6tRtLfnyP8AJXRUdbCVj/q3axe8F6phrinzJE9odMEPIqpIzzhel/tSV9pyDcQdTozzu5w/ArnJ7eWC/po6OZIA/Q2/ZgocyIavBhrKfiLmlLj6NcY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com; spf=pass smtp.mailfrom=chipsnmedia.com; dkim=pass (1024-bit key) header.d=chipsnmedia.com header.i=@chipsnmedia.com header.b=VCw1MaKb; arc=fail smtp.client-ip=52.101.154.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.com header.i=@chipsnmedia.com header.b="VCw1MaKb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Av4moj8oUHR9FcEFkKYni2E6y1nN+rojHHz+8dmtGishUxZUEghnNjcwqkFMYyNG1RrOz4tQ2+IBshWRa4/5vFLAy7xFJ5i7RQDiEZnfZULFKWgfc7KWUIxhWzXxCo3GLG3ZCqIDNIyWJIKAzLOeRsK0wNob07AtdWdQmB/DJC7ulwSctyBbteAtTwCvffOR431JCFDrMWPtQa5F7w2zcD39TYoryJhhQAfgVi3RJSDvfTTilKa5DdBR2ywacRq7//Yrv0IK3C4gZHuc3tN87iX+cutLXw6ddq5EHDL5rdH9nk62J6MYIOgGqBlf/bQNLwG6ltomD6EjL+Nth8KOcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wbHaY/RN3sriw+PWqSPfBhyDm6vcvpDz6rCL7/jkTlk=; b=IAKIM+H7KVuC09/4ebJvqLRDJkCBGX9ccHbgfrRnqR7IOBAVNfY7NJDlSK4JlN19cxr4kLam9+KXBro0VWFIkuEmcdi4owM0+nyuLn0lZh3hS3STG3wLUwR04V20MY6k7+PcksyQg0IMVtg4tOE8ZEMaOWQP6RkynaV/fN0JV+vtACnayZZwUgVQpa735noUlKGbci/qhT2b9v2i63f2gn39Sou3P7TARyKDD3troIjPy89rej9VRF4fV8rhhC4/H2Un9aGEpaLNJ6m8/X6WBSs/sg/XS5zwcbvF4yCZIn/E8iIrRJ/uluZkRH68TJZgcRstiKukTqiXGK36jefU3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=chipsnmedia.com; dmarc=pass action=none header.from=chipsnmedia.com; dkim=pass header.d=chipsnmedia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chipsnmedia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wbHaY/RN3sriw+PWqSPfBhyDm6vcvpDz6rCL7/jkTlk=; b=VCw1MaKbgjCKkQErF3EVQDpYDjy7Xzs7fND2DIpydQgJ3RKGmc9+qaOAkn+7Dcjbr5rLi0FrE2esYJOhuln6Hmf8pWkdzb+9xj+r3rIq5xbYWJlfwKwX8ZCwJoWxA7cPsLGjeU/et2NZW5FaqT3GBzETURxFjm5PZcvzS0GlaCg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=chipsnmedia.com; Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) by SL2P216MB3099.KORP216.PROD.OUTLOOK.COM (2603:1096:101:282::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 10:42:04 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::b711:5ab1:b5a4:d01b]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::b711:5ab1:b5a4:d01b%4]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 10:42:04 +0000 From: "Jackson.lee" To: mchehab@kernel.org, nicolas@ndufresne.ca, sebastian.fricke@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, jackson.lee@chipsnmedia.com, Nicolas Dufresne Subject: [PATCH v6 1/4] media: chips-media: wave5: Support SPS/PPS generation for each IDR Date: Mon, 17 Jun 2024 19:41:52 +0900 Message-Id: <20240617104155.153-2-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617104155.153-1-jackson.lee@chipsnmedia.com> References: <20240617104155.153-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0185.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1a::9) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|SL2P216MB3099:EE_ X-MS-Office365-Filtering-Correlation-Id: da95ecfe-e864-4c9a-c3dc-08dc8eba2058 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|52116011|376011|1800799021|366013|38350700011; X-Microsoft-Antispam-Message-Info: vEDBDjYg/qpkk7Hvx2uRUC26eyh8BozgX6gH67e3rTQkTNzSJOhAroqZLG8zBCTJD/qyOyMsydEPbTdFOVDxfSv62X4aGEN5OKKWnQ2LxTiZnLb8bgy7nDvBSwLHaJcWW0hedcrLwG9VNYL7FCpP7v3kFMkh+6HNKwmap80hZ1MDEY4xiZizgQxoaDghZFL0VSVb8BItGOU3BpM++DBEhiT0uTi9CP9VX/rOyascSZMr6jYwZgibUrPCtflWUDJfZM42T5zXHisA8gx+ABXu+VSbcT5QAfkWDyS/MyhrKUm8HHPAHpPtpBDpqc6QfXM6uC4VeQIdFmuldCyWfKEjFjZixqfiCtjukSZ7EfOl5NaGWXjSFjq0fXPpEIVVjZ1z4FrRKff3bwpviOXciIiE85Rc7WxgQC8oY0s6FNcgqLXJbXpMvzhmGHs8Vqbgn1G/hDOVty65FQ33Zj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PFiIQgtgH17fONYAaqHxBWeo1h4JpSAX7klzp9kIyAFnuI/s/nAZc6Gl8FTFzUbZ7rCP8kRNtRMMFgvaADu4wl13ieOSF8MjoG0VPK8seGOgh0qYw1fHgoRX6HV9Jh8WDosRCEAphXanjc3xD+52oUeMX9OrK+ga8Z4liAOYQq2HeiSBk6iQVK6BGXdLrjmUgaQLgMvzBoVWuqIcs4Ah/yIY/xEzcGNfMSx64WXbo1OcQvnNwBjrewUecVwLZ4o+mRlEGA2vciO+TkOLPDet+ir6T3k3342zCXsJC7PNWPwoebraKUgrec4BNMVPbDc1+2X4vniLZjk/RNTkVIUED/yrGS2BxitWw7B93HeykPmLu44QHr4SAvQcyuE5zPLJ4VPu+oaG+zj1NV4xmy/PbBDgVKlI6BIU1tHC0qjYMy+7kPIA0KNcD3eMXUCKvFEIWUYYPEl+IsvElI81KNHHMdpgYLp/dpXm7S+FOYK7TCGrjdQ71uwnGjEzYoPM7qUi+RWr4rIW0YTDk7479RONfS7rFBJEc8yh21mr7+ZuZfbtqfM84nYM5gaqE1WyXDd3abfJHGyxZMn4Z6SJIbc9dxI+j0/cgCG8yy1S/45McmMoJKkPeM72QtK84xBqmrmd7JGgA== X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: da95ecfe-e864-4c9a-c3dc-08dc8eba2058 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 10:42:03.8790 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4d70c8e9-142b-4389-b7f2-fa8a3c68c467 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sNNRR1fBg+2LHEBRP7uCtMhUWCodUVEUw+MlymsyW2f3BdpRgKlCLgoUVi1YeWwHRycydtjK/RY9Sh49x3grUM4tjXwsrCCdWDsNDrjzgUI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2P216MB3099 From: "jackson.lee" Provide a control to toggle (0 = off / 1 = on), whether the SPS and PPS are generated for every IDR. Signed-off-by: Jackson.lee Signed-off-by: Nas Chung Reviewed-by: Nicolas Dufresne --- .../platform/chips-media/wave5/wave5-hw.c | 26 +++++++++++++++---- .../chips-media/wave5/wave5-vpu-enc.c | 7 +++++ .../platform/chips-media/wave5/wave5-vpuapi.h | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-hw.c b/drivers/media/platform/chips-media/wave5/wave5-hw.c index 2d82791f575e..6ef5bd5fb325 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-hw.c +++ b/drivers/media/platform/chips-media/wave5/wave5-hw.c @@ -23,6 +23,15 @@ #define FEATURE_AVC_ENCODER BIT(1) #define FEATURE_HEVC_ENCODER BIT(0) +#define ENC_AVC_INTRA_IDR_PARAM_MASK 0x7ff +#define ENC_AVC_INTRA_PERIOD_SHIFT 6 +#define ENC_AVC_IDR_PERIOD_SHIFT 17 +#define ENC_AVC_FORCED_IDR_HEADER_SHIFT 28 + +#define ENC_HEVC_INTRA_QP_SHIFT 3 +#define ENC_HEVC_FORCED_IDR_HEADER_SHIFT 9 +#define ENC_HEVC_INTRA_PERIOD_SHIFT 16 + /* Decoder support fields */ #define FEATURE_AVC_DECODER BIT(3) #define FEATURE_HEVC_DECODER BIT(2) @@ -33,7 +42,7 @@ #define REMAP_CTRL_MAX_SIZE_BITS ((W5_REMAP_MAX_SIZE >> 12) & 0x1ff) #define REMAP_CTRL_REGISTER_VALUE(index) ( \ - (BIT(31) | (index << 12) | BIT(11) | REMAP_CTRL_MAX_SIZE_BITS) \ + (BIT(31) | ((index) << 12) | BIT(11) | REMAP_CTRL_MAX_SIZE_BITS)\ ) #define FASTIO_ADDRESS_MASK GENMASK(15, 0) @@ -1601,12 +1610,19 @@ int wave5_vpu_enc_init_seq(struct vpu_instance *inst) if (inst->std == W_AVC_ENC) vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_INTRA_PARAM, p_param->intra_qp | - ((p_param->intra_period & 0x7ff) << 6) | - ((p_param->avc_idr_period & 0x7ff) << 17)); + ((p_param->intra_period & ENC_AVC_INTRA_IDR_PARAM_MASK) + << ENC_AVC_INTRA_PERIOD_SHIFT) | + ((p_param->avc_idr_period & ENC_AVC_INTRA_IDR_PARAM_MASK) + << ENC_AVC_IDR_PERIOD_SHIFT) | + (p_param->forced_idr_header_enable + << ENC_AVC_FORCED_IDR_HEADER_SHIFT)); else if (inst->std == W_HEVC_ENC) vpu_write_reg(inst->dev, W5_CMD_ENC_SEQ_INTRA_PARAM, - p_param->decoding_refresh_type | (p_param->intra_qp << 3) | - (p_param->intra_period << 16)); + p_param->decoding_refresh_type | + (p_param->intra_qp << ENC_HEVC_INTRA_QP_SHIFT) | + (p_param->forced_idr_header_enable + << ENC_HEVC_FORCED_IDR_HEADER_SHIFT) | + (p_param->intra_period << ENC_HEVC_INTRA_PERIOD_SHIFT)); reg_val = (p_param->rdo_skip << 2) | (p_param->lambda_scaling_enable << 3) | diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c index a45a2f699000..a23908011a39 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -1061,6 +1061,9 @@ static int wave5_vpu_enc_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE: inst->enc_param.entropy_coding_mode = ctrl->val; break; + case V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR: + inst->enc_param.forced_idr_header_enable = ctrl->val; + break; case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT: break; default: @@ -1219,6 +1222,7 @@ static void wave5_set_enc_openparam(struct enc_open_param *open_param, else open_param->wave_param.intra_refresh_arg = num_ctu_row; } + open_param->wave_param.forced_idr_header_enable = input.forced_idr_header_enable; } static int initialize_sequence(struct vpu_instance *inst) @@ -1701,6 +1705,9 @@ static int wave5_vpu_open_enc(struct file *filp) 0, 1, 1, 0); v4l2_ctrl_new_std(v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, 1, 32, 1, 1); + v4l2_ctrl_new_std(v4l2_ctrl_hdl, &wave5_vpu_enc_ctrl_ops, + V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR, + 0, 1, 1, 0); if (v4l2_ctrl_hdl->error) { ret = -ENODEV; diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h index edc50450ddb8..554c40b2e002 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h @@ -566,6 +566,7 @@ struct enc_wave_param { u32 lambda_scaling_enable: 1; /* enable lambda scaling using custom GOP */ u32 transform8x8_enable: 1; /* enable 8x8 intra prediction and 8x8 transform */ u32 mb_level_rc_enable: 1; /* enable MB-level rate control */ + u32 forced_idr_header_enable: 1; /* enable header encoding before IDR frame */ }; struct enc_open_param {