From patchwork Fri Mar 18 08:16:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 552722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 307D7C433EF for ; Fri, 18 Mar 2022 08:17:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233631AbiCRITB (ORCPT ); Fri, 18 Mar 2022 04:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233653AbiCRITA (ORCPT ); Fri, 18 Mar 2022 04:19:00 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150045.outbound.protection.outlook.com [40.107.15.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E22B2DD9BD; Fri, 18 Mar 2022 01:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E59V/KY1vmRgbHQf1XT1nmY7pRdEZRtqN9jCPmdtzMdQXSB52HY7gsBteTkS18VV0BRqQ/IgktmPLWHde7fHgfw4XUTt/r151mbDcCmgb/j7A23AeS1c1VgZcX0hJoGSYxAEm5z+0B1glMq3XySG2uCjcfBZsCqwMAOXHoHzz1QSvqbIYnkAgDQssp71Dln8aDnlkaZ/aeO7HpynsAQP4FWr7ICypNqiqjUD1MbAuDJf/NyS4WQNElg0PYvAzCBjNriJia3YUBzzX6Ppg8B8GkZVfNJUZCCEKpKlth4Hc9CK7TISXqa/KZORFiKiaSgitRMlwV51xcspViShhTI2/A== 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=nV+4+ggQij4sZAFQbBSSvSn62mz5psI8ZHje06+CNwc=; b=Yv5BOcWXKH7gjwhP0yB0HQRxWF1YZ3jSSkeiSCfN0ahvxIcC24GyjoTgRgI5KWLiY0FRBlMdyaNrN27bRmfdRBk+vLXYg85BxvPh1iYWVrl3+jXWqx++faBI/OA26S9HP08TIGCnUF9Ow43DhcnEmJgrHt8j5eizqrI836uPeNwQdNNvKgiTrj8KIStnDUlwckA3HIxAe+MquWw9kFFPWvDo8BAFtphWf6KhA5LJoOM8nxWSSV+EwmTsMiXqIzkFNNnkwR1hhPHMOWhpAPL/OOMa0duWmvZdXUvBS6U25stcwM2y+0O+P+bLu7w/rKY9foKsTbOTnFEH9FgSZz7+Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nV+4+ggQij4sZAFQbBSSvSn62mz5psI8ZHje06+CNwc=; b=aGl2FXfnL8esoq7L+6ag6cVP1w37fUGV2IIiVYNRwBQuLCU7P8eODjtO2kWbvML5MkbgPbCMpH6KHgAeuoDdOEmZm9bhUaWmgUlztk2sOSC/mZQtlmry9ONCbxS+78zV+ds+e0UScaavRtC8XR8Wr6Q1Yh1nvTesW80w8ikN6mo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6346.eurprd04.prod.outlook.com (2603:10a6:10:10c::14) by VI1PR04MB6285.eurprd04.prod.outlook.com (2603:10a6:803:fc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Fri, 18 Mar 2022 08:17:40 +0000 Received: from DB8PR04MB6346.eurprd04.prod.outlook.com ([fe80::a8a5:945f:4d08:69c2]) by DB8PR04MB6346.eurprd04.prod.outlook.com ([fe80::a8a5:945f:4d08:69c2%4]) with mapi id 15.20.5081.018; Fri, 18 Mar 2022 08:17:39 +0000 From: Ming Qian To: mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, mirela.rabulea@oss.nxp.com Cc: hverkuil-cisco@xs4all.nl, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/5] media: imx-jpeg: Refactor function mxc_jpeg_parse Date: Fri, 18 Mar 2022 16:16:51 +0800 Message-Id: <9f67125ccbab5d36f985c783990ac2767df50f36.1647590462.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: X-ClientProxiedBy: SI2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:4:186::7) To DB8PR04MB6346.eurprd04.prod.outlook.com (2603:10a6:10:10c::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d43917a2-1cdb-4283-e6cd-08da08b7c46c X-MS-TrafficTypeDiagnostic: VI1PR04MB6285:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8sG6MlP5zitEKqADsdSEvbzDkfWPfjVTiP6A6180IfR+IRYF2sRm2kNkxKkypPLJy0x7+q+TNLyMXyXoHE8uClxYH65OtoZgh/x9NWe8+qSn12I2X2KpnUKsSZfpobnehBWfbKaMRiDQDLnJGSejTyazYAhknMVV4U00oqCmKW3WhaQCDOQ225p4o263QAJqdwlgp2x3rNsMDgi8ugsPnZwqMaX5hFqE26xbLT2aX9eazuDsycPpA0U4WlqV6M4MiiXfSWZld+PwtfcC1VM9L66Og0hlJRtr6mhISI11cbJnEh9NbCEKZSqX/xhJtPxJGzJpn7DbGLfi0Eb9kPkKhwTBmjBVk8Fc1g2iIHGQU4rNtOnzEVU187Jj0JuwWCB37ndcieI6z1/EmFak3RLs443PqLudEenUXkZzGxEMxYIVJDfD+IHJo4KDcmcbv2spyg5Ji8CF0eMyOTA8UXQe9M63JPwkFCVfh6vP7WhSRyzLNx/AMHEuCllzmxphEJVZ0ifCB0Y4ihxQAtqACR/FY2DiCZ3K2wVp6myQGQwN9H4ccu/5XyRsaIW9+/7NwbzdqIQqt+TjqgJGFvzVwFFbpOwCVann4sBwTxy/XQptZh9CTBVY7C03IzANtGfShpGPxiLqxr0BvaqCNcnnAOj0U5xgaHstGtjj1QrrVytntStvZIq783SJ6VU4+EIbfvoM11mp2XciB0yymi4Yjycidw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6346.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(186003)(38350700002)(26005)(38100700002)(5660300002)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(52116002)(86362001)(7416002)(8936002)(44832011)(6512007)(6666004)(2616005)(316002)(508600001)(83380400001)(6486002)(36756003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mb3Rpk2D2Psh/jHFqgtyaHkmKwkk5uyeA8OvwdDHG2hV9xje1adb3TqKCI9hIF9F4y9X/a2/0geICWr54ZESIs5E61AzPLuYO2MdQdKdKxa4R3SjrWI+L2awZMKiknKgrLRHjkecEHP4Wp5g0CwQXdhDk8FCsJF9bbrGqLaPiIwiW/Rix4SFltibm0IFTO+LgWpe00hQ8ukWaiDJEXG7E1I15sSc+NAAbOo2kupjFZ76q5uhEEShJxtUrYMivw7Imxxwi8orIu4y6PGTJK7zCTPCWVdDzcWOdtdEBTtnBtaaINtRi3iLiryIssj18nKWMspM2tA0lVcQOdWlHGrJSmM7A5p0KA9yB36KsCnu6Tmxa1JD93Aw4W74WndcoJ8AMxlnlmd0oEgWQkzTvarztDBLYCWDj0DrmkH3ti8PqZwVbxT07KEnEx5n6Ihpssryl4HKR+tgJowNqUCL+Trvp0TsQK4TVfKZfs+owHSbFzRpgbVUcGmiyi/exCf6fC0mt4mu/7Cia7vKBVQKAtDHEbu0lelGVbCh7xxoVa7rDMizLj03fko0FxJEWF5Ns66RDVjllLx3Q7XqzApll/u2UpKnmKT16FmYCIQJCCOC1smMRWMPnlRROTwfP6VJuHOYWA2+1CitvzBjZWV0kVzu4utGDSzCEL9oSKIoDQdgE/eK0LYIJj34wANFzT/vKUDsMjiuy8Fdolzl//bvrEAo99N+zG2VIVRCJbFmc1GGn3tgzhdO3XG0wuRcWNkgZ8BpUrmqIJk2WkRfmkG6zmVqvWiHLm9R9zVGFkeAxMpq6t6UlMe2S9l27eGcTf/y0sfZvBG9opp6eR3e4lfO9qRjkHs31fySZl2/3/fdpjbg2ixbHrnWrePsRlCDg4DiBgNaH9rdZ9wgL8yDb27Z89tVaNgorL2uHdNlOXeTELqscZCffeHP11+tH9pzIUNGRFLQvitrcstBQTMfAljnzPVydCC9ffej5S8ppYjvgL9gVr6u8qlhRYTPf7uCTEdffkJ966W8caiV7nZsw/gdoDejFBHvZlE3FMc7ob9ufiGRaiFrnA5mUPE3v48bajJhgi9a78Ij0T1fmXN+aQX0+rGl6RvS+6vwhusp/hJ8FQQV0RUL2+N0xzI81EHP8tbR9UACTZs1PS+GpXFMuh++0IAnFiFZpXSsTw7SFrZsMFggPTMhB0SZxv+wqBsqJd/OL5TD/R2eZlIzESwIS7BGwBPrkESoEK5dSg0lkWM5Vwr/Y7/07fM0RYs8mwlTRUs6Eb/9u4IG6vtjB5u1SNpq5rbCESXXCK+tOADAuvOWi5auVtHGYgAsr34E0fdN4huJyvZBSQe1AjGaCy6qIzjcMYBbbsRHQucW7Ernceb8Bbq1ymPtXRzQ9eh3Dz2i0sCNPeJG3FoAYahlTAb2Xtweu4zTwGz/TUfTeluNqrxayV2qrt9w2h3BQPlroLpoWAnEppzh X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d43917a2-1cdb-4283-e6cd-08da08b7c46c X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6346.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2022 08:17:39.5730 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: s3e59wMcGzfsXCg9B5KsaK9JXNMycwdPvFlEm8NxK9TVclQsesmMQxwHIW94obnliebC4nkRpp5qqqGfw2bilg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6285 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Refine code to support dynamic resolution change Signed-off-by: Ming Qian --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index d1ec1f4b506b..48e496cec04d 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -1245,8 +1245,7 @@ static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q) } } -static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, - u8 *src_addr, u32 size, bool *dht_needed) +static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb) { struct device *dev = ctx->mxc_jpeg->dev; struct mxc_jpeg_q_data *q_data_out, *q_data_cap; @@ -1256,6 +1255,9 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct v4l2_jpeg_header header; struct mxc_jpeg_sof *psof = NULL; struct mxc_jpeg_sos *psos = NULL; + struct mxc_jpeg_src_buf *jpeg_src_buf = vb2_to_mxc_buf(vb); + u8 *src_addr = (u8 *)vb2_plane_vaddr(vb, 0); + u32 size = vb2_get_plane_payload(vb, 0); int ret; memset(&header, 0, sizeof(header)); @@ -1266,7 +1268,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, } /* if DHT marker present, no need to inject default one */ - *dht_needed = (header.num_dht == 0); + jpeg_src_buf->dht_needed = (header.num_dht == 0); q_data_out = mxc_jpeg_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); @@ -1381,10 +1383,7 @@ static void mxc_jpeg_buf_queue(struct vb2_buffer *vb) jpeg_src_buf = vb2_to_mxc_buf(vb); jpeg_src_buf->jpeg_parse_error = false; - ret = mxc_jpeg_parse(ctx, - (u8 *)vb2_plane_vaddr(vb, 0), - vb2_get_plane_payload(vb, 0), - &jpeg_src_buf->dht_needed); + ret = mxc_jpeg_parse(ctx, vb); if (ret) jpeg_src_buf->jpeg_parse_error = true; From patchwork Fri Mar 18 08:16:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 552721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8048AC433EF for ; Fri, 18 Mar 2022 08:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233657AbiCRITL (ORCPT ); Fri, 18 Mar 2022 04:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233660AbiCRITK (ORCPT ); Fri, 18 Mar 2022 04:19:10 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150072.outbound.protection.outlook.com [40.107.15.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 638302E1A83; Fri, 18 Mar 2022 01:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OWmVyvIVMVIgX6zFe2NuWnXGlit34UvFHFyXHbM5MFPws6dP4+MEmHcnFRndijo/irwKYnc03XZtRH8awxrznDxq7a7bRMQZhpp8LiW6GETG5ZwLnWPSfCf99htBjlSP/+drA2C+OO2Iww9gLd8SKuKxYIjUWCCjqaOaHPtxYwcTEPNHernfX2ZqM5uqCJHAoq3hJ5aW09QuRCiV+MxabriG5BCvAWXQa3RxPy3piOM1rrQZPNlFHWRyr8PlVqZuYUEWGW4ml/p8JPp2yrp6Bq8YfllrLzUe0LYTKzqecMkmnDp1PScrfgNyjGzlMPZ/NckxnZDWlgNur8sw6nEP8g== 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=ICyghvJRyomCtrEkMPimsa5pCA8XKB6BWA6hy0c0UlU=; b=UIeMRrQclPfDzYeOsiuxj9VJMoEkQK3NfOW5RkmK8VlWW54uRrYegJoSFi9QdYMLZKR2U6mbhD9l7FS+A0EcWwXzW17tZC7ihQvLBNE/p8lQQzDbzHraAK+UVN1DdAM7x2UQ/JygI8pVOqc33mF40bef/5Fqp11GE/NC/Sw4fTkRuXwshsuuIUvlt0lufDiDLXRk5UEx8QoEaehvfX9dSTF/AEXenOG73IeZuSmaCt1ybpNelMVDJQMpikZKHRK7KIEFnvnByhg2XExRBjYMAfjnOvTSJ6tsPsiVJ/tCAisizgaUNUa9tSJvg13xQFLM6yJBHUJXF5DsC/ffJ4LNAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ICyghvJRyomCtrEkMPimsa5pCA8XKB6BWA6hy0c0UlU=; b=MBpsr3qfWxCTS9LTvnDjLZJtBYlJlbzsu4eoWjpktSKMIAGvs4LDodGjcTps/jwvr4dwDLNCCwPOZyEFixLKPUIeHFKUwZ3h6Hh9wheEoS/1dZnHSNVPOQivENM94VBVEGK+jYn31InP+g7EQqc5hkzqLo3Je0BBuBVhhz2WAs0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6346.eurprd04.prod.outlook.com (2603:10a6:10:10c::14) by VI1PR04MB6285.eurprd04.prod.outlook.com (2603:10a6:803:fc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Fri, 18 Mar 2022 08:17:47 +0000 Received: from DB8PR04MB6346.eurprd04.prod.outlook.com ([fe80::a8a5:945f:4d08:69c2]) by DB8PR04MB6346.eurprd04.prod.outlook.com ([fe80::a8a5:945f:4d08:69c2%4]) with mapi id 15.20.5081.018; Fri, 18 Mar 2022 08:17:47 +0000 From: Ming Qian To: mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, mirela.rabulea@oss.nxp.com Cc: hverkuil-cisco@xs4all.nl, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/5] media: imx-jpeg: Propagate the output frame size to the capture side Date: Fri, 18 Mar 2022 16:16:53 +0800 Message-Id: <18af657bba31a7aa49a23e9952884beba7cd4f04.1647590462.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: X-ClientProxiedBy: SI2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:4:186::7) To DB8PR04MB6346.eurprd04.prod.outlook.com (2603:10a6:10:10c::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5fed04f-46d2-4259-eb1a-08da08b7c914 X-MS-TrafficTypeDiagnostic: VI1PR04MB6285:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 543763QqF2FgvIqpXGK7cLDgB6LnINEWHnMNvut88QRSfGJbSPMmeyvAsiapAD19tQSJjB+4l/V63O3yzOyzUYoTVDQNwMAXuUjLycThXS06rH3o2ZRopkeJBprykCvFehFkfPu7+DU+6VP+0k1iUcSNrw1MeHBU/2lwrkU5LESxN50LTWNKmQt3DSeXXHgR8vwxHa8DhFpbxWl3RsW5m5lLIekYDH9tkvfQ1xjOQKDtXje3qHyj2tTFvEE6qGqQBTEHRA2akyJT/4TjSiejvMuI5ehIdEAIScm+PE08zcw5JU8lksfdgUk1ykeFP5Q4NrZ3WRdqXZOO945q7+2nt7YIvk6AfEETy28k92RGmmTGhj9s+Ew7dZdst8Gqf5/3xta5VLUJjhKVoPUFKDA2CQ98uF3EjgAQQR9bw5v0lJxt9xoKiyaFC5X4Ud2fzr/KeQ6huAeGW/hVvD2exFDzpJIEObKTD7nLY98AYFgM0HNMEs/5IpR1KiaQuDnNHL9sYIigs8UP+Wuhjx3MM8Pd/Au67hXeSibCL7/upluL4FNvwbBEX2L+PQvj9neUA102hlQe7YKGYdv9LW/H87GhSPUQfw+62CDvqa93IfR4E6zKOq+wD7MwPOgVBkcdIZOuT8C53VJDY7CokgNO0AbkGqy+BxB5kqolqR4skS/ee1/BZy3Mq+bFfxojs7Wo06p/6nFKx2V1kX00dGk7PbXp7g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6346.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(186003)(38350700002)(26005)(38100700002)(5660300002)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(52116002)(86362001)(7416002)(8936002)(44832011)(6512007)(6666004)(2616005)(316002)(508600001)(83380400001)(6486002)(36756003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P6AAu/kzcpPYzDbRZTfnv4X/90VEaUqlu65BKy/W0MGYH0uG0V5EzBsVy0M5Mz5urNLfZOxQKzfaacTIyLYXjX8URNDLmmlfZ+sqhIMq/u8Qn9ZaYrbNKvsUALaOFY9nu0qOKtYP6ST9epIHvt2MF26P7axtb79OLp14nyH5ZGKtqUTkYviZCvKcVa0rJBOVKgNQm0ToKqplxrloJQB6XQjB0ziLSj63bOYaeZ0KLVjxo1FPETXowobOop755WLCS3+KEOsjUf2iFHKM96GpW4Cd/wq0+XK59+H8hft0p3Pd2K3krLjpRUt5+GfKgNBlA4WO3PPCY7vZnpnqiXRdSMeHVL1WOFBgL98mt4bB0s+qrSPA9e5mNWBTX+UheA3uN1hCZJW5XS29UNPCComf5OOqwJTogcJvJjg7IlnNcIJxG97dcmd/Cj7JB4KbCLTGxloZm+ed6lpcgzF0rL/qQ3DnGCtHxSnqSAQzaoORQfdAXVZvB7MgqLWat55C0lVz5ivu9B3QXqZpoThHsF0KcfEGqorOPnWxF9PXQHfmfwRjxmrDxZ993qDSA11r1ruZQfFVua8Jj2aO8ipo+y/2d7xqIV968eJhwe33tBq9wt2k/AYGcRny3yOCWqtOjs/eMqi8F2a5wMz7LUr0m4F07C8xXuVCL5k1JtPnRjMRO1BIMfdHnR1DKiRU7/1la5afLT+xcUgX5ov1uDUMJkt3bRDDRTcTbBEV/PVKzWC8Y2a3tSzhQXxThpXexloSyUbsHhf348m0kyJPkp4LwEC0l5lhhX/FFiamOwUnaM8Wbc585h2de09RRr7c1iOOlC01dHVEKpwbff40OT1IBe32NcFC0OUNGNFg75CIdahd01Jke80mcTK4uZMaCN33vvagexBluhv7WZqrjCNPmcZuOr3mMrC0QDQNZnYmmJiMMUoVka358iXJiUamlRiUw7hqrnyYgWB1ZTTq5U37oVhw67qpQlJMndf2vKQjoTLHTNoUBoKTQSn9Md1XSIFTjcJZCDVyq4bauloVgi/tlJ2v5Kz1nYqC0KX8OWdO3uUqhzCKCjYxniJ8lvWSAkomAhldrkNh11YNpHCEihfp/XCroaLabD3ydL+NQQKipzVIxaXGaChEXz71AC6Rh9ebBVc2b4UeWWiMg4zSgxDYZcbXVtURT/Z/Ka5vlAxInELomsyEd7NbF3O3vO0BDPTHJyDSPXwIFBjN6QVS+dfwC4VJr9F6sC9KewjyNiU5VRl2Mo8dd+Jkdu7a85LHGmW9JavcWFNwt4y1VpbOHfgEPvopsCCv+hJ8dUr4cP6lObWvZ1SKoPbd97pd7AIgPsaE4gbM6V3MHDai9zGKlxu+sMJcC7Fhp4mTx7TccVvlxJGHJinNl84v9sd5gXBRatBkz5yDZ1FLrI8QLc5vNEGnJGEN1cBUQWa6kDpIsBTaVoluTgvp9GwDX5aqiMZG5T16/G1P X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5fed04f-46d2-4259-eb1a-08da08b7c914 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6346.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2022 08:17:47.3850 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cbvkUMDKUt6kRVZuIUl3dR63LOep27OBZbHsCgP6iNG3uOD7vTnpI0pVP1p9us2Z6Hn8IcH8iHpBw71gmNHRCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6285 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The GStreamer v4l2videodec only ever calls S_FMT on the output side and then expects G_FMT on the capture side to return a valid format. Signed-off-by: Ming Qian --- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index a95305639dd9..d2110731346b 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -1831,12 +1831,35 @@ static int mxc_jpeg_s_fmt_vid_out(struct file *file, void *priv, struct v4l2_format *f) { int ret; + struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv); + struct vb2_queue *dst_vq; + struct mxc_jpeg_q_data *q_data_cap; + enum v4l2_buf_type cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + struct v4l2_format fc; ret = mxc_jpeg_try_fmt_vid_out(file, priv, f); if (ret) return ret; - return mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f); + ret = mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f); + if (ret) + return ret; + + dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, cap_type); + if (!dst_vq) + return -EINVAL; + + if (vb2_is_busy(dst_vq)) + return 0; + + q_data_cap = mxc_jpeg_get_q_data(ctx, cap_type); + memset(&fc, 0, sizeof(fc)); + fc.type = cap_type; + fc.fmt.pix_mp.pixelformat = q_data_cap->fmt->fourcc; + fc.fmt.pix_mp.width = f->fmt.pix_mp.width; + fc.fmt.pix_mp.height = f->fmt.pix_mp.height; + + return mxc_jpeg_s_fmt_vid_cap(file, priv, &fc); } static int mxc_jpeg_g_fmt_vid(struct file *file, void *priv, From patchwork Fri Mar 18 08:16:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 552720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2756EC4332F for ; Fri, 18 Mar 2022 08:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233714AbiCRITX (ORCPT ); Fri, 18 Mar 2022 04:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233710AbiCRITU (ORCPT ); Fri, 18 Mar 2022 04:19:20 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150082.outbound.protection.outlook.com [40.107.15.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E07222A1; Fri, 18 Mar 2022 01:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VafPXqKeynrwhy1vs/2neTLMsb0oq/OmkjwNWn0SdUzGLDWZPbqlPKq3YtQl8LI7guq/d22qh0jzOV2LSAkPxfKUhTTW3nzYN5Tx4+lw74JmYIfhBnmz0bJxE05PWlb8aIzvJY2NvuOP61d9JMSicakZRhc7NpUprWnfBEOUQVJGPahRuZo5eo1UaEUOIfMTWohzUrBaJTfX6E+kn5aE7pPsItCzzz20dNTrCnubgmKGzuuQsGubjf4EnuB/tUnEiZAnOqkdfH7b30oCU+pZu/9dnzET6eufsWhvDXLq2oMrr+L+BfetBVyRaej94WC7yUzZcAoa/ru2ufScS/XRow== 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=qSP+wNzua7vbfftMiEf1QRK1mgGgsnw1qa5RCzCG5rA=; b=LytNgXmk+vN6bwWYvwjArrlqRlUDSA4Iqf4jj+w9ytZVavj9z3pBKHESCrR942YAzsPcupbNUWe5fpsSGL2PeYnQJqETfYfyiqSNPDAivgEmJb9nLSS/7ZlNCFwoWSHK2fQxA/0wWqLYtdlSHsw6kV2RCMNpiMFWuAK8f5EjmbSHIIQJKdaNEgwDTg+csw4LLdbradOuSiP7/Qu63U6IT2aninuBN8pH+SEx+PXdQPK8hCevnhG2NXnveAEWjwuIxZ2orY/CWLHu+1jqQUYIUl0EA8ZF0DZDH5il0W7pxbVNxyU/ifkeLYdcfqbbtVQlezERMYsyPJ8MYZPvatfV+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qSP+wNzua7vbfftMiEf1QRK1mgGgsnw1qa5RCzCG5rA=; b=sl0DvOoao/jITRqxfGVqLGr2oOaPRjBYSf505Icgwo0ccFTtVD+P+4wQYVvH7xLOtcKGYZqWJ7Qw1CgwJaqBi8dSKV2rucDrrEkFvkF2LKGN8od1fGM+etPQO9pTr25Q/8FEPYwOa9TboJZhSKVOCuhdi2tNSFbBomCs9wq7rBQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6346.eurprd04.prod.outlook.com (2603:10a6:10:10c::14) by VI1PR04MB6285.eurprd04.prod.outlook.com (2603:10a6:803:fc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Fri, 18 Mar 2022 08:17:55 +0000 Received: from DB8PR04MB6346.eurprd04.prod.outlook.com ([fe80::a8a5:945f:4d08:69c2]) by DB8PR04MB6346.eurprd04.prod.outlook.com ([fe80::a8a5:945f:4d08:69c2%4]) with mapi id 15.20.5081.018; Fri, 18 Mar 2022 08:17:55 +0000 From: Ming Qian To: mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, mirela.rabulea@oss.nxp.com Cc: hverkuil-cisco@xs4all.nl, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/5] media: imx-jpeg: Support dynamic resolution change Date: Fri, 18 Mar 2022 16:16:55 +0800 Message-Id: X-Mailer: git-send-email 2.33.0 In-Reply-To: References: X-ClientProxiedBy: SI2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:4:186::7) To DB8PR04MB6346.eurprd04.prod.outlook.com (2603:10a6:10:10c::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f886b7a-7006-4713-ef7b-08da08b7cdbc X-MS-TrafficTypeDiagnostic: VI1PR04MB6285:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nqme/2NP/xc1Yer/DIFZXPse4aWAG07fqXZ3AUKHk0lvkaTEoRQUAH76sT+5I7QOUykHD5mijFyJMvHcXhFO6VlFZpNXq4qX5BZsFbC0Q3qo9JNc7ekeVM3Ay9VCfFciZKybgVNY/LeG59vgYbKNfLEo8cW7c98EBpuVBg6Qcf4M6YaIBk2XbJJbTBS4M9xCzZtD5BW1YlOGh348i+0auS0ay/I7gseSV487lQls10QOSYz0plfsaC9w7kAsB4U8ut1fL72aiUIes123smOUqitaElgMJiZC/q+wq5BJcPSkMdmye867bfz1oPRKaZYp35okYA3LaX6IYTqVPxupSN/dOcyQrGaJNkwvE+QgbhyYaydgdx+scLbJ5nemM4hhn2fvgR5y4HkGS2Skt24lLVVVh6Eqkk+Q0AWOh3Xl0w4jyD560d9YR9f1TsuVSkii/GKij/w9EMEXRdOGH4BHRorokbeK/h/Qpj4eMlFUc4xSk8ho/ahc2RiY2MkuycD1Ja504o9H9hK4UvzbEejPZuYeQg8HiMKb+Uta15q9RcK5DXXljTIunztrzOHbc8z+rIPwS1TBpKOfB1ORGHoysYafPJ0rYEi99qfaxRq+9gyLPDizkatdhyJQYwm1tFTPaLGnd7PRhk4T0pLKm3e4JXbZKRxfV8g6HKmzYjxkPjcXuGaLyLIwzv5vJopd+/mpp3IBKCyLFVcqSaT2rvtFNA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6346.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(186003)(38350700002)(26005)(38100700002)(5660300002)(6506007)(4326008)(8676002)(66946007)(66556008)(66476007)(52116002)(86362001)(7416002)(8936002)(44832011)(6512007)(2616005)(316002)(508600001)(83380400001)(6486002)(36756003)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LHHR8k5TGtiAYm1UVW1KHPv51aJFn92hi6F6A8vmUOtv1/X5ojs7XQLpY7JNu6YlxGxZLDnVezveSU89/IC9NQ/WE0E3Qj6wZ4OP2EP9IFUBmk/C6JXl8ZQM73nqGhw491ZZUbI4j3TlFmDnHqfYeWxHgmae1KUBaKJsl00iyrNFHCJiYF9FrbUpZfi4axBFFOkAs/JVHeZRoEyfgaiIFfd7iJph0f3Zt53PNN669an4qn3vaxsvChHfHYPiJJPfxcXr5Bn27oPCxAEeo5lxf83/YKB5ESKjIf3wwJsJL7c4ActzYKiMu3ovZzTNE9urzTmSrJqE2532p8jHWeW1jw8KqdJaKghRIiA4kQI0ikW7GjIug1UJpIERBd7um2cyxnR1Rpyx8UeOQy1++oafsJkNxiC2jPCYc9HkJ4ERTFCwem9Rf72nMiF9poTYXD+SwoY/AN4JiwYUf9c2QsFRW+/YvmJGUAmaiPjq7TFTSOnru336qxZjZrH62bsFGOOIxQuWASKCbjc6+d1hIE06q58j5MZSycZHZqrXJAAAn4jjudSFMaDyt+oNJi/zBI9Bz4+5KYSTx61QkifBAEbK2GBbmslez/qxMmNH49oRD3tAGzqAhzso9nhIACBhOc9fOc0Rn5zxaENvVm3dbgoylGtfsBrt+kQV79MXTnvu82xvjR+bh9h0XHPchvjAkdPEM+wNZOk4z0Wn5z1rx0ZRDozXkzhIxeVHmgNlBwBJkidcVX9dAo94gxaaJw6S8aftb1I7z1ePgs/fBxLT0zvZPNYqzqlDRCdADlcu8qIZuLXpWj3scMHBnogTlWMMKeTplLR+ptyUUAG3e2bKaCFH+EAye8sq1IaatzZ/AlSyP8SIYI4RZ1ceI9gVQ+UjA7vZ3NBAeLzcgs7d+ai40jrMtyvTE3jNnZN6lW7/R4iEEZUYxk8spIAssX+mdtaqbLg1XaSCkKFDnGlfCOfJM/YPZ00YCyj/pLT6tVotEEi4tI84CJDXn0Fm4Oqe3kmZF5g9WGlA4Jho1IL2bI0tksn6FNZQSkGYSogI3I3c+3nyBumO1zsicFSyCj4AdeQbWXNcdn+uOKg45YXaWCq+qhmeqik4EfVd4/D92lIvmgqueeOmHR3RQB/WiXD/XyxMIJp+LjsC73CQuylyzYhtk+zbLqTu/GEtVBiJMzolvYRuaVqPfLv/h1VC15Cn/kXV31ruQLqKdLu31dHf7PGAITurph1j+IMZ3tBgHzxyRGVonID0V5VQitVYeZHGwzVHOGO4PBNi2exPFPo6ggLAx2ZMasYHT9/PMTbCZIKpobDwLNPDoea1urgMxAcDPRqbLuX/600XhQl0lPSOL7Ja6YxbfDbZ6Po3z0t5LeQpZc+iBvkF1wkhrxawNXGxaRlVYqYVStqrCid3wUZkU3ayYEUMEIUF4vlOYjELm5dkY5WLtgXo3zIwFzS++j5n4inv0ErH X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f886b7a-7006-4713-ef7b-08da08b7cdbc X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6346.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2022 08:17:55.1970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kozNkaoXKbP2/inCbOCG9ijpaGPBpSHMs2m2xAaEAPYMnFCkPSss4+ANAd9g3RQ0HnWhiWppzZlBqhMUkeIyig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6285 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org To support dynamic resolution change, driver should meet the following conditions: 1. the previous pictures are all decoded before source change event. 2. prevent decoding new resolution pictures with incorrect capture buffer, until user handle source change event and setup capture. 3. report correct fmt and resolution during source change. Signed-off-by: Ming Qian --- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 69 ++++++++++++++----- .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 2 + 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index 5bce74de7cf2..5584b40fb36d 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -933,13 +933,14 @@ static bool mxc_jpeg_source_change(struct mxc_jpeg_ctx *ctx, { struct device *dev = ctx->mxc_jpeg->dev; struct mxc_jpeg_q_data *q_data_cap; - bool src_chg = false; if (!jpeg_src_buf->fmt) - return src_chg; + return false; q_data_cap = mxc_jpeg_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); - if (q_data_cap->w != jpeg_src_buf->w || q_data_cap->h != jpeg_src_buf->h) { + if (q_data_cap->fmt != jpeg_src_buf->fmt || + q_data_cap->w != jpeg_src_buf->w || + q_data_cap->h != jpeg_src_buf->h) { dev_dbg(dev, "Detected jpeg res=(%dx%d)->(%dx%d), pixfmt=%c%c%c%c\n", q_data_cap->w, q_data_cap->h, jpeg_src_buf->w, jpeg_src_buf->h, @@ -976,9 +977,16 @@ static bool mxc_jpeg_source_change(struct mxc_jpeg_ctx *ctx, mxc_jpeg_bytesperline(q_data_cap, jpeg_src_buf->fmt->precision); mxc_jpeg_sizeimage(q_data_cap); notify_src_chg(ctx); - src_chg = true; + ctx->source_change = 1; } - return src_chg; + return ctx->source_change ? true : false; +} + +static int mxc_jpeg_job_ready(void *priv) +{ + struct mxc_jpeg_ctx *ctx = priv; + + return ctx->source_change ? 0 : 1; } static void mxc_jpeg_device_run(void *priv) @@ -1028,6 +1036,13 @@ static void mxc_jpeg_device_run(void *priv) return; } + if (ctx->mxc_jpeg->mode == MXC_JPEG_DECODE) { + if (ctx->source_change || mxc_jpeg_source_change(ctx, jpeg_src_buf)) { + spin_unlock_irqrestore(&ctx->mxc_jpeg->hw_lock, flags); + v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); + return; + } + } mxc_jpeg_enable(reg); mxc_jpeg_set_l_endian(reg, 1); @@ -1074,6 +1089,7 @@ static void mxc_jpeg_set_last_buffer_dequeued(struct mxc_jpeg_ctx *ctx) q->last_buffer_dequeued = true; wake_up(&q->done_wq); ctx->stopped = 0; + ctx->header_parsed = false; } static int mxc_jpeg_decoder_cmd(struct file *file, void *priv, @@ -1167,6 +1183,8 @@ static int mxc_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) struct mxc_jpeg_q_data *q_data = mxc_jpeg_get_q_data(ctx, q->type); int ret; + if (ctx->mxc_jpeg->mode == MXC_JPEG_DECODE && V4L2_TYPE_IS_CAPTURE(q->type)) + ctx->source_change = 0; dev_dbg(ctx->mxc_jpeg->dev, "Start streaming ctx=%p", ctx); q_data->sequence = 0; @@ -1345,16 +1363,15 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb) dev_warn(dev, "Invalid user resolution 0x0"); dev_warn(dev, "Keeping resolution from JPEG: %dx%d", header.frame.width, header.frame.height); - q_data_out->w = header.frame.width; - q_data_out->h = header.frame.height; } else if (header.frame.width != q_data_out->w || header.frame.height != q_data_out->h) { dev_err(dev, "Resolution mismatch: %dx%d (JPEG) versus %dx%d(user)", header.frame.width, header.frame.height, q_data_out->w, q_data_out->h); - return -EINVAL; } + q_data_out->w = header.frame.width; + q_data_out->h = header.frame.height; if (header.frame.width % 8 != 0 || header.frame.height % 8 != 0) { dev_err(dev, "JPEG width or height not multiple of 8: %dx%d\n", header.frame.width, header.frame.height); @@ -1390,8 +1407,10 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb) jpeg_src_buf->fmt = mxc_jpeg_find_format(ctx, fourcc); jpeg_src_buf->w = header.frame.width; jpeg_src_buf->h = header.frame.height; + ctx->header_parsed = true; - mxc_jpeg_source_change(ctx, jpeg_src_buf); + if (!v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx)) + mxc_jpeg_source_change(ctx, jpeg_src_buf); return 0; } @@ -1468,6 +1487,7 @@ static void mxc_jpeg_buf_finish(struct vb2_buffer *vb) if (list_empty(&q->done_list)) { vbuf->flags |= V4L2_BUF_FLAG_LAST; ctx->stopped = 0; + ctx->header_parsed = false; } } @@ -1613,26 +1633,42 @@ static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) { struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv); + struct mxc_jpeg_q_data *q_data = mxc_jpeg_get_q_data(ctx, f->type); - if (ctx->mxc_jpeg->mode == MXC_JPEG_ENCODE) + if (ctx->mxc_jpeg->mode == MXC_JPEG_ENCODE) { return enum_fmt(mxc_formats, MXC_JPEG_NUM_FORMATS, f, MXC_JPEG_FMT_TYPE_ENC); - else + } else if (!ctx->header_parsed) { return enum_fmt(mxc_formats, MXC_JPEG_NUM_FORMATS, f, MXC_JPEG_FMT_TYPE_RAW); + } else { + /* For the decoder CAPTURE queue, only enumerate the raw formats + * supported for the format currently active on OUTPUT + * (more precisely what was propagated on capture queue + * after jpeg parse on the output buffer) + */ + if (f->index) + return -EINVAL; + f->pixelformat = q_data->fmt->fourcc; + strscpy(f->description, q_data->fmt->name, sizeof(f->description)); + return 0; + } } static int mxc_jpeg_enum_fmt_vid_out(struct file *file, void *priv, struct v4l2_fmtdesc *f) { struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv); + u32 type = ctx->mxc_jpeg->mode == MXC_JPEG_DECODE ? MXC_JPEG_FMT_TYPE_ENC : + MXC_JPEG_FMT_TYPE_RAW; + int ret; + ret = enum_fmt(mxc_formats, MXC_JPEG_NUM_FORMATS, f, type); + if (ret) + return ret; if (ctx->mxc_jpeg->mode == MXC_JPEG_DECODE) - return enum_fmt(mxc_formats, MXC_JPEG_NUM_FORMATS, f, - MXC_JPEG_FMT_TYPE_ENC); - else - return enum_fmt(mxc_formats, MXC_JPEG_NUM_FORMATS, f, - MXC_JPEG_FMT_TYPE_RAW); + f->flags = V4L2_FMT_FLAG_DYN_RESOLUTION; + return 0; } static int mxc_jpeg_try_fmt(struct v4l2_format *f, const struct mxc_jpeg_fmt *fmt, @@ -2013,6 +2049,7 @@ static const struct v4l2_file_operations mxc_jpeg_fops = { }; static const struct v4l2_m2m_ops mxc_jpeg_m2m_ops = { + .job_ready = mxc_jpeg_job_ready, .device_run = mxc_jpeg_device_run, }; diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h index 82b38cc2dfab..9ae56e6e0fbe 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h @@ -94,6 +94,8 @@ struct mxc_jpeg_ctx { unsigned int stopping; unsigned int stopped; unsigned int slot; + unsigned int source_change; + bool header_parsed; }; struct mxc_jpeg_slot_data {