From patchwork Wed Jan 31 01:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 98880 X-Patchwork-Delegate: sebastian.fricke@collabora.com Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rUzRS-0006ki-1a for patchwork@linuxtv.org; Wed, 31 Jan 2024 01:31:10 +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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A156F2831F9 for ; Wed, 31 Jan 2024 01:31:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A439139B; Wed, 31 Jan 2024 01:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="GkQCVtfK" X-Original-To: linux-media@vger.kernel.org Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2119.outbound.protection.outlook.com [40.107.129.119]) (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 6537AEA4; Wed, 31 Jan 2024 01:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.129.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664660; cv=fail; b=BtxIo94PzR2eR08ZkAgx0I4bNp34tpRM0P3hcDGKAK3GvZI28YM7jBfSHs5PtnhPuGZPSVz2iwxk6jwtK5NzDVDcnP/sTobQLJK5Z4hBEbVcpqGciZ7G9GHot1u2eRgDd9g0IQYWATtRNF/gkGSZPeEQI5/HVNHAGrWZhk1MSlU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664660; c=relaxed/simple; bh=JIhvGfNywtwdrHhM1QNneERXxrfgWpuWXUxJ8ff+Y5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=p06xjCU9M1NDJtDhtBWR0M5TzHG/9dHL49HwebxzIGM6xwzPqBfFBmahPW3zunk8h8xG4vKlNGhYbysaIIpmqkVKVNGA6nR8RFLRkQaf3zBzHZXDK43MCineXi9DGnlGv6Lq4WdbwriMeATGz7Ctx3N/T4lwPyCyxyicTGTkvDk= 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.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b=GkQCVtfK; arc=fail smtp.client-ip=40.107.129.119 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=CuyQHa0mD9t7e+jABp2sZcWRAtrDiJVkxTr9SnfUsoGSDI2qzB4a6j91CjtbEzOTFl4/IYAa+KUQGdQlxSQbvjq2R2mhxtZNFyFiioEN/OXV2POvYGEytGo5wFO0/C0eFYAIBUYIdli+HswigckE8gbuF49hXb9Jc/GJfs8nY1P2Nzsl1ri779a/xnCtbR60vRjMblGXP17JZv7JBZv/SdR6Viw9NT9VvFLcbLa5grL82LB26AzxzOq7JHCQFTk34AHM5CV2YqyLYzPymY0BXYgwO0mKev1eqCq7yYdDoWMckOO/b+w9v7smRbeaACDppNW7TSN4fWIsfsONFhHzpg== 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=GJnQ/OS1RAiuGjD1AtU31iFg23nF99Sk/pxQkcLYO6Q=; b=gipHeMXCjQ9z2/JkImQhsnC/6UBqccPbvi+UUtt6o+qApr1X99Hlxv30FdUt42VB9V8G+9jWI70jwMlU0E65W/5Z3zW+YWXWmYmiSfXEQ3a3JFjG2JqndZ8mIoGUtI0pk3xl2/sE0zqXvP2Cg9As5USzIPZpIRdjRaf/qdnrSJvc0XBPTHAH0W4BiGweRMHb22cna2PoItYJdNxBfQ8DM2YVjx2EDi5ITDCw+Pdix1q/Xm6/W1YNpqwn7ko1y4YBUxBfZTmY6k1b/S7dh77IXhFRqQDvWlGjC0YnsNOcAodEzws3X5ZO3cNXEiLHwPgS2f0SJYWF1dzThKWz8/uWkw== 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.onmicrosoft.com; s=selector2-chipsnmedia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GJnQ/OS1RAiuGjD1AtU31iFg23nF99Sk/pxQkcLYO6Q=; b=GkQCVtfKpaeh8rRt9isWENCZsC+Z0N92y86aFsVqRlnmGThMjywvazNkEk0O5GUjh1k5P2oZ9iI2IvAyi3in0tf7h0Sje+I+QqOWFeHt8jUoYaySvPnAPcC/hA8h6vdwcSJMqYowsxzHv2sp2OuvOZ4EDG5NWPRQxikBKjtH6DE= 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 PU4P216MB2229.KORP216.PROD.OUTLOOK.COM (2603:1096:301:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Wed, 31 Jan 2024 01:30:54 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c%4]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 01:30:54 +0000 From: "jackson.lee" To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, nas.chung@chipsnmedia.com Cc: jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com Subject: [RESEND PATCH v0 1/5] wave5 : Support yuv422 input format for encoder. Date: Wed, 31 Jan 2024 10:30:42 +0900 Message-Id: <20240131013046.15687-2-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> References: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0224.KORP216.PROD.OUTLOOK.COM (2603:1096:101:18::12) 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_|PU4P216MB2229:EE_ X-MS-Office365-Filtering-Correlation-Id: 209c073e-a94c-4d74-a1d5-08dc21fc4470 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VShc+megklDNcQ6MCBPQ1Jq4YyiuX8A4aM8qnVTjyB8F4H09IjyOs/7vfB/UwSmfLv1/xdS/K/0lflsdYKgd6SrQwfzsx7M+FJluDaQ0GPJGAACd/GQzGbxHV79KTtAM7xFK9vxY4n2dzz1iVAvHpbq1YZ10ngUCvg5ySOVYpyxiboxWk9kXMOBrsimPwqRRqtVJSOUu7KQaUM89x3gurXfDj4Ltnmom5gYhwbUxqPuTNx5BnHTG4QsvFCfZdbZtFrWlKErix/npge1lvPBlZraAhJGtsVz+/CBRjB7JYPACcI5AjLpP/wqwxcfUuZwlB8YPyqv2eOhpg3rt0omKB4PIVf6KLdZpjIx0hOq7OFD/uar70fr94D32pg4qLYM998qcSyAQO0YxqDK3+uGJg8lsAMZa7W3QATs5fODAn7o0kdGN1+uVu06sCI9mn1ZxXtRqMXcnv7MRPyelTfu96eUFEzkUx6AWEyge6dzNQueUO4p0gL7UoHFJj/C82/T/N6f+vnSqTe2cD96YWgrxyA694/Xm/zVU7Bwtm7Ba4fAdhYqOw6pMRxXGRvHNzlkrOgA66oPRiM8g67ZZm4HhOkv/0+9h0YaL/HkdyKXVbh7ff+Sob4jddeP840RM7ksQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SE1P216MB1303.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(39850400004)(396003)(346002)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(83380400001)(6666004)(52116002)(2616005)(6506007)(316002)(6486002)(478600001)(86362001)(6636002)(66946007)(66556008)(66476007)(41300700001)(26005)(6512007)(1076003)(5660300002)(8936002)(4326008)(8676002)(38100700002)(2906002)(38350700005)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z9dahGO0ZmKEMCdAndcoWPlDV/y+cc63VtbKf8Nk9EcgJ+82nKgRSH85CMENzJM+2anuMJrnS346e0CCCIG8BLocLLLSCBTH52n9XBvwYiSHTezXt4mYj5AwOva91kda4oYOqXQIyDmya/F8oP/qG0JXNLuPFydBWrRt5+nfhvQiGflm2vF6YAmvTZa+whjLUzjKr57MRBJGztG2tVcddw+6wYE7tf+OTZ2l08fjSunjsN/3FWB9KbhwblhbQ/VffesJOmNRQv8bmOZOHW0Bj1bTCgCrPltzH9M15IZwKtwJRm3q8mKOCoiGglnnqGsopBI5SvQ+PNYh2QVUm+ofxwNaG2wY25PoHVk9dzNNjLAyeHgT9uB/FQu3yRi3iBx3e6UqAoVtl32Gj1I3hFRVDWuYRTvDBj1fivvUIWV1nNXzFNCZEnYVCmav+Abd4mjMZb288pQdyogf3NNNBPLGW9ZPa9CN7dK5X9gQw3mfMBpUnRZF4SoLLv4+Xf+ArLcrYVN+zVVAed/LZYT7M6NB6mivR76b3I77n3qcXU06DDSwM1L57QHygAJ1S8ixMAlli9PqoWjn3Sv+dt98uLO/whhsySepfQguiabVSIXSc5g9ilh9yU1NuFErrWSdd+huwnYhFLKht4MTsR06Ra896kARmlTRX6O+mRFbCUYFeMzKYfynZv55RntlJUpwBjzHbtOWdKU1t/OPgi/xJVXb72O9BXUwG14qu2Muv9eBsZJCb7R4MuU2jpi4LgcpXmC2k3IolVly3026o6YHqFoHCsMOyDTFh8LX9yJJHQhsNTwLA5aRLcGM98rm4YmgcH9wfzj9IqfR2JxrBaw9krseYW9HYAfM1wqLxew1dkoWQeE+LuRe+ZrGql6SGuKz5L26FD+lZwYKTskzM3a3/pYSsvK9Gc2/rJPcsyVfzBv4LUJzru/O+vFisPJRNBh5TnVdm5YMwXp0L0TTtjCfDOxQcBKiRG0N0NkKp5GKpRWqEvAdfCZcm7mqVfQJ9CjF3rq5f/gd4MxJ+eRjO2Rfi7Rq9xDPzaJM0qW5NR3HcimtqV7qyk24qyRLykkeVG/A97My5+Hjc+KESLFImdYuwWPm/TTuQeyxRKyjZZunKaJ6AYJ5hG2gSegxS10IhF4CWHlX7pGm8hPw9jmG/sjhdYmuNAx8ZuYuY8VMUFhywfp4NNUQjnotoSwLeH5t3pl8AhZjYlZDcksiRCzT8NrvZ8wiH7GvSeLoKImJ+CsK44r08d48u7M/cg+qAqdY3mDAmKIfWvlun9hxUnAqeefz8Qao+PHYH++LoxAjl7OmwU3Fvx6KXJDUtWY3DZwSTsnXRP89t2Zan81zpOfg0kTeTaJx6MdI9KNCn6PI9oqyWnxcxtTHhfrK2MaR6V1pXlLCJ2VfC9I3Zo/XNUmhC54h2VXmzRpuLlpyplSMh1iiKYkllYfiNWST/A4EhfmbUkazJIlgiqVDN06BJ5sFFr0jygcgjXL/kx0Skh033CvEmGrD9NfcNs4G8lMoALxPkasQsMwQfYAxBF8rqx3wyDTZb4dDucUTGd+zFhMPJ6ttHPxOQDBD3b/YWl5o/ztDL69sUurbj4UiZlEKCXBxMaK0V/Yag3VUn0XWZKKst8oJ4JjpC1Q= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 209c073e-a94c-4d74-a1d5-08dc21fc4470 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 01:30:54.4349 (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: sf/durbcPothbmshjhi99DfB1eKrmt09QkH7gnCtk7tJPfy5F5neWy0LCBetLSFbr6DawOFQXYzt+gSN9nUXf7rfJuKD+EHP1OFnuIsa7Q8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB2229 X-LSpam-Score: -2.9 (--) X-LSpam-Report: No, score=-2.9 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DMARC_MISSING=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Encoder supports the following formats. YUV422P, NV16, NV61, NV16M, NV61M Signed-off-by: Jackson Lee Signed-off-by: Nas Chung --- .../chips-media/wave5/wave5-vpu-enc.c | 79 ++++++++++++++++++- 1 file changed, 76 insertions(+), 3 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 f29cfa3af94a..0cb5bfb67258 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -70,6 +70,41 @@ static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = { .max_height = W5_MAX_ENC_PIC_HEIGHT, .min_height = W5_MIN_ENC_PIC_HEIGHT, }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_YUV422P, + .max_width = W5_MAX_ENC_PIC_WIDTH, + .min_width = W5_MIN_ENC_PIC_WIDTH, + .max_height = W5_MAX_ENC_PIC_HEIGHT, + .min_height = W5_MIN_ENC_PIC_HEIGHT, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16, + .max_width = W5_MAX_ENC_PIC_WIDTH, + .min_width = W5_MIN_ENC_PIC_WIDTH, + .max_height = W5_MAX_ENC_PIC_HEIGHT, + .min_height = W5_MIN_ENC_PIC_HEIGHT, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61, + .max_width = W5_MAX_ENC_PIC_WIDTH, + .min_width = W5_MIN_ENC_PIC_WIDTH, + .max_height = W5_MAX_ENC_PIC_HEIGHT, + .min_height = W5_MIN_ENC_PIC_HEIGHT, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV16M, + .max_width = W5_MAX_ENC_PIC_WIDTH, + .min_width = W5_MIN_ENC_PIC_WIDTH, + .max_height = W5_MAX_ENC_PIC_HEIGHT, + .min_height = W5_MIN_ENC_PIC_HEIGHT, + }, + { + .v4l2_pix_fmt = V4L2_PIX_FMT_NV61M, + .max_width = W5_MAX_ENC_PIC_WIDTH, + .min_width = W5_MIN_ENC_PIC_WIDTH, + .max_height = W5_MAX_ENC_PIC_HEIGHT, + .min_height = W5_MIN_ENC_PIC_HEIGHT, + }, } }; @@ -136,6 +171,23 @@ static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); pix_mp->plane_fmt[1].sizeimage = round_up(width, 32) * height / 2; break; + case V4L2_PIX_FMT_YUV422P: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_NV61: + pix_mp->width = width; + pix_mp->height = height; + pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); + pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height * 2; + break; + case V4L2_PIX_FMT_NV16M: + case V4L2_PIX_FMT_NV61M: + pix_mp->width = width; + pix_mp->height = height; + pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); + pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height; + pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); + pix_mp->plane_fmt[1].sizeimage = round_up(width, 32) * height; + break; default: pix_mp->width = width; pix_mp->height = height; @@ -155,11 +207,19 @@ static int start_encode(struct vpu_instance *inst, u32 *fail_res) 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 chroma_size; 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 = ((stride / 2) * (inst->dst_fmt.height / 2)); + else if (inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P) + chroma_size = ((stride) * (inst->dst_fmt.height / 2)); + else + chroma_size = 0; + dst_buf = v4l2_m2m_next_dst_buf(m2m_ctx); if (!dst_buf) { dev_dbg(inst->dev->dev, "%s: No destination buffer found\n", __func__); @@ -550,11 +610,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 { @@ -1132,6 +1196,15 @@ 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_NV16 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_NV61 || + inst->src_fmt.pixelformat == V4L2_PIX_FMT_YUV422P || + 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; From patchwork Wed Jan 31 01:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 98881 X-Patchwork-Delegate: sebastian.fricke@collabora.com Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rUzRp-0006nE-39 for patchwork@linuxtv.org; Wed, 31 Jan 2024 01:31:31 +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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E09BD1C234D8 for ; Wed, 31 Jan 2024 01:31:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 070F35226; Wed, 31 Jan 2024 01:31:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="iFx8xWxI" X-Original-To: linux-media@vger.kernel.org Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2119.outbound.protection.outlook.com [40.107.129.119]) (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 04FC41879; Wed, 31 Jan 2024 01:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.129.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664663; cv=fail; b=auXbSVWT7J0GKQmW4iZFTon4O3iBuOCcemd/4/amxhSy6T4U5bCSgG8Dbg7CEZdqTR/Pr+bK8aWBpDymshEumTSmmMgB3cFbFDbAfTxP2TGheQfaQOFC90iAgQRZCtRonp3tZcA3jEsDIYVhsdrGOnz5Qx+PNU7mRTc3lvoQmb8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664663; c=relaxed/simple; bh=X0yfwrshsp8er0k1tHV5dMdkLO32f9I0607hnZSGlLo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rR8E5WyKkWtzEDUNm+sU6x/BIEN15WJ14wgb4zwqyFK2agHSQuABVF7j9u1WjL5jSD87OeDxpOlNEH5BuouLehqXm1nl5Sccjn3ruy2nx1tpJY6YwcDTKlb1Kvqmlz+f4W5OgtQ/zeREPrmLQ3ZzvEJB4d3RP6kRR1ZPbN2AG6U= 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.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b=iFx8xWxI; arc=fail smtp.client-ip=40.107.129.119 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=fEWx3CMLP2bDQ/YrMcv6Jq9NZiHE0/t7yez2oH53870rluIPI9yoIrp1DKmV82QJICJ3eJiGWYojfb5xiiD00aaZaWRfbnGcLoztgQ9EkfHwkc7tyZcC+VA9sakSCDAz07SDUBtE15F6NAlDs/BYnB+SKoojWAn8GXl2gU4coMPNosEzRy9eevifavgydnGSXYNgl4tbR5eqBiKfmOPh6IYhbbeAlrwGrKAmtq+4ThQcLLvl6EseGhmdcC15/s2yepmoY1DXqK1YNjMqbqeuNSmfhgpK6RF/kQof9HQB8n+Kr0zrc6bSqazrnog0PailHEJgVTcT6JVZidt8cQUCXQ== 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=8utOFXxbLDEr2TD58UTmf2jV6OeoYkStHv59ULoeMxs=; b=kmjPDjb8f9y4Fm3sXWjr8V235MHPFP8GrcVFe5BxIvYG8P4k2DGwlmY81ejQrUCl13omHOWQe+V7WdrNVGK85F82MGYlWAf+WXxI9f01jL0g3oGaiye+BPIH7AILQfywSnFw9/LA5cns5UwxrjvdxVM8iAAw4ldwuomF/hppCrjtkeZrITrKay0/k+8CbzH25owCM+A3J1vdS0IXDSiTXaey9HHOswctOxN0+6JB7z9fhKeOBvC7J6BikuH0URDsRNlmgjETjwib/vX4gDPNxPLnOasg97fY+jHjDo0ai1WkuiJRDj5PlYcumo7KtJL6NQOnTjMvdNGf8bVcGvTDlw== 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.onmicrosoft.com; s=selector2-chipsnmedia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8utOFXxbLDEr2TD58UTmf2jV6OeoYkStHv59ULoeMxs=; b=iFx8xWxIvz+JQD8IdFN2PqejjbvLPbbDhK8ItSsUbSaPag/9bvk1z+DH89fPELGhPvnM7cyTFS8euSpaf88litkGkc0+ggq6tTkiKBA93LqDsudbrGxNtAur5NNK2zZb9vdb3xl7JbAyPb5RLMeelG0mFsujSXKSvHzb7TtFvyg= 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 PU4P216MB2229.KORP216.PROD.OUTLOOK.COM (2603:1096:301:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Wed, 31 Jan 2024 01:30:54 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c%4]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 01:30:54 +0000 From: "jackson.lee" To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, nas.chung@chipsnmedia.com Cc: jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com Subject: [RESEND PATCH v0 2/5] wave5: Support to prepend sps/pps to IDR frame. Date: Wed, 31 Jan 2024 10:30:43 +0900 Message-Id: <20240131013046.15687-3-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> References: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0224.KORP216.PROD.OUTLOOK.COM (2603:1096:101:18::12) 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_|PU4P216MB2229:EE_ X-MS-Office365-Filtering-Correlation-Id: 99554df8-d27b-4bd2-ff9c-08dc21fc44a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wyOe5ME378lDvSEFQJI2+98whXv8dk2n1i8BW7i8vGtB9Vuog9JQ263J1zY8io70SEl2nor2RXuYVnI2HFgBR9hLtiazWDkUjRvqqgUnK4PbKRHW63waxMOitVcpwW/ZBfM4Ee4o0JV2WeOVuPtVkybOr6L0mpASUPkTbBGhUZrDMzZLOMKr2nByiqw97meIsXNaYTZSwuJkRdsYf6RB5NyvA1/dqQH1SPd2CsDZIRFU3KMfIY4xADA847bA2IFyPeSPN1oyxuoWKdBnxOejmcJ2Fm6udAYImUp2dXin/9T6qBu5C2Jxjb855V9bGqJ/SqWT5cdTqeOyOeDphjaj8HjStl28fJqzA8CaE+9/Z7Mqx66vOO9Mm+98m+ipFk3T+OOCCXA06aa9UKLpdQmgQKKrtjDZfw4Rx2PT5k5sAhYXPl8EO6iYSYMjeMe92PseWKCX05Ch+3z3TGxgqDlrO42V9S1PjRGcYYOWrPNnaXpELj8OOBvvewppTSD4FkZBtkKy7ZdJpvWUcTklvKF+nzOfJz7aL3Zxt0AUl8MD4lVkYxJIt0vpdxACKRr9M9EpSyfn7kV3oyJ89rHV+zElLR8GipEtdoG9K3huF7Hvg1QBjdxB+JOS/Ud5I43yn5Q6 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SE1P216MB1303.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(39850400004)(396003)(346002)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(83380400001)(6666004)(52116002)(2616005)(6506007)(316002)(6486002)(478600001)(86362001)(6636002)(66946007)(66556008)(66476007)(41300700001)(26005)(6512007)(1076003)(5660300002)(8936002)(4326008)(8676002)(38100700002)(2906002)(38350700005)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qAFQ2ss0dpqH4puRJ5cIL7lDJBabns8nIgxs9OueCPpkMwOqcehCwNj7hRakSDYIvujxf2O8Ew0hM4IBNxXx8+YKT8V5WICQ5skNqUNDwTvRTWK8HdmlHGMwhFtW1jV1ZaqrkFopvSKA2Bqkty3gUCtQWtiSY5kXdLbGsHuFIz1/0kQ65TxlTlYCS6w5/+rPv8B0rz6m1s7WcehmYI+TJuqkLK5NpwkoAR3/mEs9uG7n5OMws/d+zgM1Ok2rzonjiae1ibghUjVXZy6DcO4hCT35oB9vbd4vt9/DvpAyxQyjt3vznZSAkjU59HhCRwpK4ZliIIydM1wDJb4P/kOQiYhdntWtUD85KxS/qpzOAFo6pZUrRD0y1GY848ktTMVR9SvDSCnLIqvgau/3SDAfUgXGYwauug4QeKV12iXihGXG3k2bsBcsddfG31r85xico9b8xJZzDWsm76PdYTbf9GRrv2cPQqgptVumfl6XbWOkvegn0/TBtG56nRwewQZ3iAQ8hX9wHts9V4yLUfZR6kx3LL4Ckunj0IS+bd1KF5zYWc6EQClTVmp1DMSXYkgG+osaFYKNfl5P3Q3FRfcypTlzvV9LagUPS7b5nNqv3jp6IZYtxy277EqEXr5w6P4zffWyzm31kGzro/jZmRlkF526UOOCenmUxJs0V/EGdiU0rrAai2HJnZmmLE99cC9t2WRqVSVdOEtGsAbLfyi+x8DmOzArnKIXsvZNd7VcYzdUYn+qNLnmoet/tOy2DTTgzuuJb7QbWLFGFLPkrDt/dX7lsqqRy9gk0Vov182Hi8F2RphV8IhxpY566zD2XGQ3B977XlRzjCUZlSxi7LtOuMtVgmrgii7vMhQHHXe8p3qPrTNJVzXytLLxYF1d+HXfLVvbfWaaI2pvwlh2cq710u+upqHbCAc2z5vpf2HB0qxQhYCySgO0pxRzjUBbFzFotleRPHr2KG+baH4+u3Be7okP00SU6mVx4+1qDGIbZtl+ioVFPnPOaMvank7Bk6uaVOu3c2CQPPCvSLVq11kUYuXB7FLDRIW4udiflwsRxFt2tA6UvOWo0NazysjGO8BzI+PXeSb1QtWMJ7NVOp/AD/iLnnE6uEtqg4GcLUv/UZFjoL9ofg3aD3Gx0FG7rkFPqdSXHQFRc5anHlK7wtoj4uOSOwwW2/grQplyxEprbUlVh03ZTFedgbex+z3+EbCR+qE/48UiJL8zsyPWQZhE06bIlP6vLFEZE8kfnXDLb4N/t4FCkYYj5usDMY6hnT4lJUfchiq4ZcEjGVIXPUh+MMwfhiiAVVlBZwuoAXHUxlKxwad8UAw5q3EDKJqnpuGopc7a/uQgtWJCKiWGq5ExbOOlaSuHutkP6l0TiC/QXyjgHFbfaNiT3nFgUxxYXn6iust8mV31XaLDXidXV/pWTY4cA1zNr5rHhteZGxTf5kRgMJ5eHaFYU88oFlN63CoIFZk770VDjRPtNhyugu1t7+dCFjbfGByUkAwI0v+16s7ybbvObju/yHXOfPrXiPwdanUnk7/N5W9Ly71bchax/ji7GiLMFUh83o79N4aX0wCvQD4KyCMltALOvQpEH9/cCEz+I5WHLhNWnfgl0uysQLYdySQQIBmwUYTjJEhaZVw= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99554df8-d27b-4bd2-ff9c-08dc21fc44a1 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 01:30:54.7621 (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: KUC7fQib/n6T5AQ8OR5NVoDQXXMmfg6D6VR28oFY1VWe35zzibQUCZ3jXrWi7rlpRL/ZINfg+G6xkcQRcmT0btpnyXf9i9Ve/yNOa7onKcw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB2229 X-LSpam-Score: -2.9 (--) X-LSpam-Report: No, score=-2.9 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DMARC_MISSING=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Indicates whether to generate SPS and PPS at every IDR. Setting it to 0 disables generating SPS and PPS at every IDR. Setting it to one enables generating SPS and PPS at every IDR. Signed-off-by: Jackson Lee Signed-off-by: Nas Chung --- drivers/media/platform/chips-media/wave5/wave5-hw.c | 6 ++++-- drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 7 +++++++ drivers/media/platform/chips-media/wave5/wave5-vpuapi.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-hw.c b/drivers/media/platform/chips-media/wave5/wave5-hw.c index f1e022fb148e..8ad7f3a28ae1 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-hw.c +++ b/drivers/media/platform/chips-media/wave5/wave5-hw.c @@ -1602,11 +1602,13 @@ 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->avc_idr_period & 0x7ff) << 17) | + (p_param->forced_idr_header_enable << 28)); 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->forced_idr_header_enable << 9) | + (p_param->intra_period << 16)); 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 0cb5bfb67258..761775216cd4 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -1125,6 +1125,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: @@ -1292,6 +1295,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) @@ -1775,6 +1779,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 352f6e904e50..3ad6118550ac 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 { From patchwork Wed Jan 31 01:30:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 98882 X-Patchwork-Delegate: sebastian.fricke@collabora.com 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 ) id 1rUzSC-0006pF-1B for patchwork@linuxtv.org; Wed, 31 Jan 2024 01:31:53 +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 454D21F22062 for ; Wed, 31 Jan 2024 01:31:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C04063C7; Wed, 31 Jan 2024 01:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="JNjAVMi/" X-Original-To: linux-media@vger.kernel.org Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2119.outbound.protection.outlook.com [40.107.129.119]) (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 E1F735221; Wed, 31 Jan 2024 01:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.129.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664665; cv=fail; b=MyRc8qn14jN7R6CBFbJwLM+Rc97h/jhXCEO5vW0Unv3DosnT5lh31crHKDWNmYBjpK/wT3ajZov23bKZiDPTcHsCVJHIkYNyp7vMNOWX1ZCPV7Rt17TF+Mum7783L88R9XN/9H477F+H2FUG3v5AWzvpPa87U3MRp0H8Gw/U2Fw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664665; c=relaxed/simple; bh=It89T/OCK0c4YrWvhqTPEL1//rjjpfiigp/1WxciMrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=suM067BUwpaDxo6M/kOkMpGIjjALDdcOFKYfFdmpfrKQG1ETjCQ3JWerwi5iEOCdCqhp7TAr597lBEKxakADvfwke4nGcK6U0Vf1Rr1FGyaI8jHwPwmcQi0aH6Nfwg9ISl/dJqfjkBsd4VNQZnTaNoXaH9vB7hrUsHTDEpSxY0M= 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.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b=JNjAVMi/; arc=fail smtp.client-ip=40.107.129.119 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=mm0stP0j4Aqe52+Qkwz320w4ucLBSakb06sGjiIeI9xPK/NL+XFmOzhfs4hfqtXoN+UUoA/u/Nb3JT3C0CsxCu1MT6fY3arCHHV5w5inHjGNIXaTkzkS4ccIP+gkv0XrODTi0YpLAFdgFRwgWaDksku88IvqsxKmT4kl9rkyo7RuGZOXPvOJFvWeM97ctgzgKlR/XVLqOzRdMMANyNNuTy+p3m0e0+NPDh+j2/q0F3jKSv3lKtmoJTowPgCfdRyfUM0rOaSo/kLdYZ/oWUmzJdNmSqxFCz/CtyvTVducAJ8VRk4spduhwPG4k5SUSkkozTFRbYu1WQ4or14U+p71wA== 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=A1FYjVEimazUD4M4Ka9FO0ZhPmGOo7/M1aUDfxKQQGY=; b=MxajkYErIpy3hypzMxnHeW/l2U/rW+YQmQ6usPAIsYoIsm4KHnibCkMwWganlnjvhvfT0a3buqZv4DMbhDvL6ht40oxe5Mtmj9MR9DVXHTpKmwRdkZfDSzOcFDpjzunuLDQo/l97ZpTvearUpDDfrSxIEZZDQPT7R45BLcVD1JW/za3M7+5B0YDn8qvDyTQ/Ei6Q4FH6EorlQQ5W8q6wA+TlJjd3Ik2QuHTvnI7XVd64aLf3dNQmaHrJcUYFc3dPW3KPajfhrWrcU0cxw0vsryrIqGA+60IDQoH+2g5UFVJ9FHhF74+ifd4Ai5TDFl4fps8826iOs5EZAhS7wMmNpg== 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.onmicrosoft.com; s=selector2-chipsnmedia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A1FYjVEimazUD4M4Ka9FO0ZhPmGOo7/M1aUDfxKQQGY=; b=JNjAVMi/c7KKHnEY4Y18rWv/zzWT+LDtbHeJi9NfhpxkNorMU35hSPZy0qT58lt15lA7yqsNau724SwGINmvL2Gjyspd22EGD7P35mL9nbwoGWF4aUJK8sHymnehUYICs9epwkadkkETHQU8LRJKEALJriHVcnJo/AUNAeiM66U= 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 PU4P216MB2229.KORP216.PROD.OUTLOOK.COM (2603:1096:301:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Wed, 31 Jan 2024 01:30:55 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c%4]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 01:30:55 +0000 From: "jackson.lee" To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, nas.chung@chipsnmedia.com Cc: jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com Subject: [RESEND PATCH v0 3/5] wave5 : Support runtime suspend/resume. Date: Wed, 31 Jan 2024 10:30:44 +0900 Message-Id: <20240131013046.15687-4-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> References: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0224.KORP216.PROD.OUTLOOK.COM (2603:1096:101:18::12) 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_|PU4P216MB2229:EE_ X-MS-Office365-Filtering-Correlation-Id: 3241f235-97b9-42ae-6a4a-08dc21fc44d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KTIyerzzR5Z3rLd080agJQ+sJ9V4YR7ZWuUy8Uv2vYLs90Su/C+NtGQewjXtBBaxyitESdBjdDYNEUNAmOOyfEceLIRjkilZ4Xx7RWDEv7cH2PEksdVkQRmqIxrvbceVd6CihcSW8E4/SVKPo5lN4rOu58QpXVbniCDqVdI4QNybRoECdAoqnVQCmnqV7Es7eBr8XKCqG1eMFBy8f2mqgMntpSDL8x5flaoWvT705Fgr3AMGlQwWhXV/BcwSrtLrQb61SyJuCJzsGwOfWQoQxouEFHrwrEFGRErqCYtTmxCb7iHu31v++qdnEEf/cB7ypjgiD+WOLQ49ZfmGtQc9Pt58ZEX/Dth0xsKfD+9aLl9dLpwhfoY4pXnM313sSyFsyfxEbH1VUCQey63Qt7dG5/EwGDYVkSZa3myIYBEnGgK8/z7q9FIj0dboZxIA0Szpu+N3jtjPYcJLijF6FuOLvUKuJSk++47/OJSScTI0xVeFHE6qYdOEmfunIpn1cbzN4jGcQm4Sxt7iymyAyjaXVf4wgMT1z3rksyn4/TUKkIsk7c0xyyc6JHL+gtRlTUh9tkVQM7xYNNP1RUEZm52WUOj7cxilOad0HBE7VNqB8cikhDl2QfHkF+jydC2JFLCY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SE1P216MB1303.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(39850400004)(396003)(346002)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(83380400001)(6666004)(52116002)(2616005)(6506007)(316002)(6486002)(478600001)(86362001)(6636002)(66946007)(66556008)(66476007)(41300700001)(26005)(6512007)(1076003)(5660300002)(8936002)(4326008)(8676002)(38100700002)(2906002)(38350700005)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w6hyyDLAKW/QLXOhCdwZ+gxOcykQcxbbCNMyvdnRiJ4JK4fg72bwuIb0dJwQ3/o6sehMxTyZs/lSoJGxUMZ8QyV1HXKsDtUVfmL5Uy4KRPbLS7lsl6qu1z4aPpSBZBvQNuMyl02xY70TFuFPcZ0GiEDzwjao5CtgQfvXuFcuj9xZDzw8CQwX5qA6A4XZPRff2sToXWUCHQB3Mucl3O9wqQoeNobHzeEWZy1n+U24Yg09c6DhDLJ3V9uhk67dIIX+6SH3krM5fOejScr9R887h9gk87u+kqa+9FsKnFSak+89+wFmDIPPw99zOOYRlYcnI2v/zHzZgJV7IpWKFq/HTy29yP74yarDPKEgXQZB32U3MDTfW3zABYU6CkrTJ7+4Kpk/VrSzzgcTopBswhkE5pMF1KutkzSQG+WNY9x/wicCdt/Dvf87Wh3HIqJzWTUsYw1LkkpWHJa7qJWXSPYt3zXusieYuN0HfTvDa+6qIBEMYuWePyEogZpSK7QQ4xTFZ4Z6zyJFTyF5Rd/0EXoSvkNIpo/lkypbqbdlO4GDguoboYLXTlpZq9Rh76eBsXd+7Egr86PY+vilTqPPWIkeH0MQupniL4umv6Qc7hBbbpTHbfM/XWKH/3peLAgdyu+cC7kGaAg3PM3FEsq3FgxAv9dDBFx7nY9YAs9/i/0BV3VTOZXyn67jS09HoajmM0KZdM0MHT3NvVozIMM7Nx98X6Z/a4dYb2HM3cK9k6TLJah4hzttjuDvZ3upmW6z7KkDX8p5eD3+92BKQH/8tbsA6gXxIJdr+SzX8S2B4o6tq5nBuovj1xll9sIUBhm9s85KkO0EW6K6xfAUBe6+hSl8WNQyBjV7lnxKcpCe84mwfsH49YTXu2GJisSgwtPl5Rj4eg8WQKhUhPP4/wtsWVslckL+ks2+l/PLPa7LbZA1epjpkvpccAEMnjbps0yZ31R5r6fewxjDTSUmqOhe6mIgzYeaxAEkwMuzFLcGXxJaFK+T6JfigBlLdS042HI+1sFZX3aEaLUk1RUk/BZU5L7ha8xyZU/GP6XsXkeshNUbA+mt14GwIq1T2iWLGAGILtRhPuGFJp1RvFPFdSCxvVRwRr+Kydp60fnAzGGBs2SFyMd6jOHi/ON7YsYRWFqRqCXQ8zepR6dyWc93T108yc2R4r7mXfbHXbSs8AxAyF6eyP21U51iWFe8xc790KD0++Rs3lXz+6RwzxljG8frw8TGqX/AV4YVFBPpxasaI/jMbK7Le9I5bCInfsr4ETCoK7tgHkAtDxvlcKBRSN9bIhpy4emNzvr+ndt8lcznriC/5BqeR2jKMXAwedU1yEJlzC+QVYE0TwjM3S/yu22fYOQHI0FVqCHUQzqhrEen6hOi/vQNk/8VeSs7Z8UHgjCYMXv/w7qU8dPRGD5axnWyNyELUSTZUc+hah2MbX9DvgPle8hRczp3eUD9+Gg5IOtzYcUJbaqVZKbcb3nXFbdQK70RZK8CGHGk+8riPs9LnKIw0jktaiZf9AXB72ebIR6q0l8CMzJBsqXK+vXOzwkxqzzyrIOA1zSQ3sY5VWRTNWKwlgHCR+rCbjzRVJ9u93UeR1TqHkEabOwIzBkwAoQ5k1dihILXV4dnHYecNe/4dH7x3hM= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3241f235-97b9-42ae-6a4a-08dc21fc44d1 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 01:30:55.1843 (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: OzUnYctPIIO59M6W1NvABeDJWBhK9srS6c44H+JK+4QmPQFhUmUhbvCYIlRhe2ZrZruXR6RuQb7/qmOyKpwF4xQoSx0+obPea9YoxYG7AHA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB2229 X-LSpam-Score: -2.9 (--) X-LSpam-Report: No, score=-2.9 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DMARC_MISSING=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no There are two device run-time PM callbacks defined in 'struct dev_pm_ops' int (*runtime_suspend)(struct device *dev); int (*runtime_resume)(struct device *dev); Signed-off-by: Jackson Lee Signed-off-by: Nas Chung --- .../platform/chips-media/wave5/wave5-hw.c | 5 +- .../chips-media/wave5/wave5-vpu-dec.c | 9 +++ .../chips-media/wave5/wave5-vpu-enc.c | 9 +++ .../platform/chips-media/wave5/wave5-vpu.c | 68 +++++++++++++++++++ .../platform/chips-media/wave5/wave5-vpuapi.c | 7 ++ .../media/platform/chips-media/wave5/wave5.h | 3 + 6 files changed, 99 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-hw.c b/drivers/media/platform/chips-media/wave5/wave5-hw.c index 8ad7f3a28ae1..8aade5a38439 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-hw.c +++ b/drivers/media/platform/chips-media/wave5/wave5-hw.c @@ -503,6 +503,7 @@ int wave5_vpu_build_up_dec_param(struct vpu_instance *inst, /* This register must be reset explicitly */ vpu_write_reg(inst->dev, W5_CMD_EXT_ADDR, 0); vpu_write_reg(inst->dev, W5_CMD_NUM_CQ_DEPTH_M1, (COMMAND_QUEUE_DEPTH - 1)); + vpu_write_reg(inst->dev, W5_CMD_ERR_CONCEAL, 0); ret = send_firmware_command(inst, W5_CREATE_INSTANCE, true, NULL, NULL); if (ret) { @@ -1075,8 +1076,8 @@ int wave5_vpu_re_init(struct device *dev, u8 *fw, size_t size) return setup_wave5_properties(dev); } -static int wave5_vpu_sleep_wake(struct device *dev, bool i_sleep_wake, const uint16_t *code, - size_t size) +int wave5_vpu_sleep_wake(struct device *dev, bool i_sleep_wake, const uint16_t *code, + size_t size) { u32 reg_val; struct vpu_buf *common_vb; diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c index ef227af72348..328a7a8f26c5 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c @@ -5,6 +5,7 @@ * Copyright (C) 2021-2023 CHIPS&MEDIA INC */ +#include #include "wave5-helper.h" #define VPU_DEC_DEV_NAME "C&M Wave5 VPU decoder" @@ -1387,9 +1388,17 @@ static int wave5_vpu_dec_start_streaming(struct vb2_queue *q, unsigned int count if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && inst->state == VPU_INST_STATE_NONE) { struct dec_open_param open_param; + int err = 0; memset(&open_param, 0, sizeof(struct dec_open_param)); + err = pm_runtime_resume_and_get(inst->dev->dev); + if (err) { + dev_err(inst->dev->dev, "decoder runtime resume failed %d\n", err); + ret = -EINVAL; + goto return_buffers; + } + ret = wave5_vpu_dec_allocate_ring_buffer(inst); if (ret) goto return_buffers; 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 761775216cd4..ff73d69de41c 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -5,6 +5,7 @@ * Copyright (C) 2021-2023 CHIPS&MEDIA INC */ +#include #include "wave5-helper.h" #define VPU_ENC_DEV_NAME "C&M Wave5 VPU encoder" @@ -1387,9 +1388,17 @@ static int wave5_vpu_enc_start_streaming(struct vb2_queue *q, unsigned int count if (inst->state == VPU_INST_STATE_NONE && q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { struct enc_open_param open_param; + int err = 0; memset(&open_param, 0, sizeof(struct enc_open_param)); + err = pm_runtime_resume_and_get(inst->dev->dev); + if (err) { + dev_err(inst->dev->dev, "encoder runtime resume failed %d\n", err); + ret = -EINVAL; + goto return_buffers; + } + wave5_set_enc_openparam(&open_param, inst); ret = wave5_vpu_enc_open(inst, &open_param); diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c index 0d90b5820bef..f81409740a56 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "wave5-vpu.h" #include "wave5-regdefine.h" #include "wave5-vpuconfig.h" @@ -117,6 +118,65 @@ static int wave5_vpu_load_firmware(struct device *dev, const char *fw_name, return 0; } +static __maybe_unused int wave5_pm_suspend(struct device *dev) +{ + struct vpu_device *vpu = dev_get_drvdata(dev); + + if (pm_runtime_suspended(dev)) + return 0; + + wave5_vpu_sleep_wake(dev, true, NULL, 0); + clk_bulk_disable_unprepare(vpu->num_clks, vpu->clks); + + return 0; +} + +static __maybe_unused int wave5_pm_resume(struct device *dev) +{ + struct vpu_device *vpu = dev_get_drvdata(dev); + int ret = 0; + + wave5_vpu_sleep_wake(dev, false, NULL, 0); + ret = clk_bulk_prepare_enable(vpu->num_clks, vpu->clks); + if (ret) { + dev_err(dev, "Enabling clocks, fail: %d\n", ret); + return ret; + } + + return ret; +} + +static __maybe_unused int wave5_suspend(struct device *dev) +{ + struct vpu_device *vpu = dev_get_drvdata(dev); + struct vpu_instance *inst; + + list_for_each_entry(inst, &vpu->instances, list) + v4l2_m2m_suspend(inst->v4l2_m2m_dev); + + return pm_runtime_force_suspend(dev); +} + +static __maybe_unused int wave5_resume(struct device *dev) +{ + struct vpu_device *vpu = dev_get_drvdata(dev); + struct vpu_instance *inst; + int ret = 0; + + ret = pm_runtime_force_resume(dev); + if (ret < 0) + return ret; + + list_for_each_entry(inst, &vpu->instances, list) + v4l2_m2m_resume(inst->v4l2_m2m_dev); + + return ret; +} + +static const struct dev_pm_ops wave5_pm_ops = { + SET_RUNTIME_PM_OPS(wave5_pm_suspend, wave5_pm_resume, NULL) +}; + static int wave5_vpu_probe(struct platform_device *pdev) { int ret; @@ -232,6 +292,10 @@ static int wave5_vpu_probe(struct platform_device *pdev) (match_data->flags & WAVE5_IS_DEC) ? "'DECODE'" : ""); dev_info(&pdev->dev, "Product Code: 0x%x\n", dev->product_code); dev_info(&pdev->dev, "Firmware Revision: %u\n", fw_revision); + + pm_runtime_enable(&pdev->dev); + wave5_vpu_sleep_wake(&pdev->dev, true, NULL, 0); + return 0; err_enc_unreg: @@ -254,6 +318,9 @@ static int wave5_vpu_remove(struct platform_device *pdev) { struct vpu_device *dev = dev_get_drvdata(&pdev->dev); + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); + mutex_destroy(&dev->dev_lock); mutex_destroy(&dev->hw_lock); clk_bulk_disable_unprepare(dev->num_clks, dev->clks); @@ -281,6 +348,7 @@ static struct platform_driver wave5_vpu_driver = { .driver = { .name = VPU_PLATFORM_DEVICE_NAME, .of_match_table = of_match_ptr(wave5_dt_ids), + .pm = &wave5_pm_ops, }, .probe = wave5_vpu_probe, .remove = wave5_vpu_remove, diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c index 1a3efb638dde..f1f8e4fc8474 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c @@ -6,6 +6,7 @@ */ #include +#include #include "wave5-vpuapi.h" #include "wave5-regdefine.h" #include "wave5.h" @@ -232,6 +233,9 @@ int wave5_vpu_dec_close(struct vpu_instance *inst, u32 *fail_res) wave5_vdi_free_dma_memory(vpu_dev, &p_dec_info->vb_task); + if (!pm_runtime_suspended(inst->dev->dev)) + pm_runtime_put_sync(inst->dev->dev); + unlock_and_return: mutex_unlock(&vpu_dev->hw_lock); @@ -734,6 +738,9 @@ int wave5_vpu_enc_close(struct vpu_instance *inst, u32 *fail_res) wave5_vdi_free_dma_memory(vpu_dev, &p_enc_info->vb_task); + if (!pm_runtime_suspended(inst->dev->dev)) + pm_runtime_put_sync(inst->dev->dev); + mutex_unlock(&vpu_dev->hw_lock); return 0; diff --git a/drivers/media/platform/chips-media/wave5/wave5.h b/drivers/media/platform/chips-media/wave5/wave5.h index 063028eccd3b..6125eff938a8 100644 --- a/drivers/media/platform/chips-media/wave5/wave5.h +++ b/drivers/media/platform/chips-media/wave5/wave5.h @@ -56,6 +56,9 @@ int wave5_vpu_get_version(struct vpu_device *vpu_dev, u32 *revision); int wave5_vpu_init(struct device *dev, u8 *fw, size_t size); +int wave5_vpu_sleep_wake(struct device *dev, bool i_sleep_wake, const uint16_t *code, + size_t size); + int wave5_vpu_reset(struct device *dev, enum sw_reset_mode reset_mode); int wave5_vpu_build_up_dec_param(struct vpu_instance *inst, struct dec_open_param *param); From patchwork Wed Jan 31 01:30:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 98883 X-Patchwork-Delegate: sebastian.fricke@collabora.com Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rUzSN-0006qF-2J for patchwork@linuxtv.org; Wed, 31 Jan 2024 01:32:04 +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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 79B661C23342 for ; Wed, 31 Jan 2024 01:32:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09A4ECA6B; Wed, 31 Jan 2024 01:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="P5YAZhTi" X-Original-To: linux-media@vger.kernel.org Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2119.outbound.protection.outlook.com [40.107.129.119]) (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 275FC63B8; Wed, 31 Jan 2024 01:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.129.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664667; cv=fail; b=E5yRBSVH5Jv2rj8tqhELJg5n/pZ0llFU5s9MyvciabnNchs4YafK7Eqd/N0ykrOcCsRtafS9EwuzmzEhGRDGkhX8eno3qr7Y4pD2beX+Llm44nYSBEbowFZIDHIPojk4kNR4Ea9dGAbQqP26tn0K3pJlYhFdgAxxrQbgXKB+T50= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664667; c=relaxed/simple; bh=HJBC+Ltj4JnvFVCRHeP4aH4x9ZCZTgbdL5Aabjx6BCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rz114BJmMBMu8RrtW28tg+glDwtjVd2SO6V8pWoyFanbcm5etcPOldNelsmzWagSbg4YeDIeH6eSBUITvZcGowEven5N85xOYnOpFmMkBhidjxBgUYvck2FfqDkSMbR85NxoATdJ6C+4HiWYDMxXuqazsUqzKh13EvAvSZ4PzcI= 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.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b=P5YAZhTi; arc=fail smtp.client-ip=40.107.129.119 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=oSQ98H4Q/3xyN8M/oOdWuEFMjhwlmsN+qWQU6nnir4fFhSgJU281TvvLm04M/5Gt71SqZ0HJDEEDxUnAjfN9dA/qc5tt6mU05v+bvEkgFwlBtlknZq9Gr0thJ2mb6GOT9glVjNIDJRvt2WVeY/2lZsRBmtZ0QqnT3+RDpCkDoMGIR4Zck0teaeSdwLyQnMYBFUc04S5p5EEm8YSxX6RKFr0+MiZ4ShnI7zh7xW8ZaMaOKFMluhmD58lEoqyJghX9r1wK1St6UJhcWGHFkR0L+/Mv2ZyNYN93skSIBaLRKadOorP2i2sivxN92CCFepG9O5JDLyyDaZ8f3F3jzZiSpg== 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=zBgH4qo5F6ppw6ZGJiII4H63BwbU2A3PKynOtX8yMs8=; b=AFFHZOqMbuAT4ZaFKtfrUDrdCHDtfNu1cR78z5TTHDATzp9njONx7IcJoBkidCQtq9Zf+e1JUuGl6q2/X4mAQ7vtilPzY0whIVOK7+D2effA/o78u8ZGwde0sUtWGIe2ciAxTHF/PqsMg8YU8quWJ6QxXcEjRX5U5/KO2sC6TNT6p4UQQu4rpzKXpnujEJGhPGKr6PVqjSdkgHtT7qZ/2noJPjvCKXG//59hJB661PgCu+01vOPPhWVU2LeK8WBUW03j0qZ/2RasIeOy/7R9OQ14KsWa1JExWCeNrtfEeuxeo0zQ216yxQcwUkN6QsDrYIJ3vqeJaPXOMK+DJ24vvA== 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.onmicrosoft.com; s=selector2-chipsnmedia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zBgH4qo5F6ppw6ZGJiII4H63BwbU2A3PKynOtX8yMs8=; b=P5YAZhTiOG7shd78H5wIijrUIZU+CJsXdPRrr8Y572hiVTVWvJ7Ujmz+0LkoKYEWl3CvQd1qhPVk0SxYqIX3UivkSmO9ANkEKJPwQ2cRpltFJqw9NtXtlQJiZg0xGfW1XW/EJxJGoIrGi39Z0T1paOe+6+SWWOWTXd4fpFBmMac= 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 PU4P216MB2229.KORP216.PROD.OUTLOOK.COM (2603:1096:301:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Wed, 31 Jan 2024 01:30:55 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c%4]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 01:30:55 +0000 From: "jackson.lee" To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, nas.chung@chipsnmedia.com Cc: jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com Subject: [RESEND PATCH v0 4/5] wave5: Use the bitstream buffer size from host. Date: Wed, 31 Jan 2024 10:30:45 +0900 Message-Id: <20240131013046.15687-5-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> References: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0224.KORP216.PROD.OUTLOOK.COM (2603:1096:101:18::12) 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_|PU4P216MB2229:EE_ X-MS-Office365-Filtering-Correlation-Id: acb3e98b-dd5a-4930-9f44-08dc21fc4525 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RCKP1tNggclQmwgxvQ9WkUCjnEjiV+GRvI9w00jzseR4FEwJjRyjZjNWRO6z2KRrYtEAdUp0/Lb/ct2k7Dok9769U1bsCZwam7ENP4QirkTEcA0A938qobyNJG/2+SmIGm9gc/mbcVU9ECdTk1NUPvBzjc7SP087DQbD1CmuaHKKcLkJZsNi2Zn0rHuadsydRN9Ml9kkriY7pJKa7eUK5k2r3la3VDdjL+2mhaDzhcagggcWPwnewV3smh44fghcUDQDk6OEsv6KDxmMKjwtYm1sxkOCL4FbELZ5dr0cbi8S0X2XgUQDrc6w51QML5Ua99ARW+A/09dYPhE2wIyoNCAW/3FrMCT21tKIeRgdPYdhnpQNbE/V8dMvroseOuls4+Lqi4D0sIpN91BPYlfLyaBUze0AXalmpcxuWqXfzq/F/gOtXJH7aFb0HBIMGERjvyIwNindygaTpt7Lh3a1p4txYyrUElO3+iqIdGS0ZitPDrobk5h7LxfPmXih3g/38zjtp99zQ4bRfaUE/XI/priwX1F+J4Llqp2Ql8hPJrUUExdDNSi7a3Aw93zC8VHeSWBjqddd39HEzELJdsyfuN1XPiqJUyu+DJ4Rx/tQY+jCx6f1Lb1XFD5z37i8/aEL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SE1P216MB1303.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(39850400004)(396003)(346002)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(83380400001)(6666004)(52116002)(2616005)(6506007)(316002)(6486002)(478600001)(86362001)(6636002)(66946007)(66556008)(66476007)(41300700001)(26005)(6512007)(1076003)(5660300002)(8936002)(4326008)(8676002)(38100700002)(2906002)(38350700005)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZZMYPJBc4n2Qb9ne1SyBbM9WSXNBZD1QO9C/gQtX7geueeN6qrUJHt6i5znFOeH0H9ah6Wi7dfpgepXjROFYfVPgnz42xY4EkRagrzLAX5e5g70CXQNxMKPwdb1RNUtIzTtyBp4Yc+XDmGoO9ZybDasmyocDt7Eqa1hivLjQNXuT9E3k8efDBYwvvge6kYbOMXHd27cns3qa2V8WUkbb252XWGjai7yfoRUdtWOIbHqjG3vuHS2fQNlI5fGVWDt3H3/Y8T0xLY7pQvAxWG2E7R3pnmYVN3UxPL0rlkIybM5p0LujllmMn8qeo1yq1Elb1mhkyBwvj90SmVk3W23F21Oy8xu74bpkrAh4aXAoJIVb03RwZcO9t9u5+FRNPgOb+SuQ1AxjMqCqa5sFDU6XRdZgQh02UI9N/qEf4K2sEB4DtCKv5ubVGTpiHQB9oYtPE2fL567pjbi3b8gQARhDDzOPWWgD/zZrM5ORz3DhZc7rn4FJHIor4zQgA1JNjrHL48UhIISBXAxZxoN9sitdgQD19ayzQHkUvxYBiazTJS8e5MSCO3xysPoJv6/eibphz+gGbgj4j0XyHKL02WFS15wzlBihDi4yDiTDqePLIPMSVJyMcDOhHycOlFqeYt1aGae8U/o4o0zozcyadTw1xikL/+FoQcnI9YhIgFoWIliesOPw83+yulvkRDH2yrai4FnXUZ3wLT3zutrsNtgUYf5flHYv7LC3yLCxT9f3CH/6+sFpCkB7nMZlhNeYMYp4iwoRnrdjib4YaF52liOkwxjPN8qhzhN7EQLwphQrVO73eRXXN+TNsf6TaW3zZS+7X5pVUUpUjf5q9k4rXmjB13KqXrsT04Y6bhtF75o2dPq1LDH5M6rZXnUHdc5RuroojDPwJi4L11n14EOVAs247xuSv2Kz1E7ECe7w1mbp6M1MGtGjhP6Ap7hhIqcDJH2QRT4CBzDObQHKwbjKWrmiTcIc7vDTDz7ZQDVPgWFDNyG7JYKnmSpO9NfEObTBYgmF1zUcXXyyvP15GpyDS+79Uu5eUezM+vFhLCLslXx3BZK36zmI1/2jiTtmbq3Ho+vUM5uguWsB++0CmjtXdg+blmXxlHdyohblHPQdt93xisvqcnm0jPzhQaqRJHP9D0twL924G+wpZ9ECV1kQ0dJGqxeAeF7wY3QcQ7QR8khMCaNF3q1YCnsl2mKCecKSbyAfMG+r0I+RU/P/f3lGsBWAxsABW0pmxVbBEvtBKoqBemiO693HlCS4SHBxDy3BgqQ/XjDJhqeqWlMBoHQAIMMNuhHOWtesPawXOPdez3pHBlPoOTuNoncjjOKyAZ7yHliAUyxZ5SeAJueDs0SXOr1i0u18pTH7/I1X9lJeOlKT/suDbuKGZs2wvl3dkp3Qp0FK4Kb3Iva7YFkhTkxB0oivR+NOkPOnmDAWgIxlTB/eXpfQXpestulGZCoCFtrPBiUPqJA+NZB427rM9DIQz2IGZlTSiguDdoBloOeB1PPPAAcpF/fXEDoTVQTUrJshv2935u8U66TMxx3SHYjNqdQx6MF+lzHt+0HdFltS4p5K7k8xVRH3znEi6JKLGeNy+Z/BjBZ9kDpr+63ax5aJr6IP5mgB+C2J9vPBsRXU9aQUOh0= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: acb3e98b-dd5a-4930-9f44-08dc21fc4525 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 01:30:55.6225 (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: V9u3HfPKk49vUif0kWieNz+/mv02SnHppYOLl3mlfxMmHXr+6hC6pbB4+2hQcr+i2+Eq4BF7N/EZF7oT9a73ROorEhhKCyBoyTvyRtutCmk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB2229 X-LSpam-Score: -2.9 (--) X-LSpam-Report: No, score=-2.9 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DMARC_MISSING=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no In V4L2 spec, Host can set the bitstream buffer size. Allow the larger size between default size and input size. Signed-off-by: Jackson Lee Signed-off-by: Nas Chung --- drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 ff73d69de41c..19018ace41b6 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -11,6 +11,10 @@ #define VPU_ENC_DEV_NAME "C&M Wave5 VPU encoder" #define VPU_ENC_DRV_NAME "wave5-enc" +#define DEFAULT_SRC_SIZE(width, height) ({ \ + (width) * (height) / 8 * 3; \ +}) + static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = { [VPU_FMT_TYPE_CODEC] = { { @@ -193,7 +197,8 @@ static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned pix_mp->width = width; pix_mp->height = height; pix_mp->plane_fmt[0].bytesperline = 0; - pix_mp->plane_fmt[0].sizeimage = width * height / 8 * 3; + pix_mp->plane_fmt[0].sizeimage = max(DEFAULT_SRC_SIZE(width, height), + pix_mp->plane_fmt[0].sizeimage); break; } } From patchwork Wed Jan 31 01:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jackson.lee" X-Patchwork-Id: 98884 X-Patchwork-Delegate: sebastian.fricke@collabora.com 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 ) id 1rUzSh-0006s4-2t for patchwork@linuxtv.org; Wed, 31 Jan 2024 01:32:24 +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 A5B2C1F24EBB for ; Wed, 31 Jan 2024 01:32:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AA3D6FC6; Wed, 31 Jan 2024 01:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="ALxcm9Sd" X-Original-To: linux-media@vger.kernel.org Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2119.outbound.protection.outlook.com [40.107.129.119]) (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 E72CF79ED; Wed, 31 Jan 2024 01:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.129.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664670; cv=fail; b=CFBZ79QNoIsPxj6BJ4HsxzUq0XCTQp9coX9uFxww97S5BtZlFPIaiq+V1n8tTm121VNWIvz7aV6NRW0YpVNK60bAoNZmAu4dGH+kaCz3i6ljJ+hxmmLO1osnVnajcAUj05WZPHxcWT5yrCdd5TXvWLFRA5OD6ki6JlbX/E5ldC0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706664670; c=relaxed/simple; bh=6ddaxAQD+4sMxQ8F2S75ufc2/oaDz6ish+U6S4vf91w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BOmyUD+I9JtCDcAYAjxsWdtmFPcZoa+TAYzdhK2F93hINmjXj2d/Fjpofj/ZMMs10L/7hhRk2N4G0Lk/474j1Rejk0+vGv0jTJhWG8xMeO4P0Iv1wfPBYyUIUQL/TyhdM3ZC7VpyyLfB62V9VmmwfAfXo7/8r6Q+8MU1NuOLWYQ= 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.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b=ALxcm9Sd; arc=fail smtp.client-ip=40.107.129.119 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=bKn9330W62TO4Y/v10GxOuPb9AnzM52gIevupnbxQ2S0zgdvBVJ8G9Gyz9OQ538jobjnDEt9S/MjNuBDyTchzk8fDRkIoIZmemYBnEBenEgRqqH8YW/VC78Xl7E+ukwfhAum5hWkgkGX5Zun/QQpD4RTXEguA0b3j3MwpsmXH5QPmDuTDYHc7Nc7s4NksHcX5q2qa15c19Ars3B6EIVKCSHQSnmU7MYt7z1OoIPMa0rzEFO71SICvgutj5MkPa7DobLcHGLX9C0OuVEZ8MbwmjHzuV4FRhOxXe1JwcfUMvikamqNGAr2uaW/rK+0JnC1ZRMC4Y9Cr1H0Tqnd0GAcdQ== 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=lj+2VmOeefx5Pw89ofh80JX8+KzzWrIoW692daLpmUE=; b=iCCF9hJdr3VcfEIFQIdm6ZFg/JIK+9jPuR45jmA0W0XqrB6nBN1hDUmPasPQk4hiC6yTVfIItMjLIQPBHlkmZviwLLDrNoS1FRNJnWB1OOqNjA5UGueSD9mjyuOrR3MSa5hS+/4XNWmiXq+zQMn27qjgXtECHzDwpZwPhZ+UtF2+52fKyvG4W4pluPa1csowIG2iUWISKhfoB6iB56GRPD7cWxqpSus4WV80tww9kK7VoDIqCSOYcbxkC/EGx2ataoYFh82gCWyEb8Sdzk2S9N0B3jm0P2J221upE/iHcn+5PnxENbp5j7GqklsDz6kQmD0jhs1PL0WOMItdA5m0GQ== 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.onmicrosoft.com; s=selector2-chipsnmedia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lj+2VmOeefx5Pw89ofh80JX8+KzzWrIoW692daLpmUE=; b=ALxcm9SdDHMpBDXZgPjgIwC21ZCbh0Z72kF57GzkK676/y0sEy1yZvFcdBd/Hc2aS2GskJG2NUVQ2ZyCMybkdLMOfms0Itq9I9+c4QUdkmVcQyAW2bo4dA/7ef1TQgArjujoQym10klgoD1y4Q/52A794mcsayVqMR8AkDBhuMk= 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 PU4P216MB2229.KORP216.PROD.OUTLOOK.COM (2603:1096:301:131::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Wed, 31 Jan 2024 01:30:56 +0000 Received: from SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c]) by SE1P216MB1303.KORP216.PROD.OUTLOOK.COM ([fe80::de27:9f30:e1f9:1b5c%4]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 01:30:56 +0000 From: "jackson.lee" To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, nas.chung@chipsnmedia.com Cc: jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com Subject: [RESEND PATCH v0 5/5] wave5 : Fixed the wrong buffer size formula. Date: Wed, 31 Jan 2024 10:30:46 +0900 Message-Id: <20240131013046.15687-6-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> References: <20240131013046.15687-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0224.KORP216.PROD.OUTLOOK.COM (2603:1096:101:18::12) 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_|PU4P216MB2229:EE_ X-MS-Office365-Filtering-Correlation-Id: 46241c42-de4f-4074-5efd-08dc21fc45a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AAK39TRug3ApHIkTXL4TEIT6xHUYUn6tZMCm/hPbvlSZJn2ufmsuUsc0SHm1aNeM1WiWZ2gL3hvh7Js7asYBFdb8nqk58Yq6CKn8BMXBl3wCa588GFSqRhBZpt/qK1i5zc3fLnpTGEoy9sW0PMeVPKF01sRVDy3RA9BlFPWKIVhKR1t5jqhKxkBMcojHZYnny+DuG+QfQVM2CqHK/oH2dKmCttLXhSHgi6sZHB8RRFhEhb0rB7aXaz9LkE1DPRhdw8lmrvHBouI1MxouwyyyTnMUd6qzkp4WhXOBgQq6B0QgZM9L8XzQktwYSxbqljkdP5sBj7Cv0A3m9UUOZ8lFB6ImcbHmyPqFM/Kxgip8BKWyMyd2kakFz95fi0lLEgiwi1o+L6d5u/BwjtndStb0BXN7kSMqiNDxph2hAtKImm/LKBjgoisYVeoi2ut/zAQtqmQQgP+JYZJR/qguDA7XIcfLAia8U8VFOXk6CltejZi/JISLoHiGk2a8hZujdqtgEnE4wwlhIMRwh+DNW/yIjpz5cfAH0c+GiWUyvrUbfWFh+PftJZjjp/pqlgjX8zJeGfbnxLIfOm3FFyWQQcqrPPE509chtYD0ZdGqEeRnJnVdgksFcHdOfdYZwfSyCruE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SE1P216MB1303.KORP216.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(39850400004)(396003)(346002)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(83380400001)(6666004)(52116002)(2616005)(6506007)(316002)(6486002)(478600001)(86362001)(6636002)(66946007)(66556008)(66476007)(41300700001)(26005)(6512007)(1076003)(5660300002)(8936002)(4326008)(8676002)(38100700002)(2906002)(38350700005)(30864003)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ud/cxG1F3rZPrmrlUJYrQCIPTkOl918MDxjbh20oswqcNK618xUoa+Y1urjAbbY+B0OaoHMZKFcvqJa2EM/48EoEXQQXMy7Q5EhFFzbRQn8PYB2RXT5TTh4U68tNXdpyI7JEJY5K89Rt7gxrf+ebUgijHOk37YcelBrz6WFydlfb54f1YVnhKL83BcdRfDXYfQLu31g+e8EdwMvi1+EyeFs5zjDUt46/zyTyLkO6oy7RL/mTHgFI+GT4DCyGUwGUQ8aUvmYeb7UcqWectz9pvm6nKsZNfR7CAUvZKaxMPFNvm5J4dO4R2p132iv5N/VF47U+G5ST88360hR2KrTm37VBtLLpYqnNajzB2H6VP5RrFgF2I1h7hWQGUL8lh6OaMMbEoEY4obdlhoDWvwkv316Sdf8AvRyfaE0k/BcMmkJVNiuIvQurf0FGWv9huJ8lnt/peWxKq7+vVBb6MSE3h7WPEqqPvWDq2OIoY2dCzgrC4EWZ6l9/AREsInExfS4fpKe/FzhGrEJLg3OD6AabirTcYVWkseDAZg5XHdVKJ5aABn6PGRjubCveVRi1t0GP3oP70XkoSi2uJMd9KBihn91yqrojKMajwFnbXX2SIwCBdNTuMrXKFuDUoTxzYKKPUmriA+rbZxaQy4QJYqh6BQAzGzpVgoChcExN0kAXxKsk1BjC0GOjM4fKpJ3PgYeBMfjKnk8EeMjD0y28wTtdBGg7VSg8OQQIX+9OLYJb7ntgJ7uH2NWxxjTT8lfrWB5tNmPB83wQNLgwp/qmiksdNOxmoRYC6v5i64XOAX+0b4qKqNsfbAZQawTLPYt3C4fOVJ3M1Xx4ahy1I62pfNIAfjVgdBYh+3CB0Fbo/PJcTcVn31u5FYrJT5nNf2M9b5LDYFGsJVIVSmY/I6rB6/NQ0uSDYHI13o3kIyQVJyluzje7IZQtTUSd45Bkz2kwtNLguBSIjkIoRE089ewBGPD/JIgOyvjiPwfwx6QKy0er+FpWc7cZYnHxoJD6rsiaLqCjPMrlmR+UytTm+Zx597mc+Xlthb4y8yTZNWZ+amY4WKGp0o2eFYS8r4Wbe/8vvyE1QI8sw1sclLSzMtW5G8vUqi/5a6m08Nau5gqox5yfoGHgkkc/+Pm6rkUJDE/9f2lEmVbLLGv9h9WU32RG1BIDOUCdxSGiQHvHqYlpEVckMqB+StBPKq0McvIebHP4hOMswjszHlg7Lp3j1NYYks2NZ5fTwQiew4UjWbWmKcPgsvF2pWIk2nK+HKihnCETs5pP+bstBRtyjwKg+5nbxoZdBxODrVeFVy7VmojVAvpNvv+yyRuoBu2b+cA10GJNDyXwc2GofNVikx/by9j7ShD1GLT1mZbfaLx/xjoly5Tgypxvg6IzfZ3xdICioPnqDPCiYXpP78cs+aldhybOT/8pQLAIhdFz9LSxlglR+xOLj8Xz8ScxA68fCRhqm1lK1cR3CJdN95Y18BjbhNMKxNLsJv/ajmoBhUPyUb01Zb3s44t5Sz3Q5MBXljAFqXOZbXxZWBE0KTOBrzMG+deOauhnW3OvyJLuECvpshvywhOpG3th9G0mvf1TlXhhy/RFoIZurfzh7/OoLDiOfqgKyvpAXh6kd7bg13gip2qL2OtugcM= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46241c42-de4f-4074-5efd-08dc21fc45a2 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 01:30:56.4234 (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: 0xcdOcZMR3/h7de+uqZjKdcGfajgLsmTroSInJviyjOzNwCn5tFRMHPx1WPAy3qL9839EiaJV5MauQl8pJRLcb1mxSdBTYCZx/IhdQvvx00= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU4P216MB2229 X-LSpam-Score: -2.9 (--) X-LSpam-Report: No, score=-2.9 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DMARC_MISSING=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,SPF_PASS=-0.001,T_PDS_OTHER_BAD_TLD=0.01 autolearn=unavailable autolearn_force=no S_FMT/G_FMT should report the buffer size based on aligned width and height. And, Host can set the real encoding size through s_selection and g_selection. So, Driver should use the conf_win information for encoding size instead of size of S_FMT/G_FMT. Signed-off-by: Nas Chung Signed-off-by: Jackson Lee --- .../chips-media/wave5/wave5-vpu-dec.c | 77 +++++++------------ .../chips-media/wave5/wave5-vpu-enc.c | 77 +++++++++++-------- 2 files changed, 72 insertions(+), 82 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c index 328a7a8f26c5..fb9449908ebd 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c @@ -243,54 +243,54 @@ static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned case V4L2_PIX_FMT_NV21: pix_mp->width = round_up(width, 32); pix_mp->height = round_up(height, 16); - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = width * height * 3 / 2; + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height * 3 / 2; break; case V4L2_PIX_FMT_YUV422P: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV61: pix_mp->width = round_up(width, 32); pix_mp->height = round_up(height, 16); - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = width * height * 2; + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height * 2; break; case V4L2_PIX_FMT_YUV420M: pix_mp->width = round_up(width, 32); pix_mp->height = round_up(height, 16); - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = width * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32) / 2; - pix_mp->plane_fmt[1].sizeimage = width * height / 4; - pix_mp->plane_fmt[2].bytesperline = round_up(width, 32) / 2; - pix_mp->plane_fmt[2].sizeimage = width * height / 4; + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width / 2; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height / 4; + pix_mp->plane_fmt[2].bytesperline = pix_mp->width / 2; + pix_mp->plane_fmt[2].sizeimage = pix_mp->width * pix_mp->height / 4; break; case V4L2_PIX_FMT_NV12M: case V4L2_PIX_FMT_NV21M: pix_mp->width = round_up(width, 32); pix_mp->height = round_up(height, 16); - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = width * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[1].sizeimage = width * height / 2; + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height / 2; break; case V4L2_PIX_FMT_YUV422M: pix_mp->width = round_up(width, 32); pix_mp->height = round_up(height, 16); - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = width * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32) / 2; - pix_mp->plane_fmt[1].sizeimage = width * height / 2; - pix_mp->plane_fmt[2].bytesperline = round_up(width, 32) / 2; - pix_mp->plane_fmt[2].sizeimage = width * height / 2; + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width / 2; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height / 2; + pix_mp->plane_fmt[2].bytesperline = pix_mp->width / 2; + pix_mp->plane_fmt[2].sizeimage = pix_mp->width * pix_mp->height / 2; break; case V4L2_PIX_FMT_NV16M: case V4L2_PIX_FMT_NV61M: pix_mp->width = round_up(width, 32); pix_mp->height = round_up(height, 16); - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = width * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[1].sizeimage = width * height; + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height; break; default: pix_mp->width = width; @@ -1003,6 +1003,7 @@ static int wave5_vpu_dec_queue_setup(struct vb2_queue *q, unsigned int *num_buff struct vpu_instance *inst = vb2_get_drv_priv(q); struct v4l2_pix_format_mplane inst_format = (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) ? inst->src_fmt : inst->dst_fmt; + unsigned int i; dev_dbg(inst->dev->dev, "%s: num_buffers: %u | num_planes: %u | type: %u\n", __func__, *num_buffers, *num_planes, q->type); @@ -1016,31 +1017,9 @@ static int wave5_vpu_dec_queue_setup(struct vb2_queue *q, unsigned int *num_buff if (*num_buffers < inst->fbc_buf_count) *num_buffers = inst->fbc_buf_count; - if (*num_planes == 1) { - if (inst->output_format == FORMAT_422) - sizes[0] = inst_format.width * inst_format.height * 2; - else - sizes[0] = inst_format.width * inst_format.height * 3 / 2; - dev_dbg(inst->dev->dev, "%s: size[0]: %u\n", __func__, sizes[0]); - } else if (*num_planes == 2) { - sizes[0] = inst_format.width * inst_format.height; - if (inst->output_format == FORMAT_422) - sizes[1] = inst_format.width * inst_format.height; - else - sizes[1] = inst_format.width * inst_format.height / 2; - dev_dbg(inst->dev->dev, "%s: size[0]: %u | size[1]: %u\n", - __func__, sizes[0], sizes[1]); - } else if (*num_planes == 3) { - sizes[0] = inst_format.width * inst_format.height; - if (inst->output_format == FORMAT_422) { - sizes[1] = inst_format.width * inst_format.height / 2; - sizes[2] = inst_format.width * inst_format.height / 2; - } else { - sizes[1] = inst_format.width * inst_format.height / 4; - sizes[2] = inst_format.width * inst_format.height / 4; - } - dev_dbg(inst->dev->dev, "%s: size[0]: %u | size[1]: %u | size[2]: %u\n", - __func__, sizes[0], sizes[1], sizes[2]); + for (i = 0; i < *num_planes; i++) { + sizes[i] = inst_format.plane_fmt[i].sizeimage; + dev_dbg(inst->dev->dev, "%s: size[%u]: %u\n", __func__, i, sizes[i]); } } 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 19018ace41b6..762973d0677b 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -152,46 +152,46 @@ static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV21: - pix_mp->width = width; - pix_mp->height = height; - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height * 3 / 2; + pix_mp->width = round_up(width, 32); + pix_mp->height = round_up(height, 16); + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height * 3 / 2; break; case V4L2_PIX_FMT_YUV420M: - pix_mp->width = width; - pix_mp->height = height; - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32) / 2; - pix_mp->plane_fmt[1].sizeimage = round_up(width, 32) * height / 4; - pix_mp->plane_fmt[2].bytesperline = round_up(width, 32) / 2; - pix_mp->plane_fmt[2].sizeimage = round_up(width, 32) * height / 4; + pix_mp->width = round_up(width, 32); + pix_mp->height = round_up(height, 16); + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width / 2; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height / 4; + pix_mp->plane_fmt[2].bytesperline = pix_mp->width / 2; + pix_mp->plane_fmt[2].sizeimage = pix_mp->width * pix_mp->height / 4; break; case V4L2_PIX_FMT_NV12M: case V4L2_PIX_FMT_NV21M: - pix_mp->width = width; - pix_mp->height = height; - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[1].sizeimage = round_up(width, 32) * height / 2; + pix_mp->width = round_up(width, 32); + pix_mp->height = round_up(height, 16); + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height / 2; break; case V4L2_PIX_FMT_YUV422P: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV61: - pix_mp->width = width; - pix_mp->height = height; - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height * 2; + pix_mp->width = round_up(width, 32); + pix_mp->height = round_up(height, 16); + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height * 2; break; case V4L2_PIX_FMT_NV16M: case V4L2_PIX_FMT_NV61M: - pix_mp->width = width; - pix_mp->height = height; - pix_mp->plane_fmt[0].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[0].sizeimage = round_up(width, 32) * height; - pix_mp->plane_fmt[1].bytesperline = round_up(width, 32); - pix_mp->plane_fmt[1].sizeimage = round_up(width, 32) * height; + pix_mp->width = round_up(width, 32); + pix_mp->height = round_up(height, 16); + pix_mp->plane_fmt[0].bytesperline = pix_mp->width; + pix_mp->plane_fmt[0].sizeimage = pix_mp->width * pix_mp->height; + pix_mp->plane_fmt[1].bytesperline = pix_mp->width; + pix_mp->plane_fmt[1].sizeimage = pix_mp->width * pix_mp->height; break; default: pix_mp->width = width; @@ -638,6 +638,8 @@ static int wave5_vpu_enc_s_fmt_out(struct file *file, void *fh, struct v4l2_form inst->xfer_func = f->fmt.pix_mp.xfer_func; wave5_update_pix_fmt(&inst->dst_fmt, f->fmt.pix_mp.width, f->fmt.pix_mp.height); + inst->conf_win.width = inst->dst_fmt.width; + inst->conf_win.height = inst->dst_fmt.height; return 0; } @@ -653,12 +655,17 @@ static int wave5_vpu_enc_g_selection(struct file *file, void *fh, struct v4l2_se switch (s->target) { case V4L2_SEL_TGT_CROP_DEFAULT: case V4L2_SEL_TGT_CROP_BOUNDS: - case V4L2_SEL_TGT_CROP: s->r.left = 0; s->r.top = 0; s->r.width = inst->dst_fmt.width; s->r.height = inst->dst_fmt.height; break; + case V4L2_SEL_TGT_CROP: + s->r.left = 0; + s->r.top = 0; + s->r.width = inst->conf_win.width; + s->r.height = inst->conf_win.height; + break; default: return -EINVAL; } @@ -681,8 +688,10 @@ static int wave5_vpu_enc_s_selection(struct file *file, void *fh, struct v4l2_se s->r.left = 0; s->r.top = 0; - s->r.width = inst->src_fmt.width; - s->r.height = inst->src_fmt.height; + s->r.width = min(s->r.width, inst->dst_fmt.width); + s->r.height = min(s->r.height, inst->dst_fmt.height); + + inst->conf_win = s->r; return 0; } @@ -1229,8 +1238,8 @@ static void wave5_set_enc_openparam(struct enc_open_param *open_param, open_param->wave_param.lambda_scaling_enable = 1; open_param->line_buf_int_en = true; - open_param->pic_width = inst->dst_fmt.width; - open_param->pic_height = inst->dst_fmt.height; + open_param->pic_width = inst->conf_win.width; + open_param->pic_height = inst->conf_win.height; open_param->frame_rate_info = inst->frame_rate; open_param->rc_enable = inst->rc_enable; if (inst->rc_enable) { @@ -1806,6 +1815,8 @@ static int wave5_vpu_open_enc(struct file *filp) v4l2_ctrl_handler_setup(v4l2_ctrl_hdl); wave5_set_default_format(&inst->src_fmt, &inst->dst_fmt); + inst->conf_win.width = inst->dst_fmt.width; + inst->conf_win.height = inst->dst_fmt.height; inst->colorspace = V4L2_COLORSPACE_REC709; inst->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; inst->quantization = V4L2_QUANTIZATION_DEFAULT;