From patchwork Mon Aug 12 07:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jackson.lee" X-Patchwork-Id: 13760227 Received: from SLXP216CU001.outbound.protection.outlook.com (mail-koreacentralazon11021080.outbound.protection.outlook.com [40.107.42.80]) (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 12169152790; Mon, 12 Aug 2024 07:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.42.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723446527; cv=fail; b=KIWZ86aKs5jj8Ue/e3ZkRH3qmzS772OWBVzpWbAEMG/kjHU0Bk+sALwScSnmEESeqLl0Ot5r/We7IXZA7bXnGaxf96tgRB503F6LQtEeNzcfuEQe0klGr5CMFVcJnjuesyoevZ6MT8NtZK/bTx2c8vapFrsDISx53d4kz1CAf1U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723446527; c=relaxed/simple; bh=kSDctqTnLEaMTcIwVIkXuc+h23dPmZ7zEJMLWdW9WEs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=q8AMi5Xl3OUty8fUwknLz7zJGObV/odvgTETmWj5Jd9oznOJCaJce1wjbhNTeljrW4nCgkXnCt5cAV+17WaeGWpDOAgJN8g/VrLWmkfHa2Nit4yMhCHZsEFj9qy6YgEHlbkAHcAJcJm4IvSvUvQhCRzCX+uL7ITzBLOd/CD1SOk= 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=JCyQTjSk; arc=fail smtp.client-ip=40.107.42.80 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="JCyQTjSk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IjOPLkhL34oLvfSyainq6K+alrJq05vnIbMTyWfcKqRrCR+ao9zIve1LEEvoLHIEaQb66U4/QexB3H7TRBvDuqz6LpJBEgCfzDlfShPKPlrLHsStm4Gg9VMQTYSzPtqiLZ4WDgY+Ry0Ov+TsmLtshEE2CXUwv8shXN1m6c/Rd9H68HgQJBoB08NGUjXOgS2/9hWh6N+tqSogiD1Gw9PfgSKATIBjRZZ8f4+2lQ7h1tZj133izwnfq5I77c9JMGnzjTmlo+SsDZMQMAc3e6yJ0arQQaBC0DvrQU2DKU7KoMhe4pjfSiGrRgG5pE2YmCynI0DHABYmuGl2bN13o/mgpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=UWbNLWskET9h61KXYtOCGImr7d5KzHGfun3x8NvAomQ=; b=qZh8CBv5r3+kqp1I7DHrUuHhEPezutK4lMTFsfLY6vwxNw54XUlDLEqUumNgJn5gK9AZsUSVnnaok0NYQOmCYQWlIvGMqkr+Sg/Y1EYqCILrcAc9Y41IGQZ+3e/+NtL0nnSGcNbcKlieyn4AtUiWMrOg+K5ngrEE65jQ4vn0BDOx/+wPrF0xK0kndRTyA/AjcuInG4+7zhlCKz/FkQfESuxhR1F7MuHIS8xOW/sywgnqgIMOZZe8Sg6LkpKLa7e6Y05ooBc/O2hcvoCHlPMPdvDRGlt33A0eDTvJmWmpK6sHZWi5U3al5kfxBavyPG8smNq0jjLNpOWSy4jcstSexg== 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=UWbNLWskET9h61KXYtOCGImr7d5KzHGfun3x8NvAomQ=; b=JCyQTjSkDQFKhNsrRDiM7yZc6qXVh8a6OCP96yzTwqdiF6DWcsblyT5DFkoDfyeBdlcxETd7Q7prsGDHggMPwbSOmpSm+vnOVH8cP4ECtIoGcprKPklt+TcOyQDea3/l+oiTY2t9pPQJkanjU/eVCPmeQytSnZnWAYOhk1EyF3U= 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 SL2P216MB1530.KORP216.PROD.OUTLOOK.COM (2603:1096:101:33::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.20; Mon, 12 Aug 2024 07:08:39 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::b711:5ab1:b5a4:d01b]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::b711:5ab1:b5a4:d01b%7]) with mapi id 15.20.7849.019; Mon, 12 Aug 2024 07:08:39 +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: [RESEND PATCH v7 1/4] media: chips-media: wave5: Support SPS/PPS generation for each IDR Date: Mon, 12 Aug 2024 16:08:20 +0900 Message-Id: <20240812070823.125-2-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240812070823.125-1-jackson.lee@chipsnmedia.com> References: <20240812070823.125-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0154.KORP216.PROD.OUTLOOK.COM (2603:1096:101:35::18) 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_|SL2P216MB1530:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d12b3e3-dbc2-44f5-e21c-08dcba9d975a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: DAJp01uaWpVAZwAr508ayXNkopfRBnKZnLHvHzFX6EHTkCySmz4rdM21wH49/b2lb8dgeIiCiCCaBcFLS637PUTTV6x4ELQSZH3g14lFb2KRoqmZ/wUlXAPTIAJ/xV0SxyS5QO5G22RzMp77+5RAf5jVz3zqW7htdGQEY/SoH3fLMnxqNiKn4YRyfTQLCQuT0VW3DCzXHgsiHIfe5j6ahAbDqHJWurdC53cs7PHpqwJ0pq+bTTV4HjX+/ll1FPg1cSsIf3DT03yljnbB6VhRBydbelB0btXg17W4WF5VYW6ulkilu/BqXsKVWyEkVjAKAKEuQNQXE/f3GdKQGIhU3bKNXh1dv05hM+vl8m+w1VtXokEXmtmgc58ElJR1Zdf7i0NQ8NK6KZ4C8h8/X7ZZXf0khPuGNZ9EUBHjnssx6M8dISQd8/OcDFJTULqIdioggmrwmI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UTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hlkJrfIOlqDhICXjXNP5U8dJT6Wyh3fghU0/ijvAwmzhYVzswBTX6+2bAazHKAi7a8eTWbZug7vEmYojGCC+Nt7uYhiARkKJP/lO2wxUfXp0fJDorESJw5gf06N4CGJj45OZI6M32Whm12nsMhIVo1GwkxsHQGH3C+9FeKWKK9+wZwQ2XCo89o3BnTVq3AeCKy/Inx07CNR7vlT+o+5JaMIbhO6A0jl4AuGYUvREF+41agujAbroloHJiy9A+Xa6AzSzoz0QtHpBUO4DEQX2c/GP2+UoeuoKB7GEu7oBFfzbhSUhbg7C85+4cPNMAwYyJHFhnQLzsbDQqFMLRjnM1H+taz303G42PCVsNASQIA9UO31Ly7gb7Y9rYHI6PlCLWB4p8rBIylHtkdkiutlYX32h3/XixQD75EoQgKG9Xfr5ojt8mQG3Cy0HY6TFJkdImumPcvWWtBA9307sPGx1stOGEqgsjjEJJW3m+QmCbRD8hSHV9cULOw0TUq3k5n4a1pC3qZJUB3TjsiHu6zkF4vwa2zJ/dI4e4Uwk2JPv40MKy6e+h2MKEl9vqTgUYbqAuWLy4oOFN8mfMzJmyfzTRF4CW3BR3IV1k6hERAcRoFQF3K9tSFow2SO44x+2KLZDunEEtQB6VC3/q4VEd2QF4YMrORKxFKF27h7Kpc8Wy9D1TOWygQe8Osz8Wf5Aj8OeibkOG+BJu8Uvswnl0Pq05fUbj0MXk2lNIOprNDNKAfre/Rn7D8ZamU4sAWT106ceMRtVktkBwc1Jd+IUrDrtAid7VJ9B8Zd0zY1xnIp+HnQlfprhJARBefcazTR6DLkw64JVIhk16mhh0V0IooA+D2PN3UHYPPqvmQWQQInvdej+v2CTkcIoPj1c5bY6QircF6SWZSQBl+wl1e4kbOAPW2GY5M366aTjvkUeTCgBysFGOczCXOQHv8J4WByLVx+vNSC2GQ8+jjtDZen7uZFqWf45YegYOW4KpvSvXLxJ7j5CqbC4hZDjFDWfR/nUGS8Neoi32O9lRJCxM43mrQQTBXSIQUwYXpEac0zlSCOU85JJkGr7FylKB3uprOcr+z0I+LmFUaROazmKZQYcFW4x1v5yMRhyjEzMBm9wWTb6wJZp4veaChy6LAzO53ujyn72VPcsATklOVet5eGae/yj0Iz/lFaJ2ZipGNVOpJV7+jaQpirdS+TvGzzOnw+KMIE/J+ctPDB41W4PJH301YXxAA426CBSfhNsxehiYgB9Sapxcm6M/PsWgpNjO17zTQ8GqwWWk8BRzarHjKXJ3IQ88MJbY1KYuubxGb6JZKFe1SnroY4ZUSUrc5Pjs4wduox4L9TQdit0GTtgo9CnzlRwZYyFBhNbtGsQ/PGuooZoIjWaIg5LBu5NLeddH58PXxMnTXtczd5/sTuDc5+6NTKcbAteec/9T4nudWhkFtZC3m8PoHXI8nkGVlihiT+eyjpqE9L/VdP8Von8sDfyUCDjMS4LJHlNfik/dS/iP2GaUnvpqYwTuzyCnTmJ0OeGVHCrgWqQ2PjpWZFqRIFRcBbOYLcQgSrnHcgrULhp1wXyU5E5cHV1L4zwaU4KbOrQI1cjWeMzwOrkOtrLiLesEQ9Gcw== X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d12b3e3-dbc2-44f5-e21c-08dcba9d975a X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2024 07:08:39.2770 (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: saglZGyhyMzJuYLLKS73HdSUm83vhChwOWdKHmHX8E1DsJgzrraNtk1oI70SE0mUxEsH4clfIRlw4ufkN4yYSArOg42zG39bGMA8xKzvuaQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2P216MB1530 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 c89aafabc742..2a98bab446d0 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 W521_FEATURE_AVC_ENCODER BIT(1) #define W521_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 W521_FEATURE_AVC_DECODER BIT(3) #define W521_FEATURE_HEVC_DECODER BIT(2) @@ -35,7 +44,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) @@ -1772,12 +1781,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 3e35a05c2d8d..b731decbfda6 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 d2370511faf8..45615c15beca 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h @@ -568,6 +568,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 {