From patchwork Fri Feb 2 07:03:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jackson.lee" X-Patchwork-Id: 13542215 Received: from KOR01-PS2-obe.outbound.protection.outlook.com (mail-ps2kor01on2109.outbound.protection.outlook.com [40.107.128.109]) (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 AF8D61758D; Fri, 2 Feb 2024 07:04:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.128.109 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857463; cv=fail; b=SojVPvXM26z5fAXk3G1Vy26uClSqGf0E7OEh2tywPH46D6r8wtGqCI0Sr1ujGfeBhMfBkcSv8lWN96AOMq8hQDk1Eu+Ph+v34mHfVV7saQUtlIGxF9Bk78hFodUPE/hJxY13Py5Asnq/z/yfLdPoQlMXe9ub1GQRQdTmIZJ3Hbs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857463; c=relaxed/simple; bh=JIhvGfNywtwdrHhM1QNneERXxrfgWpuWXUxJ8ff+Y5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=inLpfY99PZ3dOjIowKdP7+cr6DK2OgQZkVIXhqIxELvNnsgvKwaeQ0ITmnd3C+W1Fl1rHamcY2XZInb8UnAzv8QFWLCE4evqU+y6rfRZKwfcL6OTZa+2PLv1+Fc2NclHCrge3W85oV9tlb/neJreCjqD6aONDIWEhXgdNVEWXk4= 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=GrqkZQIj; arc=fail smtp.client-ip=40.107.128.109 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="GrqkZQIj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f7YinEGEtpePtfJjIsUuAQWoHIKlJoabKB051iaYWhHnl7xcU7uSvbR5/qX2TEn+PjV9KjFkJf1T3fTDST6ikNWyNyoGU/v6i1mq/BwM0ZTSaNzkVfC5vRLW+3qlSME8BQqeI9fDL0vVGVwhFREDHeCAPT7w/fQSBTXEYxeUSRWJkkF14gftpMttbbbwEQ5sppi47WZNDHPxCqthlfUQkDcYLlmdMSdl+FbLl4cRuSCnsJPfWAqeE45HsMaX3Vl6BdELHhlfUNMKEi/po49Gpa2Gp98z54Gv0s8lp5zuGBvYqSvAYrv3L848nYBQ6XWRNGUYJt1gERitLdkF3GNGeA== 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=CuqyG/8f96fGfFvnMHtjvfX0ChROj/waUEM4zMq26ZXpeSMu3KyErlL3EncY+Oq3j6A0p+i80YwNCF8fYDbdgYa/jrD4JqBMiaRfHPNfnvDF0GxVAhOTHckJ21nEaXloxdZe9kw+1bX6RvDdm2SLpNmPOjDyrWq9TITZaOyz6FtgjYoQKDOvl5UQJZaAjqUp7GlZWjki50NLGCpC38f92U50PxsgxUAN9flljmBG5cUzZ9K9St2RD9U50lCkFCutKi7yUfnwN/PrErpfvSCSGGwt4p7Tg3wxBDmTKMq8pAZa3AF2jrWDhWNCDtStvL//fvxbgz9SLMeRMSuO1YGhkw== 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=GrqkZQIjHsjaa6FP6qtKeJhd9fdTc3Xhe3x07V+B+lQ93nL5flM66jNBzgDGjnSLboOLaOdQzfXmSwQJUDNaRBXOelA06O/0Q44cIhorrTTrWPkNit3FwXDokQxszE/9g3NMSn01QaMPu0JmlXkg1YMjRgTKTlWmy4okg15UqFI= 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 SE2P216MB1425.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 07:04:15 +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.027; Fri, 2 Feb 2024 07:04:15 +0000 From: "jackson.lee" To: mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com Subject: [PATCH v1 1/5] wave5 : Support yuv422 input format for encoder. Date: Fri, 2 Feb 2024 16:03:48 +0900 Message-Id: <20240202070352.14307-2-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> References: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0112.KORP216.PROD.OUTLOOK.COM (2603:1096:101::9) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|SE2P216MB1425:EE_ X-MS-Office365-Filtering-Correlation-Id: 59260c35-ed3e-491a-259e-08dc23bd2a6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o+7Ao9IJYHKxPRk4jd9PQr7TdOkoNYzL8HlmssnnRcgWE5n1JuEu9Xqgf2vUH6WxPugaH9WuyfNn7/dA6a3vLFCReR4O0ENYj1yXiHour9Z5H6Tl2ZNEHsZiQJ3sXmX7JDkzaWHUOB4ZzA3SNmPw7umJ+ymgZ9EBcQnzlq6mNR9CPtjAMsl01+us+emTPl7LdPLDyQWbGG3h9k/EPEB9V+dEAwCdeV1bkFOdoQzS05PJISWZALJa9O7iviGzwr2YdQkI1GBVFwNe0CQka5Xl+X1MBGkQ0GkjZr7069F1Fa6rb+T8N0TFTk6NrTekyBsKW017mDBTFJdniVE7NzZ/UdNxK/JI99Niua7qHWdsyOzRuRuqQm+JbBvelCYK39UGwAy3nlsRmrBKdSEukQGSoC2unqNcUkvgKw7KySbYcejj9r+1EJ43t6vl7KJk+vc3FHSZ6Jewy8AfQkVO5Y7U42DpHo87EftuXogjUtRGGui18bsXv26omBk1G0+dyJngKxjj/7E49IywXluV7MU0rPjFIswLP2X1CedxB0V988/80FbVEOROal0k2WZvXfHNzCtiPKuWzA4Pw/NbPvziuPyvDLKGkvsVsgx9XSLC90X485uNomnx1LdAiMUlUDh3 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)(396003)(346002)(376002)(366004)(39850400004)(136003)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(66476007)(41300700001)(66946007)(8936002)(8676002)(4326008)(5660300002)(2906002)(86362001)(6916009)(478600001)(38350700005)(36756003)(316002)(66556008)(6512007)(6506007)(52116002)(38100700002)(83380400001)(6486002)(6666004)(2616005)(107886003)(26005)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lVbBILO9MPy5pvVftWy3iaTXoTMYV2GCCpKnzMsrA7vRxVnsvWhPAux775sUQfr/iyo7sh0L1e7AG4by5Rtz2KCP7XB8q5zmXO9S/jAIK51U6sDo5rSV6YhYRCGSwmrLxxOrNxHkTenT2p0ERwL4q6TT6G1vreySbzp2iVY25CxknG2QU324sO5NnMt7+Pw50Oq+NwXDxoyyw/KQPry+wA3FSRb4inxAOn1V/U6OPRGIJJjlfM4E4AKdXAkFVBTwh/KMPxfmLIRILt6yDYg4XbCt8hTnvTePWhS81OmnsIqBIB65Ij3ZES7xqNe/sThKz6ZvmycLX2H8rh5U2CJneJ1zuyqitq1Z/BKeGhf0zIq+R9LnT24p0HX7sPcFlrSUGB8gaxHzWxYlzSrzfiszvcYZFDC6n6lOge74cTIcybRh7wGa1rX8Ne3p4uE7PEGK9JA4bfWlmr9Aiz+7hTJeI6gM7O5h0gs7C1pJGFEkPaaMGRO4yMlqPDxrFtqhKCZS/T6+SS5Gnm6hZundwFH6R0wYWI8xXGQfbfVKpbr+tc+tWed0A2+CHe6sNE5Sn37QQH368ci22cVFMnAPn5VSsUnzoE4/KeVdB8JHqoAoKQjCH776Mqz3dctCekIKKdFhh0hc4MpRurlnvavw+w4pIi2fqHudXMo0SOaJKxNAbFXJiBkTGE7i7Hm0goQ2w8CcpWBt8JDTYTm2aFXPMoqrc/Ph+TSdflkqqG0Xqoqy+AwMlrkH64dqA3jPvw+T15Ceq2F7+KKRDDi8USkLaEv7nwxSQO2LC6zaD1UbyfmI9O8AuxZsZLaahjwShaY0C8u9+FnACKQzkNIY4AuOQlcSq42vjr0MBUzBqwXnlFnagL1OxN/8PY51zchOVMgFGtALyXP1b+nzuVuvsunUYUBVQURMnyLDYlqvCu9S2682zZF1/bwhOZ4H+TzaV+rISCRpADdoRXSy9t/+L6ZozyJ0t9lajV1P4BtiHspMwjI2Jly8JJPMtQlUMn+/NNHb+uWu5WDBvbahDBmMow9sjBK3UW/BDji/w3V0A9Cq0KrHwQLTR95EwS/Ej6odF0Iqa43KfbW9K33rgVndI/En6neE/Yz+4K0GNELTV1dyFsIebm4/o53mBO/wIrf8SCP9uO1t6TYGNrP7RNscVSoW0NrXNfWfCiJDTbi0gokqQgtjNhjmdUqHpL51OGqTLSnlsuNVuYaYpnulfzbnNDE0jTnrUjtddbIw/MyDtu+7lbNXs8PN+UwxAhdBfvGIJXtRuY8Gh2qpxKJ9eHuVpcK/Z4/j10T+S21TLKb9UVUwuYbob9PlVy6CppwY6fnSO9L6AJECo2afJxEptbgPLdAqgU+Vt/cP/CWhaUOVbGm5PGbQVQcsfjPBDvngqNNQiLCpibEtufHq+2OiYF0bmwk5sW9cfflQ8ZBy9mlbBMWl0vFNjfLJTe+RrDoVVbi8yImeB6mCxNHbmFsLS6zgKw6DA0bkG1ABKo3wofJHVbxN2sd//pnJCC36RB2C5fMPZsQhsDivsQ+VoyBKveqZQy/x9dpINvLh0G7Cvt6KVOtoAZGP7fBtJR156RuuUzl2NxyKfkVJTQw+IX9u02soCJGBxjig6A== X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59260c35-ed3e-491a-259e-08dc23bd2a6b X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 07:04:14.8194 (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: kLmg4xrgM9umyduYPUVBiMoxW2hHxWOvMgf23tHvvTrnDMRMuHhfaTLT/8qjSk0Wd2DZ8JMit0/rCdeh5P+MKArOEgPq1bRDlEJa3WfF2jU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SE2P216MB1425 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 Fri Feb 2 07:03:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jackson.lee" X-Patchwork-Id: 13542216 Received: from KOR01-PS2-obe.outbound.protection.outlook.com (mail-ps2kor01on2095.outbound.protection.outlook.com [40.107.128.95]) (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 D0E9D17984; Fri, 2 Feb 2024 07:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.128.95 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857463; cv=fail; b=WBtvf2s2J8NYDjSnMibMq7TDZm+av02qrwnwjN/kUQQpXmr6ot7Wb2SVsbkODr1TmEJHO2kvrwCe+8OnXELLBKe1mXXBcG9gpUl7Wnw+ATqMC6Dven4kZmaWRlVmyO9kQfRI2OSN4UK/nZ0m1WX5kgrRrezemq+mdZdtQEI6koY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857463; c=relaxed/simple; bh=X0yfwrshsp8er0k1tHV5dMdkLO32f9I0607hnZSGlLo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bcaz6VVb0oe8LtRHKNd387UvvOQ9qZl+BchkhjCTl3iDine2yB8EzluucL6xayiIW//PvB7QiiX7LcZjjEswMlMDvdaTA7xrWj2Pv+BPVsnFjvL8+mvWp2OxPegbZEg7623oHn2OoAsRFuyU0V1w3SLbHe78pLkvxeCw3lzt4v0= 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=ZEFo14+Q; arc=fail smtp.client-ip=40.107.128.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="ZEFo14+Q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HwIY7ByWz8XToe2eWtJjMTfjrFnA0v2RjqKFGygsYoPfAvCgH//Qjs6+8OvNnFQEZ8It9FdbFHgCAMP6Z8n59O78Nt6qbM0mAYH9ILCw2+kKEGvY7AERlXxwwzvb6KOtqW2ZHm3B8p3KM0RO8HokblfqENaCSdTRbhwnGUAfTRUwaFSzhK4tawmNtsiNMamwesEQUEEP8PG2W+JRQvJoZOiBqvjzcbFxAogSvRCIuYnehrJbq2tKuQBxUmyn8EXpxba2Bc9ODqD7DaKGdUU+12Tux8inNPZ7dvhkGvI1zDFb4p7v15l6TKgHeAbz/7HxtdfFXnAc535aOHAb5jlj0w== 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=ageIZhaAp9W42WOMuvQn6hN2euI0aFHbjwOIA4CwMgDmhmMn6nFVKai92u0Qrh4NX8BZzEpK8mDHHJ+N+7X7xgQ11m0NsmcxtaGV1+pxoeCLjMESl72WtLj2c4KvHiHGuqLWd+8sMOPCjHr9x9KaOGwkirko2VpDJ0pkSEfZTor71zg3ajnznZ9xX9r/773r2dWJxKWH+V99yX5qyxVUR8THLrETeSDw2jbQQo8Y5fyTUyrrE7HnAMLZmm9ag1rLDsOOFvnYub/h9vG9/Gwe9hY+3g0IhGZFODtEhot2k0w8Wv9DHNRrGbpXQLc40zl/nzLe2mL8xpN681IbK9f0lw== 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=ZEFo14+Q7EMOczCHnq/gBvbQ2a36TeorWpTkV6dRZH6tY7sLPSeiglbDwwFxZP9tTmv8YTcUxAvX8Ca1HlXD/1Pti3CRP9kcjQDfcuMguZPkv3xJspSCaVvWDXrT01pVfDAiwbVAC8rmXmTKBkJ7llRyexE7ui2tcNQ1bn/CKHk= 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 SE2P216MB1425.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 07:04:15 +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.027; Fri, 2 Feb 2024 07:04:15 +0000 From: "jackson.lee" To: mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com Subject: [PATCH v1 2/5] wave5: Support to prepend sps/pps to IDR frame. Date: Fri, 2 Feb 2024 16:03:49 +0900 Message-Id: <20240202070352.14307-3-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> References: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0112.KORP216.PROD.OUTLOOK.COM (2603:1096:101::9) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|SE2P216MB1425:EE_ X-MS-Office365-Filtering-Correlation-Id: b684db14-bf8a-4ff8-2d7d-08dc23bd2a8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z9iFqT+QUBPdDXqYJi73bLopT5JFfJu1E7kK9OxIIFw8onOWMpyOcAXjb9jLco2RAz2InqEBbVw91tZrqWtQqvTTDlykY9nISDguCIXfg4C35z2lAHK5OMyWVQDHpPKAPuCx/x9u3hVi0/pF+rOGDCb0Znwdjda3qZIJ5PqkWKgksd6aHYkQnG2PzupTv9rAUMsPIeCaRbAqVtDoVUve3A0vxKqJo6H08+Yg+P4Xu42aEa+7uQqQ/bum9ElONragkayhuECHC41NGzEIWcV2qKBNuyRqPPQDeE21eRuE/rkTeA6vzGdrCKjBJjldD+z0cNhF2wf47aXSppK3SFtWO884N7e54FNgFJ1gnAchdd19Kgi+HY8Qo82NIv0DCn1lTKXPt5cZiyxy9mrCVQ1HVIgyFv0vV/3sVt1mWM/SSVHcO39bp+6buuGBSMBZco06c+zl50VrO89N+jD2LZVQzhnzOL7/ZAIx1i6zcIBW1uyKfKckGHtqA7uf7MNLJioo2z9dRjnbNrb0Xwp1ozoyr8LNf4x/2OY8GG6tz8sQK3PwYzh4P8iion7ixnSpRsk7hLdhc8nJ/19eH2xGK1ujXbEfD4dZDW7nG1Z/i5OvHyedU79ZBttxDQyhXSMfjruY 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)(396003)(346002)(376002)(366004)(39850400004)(136003)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(66476007)(41300700001)(66946007)(8936002)(8676002)(4326008)(5660300002)(2906002)(86362001)(6916009)(478600001)(38350700005)(36756003)(316002)(66556008)(6512007)(6506007)(52116002)(38100700002)(83380400001)(6486002)(6666004)(2616005)(107886003)(26005)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uqd9SLV4/ZhgsMKr2vyD/0BCyjDLlu4T+MvotsYTofibK+qtqlVkAOHyWBZmzkQNsG35GsUfKcXZEjTYpAFdRRXN2m5Sp9RnYaOVPtQZqHdObJI+UCtsL5VRuX0atl83AzQCSAtnY82xkgxWEbJugM76dewLvoYzcnruQ6CdA8zIf5BkkIV1B+AmeiAC4SNiNhCpzaU0yyjMtCCBy4QhV2oAZr1pb0RmiGHQdHv2IldRS+m2htYPKx/A+33JF9Wlfi6IcA6RNZ8Q3EIH7fWRZrM7m5EmGi2O7OcuSERnrR4zXUmdTykeJ7kg2ComHjzvjCiT1Phqwxv4zZ+qrkShbF494LOJ4W0TPUcbMZKI3pv6mUbboPuZBgvqodof+lKLtQfIedt5yW4ou8zp5ah1Zgpf7EeHwZSwzFTZH6YpmGXFodXwHYDr/ZnQxN0/1XjWm454udxV/W1/AjNx5B1588Sev27GUzuuUvX3J4jHFrDyn9kpgG8QrOng29D1ZBs853QZOaBU56FkX0ivLgBl43YpkOtC4caq5yuih5l0jH9QXo8HZuIeiTMAOZgHOk0FQw92rOwVnETJhzeM1HqWb+cUTm59S3KMWw/JGGQoGEUNFiAj0engWgdGd7kXk3cNzFl4s66YM/u1MB8RgnjpWkK0FjZ/KykowJHV/Gb0FuWzMEAwKS7mVK3JDG1JlFDFqJpz10B+9r+B08zh0qhk8u3yLCnZP/PtGBi4zHzMILS5JKmp4tsIWHFHAxzvGxA6xaJswMP99LCUvAih20/OCHnUHJvpt69eJtJ/4nhwaDlWl3YcbLGjP/oRJBTRUWKxVq7GQ1bjbuU3HFGvpaG1FI+vz96Q+3ASgQgk7ldfvQpSX7TIelrWeMcdr9TVN9g9ErBoRY7lJkb1rzIQLdWude5WnJIZdIk3aSRs4sODJN3lvzskfqfJngRFZ2KhbjvCFG5CD79m8bfUoOEss4SI0K+0JKsZIpWKX/LWOKiNWvPI57fKqObeTYLpWty4iaHzscQYg/5sckgpoSiV4f/e77qEKxA0Ra86pzmK1K3Af+jJzD73V4vxEim9C0iWTNarQ0V3jHxX+/M6YcZQ09fbz58STqKhSE0kr/S+mBlxgL2HkTE4wPByx5bizJeOvoworqmRln48Vp1jVFKiqMyCNEK+TkW/fbjjDUJGajUAdaXMIIpiECp86IiaJvXfwtUCK6msaXoKAnrPedRa8sHoP6j6QPstzV1GTTcbeBMOFWOU+NjLv/e8++hlphPCkh2AVlTdWrXWdr/zdtexXpuLaYTNo/ysDPWxqcAzx5RgR7bpZ4RgzMkQDSfjODM9MH1K9+nMl9SQA5ER0ySWIABD4rVSXSR+ppiLxyrwkmg1lgTzazS+KvNcE6VxAnQAmxnCMyeIlHIRaOdQapp8plVJLEvnTmblYyTh3otvAikCnHGWbjyJxWoMp4bGhRVLuCgHVVQVbuXXmKQhV7KW+h2Fgm2tILp5IvEy7nlMkcuo3xKqPGwfFYm47Se4hs38mXV3DOhRnPAxR3Cnawkcu2jYHhpMze/Au1IARZsS/3mU7X75UzVrIGcfXZF63n9YCkyg89d7GYowef48L98HCfSIpQ== X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b684db14-bf8a-4ff8-2d7d-08dc23bd2a8e X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 07:04:15.0893 (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: PaVVwZzRphel5FC8jeP0I7vn9elF4ADaN56Rw+ZKTLUyUP2Io+ORxXuvecqysfYCYZ72ri0g1OWK4UdjSk/aa8/KNHFH8ONnwIZ0/+9VLfU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SE2P216MB1425 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 Fri Feb 2 07:03:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jackson.lee" X-Patchwork-Id: 13542218 Received: from KOR01-PS2-obe.outbound.protection.outlook.com (mail-ps2kor01on2095.outbound.protection.outlook.com [40.107.128.95]) (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 1D0AB17BB5; Fri, 2 Feb 2024 07:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.128.95 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857466; cv=fail; b=etjcieIEur6JvDFJrh6jC7QWM2Y4oVhY4cjVCM2+vfdP++HWCS5sfWWpO9UFJDVRHwU2lb7oNJglsB5lNoMy8PAykno9Z2OPD/lTbmikOvnQjCC4zlyphwmn31FoEgwKu9aJCS/YiyYoAPf7x0Z2iFV2+f+6jXOWktdWui4G1ZU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857466; 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=DJidJ5GzDPXa0EurDyu+XWvWTj0eyZ/Mqtu5GsN05LrxrGfGc+ARVkBf6uob3l7bMY5qhpKM+IG3sIxNUjHUN7T6ez/7mWyBpP3KnnEY/pjErqK1NWqsucJW2hkaLwWAQ8/fyy0aJEuxpaKhO1EDCBnXIhReoz6bVtgIv51fedg= 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=Gkq+kGR9; arc=fail smtp.client-ip=40.107.128.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="Gkq+kGR9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nZ+yjYBzLno266sRDOMLvLhkpIkTf/owlmgvyahJGaAmi1Rg2nwrlkTJS2B1ZLFQ8yUGxkzPcSwVh4wsl7E2izYGIT4pvLDJwAx9FQIkaroofucq3wuWUWwV6egQT2hTb5Qainz06rGsDLANcqr2aI6NciplgwcURVxqAq8orQUsTD6i1DA+Wh/eSuXZ8ELHhnhfavlDEHXzCSI+fBXtsXUEWUGzU8kAv0jBs4i2+tWefOrl6FEhYSYFyph5iMrBH1Rc+UMBVWWFMkQQ+fWmTgC2BlEfKxDh6vpEW79f36L69fpLVNx+8wnqOQk9q0P7FG4UY2/B7VnP5Lm6zliWmg== 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=mV6Y5i+QaOew/dGwLutdo7cxBIiBh5H/R0r4jTwZ9FZYEjcI5e+3hCz9x3eGOIcODxODKAhQi/dPieeu9eKWbVbdvUofCvMOmYzVMo5K7Y6/SIZw0LgqSL97adghaipSvnXB5tedxe7vZmBg7nGkhWZ4uqvWW1SsNJWJ0Bz1RmasmphJ0LGNZ5naYyeY1m9aiPc7NWIyv18n40y4sMxPHJfYArXGQq/V+iseVDGmaJpKy3IqrkU+XSxO4Jmq2M8VFzJzu4WvACs19eBLmh2OiJf+rtAI8u/yCfHOqowvDx5pm1YmdlWZX4ouoVtxXpEJhDwwpNm9MefgN3KNhKnPWw== 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=Gkq+kGR9Zki6gZOinScijHh73+uuxvQyy/LqMEhQeLg/xXpZtPmfXEY730vwAFzcLGIBMYSl5+1hG/7JJmyA+obbk0xuKOGmSYShtGaFv5cgFFnko5V1ESdcSZiJQ0hE9EYlRoOTPxeQxEiOJzr3outj/8VysGERV/zWpHHW3zw= 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 SE2P216MB1425.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 07:04:15 +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.027; Fri, 2 Feb 2024 07:04:15 +0000 From: "jackson.lee" To: mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com Subject: [PATCH v1 3/5] wave5 : Support runtime suspend/resume. Date: Fri, 2 Feb 2024 16:03:50 +0900 Message-Id: <20240202070352.14307-4-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> References: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0112.KORP216.PROD.OUTLOOK.COM (2603:1096:101::9) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|SE2P216MB1425:EE_ X-MS-Office365-Filtering-Correlation-Id: 28235bb9-bf84-4473-3c4d-08dc23bd2ab5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vWQkwrxt+5S4sMIILK8nGb0+JOUrVoSj5uQMjL0Nk/MdkMI0fsaZolmT4lH951zZ/eYOfNOSq3RnHQs1TPF4KXM+hE1sc5hAWkgkVKRCQ+phNeCMPlROd8kpG3XfYtQNztrCljxFEbT97gpbGBvs1aq2534aXJ8hOjczMRlArTRRI24Vb5xYlrOidlS84cRpdLJcw9wp0tsQIxOXpLy7G8zYCkVlI433RWrlG5c+WY78QGWBpY6aTYQm6T6GVlzYTvVWpq3pGFffJoLyYH91U+lUHAIFPmrfsBDe7vcZ075VxyEGIktrC02b1pgUpA/T1Ww8EvJF1FXbTQFGEs3qahrD0d1WMZC7+26WMeS3XYTJIic5vT/VA4JfGq+2tqKulE5E1DaZNbis6xISSh1DeGmDRXoCz/UP4PeYXx+aoAsxAiTJ4xSegoUE+cgnA1DZtqa0Dsem278HLmE8KEOtQspz0p6gb+tVjCBSxK5Qh2OjKf2heeCMK2nhc1pSHSJeIfpOiNoEpec/O98Hgt/Orc9DSRPxkpahsdAr34ebaoX9gN7mDIE3mYaK8obb49yieUXLZ3R3NSc0UGFuw2mRDqBl3lmWY6hk1I2izQmbBsbAnifMVXM7Qcz30GpaQbkH 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)(396003)(346002)(376002)(366004)(39850400004)(136003)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(66476007)(41300700001)(66946007)(8936002)(8676002)(4326008)(5660300002)(2906002)(86362001)(6916009)(478600001)(38350700005)(36756003)(316002)(66556008)(6512007)(6506007)(52116002)(38100700002)(83380400001)(6486002)(6666004)(2616005)(107886003)(26005)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u1hjulIpDpw4NIRl8i8KGQCVwwaNNQ73l09bmYqBKgCOMLpF8qYp2wzR/rVsUDg0PmegQuTQm9jhdR5MrxXXxjw0KJiDkRlk43vkN0yQxOMP8B+JbORlmbSrx8aPsjua+mYMZDU/RjdNRhHjaPGEYHpTHUzc9E5/bZ4s6JU9B0E3NUcBv2FnBTMFIPZJEdcxGRj7w+c5HhcTJKGOcxYOsSAEBESwxjdfhVWKpr5OO8frPNxTilrP2lSPF+JY9xOdVMIAhJK//rmyRXYy0XMVGTEUwhWpH3we840Hu8rVMl//6bsgVksgL7K0VZZmr4OjK0SqvSXj5zFNrjneKwMqqXwN8hOtmN6G+TQM1Kx354Mn2bbkuydHE6APsKoeJ0mu7qLMic2K8T1fQm/XGIqxKYEXI1M7MICUz5K6Ezy70LIMmPXPFzj5AVPxWSYjm3VN5DLiJ7hH8FoSBalIGoXfKVvVNiUjTmOz30zwoj/XAWKz8zvOWgElngZH1C7KnmRncwxK7ONWc4Iy81K/AYLSStZ466+DocNEw01J2q4sTynEdq0kGJsaxJD/cMwGp6V/l8roqwtkbtysO8As2cWbl3qymPVk642Wes3iyfF67JVBoHYdDkgLb3nDXmFRuct1kcuVlq8aTJxYRTjm8sRXd+u8NJssjc8v0k5FlqubEJACUjBbhdNoRUB08HN73O7NxlP7AMZuDGM24u2vEpv6eUEu95mTyeDqJ5tcclwqepqVmqTxdyFWVDyABmzt3CiZzkXXZqkm1Qd0cTwPVMzdEfI83didDSLZjyoURrQT4A/MuA5pMcaXIKjciJfhj86MuKQq552BiiAW1Kof3Wp2JWH2AE5lnxgtQOzmBQpkuGYOIszYvS3kfAwsYZwjPklbvqN5P3hqa0NP4+Vv6Df8uY9tcEGgBBLUo4u9MFHBySmQ0Dm0KoLdBFbhKs6UPfT7bvi2K/I6skLaNB8pTqoTVtp6AYuVgD1W65vxwZNQhWJBSJiv2pbQrm5Ed9Bimbcgha6nAJDKuHSrmYTQBkMcx8p8+7JLfQJUZFfni1b4npAZ/xGDBxQF9dHLcryDLD1WCe41mLI6Wzk0uKPE3pZOKD3tMjwSzXMywFYSEqTcatVS0txjgHueZ3eb8/axNs8GA0sKb8ky2mPiBslqKYoITmMLb3hYQlGsyKtmmtEWeVp/GCOeh6ZRjCcbrUgcT7QXhcZpkBBJNcmHS9y4BY+PuJXshi6b2EPslwceKg13fmcjpHVmIST+3AkCKGvRN5p4arvuldtuHPaCyG81kbbSSdXVZ3jGkFKfhlZ3ldxZkMWYnQZmAtyHkb/gort8WUEEioEP5L736yaolTvuOsWh8dPojvrddL/+6mkqO/RSiYPxeh0I+ObcpdkidosFCAYQJCBu2I/F2+mnitk212Ear5M/KLi6jHcNLZwSl4NF+eWeHxb2dESSD5m2r3JVwF4EiPyo28h90PFchR7hgDbJbWp82DaYrel1v79y+Q57qwEU7RO7IMiTV7S0iIl+NWwNJZ7dSt7Yb6gnIuzfusgdOxpiQ/AFA2DNGAx0KF2D62fsDjXiyC0aDwoWCqXjOSr27Oow3hZyw2iikmYODFhFe5Fliqx7p8UdfqCTDd8dSrc= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28235bb9-bf84-4473-3c4d-08dc23bd2ab5 X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 07:04:15.3239 (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: LUEVIgr6VTySA7ihW7M0UGIYb5dBCHllGRW7VlRjTGi+p9SzWrt/CwMIzJucJy1G7tDDYB2T4QICgqi5IAkI+c4R/nLV1CSquPJAF/UhIcs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SE2P216MB1425 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 Fri Feb 2 07:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jackson.lee" X-Patchwork-Id: 13542217 Received: from KOR01-PS2-obe.outbound.protection.outlook.com (mail-ps2kor01on2109.outbound.protection.outlook.com [40.107.128.109]) (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 DD8D01799B; Fri, 2 Feb 2024 07:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.128.109 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857465; cv=fail; b=rkjfK985zMTGngBnYHYQFQ6wMKlUANTC9rN0E1af/MqJm3F5kSgx1JzJaCNNkRJ6csOhU6Bk1OqUjLObo3kLSL2TXohYQWQohVL06tmG4VOPnSQQS+nRmkcU2m4vrJVeiXg4V/Ou13iK69kwGVzuR6iN0lrTXFrbKHh3l2tSid8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857465; c=relaxed/simple; bh=uXCX7Zb1YFiWugkY/J2GQqpDoWQa9jzsN0oPdthfgdg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=kvsNHo7JNO/DM7rTovSTNqobyVyIetMSJUeWYrITTgTREA2bAjWsnfrNIYfjN3hOnbZDUEWS98nvJN89bDmECUnu/2wFwLrvwQrEyHtpSHUlQ/E3t1RNt/yRfAkso5mwCgcm5eoUzrtkByvTzelHpvN94lnSl4SjZH8Ji0WKRFo= 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=e27k0HW2; arc=fail smtp.client-ip=40.107.128.109 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="e27k0HW2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aoG6eZyolOFZYkjlpmJzdIEkUqFld28NZt2/z6wv3Gdas79OkezAvhgnyBcXAIQMdrun1VI2LDSzgZEhHLIH0wqZVeSF2Zunk6tnmDb2/i8nRZdSgyu77HbExM6o/0acDjX4w35pivaPGwa+6HbEAtdWaE/rRoURELKJt6SwwqKBmL4F2TVrBSjd3erNZNe3xdgT6E5GfO51dD1zzIUpwONrw587r75sCzRm1F2A/xwvdp5z6fWiUTWLZxZihJanD9pa2GlcWJb3/SR74fsb9j12ZZr+Sw5N8FysLP93wsQGLQbn5KxspwFdEOG8efyWIiQQJE3YXDQCNtuoI36qow== 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=HWhRJLfD0YtdtMQPxy8kjWI35mM/okkIxLGCZP7Tzo8=; b=PBHsSd6XbQTuEXDozhPwDCbB6RWb2UduCpAtqVwAPw10OjqBDx6MtS1IqUOk7mdoiY5zxjSEE9ocviFGSmCrBx10POEw7BszURKN62bcRboG6ieiZf4tp6mGUewFTI7evSLfF6JOaOygUmAKG+enqYKhlGHQmTZ/Dk9QYoj8+qgeI4tfgwwqraAN0mTmsXHmUGoNQVjMDNuRbA98njw3LVGN2RIvwQ5HzjyWPu+HIR76D9JlG+ygOuYczc/8HYRszKn/UUtGHwJu8VRUFqtYac7yRSjNTl7tcEq80GcnbMxAkMlrVuUimFbnh0YN8Bp/ikTzuN6lfd3hL5N/5h5g8Q== 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=HWhRJLfD0YtdtMQPxy8kjWI35mM/okkIxLGCZP7Tzo8=; b=e27k0HW2/EwIrn3uzSG/GYKEVxm2UMJ7+C8J8pFsebk06hsiDwnIjHTcfm25GnGl4X/kCh1pmNgJQMwFwlQOgUlxdWf1ljGyrMlrwIv1j/AccClwuKbQQ8pgwdi9KgE1vdsbf4J+tNaZQnI5C+xutoCqmMgP6vNzRZDjAHw3Guk= 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 SE2P216MB1425.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 07:04:15 +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.027; Fri, 2 Feb 2024 07:04:15 +0000 From: "jackson.lee" To: mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com Subject: [PATCH v1 4/5] wave5: Use the bitstream buffer size from host. Date: Fri, 2 Feb 2024 16:03:51 +0900 Message-Id: <20240202070352.14307-5-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> References: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0112.KORP216.PROD.OUTLOOK.COM (2603:1096:101::9) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|SE2P216MB1425:EE_ X-MS-Office365-Filtering-Correlation-Id: 69cce1b1-7650-4fcf-d9f3-08dc23bd2add X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+IwAhbEdBEOS4TH4Zld6eGCtyhvWerHwsU1VOIeuR6GswjzPGJ266pAGRw7qUFLbc97kCQueyMrM+nH7LYrP/6bzmSY667ryBEIq6Q4miCJNm2llE9pBk/lFn5HazfGUP+MzwXQrTxKlkIzW87AMj5HDvjjgw0qzAj6kHFi67x54g9rlG9UAgMGBokZBCVnHq0mBi+H1PAihZqM2TsSIZlIKXD9MzPqk5+A4IAtLY98Dhm0rIRTUuv8ouggAImHpGpqeMT5eBs6/YfEqI9Eq9quCbLMXsGy9nmKYl3vWKfSWRTJ3p+qPvXbMuXjxR+09REZ6UN1UQWfThgF6vGMAR+Kbml/x5+B07LoV0OpV7H4GuMT05sCt9x43z03vj2jznBx7wuUu2Tv4KcV8s0j6ndcl0MAjdVPo4HyDw0rUK5EKhnJYtFmSbtrSTjgtZXoCgz8ocd0EEWiLazN6DMptXv0JN5dSN5nuZVzFRmZBDWnx4zTCb1De9G+9kpUvgGat4Bxm10KPPH/csnamcq2WjNsQhOjjDYE4gTfcTMd0RFEgojBrlA5fWrY0Z5/3Gh/3goPtZGsiQYRb9m8rn58LsC46llSmvE9/NKJKWDU4d/4knx3/TE+DKMMr0sCm+ea 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)(396003)(346002)(376002)(366004)(39850400004)(136003)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(66476007)(41300700001)(66946007)(8936002)(8676002)(4326008)(5660300002)(2906002)(86362001)(6916009)(478600001)(38350700005)(36756003)(316002)(66556008)(6512007)(6506007)(52116002)(38100700002)(83380400001)(6486002)(6666004)(2616005)(107886003)(26005)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M9V9wXi6l9kzUboFkHaQ3st6/1AB+Sq65BmWVjorguH4KmiJ1WgSkj6s/r1xescAoocgQ76v//4S/aWBVkGlv75LQkx5OhaujHAvRnVVyNuvzorV4J2hUwFgbWfEONbiA0euXfQYFuKBPXJqeCROovvnXjygZJJmiJDhMIjdSn/yF5S2/xV3nv3CXnaOE4p/3x7ggQaz3GP9YIIWyxeWqK5lfJe5oi/qcWXKMeLZeH3WLHbqS9+VYBot424rIqmQRzwCh7GVJey+c9RFvbExn5WubOERQ+y1xaEnemRbTzeo+owt3ozIJ9c9Pnxrrykb44A1PtzJVtEEfNTBesP7mXhswufX8++I2kUly9CFdqxLOGGn+yD3RzD4GCvuqJu7VCeHdcqr2jmVPY6d1yGysAG7jNnRHdtiWxwFOedKPHslqWGx2ChF3GWgD7cfXr6VDHsssgQafgp7xF+wQQIVDD2OyuemsMZXwYvWXIqCucEszZTWdH4eoX/UwkX80W8BIPfm1vHFRF7pz0M/peObA002s1vKtH8Xkc/a/DE78mGpyHcEOktq8UcvOjfkqAEjeFnbfYS60RROmSdeO+t6m9vb5sC0EFRYushVj2pJewp8nljRKgNmfSVcTRoFswqUoTTPd+62TuRjsFlNnUIdG68ln4k5zhPTJ0vMgYsN+bFXUo2ZFXbtORg46xYCNXwMcLYuEZ+BYtJb3PfdPlx+NDa3cAjHdOdd70DTUH2mrcCdeGKy3QBHxThAWsquTqVPPxtBZwdRK5fz7LcZBb5JL00TW4RPBYAwbSI3fp8ZXOU5rBlXK/KoJoHmaJBiv78ubQD/6cBJ/LMp2hEDe8wIYQcluwJnPQu1coSLd7zVSfXfZ4SRmwF6lAx8eOqIHXiE0hTcmmfBnNId8LiXbaAk17Co23hgcDmmkbwm+YraVpvF62kjpOqNoXHVwJgIw+IFQ0R8hRNmxNE/uczioXrIe3ptfKeI4JC3gOl+1EA+V6YzDbjPcuKnrgCgtLLectJeAdB3nwREjmvvf/o5DffQsDZEDn7rG3BeW7+OVSym8v1dTY58tS15YilFRmaNlrDV3b8OQKwIOz5Dc36Rn6nCV8uTr74GmwN3wU9WiDB5ziNwF3SAxOdtYLEMcZQUNza9bn+BvRDzY+tVApyDvrO7/MTjRtx8ChecaM8p/kc0HkPJL5qa4TDovOMPf0QejSzipAJ+ndJLeAoD0pEirSDvYmCw6s1CEZhOZ8Zzl1R2j5BdzPXm8kF56BXfpZLwegzvlMR5y/VQr2c6BzdSbK+zf5gQmSCI5pbMevoO3uuJW1GhW145ZMuDA5K/ZfpCGpbafesHqpcgRB1KN2yL4jTK/5rgc1XzHJAp9V4oONQRzGndFw4Ha1vWxFdhIGxU5XNKrgCjvYa2fahHgjl/l55cxa0bsqQpxtZMluok2Aamxm6wlcijiqSH5ph5w1sb7WbPYbITovpj2yK0byZB9FBoQDWafvhnidQTkSTUrTNbSiHEdOOsndAFUaTbhT6Ew21ov7/SDzJWBgYolf2AfO6FIP2qo8c6ioLeDkB5qV/dq5psHF3LHfEpcAGFcua0O9u4/koSdvE8bmFhJenQCub+5hRAPOneygW1nc512ajk/GQ= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69cce1b1-7650-4fcf-d9f3-08dc23bd2add X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 07:04:15.6222 (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: N3WU75Akh4BfpV2iM8MhqJil/O46lYyacE9uZPFu0ZF6lPmAM3nwzdNSMRMLTBYyG4VPxs7dvJoC6xPMg+/zCNNHl32P92Rad7sv4oekt0U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SE2P216MB1425 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 | 5 ++++- 1 file changed, 4 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..62be7cdfccd8 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,8 @@ #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 +195,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 Fri Feb 2 07:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jackson.lee" X-Patchwork-Id: 13542219 Received: from KOR01-PS2-obe.outbound.protection.outlook.com (mail-ps2kor01on2109.outbound.protection.outlook.com [40.107.128.109]) (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 D2BE917C95; Fri, 2 Feb 2024 07:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.128.109 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857467; cv=fail; b=e/GoxiM3nEX4wUedTJnh5ANzMoOvp2pgdnwG7YLp/e068P3z2zNsFNeVuTE2LjrUDUTob3QkDDMucFP7f4SHlDNw8dDTlZvTJasQQY2EYMliOwxPgnRxMLLd8rKtjpXeUL6EBS7io+E/GLQd+nFQgdy4GKiTYRIEJCjBDujbwVE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857467; c=relaxed/simple; bh=wPur5CDK+GPfnsOvrUL4OeptQ9WQk73AZtzI19NVtIE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=MdlCxavYrXUjPuKo6WbigD8Zle/ZeInlP9S9fjxCoJ7RXnu5W4Ue/WLfL0EnXamQACRN0aCT8zL5MTApaZHJXsjSzIjgFGUUQLoR+eQ5Hci7jfksJdTmQtvr5P8r8lxCPq+BzjEQ1W/30prAfl9u91lqF7q/LR2I1I4ldsULft0= 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=NykyLqtQ; arc=fail smtp.client-ip=40.107.128.109 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chipsnmedia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chipsnmedia.onmicrosoft.com header.i=@chipsnmedia.onmicrosoft.com header.b="NykyLqtQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=loBdTxYbt3+4QhNS2b5XVkoROwce+94pkabKV5b6PcOkI324oTdPQpPl4ueEBsTdoygPX71bihYlX1uZPwsnJPd0zmJFkyHolwn0Iz3S4NIJuCjhG110zlLWMa3obLdA5MYnrHT5AXRF7AZqSyIcQjMQUZb74r68/1UBGzn51XO0tIG5DODsiMN1VRtG2/PUsdb/lb1X8K8vz2ZdBJi3uXO+o9mOqVCVS6+lXJKf1JsIRBTNLMCk5IbEE/weClYIecMkGtPJ2xXrpUGV4APV62gwDu5MXJ9xO+eHXE5dPm2n1zH2kIUL0CEMTjmD+XkKQhVX3H3aH/vEHJ7R7HzMJA== 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=JL0/9A/M7Ksa1POnOCBelPf77EX94Zu9n7Sy+IcOEtQ=; b=B4XBp8DgKYQQSS1Rwawt4HeDArKT+5Exl6V7MEgeHlnmFyWQJI3jWidoDUsqZTH+Z6z0VPXtYdT2xgF0Ic6t6MBEsHkkcpg3PmhOgrVdr95RqmLzHlh3y7NLm5YqAo/r0UFHWl3EjAIl1vbi+Jvn3iFFcW2MZcTChOtwOps8ZJjjA4oGU5U+1TbYiq2HMruU3qa0KeXZu+xFd4HWlTyJSX8hLWV524nDtk3512a67y2tUyOVSgLLnQqZmwBaVZk8HD1en8nRQLt8egLPQhd5Yl+eRu2vKIjAJNW5ehIfHqKWDMcQ6gQBClqE/deTw+qY/+B8YEvQnTguiBdsEsoByA== 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=JL0/9A/M7Ksa1POnOCBelPf77EX94Zu9n7Sy+IcOEtQ=; b=NykyLqtQro80/XHjNb0Q2Cv4qRLjpXJOWDmhYuitfABUsZDxmgsn6jx8hdRzQtXgTP+27nEXY19K19g4DFFmzS9p3mOXdaCaqLIAscO8HCses42KEfhdqVVIWE+BdFRbq6oiF+umeXH6eOuDGu905tAGqc0BhTeYdh8+i2foV2E= 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 SE2P216MB1425.KORP216.PROD.OUTLOOK.COM (2603:1096:101:1e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 07:04:16 +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.027; Fri, 2 Feb 2024 07:04:16 +0000 From: "jackson.lee" To: mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, jackson.lee@chipsnmedia.com, lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl, nas.chung@chipsnmedia.com Subject: [PATCH v1 5/5] wave5 : Fixed the wrong buffer size formula. Date: Fri, 2 Feb 2024 16:03:52 +0900 Message-Id: <20240202070352.14307-6-jackson.lee@chipsnmedia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> References: <20240202070352.14307-1-jackson.lee@chipsnmedia.com> X-ClientProxiedBy: SL2P216CA0112.KORP216.PROD.OUTLOOK.COM (2603:1096:101::9) To SE1P216MB1303.KORP216.PROD.OUTLOOK.COM (2603:1096:101:15::5) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SE1P216MB1303:EE_|SE2P216MB1425:EE_ X-MS-Office365-Filtering-Correlation-Id: 85d4100d-58e2-45f5-9cec-08dc23bd2b0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6pvgXWu9hnc5rviT/w3TpDcdJZE1ZinD8heB0OgphWHE+IO3S5biRD8QtPOf3mToKeoTsAqr72oliM5DaWhfc53LT67lRK4R62+Xzngf/Yc3LGRYBaBQjdeX+Fh1BCpT6vRkYxfkFlT1KH14z5eDE2Q74XcFBUKUJUimSMtGSaxr3lVlDEeB4RfFjhjjayjYbDCVZhBzUPx5xalRIclvKry16ei8XSxcErPlMFno+AbV3UZ9zEzuUc4zx2RV2Kvt/nUI3uOUa5PvSTVurVTmE3Y9tTcu/sSvJvgOhZ3hX4UuXMT7n8MpreOGjSzClj0qaBRQO+fzUxm7s87MjNQrADsKMIC5qERXYVr6/2olIlrbO2ZOTfjGYI2WKw+07R6mUFhbf7p2yWSj7qvoYeoThgWBrbdJBT2oORI9YNTTDiRUKgY+/kq0V7kHklaH6F4jQiamv15D1u6u7T3vCjMlRt7nsAZjfwnU/ozuPNTG98TNYPsGUgSs5RXMWQyQKBD19oZ8dFnj8h/qYNSFdgshRjqGe/q9dFAvIZHRMi+2cuTj4JlquYfl0efkfz61bvRiY7HL1Lfz+iGGhM+yo0vnWFnhHZ0iGft8UKFvC21G2OGJOL1Cqh6b80iFtbIOqaQn 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)(396003)(346002)(376002)(366004)(39850400004)(136003)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(66476007)(41300700001)(66946007)(8936002)(8676002)(4326008)(30864003)(5660300002)(2906002)(86362001)(6916009)(478600001)(38350700005)(36756003)(316002)(66556008)(6512007)(6506007)(52116002)(38100700002)(83380400001)(6486002)(6666004)(2616005)(107886003)(26005)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mFthY0yGJ+diePbwQwclFWxNH4qqY3V4GOxAhZPIJ8DHTfJg4dP27gHPqb7XggLf9Zt1xGwfoWA1gYlflFZSJBZyepsQx8lPe7UUstmt74D01g75MGg3gKV6J2F0M8jmrme+Mi7RtTemDo78MV2OhC5ND8y8BvmJWsTxCHrPcKKfVy/NbqvYjtgnAOapdcrHU7AjF724C83iDruidBoNV8dp5fe09onX6gnakpXLJ0IIZGLz2k5lsdZd2wIe2eWtI55gQE4fQblrcPbeXcWDYRixw9osajhZVJX86p9GlNK9cwzxqujDqijEEd42cRMi4k0zgOMT06cBCb0fo0HM4UwSVjXFlFyDeonG93QJ5TWZTLVXGr3qCqdSMO1gnYbRJKXvJpz5JM0zoHbfPkUO25opjpUEzMH0fs4rJWfsPl1egf6JAb5UjAHihBYhg0js/N7AD2xbh9r0ZVPS5e9CclMuJAiMvZYvef+85/4xmaejGOPJQ1hHhuIOLS4k3/5xWvsFIq0HLMa8xWjSjx+3mLP3xLZFJuXSfy/gmu1J26bDxV0trZ/gKSI8BEayL9eI9lXxpJ9tTHIYoA5e8vykqDpHJw62aRe018TcjxQEnHgTzEAM80nMgeJItWSHi0nBOpae9L/myeuRYEJR9LkbvpBc5F7U9MMq5C9qqM7H/2T+Qr979nzU4HPZIeKNY+60FiHVoxQafANJkPuUD/yai+V+n7Orx9vRoqKHqwpfTUmQP1eX3qcWobwKxUWMp+GnYzoKtErMuXNV7ktMBRcJRrsHYADZScMcj8vWFHeJHxD38XtALdviWkdYH+pemD2W5jlokWjojniNxdFq9MULeMQKKXzd3IYfSC2/N18u0z8iII+ho20RJBOBDje6Ds0+Zf0jCd2ha/gsYfpc/DxwkdbMMIeXaYf3XDWjmNeraUDKl61EKCjDdrlHdc45u1nqasPW3pqhoE923K3fQE3Ybt/wvdQfS2sMlEGiUQMOwvIjtdhKtEg3/6vDgraBLjAUPBZwRIWU8vkwbmwVV7kwo9ejQD5Sy5mkX/x+zf0mBC1ZYs+bTWpwf22uxi4vopJTzQFZjxMeTzbxZkoBIZmmWheaLSQ2a9ccc1mY/+/r61LghZT2j1vOoNzmidO5tpbEkhThFFqhNeiIQsYWWW4Y1UMJrvfxCuxmnL3XxEgVVEm1irA+shvAjvv44yaRQ2h7uPfgK0nMH7yR4Nnz+TeETWEQCr2Cba/GoZv//8WcAEFA/Fl5K6apOuXzDMPleCIcLqTJX6yUKKAvIAebNh7Sf8gTt3TC47BrTtvgrsJ6bGATp4yb3pWy2UFKbro7KMFBBubUNx+ceb9OKip8KOS70HLws2Y952lScvJdRly6T3jhoUcVGmjVrUmkZ4kH/WWovlvDMbvW+af97ozOD1JiV1FiFQM8OgohPWydcuq+1UapxSyw2QySZLRFF1elgIw8q7PJI7MoitZa2HqwsxHtHXQ5hJvKjgi8UejErCrk0wbP3t7wg1RS9YNwHCQg/Lt4uI3rmwoCNbqxt32/tbDeC+GtDLdYBqQKgcGhRiP8tr/ikhfATsJXqcNg8C1o1Yr0WuME+Fye/cB8ARi+GVZnov32HI2uWsUrLyMpA0g3t54= X-OriginatorOrg: chipsnmedia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85d4100d-58e2-45f5-9cec-08dc23bd2b0c X-MS-Exchange-CrossTenant-AuthSource: SE1P216MB1303.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 07:04:15.8903 (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: JdIp8a8BGlohRCYbJLd9pCjYl6byMPBcqPYF8PsQpUfBwFUZHMkVVEHd071Oma3dap0sxIzjszrPXqM7BGkLsF+/CeYQRssnqEZXkORLZsg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SE2P216MB1425 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 62be7cdfccd8..6898d1513f11 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -150,46 +150,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; @@ -636,6 +636,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; } @@ -651,12 +653,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; } @@ -679,8 +686,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; } @@ -1227,8 +1236,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) { @@ -1804,6 +1813,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;