From patchwork Tue May 10 11:58:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571465 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 8A041C433F5 for ; Tue, 10 May 2022 11:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235785AbiEJMDL (ORCPT ); Tue, 10 May 2022 08:03:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233564AbiEJMDK (ORCPT ); Tue, 10 May 2022 08:03:10 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA91146163 for ; Tue, 10 May 2022 04:59:12 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57F8DB60; Tue, 10 May 2022 13:59:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183951; bh=ID7KsvsOkIXuQ4cSOB4gIYwOWmaaua/BqNjfCaF7y3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1oe320a/YvZwL2x4zvkz6kY37pWyHxXrpdvkNZ8yX08ROY2vGP4JDxrSy9ufdHTA mKpOBF9SnSTD/ak9OGgyy+sZewjPmdWShgLqxrBBy7vWY3KUQfWMxsgPxoxS2ziNzh chv55gSvdm4vNaU5ojWAUECbKr8Yph3a9rMlC17o= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 01/50] staging: media: imx: imx7-media-csi: Initialize locks early on Date: Tue, 10 May 2022 14:58:10 +0300 Message-Id: <20220510115859.19777-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Group all the direct initialization of imx7_csi fields at the beginning of the imx7_csi_probe() function instead of spreading them around. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 8467a1491048..893620e8fc03 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1188,27 +1188,32 @@ static int imx7_csi_probe(struct platform_device *pdev) return -ENOMEM; csi->dev = dev; + platform_set_drvdata(pdev, &csi->sd); + + spin_lock_init(&csi->irqlock); + mutex_init(&csi->lock); csi->mclk = devm_clk_get(&pdev->dev, "mclk"); if (IS_ERR(csi->mclk)) { ret = PTR_ERR(csi->mclk); dev_err(dev, "Failed to get mclk: %d", ret); - return ret; + goto destroy_mutex; } csi->irq = platform_get_irq(pdev, 0); - if (csi->irq < 0) - return csi->irq; + if (csi->irq < 0) { + ret = csi->irq; + goto destroy_mutex; + } csi->regbase = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(csi->regbase)) - return PTR_ERR(csi->regbase); + if (IS_ERR(csi->regbase)) { + ret = PTR_ERR(csi->regbase); + goto destroy_mutex; + } csi->model = (enum imx_csi_model)(uintptr_t)of_device_get_match_data(&pdev->dev); - spin_lock_init(&csi->irqlock); - mutex_init(&csi->lock); - /* install interrupt handler */ ret = devm_request_irq(dev, csi->irq, imx7_csi_irq_handler, 0, "csi", (void *)csi); @@ -1223,7 +1228,6 @@ static int imx7_csi_probe(struct platform_device *pdev) ret = PTR_ERR(imxmd); goto destroy_mutex; } - platform_set_drvdata(pdev, &csi->sd); ret = imx_media_of_add_csi(imxmd, node); if (ret < 0 && ret != -ENODEV && ret != -EEXIST) From patchwork Tue May 10 11:58:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571463 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 66BF0C433EF for ; Tue, 10 May 2022 11:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240529AbiEJMDQ (ORCPT ); Tue, 10 May 2022 08:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240118AbiEJMDP (ORCPT ); Tue, 10 May 2022 08:03:15 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0B71165AB for ; Tue, 10 May 2022 04:59:17 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D4A72D18; Tue, 10 May 2022 13:59:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183953; bh=pcHJ/iHL8mYCDutTvm2V49TLbx7X/i0r5Te2u6dAS1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txmdQ+kWcu/zbqaNrqv8W8Y/lZTULi9dha3om5d2MzyRVHNJgIahwQm8C92ffF9vS xnbFtXkvH6R8IuP/GR6EBrlvex9XweAgPE91HMQq1VrCYdvWwRFj3hXlRaHax52VcK Dyp+Lekg+HeaTMDHLFwHOLtlAGjBVo32uwxsfl6c= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 04/50] staging: media: imx: imx7-media-csi: Drop duplicate link creation Date: Tue, 10 May 2022 14:58:13 +0300 Message-Id: <20220510115859.19777-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The imx_media_create_csi2_links() creates a media controller link between the CSI-2 receiver and the next entity in the pipeline, which can be either a video mux (handled by the video-mux driver) or the CSI bridge itself. This isn't needed, as the link is already created either by the video-mux driver or by the imx7-media-csi driver itself (in imx7_csi_notify_bound()). Drop imx_media_create_csi2_links(), which allows dropping the CSI bridge subdev grp_id. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 31 ---------------------- 1 file changed, 31 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 708076b7045a..e2d6dabad007 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -726,34 +726,6 @@ static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n) return container_of(n, struct imx_media_dev, notifier); } -/* - * Create the missing media links from the CSI-2 receiver. - * Called after all async subdevs have bound. - */ -static void imx_media_create_csi2_links(struct imx_media_dev *imxmd) -{ - struct v4l2_subdev *sd, *csi2 = NULL; - - list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { - if (sd->grp_id == IMX_MEDIA_GRP_ID_CSI2) { - csi2 = sd; - break; - } - } - if (!csi2) - return; - - list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { - /* skip if not a CSI or a CSI mux */ - if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) && - !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) && - !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI_MUX)) - continue; - - v4l2_create_fwnode_links(csi2, sd); - } -} - /* * adds given video device to given imx-media source pad vdev list. * Continues upstream from the pad entity's sink pads. @@ -883,8 +855,6 @@ static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier) mutex_lock(&imxmd->mutex); - imx_media_create_csi2_links(imxmd); - ret = imx_media_create_pad_vdev_lists(imxmd); if (ret) goto unlock; @@ -1477,7 +1447,6 @@ static int imx7_csi_probe(struct platform_device *pdev) csi->sd.dev = &pdev->dev; csi->sd.owner = THIS_MODULE; csi->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; - csi->sd.grp_id = IMX_MEDIA_GRP_ID_CSI; snprintf(csi->sd.name, sizeof(csi->sd.name), "csi"); for (i = 0; i < IMX7_CSI_PADS_NUM; i++) From patchwork Tue May 10 11:58:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571462 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 188CCC433EF for ; Tue, 10 May 2022 11:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241362AbiEJMDT (ORCPT ); Tue, 10 May 2022 08:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241270AbiEJMDS (ORCPT ); Tue, 10 May 2022 08:03:18 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6888D5046D for ; Tue, 10 May 2022 04:59:20 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 83C13E0C; Tue, 10 May 2022 13:59:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183955; bh=g1HSzGVKOFmiTz3acZlXrvGDr9k5S9lpIAwIEIkpp9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IGg2/1nYFSWINsoBkH9C621lW6eeOFDAlaxaIXg0FxUnuiUsx/oJV1Dc3CQSECS4o om8QTUAQNMYaHEUxIw5JR4MmG07gmaVvwGQMjrG0/cN+yYcuxrsIvq4B/LdvGHu0Ar vjcMBwMFwCAKFJ0xXbt+HeW79MV0kDGvCdRfZpnU= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de, Paul Elder Subject: [PATCH 06/50] staging: media: imx: imx7-media-csi: Move misc init out of probe() Date: Tue, 10 May 2022 14:58:15 +0300 Message-Id: <20220510115859.19777-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Paul Elder There is a chunk of miscellaneous initializations related to the CSI subdev and media pads directly in the probe function. Move them into the imx7_csi_media_init() function to clean up the probe function. Signed-off-by: Paul Elder --- drivers/staging/media/imx/imx7-media-csi.c | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 984f7bec15af..042dd4c0cb4d 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1342,7 +1342,7 @@ static void imx7_csi_media_cleanup(struct imx7_csi *csi) static int imx7_csi_media_init(struct imx7_csi *csi) { struct imx_media_dev *imxmd; - int ret; + int i, ret; /* add media device */ imxmd = imx_media_dev_init(csi->dev, NULL); @@ -1357,14 +1357,33 @@ static int imx7_csi_media_init(struct imx7_csi *csi) csi->imxmd = imxmd; - return 0; + v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); + v4l2_set_subdevdata(&csi->sd, csi); + csi->sd.internal_ops = &imx7_csi_internal_ops; + csi->sd.entity.ops = &imx7_csi_entity_ops; + csi->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + csi->sd.dev = csi->dev; + csi->sd.owner = THIS_MODULE; + csi->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + snprintf(csi->sd.name, sizeof(csi->sd.name), "csi"); + + for (i = 0; i < IMX7_CSI_PADS_NUM; i++) + csi->pad[i].flags = (i == IMX7_CSI_PAD_SINK) ? + MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; + + ret = media_entity_pads_init(&csi->sd.entity, IMX7_CSI_PADS_NUM, + csi->pad); + if (ret < 0) + return ret; + + return v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); } static int imx7_csi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct imx7_csi *csi; - int i, ret; + int ret; csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); if (!csi) @@ -1410,28 +1429,9 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret) goto destroy_mutex; - v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); - v4l2_set_subdevdata(&csi->sd, csi); - csi->sd.internal_ops = &imx7_csi_internal_ops; - csi->sd.entity.ops = &imx7_csi_entity_ops; - csi->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; - csi->sd.dev = &pdev->dev; - csi->sd.owner = THIS_MODULE; - csi->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; - snprintf(csi->sd.name, sizeof(csi->sd.name), "csi"); - - for (i = 0; i < IMX7_CSI_PADS_NUM; i++) - csi->pad[i].flags = (i == IMX7_CSI_PAD_SINK) ? - MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; - - ret = media_entity_pads_init(&csi->sd.entity, IMX7_CSI_PADS_NUM, - csi->pad); - if (ret < 0) - goto cleanup; - ret = v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); if (ret) - goto cleanup; + goto media_cleanup; ret = imx7_csi_async_register(csi); if (ret) @@ -1442,8 +1442,7 @@ static int imx7_csi_probe(struct platform_device *pdev) subdev_notifier_cleanup: v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); - -cleanup: +media_cleanup: imx7_csi_media_cleanup(csi); destroy_mutex: From patchwork Tue May 10 11:58:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571461 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 65775C433EF for ; Tue, 10 May 2022 11:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241374AbiEJMDV (ORCPT ); Tue, 10 May 2022 08:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241270AbiEJMDU (ORCPT ); Tue, 10 May 2022 08:03:20 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 468D05046D for ; Tue, 10 May 2022 04:59:23 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 406AAB60; Tue, 10 May 2022 13:59:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183956; bh=Hfk7LzAL2PoWuZNMaH9HkgU3bH8tE7q5YD8bmWHbQzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nG7BWDmyJMkmuZDVbzZG/tXYt8e9GYCz8H4TAPI7g1NhlhhtpztpfXqSXV4q36jRC StxbftzJCIkKpKMOgoOc//M/+9UiwxBzex2OW9KegQdKuy93CrZIvkCcVwKocBZLo/ uF8qnNXwULbKaiwXu+SRsDOSfyagbUTIJWhibqPo= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 08/50] staging: media: imx: imx7-media-csi: Drop unused frame_interval Date: Tue, 10 May 2022 14:58:17 +0300 Message-Id: <20220510115859.19777-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The frame_interval field of the imx7_csi structure is set but never used. Drop it. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e0b600580c21..cd063c4f3f40 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -181,7 +181,6 @@ struct imx7_csi { struct v4l2_mbus_framefmt format_mbus[IMX7_CSI_PADS_NUM]; const struct imx_media_pixfmt *cc[IMX7_CSI_PADS_NUM]; - struct v4l2_fract frame_interval[IMX7_CSI_PADS_NUM]; void __iomem *regbase; int irq; @@ -1056,10 +1055,6 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) &csi->cc[i]); if (ret < 0) return ret; - - /* init default frame interval */ - csi->frame_interval[i].numerator = 1; - csi->frame_interval[i].denominator = 30; } csi->vdev = imx_media_capture_device_init(csi->sd.dev, &csi->sd, From patchwork Tue May 10 11:58:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571460 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 CCB53C433FE for ; Tue, 10 May 2022 11:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241381AbiEJMDX (ORCPT ); Tue, 10 May 2022 08:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241375AbiEJMDW (ORCPT ); Tue, 10 May 2022 08:03:22 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71EC552E73 for ; Tue, 10 May 2022 04:59:25 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E04A0BA9; Tue, 10 May 2022 13:59:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183958; bh=d+7BkkERKznRknT/kY5nL7k0K2j0jSnisRVTDGKQ6Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMEMNQSmaDynk7910TrgmtlEBn6UPfMUVrZDV3qs7zlzRKmsHzUBDEmN1Sm6eLFR4 +bOIf+Mh9Q9+Mu334nCCDUv3w3om+alTsdhvGo1CQmclRqHG5A5q1cYKZ11Bl6eMGL g3Ps7VYfizoPrhQ3fWar3NkWx/VpYfMjECdAYepA= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de, Paul Elder Subject: [PATCH 10/50] staging: media: imx: imx7-media-csi: Remove imx_media_of_add_csi Date: Tue, 10 May 2022 14:58:19 +0300 Message-Id: <20220510115859.19777-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Paul Elder imx_media_of_add_csi() from imx-media-of.c validates that the fwnode for the CSI bridge is enabled, and adds the fwnode to the async notifier of the imxmd. The former is redundant, as if the CSI bridge driver probes, clearly it is enabled in the DT. The latter is not needed as the imxmd notifier isn't used anymore. The call is thus not needed and can be dropped. This removes the dependency of imx7-media-csi.c on imx-media-of.c. Signed-off-by: Paul Elder --- drivers/staging/media/imx/imx7-media-csi.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index d85b5ab204df..e7dcb602afae 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1203,12 +1203,6 @@ static int imx7_csi_media_init(struct imx7_csi *csi) if (IS_ERR(imxmd)) return PTR_ERR(imxmd); - ret = imx_media_of_add_csi(imxmd, csi->dev->of_node); - if (ret < 0 && ret != -ENODEV && ret != -EEXIST) { - imx7_csi_media_cleanup(csi); - return ret; - } - csi->imxmd = imxmd; v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); From patchwork Tue May 10 11:58:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571459 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 B3DAFC433EF for ; Tue, 10 May 2022 11:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241389AbiEJMD0 (ORCPT ); Tue, 10 May 2022 08:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241388AbiEJMDZ (ORCPT ); Tue, 10 May 2022 08:03:25 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BA8F5131E for ; Tue, 10 May 2022 04:59:27 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EE4141248; Tue, 10 May 2022 13:59:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183960; bh=fvLlTM3o+3rn3zzOQBxWlaa4ljFoBkY1Y//8BFiskao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PzIWVaJQb4hX8/rUairbnPSjPdAP7EOCo3lqAeCTBtFJa+LCgUyw4WLr/UB+uiDug ykXfv7Gh9gfRVEzc24QjO4gsIONobLHf9X/+l/VDmOFniRX8FRGlR/7gz+tZgtFjlH hPL/OgQk0m0IfDb7SQUaK3SGHJg1g7n5LVJ8GqSo= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 12/50] staging: media: imx: imx7-media-csi: Drop legacy video device support Date: Tue, 10 May 2022 14:58:21 +0300 Message-Id: <20220510115859.19777-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Drop all the code related to the unused (by this driver) legacy video device support. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 31 +++++----------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 63f291684e79..2e314ce961dc 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -746,8 +746,6 @@ struct capture_priv { spinlock_t q_lock; /* Protect ready_q */ struct v4l2_ctrl_handler ctrl_hdlr; /* Controls inherited from subdevs */ - - bool legacy_api; /* Use the legacy (pre-MC) API */ }; #define to_capture_priv(v) container_of(v, struct capture_priv, vdev) @@ -1240,20 +1238,10 @@ static int capture_init_format(struct capture_priv *priv) .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; struct imx_media_video_dev *vdev = &priv->vdev; - int ret; - if (priv->legacy_api) { - ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, - &fmt_src); - if (ret) { - dev_err(priv->dev, "failed to get source format\n"); - return ret; - } - } else { - fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8; - fmt_src.format.width = IMX_MEDIA_DEF_PIX_WIDTH; - fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT; - } + fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8; + fmt_src.format.width = IMX_MEDIA_DEF_PIX_WIDTH; + fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT; imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL); vdev->compose.width = fmt_src.format.width; @@ -1322,7 +1310,7 @@ static void imx7_media_capture_device_unregister(struct imx_media_video_dev *vde static struct imx_media_video_dev * imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, - int pad, bool legacy_api) + int pad) { struct capture_priv *priv; struct video_device *vfd; @@ -1336,7 +1324,6 @@ imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, priv->src_sd = src_sd; priv->src_sd_pad = pad; priv->dev = dev; - priv->legacy_api = legacy_api; mutex_init(&priv->mutex); INIT_LIST_HEAD(&priv->ready_q); @@ -1354,7 +1341,7 @@ imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, vfd->vfl_dir = VFL_DIR_RX; vfd->tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; vfd->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING - | (!legacy_api ? V4L2_CAP_IO_MC : 0); + | V4L2_CAP_IO_MC; vfd->lock = &priv->mutex; vfd->queue = &priv->q; @@ -1392,12 +1379,6 @@ imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, return ERR_PTR(ret); } - if (legacy_api) { - /* Initialize the control handler. */ - v4l2_ctrl_handler_init(&priv->ctrl_hdlr, 0); - vfd->ctrl_handler = &priv->ctrl_hdlr; - } - return &priv->vdev; } @@ -1742,7 +1723,7 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) int ret; csi->vdev = imx7_media_capture_device_init(csi->sd.dev, &csi->sd, - IMX7_CSI_PAD_SRC, false); + IMX7_CSI_PAD_SRC); if (IS_ERR(csi->vdev)) return PTR_ERR(csi->vdev); From patchwork Tue May 10 11:58:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571458 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 84251C433EF for ; Tue, 10 May 2022 11:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241414AbiEJMDb (ORCPT ); Tue, 10 May 2022 08:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241388AbiEJMD2 (ORCPT ); Tue, 10 May 2022 08:03:28 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 224E65418B for ; Tue, 10 May 2022 04:59:31 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9B44512B9; Tue, 10 May 2022 13:59:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183962; bh=VV3eplvYk/sJft+X1ditSjuXp/Rm1i02+4x1EUzfKII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VVTXMerwkML7H8HdCA6i5vO3bmCFuoS+iY0orWnFGvrfmaKiSGj7bCEQ4nz4LnyJG 0YpIsaRD/apHsFcpWChS/kkTxDeBtViSwYUWkTSSdKgeKThZnn/55YglwGhgsIEFsD 4o2KoVeSCX0Ce5dGYG3dNpLVz6HIGELbX8PaCwVA= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 14/50] staging: media: imx: imx7-media-csi: Reorganize imx7_csi structure Date: Tue, 10 May 2022 14:58:23 +0300 Message-Id: <20220510115859.19777-15-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The struct imx7_csi fields are in a random order, reorganize them logically to prepare for adding new fields. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 499bb74ad6f3..ad69c2e8dbc2 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -169,37 +169,41 @@ enum imx_csi_model { struct imx7_csi { struct device *dev; - struct v4l2_subdev sd; + + /* Resources and locks */ + void __iomem *regbase; + int irq; + struct clk *mclk; + + struct mutex lock; /* Protects is_streaming, format_mbus, cc */ + spinlock_t irqlock; /* Protects last_eof */ + + /* Media and V4L2 device */ + struct imx_media_dev *imxmd; struct v4l2_async_notifier notifier; - struct imx_media_video_dev *vdev; - struct imx_media_dev *imxmd; - struct media_pad pad[IMX7_CSI_PADS_NUM]; - - /* lock to protect members below */ - struct mutex lock; - /* lock to protect irq handler when stop streaming */ - spinlock_t irqlock; struct v4l2_subdev *src_sd; + bool is_csi2; + + /* V4L2 subdev */ + struct v4l2_subdev sd; + struct media_pad pad[IMX7_CSI_PADS_NUM]; struct v4l2_mbus_framefmt format_mbus[IMX7_CSI_PADS_NUM]; const struct imx_media_pixfmt *cc[IMX7_CSI_PADS_NUM]; - void __iomem *regbase; - int irq; - struct clk *mclk; + /* Video device */ + struct imx_media_video_dev *vdev; - /* active vb2 buffers to send to video dev sink */ + /* Buffers and streaming state */ struct imx_media_buffer *active_vb2_buf[2]; struct imx_media_dma_buf underrun_buf; + bool is_streaming; int buf_num; u32 frame_sequence; bool last_eof; - bool is_streaming; - bool is_csi2; - struct completion last_eof_completion; enum imx_csi_model model; From patchwork Tue May 10 11:58:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571457 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 7A5F0C433F5 for ; Tue, 10 May 2022 11:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240993AbiEJMDe (ORCPT ); Tue, 10 May 2022 08:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241405AbiEJMDb (ORCPT ); Tue, 10 May 2022 08:03:31 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCB8646163 for ; Tue, 10 May 2022 04:59:33 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4FC14E0C; Tue, 10 May 2022 13:59:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183963; bh=ntJKLze6OrE+9OL6FEXItJoTrYmk7Yeef2Xythqg8GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ugR72czBZyuO7ErrE56ITEwFumuKzs/LVfxdoviq4hgPfm6KG4rSAYoXIAZ5tznHM km2JUJf4z0jVMdHLArx3Zg2cTeVdGY6GMK/KuVoRDCDyPi6/SIOcWsgoHLcjDBaHXA 2ZugrF0mT5VlPGPqMyfH8z3xary21w4oIbqQkQ9Y= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 16/50] staging: media: imx: imx7-media-csi: Ensure consistent function prefix Date: Tue, 10 May 2022 14:58:25 +0300 Message-Id: <20220510115859.19777-17-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Rename all the functions and macros imported from imx-media-capture.c with a consistent imx7_csi_video_ prefix. No functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 164 ++++++++++----------- 1 file changed, 80 insertions(+), 84 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 9b4463e456c2..80d666416d47 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -162,6 +162,10 @@ #define CSI_CSICR18 0x48 #define CSI_CSICR19 0x4c +#define IMX7_CSI_VIDEO_NAME "imx-capture" +/* In bytes, per queue */ +#define IMX7_CSI_VIDEO_MEM_LIMIT SZ_64M + enum imx_csi_model { IMX7_CSI_IMX7 = 0, IMX7_CSI_IMX8MQ, @@ -349,8 +353,7 @@ static void imx7_csi_update_buf(struct imx7_csi *csi, dma_addr_t phys, imx7_csi_reg_write(csi, phys, CSI_CSIDMASA_FB1); } -static struct imx_media_buffer * -imx7_media_capture_device_next_buf(struct imx7_csi *csi); +static struct imx_media_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi); static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) { @@ -360,7 +363,7 @@ static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) int i; for (i = 0; i < 2; i++) { - buf = imx7_media_capture_device_next_buf(csi); + buf = imx7_csi_video_next_buf(csi); if (buf) { csi->active_vb2_buf[i] = buf; vb2_buf = &buf->vbuf.vb2_buf; @@ -662,7 +665,7 @@ static void imx7_csi_vb2_buf_done(struct imx7_csi *csi) csi->frame_sequence++; /* get next queued buffer */ - next = imx7_media_capture_device_next_buf(csi); + next = imx7_csi_video_next_buf(csi); if (next) { phys = vb2_dma_contig_plane_dma_addr(&next->vbuf.vb2_buf, 0); csi->active_vb2_buf[csi->buf_num] = next; @@ -732,20 +735,12 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) return IRQ_HANDLED; } -/* ----------------------------------------------------------------------------- - * Video Capture Device - */ - -#define IMX_CAPTURE_NAME "imx-capture" - -/* In bytes, per queue */ -#define VID_MEM_LIMIT SZ_64M - /* ----------------------------------------------------------------------------- * Video Capture Device - IOCTLs */ -static const struct imx_media_pixfmt *capture_find_format(u32 code, u32 fourcc) +static const struct imx_media_pixfmt * +imx7_csi_video_find_format(u32 code, u32 fourcc) { const struct imx_media_pixfmt *cc; @@ -766,28 +761,28 @@ static const struct imx_media_pixfmt *capture_find_format(u32 code, u32 fourcc) return imx_media_find_mbus_format(code, PIXFMT_SEL_ANY); } -static int capture_querycap(struct file *file, void *fh, - struct v4l2_capability *cap) +static int imx7_csi_video_querycap(struct file *file, void *fh, + struct v4l2_capability *cap) { struct imx7_csi *csi = video_drvdata(file); - strscpy(cap->driver, IMX_CAPTURE_NAME, sizeof(cap->driver)); - strscpy(cap->card, IMX_CAPTURE_NAME, sizeof(cap->card)); + strscpy(cap->driver, IMX7_CSI_VIDEO_NAME, sizeof(cap->driver)); + strscpy(cap->card, IMX7_CSI_VIDEO_NAME, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", dev_name(csi->dev)); return 0; } -static int capture_enum_fmt_vid_cap(struct file *file, void *fh, - struct v4l2_fmtdesc *f) +static int imx7_csi_video_enum_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_fmtdesc *f) { return imx_media_enum_pixel_formats(&f->pixelformat, f->index, PIXFMT_SEL_ANY, f->mbus_code); } -static int capture_enum_framesizes(struct file *file, void *fh, - struct v4l2_frmsizeenum *fsize) +static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *fsize) { const struct imx_media_pixfmt *cc; @@ -814,8 +809,8 @@ static int capture_enum_framesizes(struct file *file, void *fh, return 0; } -static int capture_g_fmt_vid_cap(struct file *file, void *fh, - struct v4l2_format *f) +static int imx7_csi_video_g_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) { struct imx7_csi *csi = video_drvdata(file); @@ -825,7 +820,8 @@ static int capture_g_fmt_vid_cap(struct file *file, void *fh, } static const struct imx_media_pixfmt * -__capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose) +__imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, + struct v4l2_rect *compose) { struct v4l2_mbus_framefmt fmt_src; const struct imx_media_pixfmt *cc; @@ -867,15 +863,15 @@ __capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose) return cc; } -static int capture_try_fmt_vid_cap(struct file *file, void *fh, - struct v4l2_format *f) +static int imx7_csi_video_try_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) { - __capture_try_fmt(&f->fmt.pix, NULL); + __imx7_csi_video_try_fmt(&f->fmt.pix, NULL); return 0; } -static int capture_s_fmt_vid_cap(struct file *file, void *fh, - struct v4l2_format *f) +static int imx7_csi_video_s_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) { struct imx7_csi *csi = video_drvdata(file); const struct imx_media_pixfmt *cc; @@ -885,7 +881,7 @@ static int capture_s_fmt_vid_cap(struct file *file, void *fh, return -EBUSY; } - cc = __capture_try_fmt(&f->fmt.pix, &csi->vdev.compose); + cc = __imx7_csi_video_try_fmt(&f->fmt.pix, &csi->vdev.compose); csi->vdev.cc = cc; csi->vdev.fmt = f->fmt.pix; @@ -893,8 +889,8 @@ static int capture_s_fmt_vid_cap(struct file *file, void *fh, return 0; } -static int capture_g_selection(struct file *file, void *fh, - struct v4l2_selection *s) +static int imx7_csi_video_g_selection(struct file *file, void *fh, + struct v4l2_selection *s) { struct imx7_csi *csi = video_drvdata(file); @@ -923,8 +919,8 @@ static int capture_g_selection(struct file *file, void *fh, return 0; } -static int capture_subscribe_event(struct v4l2_fh *fh, - const struct v4l2_event_subscription *sub) +static int imx7_csi_video_subscribe_event(struct v4l2_fh *fh, + const struct v4l2_event_subscription *sub) { switch (sub->type) { case V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR: @@ -934,17 +930,17 @@ static int capture_subscribe_event(struct v4l2_fh *fh, } } -static const struct v4l2_ioctl_ops capture_ioctl_ops = { - .vidioc_querycap = capture_querycap, +static const struct v4l2_ioctl_ops imx7_csi_video_ioctl_ops = { + .vidioc_querycap = imx7_csi_video_querycap, - .vidioc_enum_fmt_vid_cap = capture_enum_fmt_vid_cap, - .vidioc_enum_framesizes = capture_enum_framesizes, + .vidioc_enum_fmt_vid_cap = imx7_csi_video_enum_fmt_vid_cap, + .vidioc_enum_framesizes = imx7_csi_video_enum_framesizes, - .vidioc_g_fmt_vid_cap = capture_g_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = capture_try_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = capture_s_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = imx7_csi_video_g_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = imx7_csi_video_try_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = imx7_csi_video_s_fmt_vid_cap, - .vidioc_g_selection = capture_g_selection, + .vidioc_g_selection = imx7_csi_video_g_selection, .vidioc_reqbufs = vb2_ioctl_reqbufs, .vidioc_create_bufs = vb2_ioctl_create_bufs, @@ -956,7 +952,7 @@ static const struct v4l2_ioctl_ops capture_ioctl_ops = { .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, - .vidioc_subscribe_event = capture_subscribe_event, + .vidioc_subscribe_event = imx7_csi_video_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; @@ -964,11 +960,11 @@ static const struct v4l2_ioctl_ops capture_ioctl_ops = { * Video Capture Device - Queue Operations */ -static int capture_queue_setup(struct vb2_queue *vq, - unsigned int *nbuffers, - unsigned int *nplanes, - unsigned int sizes[], - struct device *alloc_devs[]) +static int imx7_csi_video_queue_setup(struct vb2_queue *vq, + unsigned int *nbuffers, + unsigned int *nplanes, + unsigned int sizes[], + struct device *alloc_devs[]) { struct imx7_csi *csi = vb2_get_drv_priv(vq); struct v4l2_pix_format *pix = &csi->vdev.fmt; @@ -983,7 +979,7 @@ static int capture_queue_setup(struct vb2_queue *vq, count += vq->num_buffers; } - count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count); + count = min_t(__u32, IMX7_CSI_VIDEO_MEM_LIMIT / pix->sizeimage, count); if (*nplanes) *nbuffers = (count < vq->num_buffers) ? 0 : @@ -997,7 +993,7 @@ static int capture_queue_setup(struct vb2_queue *vq, return 0; } -static int capture_buf_init(struct vb2_buffer *vb) +static int imx7_csi_video_buf_init(struct vb2_buffer *vb) { struct imx_media_buffer *buf = to_imx_media_vb(vb); @@ -1006,7 +1002,7 @@ static int capture_buf_init(struct vb2_buffer *vb) return 0; } -static int capture_buf_prepare(struct vb2_buffer *vb) +static int imx7_csi_video_buf_prepare(struct vb2_buffer *vb) { struct imx7_csi *csi = vb2_get_drv_priv(vb->vb2_queue); struct v4l2_pix_format *pix = &csi->vdev.fmt; @@ -1023,7 +1019,7 @@ static int capture_buf_prepare(struct vb2_buffer *vb) return 0; } -static void capture_buf_queue(struct vb2_buffer *vb) +static void imx7_csi_video_buf_queue(struct vb2_buffer *vb) { struct imx7_csi *csi = vb2_get_drv_priv(vb->vb2_queue); struct imx_media_buffer *buf = to_imx_media_vb(vb); @@ -1036,7 +1032,7 @@ static void capture_buf_queue(struct vb2_buffer *vb) spin_unlock_irqrestore(&csi->q_lock, flags); } -static int capture_validate_fmt(struct imx7_csi *csi) +static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) { struct v4l2_subdev_format fmt_src; const struct imx_media_pixfmt *cc; @@ -1064,21 +1060,22 @@ static int capture_validate_fmt(struct imx7_csi *csi) * Verify that the media bus code is compatible with the pixel format * set on the video node. */ - cc = capture_find_format(fmt_src.format.code, 0); + cc = imx7_csi_video_find_format(fmt_src.format.code, 0); if (!cc || csi->vdev.cc->cs != cc->cs) return -EPIPE; return 0; } -static int capture_start_streaming(struct vb2_queue *vq, unsigned int count) +static int imx7_csi_video_start_streaming(struct vb2_queue *vq, + unsigned int count) { struct imx7_csi *csi = vb2_get_drv_priv(vq); struct imx_media_buffer *buf, *tmp; unsigned long flags; int ret; - ret = capture_validate_fmt(csi); + ret = imx7_csi_video_validate_fmt(csi); if (ret) { dev_err(csi->dev, "capture format not valid\n"); goto return_bufs; @@ -1102,7 +1099,7 @@ static int capture_start_streaming(struct vb2_queue *vq, unsigned int count) return ret; } -static void capture_stop_streaming(struct vb2_queue *vq) +static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) { struct imx7_csi *csi = vb2_get_drv_priv(vq); struct imx_media_buffer *frame; @@ -1123,22 +1120,22 @@ static void capture_stop_streaming(struct vb2_queue *vq) spin_unlock_irqrestore(&csi->q_lock, flags); } -static const struct vb2_ops capture_qops = { - .queue_setup = capture_queue_setup, - .buf_init = capture_buf_init, - .buf_prepare = capture_buf_prepare, - .buf_queue = capture_buf_queue, +static const struct vb2_ops imx7_csi_video_qops = { + .queue_setup = imx7_csi_video_queue_setup, + .buf_init = imx7_csi_video_buf_init, + .buf_prepare = imx7_csi_video_buf_prepare, + .buf_queue = imx7_csi_video_buf_queue, .wait_prepare = vb2_ops_wait_prepare, .wait_finish = vb2_ops_wait_finish, - .start_streaming = capture_start_streaming, - .stop_streaming = capture_stop_streaming, + .start_streaming = imx7_csi_video_start_streaming, + .stop_streaming = imx7_csi_video_stop_streaming, }; /* ----------------------------------------------------------------------------- * Video Capture Device - File Operations */ -static int capture_open(struct file *file) +static int imx7_csi_video_open(struct file *file) { struct imx7_csi *csi = video_drvdata(file); struct video_device *vfd = csi->vdev.vfd; @@ -1162,7 +1159,7 @@ static int capture_open(struct file *file) return ret; } -static int capture_release(struct file *file) +static int imx7_csi_video_release(struct file *file) { struct imx7_csi *csi = video_drvdata(file); struct video_device *vfd = csi->vdev.vfd; @@ -1182,10 +1179,10 @@ static int capture_release(struct file *file) return 0; } -static const struct v4l2_file_operations capture_fops = { +static const struct v4l2_file_operations imx7_csi_video_fops = { .owner = THIS_MODULE, - .open = capture_open, - .release = capture_release, + .open = imx7_csi_video_open, + .release = imx7_csi_video_release, .poll = vb2_fop_poll, .unlocked_ioctl = video_ioctl2, .mmap = vb2_fop_mmap, @@ -1195,8 +1192,7 @@ static const struct v4l2_file_operations capture_fops = { * Video Capture Device - Init & Cleanup */ -static struct imx_media_buffer * -imx7_media_capture_device_next_buf(struct imx7_csi *csi) +static struct imx_media_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi) { struct imx_media_buffer *buf = NULL; unsigned long flags; @@ -1215,7 +1211,7 @@ imx7_media_capture_device_next_buf(struct imx7_csi *csi) return buf; } -static int capture_init_format(struct imx7_csi *csi) +static int imx7_csi_video_init_format(struct imx7_csi *csi) { struct v4l2_subdev_format fmt_src = { .pad = IMX7_CSI_PAD_SRC, @@ -1237,7 +1233,7 @@ static int capture_init_format(struct imx7_csi *csi) return 0; } -static int imx7_media_capture_device_register(struct imx7_csi *csi) +static int imx7_csi_video_register(struct imx7_csi *csi) { struct v4l2_subdev *sd = &csi->sd; struct v4l2_device *v4l2_dev = sd->v4l2_dev; @@ -1247,7 +1243,7 @@ static int imx7_media_capture_device_register(struct imx7_csi *csi) vfd->v4l2_dev = v4l2_dev; /* Initialize the default format and compose rectangle. */ - ret = capture_init_format(csi); + ret = imx7_csi_video_init_format(csi); if (ret < 0) return ret; @@ -1277,7 +1273,7 @@ static int imx7_media_capture_device_register(struct imx7_csi *csi) return 0; } -static void imx7_media_capture_device_unregister(struct imx7_csi *csi) +static void imx7_csi_video_unregister(struct imx7_csi *csi) { struct video_device *vfd = csi->vdev.vfd; @@ -1285,7 +1281,7 @@ static void imx7_media_capture_device_unregister(struct imx7_csi *csi) video_unregister_device(vfd); } -static int imx7_media_capture_device_init(struct imx7_csi *csi) +static int imx7_csi_video_init(struct imx7_csi *csi) { struct video_device *vfd; struct vb2_queue *vq; @@ -1300,8 +1296,8 @@ static int imx7_media_capture_device_init(struct imx7_csi *csi) if (!vfd) return -ENOMEM; - vfd->fops = &capture_fops; - vfd->ioctl_ops = &capture_ioctl_ops; + vfd->fops = &imx7_csi_video_fops; + vfd->ioctl_ops = &imx7_csi_video_ioctl_ops; vfd->minor = -1; vfd->release = video_device_release; vfd->vfl_dir = VFL_DIR_RX; @@ -1331,7 +1327,7 @@ static int imx7_media_capture_device_init(struct imx7_csi *csi) vq->io_modes = VB2_MMAP | VB2_DMABUF; vq->drv_priv = csi; vq->buf_struct_size = sizeof(struct imx_media_buffer); - vq->ops = &capture_qops; + vq->ops = &imx7_csi_video_qops; vq->mem_ops = &vb2_dma_contig_memops; vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; vq->lock = &csi->vdev_mutex; @@ -1681,11 +1677,11 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) struct imx7_csi *csi = v4l2_get_subdevdata(sd); int ret; - ret = imx7_media_capture_device_init(csi); + ret = imx7_csi_video_init(csi); if (ret) return ret; - ret = imx7_media_capture_device_register(csi); + ret = imx7_csi_video_register(csi); if (ret) return ret; @@ -1700,7 +1696,7 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) return 0; err_unreg: - imx7_media_capture_device_unregister(csi); + imx7_csi_video_unregister(csi); return ret; } @@ -1708,7 +1704,7 @@ static void imx7_csi_unregistered(struct v4l2_subdev *sd) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); - imx7_media_capture_device_unregister(csi); + imx7_csi_video_unregister(csi); } static const struct v4l2_subdev_video_ops imx7_csi_video_ops = { From patchwork Tue May 10 11:58:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571456 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 BAB6CC4332F for ; Tue, 10 May 2022 11:59:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241429AbiEJMDg (ORCPT ); Tue, 10 May 2022 08:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241426AbiEJMDe (ORCPT ); Tue, 10 May 2022 08:03:34 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F445046D for ; Tue, 10 May 2022 04:59:36 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F2B161224; Tue, 10 May 2022 13:59:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183965; bh=zHEDlecSQr99fSBCxfJcECaZP6Pkmnn8f2Cu8iYM8vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LUvCyi3KPApH3DqUMDEPxSak7LFElaW91HyrfMXGJVJbzOsoJikadJ+30G/FOzKIG TWaZe0Tn0HXEOPy3WZSJn38dLhXvCqVZxrHzW9ZB+haMX+06umze0Befcgg31vzCgy pTgoC0hQKblsZE+W77T3gU15RK0aX6zP5e6XxLis= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 18/50] staging: media: imx: imx7-media-csi: Import imx_media_dev_init() helper Date: Tue, 10 May 2022 14:58:27 +0300 Message-Id: <20220510115859.19777-19-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org To prepare for code refactoring, copy the imx_media_dev_init() helper used by this driver from imx-media-dev-common.c. Rename the function to avoid name clashes, and leave the v4l2_device notify handler out as it only serves to implement control inheritance, which this driver doesn't use. No functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 50 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index bd1bdc09e701..8b19792adfc6 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1809,13 +1809,61 @@ static void imx7_csi_media_cleanup(struct imx7_csi *csi) media_device_cleanup(&imxmd->md); } +static const struct media_device_ops imx7_csi_media_ops = { + .link_notify = v4l2_pipeline_link_notify, +}; + +static struct imx_media_dev *imx7_csi_media_dev_init(struct device *dev) +{ + struct imx_media_dev *imxmd; + int ret; + + imxmd = devm_kzalloc(dev, sizeof(*imxmd), GFP_KERNEL); + if (!imxmd) + return ERR_PTR(-ENOMEM); + + dev_set_drvdata(dev, imxmd); + + strscpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model)); + imxmd->md.ops = &imx7_csi_media_ops; + imxmd->md.dev = dev; + + mutex_init(&imxmd->mutex); + + imxmd->v4l2_dev.mdev = &imxmd->md; + strscpy(imxmd->v4l2_dev.name, "imx-media", + sizeof(imxmd->v4l2_dev.name)); + snprintf(imxmd->md.bus_info, sizeof(imxmd->md.bus_info), + "platform:%s", dev_name(imxmd->md.dev)); + + media_device_init(&imxmd->md); + + ret = v4l2_device_register(dev, &imxmd->v4l2_dev); + if (ret < 0) { + v4l2_err(&imxmd->v4l2_dev, + "Failed to register v4l2_device: %d\n", ret); + goto cleanup; + } + + INIT_LIST_HEAD(&imxmd->vdev_list); + + v4l2_async_nf_init(&imxmd->notifier); + + return imxmd; + +cleanup: + media_device_cleanup(&imxmd->md); + + return ERR_PTR(ret); +} + static int imx7_csi_media_init(struct imx7_csi *csi) { struct imx_media_dev *imxmd; int i, ret; /* add media device */ - imxmd = imx_media_dev_init(csi->dev, NULL); + imxmd = imx7_csi_media_dev_init(csi->dev); if (IS_ERR(imxmd)) return PTR_ERR(imxmd); From patchwork Tue May 10 11:58:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571455 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 D608AC433EF for ; Tue, 10 May 2022 11:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241421AbiEJMDh (ORCPT ); Tue, 10 May 2022 08:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241425AbiEJMDg (ORCPT ); Tue, 10 May 2022 08:03:36 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 081255131E for ; Tue, 10 May 2022 04:59:39 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A0207BA9; Tue, 10 May 2022 13:59:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183967; bh=gm/2LW6ZHCvoGWF4lJlzBcDie/aSGoep0fsUMokwzPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+jeN6fLShQnt8YjDbtSwxEZ2WShY5ohU5M8yMwkpfBfYCDc13KspQQtWa0qN6qid GRGvIXz4CQcrZuULF6fRsjPipbUsieyCKV3k5J3gFKTxvEk386kzR01QBCKO5nIaUX lsxCfsC4PpUvZ7oyvGgz+m5WaD3bm52JUGvCL/Qo= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 20/50] staging: media: imx: imx7-media-csi: Drop imx_media_add_video_device call Date: Tue, 10 May 2022 14:58:29 +0300 Message-Id: <20220510115859.19777-21-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There's no need to call imx_media_add_video_device() anymore, as the video devices list it manages is only used by the control inheritance mechanism in the helpers, which this driver doesn't use. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 891e939d7ea5..b6643952da25 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1267,9 +1267,6 @@ static int imx7_csi_video_register(struct imx7_csi *csi) return ret; } - /* Add vdev to the video devices list. */ - imx_media_add_video_device(&csi->imxmd, &csi->vdev); - return 0; } From patchwork Tue May 10 11:58:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571454 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 B2943C433EF for ; Tue, 10 May 2022 11:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241443AbiEJMDk (ORCPT ); Tue, 10 May 2022 08:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241425AbiEJMDi (ORCPT ); Tue, 10 May 2022 08:03:38 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E91E46673 for ; Tue, 10 May 2022 04:59:41 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 52AD018C1; Tue, 10 May 2022 13:59:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183969; bh=wREWnlZORWJLC+76NQD4bNVhlmjZ7u0qButDdbEp29U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ji+tbR7X7ocw+GLi9TtlJ/WwdWok2ENdvdB9ZcFN6V6B+2zPf8JMgwqvYCBWG6x5M K1pkfgWH6n3u+wp4FjjSmrL2JjtQmIVJ0BI17ftxmwBmjLobeiyPPjIkeRef3Wmo/e 5DITVHPILoEHTV9odqxQnRwz/OKwBO6RO6h+6wvg= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 22/50] staging: media: imx: imx7-media-csi: Inline imx_media_pipeline_pad() Date: Tue, 10 May 2022 14:58:31 +0300 Message-Id: <20220510115859.19777-23-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Inline the imx_media_pipeline_pad() helper, dropping all the code unused by the imx7-media-csi driver. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 7e932884fd02..e1b494183ebc 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1605,7 +1605,8 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, struct imx7_csi *csi = v4l2_get_subdevdata(sd); struct imx_media_video_dev *vdev = &csi->vdev; const struct v4l2_pix_format *out_pix = &vdev->fmt; - struct media_pad *pad; + struct media_pad *pad = NULL; + unsigned int i; int ret; if (!csi->src_sd) @@ -1627,7 +1628,17 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, case MEDIA_ENT_F_VID_MUX: /* The input is the mux, check its input. */ - pad = imx_media_pipeline_pad(&csi->src_sd->entity, 0, 0, true); + for (i = 0; i < csi->src_sd->entity.num_pads; i++) { + struct media_pad *spad = &csi->src_sd->entity.pads[i]; + + if (!(spad->flags & MEDIA_PAD_FL_SINK)) + continue; + + pad = media_entity_remote_pad(spad); + if (pad) + break; + } + if (!pad) return -ENODEV; From patchwork Tue May 10 11:58:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571453 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 E4CD8C433F5 for ; Tue, 10 May 2022 11:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241447AbiEJMDm (ORCPT ); Tue, 10 May 2022 08:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241430AbiEJMDk (ORCPT ); Tue, 10 May 2022 08:03:40 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4DFC54BFB for ; Tue, 10 May 2022 04:59:43 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 03579B9A; Tue, 10 May 2022 13:59:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183970; bh=D5kh5m5dVFSdvWBJedF03x3RCtpo2Vy/S76Gby0LnNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pvH/EnMul8dQHfXufRAV8zjYPDEREsVNIw7QnyoNiRIohzbBDJFubs0zEgrS2xM1H 6T/G8/kBVT1AbcDWRZAM1ryn3pfA6J2mZAV+08WYXkH9OGbp+dLh+DzC+wjHNID75h 45VcWCrJvqQhOVbh7DEJde8OdjpE308urfY2sB0o= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 24/50] staging: media: imx: imx7-media-csi: Avoid unnecessary casts Date: Tue, 10 May 2022 14:58:33 +0300 Message-Id: <20220510115859.19777-25-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Simplify the imx7_csi_media_pipeline_set_stream() function by passing it the imx7_csi pointer, which avoids going from subdev to entity and back to subdev. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 31 +++++++--------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 1c8ee7c88f46..8600fc4d6be2 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1067,33 +1067,24 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) return 0; } -/* - * Turn current pipeline streaming on/off starting from entity. - */ -static int imx7_csi_media_pipeline_set_stream(struct imx_media_dev *imxmd, - struct media_entity *entity, - bool on) +static int imx7_csi_media_pipeline_set_stream(struct imx7_csi *csi, bool on) { - struct v4l2_subdev *sd; + struct imx_media_dev *imxmd = &csi->imxmd; int ret = 0; - if (!is_media_entity_v4l2_subdev(entity)) - return -EINVAL; - sd = media_entity_to_v4l2_subdev(entity); - mutex_lock(&imxmd->md.graph_mutex); if (on) { - ret = __media_pipeline_start(entity, &imxmd->pipe); + ret = __media_pipeline_start(&csi->sd.entity, &imxmd->pipe); if (ret) goto out; - ret = v4l2_subdev_call(sd, video, s_stream, 1); + ret = v4l2_subdev_call(&csi->sd, video, s_stream, 1); if (ret) - __media_pipeline_stop(entity); + __media_pipeline_stop(&csi->sd.entity); } else { - v4l2_subdev_call(sd, video, s_stream, 0); - if (entity->pipe) - __media_pipeline_stop(entity); + v4l2_subdev_call(&csi->sd, video, s_stream, 0); + if (csi->sd.entity.pipe) + __media_pipeline_stop(&csi->sd.entity); } out: @@ -1115,8 +1106,7 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto return_bufs; } - ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, - true); + ret = imx7_csi_media_pipeline_set_stream(csi, true); if (ret) { dev_err(csi->dev, "pipeline start failed with %d\n", ret); goto return_bufs; @@ -1142,8 +1132,7 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) unsigned long flags; int ret; - ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, - false); + ret = imx7_csi_media_pipeline_set_stream(csi, false); if (ret) dev_warn(csi->dev, "pipeline stop failed with %d\n", ret); From patchwork Tue May 10 11:58:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571452 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 69A70C433EF for ; Tue, 10 May 2022 11:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241442AbiEJMDo (ORCPT ); Tue, 10 May 2022 08:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241452AbiEJMDn (ORCPT ); Tue, 10 May 2022 08:03:43 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1DC052E73 for ; Tue, 10 May 2022 04:59:45 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AD517DFF; Tue, 10 May 2022 13:59:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183972; bh=HbKz4y1G2znjiWeWjvthgfOCUuheE0gfBZq5dYC849s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7dmKovMwuSeMdFD155VqE1xTNlS0baa4306+chZwyqMonjIx7VbYH+vTQG6geFJ4 Mqg+mTi0cTUNZfedLF0cz7F+AyIq8CFUwoJDIs3kcKZt79Uirt6sB/vBXe4UbJpC67 LiNxMumyEd1V142W85/YV8xScXddZs2E/efDLwlU= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 26/50] staging: media: imx: imx7-media-csi: Fold imx_media_dev into imx7_csi Date: Tue, 10 May 2022 14:58:35 +0300 Message-Id: <20220510115859.19777-27-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Now that the driver doesn't use any helper that relies on the imx_media_dev structure anymore, merge the three fields of the imx_media_dev structure directly in the imx7_csi structure. Update all the users accordingly. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 61 +++++++++++----------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 44c19c73da97..b116f6ab96f0 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -183,8 +183,10 @@ struct imx7_csi { spinlock_t irqlock; /* Protects last_eof */ /* Media and V4L2 device */ - struct imx_media_dev imxmd; + struct media_device mdev; + struct v4l2_device v4l2_dev; struct v4l2_async_notifier notifier; + struct media_pipeline pipe; struct v4l2_subdev *src_sd; bool is_csi2; @@ -1081,9 +1083,9 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto err_buffers; } - mutex_lock(&csi->imxmd.md.graph_mutex); + mutex_lock(&csi->mdev.graph_mutex); - ret = __media_pipeline_start(&csi->sd.entity, &csi->imxmd.pipe); + ret = __media_pipeline_start(&csi->sd.entity, &csi->pipe); if (ret) goto err_unlock; @@ -1091,14 +1093,14 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, if (ret) goto err_stop; - mutex_unlock(&csi->imxmd.md.graph_mutex); + mutex_unlock(&csi->mdev.graph_mutex); return 0; err_stop: __media_pipeline_stop(&csi->sd.entity); err_unlock: - mutex_unlock(&csi->imxmd.md.graph_mutex); + mutex_unlock(&csi->mdev.graph_mutex); dev_err(csi->dev, "pipeline start failed with %d\n", ret); err_buffers: spin_lock_irqsave(&csi->q_lock, flags); @@ -1117,10 +1119,10 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) struct imx_media_buffer *tmp; unsigned long flags; - mutex_lock(&csi->imxmd.md.graph_mutex); + mutex_lock(&csi->mdev.graph_mutex); v4l2_subdev_call(&csi->sd, video, s_stream, 0); __media_pipeline_stop(&csi->sd.entity); - mutex_unlock(&csi->imxmd.md.graph_mutex); + mutex_unlock(&csi->mdev.graph_mutex); /* release all active buffers */ spin_lock_irqsave(&csi->q_lock, flags); @@ -1704,11 +1706,11 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) if (ret) return ret; - ret = v4l2_device_register_subdev_nodes(&csi->imxmd.v4l2_dev); + ret = v4l2_device_register_subdev_nodes(&csi->v4l2_dev); if (ret) goto err_unreg; - ret = media_device_register(&csi->imxmd.md); + ret = media_device_register(&csi->mdev); if (ret) goto err_unreg; @@ -1778,7 +1780,7 @@ static int imx7_csi_notify_complete(struct v4l2_async_notifier *notifier) { struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier); - return v4l2_device_register_subdev_nodes(&csi->imxmd.v4l2_dev); + return v4l2_device_register_subdev_nodes(&csi->v4l2_dev); } static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { @@ -1812,7 +1814,7 @@ static int imx7_csi_async_register(struct imx7_csi *csi) csi->notifier.ops = &imx7_csi_notify_ops; - ret = v4l2_async_nf_register(&csi->imxmd.v4l2_dev, &csi->notifier); + ret = v4l2_async_nf_register(&csi->v4l2_dev, &csi->notifier); if (ret) return ret; @@ -1821,11 +1823,9 @@ static int imx7_csi_async_register(struct imx7_csi *csi) static void imx7_csi_media_cleanup(struct imx7_csi *csi) { - struct imx_media_dev *imxmd = &csi->imxmd; - - v4l2_device_unregister(&imxmd->v4l2_dev); - media_device_unregister(&imxmd->md); - media_device_cleanup(&imxmd->md); + v4l2_device_unregister(&csi->v4l2_dev); + media_device_unregister(&csi->mdev); + media_device_cleanup(&csi->mdev); } static const struct media_device_ops imx7_csi_media_ops = { @@ -1834,26 +1834,25 @@ static const struct media_device_ops imx7_csi_media_ops = { static int imx7_csi_media_dev_init(struct imx7_csi *csi) { - struct imx_media_dev *imxmd = &csi->imxmd; int ret; - dev_set_drvdata(csi->dev, imxmd); + dev_set_drvdata(csi->dev, csi); - strscpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model)); - imxmd->md.ops = &imx7_csi_media_ops; - imxmd->md.dev = csi->dev; + strscpy(csi->mdev.model, "imx-media", sizeof(csi->mdev.model)); + csi->mdev.ops = &imx7_csi_media_ops; + csi->mdev.dev = csi->dev; - imxmd->v4l2_dev.mdev = &imxmd->md; - strscpy(imxmd->v4l2_dev.name, "imx-media", - sizeof(imxmd->v4l2_dev.name)); - snprintf(imxmd->md.bus_info, sizeof(imxmd->md.bus_info), - "platform:%s", dev_name(imxmd->md.dev)); + csi->v4l2_dev.mdev = &csi->mdev; + strscpy(csi->v4l2_dev.name, "imx-media", + sizeof(csi->v4l2_dev.name)); + snprintf(csi->mdev.bus_info, sizeof(csi->mdev.bus_info), + "platform:%s", dev_name(csi->mdev.dev)); - media_device_init(&imxmd->md); + media_device_init(&csi->mdev); - ret = v4l2_device_register(csi->dev, &imxmd->v4l2_dev); + ret = v4l2_device_register(csi->dev, &csi->v4l2_dev); if (ret < 0) { - v4l2_err(&imxmd->v4l2_dev, + v4l2_err(&csi->v4l2_dev, "Failed to register v4l2_device: %d\n", ret); goto cleanup; } @@ -1861,7 +1860,7 @@ static int imx7_csi_media_dev_init(struct imx7_csi *csi) return 0; cleanup: - media_device_cleanup(&imxmd->md); + media_device_cleanup(&csi->mdev); return ret; } @@ -1894,7 +1893,7 @@ static int imx7_csi_media_init(struct imx7_csi *csi) if (ret < 0) return ret; - return v4l2_device_register_subdev(&csi->imxmd.v4l2_dev, &csi->sd); + return v4l2_device_register_subdev(&csi->v4l2_dev, &csi->sd); } static int imx7_csi_probe(struct platform_device *pdev) From patchwork Tue May 10 11:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571451 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 C998CC433F5 for ; Tue, 10 May 2022 11:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241451AbiEJMDq (ORCPT ); Tue, 10 May 2022 08:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241453AbiEJMDp (ORCPT ); Tue, 10 May 2022 08:03:45 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 343EE46163 for ; Tue, 10 May 2022 04:59:48 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6CCF019AD; Tue, 10 May 2022 13:59:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183974; bh=dOIuG8WAkRVjS+sir4i0rbt/c2SmHOREKpWNSEMUE7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Io0ytnxWf/YpJRuaXAu6+O4ekTaxjifKSuBFW3OiCPNJdbxksUCqbmMoX1skbCh7D OTmgDyTndFEvYve6E3s7Apy4woDhh1QrOtI0ymDeexDlsPC52viFQPRsDwUCy98lSo WktKxONHNJ1D/yKV8rXQdf7YFCeCjADkFYVA5gfk= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 28/50] staging: media: imx: imx7-media-csi: Fold imx_media_video_dev into imx7_csi Date: Tue, 10 May 2022 14:58:37 +0300 Message-Id: <20220510115859.19777-29-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Now that the driver doesn't use any helper that relies on the imx_media_video_dev structure anymore, merge its fields directly in the imx7_csi structure. Update all the users accordingly, and drop the list field that isn't used by the driver. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 121 ++++++++++----------- 1 file changed, 57 insertions(+), 64 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index bd1bc3fada2e..14683a15e003 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -212,9 +212,13 @@ struct imx7_csi { const struct imx_media_pixfmt *cc[IMX7_CSI_PADS_NUM]; /* Video device */ - struct imx_media_video_dev vdev; /* Video device */ + struct video_device *vdev; /* Video device */ struct media_pad vdev_pad; /* Video device pad */ + struct v4l2_pix_format vdev_fmt; /* The user format */ + const struct imx_media_pixfmt *vdev_cc; + struct v4l2_rect vdev_compose; /* The compose rectangle */ + struct mutex vdev_mutex; /* Protect vdev operations */ struct vb2_queue q; /* The videobuf2 queue */ @@ -413,11 +417,10 @@ static void imx7_csi_dma_unsetup_vb2_buf(struct imx7_csi *csi, static int imx7_csi_dma_setup(struct imx7_csi *csi) { - struct imx_media_video_dev *vdev = &csi->vdev; int ret; ret = imx_media_alloc_dma_buf(csi->dev, &csi->underrun_buf, - vdev->fmt.sizeimage); + csi->vdev_fmt.sizeimage); if (ret < 0) { v4l2_warn(&csi->sd, "consider increasing the CMA area\n"); return ret; @@ -464,8 +467,7 @@ static void imx7_csi_dma_stop(struct imx7_csi *csi) static void imx7_csi_configure(struct imx7_csi *csi) { - struct imx_media_video_dev *vdev = &csi->vdev; - struct v4l2_pix_format *out_pix = &vdev->fmt; + struct v4l2_pix_format *out_pix = &csi->vdev_fmt; int width = out_pix->width; u32 stride = 0; u32 cr3 = BIT_FRMCNT_RST; @@ -664,14 +666,13 @@ static void imx7_csi_error_recovery(struct imx7_csi *csi) static void imx7_csi_vb2_buf_done(struct imx7_csi *csi) { - struct imx_media_video_dev *vdev = &csi->vdev; struct imx7_csi_vb2_buffer *done, *next; struct vb2_buffer *vb; dma_addr_t phys; done = csi->active_vb2_buf[csi->buf_num]; if (done) { - done->vbuf.field = vdev->fmt.field; + done->vbuf.field = csi->vdev_fmt.field; done->vbuf.sequence = csi->frame_sequence; vb = &done->vbuf.vb2_buf; vb->timestamp = ktime_get_ns(); @@ -829,7 +830,7 @@ static int imx7_csi_video_g_fmt_vid_cap(struct file *file, void *fh, { struct imx7_csi *csi = video_drvdata(file); - f->fmt.pix = csi->vdev.fmt; + f->fmt.pix = csi->vdev_fmt; return 0; } @@ -896,10 +897,10 @@ static int imx7_csi_video_s_fmt_vid_cap(struct file *file, void *fh, return -EBUSY; } - cc = __imx7_csi_video_try_fmt(&f->fmt.pix, &csi->vdev.compose); + cc = __imx7_csi_video_try_fmt(&f->fmt.pix, &csi->vdev_compose); - csi->vdev.cc = cc; - csi->vdev.fmt = f->fmt.pix; + csi->vdev_cc = cc; + csi->vdev_fmt = f->fmt.pix; return 0; } @@ -914,7 +915,7 @@ static int imx7_csi_video_g_selection(struct file *file, void *fh, case V4L2_SEL_TGT_COMPOSE_DEFAULT: case V4L2_SEL_TGT_COMPOSE_BOUNDS: /* The compose rectangle is fixed to the source format. */ - s->r = csi->vdev.compose; + s->r = csi->vdev_compose; break; case V4L2_SEL_TGT_COMPOSE_PADDED: /* @@ -924,8 +925,8 @@ static int imx7_csi_video_g_selection(struct file *file, void *fh, */ s->r.left = 0; s->r.top = 0; - s->r.width = csi->vdev.fmt.width; - s->r.height = csi->vdev.fmt.height; + s->r.width = csi->vdev_fmt.width; + s->r.height = csi->vdev_fmt.height; break; default: return -EINVAL; @@ -982,7 +983,7 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, struct device *alloc_devs[]) { struct imx7_csi *csi = vb2_get_drv_priv(vq); - struct v4l2_pix_format *pix = &csi->vdev.fmt; + struct v4l2_pix_format *pix = &csi->vdev_fmt; unsigned int count = *nbuffers; if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -1020,7 +1021,7 @@ static int imx7_csi_video_buf_init(struct vb2_buffer *vb) static int imx7_csi_video_buf_prepare(struct vb2_buffer *vb) { struct imx7_csi *csi = vb2_get_drv_priv(vb->vb2_queue); - struct v4l2_pix_format *pix = &csi->vdev.fmt; + struct v4l2_pix_format *pix = &csi->vdev_fmt; if (vb2_plane_size(vb, 0) < pix->sizeimage) { dev_err(csi->dev, @@ -1063,12 +1064,12 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) /* * Verify that the media bus size matches the size set on the video * node. It is sufficient to check the compose rectangle size without - * checking the rounded size from vdev.fmt, as the rounded size is + * checking the rounded size from pix_fmt, as the rounded size is * derived directly from the compose rectangle size, and will thus * always match if the compose rectangle matches. */ - if (csi->vdev.compose.width != fmt_src.format.width || - csi->vdev.compose.height != fmt_src.format.height) + if (csi->vdev_compose.width != fmt_src.format.width || + csi->vdev_compose.height != fmt_src.format.height) return -EPIPE; /* @@ -1076,7 +1077,7 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) * set on the video node. */ cc = imx7_csi_video_find_format(fmt_src.format.code, 0); - if (!cc || csi->vdev.cc->cs != cc->cs) + if (!cc || csi->vdev_cc->cs != cc->cs) return -EPIPE; return 0; @@ -1164,7 +1165,6 @@ static const struct vb2_ops imx7_csi_video_qops = { static int imx7_csi_video_open(struct file *file) { struct imx7_csi *csi = video_drvdata(file); - struct video_device *vfd = csi->vdev.vfd; int ret; if (mutex_lock_interruptible(&csi->vdev_mutex)) @@ -1176,7 +1176,7 @@ static int imx7_csi_video_open(struct file *file) goto out; } - ret = v4l2_pipeline_pm_get(&vfd->entity); + ret = v4l2_pipeline_pm_get(&csi->vdev->entity); if (ret) v4l2_fh_release(file); @@ -1188,7 +1188,6 @@ static int imx7_csi_video_open(struct file *file) static int imx7_csi_video_release(struct file *file) { struct imx7_csi *csi = video_drvdata(file); - struct video_device *vfd = csi->vdev.vfd; struct vb2_queue *vq = &csi->q; mutex_lock(&csi->vdev_mutex); @@ -1198,7 +1197,7 @@ static int imx7_csi_video_release(struct file *file) vq->owner = NULL; } - v4l2_pipeline_pm_put(&vfd->entity); + v4l2_pipeline_pm_put(&csi->vdev->entity); v4l2_fh_release(file); mutex_unlock(&csi->vdev_mutex); @@ -1243,18 +1242,16 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) .pad = IMX7_CSI_PAD_SRC, .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; - struct imx_media_video_dev *vdev = &csi->vdev; - fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8; fmt_src.format.width = IMX_MEDIA_DEF_PIX_WIDTH; fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT; - imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL); - vdev->compose.width = fmt_src.format.width; - vdev->compose.height = fmt_src.format.height; + imx_media_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &fmt_src.format, NULL); + csi->vdev_compose.width = fmt_src.format.width; + csi->vdev_compose.height = fmt_src.format.height; - vdev->cc = imx_media_find_pixel_format(vdev->fmt.pixelformat, - PIXFMT_SEL_ANY); + csi->vdev_cc = imx_media_find_pixel_format(csi->vdev_fmt.pixelformat, + PIXFMT_SEL_ANY); return 0; } @@ -1263,10 +1260,10 @@ static int imx7_csi_video_register(struct imx7_csi *csi) { struct v4l2_subdev *sd = &csi->sd; struct v4l2_device *v4l2_dev = sd->v4l2_dev; - struct video_device *vfd = csi->vdev.vfd; + struct video_device *vdev = csi->vdev; int ret; - vfd->v4l2_dev = v4l2_dev; + vdev->v4l2_dev = v4l2_dev; /* Initialize the default format and compose rectangle. */ ret = imx7_csi_video_init_format(csi); @@ -1274,22 +1271,22 @@ static int imx7_csi_video_register(struct imx7_csi *csi) return ret; /* Register the video device. */ - ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1); + ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) { dev_err(csi->dev, "Failed to register video device\n"); return ret; } - dev_info(csi->dev, "Registered %s as /dev/%s\n", vfd->name, - video_device_node_name(vfd)); + dev_info(csi->dev, "Registered %s as /dev/%s\n", vdev->name, + video_device_node_name(vdev)); /* Create the link from the CSI subdev to the video device. */ - ret = media_create_pad_link(&sd->entity, IMX7_CSI_PAD_SRC, &vfd->entity, - 0, MEDIA_LNK_FL_IMMUTABLE | + ret = media_create_pad_link(&sd->entity, IMX7_CSI_PAD_SRC, + &vdev->entity, 0, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); if (ret) { dev_err(csi->dev, "failed to create link to device node\n"); - video_unregister_device(vfd); + video_unregister_device(vdev); return ret; } @@ -1298,15 +1295,13 @@ static int imx7_csi_video_register(struct imx7_csi *csi) static void imx7_csi_video_unregister(struct imx7_csi *csi) { - struct video_device *vfd = csi->vdev.vfd; - - media_entity_cleanup(&vfd->entity); - video_unregister_device(vfd); + media_entity_cleanup(&csi->vdev->entity); + video_unregister_device(csi->vdev); } static int imx7_csi_video_init(struct imx7_csi *csi) { - struct video_device *vfd; + struct video_device *vdev; struct vb2_queue *vq; int ret; @@ -1315,32 +1310,31 @@ static int imx7_csi_video_init(struct imx7_csi *csi) spin_lock_init(&csi->q_lock); /* Allocate and initialize the video device. */ - vfd = video_device_alloc(); - if (!vfd) + vdev = video_device_alloc(); + if (!vdev) return -ENOMEM; - vfd->fops = &imx7_csi_video_fops; - vfd->ioctl_ops = &imx7_csi_video_ioctl_ops; - vfd->minor = -1; - vfd->release = video_device_release; - vfd->vfl_dir = VFL_DIR_RX; - vfd->tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; - vfd->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING + vdev->fops = &imx7_csi_video_fops; + vdev->ioctl_ops = &imx7_csi_video_ioctl_ops; + vdev->minor = -1; + vdev->release = video_device_release; + vdev->vfl_dir = VFL_DIR_RX; + vdev->tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; - vfd->lock = &csi->vdev_mutex; - vfd->queue = &csi->q; + vdev->lock = &csi->vdev_mutex; + vdev->queue = &csi->q; - snprintf(vfd->name, sizeof(vfd->name), "%s capture", csi->sd.name); + snprintf(vdev->name, sizeof(vdev->name), "%s capture", csi->sd.name); - video_set_drvdata(vfd, csi); - csi->vdev.vfd = vfd; - INIT_LIST_HEAD(&csi->vdev.list); + video_set_drvdata(vdev, csi); + csi->vdev = vdev; /* Initialize the video device pad. */ csi->vdev_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_pads_init(&vfd->entity, 1, &csi->vdev_pad); + ret = media_entity_pads_init(&vdev->entity, 1, &csi->vdev_pad); if (ret) { - video_device_release(vfd); + video_device_release(vdev); return ret; } @@ -1360,7 +1354,7 @@ static int imx7_csi_video_init(struct imx7_csi *csi) ret = vb2_queue_init(vq); if (ret) { dev_err(csi->dev, "vb2_queue_init failed\n"); - video_device_release(vfd); + video_device_release(vdev); return ret; } @@ -1629,8 +1623,7 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); - struct imx_media_video_dev *vdev = &csi->vdev; - const struct v4l2_pix_format *out_pix = &vdev->fmt; + const struct v4l2_pix_format *out_pix = &csi->vdev_fmt; struct media_pad *pad = NULL; unsigned int i; int ret; From patchwork Tue May 10 11:58:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571450 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 2C5E6C4332F for ; Tue, 10 May 2022 11:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241476AbiEJMDs (ORCPT ); Tue, 10 May 2022 08:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241470AbiEJMDs (ORCPT ); Tue, 10 May 2022 08:03:48 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA43E54685 for ; Tue, 10 May 2022 04:59:50 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5DAF4E0C; Tue, 10 May 2022 13:59:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183977; bh=H0UZuPYvqIKi1smJ8Qfmjedgtg9V7e3LUJmJMM+87hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J7EOm4zh3ZfbthdkMlrxtQ48/G1BjkmHWv3CDqyTvhwRqOXwPmiriERlrLaTb5PfU LT9gkFqchrUUdNSx0pvfiX8Ds2sKyOkVpwpvb0fN+Bf5gJELwkwL2qkpCeLRqS+Dlf Fz+1uSlKwyrJzTd+bV5cUlZ+cC6OGzk4gK7t+/6A= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 31/50] staging: media: imx: imx7-media-csi: Decouple from shared macros Date: Tue, 10 May 2022 14:58:40 +0300 Message-Id: <20220510115859.19777-32-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Decouple from the IMX7_CSI_VIDEO_DEF_PIX_WIDTH, IMX7_CSI_VIDEO_DEF_PIX_HEIGHT and IMX_MEDIA_EOF_TIMEOUT macros defined in shared helpers by duplicating them in the imx7-media-csi driver, with a rename to avoid name clashes. No functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 05907d6257a8..2106a72ebe85 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -165,6 +165,9 @@ #define IMX7_CSI_VIDEO_NAME "imx-capture" /* In bytes, per queue */ #define IMX7_CSI_VIDEO_MEM_LIMIT SZ_64M +#define IMX7_CSI_VIDEO_DEF_PIX_WIDTH 640 +#define IMX7_CSI_VIDEO_DEF_PIX_HEIGHT 480 +#define IMX7_CSI_VIDEO_EOF_TIMEOUT 2000 enum imx_csi_model { IMX7_CSI_IMX7 = 0, @@ -488,7 +491,7 @@ static void imx7_csi_dma_stop(struct imx7_csi *csi) /* * and then wait for interrupt handler to mark completion. */ - timeout_jiffies = msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT); + timeout_jiffies = msecs_to_jiffies(IMX7_CSI_VIDEO_EOF_TIMEOUT); ret = wait_for_completion_timeout(&csi->last_eof_completion, timeout_jiffies); if (ret == 0) @@ -1275,8 +1278,8 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8; - fmt_src.format.width = IMX_MEDIA_DEF_PIX_WIDTH; - fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT; + fmt_src.format.width = IMX7_CSI_VIDEO_DEF_PIX_WIDTH; + fmt_src.format.height = IMX7_CSI_VIDEO_DEF_PIX_HEIGHT; imx_media_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &fmt_src.format, NULL); csi->vdev_compose.width = fmt_src.format.width; From patchwork Tue May 10 11:58:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571449 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 A88B7C433F5 for ; Tue, 10 May 2022 11:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241475AbiEJMDv (ORCPT ); Tue, 10 May 2022 08:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241477AbiEJMDu (ORCPT ); Tue, 10 May 2022 08:03:50 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706B353B52 for ; Tue, 10 May 2022 04:59:53 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 310FF1A49; Tue, 10 May 2022 13:59:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183977; bh=uk7QSLv2qM0UlTKkUT4qWhdMuv+9FNoxBd4UtAMVX14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ooWVWNX4AZouZLaGEJvdu9lAWJSs2gn6SYef0e52FVY33QHFIVoMuG+UmPAX8vLVg X9VCgYd8e1uw/7CC6ar6nl/L+iJIrfk3yrK9Hm0c3MYOs1NBBHSx7wsM9Yi+E8UBs1 gzMD8TdsTMX3PwoOH3CkKfMIN5CvMLK4P708X2+M= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 32/50] staging: media: imx: imx7-media-csi: Drop error message on alloc failure Date: Tue, 10 May 2022 14:58:41 +0300 Message-Id: <20220510115859.19777-33-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The kernel memory allocators already complain loudly to the log when allocation fails. There's no need for an additional message. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 2106a72ebe85..e5dc9525fa52 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -442,10 +442,8 @@ static int imx7_csi_alloc_dma_buf(struct imx7_csi *csi, buf->len = PAGE_ALIGN(size); buf->virt = dma_alloc_coherent(csi->dev, buf->len, &buf->phys, GFP_DMA | GFP_KERNEL); - if (!buf->virt) { - dev_err(csi->dev, "%s: failed\n", __func__); + if (!buf->virt) return -ENOMEM; - } return 0; } From patchwork Tue May 10 11:58:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571448 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 9DDDCC433F5 for ; Tue, 10 May 2022 11:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241489AbiEJMDy (ORCPT ); Tue, 10 May 2022 08:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241477AbiEJMDw (ORCPT ); Tue, 10 May 2022 08:03:52 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2385046D for ; Tue, 10 May 2022 04:59:55 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D9DE21838; Tue, 10 May 2022 13:59:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183979; bh=VdbQSy3P82Rsg+gZHdvz8pmd9A0c/1tnz7bkpEBrIAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1OQJOaOteI11+YyoyVrjCi1+xkZn97/W1+cOR8p/nNxyXtzcds+GT600hPmwLcBK sO/m5NSQgwLllCImSTagudc3ysIX/7411vIhZbGT+7xkDA4He8K5nJHKUSl9m49edx jTFDs0Kf5PdAV3vQTVA3qCDa3xv79bOZeNGH20lI= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 34/50] staging: media: imx: imx7-media-csi: Replace ipu_color_space with bool yuv field Date: Tue, 10 May 2022 14:58:43 +0300 Message-Id: <20220510115859.19777-35-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Replace the enum ipu_color_space cs field in struct imx7_csi_pixfmt with a bool yuv field. This decouples the driver from the unrelated IPUv3 headers. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 71 ++++++++-------------- 1 file changed, 26 insertions(+), 45 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 42f1485b3550..b8ce4fd7c55d 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -185,7 +185,7 @@ struct imx7_csi_pixfmt { int bpp; /* total bpp */ /* cycles per pixel for generic (bayer) formats for the parallel bus */ int cycles; - enum ipu_color_space cs; + bool yuv; bool planar; /* is a planar format */ bool bayer; /* is a raw bayer format */ bool ipufmt; /* is one of the IPU internal formats */ @@ -830,7 +830,7 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_UYVY8_1X16 ), - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 16, }, { .fourcc = V4L2_PIX_FMT_YUYV, @@ -838,37 +838,37 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_YUYV8_2X8, MEDIA_BUS_FMT_YUYV8_1X16 ), - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 16, }, { .fourcc = V4L2_PIX_FMT_YUV420, - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 12, .planar = true, }, { .fourcc = V4L2_PIX_FMT_YVU420, - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 12, .planar = true, }, { .fourcc = V4L2_PIX_FMT_YUV422P, - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 16, .planar = true, }, { .fourcc = V4L2_PIX_FMT_NV12, - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 12, .planar = true, }, { .fourcc = V4L2_PIX_FMT_NV16, - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 16, .planar = true, }, { .fourcc = V4L2_PIX_FMT_YUV32, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_AYUV8_1X32), - .cs = IPUV3_COLORSPACE_YUV, + .yuv = true, .bpp = 32, .ipufmt = true, }, @@ -876,7 +876,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { { .fourcc = V4L2_PIX_FMT_RGB565, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_RGB565_2X8_LE), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .cycles = 2, }, { @@ -885,59 +884,48 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_RGB888_1X24, MEDIA_BUS_FMT_RGB888_2X12_LE ), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 24, }, { .fourcc = V4L2_PIX_FMT_BGR24, - .cs = IPUV3_COLORSPACE_RGB, .bpp = 24, }, { .fourcc = V4L2_PIX_FMT_XRGB32, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_ARGB8888_1X32), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 32, }, { .fourcc = V4L2_PIX_FMT_XRGB32, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_ARGB8888_1X32), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 32, .ipufmt = true, }, { .fourcc = V4L2_PIX_FMT_XBGR32, - .cs = IPUV3_COLORSPACE_RGB, .bpp = 32, }, { .fourcc = V4L2_PIX_FMT_BGRX32, - .cs = IPUV3_COLORSPACE_RGB, .bpp = 32, }, { .fourcc = V4L2_PIX_FMT_RGBX32, - .cs = IPUV3_COLORSPACE_RGB, .bpp = 32, }, /*** raw bayer and grayscale formats start here ***/ { .fourcc = V4L2_PIX_FMT_SBGGR8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SBGGR8_1X8), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 8, .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGBRG8_1X8), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 8, .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGRBG8_1X8), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 8, .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SRGGB8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SRGGB8_1X8), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 8, .bayer = true, }, { @@ -948,7 +936,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SBGGR14_1X14, MEDIA_BUS_FMT_SBGGR16_1X16 ), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true, }, { @@ -959,7 +946,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SGBRG14_1X14, MEDIA_BUS_FMT_SGBRG16_1X16 ), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true, }, { @@ -970,7 +956,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SGRBG14_1X14, MEDIA_BUS_FMT_SGRBG16_1X16 ), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true, }, { @@ -981,7 +966,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SRGGB14_1X14, MEDIA_BUS_FMT_SRGGB16_1X16 ), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true, }, { @@ -991,19 +975,16 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y12_1X12 ), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 8, .bayer = true, }, { .fourcc = V4L2_PIX_FMT_Y10, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y10_1X10), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true, }, { .fourcc = V4L2_PIX_FMT_Y12, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y12_1X12), - .cs = IPUV3_COLORSPACE_RGB, .bpp = 16, .bayer = true, }, @@ -1031,9 +1012,9 @@ imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) if (sel_ipu != fmt->ipufmt) continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : - ((fmt->cs == IPUV3_COLORSPACE_YUV) ? - IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER + : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : + IMX7_CSI_PIXFMT_SEL_RGB); if ((fmt_sel & sel) && fmt->fourcc == fourcc) return fmt; @@ -1065,9 +1046,9 @@ imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) if (sel_ipu != fmt->ipufmt) continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : - ((fmt->cs == IPUV3_COLORSPACE_YUV) ? - IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER + : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : + IMX7_CSI_PIXFMT_SEL_RGB); if (!(fmt_sel & sel) || !fmt->codes) continue; @@ -1116,9 +1097,9 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, if (sel_ipu != fmt->ipufmt) continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : - ((fmt->cs == IPUV3_COLORSPACE_YUV) ? - IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER + : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : + IMX7_CSI_PIXFMT_SEL_RGB); if (!(fmt_sel & sel)) continue; @@ -1180,9 +1161,9 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index, if (sel_ipu != fmt->ipufmt) continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : - ((fmt->cs == IPUV3_COLORSPACE_YUV) ? - IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER + : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : + IMX7_CSI_PIXFMT_SEL_RGB); if (!(fmt_sel & sel) || !fmt->codes) continue; @@ -1226,7 +1207,7 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, mbus->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(mbus->colorspace); mbus->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(mbus->colorspace); mbus->quantization = - V4L2_MAP_QUANTIZATION_DEFAULT(lcc->cs == IPUV3_COLORSPACE_RGB, + V4L2_MAP_QUANTIZATION_DEFAULT(!lcc->yuv, mbus->colorspace, mbus->ycbcr_enc); @@ -1257,7 +1238,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, * TODO: the IPU currently does not support the AYUV32 format, * so until it does convert to a supported YUV format. */ - if (cc->ipufmt && cc->cs == IPUV3_COLORSPACE_YUV) { + if (cc->ipufmt && cc->yuv) { u32 code; imx7_csi_enum_mbus_formats(&code, 0, IMX7_CSI_PIXFMT_SEL_YUV); @@ -1299,7 +1280,7 @@ imx7_csi_video_find_format(u32 code, u32 fourcc) cc = imx7_csi_find_ipu_format(code, IMX7_CSI_PIXFMT_SEL_YUV_RGB); if (cc) { - enum imx7_csi_pixfmt_sel fmt_sel = cc->cs == IPUV3_COLORSPACE_YUV + enum imx7_csi_pixfmt_sel fmt_sel = cc->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB; @@ -1618,7 +1599,7 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) * set on the video node. */ cc = imx7_csi_video_find_format(fmt_src.format.code, 0); - if (!cc || csi->vdev_cc->cs != cc->cs) + if (!cc || csi->vdev_cc->yuv != cc->yuv) return -EPIPE; return 0; @@ -2066,7 +2047,7 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, cc = imx7_csi_find_ipu_format(tryfmt->code, IMX7_CSI_PIXFMT_SEL_YUV_RGB); - if (cc && cc->cs == IPUV3_COLORSPACE_RGB) + if (cc && !cc->yuv) is_rgb = true; switch (tryfmt->colorspace) { From patchwork Tue May 10 11:58:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571447 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 5C877C433F5 for ; Tue, 10 May 2022 12:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241495AbiEJMEA (ORCPT ); Tue, 10 May 2022 08:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241485AbiEJMD5 (ORCPT ); Tue, 10 May 2022 08:03:57 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB0B46673 for ; Tue, 10 May 2022 04:59:58 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 84AB9BA9; Tue, 10 May 2022 13:59:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183981; bh=Nsc9cQrGdNHUTWWL9yyzYak+ErdyW8aB4BwSgWgEAM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DEcl7bIDs2ku2bmNhttnO/gdt7kidjNoU0b7bML3rWSz4Y7+IDhwXskc7yBXW5UPk wJM2beTI3Rxd1EG1I+8ppF8fdddK3f9Mkt6m7DjS0VQJ8uOgm6SHl9LjJRLLX4/GLU u55Q5G2m6AeAuC+Hszr2Usf80plZLGbot9R1qakU= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 36/50] staging: media: imx: imx7-media-csi: Drop IPU-only formats Date: Tue, 10 May 2022 14:58:45 +0300 Message-Id: <20220510115859.19777-37-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The formats specific to the IPUv3 are not supported by the CSI bridge. Drop them, along with the related code. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 98 ++-------------------- 1 file changed, 6 insertions(+), 92 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index c8ff259452b1..17259922a082 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -188,7 +188,6 @@ struct imx7_csi_pixfmt { bool yuv; bool planar; /* is a planar format */ bool bayer; /* is a raw bayer format */ - bool ipufmt; /* is one of the IPU internal formats */ }; struct imx7_csi_vb2_buffer { @@ -811,7 +810,6 @@ enum imx7_csi_pixfmt_sel { IMX7_CSI_PIXFMT_SEL_YUV = BIT(0), /* select YUV formats */ IMX7_CSI_PIXFMT_SEL_RGB = BIT(1), /* select RGB formats */ IMX7_CSI_PIXFMT_SEL_BAYER = BIT(2), /* select BAYER formats */ - IMX7_CSI_PIXFMT_SEL_IPU = BIT(3), /* select IPU-internal formats */ IMX7_CSI_PIXFMT_SEL_YUV_RGB = IMX7_CSI_PIXFMT_SEL_YUV | IMX7_CSI_PIXFMT_SEL_RGB, IMX7_CSI_PIXFMT_SEL_ANY = IMX7_CSI_PIXFMT_SEL_YUV @@ -865,12 +863,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { .yuv = true, .bpp = 16, .planar = true, - }, { - .fourcc = V4L2_PIX_FMT_YUV32, - .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_AYUV8_1X32), - .yuv = true, - .bpp = 32, - .ipufmt = true, }, /*** RGB formats start here ***/ { @@ -892,11 +884,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { .fourcc = V4L2_PIX_FMT_XRGB32, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_ARGB8888_1X32), .bpp = 32, - }, { - .fourcc = V4L2_PIX_FMT_XRGB32, - .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_ARGB8888_1X32), - .bpp = 32, - .ipufmt = true, }, { .fourcc = V4L2_PIX_FMT_XBGR32, .bpp = 32, @@ -1000,18 +987,12 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { static const struct imx7_csi_pixfmt * imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) { - bool sel_ipu = fmt_sel & IMX7_CSI_PIXFMT_SEL_IPU; unsigned int i; - fmt_sel &= ~IMX7_CSI_PIXFMT_SEL_IPU; - for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; enum imx7_csi_pixfmt_sel sel; - if (sel_ipu != fmt->ipufmt) - continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); @@ -1033,19 +1014,13 @@ imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) static const struct imx7_csi_pixfmt * imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) { - bool sel_ipu = fmt_sel & IMX7_CSI_PIXFMT_SEL_IPU; unsigned int i; - fmt_sel &= ~IMX7_CSI_PIXFMT_SEL_IPU; - for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; enum imx7_csi_pixfmt_sel sel; unsigned int j; - if (sel_ipu != fmt->ipufmt) - continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); @@ -1062,12 +1037,6 @@ imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) return NULL; } -static inline const struct imx7_csi_pixfmt * -imx7_csi_find_ipu_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) -{ - return imx7_csi_find_mbus_format(code, fmt_sel | IMX7_CSI_PIXFMT_SEL_IPU); -} - /* * Enumerate entries in the pixel_formats[] array that match the * requested selection criteria. Return the fourcc that matches the @@ -1085,18 +1054,12 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, enum imx7_csi_pixfmt_sel fmt_sel, u32 code) { - bool sel_ipu = fmt_sel & IMX7_CSI_PIXFMT_SEL_IPU; unsigned int i; - fmt_sel &= ~IMX7_CSI_PIXFMT_SEL_IPU; - for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; enum imx7_csi_pixfmt_sel sel; - if (sel_ipu != fmt->ipufmt) - continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); @@ -1148,19 +1111,13 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, static int imx7_csi_enum_mbus_formats(u32 *code, u32 index, enum imx7_csi_pixfmt_sel fmt_sel) { - bool sel_ipu = fmt_sel & IMX7_CSI_PIXFMT_SEL_IPU; unsigned int i; - fmt_sel &= ~IMX7_CSI_PIXFMT_SEL_IPU; - for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; enum imx7_csi_pixfmt_sel sel; unsigned int j; - if (sel_ipu != fmt->ipufmt) - continue; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); @@ -1195,11 +1152,8 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, imx7_csi_enum_mbus_formats(&code, 0, IMX7_CSI_PIXFMT_SEL_YUV); lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); - if (!lcc) { - lcc = imx7_csi_find_ipu_format(code, IMX7_CSI_PIXFMT_SEL_YUV_RGB); - if (!lcc) - return -EINVAL; - } + if (!lcc) + return -EINVAL; mbus->code = code; @@ -1225,26 +1179,12 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, u32 stride; if (!cc) { - cc = imx7_csi_find_ipu_format(mbus->code, - IMX7_CSI_PIXFMT_SEL_YUV_RGB); - if (!cc) - cc = imx7_csi_find_mbus_format(mbus->code, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(mbus->code, + IMX7_CSI_PIXFMT_SEL_ANY); if (!cc) return -EINVAL; } - /* - * TODO: the IPU currently does not support the AYUV32 format, - * so until it does convert to a supported YUV format. - */ - if (cc->ipufmt && cc->yuv) { - u32 code; - - imx7_csi_enum_mbus_formats(&code, 0, IMX7_CSI_PIXFMT_SEL_YUV); - cc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_YUV); - } - /* Round up width for minimum burst size */ width = round_up(mbus->width, 8); @@ -1273,29 +1213,6 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, * Video Capture Device - IOCTLs */ -static const struct imx7_csi_pixfmt * -imx7_csi_video_find_format(u32 code, u32 fourcc) -{ - const struct imx7_csi_pixfmt *cc; - - cc = imx7_csi_find_ipu_format(code, IMX7_CSI_PIXFMT_SEL_YUV_RGB); - if (cc) { - enum imx7_csi_pixfmt_sel fmt_sel = cc->yuv - ? IMX7_CSI_PIXFMT_SEL_YUV - : IMX7_CSI_PIXFMT_SEL_RGB; - - cc = imx7_csi_find_pixel_format(fourcc, fmt_sel); - if (!cc) { - imx7_csi_enum_pixel_formats(&fourcc, 0, fmt_sel, 0); - cc = imx7_csi_find_pixel_format(fourcc, fmt_sel); - } - - return cc; - } - - return imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); -} - static int imx7_csi_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap) { @@ -1598,7 +1515,8 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) * Verify that the media bus code is compatible with the pixel format * set on the video node. */ - cc = imx7_csi_video_find_format(fmt_src.format.code, 0); + cc = imx7_csi_find_mbus_format(fmt_src.format.code, + IMX7_CSI_PIXFMT_SEL_ANY); if (!cc || csi->vdev_cc->yuv != cc->yuv) return -EPIPE; @@ -2038,10 +1956,6 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt) bool is_rgb = false; cc = imx7_csi_find_mbus_format(tryfmt->code, IMX7_CSI_PIXFMT_SEL_ANY); - if (!cc) - cc = imx7_csi_find_ipu_format(tryfmt->code, - IMX7_CSI_PIXFMT_SEL_YUV_RGB); - if (cc && !cc->yuv) is_rgb = true; From patchwork Tue May 10 11:58:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571446 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 B18FAC43217 for ; Tue, 10 May 2022 12:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241499AbiEJMEC (ORCPT ); Tue, 10 May 2022 08:04:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241484AbiEJMD7 (ORCPT ); Tue, 10 May 2022 08:03:59 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E54EA5131E for ; Tue, 10 May 2022 05:00:02 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 33DA621C3; Tue, 10 May 2022 13:59:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183982; bh=B6WanzxxZOvDy0QJchsYwXbrY8qfDYztQWKS2dM7214=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fI3sMoXzX4X0+qvSmW9WK+nzfZtBoBk3th1GlDI++8KQn7V0zIogemptiEjYSeUNp DmvaUhucaCTZ/PkzG5VmqOY0nak15DD1jtX8G/9AwumBRU8ChVbdhVGhQshsnHKZyi +uGsfYoN6Dl4EqoSZebg1+ASaZFOMVK+reYeDKik= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 38/50] staging: media: imx: imx7-media-csi: Make default formats consistent Date: Tue, 10 May 2022 14:58:47 +0300 Message-Id: <20220510115859.19777-39-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the same default image width and height for both the CSI subdev and the video node to achieve a consistent default through the driver. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 6704e5d4d43b..bcf57aff3572 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -165,10 +165,11 @@ #define IMX7_CSI_VIDEO_NAME "imx-capture" /* In bytes, per queue */ #define IMX7_CSI_VIDEO_MEM_LIMIT SZ_64M -#define IMX7_CSI_VIDEO_DEF_PIX_WIDTH 640 -#define IMX7_CSI_VIDEO_DEF_PIX_HEIGHT 480 #define IMX7_CSI_VIDEO_EOF_TIMEOUT 2000 +#define IMX7_CSI_DEF_PIX_WIDTH 640 +#define IMX7_CSI_DEF_PIX_HEIGHT 480 + enum imx_csi_model { IMX7_CSI_IMX7 = 0, IMX7_CSI_IMX8MQ, @@ -303,7 +304,8 @@ static void imx7_csi_init_default(struct imx7_csi *csi) imx7_csi_reg_write(csi, 0, CSI_CSICR2); imx7_csi_reg_write(csi, BIT_FRMCNT_RST, CSI_CSICR3); - imx7_csi_reg_write(csi, BIT_IMAGE_WIDTH(800) | BIT_IMAGE_HEIGHT(600), + imx7_csi_reg_write(csi, BIT_IMAGE_WIDTH(IMX7_CSI_DEF_PIX_WIDTH) | + BIT_IMAGE_HEIGHT(IMX7_CSI_DEF_PIX_HEIGHT), CSI_CSIIMAG_PARA); imx7_csi_reg_write(csi, BIT_DMA_REFLASH_RFF, CSI_CSICR3); @@ -1628,8 +1630,8 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8; - fmt_src.format.width = IMX7_CSI_VIDEO_DEF_PIX_WIDTH; - fmt_src.format.height = IMX7_CSI_VIDEO_DEF_PIX_HEIGHT; + fmt_src.format.width = IMX7_CSI_DEF_PIX_WIDTH; + fmt_src.format.height = IMX7_CSI_DEF_PIX_HEIGHT; imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &fmt_src.format, NULL); csi->vdev_compose.width = fmt_src.format.width; @@ -1818,8 +1820,9 @@ static int imx7_csi_init_cfg(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf = imx7_csi_get_format(csi, sd_state, i, which); - ret = imx7_csi_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE, - &csi->cc[i]); + ret = imx7_csi_init_mbus_fmt(mf, IMX7_CSI_DEF_PIX_WIDTH, + IMX7_CSI_DEF_PIX_HEIGHT, 0, + V4L2_FIELD_NONE, &csi->cc[i]); if (ret < 0) return ret; } From patchwork Tue May 10 11:58:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571445 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 27116C433FE for ; Tue, 10 May 2022 12:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241497AbiEJMEE (ORCPT ); Tue, 10 May 2022 08:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241490AbiEJMEB (ORCPT ); Tue, 10 May 2022 08:04:01 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01670165AB for ; Tue, 10 May 2022 05:00:05 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E154021CB; Tue, 10 May 2022 13:59:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183984; bh=aeX1orNGzBDkwKiTIbU/NLaLk/IOSa8sRNi19vKUMfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eDS2Xq0pU+YBTWQ1lMRWVyOQGYYlRTvi1gcswx3rkRsdnRxgMf4Bm6zAf74Kt8kE2 45lrtDgvej0hg8m2rXvxTbWjNSMhrYdgtnXdSgGNhIwgR7MjURgrkuooujmTGhNCSE CTJP8fRWsczN/mpHV9G9Ljpe77mzN+x2Xh25fuJ8= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 40/50] staging: media: imx: imx7-media-csi: Simplify default mbus code in try_fmt Date: Tue, 10 May 2022 14:58:49 +0300 Message-Id: <20220510115859.19777-41-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When trying a format on the subdev sink pad, if the requested media bus code isn't supported, fallback to the default with a simpler logic. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index f2e85e9851e4..f3b9ce03318f 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1972,11 +1972,10 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, *cc = imx7_csi_find_mbus_format(sdformat->format.code, IMX7_CSI_PIXFMT_SEL_ANY); if (!*cc) { - imx7_csi_enum_mbus_formats(&code, 0, - IMX7_CSI_PIXFMT_SEL_YUV_RGB); + code = IMX7_CSI_DEF_MBUS_CODE; *cc = imx7_csi_find_mbus_format(code, - IMX7_CSI_PIXFMT_SEL_YUV_RGB); - sdformat->format.code = (*cc)->codes[0]; + IMX7_CSI_PIXFMT_SEL_ANY); + sdformat->format.code = code; } if (sdformat->format.field != V4L2_FIELD_INTERLACED) From patchwork Tue May 10 11:58:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571444 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 E3D62C4332F for ; Tue, 10 May 2022 12:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241498AbiEJMEF (ORCPT ); Tue, 10 May 2022 08:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241500AbiEJMED (ORCPT ); Tue, 10 May 2022 08:04:03 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4697146163 for ; Tue, 10 May 2022 05:00:05 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BCE41B9A; Tue, 10 May 2022 13:59:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183985; bh=acBHI4Cc+IejSUvtpcxUVa16XO7kLHAsl0OGhtOqMnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sge6ZGDd8YVzTc3zpQDrh6SIMXZnB6OzXnUcNtYnol8kE0f039Mkyq3ZJlOu/37VU aWfvgF+BtLoYmHWJCI+yJK6Xm2SG7ULsszVIr2zsxzwpOs8rgWCm8l3Job2U2q9uR8 +Rf61QkUt1NVJRzXgNbFWFzARz8P8A+v8dylrWZY= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 41/50] staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors Date: Tue, 10 May 2022 14:58:50 +0300 Message-Id: <20220510115859.19777-42-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org All the format lookup functions are called with a ANY selector, drop selector support. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 105 +++++---------------- 1 file changed, 22 insertions(+), 83 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index f3b9ce03318f..ab101d82c253 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -809,17 +809,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) #define IMX_BUS_FMTS(fmt...) (const u32[]) {fmt, 0} -enum imx7_csi_pixfmt_sel { - IMX7_CSI_PIXFMT_SEL_YUV = BIT(0), /* select YUV formats */ - IMX7_CSI_PIXFMT_SEL_RGB = BIT(1), /* select RGB formats */ - IMX7_CSI_PIXFMT_SEL_BAYER = BIT(2), /* select BAYER formats */ - IMX7_CSI_PIXFMT_SEL_YUV_RGB = IMX7_CSI_PIXFMT_SEL_YUV - | IMX7_CSI_PIXFMT_SEL_RGB, - IMX7_CSI_PIXFMT_SEL_ANY = IMX7_CSI_PIXFMT_SEL_YUV - | IMX7_CSI_PIXFMT_SEL_RGB - | IMX7_CSI_PIXFMT_SEL_BAYER, -}; - /* * List of supported pixel formats for the subdevs. */ @@ -927,25 +916,16 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { /* * Search in the pixel_formats[] array for an entry with the given fourcc - * that matches the requested selection criteria and return it. - * - * @fourcc: Search for an entry with the given fourcc pixel format. - * @fmt_sel: Allow entries only with the given selection criteria. + * return it. */ -static const struct imx7_csi_pixfmt * -imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) +static const struct imx7_csi_pixfmt *imx7_csi_find_pixel_format(u32 fourcc) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if ((fmt_sel & sel) && fmt->fourcc == fourcc) + if (fmt->fourcc == fourcc) return fmt; } @@ -954,26 +934,17 @@ imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) /* * Search in the pixel_formats[] array for an entry with the given media - * bus code that matches the requested selection criteria and return it. - * - * @code: Search for an entry with the given media-bus code. - * @fmt_sel: Allow entries only with the given selection criteria. + * bus code and return it. */ -static const struct imx7_csi_pixfmt * -imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) +static const struct imx7_csi_pixfmt *imx7_csi_find_mbus_format(u32 code) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; unsigned int j; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if (!(fmt_sel & sel) || !fmt->codes) + if (!fmt->codes) continue; for (j = 0; fmt->codes[j]; j++) { @@ -993,27 +964,15 @@ imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) * @fourcc: The returned fourcc that matches the search criteria at * the requested match index. * @index: The requested match index. - * @fmt_sel: Include in the enumeration entries with the given selection - * criteria. * @code: If non-zero, only include in the enumeration entries matching this * media bus code. */ -static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, - enum imx7_csi_pixfmt_sel fmt_sel, - u32 code) +static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, u32 code) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; - - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if (!(fmt_sel & sel)) - continue; /* * If a media bus code is specified, only consider formats that @@ -1053,24 +1012,16 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, * @code: The returned media-bus code that matches the search criteria at * the requested match index. * @index: The requested match index. - * @fmt_sel: Include in the enumeration entries with the given selection - * criteria. */ -static int imx7_csi_enum_mbus_formats(u32 *code, u32 index, - enum imx7_csi_pixfmt_sel fmt_sel) +static int imx7_csi_enum_mbus_formats(u32 *code, u32 index) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; unsigned int j; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if (!(fmt_sel & sel) || !fmt->codes) + if (!fmt->codes) continue; for (j = 0; fmt->codes[j]; j++) { @@ -1099,7 +1050,7 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, if (code == 0) code = IMX7_CSI_DEF_MBUS_CODE; - lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); + lcc = imx7_csi_find_mbus_format(code); if (!lcc) return -EINVAL; @@ -1127,8 +1078,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, u32 stride; if (!cc) { - cc = imx7_csi_find_mbus_format(mbus->code, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(mbus->code); if (!cc) return -EINVAL; } @@ -1178,7 +1128,6 @@ static int imx7_csi_video_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { return imx7_csi_enum_pixel_formats(&f->pixelformat, f->index, - IMX7_CSI_PIXFMT_SEL_ANY, f->mbus_code); } @@ -1190,8 +1139,7 @@ static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, if (fsize->index > 0) return -EINVAL; - cc = imx7_csi_find_pixel_format(fsize->pixel_format, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_pixel_format(fsize->pixel_format); if (!cc) return -EINVAL; @@ -1232,13 +1180,10 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, * Find the pixel format, default to the first supported format if not * found. */ - cc = imx7_csi_find_pixel_format(pixfmt->pixelformat, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); if (!cc) { - imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, - IMX7_CSI_PIXFMT_SEL_ANY, 0); - cc = imx7_csi_find_pixel_format(pixfmt->pixelformat, - IMX7_CSI_PIXFMT_SEL_ANY); + imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, 0); + cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); } /* Allow IDMAC interweave but enforce field order from source. */ @@ -1463,8 +1408,7 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) * Verify that the media bus code is compatible with the pixel format * set on the video node. */ - cc = imx7_csi_find_mbus_format(fmt_src.format.code, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(fmt_src.format.code); if (!cc || csi->vdev_cc->yuv != cc->yuv) return -EPIPE; @@ -1638,8 +1582,7 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) csi->vdev_compose.width = fmt_src.format.width; csi->vdev_compose.height = fmt_src.format.height; - csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat, - IMX7_CSI_PIXFMT_SEL_ANY); + csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat); return 0; } @@ -1846,8 +1789,7 @@ static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd, switch (code->pad) { case IMX7_CSI_PAD_SINK: - ret = imx7_csi_enum_mbus_formats(&code->code, code->index, - IMX7_CSI_PIXFMT_SEL_ANY); + ret = imx7_csi_enum_mbus_formats(&code->code, code->index); break; case IMX7_CSI_PAD_SRC: if (code->index != 0) { @@ -1904,7 +1846,7 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt) const struct imx7_csi_pixfmt *cc; bool is_rgb = false; - cc = imx7_csi_find_mbus_format(tryfmt->code, IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(tryfmt->code); if (cc && !cc->yuv) is_rgb = true; @@ -1954,8 +1896,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, switch (sdformat->pad) { case IMX7_CSI_PAD_SRC: - in_cc = imx7_csi_find_mbus_format(in_fmt->code, - IMX7_CSI_PIXFMT_SEL_ANY); + in_cc = imx7_csi_find_mbus_format(in_fmt->code); sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; @@ -1969,12 +1910,10 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.ycbcr_enc = in_fmt->ycbcr_enc; break; case IMX7_CSI_PAD_SINK: - *cc = imx7_csi_find_mbus_format(sdformat->format.code, - IMX7_CSI_PIXFMT_SEL_ANY); + *cc = imx7_csi_find_mbus_format(sdformat->format.code); if (!*cc) { code = IMX7_CSI_DEF_MBUS_CODE; - *cc = imx7_csi_find_mbus_format(code, - IMX7_CSI_PIXFMT_SEL_ANY); + *cc = imx7_csi_find_mbus_format(code); sdformat->format.code = code; } From patchwork Tue May 10 11:58:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571443 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 9D1ECC433F5 for ; Tue, 10 May 2022 12:00:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241506AbiEJMEH (ORCPT ); Tue, 10 May 2022 08:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241501AbiEJMEH (ORCPT ); Tue, 10 May 2022 08:04:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C094F5418B for ; Tue, 10 May 2022 05:00:09 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4063CDFF; Tue, 10 May 2022 13:59:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183987; bh=KgBCrsGlH31L2cj6pWaqulM0WKSu9Yyu/7MNfoNUqqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oxS4CMlqGLPFVUeICbbQS3jFTKvUcxWAZZTI/QnAPSvchknp71/o4RkkrnWKWlkjp OVbrppFEY0nelIcq8Z+3Ms0hayHe1uCn66UZY3LAXDCjimV3eaaFqtdf2QaSKpVawd /PpYU4DHmrOhUZrkEZxoLP3VLh8T6ffyNTEfbggQ= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 44/50] staging: media: imx: imx7-media-csi: Simplify default format in try_fmt Date: Tue, 10 May 2022 14:58:53 +0300 Message-Id: <20220510115859.19777-45-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When trying a format on the video node, if the requested pixel format isn't supported, fallback to the default with a simpler logic. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index bc3a87656117..0fb5e0c03396 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -168,6 +168,7 @@ #define IMX7_CSI_VIDEO_EOF_TIMEOUT 2000 #define IMX7_CSI_DEF_MBUS_CODE MEDIA_BUS_FMT_UYVY8_2X8 +#define IMX7_CSI_DEF_PIX_FORMAT V4L2_PIX_FMT_UYVY #define IMX7_CSI_DEF_PIX_WIDTH 640 #define IMX7_CSI_DEF_PIX_HEIGHT 480 @@ -1130,7 +1131,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, */ cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); if (!cc) { - imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, 0); + pixfmt->pixelformat = IMX7_CSI_DEF_PIX_FORMAT; cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); } From patchwork Tue May 10 11:58:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571442 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 4FE6BC433EF for ; Tue, 10 May 2022 12:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241511AbiEJMEK (ORCPT ); Tue, 10 May 2022 08:04:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241501AbiEJMEJ (ORCPT ); Tue, 10 May 2022 08:04:09 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C80352E73 for ; Tue, 10 May 2022 05:00:12 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E493C21CD; Tue, 10 May 2022 13:59:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183989; bh=8RjlLCLqB3e6bnEKhzH3wSIoisKEZ2LtKIghyJR8FuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFG09sYFsxxRj5SMMS5H5KQbolIXa/AOoH5ZZOjflmotdNmmUyh89xGBJYMgoVjhI bLaBpbfxksE1yQ6Qm4iCRDBLp+JEklSCADWKklUyudP5eaEQUTq3VUPEvVUfTRjSVK xlzEh60XIvMLeV0Ca2asdQCp6dWGcAq7BI11hg/c= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 46/50] staging: media: imx: imx7-media-csi: Add V4L2_PIX_FMT_Y14 support Date: Tue, 10 May 2022 14:58:55 +0300 Message-Id: <20220510115859.19777-47-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The device supports 14-bit greyscale formats the same way it supports 14-bit Bayer formats. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 1bb60f245861..4d8e3c0a3633 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -905,6 +905,10 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { .fourcc = V4L2_PIX_FMT_Y12, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y12_1X12), .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_Y14, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y14_1X14), + .bpp = 16, }, }; @@ -2019,6 +2023,7 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, case V4L2_PIX_FMT_GREY: case V4L2_PIX_FMT_Y10: case V4L2_PIX_FMT_Y12: + case V4L2_PIX_FMT_Y14: case V4L2_PIX_FMT_SBGGR8: case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: From patchwork Tue May 10 11:58:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571441 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 BFE45C433EF for ; Tue, 10 May 2022 12:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241014AbiEJMEP (ORCPT ); Tue, 10 May 2022 08:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241514AbiEJMEL (ORCPT ); Tue, 10 May 2022 08:04:11 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F2D52E73 for ; Tue, 10 May 2022 05:00:14 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 99A7E12B9; Tue, 10 May 2022 13:59:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183991; bh=7n8of1MXRoPvO3JeUjedG56zxX0gutOm/D21RqQZXt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ENzGDGlY4MmHgWZSG0IsM7kwAMfyAy0f6pKWjtrS7tBcgx/4Sq6N6mx+1DNeSPIgS 5KGw1AGgzmUZQUrBJtwP9jyK/00p31RIXjzhVfd5Gw5OtF4DjsNaA3PloStOj6aZGB pGKfMaK+sl0swgSnsNykPn9Oq6+ThjhC+77f5meQ= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 48/50] staging: media: imx: imx7-media-csi: Inline imx7_csi_enum_pixel_formats() Date: Tue, 10 May 2022 14:58:57 +0300 Message-Id: <20220510115859.19777-49-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Inline the imx7_csi_enum_pixel_formats() function in its only caller. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 84 +++++++++------------- 1 file changed, 34 insertions(+), 50 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 8be6f40588af..0bf69933f1bd 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -954,54 +954,6 @@ static const struct imx7_csi_pixfmt *imx7_csi_find_mbus_format(u32 code) return NULL; } -/* - * Enumerate entries in the pixel_formats[] array that match the - * requested selection criteria. Return the fourcc that matches the - * selection criteria at the requested match index. - * - * @fourcc: The returned fourcc that matches the search criteria at - * the requested match index. - * @index: The requested match index. - * @code: If non-zero, only include in the enumeration entries matching this - * media bus code. - */ -static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, u32 code) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { - const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - - /* - * If a media bus code is specified, only consider formats that - * match it. - */ - if (code) { - unsigned int j; - - if (!fmt->codes) - continue; - - for (j = 0; fmt->codes[j]; j++) { - if (code == fmt->codes[j]) - break; - } - - if (!fmt->codes[j]) - continue; - } - - if (index == 0) { - *fourcc = fmt->fourcc; - return 0; - } - - index--; - } - - return -EINVAL; -} - /* * Enumerate entries in the pixel_formats[] array that match the * requested search criteria. Return the media-bus code that matches @@ -1088,8 +1040,40 @@ static int imx7_csi_video_querycap(struct file *file, void *fh, static int imx7_csi_video_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { - return imx7_csi_enum_pixel_formats(&f->pixelformat, f->index, - f->mbus_code); + unsigned int index = f->index; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { + const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; + + /* + * If a media bus code is specified, only consider formats that + * match it. + */ + if (f->mbus_code) { + unsigned int j; + + if (!fmt->codes) + continue; + + for (j = 0; fmt->codes[j]; j++) { + if (f->mbus_code == fmt->codes[j]) + break; + } + + if (!fmt->codes[j]) + continue; + } + + if (index == 0) { + f->pixelformat = fmt->fourcc; + return 0; + } + + index--; + } + + return -EINVAL; } static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, From patchwork Tue May 10 11:58:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 571440 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 AC1C3C433EF for ; Tue, 10 May 2022 12:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241518AbiEJMES (ORCPT ); Tue, 10 May 2022 08:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240882AbiEJMEO (ORCPT ); Tue, 10 May 2022 08:04:14 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03E046673 for ; Tue, 10 May 2022 05:00:16 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 705FF19AD; Tue, 10 May 2022 13:59:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183992; bh=7TZAvmLE3VyU/IP2y4JQZc51w8dX52N/5RgRLrzd8oU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CN5hc/77MmGC2QXy+NbdjEZSJjMcJxAFZwQWpo7cPdKR9MCrvXYpa0cbfqiYgHa5j s1LOm2+jE4UQL8WsAeQr2wldiH+gODXTlF3afDlFweQe1aq4h7x1CP8gXTjMkjhdI4 bwazDQTqh5RYJAD7KEsUltIpivJXeqEy+j+T9GOI= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 49/50] staging: media: imx: imx7-media-csi: Drop V4L2 events support Date: Tue, 10 May 2022 14:58:58 +0300 Message-Id: <20220510115859.19777-50-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The only event that the driver allows subscribing to, V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR, is never generated. Drop events support. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 0bf69933f1bd..ae74256755f4 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -22,14 +22,12 @@ #include #include -#include #include #include #include #include #include -#include #include "imx-media.h" #define IMX7_CSI_PAD_SINK 0 @@ -1212,17 +1210,6 @@ static int imx7_csi_video_g_selection(struct file *file, void *fh, return 0; } -static int imx7_csi_video_subscribe_event(struct v4l2_fh *fh, - const struct v4l2_event_subscription *sub) -{ - switch (sub->type) { - case V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR: - return v4l2_event_subscribe(fh, sub, 0, NULL); - default: - return -EINVAL; - } -} - static const struct v4l2_ioctl_ops imx7_csi_video_ioctl_ops = { .vidioc_querycap = imx7_csi_video_querycap, @@ -1244,9 +1231,6 @@ static const struct v4l2_ioctl_ops imx7_csi_video_ioctl_ops = { .vidioc_expbuf = vb2_ioctl_expbuf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, - - .vidioc_subscribe_event = imx7_csi_video_subscribe_event, - .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; /* -----------------------------------------------------------------------------