From patchwork Wed Mar 23 09:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12789584 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FF26C433EF for ; Wed, 23 Mar 2022 09:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FP2OylUwgMWLrnAz9iM1Cknq0FOYZ5Ajn/JzOIg57nI=; b=E68E2PJePfzfLr OvLDQErrybrhklo/RlsvMcj2RgZZbS9SJHIhglpdhuGRs4TpC2ye08iDSdS/W1tItgZ7T7C3/AJSN gpjwOtdEJYUmfEe7zr5JihIcJms0vT9XYaJhfFh5k+ti0lZmnrio0H/jgWs4Bl4JUSNA2j/OD/e6t W3bqOkbz1xJ3yGS7vmfSJdotqkHsaOU2MrPcI62dbgY+Howc66cxOAxwfmq5Z5ugSnUDjlZPkuXUF rgNvarX3M5QU44wUDMYeCfdw9vWjiJEjEMGOdOhfhMh+IwP+4sTKxaRmfFlB/ZtqDxxR8lEG2+P8k Is4tFPcDz/4q3xgMVObQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWwxF-00DBIk-Gw; Wed, 23 Mar 2022 09:06:57 +0000 Received: from mail-he1eur04on061c.outbound.protection.outlook.com ([2a01:111:f400:fe0d::61c] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWwwl-00DB7p-TF for linux-arm-kernel@lists.infradead.org; Wed, 23 Mar 2022 09:06:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQhesWiQCFGvhk7cv6H9MNE6fvqqsbdHqK/PozS5AKdYfgdBg0y7N2mBV8VBrt4TdaLACRDsyxpBE2L0PUpK5LwnAMFcVjdPCd4HlVnP94plJFrv6+GCuZdYgKy5tNXKRHF/EeONIBx57o375c7fBO6rB/lTXg76BES7ypigMVRfv0WnMCQoFha6ZqQVB+3Sx44lOmQeONqlvlf34oTQr1lM6r4ZqkifCBriZxvChNnOigMcxf7pQzxtwcuPSQQyHCLxUUoZ3ZKU8fbl0gb8KQRzYxTescuL7AJ24NCghXApFx4BLzxjX7DFlrvAhjqmJFq3eldk5qGfpZq86R9slg== 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=TxbkxqO1O3BFIRbYDJPwW5bmJEorFPJX8Y9qkO5XWMQ=; b=hCPKmT8DuULRDCLtqwV6o6yJz66p+lT2BB4z1JCuYmIIraAT230NMaQG9pg6m8Cv+XOg/CLnwfRk4hUkQij45JTXejJ3DN5I2yjBT1rK+y3pjv1uNfDF8HnSDJ6wHKsEVIJYzo58IIc4M38E3775ovWY75DS6svDNSnUVtGbbJ5a6k3PlyqJNCvbT9Ez89fpjZQzOz9KiQAUMIW40vt7/NxXzrPbtw9ya49EXE4KEiQnEYgoCl/KtMKlj1tXWw5UN9Rrg8/LdAs/6rudbx9dYWuF/yaPY19A36n2O9MGKZZT+5TXyH3zyw9thnyX+oElUSovaSuo46r1Zukqsd2sNA== 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=TxbkxqO1O3BFIRbYDJPwW5bmJEorFPJX8Y9qkO5XWMQ=; b=SlnicDMGkoFa+Jc5eOmzU5APuaXdIy3JBc2OCDPVFT8+KOnbR3uLPdemyRQWGaWgfTtRvUzRWy70b8KogQB3ORje/NFi2oDPYL0H/0rQt1bRA17a5czs+5YfclBRC1u8pcrpJgn+41ASJX5aFt4SHOhJ0oaiNc1oO0Lq3FMQtlU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM6PR04MB4901.eurprd04.prod.outlook.com (2603:10a6:20b:1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.23; Wed, 23 Mar 2022 09:06:26 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::c39:69cf:c4ea:967]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::c39:69cf:c4ea:967%5]) with mapi id 15.20.5102.017; Wed, 23 Mar 2022 09:06:26 +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 v3 3/5] media: imx-jpeg: Propagate the output frame size to the capture side Date: Wed, 23 Mar 2022 17:05:56 +0800 Message-Id: <473edd5666b24a659f651ca003add12ac9a0c2d2.1648023273.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: X-ClientProxiedBy: SG2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:3:1::24) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fea22ca5-aa25-4975-8106-08da0cac68d6 X-MS-TrafficTypeDiagnostic: AM6PR04MB4901: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: htxEOoc4VFHSeJUDQZe9ry+LIQ30O+kdYq4oCihljX7zuX/1+SmieOtjq3BTs+s09T+gAETShyuJOT0vuAi20Il89nklKDXOEthssyGloqOMEwO3yRFWlolY6hueRcJTaIl/skQo+4k9Zu8HuAZ2d1/+WQOhse0hN3ct4UBT/Xu0DiKrbZlpCAeuLKVSVALLpee70xTHNNezKgoO8J4qmxth/7nkIsiHHz+HJyu1lh+x0FhZy2+z5eLM1EhgCHYerwJgOd5u4zVdLsKFjHmcjeFXxhkMn6MqIbfXuJBiLRkscZKFs+4653TGw/r7R9mk4qKFnhEiGJoHHN5gBTxZwqZIcEX7IRZFEFTIcq7JMIvmpMHE55MDQ843QFBFNOolVNmqNpYJxAAL+n1yNWn/bZxDlNQP8mWKWqBZFJRd249XiX+NGcik179i3ned4ly9KnKSDpcNuonquoeYAjhOtUiXLcIut4+zH2O7xSY5peC3IeOVG0BqQXeQ2/m31O1RxTzj4Eft/DteskidBRQh5j+0UagSK4OQzP5jQT+E+v2wQrl4JODULO2LP3ihKoNqEoz5gZ7kM2w8wzWFVbuMXm7E9D4QIb/Ia+Ebmh75w+zNsJjj+DKMHO2sZk2kjTl5aG/aoRQ6hh3YIcDr1xAER4KcHUT6d//cNEkl2djaFZwKNhAryp/LNffIIFDzzbK2BJ3MIyGOmvEYBkL/ssQmpg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(36756003)(2906002)(38100700002)(38350700002)(316002)(8676002)(4326008)(66946007)(66556008)(66476007)(6486002)(6506007)(86362001)(508600001)(8936002)(83380400001)(7416002)(52116002)(6666004)(44832011)(5660300002)(26005)(186003)(2616005)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aI8nEhFAfQ/W1YZ0g5EbG+KI7WoliO4cT6nHRF6dgod0KmidmDVxSkk8jefx42gCzS9bAlh8yKs/JoW2IPtwNT1qNkgAx5+5QwXQzjvt4P9Q9G0s3R02MZdJ4p1e849aIHCHx13WiAV7DEemxXk7/K/0Bf7LHTpZYWYSyBHQ4BZjHVatDyeUZnghubQe7GLZHWL1E7ocPoGidD/k9f4VATqpAxncLESGZQ51ssfolu3M3NYVIWpU1bABDbFceHsJgSXJ/4ttWg1IEphn/NA5rgyu8olEz1Djc0bXQY+XkeTsOMudX5+2oH59ao5cHXJa/AijzsLBKGHjtXuBZk2agnCKsX8JPS2NVMCHwlLkPhSIO2csjaamRLz24Bzd2xkZExYY592ELiQzXLLSqNbDsM20hJX9ZQ3U84qsT/y9ooR6cZmcyP4AMS8cg4vu6cbulQ3FZTj9XdawNBqZomrmNqqQBtN15YoFivznBseVMFLLaEPHGHydGqRmzZLUbHEcHldSATZYo7MmwF/WhgOT8/7lsYnxN8u4eGOvP965M7Hdw7joLljB5H0rLUv20heGPSHsOSBam7WvVbQwAP+k3OKsdmpv+bHqDB9LTFGWJl5A92uuRU2iFXDxWvPTBHZRtSThHQrEfbTzSpnhNHSgrVYvOjo/nhsutBLCFyP3Ksvcc8pGoTOvdr2eDu+RVxwS5lYlcBvMmxRgO66FCQfEd1Wn1w7GEiBkdQt0X26xjEADhK6QNKtALPDITs+L9hA/ZvtPCFK8hKEo6VpC+jZ06hPJUtoPve1VzOgvSDbHkh9FhQchlDwU58KN9DV79pCn7z7w5f5Gtgxuq2tup/dZuIl4yHwA/sC51EhrA+j5G2AuQCO9zoneOT+MVf2vuiQ1a5rv/Gk9nI4oosiFfi+vU0gHQEIw3WfkwG+9K5zCYTeTgH/GR1Idvm4HWxKVMCDpC6wY2ODAdkk6ywh17TMINgQ82xJytfQI23jgnyPewba1VOwfVy2Zqqsn0kbHJiOjans49pMe6Ru1MJXNhoJDoEtX5mx0iEcctt2BfN9F2t/C7G3qTj0/zfrGJ3TjPRUsDyWSYmSk5OlyPiDp/6U913W2P63R7T9CGLCAFbErSWI4XJDRufletzHB4RhPlDZL9cbHCV4KQjwiDRtr7Wc9KXYUkPu3hOrTAoJSi/LwuIRtxcXLqOW3TlYiuf6IJXZj98XgyLs9LT68A8Zf84Fr1jfXAiLfzx+Iz09NFgN/U9654T1LZv6O2qdTldO0J4beNwjYNexJypjEwvdbSyIU6b7xskrv+IQ16uI9vipRD5cW99Q+e7ube3MY7K2eGhJ6DumJUQ1VhzGRI2HS11fLXczocsbTikjuqioL15RGwSVOEdY0iU3+FReMPPaCxw60/WVv1Pn7Zxa6Y29IgQZ0THVgmlqt49oiwfwg2rn12/0RtIB2j13cNmQTHOJOynQU X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fea22ca5-aa25-4975-8106-08da0cac68d6 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 09:06:26.0705 (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: ck0kitYGFm74Vhdl3w1LUzIFzGsRttvNusUI+YlEXYjB+p0TJ3WlH8HTUfpTJ+QuXoA+FwJaxWAlna9PG81d6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4901 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220323_020627_973014_5555AEBE X-CRM114-Status: GOOD ( 12.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 | 30 ++++++++++++++++++- 1 file changed, 29 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..5dfa6f87871e 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -1831,12 +1831,40 @@ 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; + + if (ctx->mxc_jpeg->mode != MXC_JPEG_DECODE) + return 0; + + 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); + if (q_data_cap->w == f->fmt.pix_mp.width && q_data_cap->h == f->fmt.pix_mp.height) + return 0; + 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,