[v3,4/4] media: chips-media: wave5: Support YUV422 raw pixel-formats on the encoder.
Message ID | 20240430013900.187-5-nas.chung@chipsnmedia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Sebastian Fricke |
Headers |
Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <linux-media+bounces-10390-patchwork=linuxtv.org@vger.kernel.org>) id 1s1cSr-0007p5-2Y for patchwork@linuxtv.org; Tue, 30 Apr 2024 01:39:26 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 71C421F21C8D for <patchwork@linuxtv.org>; Tue, 30 Apr 2024 01:39:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C05033D5; Tue, 30 Apr 2024 01:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.com header.i=@chipsnmedia.com header.b="jMQdILad" X-Original-To: linux-media@vger.kernel.org Received: from SEVP216CU002.outbound.protection.outlook.com (mail-koreacentralazon11022018.outbound.protection.outlook.com [52.101.154.18]) (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 0482C17F5; Tue, 30 Apr 2024 01:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.154.18 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714441156; cv=fail; b=N3KCBfeN9vu3itziQ4nyKV4akU30g+nehX495TRI1DJFgu9027O46YzDv9591j0+XrmNk0Vm2vxs5yZJ4OY0skrbCVmlSMlcKMUk+U4i6sua9veXxBd6L+Ubeomgz8porZRu4C2HLBqOBclsDkK4fhQH04JJoIjcwdjRJkSsul4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714441156; c=relaxed/simple; bh=LRZ7WFXbHhzipeQ4f4GxVYXrahpPa1ffp4oaRK4ViNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IVw7Xi/pAgZoflGTJiio+XYQYiEbxcpdtyXsaOeoYyTdrujRqU4AEliu7lCuGFMYKnp+a+9rhVOtMbcedjMBsuWhZu86nXITSRer+SpInt7Q/nceLeP1Ik3zYThXpR/QCA+scteWMMx/5piUtFPGEJTMqXKiTK46ZWUo5gZDiJ4= 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=jMQdILad; arc=fail smtp.client-ip=52.101.154.18 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IAFqCCQc8KWQv62a25TRgoxGXC8Y7hiFllzk6TayMxHtpbo1k8cr/Be075sh7tfNoYTav6jXakQVMLpb2uWyRBu8cjmc5410rynvtunsBOSgrx7h4ISKRm+t+ImOXYaGS3hlafwgMED8+MpoI/L+PxHeG9xTjJISK2L0QTVkYsWUMgIC34IGtSiTEZ4DUaeTr+3j4BK1akx0A6Hk3l8HAiIY830Vfs0SHFP2ik34hcs9d/sDe0syp4P2Bl2GXsYdm8LWzw5e1/zBaUSKsozD3w1Gj1fJD/JkDiA3d6AZr4rguAOTui9qi+rw5uIU/iJZqWPoT2LhiO9hZj40LJN1lw== 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=HZmiTKU+GeUSjmX5LtpCmEnBh4mdQBL3M1DfjwaYLIA=; b=hZxPwT7v3l/2xSfAC/+kEejR8SDnOzpLGjmAvWkrkZpTU6+AUydjHEpPp96Eo1iiHk1iRVw6fuiOAdYzpGiZkMoEVwMVZTtKQtIAlxbHyFMNcJxf5o8Lf1pVG8Qthuh1MiNqV1bzP7atsSG07oJ8URFpBE2s1is5A4wUpvGVA2jlDI3Ph7PuQfW7sBUqgH5xWChFJUQfbgQcfUNzEyCicVbo+4n0ed5R6nDKaAEnx6A2sT7ja2PF8yJYojeYMBIVKNZ5JPOSSuUEYysj5L5S5RK2Hyw/I98ymb/+57TmGTIbFGpytTdqbAgG9hdMQ1hN38PaKFPvh+WD37Z8zXM4mA== 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=HZmiTKU+GeUSjmX5LtpCmEnBh4mdQBL3M1DfjwaYLIA=; b=jMQdILadD/ENoVehWGL4C8y2A2lyian7Uj+XSUU2EXAFcNzfwFVLmQFOx6FXaB2bg14NkLO2r2NvXEFNW9rr5ml/oFxW4c3NBjjTSNXG1AUCARUKW25lkOUs3LSwofUnRhxhS5N+H1cH4dxZgeW7xbzsxyP7CPBrUBwBT4qT0Lg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=chipsnmedia.com; Received: from SL2P216MB1246.KORP216.PROD.OUTLOOK.COM (2603:1096:101:a::9) by PU4P216MB1324.KORP216.PROD.OUTLOOK.COM (2603:1096:301:a8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.36; Tue, 30 Apr 2024 01:39:11 +0000 Received: from SL2P216MB1246.KORP216.PROD.OUTLOOK.COM ([fe80::5b8:35f1:821f:4f57]) by SL2P216MB1246.KORP216.PROD.OUTLOOK.COM ([fe80::5b8:35f1:821f:4f57%2]) with mapi id 15.20.7519.035; Tue, 30 Apr 2024 01:39:11 +0000 From: Nas Chung <nas.chung@chipsnmedia.com> 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@chipnsmedia.com, "Jackson.lee" <jackson.lee@chipsnmedia.com> Subject: [PATCH v3 4/4] media: chips-media: wave5: Support YUV422 raw pixel-formats on the encoder. Date: Tue, 30 Apr 2024 10:39:00 +0900 Message-Id: <20240430013900.187-5-nas.chung@chipsnmedia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240430013900.187-1-nas.chung@chipsnmedia.com> References: <20240430013900.187-1-nas.chung@chipsnmedia.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SL2P216CA0211.KORP216.PROD.OUTLOOK.COM (2603:1096:101:19::19) To SL2P216MB1246.KORP216.PROD.OUTLOOK.COM (2603:1096:101:a::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: <linux-media.vger.kernel.org> List-Subscribe: <mailto:linux-media+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-media+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SL2P216MB1246:EE_|PU4P216MB1324:EE_ X-MS-Office365-Filtering-Correlation-Id: b39bdff6-ed38-4a8b-7be6-08dc68b6559b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|376005|366007|38350700005; X-Microsoft-Antispam-Message-Info: rGpZp02/u6iXNL9/Mc6jUVPKam4xZ1WEBmAROEvgUl8Y1Rf/j2snMcEmvWhwJDuR4tbxMuYA6lo71yFmsN9or36yIbKcKgcL+JK8axALTKZKboKrxa0WVv6Ln2LIBtwwWsO2QoLs1RR3WJwW3UVITl4lS80jkkV9K1Xn3WWz7BXax3FYajy2tb+qSBDB9Y/BVv5Ia975ETo5exA2k9uPQ3Tz4HZ9fOo+YGCa2twesfRKgJOhv2DPJuxgEyG/dInQ3BBmCIh4ih1jAY22CC8CfbW7f9tAqQfUkaL5lccU8CNcMcii3aq+QMt3D59C9w5RLEwE1juA+s/y63gM0ztDUBYUasm1rpVJ//OjsjkDQMR0CQHppoyDek4umv2ZjJ0PsKu5rDfK4QiRoJLkgvVmyGev7Sp2TS82cxM1YJegYqqmR/dS4ObfWVmWPDWzdcNzYkHhCUQmENGUHZNbsAqAeUab40pI610I5I6aIBWukNDpWcc8YrkSZ2BHPWTkBc//o0NBADwFmG2vrXwBwXFyuQtdAuzH8LtfErxgS+olJHFE6Ow6J6eKemar87FWKC7hzVu+iT2/wKDdSvJaN2ma6KevSM1NaFmB9OMCggBI4cjE7++4kl/du+2Lu7IcDM5MU9WP7LiIvcIEgWn53LYItzwWAIYMDG7XJDcCuS9CLd5EfMRUChCc9z8fAiTIZ+QPPwZ9ykZE2iurtT3JlOxiDYMfR8K5FsvrvVZWEPVGOMPJB9ylczd9UFxwMXI1w0HhtewfxhIp9apa/fe1OfcFS2l/V87Oo3TE1EFcEsFoV+DkBbRENxFOTTgVKhtvLy9a+eXVEQR0xBq4j1sVvXcbr8EP4JA/39zKUIr8Sw2uYMxC4w4f23P544XZTguVVSHU8AWFwNzDEPjsmEQgJ6E0MCqHO3qYKnKP7GEGj22IOVOe0W0+gGWdgb+fVlblAjLOw0NXCWEX6WVWoiPvXEGZwz2JaCJJC765bJsBGidWSmkHzQxu0G7SyHEN9HVEAgcHQClhloGqrhf0BLmNr5qT5+XpIurIhvNN46MDtvz0BfekXMPnKok0OqymI7P4nYvwbES3wxejclcNjoWWZrcWWd3qFJWTlvX9eR1VsyYG++AwFRtbcE2/Bb8hPCg9iSKUSUH0vkh2dn0kTYQUPJEX0LAb/fmz2KPhioYlEH5Ilml+yD0dCSe62HlFIQBB/A4P1d6ekv21JN+4JkKEd0dbvqkAgI3R8GTukKv6ugTCdU4wvems5+n+FtOF/9q68ZjHzsVfS2uewE7g2QvxAor3SmUaoTQoUhxC5NidGPYF7/QARZYtK3GmKkBPfCy1Y1qtA2xny9ASc9Tr6I/VIPmIsw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2P216MB1246.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(376005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: blG7TrdS6lD1kcatld35V7fEtt5gIzvvy7YmM167Cpc9wR3gA1y9tW3fFdRPhSLc1GFLdG47W/18IpipYzXBL8hAqMJUxiseHkJhYaqy4GmqN2WoZMgZ3TC+xvzwJCFPeGG/ezfabPNcm2b0j7nzsodnpNVRafF+U5Bf7l/U9KOOQrRzqdaX+EuMOz45Cs26+qMdyFMRFGSsGWWxaMILQV14+bT5BLEwXreyV1UTZFEYYkCIZBc2NU0iqabYPkp5rGYdELW3DNh3Ya0vFVZU4Q9EPsTGywe90udo44eIyWwoGgY/dCklYDuOLU03GVQ9VZZo+1asyKna0JKkLVulnJaSqyaldZZKU1VXr4R0yphpcJM/6IbaC2bcKcFJjRQ+ogHl/fLQY4LSmwPk7OhRK7Uls6gb0fSmdVRrRWsJsk6/0vASrYRV3z433o82EGmhdwnacDTeyfHe4KyKtKAUe0X3X233YAnKVFaajERjIchKrYuff+keNiBJXbTU+Cy+RDYXRNup07j+jxH6UfFhLj5ODg9dGgDxmBagMbtAOCm4ncdzXhgPjm6eZBcIXPMzwkMaJ9YZyhgB5dF06p4kF2McXZ2yAJ1jx63XSUn7oz0POgud0oOCUg6syAeHSn+8HNymmzOZyGFrp9s1nCwSx5fTZBdOUpd6PM2R5NOMTOCbzluUHuME1qrzgzPwgr/k09atwYDGaV8vq+3FXMXnOo8CWiKGQD+IBr+usnANsLmSYCshd2fVBKBlt41MiRxgjKKWz1IWj00kxOH+UE9WwmVX4TZfOU77NtFrxoQk4SIf4tLhAfdEVJTpUhm5Svog4tuU/gk8QnX9c3o/TBB8l7e8qBWaMF58+f5feJct96COYrSdqUug9ApNHR6lgU8ggFZpjq6F2meljBau2CQ0u2OXU+qVAzXBGH3OJwhRszhZFi3aBFz33oYzY7Oxnn/L3UjAlgfBjiBYAQI3paeBoBWwTqcrEzDM1iQ8Vns0xx3ysyVSvxiJEviZFCJmEFMnyIau3X+/RtzXipMBgzPLWfxD1VkKILmU0b6uO0EhLj1tYVelLrlUxs/8zfFP1bO9lyPN93nRLNA6evWnj6RsGM3wVJGnrqAniuKVQKCW8ds0zLfpXPv9LVX33R5QUnbInbny6/lsGzIcbMwWtWXFLZSOD1Whr+mxKh8Q7PoDUpr01s028z/2kvSITljosKni4Oadklew9lOEVRMv6A2kq/yyBa1z1XgCnroBoWMgywHIvwxuSdc5E/8EpMYMUwCcJxSk/JzIP8y6sF2B5tSsH+lprEvAoNpFdW0kL/20y6ZPsZVgpoGJ/cKcTcjDxbqUxYtoxccwhxp1VwFrjoiODMbnOoJ56tkhBL8uiP5EP4ivJGHwbLuI2RJJ5ICUYx2VL7wkI8IVTiqzY7wQo1WCzloghR1H0MD2SRA92yh6Sb9lI+WdaHBVb9ECXWwylg5yu9/HGmT4a0cgyEM4qylCfuGdpDCYizBVlS9Ug22qcMRVcNr33y3h4Za7XwqLGh5sXXGrAbGS0w/cQDA1X7cuGjv0Dl2m5P9FW//bOCsZNtSeth5y7xKt1cuHTrPVNdlcbg3KIyjc6frV89gmJEZvIw== X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b39bdff6-ed38-4a8b-7be6-08dc68b6559b X-MS-Exchange-CrossTenant-AuthSource: SL2P216MB1246.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2024 01:39:11.1101 (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: gQFBL71WBWljVz/IkDdFLdsxsix/xJr+Tn0cIvrwNwBSTl5UG44d8vn/sdmswrGcADdmHzqyml65u65j67UFmp50n42Qah8ZRK4/YJPwudg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB1324 X-LSpam-Score: -2.6 (--) X-LSpam-Report: No, score=-2.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_MISSING=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no |
Series |
Add features to an existing driver
|
|
Commit Message
Nas Chung
April 30, 2024, 1:39 a.m. UTC
From: "Jackson.lee" <jackson.lee@chipsnmedia.com> Add support for the YUV422P, NV16, NV61, YUV422M, NV16M, NV61M raw pixel-formats to the Wave5 encoder. All these formats have a chroma subsampling ratio of 4:2:2 and therefore require a new image size calculation as the driver previously only handled a ratio of 4:2:0. Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com> --- .../chips-media/wave5/wave5-vpu-enc.c | 59 +++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-)
Comments
Hi Nas, Le mardi 30 avril 2024 à 10:39 +0900, Nas Chung a écrit : > From: "Jackson.lee" <jackson.lee@chipsnmedia.com> > > Add support for the YUV422P, NV16, NV61, YUV422M, NV16M, NV61M raw pixel-formats to the Wave5 encoder. > All these formats have a chroma subsampling ratio of 4:2:2 and therefore require a new image size calculation as the driver previously only handled a ratio of 4:2:0. Same here, run check-patch, before sending your next version, it should tell you that this message is not indented properly. > > Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com> > Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com> > --- > .../chips-media/wave5/wave5-vpu-enc.c | 59 +++++++++++++++++-- > 1 file changed, 54 insertions(+), 5 deletions(-) > > 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 75d230df45f6..0d6bec4e28d1 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > @@ -66,6 +66,24 @@ static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = { > .v4l2_pix_fmt = V4L2_PIX_FMT_NV21M, > .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], > }, > + { > + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422P, > + }, > + { > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16, > + }, > + { > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61, > + }, > + { > + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422M, > + }, > + { > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16M, > + }, > + { > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, > + }, > } > }; > > @@ -109,13 +127,30 @@ static int start_encode(struct vpu_instance *inst, u32 *fail_res) > struct vb2_v4l2_buffer *dst_buf; > struct frame_buffer frame_buf; > struct enc_param pic_param; > - u32 stride = ALIGN(inst->dst_fmt.width, 32); > - u32 luma_size = (stride * inst->dst_fmt.height); > - u32 chroma_size = ((stride / 2) * (inst->dst_fmt.height / 2)); > + u32 stride = inst->src_fmt.plane_fmt[0].bytesperline; > + u32 luma_size = (stride * inst->src_fmt.height); > + u32 chroma_size = 0; > > memset(&pic_param, 0, sizeof(struct enc_param)); > memset(&frame_buf, 0, sizeof(struct frame_buffer)); > > + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420M) > + chroma_size = luma_size / 4; > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) > + chroma_size = luma_size / 2; > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M) > + chroma_size = luma_size / 2; > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) > + chroma_size = luma_size; > + I'm still unhappy to see all the supported format having to be listed again here, this is error prone and a maintenance burden. In general, what I would do is (and this is simplified to the subset of format we support): // might want to bug on that the info->pixel_encoding == V4L2_PIXEL_ENC_YUV // if you believe some RGB or bayer formats could be added in the future and // want the devs to notice. I've ignored fractional bytes-per-pixel values as // we don't use that, but another bugon if there is a chance the firmware // will support more complex packing. info = v4l2_format_info(inst->src_fmt.pixelformat); if (info->mem_planes == 1) { luma_size = stride * inst->dst_fmt.height; chroma_size = luma_size * info->bpp[1] / (info->hdiv * info->vdiv) } else { luma_size = inst->src_fmt.plane_fmt[0].sizeimage; chroma_size = inst->src_fmt.plane_fmt[1].sizeimage; } Or something similar that works ... (untested code above) > dst_buf = v4l2_m2m_next_dst_buf(m2m_ctx); > if (!dst_buf) { > dev_dbg(inst->dev->dev, "%s: No destination buffer found\n", __func__); > @@ -501,11 +536,15 @@ static int wave5_vpu_enc_s_fmt_out(struct file *file, void *fh, struct v4l2_form > } > > if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || > - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M) { > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M) { > inst->cbcr_interleave = true; > inst->nv21 = false; > } else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || > - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) { > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) { > inst->cbcr_interleave = true; This can be simplified to (avoiding enumerating formats): inst->cbcr_interleave = (info->comp_planes == 2) ? true : false; > inst->nv21 = true; Could be something to add into the info in the future, but for now this is list of formats is needed. Would be a lot more efficient with a switch, but not a hot path so not making this mandatory. > } else { > @@ -1102,6 +1141,16 @@ static void wave5_set_enc_openparam(struct enc_open_param *open_param, > u32 num_ctu_row = ALIGN(inst->dst_fmt.height, 64) / 64; > u32 num_mb_row = ALIGN(inst->dst_fmt.height, 16) / 16; > > + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) > + open_param->src_format = FORMAT_422; > + else > + open_param->src_format = FORMAT_420; Can be simplified to: if (info->hdiv == 2 && info->vdiv == 2) open_param->src_format = FORMAT_422; else if (info->hdiv == 2 && info->vdiv == 1) open_param->src_format = FORMAT_420; > + > open_param->wave_param.gop_preset_idx = PRESET_IDX_IPP_SINGLE; > open_param->wave_param.hvs_qp_scale = 2; > open_param->wave_param.hvs_max_delta_qp = 10; regards, Nicolas
Hi Nicolas > -----Original Message----- > From: Nicolas Dufresne <nicolas@ndufresne.ca> > Sent: Thursday, May 2, 2024 4:46 AM > To: Nas Chung <nas.chung@chipsnmedia.com>; mchehab@kernel.org; > sebastian.fricke@collabora.com > Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; > hverkuil@xs4all.nl; lafley.kim <lafley.kim@chipsnmedia.com>; b-brnich@ti.com; > jackson.lee@chipnsmedia.com; jackson.lee <jackson.lee@chipsnmedia.com> > Subject: Re: [PATCH v3 4/4] media: chips-media: wave5: Support YUV422 raw > pixel-formats on the encoder. > > Hi Nas, > > Le mardi 30 avril 2024 à 10:39 +0900, Nas Chung a écrit : > > From: "Jackson.lee" <jackson.lee@chipsnmedia.com> > > > > Add support for the YUV422P, NV16, NV61, YUV422M, NV16M, NV61M raw pixel- > formats to the Wave5 encoder. > > All these formats have a chroma subsampling ratio of 4:2:2 and therefore > require a new image size calculation as the driver previously only handled a > ratio of 4:2:0. > > Same here, run check-patch, before sending your next version, it should tell > you that this message is not indented properly. > > > > > Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com> > > Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com> > > --- > > .../chips-media/wave5/wave5-vpu-enc.c | 59 +++++++++++++++++-- > > 1 file changed, 54 insertions(+), 5 deletions(-) > > > > 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 75d230df45f6..0d6bec4e28d1 100644 > > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > > @@ -66,6 +66,24 @@ static const struct vpu_format > enc_fmt_list[FMT_TYPES][MAX_FMTS] = { > > .v4l2_pix_fmt = V4L2_PIX_FMT_NV21M, > > .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], > > }, > > + { > > + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422P, > > + }, > > + { > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16, > > + }, > > + { > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61, > > + }, > > + { > > + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422M, > > + }, > > + { > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16M, > > + }, > > + { > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, > > + }, > > } > > }; > > > > @@ -109,13 +127,30 @@ static int start_encode(struct vpu_instance *inst, > u32 *fail_res) > > struct vb2_v4l2_buffer *dst_buf; > > struct frame_buffer frame_buf; > > struct enc_param pic_param; > > - u32 stride = ALIGN(inst->dst_fmt.width, 32); > > - u32 luma_size = (stride * inst->dst_fmt.height); > > - u32 chroma_size = ((stride / 2) * (inst->dst_fmt.height / 2)); > > + u32 stride = inst->src_fmt.plane_fmt[0].bytesperline; > > + u32 luma_size = (stride * inst->src_fmt.height); > > + u32 chroma_size = 0; > > > > memset(&pic_param, 0, sizeof(struct enc_param)); > > memset(&frame_buf, 0, sizeof(struct frame_buffer)); > > > > + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420M) > > + chroma_size = luma_size / 4; > > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) > > + chroma_size = luma_size / 2; > > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M) > > + chroma_size = luma_size / 2; > > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) > > + chroma_size = luma_size; > > + > > I'm still unhappy to see all the supported format having to be listed again > here, this is error prone and a maintenance burden. In general, what I would > do is (and this is simplified to the subset of format we support): > > // might want to bug on that the info->pixel_encoding == V4L2_PIXEL_ENC_YUV > // if you believe some RGB or bayer formats could be added in the future and > // want the devs to notice. I've ignored fractional bytes-per-pixel values as > // we don't use that, but another bugon if there is a chance the firmware // > will support more complex packing. > > info = v4l2_format_info(inst->src_fmt.pixelformat); > if (info->mem_planes == 1) { > luma_size = stride * inst->dst_fmt.height; > chroma_size = luma_size * info->bpp[1] / (info->hdiv * info->vdiv) } > else { > luma_size = inst->src_fmt.plane_fmt[0].sizeimage; > chroma_size = inst->src_fmt.plane_fmt[1].sizeimage; > } > > Or something similar that works ... (untested code above) > > > dst_buf = v4l2_m2m_next_dst_buf(m2m_ctx); > > if (!dst_buf) { > > dev_dbg(inst->dev->dev, "%s: No destination buffer found\n", > > __func__); @@ -501,11 +536,15 @@ static int wave5_vpu_enc_s_fmt_out(struct > file *file, void *fh, struct v4l2_form > > } > > > > if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || > > - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M) { > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M) { > > inst->cbcr_interleave = true; > > inst->nv21 = false; > > } else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || > > - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) { > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) { > > inst->cbcr_interleave = true; > > This can be simplified to (avoiding enumerating formats): > > inst->cbcr_interleave = (info->comp_planes == 2) ? true : false; > > > inst->nv21 = true; > > Could be something to add into the info in the future, but for now this is > list of formats is needed. Would be a lot more efficient with a switch, but > not a hot path so not making this mandatory. > Switch(pixel_format) { Case V4L2_PIX_FMT_NV21: Case V4L2_PIX_FMT_NV21M: Case V4L2_PIX_FMT_NV61: Case V4L2_PIX_FMT_NV61M: inst->nv21 = true; Default: inst->nv21 = false; } What you are saying is that to set the nv21 variable(using switch) ? > > } else { > > @@ -1102,6 +1141,16 @@ static void wave5_set_enc_openparam(struct > enc_open_param *open_param, > > u32 num_ctu_row = ALIGN(inst->dst_fmt.height, 64) / 64; > > u32 num_mb_row = ALIGN(inst->dst_fmt.height, 16) / 16; > > > > + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) > > + open_param->src_format = FORMAT_422; > > + else > > + open_param->src_format = FORMAT_420; > > Can be simplified to: > > if (info->hdiv == 2 && info->vdiv == 2) > open_param->src_format = FORMAT_422; > else if (info->hdiv == 2 && info->vdiv == 1) > open_param->src_format = FORMAT_420; > I think the above codes should be changed like below.(we should swap the values of the src_format variable.) if (info->hdiv == 2 && info->vdiv == 2) open_param->src_format = FORMAT_420; else if (info->hdiv == 2 && info->vdiv == 1) open_param->src_format = FORMAT_422; > > + > > open_param->wave_param.gop_preset_idx = PRESET_IDX_IPP_SINGLE; > > open_param->wave_param.hvs_qp_scale = 2; > > open_param->wave_param.hvs_max_delta_qp = 10; > > regards, > Nicolas
Hi, sorry for the delay Le jeudi 02 mai 2024 à 04:55 +0000, jackson.lee a écrit : > Hi Nicolas > > > -----Original Message----- > > From: Nicolas Dufresne <nicolas@ndufresne.ca> > > Sent: Thursday, May 2, 2024 4:46 AM > > To: Nas Chung <nas.chung@chipsnmedia.com>; mchehab@kernel.org; > > sebastian.fricke@collabora.com > > Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; > > hverkuil@xs4all.nl; lafley.kim <lafley.kim@chipsnmedia.com>; b-brnich@ti.com; > > jackson.lee@chipnsmedia.com; jackson.lee <jackson.lee@chipsnmedia.com> > > Subject: Re: [PATCH v3 4/4] media: chips-media: wave5: Support YUV422 raw > > pixel-formats on the encoder. > > > > Hi Nas, > > > > Le mardi 30 avril 2024 à 10:39 +0900, Nas Chung a écrit : > > > From: "Jackson.lee" <jackson.lee@chipsnmedia.com> > > > > > > Add support for the YUV422P, NV16, NV61, YUV422M, NV16M, NV61M raw pixel- > > formats to the Wave5 encoder. > > > All these formats have a chroma subsampling ratio of 4:2:2 and therefore > > require a new image size calculation as the driver previously only handled a > > ratio of 4:2:0. > > > > Same here, run check-patch, before sending your next version, it should tell > > you that this message is not indented properly. > > > > > > > > Signed-off-by: Jackson.lee <jackson.lee@chipsnmedia.com> > > > Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com> > > > --- > > > .../chips-media/wave5/wave5-vpu-enc.c | 59 +++++++++++++++++-- > > > 1 file changed, 54 insertions(+), 5 deletions(-) > > > > > > 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 75d230df45f6..0d6bec4e28d1 100644 > > > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > > > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > > > @@ -66,6 +66,24 @@ static const struct vpu_format > > enc_fmt_list[FMT_TYPES][MAX_FMTS] = { > > > .v4l2_pix_fmt = V4L2_PIX_FMT_NV21M, > > > .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], > > > }, > > > + { > > > + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422P, > > > + }, > > > + { > > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16, > > > + }, > > > + { > > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61, > > > + }, > > > + { > > > + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422M, > > > + }, > > > + { > > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16M, > > > + }, > > > + { > > > + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, > > > + }, > > > } > > > }; > > > > > > @@ -109,13 +127,30 @@ static int start_encode(struct vpu_instance *inst, > > u32 *fail_res) > > > struct vb2_v4l2_buffer *dst_buf; > > > struct frame_buffer frame_buf; > > > struct enc_param pic_param; > > > - u32 stride = ALIGN(inst->dst_fmt.width, 32); > > > - u32 luma_size = (stride * inst->dst_fmt.height); > > > - u32 chroma_size = ((stride / 2) * (inst->dst_fmt.height / 2)); > > > + u32 stride = inst->src_fmt.plane_fmt[0].bytesperline; > > > + u32 luma_size = (stride * inst->src_fmt.height); > > > + u32 chroma_size = 0; > > > > > > memset(&pic_param, 0, sizeof(struct enc_param)); > > > memset(&frame_buf, 0, sizeof(struct frame_buffer)); > > > > > > + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420M) > > > + chroma_size = luma_size / 4; > > > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) > > > + chroma_size = luma_size / 2; > > > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M) > > > + chroma_size = luma_size / 2; > > > + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) > > > + chroma_size = luma_size; > > > + > > > > I'm still unhappy to see all the supported format having to be listed again > > here, this is error prone and a maintenance burden. In general, what I would > > do is (and this is simplified to the subset of format we support): > > > > // might want to bug on that the info->pixel_encoding == V4L2_PIXEL_ENC_YUV > > // if you believe some RGB or bayer formats could be added in the future and > > // want the devs to notice. I've ignored fractional bytes-per-pixel values as > > // we don't use that, but another bugon if there is a chance the firmware // > > will support more complex packing. > > > > info = v4l2_format_info(inst->src_fmt.pixelformat); > > if (info->mem_planes == 1) { > > luma_size = stride * inst->dst_fmt.height; > > chroma_size = luma_size * info->bpp[1] / (info->hdiv * info->vdiv) } > > else { > > luma_size = inst->src_fmt.plane_fmt[0].sizeimage; > > chroma_size = inst->src_fmt.plane_fmt[1].sizeimage; > > } > > > > Or something similar that works ... (untested code above) > > > > > dst_buf = v4l2_m2m_next_dst_buf(m2m_ctx); > > > if (!dst_buf) { > > > dev_dbg(inst->dev->dev, "%s: No destination buffer found\n", > > > __func__); @@ -501,11 +536,15 @@ static int wave5_vpu_enc_s_fmt_out(struct > > file *file, void *fh, struct v4l2_form > > > } > > > > > > if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || > > > - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M) { > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M) { > > > inst->cbcr_interleave = true; > > > inst->nv21 = false; > > > } else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || > > > - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) { > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) { > > > inst->cbcr_interleave = true; > > > > This can be simplified to (avoiding enumerating formats): > > > > inst->cbcr_interleave = (info->comp_planes == 2) ? true : false; > > > > > inst->nv21 = true; > > > > Could be something to add into the info in the future, but for now this is > > list of formats is needed. Would be a lot more efficient with a switch, but > > not a hot path so not making this mandatory. > > > > Switch(pixel_format) { > Case V4L2_PIX_FMT_NV21: > Case V4L2_PIX_FMT_NV21M: > Case V4L2_PIX_FMT_NV61: > Case V4L2_PIX_FMT_NV61M: > inst->nv21 = true; > Default: > inst->nv21 = false; > } > > What you are saying is that to set the nv21 variable(using switch) ? Yes, it seems easier to maintain to me. > > > > > > } else { > > > @@ -1102,6 +1141,16 @@ static void wave5_set_enc_openparam(struct > > enc_open_param *open_param, > > > u32 num_ctu_row = ALIGN(inst->dst_fmt.height, 64) / 64; > > > u32 num_mb_row = ALIGN(inst->dst_fmt.height, 16) / 16; > > > > > > + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || > > > + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) > > > + open_param->src_format = FORMAT_422; > > > + else > > > + open_param->src_format = FORMAT_420; > > > > Can be simplified to: > > > > if (info->hdiv == 2 && info->vdiv == 2) > > open_param->src_format = FORMAT_422; > > else if (info->hdiv == 2 && info->vdiv == 1) > > open_param->src_format = FORMAT_420; > > > > I think the above codes should be changed like below.(we should swap the values of the src_format variable.) > > if (info->hdiv == 2 && info->vdiv == 2) > open_param->src_format = FORMAT_420; > else if (info->hdiv == 2 && info->vdiv == 1) > open_param->src_format = FORMAT_422; > Good catch. > > > > + > > > open_param->wave_param.gop_preset_idx = PRESET_IDX_IPP_SINGLE; > > > open_param->wave_param.hvs_qp_scale = 2; > > > open_param->wave_param.hvs_max_delta_qp = 10; > > > > regards, > > Nicolas
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 75d230df45f6..0d6bec4e28d1 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -66,6 +66,24 @@ static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = { .v4l2_pix_fmt = V4L2_PIX_FMT_NV21M, .v4l2_frmsize = &enc_frmsize[VPU_FMT_TYPE_RAW], }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422P, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422M, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16M, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, + }, } }; @@ -109,13 +127,30 @@ static int start_encode(struct vpu_instance *inst, u32 *fail_res) struct vb2_v4l2_buffer *dst_buf; struct frame_buffer frame_buf; struct enc_param pic_param; - u32 stride = ALIGN(inst->dst_fmt.width, 32); - u32 luma_size = (stride * inst->dst_fmt.height); - u32 chroma_size = ((stride / 2) * (inst->dst_fmt.height / 2)); + u32 stride = inst->src_fmt.plane_fmt[0].bytesperline; + u32 luma_size = (stride * inst->src_fmt.height); + u32 chroma_size = 0; memset(&pic_param, 0, sizeof(struct enc_param)); memset(&frame_buf, 0, sizeof(struct frame_buffer)); + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV420M) + chroma_size = luma_size / 4; + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) + chroma_size = luma_size / 2; + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M) + chroma_size = luma_size / 2; + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) + chroma_size = luma_size; + dst_buf = v4l2_m2m_next_dst_buf(m2m_ctx); if (!dst_buf) { dev_dbg(inst->dev->dev, "%s: No destination buffer found\n", __func__); @@ -501,11 +536,15 @@ static int wave5_vpu_enc_s_fmt_out(struct file *file, void *fh, struct v4l2_form } if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12 || - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M) { + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV12M || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M) { inst->cbcr_interleave = true; inst->nv21 = false; } else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21 || - inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M) { + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV21M || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) { inst->cbcr_interleave = true; inst->nv21 = true; } else { @@ -1102,6 +1141,16 @@ static void wave5_set_enc_openparam(struct enc_open_param *open_param, u32 num_ctu_row = ALIGN(inst->dst_fmt.height, 64) / 64; u32 num_mb_row = ALIGN(inst->dst_fmt.height, 16) / 16; + if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422M || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV16M || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61M) + open_param->src_format = FORMAT_422; + else + open_param->src_format = FORMAT_420; + open_param->wave_param.gop_preset_idx = PRESET_IDX_IPP_SINGLE; open_param->wave_param.hvs_qp_scale = 2; open_param->wave_param.hvs_max_delta_qp = 10;