From patchwork Tue May 10 11:50: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: 15841 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5A117C3256 for ; Tue, 10 May 2022 11:52:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C1D1665646; Tue, 10 May 2022 13:51:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183519; bh=ID7KsvsOkIXuQ4cSOB4gIYwOWmaaua/BqNjfCaF7y3I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=rfF+V1Aab6QK8RSk7QlXZkNjZLaIcjMxSmpiIVluMZsXLK4AK09/V0yd077I+iftU 9rSlecTLkXnPCV3zbNIhB4ZEm8f4p+6qvFTzYn2+nC8Y0ehGAV1FXggctTWq5kvTgz 2zp0rGpS/3iv/Ro19I/vZejXHrqCeJblXUTCtMck1yDReS5ORNVfNx3e4nCyl7Nt8C vRRk/1EvPLb4PFK5DaJbFreTDmQt/vfQflx2QgXkrRZGSpigOFF9f9qo4y11OTumvL 0NpypI1HMH7xCZDcEL54bkf+LQCuI9aRuCtQcrFzK4FaSrjPRuyZ/qFx61MK8SHWwz mXHCFtbEmwuxQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A7C3F65643 for ; Tue, 10 May 2022 13:51:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JF8zwD2G"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B4EABB60; Tue, 10 May 2022 13:51:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183517; bh=ID7KsvsOkIXuQ4cSOB4gIYwOWmaaua/BqNjfCaF7y3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JF8zwD2G6PQYjAGifRPKTNZqP2K7//gyJOVepUnbUt/9sZDDMSlr2ybLbqQBcKWVG HSMAJW8aLmCmFyzaK4hbOrr5VPxH1vrmukrKWZC44ufGg/947utzRzokxC4iuZpnHJ FeSvSbDhGmUi+TCmSXKiQQx3blxb1pKXUGT6ETjY= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:50:58 +0300 Message-Id: <20220510115147.19360-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 01/50] staging: media: imx: imx7-media-csi: Initialize locks early on X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:50:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15842 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 8EDF9C326C for ; Tue, 10 May 2022 11:52:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2FA306564F; Tue, 10 May 2022 13:52:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183521; bh=biy0GTT1QoP72aKYu5WMI/a8pkSOFL+DXgOcxXmEqYk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=VY+k/Q/jnDhzxsIfztw2kBhVowzRYa4xGxQJwYpenByxin0jPT5GnkP7IOVAgv44x h0euTW46m9BAvLZSRlfvrzIM0cDDZz9DMoZN92wDc7waznIjTzErdfpP9hCvPmlZDt B5jVmC+ZHoUd2X8uZRsPHxGCZ0zXefUGOkbCUZA3vjnnTaNvfcPwihnOWMlTtf/i61 CSfc7AVNcpp7FYfI9a/EOzXxy3kbrzK3ufUGpFc7FRn2Pzvs9F8HhYtPgPtr9QvlGg HE8+8vc/nBm/6Ek3C0Mm3D+cjxLIZeHN9RD1O42MBBdV8t4guJ+Gxw5vaLdaDdfUE1 592uwBnWMGecA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8223F65648 for ; Tue, 10 May 2022 13:51:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OFIx9Vtb"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 900EFB9A; Tue, 10 May 2022 13:51:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183518; bh=biy0GTT1QoP72aKYu5WMI/a8pkSOFL+DXgOcxXmEqYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OFIx9VtbfZpvK4FYMar2dLCOnuZ3X+X/6aqhonL4sDKXhr7sfbwQwC1p75ugYV7R8 9YDA7n0GXLHgkWtUckcGO2Cq1Oh+W/FmZl7l//DcsCHdLJg2Tjlz3Vs5OtrNOLaCqA 0dllezY6TwqMZfVZjY6maCTIaWmKD+gB13nFV5RI= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:50:59 +0300 Message-Id: <20220510115147.19360-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/50] staging: media: imx: imx7-media-csi: Split imx_media_dev from probe() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Prepare for the decoupling of the imx7-media-csi driver from the IPUv3-based drivers by moving the imx_media_dev handling from probe() function to separate functions. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 71 +++++++++++++--------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 893620e8fc03..d7c65b8bb3c9 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1175,11 +1175,45 @@ static int imx7_csi_async_register(struct imx7_csi *csi) return v4l2_async_register_subdev(&csi->sd); } +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); +} + +static int imx7_csi_media_init(struct imx7_csi *csi) +{ + struct imx_media_dev *imxmd; + int ret; + + /* add media device */ + imxmd = imx_media_dev_init(csi->dev, NULL); + 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; + } + + ret = imx_media_dev_notifier_register(imxmd, NULL); + if (ret < 0) { + imx7_csi_media_cleanup(csi); + return ret; + } + + csi->imxmd = imxmd; + + return 0; +} + static int imx7_csi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; - struct imx_media_dev *imxmd; struct imx7_csi *csi; int i, ret; @@ -1193,6 +1227,7 @@ static int imx7_csi_probe(struct platform_device *pdev) spin_lock_init(&csi->irqlock); mutex_init(&csi->lock); + /* Acquire resources and install interrupt handler. */ csi->mclk = devm_clk_get(&pdev->dev, "mclk"); if (IS_ERR(csi->mclk)) { ret = PTR_ERR(csi->mclk); @@ -1214,7 +1249,6 @@ static int imx7_csi_probe(struct platform_device *pdev) csi->model = (enum imx_csi_model)(uintptr_t)of_device_get_match_data(&pdev->dev); - /* install interrupt handler */ ret = devm_request_irq(dev, csi->irq, imx7_csi_irq_handler, 0, "csi", (void *)csi); if (ret < 0) { @@ -1222,22 +1256,11 @@ static int imx7_csi_probe(struct platform_device *pdev) goto destroy_mutex; } - /* add media device */ - imxmd = imx_media_dev_init(dev, NULL); - if (IS_ERR(imxmd)) { - ret = PTR_ERR(imxmd); + /* Initialize all the media device infrastructure. */ + ret = imx7_csi_media_init(csi); + if (ret) goto destroy_mutex; - } - ret = imx_media_of_add_csi(imxmd, node); - if (ret < 0 && ret != -ENODEV && ret != -EEXIST) - goto cleanup; - - ret = imx_media_dev_notifier_register(imxmd, NULL); - if (ret < 0) - goto cleanup; - - csi->imxmd = imxmd; v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); v4l2_set_subdevdata(&csi->sd, csi); csi->sd.internal_ops = &imx7_csi_internal_ops; @@ -1269,11 +1292,7 @@ static int imx7_csi_probe(struct platform_device *pdev) v4l2_async_nf_cleanup(&csi->notifier); cleanup: - v4l2_async_nf_unregister(&imxmd->notifier); - v4l2_async_nf_cleanup(&imxmd->notifier); - v4l2_device_unregister(&imxmd->v4l2_dev); - media_device_unregister(&imxmd->md); - media_device_cleanup(&imxmd->md); + imx7_csi_media_cleanup(csi); destroy_mutex: mutex_destroy(&csi->lock); @@ -1285,14 +1304,8 @@ static int imx7_csi_remove(struct platform_device *pdev) { struct v4l2_subdev *sd = platform_get_drvdata(pdev); struct imx7_csi *csi = v4l2_get_subdevdata(sd); - struct imx_media_dev *imxmd = csi->imxmd; - v4l2_async_nf_unregister(&imxmd->notifier); - v4l2_async_nf_cleanup(&imxmd->notifier); - - media_device_unregister(&imxmd->md); - v4l2_device_unregister(&imxmd->v4l2_dev); - media_device_cleanup(&imxmd->md); + imx7_csi_media_cleanup(csi); v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); From patchwork Tue May 10 11:51:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15843 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 09B72C3256 for ; Tue, 10 May 2022 11:52:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B75C665655; Tue, 10 May 2022 13:52:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183522; bh=DQNnAnAdnM1VsPNzt3WveXXRzKRWpGwQ+Fq/1O4hhtE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DPJnMPeE0LfUZZLd7cUqu841nMiWmrz6QKxCu76bRYZrYRnMJVByAjsZxxbAohfDR YRZg8SNbeI3h5fVJ8HOAeN2FbZ2hgQ5VurJz+pYFNUQ1F5MocELigm1tk0XKLwYazN hvFDFG591Cioabu2KLZVfBsvxJ+uPMWbVx4+Wv9NZBI9haxJ1vbtws84jmlQu74U+l Mu2qxZ0zkdq3Pj6d2Z0FxLokLrddlGrBcmwIMp9C94DM5L85Hsze9+3NPG5LsJJVyZ dAGPwqHli+xuwhJE3fnTZdnmx2CrDJg9wY5Of4xcFAP1i47O7gCX6gz/WxGyZmHaXH a3RTivYydTDfQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E4A065643 for ; Tue, 10 May 2022 13:51:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ib/NdEi4"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 68431BA9; Tue, 10 May 2022 13:51:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183519; bh=DQNnAnAdnM1VsPNzt3WveXXRzKRWpGwQ+Fq/1O4hhtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ib/NdEi4kYMQOj1L5mXLkEDV91quvFIfEI54tFOZNPAVqgrdfNy218mDVHPil6czZ Q6M76QsN8GJG25f8uToPhExcXiHcjHF0Wds4ElBXvtnWZqrwagz+SNqkdV2YeRlQ2Y WeHPXipo9nBJHtkQwFmVGyiLY1in5/ax5PtYUogE= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:00 +0300 Message-Id: <20220510115147.19360-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 03/50] staging: media: imx: imx7-media-csi: Import notifier helpers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To prepare for code refactoring, copy the V4L2 async notifier helper code used by this driver verbatim from imx-media-dev-common.c. Rename some functions to avoid name clashes. No functional change included. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 210 ++++++++++++++++++++- 1 file changed, 209 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index d7c65b8bb3c9..708076b7045a 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -717,6 +717,214 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) return IRQ_HANDLED; } +/* ----------------------------------------------------------------------------- + * Temporary copy of imx_media_dev helpers + */ + +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. + */ +static int imx_media_add_vdev_to_pad(struct imx_media_dev *imxmd, + struct imx_media_video_dev *vdev, + struct media_pad *srcpad) +{ + struct media_entity *entity = srcpad->entity; + struct imx_media_pad_vdev *pad_vdev; + struct list_head *pad_vdev_list; + struct media_link *link; + struct v4l2_subdev *sd; + int i, ret; + + /* skip this entity if not a v4l2_subdev */ + if (!is_media_entity_v4l2_subdev(entity)) + return 0; + + sd = media_entity_to_v4l2_subdev(entity); + + pad_vdev_list = to_pad_vdev_list(sd, srcpad->index); + if (!pad_vdev_list) { + v4l2_warn(&imxmd->v4l2_dev, "%s:%u has no vdev list!\n", + entity->name, srcpad->index); + /* + * shouldn't happen, but no reason to fail driver load, + * just skip this entity. + */ + return 0; + } + + /* just return if we've been here before */ + list_for_each_entry(pad_vdev, pad_vdev_list, list) { + if (pad_vdev->vdev == vdev) + return 0; + } + + dev_dbg(imxmd->md.dev, "adding %s to pad %s:%u\n", + vdev->vfd->entity.name, entity->name, srcpad->index); + + pad_vdev = devm_kzalloc(imxmd->md.dev, sizeof(*pad_vdev), GFP_KERNEL); + if (!pad_vdev) + return -ENOMEM; + + /* attach this vdev to this pad */ + pad_vdev->vdev = vdev; + list_add_tail(&pad_vdev->list, pad_vdev_list); + + /* move upstream from this entity's sink pads */ + for (i = 0; i < entity->num_pads; i++) { + struct media_pad *pad = &entity->pads[i]; + + if (!(pad->flags & MEDIA_PAD_FL_SINK)) + continue; + + list_for_each_entry(link, &entity->links, list) { + if (link->sink != pad) + continue; + ret = imx_media_add_vdev_to_pad(imxmd, vdev, + link->source); + if (ret) + return ret; + } + } + + return 0; +} + +/* + * For every subdevice, allocate an array of list_head's, one list_head + * for each pad, to hold the list of video devices reachable from that + * pad. + */ +static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd) +{ + struct list_head *vdev_lists; + struct media_entity *entity; + struct v4l2_subdev *sd; + int i; + + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { + entity = &sd->entity; + vdev_lists = devm_kcalloc(imxmd->md.dev, + entity->num_pads, sizeof(*vdev_lists), + GFP_KERNEL); + if (!vdev_lists) + return -ENOMEM; + + /* attach to the subdev's host private pointer */ + sd->host_priv = vdev_lists; + + for (i = 0; i < entity->num_pads; i++) + INIT_LIST_HEAD(to_pad_vdev_list(sd, i)); + } + + return 0; +} + +/* form the vdev lists in all imx-media source pads */ +static int imx_media_create_pad_vdev_lists(struct imx_media_dev *imxmd) +{ + struct imx_media_video_dev *vdev; + struct media_link *link; + int ret; + + ret = imx_media_alloc_pad_vdev_lists(imxmd); + if (ret) + return ret; + + list_for_each_entry(vdev, &imxmd->vdev_list, list) { + link = list_first_entry(&vdev->vfd->entity.links, + struct media_link, list); + ret = imx_media_add_vdev_to_pad(imxmd, vdev, link->source); + if (ret) + return ret; + } + + return 0; +} + +/* async subdev complete notifier */ +static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier) +{ + struct imx_media_dev *imxmd = notifier2dev(notifier); + int ret; + + mutex_lock(&imxmd->mutex); + + imx_media_create_csi2_links(imxmd); + + ret = imx_media_create_pad_vdev_lists(imxmd); + if (ret) + goto unlock; + + ret = v4l2_device_register_subdev_nodes(&imxmd->v4l2_dev); +unlock: + mutex_unlock(&imxmd->mutex); + if (ret) + return ret; + + return media_device_register(&imxmd->md); +} + +static const struct v4l2_async_notifier_operations imx_media_notifier_ops = { + .complete = __imx_media_probe_complete, +}; + +static int __imx_media_dev_notifier_register(struct imx_media_dev *imxmd, + const struct v4l2_async_notifier_operations *ops) +{ + int ret; + + /* no subdevs? just bail */ + if (list_empty(&imxmd->notifier.asd_list)) { + v4l2_err(&imxmd->v4l2_dev, "no subdevs\n"); + return -ENODEV; + } + + /* prepare the async subdev notifier and register it */ + imxmd->notifier.ops = ops ? ops : &imx_media_notifier_ops; + ret = v4l2_async_nf_register(&imxmd->v4l2_dev, &imxmd->notifier); + if (ret) { + v4l2_err(&imxmd->v4l2_dev, + "v4l2_async_nf_register failed with %d\n", ret); + return ret; + } + + return 0; +} + /* ----------------------------------------------------------------------------- * V4L2 Subdev Operations */ @@ -1200,7 +1408,7 @@ static int imx7_csi_media_init(struct imx7_csi *csi) return ret; } - ret = imx_media_dev_notifier_register(imxmd, NULL); + ret = __imx_media_dev_notifier_register(imxmd, NULL); if (ret < 0) { imx7_csi_media_cleanup(csi); return ret; From patchwork Tue May 10 11:51:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15844 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 96FE1C326C for ; Tue, 10 May 2022 11:52:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 451056564D; Tue, 10 May 2022 13:52:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183523; bh=pcHJ/iHL8mYCDutTvm2V49TLbx7X/i0r5Te2u6dAS1Q=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=zsvmt7kwqO0OG8fEZOjxP4FrgpaUpjLbqcq1saqbVYw/KirBkTPsYCN+a9ksvnjRq aUp632hS7NqOYFsIyiTbC/YuMN6RGZSEXDCv2ZSNax7Pwez/2T45hJQ+FvnIYUHlE7 20CJ7zma/InLZH/zH5IjtdH9n7wkXfjxdebws+errwS9gDJ8PYuStPh2MatT/LXdpQ MMH7Rvxiwm9K1EvXMvA1XOxIopbGNARwiRGXzLCGi5XoFTJaVM6VKn3UvCh5LrmTf7 pqBIB8yTJHnewnY7DOtkZ2l7bcdW4UGkAIiOJ/vU3uDlNX4lFYobosWp2o5cw5bGt1 ZN6f8/VDg536g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 385D865648 for ; Tue, 10 May 2022 13:52:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jgDwYlm6"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5A254DFF; Tue, 10 May 2022 13:51:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183520; bh=pcHJ/iHL8mYCDutTvm2V49TLbx7X/i0r5Te2u6dAS1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgDwYlm6p4aEHUvn3Y4nUh2HkT21gU6UJFCytdlnkqEhrt7d8n7LTHv2ATmbP6mW7 Rkl0pcrnOqucYxbG6b/wI0fiq+K4NhxFBmyrlUiDOvWA8emS4rKiF8ak0nyMuYn39n j9b8iD86m0lHB8/Ge6J90T6/TudPh9gqd77Gu0P0= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:01 +0300 Message-Id: <20220510115147.19360-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 04/50] staging: media: imx: imx7-media-csi: Drop duplicate link creation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15845 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1ADCBC3256 for ; Tue, 10 May 2022 11:52:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 91EB165653; Tue, 10 May 2022 13:52:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183524; bh=vVaxZhjLlAQkxGPt/Aih151SXhS9D/3jxSOJe0M5h7Q=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=b97q0VgRe5yTGL0SLu1LBJHLpETvtSYB/5NWHuHtDuzeDXNWZuRNTxTyPkqPoh000 08LwEDwy2ET2isXtmlSr3Yu81xkxGYwNK6h33Z9PCdOQK0U9ipmlcQMCyRHeRtwCbA DWb1VbYKoEXhPLL80kV2R42MsGRz4E2XZ23fSGho+FU9Epdwb7cd0x1XRRZWM6T/O2 898Piy762neLsTMuu2+0GRecnzJPzcxBMGZsZDmZuaPi8+RoWIdKqXG0S+UiI4EsP2 IUZQK1tT4Tx6c9hkW7eau17YhMzgCHAA2tWK2U3Grzc9CGRTi91NaiYdC/2nkKEReY WxdaW1whmV/Bg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0FC636564A for ; Tue, 10 May 2022 13:52:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jbDgeBdP"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 39982E0C; Tue, 10 May 2022 13:52:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183520; bh=vVaxZhjLlAQkxGPt/Aih151SXhS9D/3jxSOJe0M5h7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jbDgeBdPaafIyFAbKkC7qKyBITE8IE8DigN3Uded1kQlU63eEft5M+OfzH62Cbuu/ +5DJXHtk5s9OZSlJY3rBQHNrf/jPviyUupITzs7SnO3TihMbjonmgdtvrjjMcLXS1Q PXSJmmFO9xx1t15HRz3WOQER1U3vj+eAZBcV0WYA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:02 +0300 Message-Id: <20220510115147.19360-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/50] staging: media: imx: imx7-media-csi: Drop the imx_media notifier X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The V4L2 async notifier embedded in the imx_media_dev structure is triggered when the CSI bridge subdev is registered. We don't need an async notifier for this, as we can call the .complete() handler directly from the CSI bridge subdev .registered() handler. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 63 +++++++--------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e2d6dabad007..984f7bec15af 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -721,11 +721,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) * Temporary copy of imx_media_dev helpers */ -static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n) -{ - return container_of(n, struct imx_media_dev, notifier); -} - /* * adds given video device to given imx-media source pad vdev list. * Continues upstream from the pad entity's sink pads. @@ -848,9 +843,8 @@ static int imx_media_create_pad_vdev_lists(struct imx_media_dev *imxmd) } /* async subdev complete notifier */ -static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier) +static int __imx_media_probe_complete(struct imx_media_dev *imxmd) { - struct imx_media_dev *imxmd = notifier2dev(notifier); int ret; mutex_lock(&imxmd->mutex); @@ -868,33 +862,6 @@ static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier) return media_device_register(&imxmd->md); } -static const struct v4l2_async_notifier_operations imx_media_notifier_ops = { - .complete = __imx_media_probe_complete, -}; - -static int __imx_media_dev_notifier_register(struct imx_media_dev *imxmd, - const struct v4l2_async_notifier_operations *ops) -{ - int ret; - - /* no subdevs? just bail */ - if (list_empty(&imxmd->notifier.asd_list)) { - v4l2_err(&imxmd->v4l2_dev, "no subdevs\n"); - return -ENODEV; - } - - /* prepare the async subdev notifier and register it */ - imxmd->notifier.ops = ops ? ops : &imx_media_notifier_ops; - ret = v4l2_async_nf_register(&imxmd->v4l2_dev, &imxmd->notifier); - if (ret) { - v4l2_err(&imxmd->v4l2_dev, - "v4l2_async_nf_register failed with %d\n", ret); - return ret; - } - - return 0; -} - /* ----------------------------------------------------------------------------- * V4L2 Subdev Operations */ @@ -1247,10 +1214,12 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) ret = imx_media_capture_device_register(csi->vdev, MEDIA_LNK_FL_IMMUTABLE); - if (ret) + if (ret) { imx_media_capture_device_remove(csi->vdev); + return ret; + } - return ret; + return __imx_media_probe_complete(csi->imxmd); } static void imx7_csi_unregistered(struct v4l2_subdev *sd) @@ -1316,8 +1285,16 @@ static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, MEDIA_LNK_FL_IMMUTABLE); } +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); +} + static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { .bound = imx7_csi_notify_bound, + .complete = imx7_csi_notify_complete, }; static int imx7_csi_async_register(struct imx7_csi *csi) @@ -1346,11 +1323,11 @@ static int imx7_csi_async_register(struct imx7_csi *csi) csi->notifier.ops = &imx7_csi_notify_ops; - ret = v4l2_async_subdev_nf_register(&csi->sd, &csi->notifier); + ret = v4l2_async_nf_register(&csi->imxmd->v4l2_dev, &csi->notifier); if (ret) return ret; - return v4l2_async_register_subdev(&csi->sd); + return 0; } static void imx7_csi_media_cleanup(struct imx7_csi *csi) @@ -1378,12 +1355,6 @@ static int imx7_csi_media_init(struct imx7_csi *csi) return ret; } - ret = __imx_media_dev_notifier_register(imxmd, NULL); - if (ret < 0) { - imx7_csi_media_cleanup(csi); - return ret; - } - csi->imxmd = imxmd; return 0; @@ -1458,6 +1429,10 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret < 0) goto cleanup; + ret = v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); + if (ret) + goto cleanup; + ret = imx7_csi_async_register(csi); if (ret) goto subdev_notifier_cleanup; From patchwork Tue May 10 11:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15846 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0EE00C326D for ; Tue, 10 May 2022 11:52:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AB116565A; Tue, 10 May 2022 13:52:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183525; bh=g1HSzGVKOFmiTz3acZlXrvGDr9k5S9lpIAwIEIkpp9E=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=o8fyufMT51Hy+4R4NINI8E5lVOnNqHkRrFltefxA/GcWWhLuqj+QDw4+PN3vOPB4k F8a7VaDxbwaH1qSQkoCtebkFOpnfHjefQKlSWj3+BKPVCHql/7elZRXtP/NSRXV8e4 bUscnxIY2dLCGiKhTzr8nWeKaTtUODtwmsUt6MmBPgJyqBe+j/8sEzVPctx9eV6T4N nt8/g/0XGn7+qVNEcedp1yAYr5qiWn0hM+o44W7UXMsIKAxEsWv0wQhPX58M9czGip UzEfhVlF9+FhKs60UxMMPGsjc+TX4YmvVrTiyeckmjwTDa2bXau1RKDd2x6VYJzpYU qIQvEJkeCMt0Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 157446564D for ; Tue, 10 May 2022 13:52:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eEPBhNTv"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 122E4824; Tue, 10 May 2022 13:52:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183521; bh=g1HSzGVKOFmiTz3acZlXrvGDr9k5S9lpIAwIEIkpp9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eEPBhNTvBK+STHKodI7N+UoAIQx2E542gSGao25WdDtAXYia5YOG7z69wH2PaIXJw vvV2Qi34nkU4/IEtvQDTBUP0YGEJFHGIcVrJ53N1sSjFRG1fu8hcNzigFBP3nD83sb U2ZbXcuLbQvIqsYn1+a3ArWsFWA/Gw/FQbcem5nc= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:03 +0300 Message-Id: <20220510115147.19360-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/50] staging: media: imx: imx7-media-csi: Move misc init out of probe() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15847 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 750A9C326C for ; Tue, 10 May 2022 11:52:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2113D65646; Tue, 10 May 2022 13:52:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183527; bh=JweyVKZn5hEu99NUVKs8LT0pqn6mT3HILsiBxsegB5s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=0u2rjM7fE4jdo2ukgQZofUeXk0bzfUZd3gRaNS8bVPTdXmWvPGpo8li32dt/BFJv0 7FSr9B4BOaYWhy2z9XP5ssJZnnZDQuZAd1laP7JFcyGBbVST1nXQbiz7Gm3aYw5JPE ZIpxL+zVQsm4fKLnN/AFTreX86WSLkx1+wfC67lvHGhbCAwsrOgBbCcdEDCMXR/onr JCFJ3qcvD6tLeZLBfPH8tXtWcP4ju31Ob/gSPA/j9d7L5sNBFJg6goSN+EOZBTiPsH 0DsbezcW4sran7PFay4J6qHuy1ZtEx6QLfMHs+fVo4BIT5RM1hxfiMlFM7+rWFcm7K 9n2oq3QNd2nXg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA1E465657 for ; Tue, 10 May 2022 13:52:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DbTIzd0R"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0850A1224; Tue, 10 May 2022 13:52:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183522; bh=JweyVKZn5hEu99NUVKs8LT0pqn6mT3HILsiBxsegB5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbTIzd0R7s40rfd8uGCAhQBVXTbGiQPNEmuMBGRCm1Y770UXt3/zkcKNbav0fBP5/ c1OOaZfkxopCc8dplIcpPXqqYkhIok7pRouVmabr8B1pq2d28/RMzegUUkjbbTkoQm pO32/AglRwAjb3lcVE8Wb0rKFR70vtEjJQ5kHzDM= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:04 +0300 Message-Id: <20220510115147.19360-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/50] staging: media: imx: imx7-media-csi: Don't populate vdev lists X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The imx_media_dev framework maintains a per-pad list of connected video devices, created once all subdevs have been bound. This is used for two purposes, updating V4L2 control inheritance when links change, and relaying subdev events to video nodes. None of these are used by the imx7-media-csi driver as it implements the MC-centric approach. Drop them. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 167 +++------------------ 1 file changed, 17 insertions(+), 150 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 042dd4c0cb4d..e0b600580c21 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -717,151 +717,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) return IRQ_HANDLED; } -/* ----------------------------------------------------------------------------- - * Temporary copy of imx_media_dev helpers - */ - -/* - * adds given video device to given imx-media source pad vdev list. - * Continues upstream from the pad entity's sink pads. - */ -static int imx_media_add_vdev_to_pad(struct imx_media_dev *imxmd, - struct imx_media_video_dev *vdev, - struct media_pad *srcpad) -{ - struct media_entity *entity = srcpad->entity; - struct imx_media_pad_vdev *pad_vdev; - struct list_head *pad_vdev_list; - struct media_link *link; - struct v4l2_subdev *sd; - int i, ret; - - /* skip this entity if not a v4l2_subdev */ - if (!is_media_entity_v4l2_subdev(entity)) - return 0; - - sd = media_entity_to_v4l2_subdev(entity); - - pad_vdev_list = to_pad_vdev_list(sd, srcpad->index); - if (!pad_vdev_list) { - v4l2_warn(&imxmd->v4l2_dev, "%s:%u has no vdev list!\n", - entity->name, srcpad->index); - /* - * shouldn't happen, but no reason to fail driver load, - * just skip this entity. - */ - return 0; - } - - /* just return if we've been here before */ - list_for_each_entry(pad_vdev, pad_vdev_list, list) { - if (pad_vdev->vdev == vdev) - return 0; - } - - dev_dbg(imxmd->md.dev, "adding %s to pad %s:%u\n", - vdev->vfd->entity.name, entity->name, srcpad->index); - - pad_vdev = devm_kzalloc(imxmd->md.dev, sizeof(*pad_vdev), GFP_KERNEL); - if (!pad_vdev) - return -ENOMEM; - - /* attach this vdev to this pad */ - pad_vdev->vdev = vdev; - list_add_tail(&pad_vdev->list, pad_vdev_list); - - /* move upstream from this entity's sink pads */ - for (i = 0; i < entity->num_pads; i++) { - struct media_pad *pad = &entity->pads[i]; - - if (!(pad->flags & MEDIA_PAD_FL_SINK)) - continue; - - list_for_each_entry(link, &entity->links, list) { - if (link->sink != pad) - continue; - ret = imx_media_add_vdev_to_pad(imxmd, vdev, - link->source); - if (ret) - return ret; - } - } - - return 0; -} - -/* - * For every subdevice, allocate an array of list_head's, one list_head - * for each pad, to hold the list of video devices reachable from that - * pad. - */ -static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd) -{ - struct list_head *vdev_lists; - struct media_entity *entity; - struct v4l2_subdev *sd; - int i; - - list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { - entity = &sd->entity; - vdev_lists = devm_kcalloc(imxmd->md.dev, - entity->num_pads, sizeof(*vdev_lists), - GFP_KERNEL); - if (!vdev_lists) - return -ENOMEM; - - /* attach to the subdev's host private pointer */ - sd->host_priv = vdev_lists; - - for (i = 0; i < entity->num_pads; i++) - INIT_LIST_HEAD(to_pad_vdev_list(sd, i)); - } - - return 0; -} - -/* form the vdev lists in all imx-media source pads */ -static int imx_media_create_pad_vdev_lists(struct imx_media_dev *imxmd) -{ - struct imx_media_video_dev *vdev; - struct media_link *link; - int ret; - - ret = imx_media_alloc_pad_vdev_lists(imxmd); - if (ret) - return ret; - - list_for_each_entry(vdev, &imxmd->vdev_list, list) { - link = list_first_entry(&vdev->vfd->entity.links, - struct media_link, list); - ret = imx_media_add_vdev_to_pad(imxmd, vdev, link->source); - if (ret) - return ret; - } - - return 0; -} - -/* async subdev complete notifier */ -static int __imx_media_probe_complete(struct imx_media_dev *imxmd) -{ - int ret; - - mutex_lock(&imxmd->mutex); - - ret = imx_media_create_pad_vdev_lists(imxmd); - if (ret) - goto unlock; - - ret = v4l2_device_register_subdev_nodes(&imxmd->v4l2_dev); -unlock: - mutex_unlock(&imxmd->mutex); - if (ret) - return ret; - - return media_device_register(&imxmd->md); -} - /* ----------------------------------------------------------------------------- * V4L2 Subdev Operations */ @@ -1214,12 +1069,24 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) ret = imx_media_capture_device_register(csi->vdev, MEDIA_LNK_FL_IMMUTABLE); - if (ret) { - imx_media_capture_device_remove(csi->vdev); - return ret; - } + if (ret) + goto err_remove; - return __imx_media_probe_complete(csi->imxmd); + ret = v4l2_device_register_subdev_nodes(&csi->imxmd->v4l2_dev); + if (ret) + goto err_unreg; + + ret = media_device_register(&csi->imxmd->md); + if (ret) + goto err_unreg; + + return 0; + +err_unreg: + imx_media_capture_device_unregister(csi->vdev); +err_remove: + imx_media_capture_device_remove(csi->vdev); + return ret; } static void imx7_csi_unregistered(struct v4l2_subdev *sd) From patchwork Tue May 10 11:51:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15848 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 200B7C3256 for ; Tue, 10 May 2022 11:52:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF51F65665; Tue, 10 May 2022 13:52:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183528; bh=Hfk7LzAL2PoWuZNMaH9HkgU3bH8tE7q5YD8bmWHbQzs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=sfhU2HMC60F4X9HEH445Bdl3owgClnmRiFthJyQXYevCo6qVN4CkysOXr2PLftaun CTrH+E0WyEjrwWFtwBnPmF97fA7Uia7u9DozqWwYPzUxgID+FHQBiahje5UrTyiR1G yQy+Z43owSm1K+WCMAmXIqxq1A/WHauKFhb7lWp99jIJyBYHvEAxPwDVdo5PjSpajf IGgdZNChWyx/3Kxb2n2Di5wvEb7vKF+9B5XseN1NKX8XcfVSUWFnlpXQ8+D56fNO10 /yRhjlFrMlotqZKY9T/DUWq6ewlyJN00wUEYsWSv+pxXXXfSuq+hrLiXRHxMj/Bggz Nt39PwscEcYHQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B2FE365654 for ; Tue, 10 May 2022 13:52:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="K/RtHgta"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D833AB9A; Tue, 10 May 2022 13:52:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183523; bh=Hfk7LzAL2PoWuZNMaH9HkgU3bH8tE7q5YD8bmWHbQzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/RtHgtaCjhwPkGAn9ZL01P2OL8aerwZ8QATlU4t0uakfKnzbIWfjpeDKJisHrqGc 9rtqU8ozzPYZ+wGuTdsmhkU9Hb9ceFIynLcy8gfWeM8y1f0cVz+kHG44KY6U9xbfYJ JXJ0NEwcuxBnhvTnUA7FS488nWOVB+99c+ouUyus= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:05 +0300 Message-Id: <20220510115147.19360-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/50] staging: media: imx: imx7-media-csi: Drop unused frame_interval X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15849 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9EE50C326E for ; Tue, 10 May 2022 11:52:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B48F65654; Tue, 10 May 2022 13:52:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183529; bh=zvOjg0QeN6mSFOMqPebQPsFhlL+PiY+QVPoTBCUk1fI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jJ2nXYq9kYqT2rX+Fj7zT04xpy4uWMqdF6yuZwhI6ekSTwNqp2hZff2nZcoL3q0s4 vDNF0TqwHyKbSyFfCS4lgWAnd/XT/y7BrZ7uZl6z/xJQYuinmZWTRWec3+wBvQXB9n AlgLYabwYGYWgXYTye9ReTj1URHq8Fy+0bacCabG4JLhU8WHYMD7Jd3wIgUFCTa3UV Sz4brSJJnLKu9ueA0E6Sijs5dvenqUT44HJ/htUhzlq+s+JxKmmfDf98wSPfDkVb2i P/ulwFwlE2MVFy/SWW6YR7QAFXEzwzlZ1f66HB92+4V6uIl5mkjOcfHn7oGaPgmZTT VmDOsjUioDyZw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 92EB96565D for ; Tue, 10 May 2022 13:52:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eNQBbn4n"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AE0F1BA9; Tue, 10 May 2022 13:52:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183524; bh=zvOjg0QeN6mSFOMqPebQPsFhlL+PiY+QVPoTBCUk1fI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eNQBbn4nxIy02Fam+n4/tMaMkGBCmzKgtTYqd6vnAcmhZ7dS2ebrMyHxZWwW9YLJo gQFSZKmHXtan7ZZZMbvwVXmGLKPTL4n9Wz2wxSI0GBN5SeUXJ9s6wzuKQoK6HzugXz dX0U0wmul3VJQw6ZLoCDBaE0H7kApnubTCPuGPjw= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:06 +0300 Message-Id: <20220510115147.19360-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/50] staging: media: imx: imx7-media-csi: Move format init to probe time X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There's no need to wait until the subdev is registered to initialize the active pad formats. Do so at probe time. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 55 ++++++++++------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index cd063c4f3f40..d85b5ab204df 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -763,26 +763,6 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable) return ret; } -static int imx7_csi_init_cfg(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state) -{ - struct imx7_csi *csi = v4l2_get_subdevdata(sd); - struct v4l2_mbus_framefmt *mf; - int ret; - int i; - - for (i = 0; i < IMX7_CSI_PADS_NUM; i++) { - mf = v4l2_subdev_get_try_format(sd, sd_state, i); - - ret = imx_media_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE, - &csi->cc[i]); - if (ret < 0) - return ret; - } - - return 0; -} - static struct v4l2_mbus_framefmt * imx7_csi_get_format(struct imx7_csi *csi, struct v4l2_subdev_state *sd_state, @@ -795,6 +775,28 @@ imx7_csi_get_format(struct imx7_csi *csi, return &csi->format_mbus[pad]; } +static int imx7_csi_init_cfg(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + const enum v4l2_subdev_format_whence which = + sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; + struct imx7_csi *csi = v4l2_get_subdevdata(sd); + int ret; + int i; + + for (i = 0; i < IMX7_CSI_PADS_NUM; i++) { + struct v4l2_mbus_framefmt *mf = + imx7_csi_get_format(csi, sd_state, i, which); + + ret = imx_media_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE, + &csi->cc[i]); + if (ret < 0) + return ret; + } + + return 0; +} + static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -1046,16 +1048,6 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); int ret; - int i; - - for (i = 0; i < IMX7_CSI_PADS_NUM; i++) { - /* set a default mbus format */ - ret = imx_media_init_mbus_fmt(&csi->format_mbus[i], - 800, 600, 0, V4L2_FIELD_NONE, - &csi->cc[i]); - if (ret < 0) - return ret; - } csi->vdev = imx_media_capture_device_init(csi->sd.dev, &csi->sd, IMX7_CSI_PAD_SRC, false); @@ -1291,7 +1283,8 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret) goto destroy_mutex; - ret = v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); + /* Set the default mbus formats. */ + ret = imx7_csi_init_cfg(&csi->sd, NULL); if (ret) goto media_cleanup; From patchwork Tue May 10 11:51:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15850 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0EBC3C3256 for ; Tue, 10 May 2022 11:52:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B3B126566F; Tue, 10 May 2022 13:52:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183532; bh=d+7BkkERKznRknT/kY5nL7k0K2j0jSnisRVTDGKQ6Co=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=YocrLsXwQjqt50Sa87b24uY0FfwjZiZOsS7SGa/bSOjgIiidG6d8MsqdFk+2YERFG BRzvG4uVy6SPVLO008IUgkTvr5hxmFlq6oEQ0XQm/0QXeSssG1X2fwJMgZVYmcXmOO I/9nZ4BI+P5CJYCw7mfRtRFlNpSRTtM/D7SwAWmIrh2JgTXcXiVpiuW3i5/wLJovrc vM6Pq3h11nKIURV96j5l6QHE5ZFiW++27D7BWJ8M8QATs485QeyqLkQxS/Chkrch75 TrnmmfJziDBui/zvkvbnwSgo6dZTVWeVCqQVOoGXvpMy5MC0n/qBPKTQFjoA7h6r+7 oGALGjTDhMvkw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F02A65646 for ; Tue, 10 May 2022 13:52:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eJUQtjfG"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 89EF1DFF; Tue, 10 May 2022 13:52:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183525; bh=d+7BkkERKznRknT/kY5nL7k0K2j0jSnisRVTDGKQ6Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eJUQtjfGxAKAf2OIwldmbr5OUD0Rqij0Wo52xqyQ4t96QKzGN6bcfomk+XuuLt0aH lvNvyIPhMIJY252kTUdfnxRJfvgK72jnMBO8e7GZMXZlMCk1Z99pSHPWqSsho2KvNT tfbgRqSp+08i3Ae06KAE8vxcqH6UCAW43iJKw/nM= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:07 +0300 Message-Id: <20220510115147.19360-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 10/50] staging: media: imx: imx7-media-csi: Remove imx_media_of_add_csi X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15851 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9407BC326C for ; Tue, 10 May 2022 11:52:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3652E65676; Tue, 10 May 2022 13:52:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183533; bh=SW6QXUPRxmJIzxkMVklssylI/Qn6MNYwgfUhiDE5yfM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ihJ5jiSbDGD58R9i9YIRm9dRLMuunSc31pYU3Ign5G4idoxXdkVOGLBy0p562x9/W /iH/bY8Bd1AJNJbYDdKzzdW5tHDkN8PVnPp5ClqjuKCe2ckgCoI/8Sk6tfZMmV/LvS /tgBxzc8SNC/+DWWdaXAqAa03KK9SVT2F+4jWAKebVW+i9xDe8dWyoIeulDEJinHd1 xxcBkW3grgMn0l6vZs5g9TH84nb2i+doVoni0Vu+/KR0NjlVkBg+Mp6+o/U71szt/c eCliJX5HYIInvr8JjIdL+/v5df0TeP6t+z0Gum3Dl9QyQ14El/m4s05jIlXvBwmmg5 XoTEvx0zHSjEg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6686F65652 for ; Tue, 10 May 2022 13:52:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QPISc5Sa"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77143824; Tue, 10 May 2022 13:52:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183526; bh=SW6QXUPRxmJIzxkMVklssylI/Qn6MNYwgfUhiDE5yfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPISc5Sa2dcqMHy99crHYTtnoAsWZ2ae0J7NhOza81yZdAQTjW703I+RDaz+OHdmh fr1YgTSmApRoTDdxz8evDK+60zOFVOdPEfBtJftOqNCTbjoyMUiBoEAEJSQMU1wFAL UNgQuFltE6mlYaZgoD18v/pxgtY80/rwglb0nPuE= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:08 +0300 Message-Id: <20220510115147.19360-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 11/50] staging: media: imx: imx7-media-csi: Import video device helpers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To prepare for code refactoring, copy the video device helper code used by this driver verbatim from imx-media-capture. Rename some functions to avoid name clashes, and leave the legacy ioctls out as they're not used by the imx7-media-csi driver. No functional change included. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 712 ++++++++++++++++++++- 1 file changed, 702 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e7dcb602afae..63f291684e79 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -17,11 +17,15 @@ #include #include #include +#include +#include #include +#include #include #include #include +#include #include #include #include @@ -335,6 +339,9 @@ 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 imx_media_video_dev *vdev); + static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) { struct imx_media_video_dev *vdev = csi->vdev; @@ -344,7 +351,7 @@ static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) int i; for (i = 0; i < 2; i++) { - buf = imx_media_capture_device_next_buf(vdev); + buf = imx7_media_capture_device_next_buf(vdev); if (buf) { csi->active_vb2_buf[i] = buf; vb2_buf = &buf->vbuf.vb2_buf; @@ -646,7 +653,7 @@ static void imx7_csi_vb2_buf_done(struct imx7_csi *csi) csi->frame_sequence++; /* get next queued buffer */ - next = imx_media_capture_device_next_buf(vdev); + next = imx7_media_capture_device_next_buf(vdev); if (next) { phys = vb2_dma_contig_plane_dma_addr(&next->vbuf.vb2_buf, 0); csi->active_vb2_buf[csi->buf_num] = next; @@ -716,6 +723,691 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) return IRQ_HANDLED; } +/* ----------------------------------------------------------------------------- + * Video Capture Device + */ + +#define IMX_CAPTURE_NAME "imx-capture" + +struct capture_priv { + struct imx_media_dev *md; /* Media device */ + struct device *dev; /* Physical device */ + + struct imx_media_video_dev vdev; /* Video device */ + struct media_pad vdev_pad; /* Video device pad */ + + struct v4l2_subdev *src_sd; /* Source subdev */ + int src_sd_pad; /* Source subdev pad */ + + struct mutex mutex; /* Protect vdev operations */ + + struct vb2_queue q; /* The videobuf2 queue */ + struct list_head ready_q; /* List of queued buffers */ + 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) + +/* 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) +{ + const struct imx_media_pixfmt *cc; + + cc = imx_media_find_ipu_format(code, PIXFMT_SEL_YUV_RGB); + if (cc) { + enum imx_pixfmt_sel fmt_sel = cc->cs == IPUV3_COLORSPACE_YUV + ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB; + + cc = imx_media_find_pixel_format(fourcc, fmt_sel); + if (!cc) { + imx_media_enum_pixel_formats(&fourcc, 0, fmt_sel, 0); + cc = imx_media_find_pixel_format(fourcc, fmt_sel); + } + + return cc; + } + + return imx_media_find_mbus_format(code, PIXFMT_SEL_ANY); +} + +static int capture_querycap(struct file *file, void *fh, + struct v4l2_capability *cap) +{ + struct capture_priv *priv = video_drvdata(file); + + strscpy(cap->driver, IMX_CAPTURE_NAME, sizeof(cap->driver)); + strscpy(cap->card, IMX_CAPTURE_NAME, sizeof(cap->card)); + snprintf(cap->bus_info, sizeof(cap->bus_info), + "platform:%s", dev_name(priv->dev)); + + return 0; +} + +static int capture_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) +{ + const struct imx_media_pixfmt *cc; + + if (fsize->index > 0) + return -EINVAL; + + cc = imx_media_find_pixel_format(fsize->pixel_format, PIXFMT_SEL_ANY); + if (!cc) + return -EINVAL; + + /* + * TODO: The constraints are hardware-specific and may depend on the + * pixel format. This should come from the driver using + * imx_media_capture. + */ + fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; + fsize->stepwise.min_width = 1; + fsize->stepwise.max_width = 65535; + fsize->stepwise.min_height = 1; + fsize->stepwise.max_height = 65535; + fsize->stepwise.step_width = 1; + fsize->stepwise.step_height = 1; + + return 0; +} + +static int capture_g_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) +{ + struct capture_priv *priv = video_drvdata(file); + + f->fmt.pix = priv->vdev.fmt; + + return 0; +} + +static const struct imx_media_pixfmt * +__capture_try_fmt(struct v4l2_pix_format *pixfmt, struct v4l2_rect *compose) +{ + struct v4l2_mbus_framefmt fmt_src; + const struct imx_media_pixfmt *cc; + + /* + * Find the pixel format, default to the first supported format if not + * found. + */ + cc = imx_media_find_pixel_format(pixfmt->pixelformat, PIXFMT_SEL_ANY); + if (!cc) { + imx_media_enum_pixel_formats(&pixfmt->pixelformat, 0, + PIXFMT_SEL_ANY, 0); + cc = imx_media_find_pixel_format(pixfmt->pixelformat, + PIXFMT_SEL_ANY); + } + + /* Allow IDMAC interweave but enforce field order from source. */ + if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) { + switch (pixfmt->field) { + case V4L2_FIELD_SEQ_TB: + pixfmt->field = V4L2_FIELD_INTERLACED_TB; + break; + case V4L2_FIELD_SEQ_BT: + pixfmt->field = V4L2_FIELD_INTERLACED_BT; + break; + default: + break; + } + } + + v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); + imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); + + if (compose) { + compose->width = fmt_src.width; + compose->height = fmt_src.height; + } + + return cc; +} + +static int capture_try_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) +{ + __capture_try_fmt(&f->fmt.pix, NULL); + return 0; +} + +static int capture_s_fmt_vid_cap(struct file *file, void *fh, + struct v4l2_format *f) +{ + struct capture_priv *priv = video_drvdata(file); + const struct imx_media_pixfmt *cc; + + if (vb2_is_busy(&priv->q)) { + dev_err(priv->dev, "%s queue busy\n", __func__); + return -EBUSY; + } + + cc = __capture_try_fmt(&f->fmt.pix, &priv->vdev.compose); + + priv->vdev.cc = cc; + priv->vdev.fmt = f->fmt.pix; + + return 0; +} + +static int capture_g_selection(struct file *file, void *fh, + struct v4l2_selection *s) +{ + struct capture_priv *priv = video_drvdata(file); + + switch (s->target) { + case V4L2_SEL_TGT_COMPOSE: + case V4L2_SEL_TGT_COMPOSE_DEFAULT: + case V4L2_SEL_TGT_COMPOSE_BOUNDS: + /* The compose rectangle is fixed to the source format. */ + s->r = priv->vdev.compose; + break; + case V4L2_SEL_TGT_COMPOSE_PADDED: + /* + * The hardware writes with a configurable but fixed DMA burst + * size. If the source format width is not burst size aligned, + * the written frame contains padding to the right. + */ + s->r.left = 0; + s->r.top = 0; + s->r.width = priv->vdev.fmt.width; + s->r.height = priv->vdev.fmt.height; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int capture_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 capture_ioctl_ops = { + .vidioc_querycap = capture_querycap, + + .vidioc_enum_fmt_vid_cap = capture_enum_fmt_vid_cap, + .vidioc_enum_framesizes = capture_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_selection = capture_g_selection, + + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_expbuf = vb2_ioctl_expbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, + + .vidioc_subscribe_event = capture_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, +}; + +/* ----------------------------------------------------------------------------- + * 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[]) +{ + struct capture_priv *priv = vb2_get_drv_priv(vq); + struct v4l2_pix_format *pix = &priv->vdev.fmt; + unsigned int count = *nbuffers; + + if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + if (*nplanes) { + if (*nplanes != 1 || sizes[0] < pix->sizeimage) + return -EINVAL; + count += vq->num_buffers; + } + + count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count); + + if (*nplanes) + *nbuffers = (count < vq->num_buffers) ? 0 : + count - vq->num_buffers; + else + *nbuffers = count; + + *nplanes = 1; + sizes[0] = pix->sizeimage; + + return 0; +} + +static int capture_buf_init(struct vb2_buffer *vb) +{ + struct imx_media_buffer *buf = to_imx_media_vb(vb); + + INIT_LIST_HEAD(&buf->list); + + return 0; +} + +static int capture_buf_prepare(struct vb2_buffer *vb) +{ + struct vb2_queue *vq = vb->vb2_queue; + struct capture_priv *priv = vb2_get_drv_priv(vq); + struct v4l2_pix_format *pix = &priv->vdev.fmt; + + if (vb2_plane_size(vb, 0) < pix->sizeimage) { + dev_err(priv->dev, + "data will not fit into plane (%lu < %lu)\n", + vb2_plane_size(vb, 0), (long)pix->sizeimage); + return -EINVAL; + } + + vb2_set_plane_payload(vb, 0, pix->sizeimage); + + return 0; +} + +static void capture_buf_queue(struct vb2_buffer *vb) +{ + struct capture_priv *priv = vb2_get_drv_priv(vb->vb2_queue); + struct imx_media_buffer *buf = to_imx_media_vb(vb); + unsigned long flags; + + spin_lock_irqsave(&priv->q_lock, flags); + + list_add_tail(&buf->list, &priv->ready_q); + + spin_unlock_irqrestore(&priv->q_lock, flags); +} + +static int capture_validate_fmt(struct capture_priv *priv) +{ + struct v4l2_subdev_format fmt_src; + const struct imx_media_pixfmt *cc; + int ret; + + /* Retrieve the media bus format on the source subdev. */ + fmt_src.pad = priv->src_sd_pad; + fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; + ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); + if (ret) + return ret; + + /* + * 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 + * derived directly from the compose rectangle size, and will thus + * always match if the compose rectangle matches. + */ + if (priv->vdev.compose.width != fmt_src.format.width || + priv->vdev.compose.height != fmt_src.format.height) + return -EPIPE; + + /* + * 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); + if (!cc || priv->vdev.cc->cs != cc->cs) + return -EPIPE; + + return 0; +} + +static int capture_start_streaming(struct vb2_queue *vq, unsigned int count) +{ + struct capture_priv *priv = vb2_get_drv_priv(vq); + struct imx_media_buffer *buf, *tmp; + unsigned long flags; + int ret; + + ret = capture_validate_fmt(priv); + if (ret) { + dev_err(priv->dev, "capture format not valid\n"); + goto return_bufs; + } + + ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity, + true); + if (ret) { + dev_err(priv->dev, "pipeline start failed with %d\n", ret); + goto return_bufs; + } + + return 0; + +return_bufs: + spin_lock_irqsave(&priv->q_lock, flags); + list_for_each_entry_safe(buf, tmp, &priv->ready_q, list) { + list_del(&buf->list); + vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_QUEUED); + } + spin_unlock_irqrestore(&priv->q_lock, flags); + return ret; +} + +static void capture_stop_streaming(struct vb2_queue *vq) +{ + struct capture_priv *priv = vb2_get_drv_priv(vq); + struct imx_media_buffer *frame; + struct imx_media_buffer *tmp; + unsigned long flags; + int ret; + + ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity, + false); + if (ret) + dev_warn(priv->dev, "pipeline stop failed with %d\n", ret); + + /* release all active buffers */ + spin_lock_irqsave(&priv->q_lock, flags); + list_for_each_entry_safe(frame, tmp, &priv->ready_q, list) { + list_del(&frame->list); + vb2_buffer_done(&frame->vbuf.vb2_buf, VB2_BUF_STATE_ERROR); + } + spin_unlock_irqrestore(&priv->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, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, + .start_streaming = capture_start_streaming, + .stop_streaming = capture_stop_streaming, +}; + +/* ----------------------------------------------------------------------------- + * Video Capture Device - File Operations + */ + +static int capture_open(struct file *file) +{ + struct capture_priv *priv = video_drvdata(file); + struct video_device *vfd = priv->vdev.vfd; + int ret; + + if (mutex_lock_interruptible(&priv->mutex)) + return -ERESTARTSYS; + + ret = v4l2_fh_open(file); + if (ret) { + dev_err(priv->dev, "v4l2_fh_open failed\n"); + goto out; + } + + ret = v4l2_pipeline_pm_get(&vfd->entity); + if (ret) + v4l2_fh_release(file); + +out: + mutex_unlock(&priv->mutex); + return ret; +} + +static int capture_release(struct file *file) +{ + struct capture_priv *priv = video_drvdata(file); + struct video_device *vfd = priv->vdev.vfd; + struct vb2_queue *vq = &priv->q; + + mutex_lock(&priv->mutex); + + if (file->private_data == vq->owner) { + vb2_queue_release(vq); + vq->owner = NULL; + } + + v4l2_pipeline_pm_put(&vfd->entity); + + v4l2_fh_release(file); + mutex_unlock(&priv->mutex); + return 0; +} + +static const struct v4l2_file_operations capture_fops = { + .owner = THIS_MODULE, + .open = capture_open, + .release = capture_release, + .poll = vb2_fop_poll, + .unlocked_ioctl = video_ioctl2, + .mmap = vb2_fop_mmap, +}; + +/* ----------------------------------------------------------------------------- + * Video Capture Device - Init & Cleanup + */ + +static struct imx_media_buffer * +imx7_media_capture_device_next_buf(struct imx_media_video_dev *vdev) +{ + struct capture_priv *priv = to_capture_priv(vdev); + struct imx_media_buffer *buf = NULL; + unsigned long flags; + + spin_lock_irqsave(&priv->q_lock, flags); + + /* get next queued buffer */ + if (!list_empty(&priv->ready_q)) { + buf = list_entry(priv->ready_q.next, struct imx_media_buffer, + list); + list_del(&buf->list); + } + + spin_unlock_irqrestore(&priv->q_lock, flags); + + return buf; +} + +static int capture_init_format(struct capture_priv *priv) +{ + struct v4l2_subdev_format fmt_src = { + .pad = priv->src_sd_pad, + .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; + } + + 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; + + vdev->cc = imx_media_find_pixel_format(vdev->fmt.pixelformat, + PIXFMT_SEL_ANY); + + return 0; +} + +static int imx7_media_capture_device_register(struct imx_media_video_dev *vdev, + u32 link_flags) +{ + struct capture_priv *priv = to_capture_priv(vdev); + struct v4l2_subdev *sd = priv->src_sd; + struct v4l2_device *v4l2_dev = sd->v4l2_dev; + struct video_device *vfd = vdev->vfd; + int ret; + + /* get media device */ + priv->md = container_of(v4l2_dev->mdev, struct imx_media_dev, md); + + vfd->v4l2_dev = v4l2_dev; + + /* Initialize the default format and compose rectangle. */ + ret = capture_init_format(priv); + if (ret < 0) + return ret; + + /* Register the video device. */ + ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1); + if (ret) { + dev_err(priv->dev, "Failed to register video device\n"); + return ret; + } + + dev_info(priv->dev, "Registered %s as /dev/%s\n", vfd->name, + video_device_node_name(vfd)); + + /* Create the link from the src_sd devnode pad to device node. */ + if (link_flags & MEDIA_LNK_FL_IMMUTABLE) + link_flags |= MEDIA_LNK_FL_ENABLED; + ret = media_create_pad_link(&sd->entity, priv->src_sd_pad, + &vfd->entity, 0, link_flags); + if (ret) { + dev_err(priv->dev, "failed to create link to device node\n"); + video_unregister_device(vfd); + return ret; + } + + /* Add vdev to the video devices list. */ + imx_media_add_video_device(priv->md, vdev); + + return 0; +} + +static void imx7_media_capture_device_unregister(struct imx_media_video_dev *vdev) +{ + struct capture_priv *priv = to_capture_priv(vdev); + struct video_device *vfd = priv->vdev.vfd; + + media_entity_cleanup(&vfd->entity); + video_unregister_device(vfd); +} + +static struct imx_media_video_dev * +imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, + int pad, bool legacy_api) +{ + struct capture_priv *priv; + struct video_device *vfd; + struct vb2_queue *vq; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return ERR_PTR(-ENOMEM); + + 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); + spin_lock_init(&priv->q_lock); + + /* Allocate and initialize the video device. */ + vfd = video_device_alloc(); + if (!vfd) + return ERR_PTR(-ENOMEM); + + vfd->fops = &capture_fops; + vfd->ioctl_ops = &capture_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 + | (!legacy_api ? V4L2_CAP_IO_MC : 0); + vfd->lock = &priv->mutex; + vfd->queue = &priv->q; + + snprintf(vfd->name, sizeof(vfd->name), "%s capture", src_sd->name); + + video_set_drvdata(vfd, priv); + priv->vdev.vfd = vfd; + INIT_LIST_HEAD(&priv->vdev.list); + + /* Initialize the video device pad. */ + priv->vdev_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_pads_init(&vfd->entity, 1, &priv->vdev_pad); + if (ret) { + video_device_release(vfd); + return ERR_PTR(ret); + } + + /* Initialize the vb2 queue. */ + vq = &priv->q; + vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + vq->io_modes = VB2_MMAP | VB2_DMABUF; + vq->drv_priv = priv; + vq->buf_struct_size = sizeof(struct imx_media_buffer); + vq->ops = &capture_qops; + vq->mem_ops = &vb2_dma_contig_memops; + vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + vq->lock = &priv->mutex; + vq->min_buffers_needed = 2; + vq->dev = priv->dev; + + ret = vb2_queue_init(vq); + if (ret) { + dev_err(priv->dev, "vb2_queue_init failed\n"); + video_device_release(vfd); + 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; +} + +static void imx7_media_capture_device_remove(struct imx_media_video_dev *vdev) +{ + struct capture_priv *priv = to_capture_priv(vdev); + + v4l2_ctrl_handler_free(&priv->ctrl_hdlr); +} + /* ----------------------------------------------------------------------------- * V4L2 Subdev Operations */ @@ -1049,13 +1741,13 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) struct imx7_csi *csi = v4l2_get_subdevdata(sd); int ret; - csi->vdev = imx_media_capture_device_init(csi->sd.dev, &csi->sd, - IMX7_CSI_PAD_SRC, false); + csi->vdev = imx7_media_capture_device_init(csi->sd.dev, &csi->sd, + IMX7_CSI_PAD_SRC, false); if (IS_ERR(csi->vdev)) return PTR_ERR(csi->vdev); - ret = imx_media_capture_device_register(csi->vdev, - MEDIA_LNK_FL_IMMUTABLE); + ret = imx7_media_capture_device_register(csi->vdev, + MEDIA_LNK_FL_IMMUTABLE); if (ret) goto err_remove; @@ -1070,9 +1762,9 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) return 0; err_unreg: - imx_media_capture_device_unregister(csi->vdev); + imx7_media_capture_device_unregister(csi->vdev); err_remove: - imx_media_capture_device_remove(csi->vdev); + imx7_media_capture_device_remove(csi->vdev); return ret; } @@ -1080,8 +1772,8 @@ static void imx7_csi_unregistered(struct v4l2_subdev *sd) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); - imx_media_capture_device_unregister(csi->vdev); - imx_media_capture_device_remove(csi->vdev); + imx7_media_capture_device_unregister(csi->vdev); + imx7_media_capture_device_remove(csi->vdev); } static const struct v4l2_subdev_video_ops imx7_csi_video_ops = { From patchwork Tue May 10 11:51:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15852 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1F483C326D for ; Tue, 10 May 2022 11:52:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B21196566D; Tue, 10 May 2022 13:52:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183533; bh=fvLlTM3o+3rn3zzOQBxWlaa4ljFoBkY1Y//8BFiskao=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=BN+50uECuYj+pJlojXqMLn2KNHucLDOMbNEj0qPGPIUiVq0EaVdO8pobEWzKc1Sa2 svM41IIYFN7ynCuQ4xBuIReoOjdKu3plikExBXhXuYnA4DdWGqxTcwCdzk3iXhWosF VAxfYkiOqgo6zzM+dGMepqKRtIMMCDiJElOvB7lQn0Lvfyk8vIYnqQbhn8LEN1j1Yn NXtdBNmR+OiLJTdgXBoHv3Ax2k//vs8Exk5FUMmYQQTkP0MlmaUIVI7Ic+uVhsLoPA BtXdhxZs+46GMN1DSEPuLdAgZ1yvkGpnuuDxV4sHJ5D45jeMGLAxCTofR14AH8jC+3 Etqbkt8m0BpgA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7DE0865664 for ; Tue, 10 May 2022 13:52:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lOfrDQFC"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 96F0AE0C; Tue, 10 May 2022 13:52:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183527; bh=fvLlTM3o+3rn3zzOQBxWlaa4ljFoBkY1Y//8BFiskao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lOfrDQFCvH8yEz/blnZhLCxB+N3FbpmLVmNV4ihBF6l9fm0XXCBKUpj0UvOdPAeud Oh+yM6VF1qP/iLsr5qjdHlGvSRboXDn0ZWi/kq17AktD6fO2/OXmRPk5BIWEuWaOPa X9Pp0MjkPA+3F8BdIBrUTLOaq9qlaedJK5Kz+tpM= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:09 +0300 Message-Id: <20220510115147.19360-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 12/50] staging: media: imx: imx7-media-csi: Drop legacy video device support X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51: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: 15853 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 00F04C326E for ; Tue, 10 May 2022 11:52:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8373965648; Tue, 10 May 2022 13:52:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183534; bh=qW8IIw68EVP3AedmAhYt7206Mi7WCoyGyeEfwRlV45Q=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Sdw6BkLxotAXBeXfPDpMb4k4mPTX7ytDe12WEVZail927FqpNucaWP92ArmuDfYOz ONpTPOAI62sLVpXEAyEPOsw30OHTf8PrTQYyvrNWmzA5KnrTMSXS4GxDrYYn+IQprA n+KQ/TTDoBMnJcSmacWElnswZyrbBaq69y/1xuindo+jUDhLp+zDTUljaExbeqGXtk M3UpkUBkE++905aLjIpCHTXxWnvUplg/PTvlCBxIykGYGWkKXnzszrg4c/3mhq+Y52 ylYjIa2eAz7WiFsMPohZDzY0KYlKMDX2Ty7cdbcFJgY+XPgJ2dV1jL+56CK73hDNvU Wj6jMwb4+MjsQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F8A365652 for ; Tue, 10 May 2022 13:52:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="B8lcUAqK"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7643BB60; Tue, 10 May 2022 13:52:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183528; bh=qW8IIw68EVP3AedmAhYt7206Mi7WCoyGyeEfwRlV45Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8lcUAqKsG2NeKYC5Cy4qpZLC2vGhYWtXULY2aMWPaqTFyOMpMMh5nyYUtFzyfx1G vDD5K7JfOJlwhW7h0hx1jFgIuaoSXOQ/048CqevtOTJYfGiRdLJ1gbFKVDT2k0WqXK vFjkIYUKvpof1nThhhnVfzDtOscQxRnbPDCLsvI0= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:10 +0300 Message-Id: <20220510115147.19360-14-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 13/50] staging: media: imx: imx7-media-csi: Drop unused controls support X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Drop the unused control handler from the driver. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 2e314ce961dc..499bb74ad6f3 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -744,8 +743,6 @@ struct capture_priv { struct vb2_queue q; /* The videobuf2 queue */ struct list_head ready_q; /* List of queued buffers */ spinlock_t q_lock; /* Protect ready_q */ - - struct v4l2_ctrl_handler ctrl_hdlr; /* Controls inherited from subdevs */ }; #define to_capture_priv(v) container_of(v, struct capture_priv, vdev) @@ -1382,13 +1379,6 @@ imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, return &priv->vdev; } -static void imx7_media_capture_device_remove(struct imx_media_video_dev *vdev) -{ - struct capture_priv *priv = to_capture_priv(vdev); - - v4l2_ctrl_handler_free(&priv->ctrl_hdlr); -} - /* ----------------------------------------------------------------------------- * V4L2 Subdev Operations */ @@ -1730,7 +1720,7 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) ret = imx7_media_capture_device_register(csi->vdev, MEDIA_LNK_FL_IMMUTABLE); if (ret) - goto err_remove; + return ret; ret = v4l2_device_register_subdev_nodes(&csi->imxmd->v4l2_dev); if (ret) @@ -1744,8 +1734,6 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) err_unreg: imx7_media_capture_device_unregister(csi->vdev); -err_remove: - imx7_media_capture_device_remove(csi->vdev); return ret; } @@ -1754,7 +1742,6 @@ static void imx7_csi_unregistered(struct v4l2_subdev *sd) struct imx7_csi *csi = v4l2_get_subdevdata(sd); imx7_media_capture_device_unregister(csi->vdev); - imx7_media_capture_device_remove(csi->vdev); } static const struct v4l2_subdev_video_ops imx7_csi_video_ops = { From patchwork Tue May 10 11:51:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15854 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 253B6C3256 for ; Tue, 10 May 2022 11:52:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A5F6D65660; Tue, 10 May 2022 13:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183535; bh=VV3eplvYk/sJft+X1ditSjuXp/Rm1i02+4x1EUzfKII=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ny8yUBQErI5Pa3UVjeImhEpkCC4VcNg7Wrcr1svOrOhP0ax0nlI5s8wyFIk44aYWu bIaV3IBeuXf4RovoOG+mr+rgjahqHhJ/irP4M+QD4RBiYxoqv/H9G6JXNiRR8cJDzg Z2TX4fm5Jze9wpPgvAszj+Bu9lNpHUYLUB23piGvEob7JqMsZIJGVXnqQJvdf75LDL TlP/zSoLWGH/D33KkSJRbAaN9ljXrbEVL8PbX2HuDKgtM3N0LCAsHgPgdgnvIBl77D EL0s9N4ifnNq1zXkARqTM5LhioX6CHq7tlsJvYJWxrvkxubuvLkDMPCC065UqsJPMN oItAxw9XcKofg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 273AF65667 for ; Tue, 10 May 2022 13:52:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f4lQBRJX"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B24FBA9; Tue, 10 May 2022 13:52:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183528; bh=VV3eplvYk/sJft+X1ditSjuXp/Rm1i02+4x1EUzfKII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4lQBRJXyL8L/g1QX9TJGNogUL/qN2UWmnx1I5KSRorjjzYYiAj15S+ZuDXPt4AfL jAAs4K2G6b7xwCsR3U7/1XsekDe+QmO2tiObIluxDyzO9u4OM/poNfJnlx5g31ZAty JV6Tiepe4fH5sv2NKCWbklnqha6hclrJwEDueEHA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:11 +0300 Message-Id: <20220510115147.19360-15-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 14/50] staging: media: imx: imx7-media-csi: Reorganize imx7_csi structure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15855 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6E2D9C326C for ; Tue, 10 May 2022 11:52:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1050465671; Tue, 10 May 2022 13:52:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183537; bh=8VldD6m7V1ArQbM/CUQB5R4nyIPDmBlDaODt8kryyMA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LO2Mn7w5vSAoc+O8OCM0gw3naZWMPxNI3IVQq7luaFblkdrcyZpQLyv7kNvchTkqX kqpA0zfL/XEDYj1jiFmmVRbNx8NVbXGTiIs9Vy+OMuks30hgxjxIRS9pb5U90t1Ii9 swLBmBxpQFsukcN9IAlc2D6yhfOL0vBMFJN7JBPESgAYQvQX2xzxY8Cex7Gl1+a5Cq dAQf2VOjrcvDIRXaLitXHH1NiwNtZ46kFxsk7GUdgDJ0s+YY5scOa0GIXde+IOdAub cUlOYmnkJnAp5TIRVUmmLxebHm/LJT2tprEzfzp3sBlCIj82EXQvjoVT2cP51f5co+ BAOFAh4RS3scw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0CBC96565D for ; Tue, 10 May 2022 13:52:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GnQkg5jN"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 23E5CB9A; Tue, 10 May 2022 13:52:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183529; bh=8VldD6m7V1ArQbM/CUQB5R4nyIPDmBlDaODt8kryyMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GnQkg5jNjp9ViBvKzwa1Ipd2eNvoK3kwj0omg4uWZFfchKArHK2WeYBIzjL5QHL9E HK8uu2q5g0xb3UNFpWhbzVrxqX7dNWl9j7wBKzLprXtpjZLGGJLVa6ledB5oS3pliL nJnXVOJsV9U0xTgpBrZD0U3aak0a7WfIjd2Ey2Vg= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:12 +0300 Message-Id: <20220510115147.19360-16-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 15/50] staging: media: imx: imx7-media-csi: Fold capture_priv into imx7_csi X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Merge the capture_priv fields in the imx7_csi structure as there's no more need to have two separate structures. Update all the users accordingly. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 271 +++++++++------------ 1 file changed, 117 insertions(+), 154 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index ad69c2e8dbc2..9b4463e456c2 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -193,7 +193,14 @@ struct imx7_csi { const struct imx_media_pixfmt *cc[IMX7_CSI_PADS_NUM]; /* Video device */ - struct imx_media_video_dev *vdev; + struct imx_media_video_dev vdev; /* Video device */ + struct media_pad vdev_pad; /* Video device pad */ + + struct mutex vdev_mutex; /* Protect vdev operations */ + + struct vb2_queue q; /* The videobuf2 queue */ + struct list_head ready_q; /* List of queued buffers */ + spinlock_t q_lock; /* Protect ready_q */ /* Buffers and streaming state */ struct imx_media_buffer *active_vb2_buf[2]; @@ -343,18 +350,17 @@ static void imx7_csi_update_buf(struct imx7_csi *csi, dma_addr_t phys, } static struct imx_media_buffer * -imx7_media_capture_device_next_buf(struct imx_media_video_dev *vdev); +imx7_media_capture_device_next_buf(struct imx7_csi *csi); static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) { - struct imx_media_video_dev *vdev = csi->vdev; struct imx_media_buffer *buf; struct vb2_buffer *vb2_buf; dma_addr_t phys[2]; int i; for (i = 0; i < 2; i++) { - buf = imx7_media_capture_device_next_buf(vdev); + buf = imx7_media_capture_device_next_buf(csi); if (buf) { csi->active_vb2_buf[i] = buf; vb2_buf = &buf->vbuf.vb2_buf; @@ -389,7 +395,7 @@ 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; + struct imx_media_video_dev *vdev = &csi->vdev; int ret; ret = imx_media_alloc_dma_buf(csi->dev, &csi->underrun_buf, @@ -440,7 +446,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 imx_media_video_dev *vdev = &csi->vdev; struct v4l2_pix_format *out_pix = &vdev->fmt; int width = out_pix->width; u32 stride = 0; @@ -640,7 +646,7 @@ 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 imx_media_video_dev *vdev = &csi->vdev; struct imx_media_buffer *done, *next; struct vb2_buffer *vb; dma_addr_t phys; @@ -656,7 +662,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(vdev); + next = imx7_media_capture_device_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,25 +738,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) #define IMX_CAPTURE_NAME "imx-capture" -struct capture_priv { - struct imx_media_dev *md; /* Media device */ - struct device *dev; /* Physical device */ - - struct imx_media_video_dev vdev; /* Video device */ - struct media_pad vdev_pad; /* Video device pad */ - - struct v4l2_subdev *src_sd; /* Source subdev */ - int src_sd_pad; /* Source subdev pad */ - - struct mutex mutex; /* Protect vdev operations */ - - struct vb2_queue q; /* The videobuf2 queue */ - struct list_head ready_q; /* List of queued buffers */ - spinlock_t q_lock; /* Protect ready_q */ -}; - -#define to_capture_priv(v) container_of(v, struct capture_priv, vdev) - /* In bytes, per queue */ #define VID_MEM_LIMIT SZ_64M @@ -782,12 +769,12 @@ static const struct imx_media_pixfmt *capture_find_format(u32 code, u32 fourcc) static int capture_querycap(struct file *file, void *fh, struct v4l2_capability *cap) { - struct capture_priv *priv = video_drvdata(file); + 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)); snprintf(cap->bus_info, sizeof(cap->bus_info), - "platform:%s", dev_name(priv->dev)); + "platform:%s", dev_name(csi->dev)); return 0; } @@ -830,9 +817,9 @@ static int capture_enum_framesizes(struct file *file, void *fh, static int capture_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - struct capture_priv *priv = video_drvdata(file); + struct imx7_csi *csi = video_drvdata(file); - f->fmt.pix = priv->vdev.fmt; + f->fmt.pix = csi->vdev.fmt; return 0; } @@ -890,18 +877,18 @@ static int capture_try_fmt_vid_cap(struct file *file, void *fh, static int capture_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - struct capture_priv *priv = video_drvdata(file); + struct imx7_csi *csi = video_drvdata(file); const struct imx_media_pixfmt *cc; - if (vb2_is_busy(&priv->q)) { - dev_err(priv->dev, "%s queue busy\n", __func__); + if (vb2_is_busy(&csi->q)) { + dev_err(csi->dev, "%s queue busy\n", __func__); return -EBUSY; } - cc = __capture_try_fmt(&f->fmt.pix, &priv->vdev.compose); + cc = __capture_try_fmt(&f->fmt.pix, &csi->vdev.compose); - priv->vdev.cc = cc; - priv->vdev.fmt = f->fmt.pix; + csi->vdev.cc = cc; + csi->vdev.fmt = f->fmt.pix; return 0; } @@ -909,14 +896,14 @@ static int capture_s_fmt_vid_cap(struct file *file, void *fh, static int capture_g_selection(struct file *file, void *fh, struct v4l2_selection *s) { - struct capture_priv *priv = video_drvdata(file); + struct imx7_csi *csi = video_drvdata(file); switch (s->target) { case V4L2_SEL_TGT_COMPOSE: case V4L2_SEL_TGT_COMPOSE_DEFAULT: case V4L2_SEL_TGT_COMPOSE_BOUNDS: /* The compose rectangle is fixed to the source format. */ - s->r = priv->vdev.compose; + s->r = csi->vdev.compose; break; case V4L2_SEL_TGT_COMPOSE_PADDED: /* @@ -926,8 +913,8 @@ static int capture_g_selection(struct file *file, void *fh, */ s->r.left = 0; s->r.top = 0; - s->r.width = priv->vdev.fmt.width; - s->r.height = priv->vdev.fmt.height; + s->r.width = csi->vdev.fmt.width; + s->r.height = csi->vdev.fmt.height; break; default: return -EINVAL; @@ -983,8 +970,8 @@ static int capture_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { - struct capture_priv *priv = vb2_get_drv_priv(vq); - struct v4l2_pix_format *pix = &priv->vdev.fmt; + struct imx7_csi *csi = vb2_get_drv_priv(vq); + struct v4l2_pix_format *pix = &csi->vdev.fmt; unsigned int count = *nbuffers; if (vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -1021,12 +1008,11 @@ static int capture_buf_init(struct vb2_buffer *vb) static int capture_buf_prepare(struct vb2_buffer *vb) { - struct vb2_queue *vq = vb->vb2_queue; - struct capture_priv *priv = vb2_get_drv_priv(vq); - struct v4l2_pix_format *pix = &priv->vdev.fmt; + struct imx7_csi *csi = vb2_get_drv_priv(vb->vb2_queue); + struct v4l2_pix_format *pix = &csi->vdev.fmt; if (vb2_plane_size(vb, 0) < pix->sizeimage) { - dev_err(priv->dev, + dev_err(csi->dev, "data will not fit into plane (%lu < %lu)\n", vb2_plane_size(vb, 0), (long)pix->sizeimage); return -EINVAL; @@ -1039,27 +1025,27 @@ static int capture_buf_prepare(struct vb2_buffer *vb) static void capture_buf_queue(struct vb2_buffer *vb) { - struct capture_priv *priv = vb2_get_drv_priv(vb->vb2_queue); + struct imx7_csi *csi = vb2_get_drv_priv(vb->vb2_queue); struct imx_media_buffer *buf = to_imx_media_vb(vb); unsigned long flags; - spin_lock_irqsave(&priv->q_lock, flags); + spin_lock_irqsave(&csi->q_lock, flags); - list_add_tail(&buf->list, &priv->ready_q); + list_add_tail(&buf->list, &csi->ready_q); - spin_unlock_irqrestore(&priv->q_lock, flags); + spin_unlock_irqrestore(&csi->q_lock, flags); } -static int capture_validate_fmt(struct capture_priv *priv) +static int capture_validate_fmt(struct imx7_csi *csi) { struct v4l2_subdev_format fmt_src; const struct imx_media_pixfmt *cc; int ret; /* Retrieve the media bus format on the source subdev. */ - fmt_src.pad = priv->src_sd_pad; + fmt_src.pad = IMX7_CSI_PAD_SRC; fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE; - ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL, &fmt_src); + ret = v4l2_subdev_call(&csi->sd, pad, get_fmt, NULL, &fmt_src); if (ret) return ret; @@ -1070,8 +1056,8 @@ static int capture_validate_fmt(struct capture_priv *priv) * derived directly from the compose rectangle size, and will thus * always match if the compose rectangle matches. */ - if (priv->vdev.compose.width != fmt_src.format.width || - priv->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; /* @@ -1079,7 +1065,7 @@ static int capture_validate_fmt(struct capture_priv *priv) * set on the video node. */ cc = capture_find_format(fmt_src.format.code, 0); - if (!cc || priv->vdev.cc->cs != cc->cs) + if (!cc || csi->vdev.cc->cs != cc->cs) return -EPIPE; return 0; @@ -1087,56 +1073,54 @@ static int capture_validate_fmt(struct capture_priv *priv) static int capture_start_streaming(struct vb2_queue *vq, unsigned int count) { - struct capture_priv *priv = vb2_get_drv_priv(vq); + struct imx7_csi *csi = vb2_get_drv_priv(vq); struct imx_media_buffer *buf, *tmp; unsigned long flags; int ret; - ret = capture_validate_fmt(priv); + ret = capture_validate_fmt(csi); if (ret) { - dev_err(priv->dev, "capture format not valid\n"); + dev_err(csi->dev, "capture format not valid\n"); goto return_bufs; } - ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity, - true); + ret = imx_media_pipeline_set_stream(csi->imxmd, &csi->sd.entity, true); if (ret) { - dev_err(priv->dev, "pipeline start failed with %d\n", ret); + dev_err(csi->dev, "pipeline start failed with %d\n", ret); goto return_bufs; } return 0; return_bufs: - spin_lock_irqsave(&priv->q_lock, flags); - list_for_each_entry_safe(buf, tmp, &priv->ready_q, list) { + spin_lock_irqsave(&csi->q_lock, flags); + list_for_each_entry_safe(buf, tmp, &csi->ready_q, list) { list_del(&buf->list); vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_QUEUED); } - spin_unlock_irqrestore(&priv->q_lock, flags); + spin_unlock_irqrestore(&csi->q_lock, flags); return ret; } static void capture_stop_streaming(struct vb2_queue *vq) { - struct capture_priv *priv = vb2_get_drv_priv(vq); + struct imx7_csi *csi = vb2_get_drv_priv(vq); struct imx_media_buffer *frame; struct imx_media_buffer *tmp; unsigned long flags; int ret; - ret = imx_media_pipeline_set_stream(priv->md, &priv->src_sd->entity, - false); + ret = imx_media_pipeline_set_stream(csi->imxmd, &csi->sd.entity, false); if (ret) - dev_warn(priv->dev, "pipeline stop failed with %d\n", ret); + dev_warn(csi->dev, "pipeline stop failed with %d\n", ret); /* release all active buffers */ - spin_lock_irqsave(&priv->q_lock, flags); - list_for_each_entry_safe(frame, tmp, &priv->ready_q, list) { + spin_lock_irqsave(&csi->q_lock, flags); + list_for_each_entry_safe(frame, tmp, &csi->ready_q, list) { list_del(&frame->list); vb2_buffer_done(&frame->vbuf.vb2_buf, VB2_BUF_STATE_ERROR); } - spin_unlock_irqrestore(&priv->q_lock, flags); + spin_unlock_irqrestore(&csi->q_lock, flags); } static const struct vb2_ops capture_qops = { @@ -1156,16 +1140,16 @@ static const struct vb2_ops capture_qops = { static int capture_open(struct file *file) { - struct capture_priv *priv = video_drvdata(file); - struct video_device *vfd = priv->vdev.vfd; + struct imx7_csi *csi = video_drvdata(file); + struct video_device *vfd = csi->vdev.vfd; int ret; - if (mutex_lock_interruptible(&priv->mutex)) + if (mutex_lock_interruptible(&csi->vdev_mutex)) return -ERESTARTSYS; ret = v4l2_fh_open(file); if (ret) { - dev_err(priv->dev, "v4l2_fh_open failed\n"); + dev_err(csi->dev, "v4l2_fh_open failed\n"); goto out; } @@ -1174,17 +1158,17 @@ static int capture_open(struct file *file) v4l2_fh_release(file); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&csi->vdev_mutex); return ret; } static int capture_release(struct file *file) { - struct capture_priv *priv = video_drvdata(file); - struct video_device *vfd = priv->vdev.vfd; - struct vb2_queue *vq = &priv->q; + struct imx7_csi *csi = video_drvdata(file); + struct video_device *vfd = csi->vdev.vfd; + struct vb2_queue *vq = &csi->q; - mutex_lock(&priv->mutex); + mutex_lock(&csi->vdev_mutex); if (file->private_data == vq->owner) { vb2_queue_release(vq); @@ -1194,7 +1178,7 @@ static int capture_release(struct file *file) v4l2_pipeline_pm_put(&vfd->entity); v4l2_fh_release(file); - mutex_unlock(&priv->mutex); + mutex_unlock(&csi->vdev_mutex); return 0; } @@ -1212,33 +1196,32 @@ static const struct v4l2_file_operations capture_fops = { */ static struct imx_media_buffer * -imx7_media_capture_device_next_buf(struct imx_media_video_dev *vdev) +imx7_media_capture_device_next_buf(struct imx7_csi *csi) { - struct capture_priv *priv = to_capture_priv(vdev); struct imx_media_buffer *buf = NULL; unsigned long flags; - spin_lock_irqsave(&priv->q_lock, flags); + spin_lock_irqsave(&csi->q_lock, flags); /* get next queued buffer */ - if (!list_empty(&priv->ready_q)) { - buf = list_entry(priv->ready_q.next, struct imx_media_buffer, + if (!list_empty(&csi->ready_q)) { + buf = list_entry(csi->ready_q.next, struct imx_media_buffer, list); list_del(&buf->list); } - spin_unlock_irqrestore(&priv->q_lock, flags); + spin_unlock_irqrestore(&csi->q_lock, flags); return buf; } -static int capture_init_format(struct capture_priv *priv) +static int capture_init_format(struct imx7_csi *csi) { struct v4l2_subdev_format fmt_src = { - .pad = priv->src_sd_pad, + .pad = IMX7_CSI_PAD_SRC, .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; - struct imx_media_video_dev *vdev = &priv->vdev; + 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; @@ -1254,86 +1237,68 @@ static int capture_init_format(struct capture_priv *priv) return 0; } -static int imx7_media_capture_device_register(struct imx_media_video_dev *vdev, - u32 link_flags) +static int imx7_media_capture_device_register(struct imx7_csi *csi) { - struct capture_priv *priv = to_capture_priv(vdev); - struct v4l2_subdev *sd = priv->src_sd; + struct v4l2_subdev *sd = &csi->sd; struct v4l2_device *v4l2_dev = sd->v4l2_dev; - struct video_device *vfd = vdev->vfd; + struct video_device *vfd = csi->vdev.vfd; int ret; - /* get media device */ - priv->md = container_of(v4l2_dev->mdev, struct imx_media_dev, md); - vfd->v4l2_dev = v4l2_dev; /* Initialize the default format and compose rectangle. */ - ret = capture_init_format(priv); + ret = capture_init_format(csi); if (ret < 0) return ret; /* Register the video device. */ ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1); if (ret) { - dev_err(priv->dev, "Failed to register video device\n"); + dev_err(csi->dev, "Failed to register video device\n"); return ret; } - dev_info(priv->dev, "Registered %s as /dev/%s\n", vfd->name, + dev_info(csi->dev, "Registered %s as /dev/%s\n", vfd->name, video_device_node_name(vfd)); - /* Create the link from the src_sd devnode pad to device node. */ - if (link_flags & MEDIA_LNK_FL_IMMUTABLE) - link_flags |= MEDIA_LNK_FL_ENABLED; - ret = media_create_pad_link(&sd->entity, priv->src_sd_pad, - &vfd->entity, 0, link_flags); + /* 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 | + MEDIA_LNK_FL_ENABLED); if (ret) { - dev_err(priv->dev, "failed to create link to device node\n"); + dev_err(csi->dev, "failed to create link to device node\n"); video_unregister_device(vfd); return ret; } /* Add vdev to the video devices list. */ - imx_media_add_video_device(priv->md, vdev); + imx_media_add_video_device(csi->imxmd, &csi->vdev); return 0; } -static void imx7_media_capture_device_unregister(struct imx_media_video_dev *vdev) +static void imx7_media_capture_device_unregister(struct imx7_csi *csi) { - struct capture_priv *priv = to_capture_priv(vdev); - struct video_device *vfd = priv->vdev.vfd; + struct video_device *vfd = csi->vdev.vfd; media_entity_cleanup(&vfd->entity); video_unregister_device(vfd); } -static struct imx_media_video_dev * -imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, - int pad) +static int imx7_media_capture_device_init(struct imx7_csi *csi) { - struct capture_priv *priv; struct video_device *vfd; struct vb2_queue *vq; int ret; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return ERR_PTR(-ENOMEM); - - priv->src_sd = src_sd; - priv->src_sd_pad = pad; - priv->dev = dev; - - mutex_init(&priv->mutex); - INIT_LIST_HEAD(&priv->ready_q); - spin_lock_init(&priv->q_lock); + mutex_init(&csi->vdev_mutex); + INIT_LIST_HEAD(&csi->ready_q); + spin_lock_init(&csi->q_lock); /* Allocate and initialize the video device. */ vfd = video_device_alloc(); if (!vfd) - return ERR_PTR(-ENOMEM); + return -ENOMEM; vfd->fops = &capture_fops; vfd->ioctl_ops = &capture_ioctl_ops; @@ -1343,44 +1308,44 @@ imx7_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, vfd->tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM; vfd->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; - vfd->lock = &priv->mutex; - vfd->queue = &priv->q; + vfd->lock = &csi->vdev_mutex; + vfd->queue = &csi->q; - snprintf(vfd->name, sizeof(vfd->name), "%s capture", src_sd->name); + snprintf(vfd->name, sizeof(vfd->name), "%s capture", csi->sd.name); - video_set_drvdata(vfd, priv); - priv->vdev.vfd = vfd; - INIT_LIST_HEAD(&priv->vdev.list); + video_set_drvdata(vfd, csi); + csi->vdev.vfd = vfd; + INIT_LIST_HEAD(&csi->vdev.list); /* Initialize the video device pad. */ - priv->vdev_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_pads_init(&vfd->entity, 1, &priv->vdev_pad); + csi->vdev_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_pads_init(&vfd->entity, 1, &csi->vdev_pad); if (ret) { video_device_release(vfd); - return ERR_PTR(ret); + return ret; } /* Initialize the vb2 queue. */ - vq = &priv->q; + vq = &csi->q; vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vq->io_modes = VB2_MMAP | VB2_DMABUF; - vq->drv_priv = priv; + vq->drv_priv = csi; vq->buf_struct_size = sizeof(struct imx_media_buffer); vq->ops = &capture_qops; vq->mem_ops = &vb2_dma_contig_memops; vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - vq->lock = &priv->mutex; + vq->lock = &csi->vdev_mutex; vq->min_buffers_needed = 2; - vq->dev = priv->dev; + vq->dev = csi->dev; ret = vb2_queue_init(vq); if (ret) { - dev_err(priv->dev, "vb2_queue_init failed\n"); + dev_err(csi->dev, "vb2_queue_init failed\n"); video_device_release(vfd); - return ERR_PTR(ret); + return ret; } - return &priv->vdev; + return 0; } /* ----------------------------------------------------------------------------- @@ -1645,7 +1610,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; + struct imx_media_video_dev *vdev = &csi->vdev; const struct v4l2_pix_format *out_pix = &vdev->fmt; struct media_pad *pad; int ret; @@ -1716,13 +1681,11 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) struct imx7_csi *csi = v4l2_get_subdevdata(sd); int ret; - csi->vdev = imx7_media_capture_device_init(csi->sd.dev, &csi->sd, - IMX7_CSI_PAD_SRC); - if (IS_ERR(csi->vdev)) - return PTR_ERR(csi->vdev); + ret = imx7_media_capture_device_init(csi); + if (ret) + return ret; - ret = imx7_media_capture_device_register(csi->vdev, - MEDIA_LNK_FL_IMMUTABLE); + ret = imx7_media_capture_device_register(csi); if (ret) return ret; @@ -1737,7 +1700,7 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) return 0; err_unreg: - imx7_media_capture_device_unregister(csi->vdev); + imx7_media_capture_device_unregister(csi); return ret; } @@ -1745,7 +1708,7 @@ static void imx7_csi_unregistered(struct v4l2_subdev *sd) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); - imx7_media_capture_device_unregister(csi->vdev); + imx7_media_capture_device_unregister(csi); } static const struct v4l2_subdev_video_ops imx7_csi_video_ops = { From patchwork Tue May 10 11:51: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: 15856 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DD56DC326D for ; Tue, 10 May 2022 11:52:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E34D65684; Tue, 10 May 2022 13:52:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183538; bh=ntJKLze6OrE+9OL6FEXItJoTrYmk7Yeef2Xythqg8GY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=rT8omwriDjOHO1G9J6FDXrwTOjJrqmIHwqyqcZgC1PeqirgxK45N5RNyaxUFChbw8 U+H9BU7sd0HtZVyf5GkzzpXKljqPJ/VsZrqkA4eB+ga9m6woms0Qt3hviwrQ0iekaG StTBypeDRIgv/DKW0YmMdMKWBrI2loIFhvb6PdluMYDzRHm8kL+JeKkgo3MSxKU58k pCRRzBRziCD9DeTsf8jvzdTjzilQnsKuVWXi7nf/pDrx/wWN01jVYYTKxgvTfm1Jy6 Sk+UjJjndsm7q0l7eDgjjs3XmM0ziQ95VaV0z4ZsTA8a6I5Q72OCnXS0SMq4nP03Wm RQ8LjMIrzLsdg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF80C6565C for ; Tue, 10 May 2022 13:52:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NPdxTvyx"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 085C9E0C; Tue, 10 May 2022 13:52:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183530; bh=ntJKLze6OrE+9OL6FEXItJoTrYmk7Yeef2Xythqg8GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NPdxTvyxk32fZs75AachcvW4KO0/8CKg8JlNQC2rCisTJWoy2rm5iG+cpcaeqs8CC htrmf2mfZA8FyrUnYWdEPRfv2TZXe2X25nRk6tfpVgWDRuEWD06v89ypYsoYc0UemA O5+JnDHjbg+2eKDd4yZMayAMqPR58ow4t8CZNrrk= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:13 +0300 Message-Id: <20220510115147.19360-17-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 16/50] staging: media: imx: imx7-media-csi: Ensure consistent function prefix X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15857 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4CC50C3256 for ; Tue, 10 May 2022 11:52:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E966B6564F; Tue, 10 May 2022 13:52:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183541; bh=2nqqOrgtxjxD2pNMktw8yQmUenswVmx0ziFCRdrpaxQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ZZ7hwin7xT8VovCocBUv5ifZjyyUzmMEE3OLY4cXbRmN7lI9QRZF/HMc4O349yhMn Jkv4fdKw/Gweg5o6f5UwBztU2KErfWQm/wpk1+H3rve7Rj1Q8WviIMTmY8vPRbhNPw Jub9wzQ1z2JkjfJJkOUdpCsMV9MbbsIX+SXJZyr5n5UYzRXJikHcbUC3GPtE90jogB tlcum99qOATIK7ASpJg0Zl/pZo0TrH9yWP/wXoI8TCPwIIUFey5VJXMPAXfGj6So4S inB9wgC+KIATpsVJbUmMBywq/VB7Pz5g1gWDWxUSl1e06ACaF5hO6TQ+IhbevlQI+E DRnQwhk4HU3FA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF9556566E for ; Tue, 10 May 2022 13:52:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="i2W1m6aN"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D6DC4824; Tue, 10 May 2022 13:52:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183531; bh=2nqqOrgtxjxD2pNMktw8yQmUenswVmx0ziFCRdrpaxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i2W1m6aNPQk7K4VeHDm8MksObo7T2kcevK/6wltfC48DmoziQUCchCjP4KXDk7gVS ME+pvn+qf6YvQlQyN9gCa09Y86gddzqvYEHCQKWJrP3QppG7CrMEDOKBO12j8bTq+a Mvkm2NFnt6eiJvUnx+U6DlW84AcFMAf+J8BdXXnE= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:14 +0300 Message-Id: <20220510115147.19360-18-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 17/50] staging: media: imx: imx7-media-csi: Don't set subdev group id X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The subdev group id isn't used by any of the remaining helpers used by this driver, don't set it. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 80d666416d47..bd1bdc09e701 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1749,13 +1749,6 @@ static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier); struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK]; - /* - * If the subdev is a video mux, it must be one of the CSI - * muxes. Mark it as such via its group id. - */ - if (sd->entity.function == MEDIA_ENT_F_VID_MUX) - sd->grp_id = IMX_MEDIA_GRP_ID_CSI_MUX; - csi->src_sd = sd; return v4l2_create_fwnode_links_to_pad(sd, sink, MEDIA_LNK_FL_ENABLED | From patchwork Tue May 10 11:51: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: 15858 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E57A8C326E for ; Tue, 10 May 2022 11:52:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 836C565647; Tue, 10 May 2022 13:52:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183541; bh=zHEDlecSQr99fSBCxfJcECaZP6Pkmnn8f2Cu8iYM8vQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=mmZlOs5YF2uf5+Xnlu83n6Dskptu8JWaJqu3PlGcnY4jek0IvX74DZxWhw/Kiu70R jbLGkdB97672bD9MN9JFWIYRWTcVbu9iS0+Lp+f8Si1LEH451dD+Lmc37Rgw/mz9ja UbuUmpMJJDeAWLew3y1wZOolbvLz4qTrIQMr7SPdO+T5fXgDWOnYlJthlbxYSWQk5e QK/oj87GlYhqsqWMtQCsQTNC/W2l0Qj4SROuH6tDcUoX05K5Jqqke/g6VMsR9nBmtW vey/nddQ9xDmXkVUCSOZZkqXq3uAu6sw3Pa413eKYrHZ6tfQjty9CU2Cgi9OuhNXv8 b78oi44kkqBIw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91B5165656 for ; Tue, 10 May 2022 13:52:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QtlbVbEn"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ABEF3B60; Tue, 10 May 2022 13:52:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183532; bh=zHEDlecSQr99fSBCxfJcECaZP6Pkmnn8f2Cu8iYM8vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QtlbVbEnLBNpuKXLVaCfGpaBO5WMQqdHC1QDnkhAijV2XdwF6RU6nqlXXiT+cP6C8 8L0nk2tnTNx4H+Idu2AtNMsAtvJS8VQf7o4tMi5L6yU5AAuAI+c8UXm7hB0BvyT/im yBo80C8NCtJt81Gmly1jFE1N+wQZVq6zikP8zPy0= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:15 +0300 Message-Id: <20220510115147.19360-19-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 18/50] staging: media: imx: imx7-media-csi: Import imx_media_dev_init() helper X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15859 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4F55AC326C for ; Tue, 10 May 2022 11:52:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C365A65680; Tue, 10 May 2022 13:52:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183543; bh=FKgYb9k2bmI3Tpr/aEtWZrnecOgXRroi+h/FsMN2epw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=uuRxqWTUUxMoOXa+dIhMZ4VnSaxCrqBC9q3Pmzehub3phhbRIGHuNVatnBKAQnSAD ahFaZtaeBjpQTvWTZ2xmVLDIw5yMF3i9bC2jLEkLlpa8ANbAQaZ4A2UkkMKSRhRoW9 JJ8MDxTSrDwDtmyaudNTYDiAm5h9QNaHMBczXZcUc3cG/f6xtIasWNfrgYk2h1d5We cKgRqoaz+srpTzyU/l//yPVyVoDAZEPCSoI2i/gXxdILLx4DHfi4DhX00o+I1TSYSX 8yQZ1gENU7k8ryhMMfPDSwQsL86B3GouKFo3BahSZbokSlZTnlI58liCsSwCElVe/Q 5r8OpDCWOn96w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B4DC6567B for ; Tue, 10 May 2022 13:52:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lCKXJM6F"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8ADC7BA9; Tue, 10 May 2022 13:52:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183533; bh=FKgYb9k2bmI3Tpr/aEtWZrnecOgXRroi+h/FsMN2epw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCKXJM6FDBtSzT2IACeI65tlA97JtXZOjUrbl+MiDSMx9kN8l1qsIMDP50EYtTGZU t4/2nBNPJ/XTtkKDZj1Yj3YplMAjWgWqj5TFjydMdUKgT4ZepKVnlqziRBkQsKY3/5 knoAiF//6phvHYSzS96At6XE3K46V0/HoCFaDDW0= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:16 +0300 Message-Id: <20220510115147.19360-20-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 19/50] staging: media: imx: imx7-media-csi: Embed imx_media_dev in imx7_csi X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There's no need anymore to allocate the imx_media_dev structure separately from imx7_csi. Embed it. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 47 +++++++++------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 8b19792adfc6..891e939d7ea5 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -183,7 +183,7 @@ struct imx7_csi { spinlock_t irqlock; /* Protects last_eof */ /* Media and V4L2 device */ - struct imx_media_dev *imxmd; + struct imx_media_dev imxmd; struct v4l2_async_notifier notifier; struct v4l2_subdev *src_sd; @@ -1081,7 +1081,7 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto return_bufs; } - ret = imx_media_pipeline_set_stream(csi->imxmd, &csi->sd.entity, true); + ret = imx_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, true); if (ret) { dev_err(csi->dev, "pipeline start failed with %d\n", ret); goto return_bufs; @@ -1107,7 +1107,7 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) unsigned long flags; int ret; - ret = imx_media_pipeline_set_stream(csi->imxmd, &csi->sd.entity, false); + ret = imx_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, false); if (ret) dev_warn(csi->dev, "pipeline stop failed with %d\n", ret); @@ -1268,7 +1268,7 @@ static int imx7_csi_video_register(struct imx7_csi *csi) } /* Add vdev to the video devices list. */ - imx_media_add_video_device(csi->imxmd, &csi->vdev); + imx_media_add_video_device(&csi->imxmd, &csi->vdev); return 0; } @@ -1685,11 +1685,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->imxmd.v4l2_dev); if (ret) goto err_unreg; - ret = media_device_register(&csi->imxmd->md); + ret = media_device_register(&csi->imxmd.md); if (ret) goto err_unreg; @@ -1759,7 +1759,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->imxmd.v4l2_dev); } static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { @@ -1793,7 +1793,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->imxmd.v4l2_dev, &csi->notifier); if (ret) return ret; @@ -1802,7 +1802,7 @@ 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; + struct imx_media_dev *imxmd = &csi->imxmd; v4l2_device_unregister(&imxmd->v4l2_dev); media_device_unregister(&imxmd->md); @@ -1813,20 +1813,16 @@ 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) +static int imx7_csi_media_dev_init(struct imx7_csi *csi) { - struct imx_media_dev *imxmd; + struct imx_media_dev *imxmd = &csi->imxmd; int ret; - imxmd = devm_kzalloc(dev, sizeof(*imxmd), GFP_KERNEL); - if (!imxmd) - return ERR_PTR(-ENOMEM); - - dev_set_drvdata(dev, imxmd); + dev_set_drvdata(csi->dev, imxmd); strscpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model)); imxmd->md.ops = &imx7_csi_media_ops; - imxmd->md.dev = dev; + imxmd->md.dev = csi->dev; mutex_init(&imxmd->mutex); @@ -1838,7 +1834,7 @@ static struct imx_media_dev *imx7_csi_media_dev_init(struct device *dev) media_device_init(&imxmd->md); - ret = v4l2_device_register(dev, &imxmd->v4l2_dev); + ret = v4l2_device_register(csi->dev, &imxmd->v4l2_dev); if (ret < 0) { v4l2_err(&imxmd->v4l2_dev, "Failed to register v4l2_device: %d\n", ret); @@ -1849,25 +1845,22 @@ static struct imx_media_dev *imx7_csi_media_dev_init(struct device *dev) v4l2_async_nf_init(&imxmd->notifier); - return imxmd; + return 0; cleanup: media_device_cleanup(&imxmd->md); - return ERR_PTR(ret); + return ret; } static int imx7_csi_media_init(struct imx7_csi *csi) { - struct imx_media_dev *imxmd; int i, ret; /* add media device */ - imxmd = imx7_csi_media_dev_init(csi->dev); - if (IS_ERR(imxmd)) - return PTR_ERR(imxmd); - - csi->imxmd = imxmd; + ret = imx7_csi_media_dev_init(csi); + if (ret) + return ret; v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); v4l2_set_subdevdata(&csi->sd, csi); @@ -1888,7 +1881,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->imxmd.v4l2_dev, &csi->sd); } static int imx7_csi_probe(struct platform_device *pdev) From patchwork Tue May 10 11:51: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: 15860 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id EAE3BC326F for ; Tue, 10 May 2022 11:52:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 897096568B; Tue, 10 May 2022 13:52:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183543; bh=gm/2LW6ZHCvoGWF4lJlzBcDie/aSGoep0fsUMokwzPE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OGQht47vvodgUcuhIGKmyFtE/XLRGGuOhFr+2jvPNjnaTN5yPIrKAV5dF5vr+Yl5u 0yWKnoYyg/smI6GZqZ9nkx9QeCHLcMvRAhaUY4ex99zmZkBqHoRBBkNRwFa/yTKb1i 1iyma+ivrAk7hPSLD8BFfPnonIMXrOSX4mcytUJ+bAbmgeWZpMF6MGSIxj+GVN8Sjh 9xpG27ffN7NcNYsO0p0cPJZee9lH2B93dBT6nbDt0XadF+ySuVf/Hh5+u9V8WlrVcJ Pw8lRTZKarb1PkID/kZlQoSHOqCTe0cNHWX8iP0Yh1NU3Izc0rj0fQGMJhbY285EDD elnsKgftljbgA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 437E26567E for ; Tue, 10 May 2022 13:52:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fbU1gbP1"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 61A12DFF; Tue, 10 May 2022 13:52:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183534; bh=gm/2LW6ZHCvoGWF4lJlzBcDie/aSGoep0fsUMokwzPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fbU1gbP1ASerflboHSYXv6MTUY+4aAS6XJROh7J0OcfBcu9KY1SQKG5oOA6LhEswc ZZ0JIgJPKeHZJvJqbpl+KY9nzxXBmNJ8QLGtFvKMRm+OkR9oKG9hXfCi/cdlM3p1SB fn5V1/tZZI2udwkrPWb74FvrCCW5hsKdTCxfNz6E= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:17 +0300 Message-Id: <20220510115147.19360-21-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 20/50] staging: media: imx: imx7-media-csi: Drop imx_media_add_video_device call X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15861 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 220D0C326D for ; Tue, 10 May 2022 11:52:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C6A5D65662; Tue, 10 May 2022 13:52:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183544; bh=R6JzINy4gD6TovfrdcP/5VdD1wSGdqHELXNnBkONj8c=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ZZLyRJ9KK45A+VjYMwz4KHW/RX08wJdzCeeL29H90sfIr6ZgMirMaF4wu3vrGIr6r +mXcd8xngbK6OfP1vyY155WtiVIp/cX9TVR7nyXCWBfHPdo1MICDDI3UGrtIrVCxiO rxXJ4LRD8SQGzIuwDcXVEwyVySsI8G4mlxbz5x4SBEiRlAhj0zOb5ImI2qYPNJyAj7 lj4DQEY1qnMK5DeTZpDkdiAVjJwrCgbbu+4DJQFDg+y3/wRLkBxs4lnAc3WAm/chFn iiyv9fLqxOdeWRAUuE2o9YVr6zSPVqO7K+P8adlbGggFidtfSuMlS5tcIWqhqUCF5k IMc5rX8ta63bQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 160D565657 for ; Tue, 10 May 2022 13:52:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jGakV36x"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3B984B9A; Tue, 10 May 2022 13:52:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183534; bh=R6JzINy4gD6TovfrdcP/5VdD1wSGdqHELXNnBkONj8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jGakV36xfs98cH7SaRJFTMQxLMeDKH1ao8k9mZ0ozBZlTYYnm3DKxtKhpnKdLIEeh Uz84ZYrzL/pr4QZFhI/FSz/nAdofxekGFuhH6pNR53d2Vfy1/1SJ4rG75Z2waJ96LT US5MVsKUpzEBY3d2pZ3i9vcHwR74JBkxTc4NAqE8= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:18 +0300 Message-Id: <20220510115147.19360-22-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 21/50] staging: media: imx: imx7-media-csi: Don't initialize unused fields X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The imx_media_dev structure contains three fields that are not used by this driver or any helper code that it calls. Don't initialize them. Signed-off-by: Laurent Pinchart --- 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 b6643952da25..7e932884fd02 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1821,8 +1821,6 @@ static int imx7_csi_media_dev_init(struct imx7_csi *csi) imxmd->md.ops = &imx7_csi_media_ops; imxmd->md.dev = csi->dev; - mutex_init(&imxmd->mutex); - imxmd->v4l2_dev.mdev = &imxmd->md; strscpy(imxmd->v4l2_dev.name, "imx-media", sizeof(imxmd->v4l2_dev.name)); @@ -1838,10 +1836,6 @@ static int imx7_csi_media_dev_init(struct imx7_csi *csi) goto cleanup; } - INIT_LIST_HEAD(&imxmd->vdev_list); - - v4l2_async_nf_init(&imxmd->notifier); - return 0; cleanup: From patchwork Tue May 10 11:51: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: 15862 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A87D8C3270 for ; Tue, 10 May 2022 11:52:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4FB6F65645; Tue, 10 May 2022 13:52:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183545; bh=wREWnlZORWJLC+76NQD4bNVhlmjZ7u0qButDdbEp29U=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Y53mRa0KFUYdClBuOLWt7loSdqVDFShtHWKTvVouCOa4wOavbOLwu5O3uFk1hL4QB Ise69n8Shkzd1YZ5pFT8Lp3VQHYA+QezzKngBGFq9CqP7+pdRB44GIrp8309hX1WYY pSi5TGjjvw0q1kC3u7k+JsXOggUNsByK1rQpiVutS+sNKEee7x2v3y1T6NQRasOCBy 9dZvvuJfb3+GIEm/A/KlM2o6GAFZjTiYjRP9ku0K+VYQzDhJvQt0iLYcjB/eLttxRm XGPOsgj/TcDVHQq5E0jVPPUsU9jW8az6rDdQsf1DkVsk//r87pV3pusgMczTE0ocuA Flhg8dLyDkMNg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E682765672 for ; Tue, 10 May 2022 13:52:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="osvrTBds"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 13268B60; Tue, 10 May 2022 13:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183535; bh=wREWnlZORWJLC+76NQD4bNVhlmjZ7u0qButDdbEp29U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=osvrTBdszMIDmR9J35xbtZAlOFtTUToEFSBpnuYV92LnNuoPCcT4Jlei6N4uU6llA hcxXW/yuAWqsOS+bOaKSEYaqlBWD4xNE7A0MCQG9/EJlFRseLSogBrbdaygxHmAiGD 8j/JObIRS7juxp6ZSpPmKHtSPrJ8TIlXcJYZeJ+g= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:19 +0300 Message-Id: <20220510115147.19360-23-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 22/50] staging: media: imx: imx7-media-csi: Inline imx_media_pipeline_pad() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15863 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 60FEAC3256 for ; Tue, 10 May 2022 11:52:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E356165695; Tue, 10 May 2022 13:52:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183546; bh=EgNZsoN/7OI10adZIP8tfznFAkRmxK+4iV9hb6MY8ns=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=MZBczqGr+JXV4vgIpTIczvIQkpjkMjR8VDoYdO5ynRLIUgX3dL94oORoCeaPoAJBZ fhMgwe6cq6Xj9zJLFXZY2y7wV6ydUOx+ac/brb2XdKCqVXtNCb598fomVW/LhyanSR cyYPk3/PYO5rzr0IT+o4whSQJlfvETGTHVnn8iP2qBL+7xIF4lkbZOoSsVnp29JARv ZC/M/LCtc2+kjeYcv51pI30qR/2rhQuH7N/D7f94tLdPJ/VsZFC6ijlsM6FSVBAAZS Om4pI/Am0mEInB25Lx2b2th/GLf5dGtWJh+sBUlifEGYWC+FGHpm8dWwQbOzcWe/bQ 7o18U7fExbSeQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C649465643 for ; Tue, 10 May 2022 13:52:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="B1QHcSLG"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DD12BBA9; Tue, 10 May 2022 13:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183536; bh=EgNZsoN/7OI10adZIP8tfznFAkRmxK+4iV9hb6MY8ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1QHcSLGTIrifMHH1MKn7ezgds0TLqjfWV+0lcrhMiAXqqqTam2AHoI/Xy25/wD6i WCttsfcWKk/wPgriccppZchQFHIwaSj27JqiLMpamb+yg4qJWawhXzbR7hjVoGe/Qp pi2ks4XGY2Tp9JepdPftqR5Oawbr2g9DKlT3IuFA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:20 +0300 Message-Id: <20220510115147.19360-24-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 23/50] staging: media: imx: imx7-media-csi: Import imx_media_pipeline_set_stream() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To prepare for code refactoring, copy the imx_media_pipeline_set_stream() helper used by this driver from imx-media-utils.c. Rename the function to avoid name clashes, no functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 40 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e1b494183ebc..1c8ee7c88f46 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1067,6 +1067,40 @@ 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) +{ + struct v4l2_subdev *sd; + 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); + if (ret) + goto out; + ret = v4l2_subdev_call(sd, video, s_stream, 1); + if (ret) + __media_pipeline_stop(entity); + } else { + v4l2_subdev_call(sd, video, s_stream, 0); + if (entity->pipe) + __media_pipeline_stop(entity); + } + +out: + mutex_unlock(&imxmd->md.graph_mutex); + return ret; +} + static int imx7_csi_video_start_streaming(struct vb2_queue *vq, unsigned int count) { @@ -1081,7 +1115,8 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto return_bufs; } - ret = imx_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, true); + ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, + true); if (ret) { dev_err(csi->dev, "pipeline start failed with %d\n", ret); goto return_bufs; @@ -1107,7 +1142,8 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) unsigned long flags; int ret; - ret = imx_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, false); + ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, + false); if (ret) dev_warn(csi->dev, "pipeline stop failed with %d\n", ret); From patchwork Tue May 10 11:51: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: 15864 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 12DBCC3271 for ; Tue, 10 May 2022 11:52:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B495F65688; Tue, 10 May 2022 13:52:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183546; bh=D5kh5m5dVFSdvWBJedF03x3RCtpo2Vy/S76Gby0LnNI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=GsEM763CxqRQrx8nRTSW9eCSFCYo29t5joUkR4Z6WQ/vGu0PBqwO8WRZmmhdwn9y+ zyUR1Uzqc0tOjr+kbKHrFDjT1whftdUOI9IBD81GCL1oFEDGY71rWI28W2msyq0MVI CstI5YDCz73+9KqI+VhTF5rnD848qf9wHfXKAWsCgrThNmdn8Fu9OIChw/F+b9NLnv jrtXz8XuxBBK08jy4h3F1iCmSP9LBjYpdYbywyCasS67nfMzL+sKVIzcMq1HwoWu6O OmrlBs4MG8EsPfD/hm9BFRN4t80ppoyKUz9uTHz9NZRQfKfOO54NAFdNfToV+mIS3S bRrsxBKra7Ppw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 960ED6564F for ; Tue, 10 May 2022 13:52:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sU2hVazh"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BAD9A824; Tue, 10 May 2022 13:52:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183537; bh=D5kh5m5dVFSdvWBJedF03x3RCtpo2Vy/S76Gby0LnNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sU2hVazhFyW3QXWodhFCns0eMkI5EHdNotatgJQpzKpgTFdJGFIGHJUAk6OXzghXq lTVQsfJcy3UzmEqltVBHrLdLuXlb1BMxM3zwRKo3eiGPau1tJGeb4EUAhW4Sutmr6M raOU8MAVSzmbjSUgjpo7xqQs0eiMOx7YkITCF1oQ= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:21 +0300 Message-Id: <20220510115147.19360-25-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 24/50] staging: media: imx: imx7-media-csi: Avoid unnecessary casts X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15865 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B522EC3272 for ; Tue, 10 May 2022 11:52:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4343165675; Tue, 10 May 2022 13:52:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183547; bh=FoyLYFnys/3AHuA1i8+u18sJF+/odDK5/oJembX9Pbs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=A8hgDSle0Ao2RCgDpGB9m4UO0xVcuNIWAgvWpvSxD7cVfdpmOwxIGJ4eHK/R7qt7I 4auceCHsGYQxfhRKeleYq2xKEakcQwBL09s3Ru+Ls6nly8ZvxFTCSHbsyDP84qonis AgWWUxLKqdiO5+RlB6Kavcpi66VRgsHjtMsPhdpWHJdRbjvHWSu+ARkz+ehU4cjSnf NyNFILzrRTF/3pBu3COzNP78JEaIf6r08+2JIiIwQApJrm/1TPPplCt4b0IjdNTSHm cSAHmX879v/7o9w4R5/6PTk+81a5kY+iwSvPe8tWk76kIWdEjRag9HT3uB8MS1L17U eewcFAyeNXN0A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7389C65680 for ; Tue, 10 May 2022 13:52:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ag6xtEXP"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 91FFEB9A; Tue, 10 May 2022 13:52:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183538; bh=FoyLYFnys/3AHuA1i8+u18sJF+/odDK5/oJembX9Pbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ag6xtEXPE/rme2wp/0rCz8XE142LVeBm3N+8xqV03LnLPBiOw0zskdyQPY9RKxWsh VreiwKk5bo3WpYzBWhXKHSBC73n3H06rho57V+tSyK8rcrcUppggC8qDJHHtlXeufJ yuO1a90H8bbhKVw8PIr5sLYzojfcaDFzNASzh4RU= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:22 +0300 Message-Id: <20220510115147.19360-26-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 25/50] staging: media: imx: imx7-media-csi: Inline pipeline start/stop X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The imx7_csi_media_pipeline_set_stream() function has separate branches for the start and stop paths, surrounded by mutex lock/unlock. That is very little shared code, inline the locking and corresponding branch in each of the two callers. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 58 ++++++++-------------- 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 8600fc4d6be2..44c19c73da97 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1067,31 +1067,6 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) return 0; } -static int imx7_csi_media_pipeline_set_stream(struct imx7_csi *csi, bool on) -{ - struct imx_media_dev *imxmd = &csi->imxmd; - int ret = 0; - - mutex_lock(&imxmd->md.graph_mutex); - - if (on) { - ret = __media_pipeline_start(&csi->sd.entity, &imxmd->pipe); - if (ret) - goto out; - ret = v4l2_subdev_call(&csi->sd, video, s_stream, 1); - if (ret) - __media_pipeline_stop(&csi->sd.entity); - } else { - v4l2_subdev_call(&csi->sd, video, s_stream, 0); - if (csi->sd.entity.pipe) - __media_pipeline_stop(&csi->sd.entity); - } - -out: - mutex_unlock(&imxmd->md.graph_mutex); - return ret; -} - static int imx7_csi_video_start_streaming(struct vb2_queue *vq, unsigned int count) { @@ -1103,18 +1078,29 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, ret = imx7_csi_video_validate_fmt(csi); if (ret) { dev_err(csi->dev, "capture format not valid\n"); - goto return_bufs; + goto err_buffers; } - 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; - } + mutex_lock(&csi->imxmd.md.graph_mutex); + + ret = __media_pipeline_start(&csi->sd.entity, &csi->imxmd.pipe); + if (ret) + goto err_unlock; + + ret = v4l2_subdev_call(&csi->sd, video, s_stream, 1); + if (ret) + goto err_stop; + + mutex_unlock(&csi->imxmd.md.graph_mutex); return 0; -return_bufs: +err_stop: + __media_pipeline_stop(&csi->sd.entity); +err_unlock: + mutex_unlock(&csi->imxmd.md.graph_mutex); + dev_err(csi->dev, "pipeline start failed with %d\n", ret); +err_buffers: spin_lock_irqsave(&csi->q_lock, flags); list_for_each_entry_safe(buf, tmp, &csi->ready_q, list) { list_del(&buf->list); @@ -1130,11 +1116,11 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) struct imx_media_buffer *frame; struct imx_media_buffer *tmp; unsigned long flags; - int ret; - ret = imx7_csi_media_pipeline_set_stream(csi, false); - if (ret) - dev_warn(csi->dev, "pipeline stop failed with %d\n", ret); + mutex_lock(&csi->imxmd.md.graph_mutex); + v4l2_subdev_call(&csi->sd, video, s_stream, 0); + __media_pipeline_stop(&csi->sd.entity); + mutex_unlock(&csi->imxmd.md.graph_mutex); /* release all active buffers */ spin_lock_irqsave(&csi->q_lock, flags); From patchwork Tue May 10 11:51: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: 15866 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9597DC326E for ; Tue, 10 May 2022 11:52:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44B4E65699; Tue, 10 May 2022 13:52:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183548; bh=HbKz4y1G2znjiWeWjvthgfOCUuheE0gfBZq5dYC849s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=CUeDBr4Q7Hkmg/130QevGGl0EGG2owl9FfhWNhWde0MhdMYGB6Kh3YccbMUffIONS eezQhhmKO+4ZSKp+iDa7x3Uxyc9uD1zLl2VCownQ3pLtqB+g0VXr3USbdUxATKvx29 6XHBUwmORx778QDJ+74akOIKnINHEbrCzeaFZ920s6jDt0QKhuf3IoUzsTCZtaNnfz ntsNaG7S4b8RvgQvKbfuJkCmNTSjpBJFy9jmegxqMyul1YKzkT00ydj29kwNsrFq9L teoFc0WeQp1m6EoRJJRnp0FHk9JPydKMho6wYfU/Juhen2qFlSF9ldSUbaFC7q/nC2 3WhCJ9HzRAQKQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E9A165685 for ; Tue, 10 May 2022 13:52:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Bkbt9/eY"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 70FBFB60; Tue, 10 May 2022 13:52:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183539; bh=HbKz4y1G2znjiWeWjvthgfOCUuheE0gfBZq5dYC849s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bkbt9/eY+VsGZl5AkUCIcvFUJS5KoGs4y+nWr95YKvbBbu5Z3OvuI4dDN5C/nM6iF erQVQCcb+3zVIa4ziqXAxvYEv4WHp6OtS8TcvOBf1t2OjYCOWcymN+fvvBsx447D4T ZsDAKJ7VU2ZhkPyg0TBuGwbJA7V0YBIOoHs+TGBg= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:23 +0300 Message-Id: <20220510115147.19360-27-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 26/50] staging: media: imx: imx7-media-csi: Fold imx_media_dev into imx7_csi X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15867 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D7940C326C for ; Tue, 10 May 2022 11:52:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6CDA36565D; Tue, 10 May 2022 13:52:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183549; bh=uhFYqlxRyJRQAdfliGJQT40i74qJsxgVla750D6q6kc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=v8Ke3pDW4CaLp68OR8QIspc6CaRx1zUKrRcTnEeoUfvtd2ttAqpPZTUFxeKB5sCyX hcrGKToBDm0lSaXGawdTWEOqK3FCeqOsSq4Il4kjiap02oKigVpPSlo82/ihr13C0J 4Dpay1wOTMyJlQGq1VGhmkK9sj60f6/+Y652Fbl78Rwaf8YHDeN7EG5G6cXaVauKWo d3sabmwTEe78BVpCE8XuDsPMPTUdBErFIQXtY/SGwQ4GHzvwAviXldMjZF5nT/p/mE o0rB/6JwUufRFwvwUQ+U+Gm6KIgHJKf7wn7E5kw9NtJR+5F2MZXvLMmHriAAtfAtO/ wb46FWjZOmosw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 22C1B6566A for ; Tue, 10 May 2022 13:52:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eGGHrcyX"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 468A6D18; Tue, 10 May 2022 13:52:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183539; bh=uhFYqlxRyJRQAdfliGJQT40i74qJsxgVla750D6q6kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGGHrcyXHqByGfSrxUtQoweQVkNfMZBpUtmRngpTySGnhKo8HKKCsr6FziL5Al2iY O9mTi8BQkhmqDA2qkpaoxkw2r6uiTE3fvRyGmmvK+AMLbC16rVasVJA5Sdn+jHhA2j 22pctdjDffwm5+ddD/FUw+NTxyE4kFCqM3Jl7yGc= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:24 +0300 Message-Id: <20220510115147.19360-28-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 27/50] staging: media: imx: imx7-media-csi: Decouple from imx_media_buffer X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Decouple from the imx_media_buffer structure defined in shared helpers by duplicating it in the imx7-media-csi driver. No functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 41 ++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index b116f6ab96f0..bd1bc3fada2e 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -171,6 +171,19 @@ enum imx_csi_model { IMX7_CSI_IMX8MQ, }; +struct imx7_csi_vb2_buffer { + struct vb2_v4l2_buffer vbuf; + struct list_head list; +}; + +static inline struct imx7_csi_vb2_buffer * +to_imx7_csi_vb2_buffer(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + + return container_of(vbuf, struct imx7_csi_vb2_buffer, vbuf); +} + struct imx7_csi { struct device *dev; @@ -209,7 +222,7 @@ struct imx7_csi { spinlock_t q_lock; /* Protect ready_q */ /* Buffers and streaming state */ - struct imx_media_buffer *active_vb2_buf[2]; + struct imx7_csi_vb2_buffer *active_vb2_buf[2]; struct imx_media_dma_buf underrun_buf; bool is_streaming; @@ -355,11 +368,11 @@ 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_csi_video_next_buf(struct imx7_csi *csi); +static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi); static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) { - struct imx_media_buffer *buf; + struct imx7_csi_vb2_buffer *buf; struct vb2_buffer *vb2_buf; dma_addr_t phys[2]; int i; @@ -382,7 +395,7 @@ static void imx7_csi_setup_vb2_buf(struct imx7_csi *csi) static void imx7_csi_dma_unsetup_vb2_buf(struct imx7_csi *csi, enum vb2_buffer_state return_status) { - struct imx_media_buffer *buf; + struct imx7_csi_vb2_buffer *buf; int i; /* return any remaining active frames with return_status */ @@ -652,7 +665,7 @@ 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 imx_media_buffer *done, *next; + struct imx7_csi_vb2_buffer *done, *next; struct vb2_buffer *vb; dma_addr_t phys; @@ -997,7 +1010,7 @@ static int imx7_csi_video_queue_setup(struct vb2_queue *vq, static int imx7_csi_video_buf_init(struct vb2_buffer *vb) { - struct imx_media_buffer *buf = to_imx_media_vb(vb); + struct imx7_csi_vb2_buffer *buf = to_imx7_csi_vb2_buffer(vb); INIT_LIST_HEAD(&buf->list); @@ -1024,7 +1037,7 @@ static int imx7_csi_video_buf_prepare(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); + struct imx7_csi_vb2_buffer *buf = to_imx7_csi_vb2_buffer(vb); unsigned long flags; spin_lock_irqsave(&csi->q_lock, flags); @@ -1073,7 +1086,7 @@ 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; + struct imx7_csi_vb2_buffer *buf, *tmp; unsigned long flags; int ret; @@ -1115,8 +1128,8 @@ static int imx7_csi_video_start_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; - struct imx_media_buffer *tmp; + struct imx7_csi_vb2_buffer *frame; + struct imx7_csi_vb2_buffer *tmp; unsigned long flags; mutex_lock(&csi->mdev.graph_mutex); @@ -1205,16 +1218,16 @@ static const struct v4l2_file_operations imx7_csi_video_fops = { * Video Capture Device - Init & Cleanup */ -static struct imx_media_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi) +static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi) { - struct imx_media_buffer *buf = NULL; + struct imx7_csi_vb2_buffer *buf = NULL; unsigned long flags; spin_lock_irqsave(&csi->q_lock, flags); /* get next queued buffer */ if (!list_empty(&csi->ready_q)) { - buf = list_entry(csi->ready_q.next, struct imx_media_buffer, + buf = list_entry(csi->ready_q.next, struct imx7_csi_vb2_buffer, list); list_del(&buf->list); } @@ -1336,7 +1349,7 @@ static int imx7_csi_video_init(struct imx7_csi *csi) vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vq->io_modes = VB2_MMAP | VB2_DMABUF; vq->drv_priv = csi; - vq->buf_struct_size = sizeof(struct imx_media_buffer); + vq->buf_struct_size = sizeof(struct imx7_csi_vb2_buffer); vq->ops = &imx7_csi_video_qops; vq->mem_ops = &vb2_dma_contig_memops; vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; From patchwork Tue May 10 11:51: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: 15868 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5F88DC0F2A for ; Tue, 10 May 2022 11:52:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0216865674; Tue, 10 May 2022 13:52:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183550; bh=dOIuG8WAkRVjS+sir4i0rbt/c2SmHOREKpWNSEMUE7c=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=v04NagGaRl6AWjuinniFfcsulGvgMdhiJjLjGykd6NOuJyBHMrQ66zMW+kzH36sdy TKKqEILfRTq7EleAVj9LDlwXsBf7zhMGq0Z9/Ep4y5RqeO3lNqEfE2xOLgtkr0EBKW 8uc8ydE7cHT+o3gqPynY/jio7fuQ6eFykDWuf6SF7ROgMQp1Xud/ouDaH4jsWALiXD QKC+pTGR+pxH8vqEQI4jjT96rnPn+0ob+y4aF84iVrVi0xGYlILf9UfZ49ViD7Et8n v2TYHJeqjHatwBTpPfAzOzurujvwNFqhVjjzUD1SY8zJwffKwluRQ0OY+rzWytvo79 xyIn+wE07C3Yw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA81565681 for ; Tue, 10 May 2022 13:52:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oTNURRoS"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1F68F824; Tue, 10 May 2022 13:52:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183540; bh=dOIuG8WAkRVjS+sir4i0rbt/c2SmHOREKpWNSEMUE7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oTNURRoSA+n9khUkjQIWmEhoAUIdWm9ckh5iKcqA4EKMiZfL3TBRkeFjPNbrTOdcJ EwdAhiVe75GHulJUMwrnokAm4h9hz9Jse8FUc+Tz3YSZUDFYukpONpZ03vlE5uZbRQ quR358hbpsnnf3MjO1qzazD9HMIhpgBuJKVY8C4U= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:25 +0300 Message-Id: <20220510115147.19360-29-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 28/50] staging: media: imx: imx7-media-csi: Fold imx_media_video_dev into imx7_csi X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15869 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 28715C326F for ; Tue, 10 May 2022 11:52:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B00BE6566E; Tue, 10 May 2022 13:52:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183550; bh=Q5pLB1e2XYYIIIEjFrPhWLsfrzF2a4m2XFlEvoFIpmM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=RAmsnwQUB63VnBQHThFaFfDggTfX2h5xxZ0mHv5JRfyG4iAL92lS4JNX6ARaN9Ixz wBQbTYwr2MJzZmaQwH8lUyW1S8HLDW4eQhsl9re+sUzgcdwNJV95ey6QyVC8JTvsvm VfJkHpwtpn6xoHET9//3lV66xIeMhCqwsz9tkH+dONu+VjlvXf2twA+O6B9sITcd3+ KCHbD3s/erj18+HIEN53TtHdLghDqjgzavFG6BbUXo5LeZ3PzbH3QZk9SracSDaNk3 sabNsy/oRUDgFjMNLdr63B+U6NuSrWXn61v+44EhgDcqjsWAJ3tr2ZOlMcJCX4ASyN bLjsBazbi5Pyw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D2C116566E for ; Tue, 10 May 2022 13:52:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="A1mh1onn"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EE49AB9A; Tue, 10 May 2022 13:52:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183541; bh=Q5pLB1e2XYYIIIEjFrPhWLsfrzF2a4m2XFlEvoFIpmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1mh1onnGcsAoADCaWcs0nvAvwPk6hFy77hJpkoRlVbpIXo7y5dP4e5d6vcaE7Q39 c+aPZSd3sdKrFo8MnY2PO7DPThNLMt8P0jMXjn9CNgFqiEo8vNyuxgzBH+hOp+n18C ApkdY1zvp0b7UkrzsBqL9a2GNpDGfXn1lNVqRxdg= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:26 +0300 Message-Id: <20220510115147.19360-30-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 29/50] staging: media: imx: imx7-media-csi: Store imx7_csi in drv data X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace the subdev pointer stored in platform drv data with the imx7_csi pointer. Drop a now redundant dev_set_drvdata() call. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 14683a15e003..5a5157d8b27b 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1842,8 +1842,6 @@ static int imx7_csi_media_dev_init(struct imx7_csi *csi) { int ret; - dev_set_drvdata(csi->dev, csi); - strscpy(csi->mdev.model, "imx-media", sizeof(csi->mdev.model)); csi->mdev.ops = &imx7_csi_media_ops; csi->mdev.dev = csi->dev; @@ -1913,7 +1911,7 @@ static int imx7_csi_probe(struct platform_device *pdev) return -ENOMEM; csi->dev = dev; - platform_set_drvdata(pdev, &csi->sd); + platform_set_drvdata(pdev, csi); spin_lock_init(&csi->irqlock); mutex_init(&csi->lock); @@ -1977,14 +1975,13 @@ static int imx7_csi_probe(struct platform_device *pdev) static int imx7_csi_remove(struct platform_device *pdev) { - struct v4l2_subdev *sd = platform_get_drvdata(pdev); - struct imx7_csi *csi = v4l2_get_subdevdata(sd); + struct imx7_csi *csi = platform_get_drvdata(pdev); imx7_csi_media_cleanup(csi); v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); - v4l2_async_unregister_subdev(sd); + v4l2_async_unregister_subdev(&csi->sd); mutex_destroy(&csi->lock); From patchwork Tue May 10 11:51: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: 15870 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id EBE6AC3274 for ; Tue, 10 May 2022 11:52:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A1E4E65697; Tue, 10 May 2022 13:52:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183551; bh=ugFiXGKljdu4sLM/6x0wIcV2N3AEtbDAbQDr0izYfQg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Ps11ts0RhJS0FtBu1jV8J8uVsaeUshto90hViFqmZ8GWMHdZOgqmVPTNMuYYu3I38 tcD+2DW9s0YdJMBFX7tqenwtkzPpatUOewV1QKTfeQ0w+C74Aeyvbl8HkN2gZ20pZa qVYff8AL3KTmNdOro82pRGxLIO64RSYoEtddcCkDux4elqanAQ1yn8pqV1y6YLuL2o 12KPsVTURC7lPTbkhDx1lT0Qbli32S0rCszaVkng6iaCzC4ytmP7CULAjIWPicFDF8 RwEvLb2EeQ2WQCf++9S21z7/Z3xjjjKBLnpmXfGm+NH8uBKi0ZtExAm6DPgjKBdSZg 8P5MYd0rJSpig== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BB8DE65675 for ; Tue, 10 May 2022 13:52:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hOR3WCFM"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE45FDFF; Tue, 10 May 2022 13:52:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183542; bh=ugFiXGKljdu4sLM/6x0wIcV2N3AEtbDAbQDr0izYfQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hOR3WCFMQwJ+Scg0B0/2RwsnaSJD0h5a7JdgHtij4GqxvGcm4TT22gf+dRi9e+nOM HaSLyY1wXM2JCt6R/RI+i2xY6uoURmG/qXnPLeAnm+idci+3i8xgTA/YBb8gj+dZ+y 6TttvRhAxTgqLHtJ7dL3eA0oJ7N7D+M0fBc0vvB4= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:27 +0300 Message-Id: <20220510115147.19360-31-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 30/50] staging: media: imx: imx7-media-csi: Decouple from imx_media_dma_buf X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Decouple from the imx_media_dma_buf structure defined in shared helpers by duplicating it in the imx7-media-csi driver, along with the two small alloc and free functions. No functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 5a5157d8b27b..05907d6257a8 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -184,6 +184,12 @@ to_imx7_csi_vb2_buffer(struct vb2_buffer *vb) return container_of(vbuf, struct imx7_csi_vb2_buffer, vbuf); } +struct imx7_csi_dma_buf { + void *virt; + dma_addr_t phys; + unsigned long len; +}; + struct imx7_csi { struct device *dev; @@ -227,7 +233,7 @@ struct imx7_csi { /* Buffers and streaming state */ struct imx7_csi_vb2_buffer *active_vb2_buf[2]; - struct imx_media_dma_buf underrun_buf; + struct imx7_csi_dma_buf underrun_buf; bool is_streaming; int buf_num; @@ -415,12 +421,38 @@ static void imx7_csi_dma_unsetup_vb2_buf(struct imx7_csi *csi, } } +static void imx7_csi_free_dma_buf(struct imx7_csi *csi, + struct imx7_csi_dma_buf *buf) +{ + if (buf->virt) + dma_free_coherent(csi->dev, buf->len, buf->virt, buf->phys); + + buf->virt = NULL; + buf->phys = 0; +} + +static int imx7_csi_alloc_dma_buf(struct imx7_csi *csi, + struct imx7_csi_dma_buf *buf, int size) +{ + imx7_csi_free_dma_buf(csi, buf); + + 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__); + return -ENOMEM; + } + + return 0; +} + static int imx7_csi_dma_setup(struct imx7_csi *csi) { int ret; - ret = imx_media_alloc_dma_buf(csi->dev, &csi->underrun_buf, - csi->vdev_fmt.sizeimage); + ret = imx7_csi_alloc_dma_buf(csi, &csi->underrun_buf, + csi->vdev_fmt.sizeimage); if (ret < 0) { v4l2_warn(&csi->sd, "consider increasing the CMA area\n"); return ret; @@ -439,7 +471,7 @@ static void imx7_csi_dma_cleanup(struct imx7_csi *csi, enum vb2_buffer_state return_status) { imx7_csi_dma_unsetup_vb2_buf(csi, return_status); - imx_media_free_dma_buf(csi->dev, &csi->underrun_buf); + imx7_csi_free_dma_buf(csi, &csi->underrun_buf); } static void imx7_csi_dma_stop(struct imx7_csi *csi) From patchwork Tue May 10 11:51:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15871 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0E933C326D for ; Tue, 10 May 2022 11:52:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8816A65677; Tue, 10 May 2022 13:52:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183552; bh=H0UZuPYvqIKi1smJ8Qfmjedgtg9V7e3LUJmJMM+87hQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dSvk62dM5eAyeWU78C7D2ZoXEdVUU51X6FEQZylG2mGDxYnaKzE+smWhVA7E5PJ2G 84Vj/78PsHXLqM85yJGSasaQpUIdkqlqmgCHUNgyjCfqWnsgPyExfXEFE76puBCkBv vaBvrqiq0Ob+miiVPHksPVBI5JsqGlgxeeQRtO2shK6wUcFNnydh5FCkgl0/zA5jOK 2aRwFxudoEvH+fUcAVyMbPKXqmkKygIW68RAWCvJzYT3J1fsoteWzje4F/ly8VlouI 4Iklp12WiGrpRR+m5EZyM1OqTp1JLkRoZVS6TaWA75Y7DlQ7j3WpUJ5GuW0MB0METl 0BC5mY0tJM1wA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 877086568E for ; Tue, 10 May 2022 13:52:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uiiYCBR7"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ACC80BA9; Tue, 10 May 2022 13:52:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183543; bh=H0UZuPYvqIKi1smJ8Qfmjedgtg9V7e3LUJmJMM+87hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiiYCBR72hJmf2LK4FVCKSE0c9M9c4JcH8Qj8LEzhT5Y/s7KGaTib3WDht/mGrIK5 xGUARJFICnaHP6OpemrRw4bEPdMoN8W2fM3DuJwT8wgpNOujhjmyGAGocBrc06Skee LgwpPiWOZrUJhJb/lmZ0YPXnJBKlYjL9qbiLbBMo= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:28 +0300 Message-Id: <20220510115147.19360-32-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 31/50] staging: media: imx: imx7-media-csi: Decouple from shared macros X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51: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: 15872 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D78FCC3275 for ; Tue, 10 May 2022 11:52:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77E416569F; Tue, 10 May 2022 13:52:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183553; bh=uk7QSLv2qM0UlTKkUT4qWhdMuv+9FNoxBd4UtAMVX14=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=cOjhzEKKS9csVH2hEj0RXHYCvTOpGZIxcvGeqbchqmYNcRRWX4SXrk/32+p3H4HSd VhSI0zaPyeR85E2ufYISOToNmZWak/D8V4yoMxHxVSwAT4pKGvVHT5HBpCBupjzDkn O/C5sqr0ENa8COVfCEOkmtO7SsrYxUUkxk8r3VA7FUXy18tTjFFys9jOd8esrg3Vc7 aPrb6FMCjktD4JnrT15k/Qa1/sMFsbHbxYds7jE12eST+HWp5F2a7HxMZO01HI7oV2 4P9nMRB3LwXPK6Yyc0i9UqmvZkccopGDuNLLhBdiESmgAl0iUPglocbuYK9PA4et/A Gga8Snm7WASsA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 709AB6566A for ; Tue, 10 May 2022 13:52:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lnWZYK7G"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 81A66D18; Tue, 10 May 2022 13:52:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183544; bh=uk7QSLv2qM0UlTKkUT4qWhdMuv+9FNoxBd4UtAMVX14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnWZYK7GsmbTF8kuGsPZhrCgE2T+1B5Rkf6ianutoom90chzgz+Pb0vYKFIkFZ6gD eKpSvL1ueUVepgB+HNZm1XEScL9Jiof4U6Rvr7GjwNRE7RLMJt2/clkZHhvH3VLElS PDfE481GeXeukVWapCT7U2gWQXwPhvSwq8fr2IEA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:29 +0300 Message-Id: <20220510115147.19360-33-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 32/50] staging: media: imx: imx7-media-csi: Drop error message on alloc failure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15873 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 72007C3276 for ; Tue, 10 May 2022 11:52:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1B852656A7; Tue, 10 May 2022 13:52:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183554; bh=OjRGMuHjDHAG1XZV5zDaeOrnmZ9X52Jw4ZXN1k9DDgM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=BF8ioNeWzsNYLo8/Hnq7Y4dbF3ndUnjPM47SaZnt46jET6eQhgkzV4X7HYHcAsW0V iNcXEE4XviNJRRGh54mN/t7NnkCNJ6j0JNwu32wktSpNyGwJwYWb7INkR+ZO0SpvX+ 8Mzbaa9QwA8lsISKN26NY60DzLDzv9uUbL950vXk8znb6EZPGf2Mws80//RLiJiMnu uF0aLuSnMThUEx+JWdYH0Dmdt+ZFjEhkYxw08ECq9gSOQFTrSlA9npaAs0rdYbhzod tQ4TbYgTiHzZCPA1P/9Sg65ItWKnOQd+vqZL2DbDGw/sJ/9wlrwQ6NAfeYejh0P4Dk YzypcptPaziaw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4474B65672 for ; Tue, 10 May 2022 13:52:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vM9e1gqy"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 61C09B9A; Tue, 10 May 2022 13:52:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183545; bh=OjRGMuHjDHAG1XZV5zDaeOrnmZ9X52Jw4ZXN1k9DDgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vM9e1gqyd9pgXfgNSkNPRgZlfKAMwAp8lHSOuJv2lTyfjv3/5N9pJNR/CFDs3Mdhq 6zYDpYkosqllQI+rrrfNO5RBoLPoJsb9SPVsaD2eKE9E6b++YXVQoULIHrD59gNtpC k8RB7qUfrZrDDaxyDF+whBVpooPI/b+TlrjNLxk8= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:30 +0300 Message-Id: <20220510115147.19360-34-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 33/50] staging: media: imx: imx7-media-csi: Import format helpers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To prepare for code refactoring, copy the format helpers used by this driver from imx-media-utils.c. Rename structures and functions to avoid name clashes, no functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 660 +++++++++++++++++++-- 1 file changed, 615 insertions(+), 45 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e5dc9525fa52..42f1485b3550 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -174,6 +174,23 @@ enum imx_csi_model { IMX7_CSI_IMX8MQ, }; +struct imx7_csi_pixfmt { + /* the in-memory FourCC pixel format */ + u32 fourcc; + /* + * the set of equivalent media bus codes for the fourcc. + * NOTE! codes pointer is NULL for in-memory-only formats. + */ + const u32 *codes; + int bpp; /* total bpp */ + /* cycles per pixel for generic (bayer) formats for the parallel bus */ + int cycles; + enum ipu_color_space cs; + 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 { struct vb2_v4l2_buffer vbuf; struct list_head list; @@ -218,14 +235,14 @@ struct imx7_csi { 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]; + const struct imx7_csi_pixfmt *cc[IMX7_CSI_PADS_NUM]; /* 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; + const struct imx7_csi_pixfmt *vdev_cc; struct v4l2_rect vdev_compose; /* The compose rectangle */ struct mutex vdev_mutex; /* Protect vdev operations */ @@ -784,30 +801,518 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) return IRQ_HANDLED; } +/* ----------------------------------------------------------------------------- + * Format Helpers + */ + +#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_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 + | IMX7_CSI_PIXFMT_SEL_RGB + | IMX7_CSI_PIXFMT_SEL_BAYER, +}; + +/* + * List of supported pixel formats for the subdevs. + */ +static const struct imx7_csi_pixfmt pixel_formats[] = { + /*** YUV formats start here ***/ + { + .fourcc = V4L2_PIX_FMT_UYVY, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_UYVY8_2X8, + MEDIA_BUS_FMT_UYVY8_1X16 + ), + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_YUYV, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_YUYV8_2X8, + MEDIA_BUS_FMT_YUYV8_1X16 + ), + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_YUV420, + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 12, + .planar = true, + }, { + .fourcc = V4L2_PIX_FMT_YVU420, + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 12, + .planar = true, + }, { + .fourcc = V4L2_PIX_FMT_YUV422P, + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 16, + .planar = true, + }, { + .fourcc = V4L2_PIX_FMT_NV12, + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 12, + .planar = true, + }, { + .fourcc = V4L2_PIX_FMT_NV16, + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 16, + .planar = true, + }, { + .fourcc = V4L2_PIX_FMT_YUV32, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_AYUV8_1X32), + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 32, + .ipufmt = true, + }, + /*** RGB formats start here ***/ + { + .fourcc = V4L2_PIX_FMT_RGB565, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_RGB565_2X8_LE), + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .cycles = 2, + }, { + .fourcc = V4L2_PIX_FMT_RGB24, + .codes = IMX_BUS_FMTS( + 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, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR16, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_SBGGR10_1X10, + MEDIA_BUS_FMT_SBGGR12_1X12, + MEDIA_BUS_FMT_SBGGR14_1X14, + MEDIA_BUS_FMT_SBGGR16_1X16 + ), + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG16, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_SGBRG10_1X10, + MEDIA_BUS_FMT_SGBRG12_1X12, + MEDIA_BUS_FMT_SGBRG14_1X14, + MEDIA_BUS_FMT_SGBRG16_1X16 + ), + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG16, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_SGRBG10_1X10, + MEDIA_BUS_FMT_SGRBG12_1X12, + MEDIA_BUS_FMT_SGRBG14_1X14, + MEDIA_BUS_FMT_SGRBG16_1X16 + ), + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB16, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_SRGGB10_1X10, + MEDIA_BUS_FMT_SRGGB12_1X12, + MEDIA_BUS_FMT_SRGGB14_1X14, + MEDIA_BUS_FMT_SRGGB16_1X16 + ), + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 16, + .bayer = true, + }, { + .fourcc = V4L2_PIX_FMT_GREY, + .codes = IMX_BUS_FMTS( + MEDIA_BUS_FMT_Y8_1X8, + 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, + }, +}; + +/* + * 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. + */ +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->cs == IPUV3_COLORSPACE_YUV) ? + IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + + if ((fmt_sel & sel) && fmt->fourcc == fourcc) + return fmt; + } + + return NULL; +} + +/* + * 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. + */ +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->cs == IPUV3_COLORSPACE_YUV) ? + IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + + if (!(fmt_sel & sel) || !fmt->codes) + continue; + + for (j = 0; fmt->codes[j]; j++) { + if (code == fmt->codes[j]) + return fmt; + } + } + + 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 + * 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. + * @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) +{ + 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->cs == IPUV3_COLORSPACE_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 + * 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 + * the search criteria at the requested match 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) +{ + 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->cs == IPUV3_COLORSPACE_YUV) ? + IMX7_CSI_PIXFMT_SEL_YUV : IMX7_CSI_PIXFMT_SEL_RGB); + + if (!(fmt_sel & sel) || !fmt->codes) + continue; + + for (j = 0; fmt->codes[j]; j++) { + if (index == 0) { + *code = fmt->codes[j]; + return 0; + } + + index--; + } + } + + return -EINVAL; +} + +static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, + u32 width, u32 height, u32 code, u32 field, + const struct imx7_csi_pixfmt **cc) +{ + const struct imx7_csi_pixfmt *lcc; + + mbus->width = width; + mbus->height = height; + mbus->field = field; + + if (code == 0) + 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; + } + + mbus->code = code; + + mbus->colorspace = V4L2_COLORSPACE_SRGB; + 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, + mbus->colorspace, + mbus->ycbcr_enc); + + if (cc) + *cc = lcc; + + return 0; +} + +static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, + const struct v4l2_mbus_framefmt *mbus, + const struct imx7_csi_pixfmt *cc) +{ + u32 width; + 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); + 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->cs == IPUV3_COLORSPACE_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); + + /* Round up stride for IDMAC line start address alignment */ + if (cc->planar) + stride = round_up(width, 16); + else + stride = round_up((width * cc->bpp) >> 3, 8); + + pix->width = width; + pix->height = mbus->height; + pix->pixelformat = cc->fourcc; + pix->colorspace = mbus->colorspace; + pix->xfer_func = mbus->xfer_func; + pix->ycbcr_enc = mbus->ycbcr_enc; + pix->quantization = mbus->quantization; + pix->field = mbus->field; + pix->bytesperline = stride; + pix->sizeimage = cc->planar ? ((stride * pix->height * cc->bpp) >> 3) : + stride * pix->height; + + return 0; +} + /* ----------------------------------------------------------------------------- * Video Capture Device - IOCTLs */ -static const struct imx_media_pixfmt * +static const struct imx7_csi_pixfmt * imx7_csi_video_find_format(u32 code, u32 fourcc) { - const struct imx_media_pixfmt *cc; + const struct imx7_csi_pixfmt *cc; - cc = imx_media_find_ipu_format(code, PIXFMT_SEL_YUV_RGB); + cc = imx7_csi_find_ipu_format(code, IMX7_CSI_PIXFMT_SEL_YUV_RGB); if (cc) { - enum imx_pixfmt_sel fmt_sel = cc->cs == IPUV3_COLORSPACE_YUV - ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB; + enum imx7_csi_pixfmt_sel fmt_sel = cc->cs == IPUV3_COLORSPACE_YUV + ? IMX7_CSI_PIXFMT_SEL_YUV + : IMX7_CSI_PIXFMT_SEL_RGB; - cc = imx_media_find_pixel_format(fourcc, fmt_sel); + cc = imx7_csi_find_pixel_format(fourcc, fmt_sel); if (!cc) { - imx_media_enum_pixel_formats(&fourcc, 0, fmt_sel, 0); - cc = imx_media_find_pixel_format(fourcc, fmt_sel); + imx7_csi_enum_pixel_formats(&fourcc, 0, fmt_sel, 0); + cc = imx7_csi_find_pixel_format(fourcc, fmt_sel); } return cc; } - return imx_media_find_mbus_format(code, PIXFMT_SEL_ANY); + return imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); } static int imx7_csi_video_querycap(struct file *file, void *fh, @@ -826,19 +1331,21 @@ 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 imx_media_enum_pixel_formats(&f->pixelformat, f->index, - PIXFMT_SEL_ANY, f->mbus_code); + return imx7_csi_enum_pixel_formats(&f->pixelformat, f->index, + IMX7_CSI_PIXFMT_SEL_ANY, + f->mbus_code); } static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, struct v4l2_frmsizeenum *fsize) { - const struct imx_media_pixfmt *cc; + const struct imx7_csi_pixfmt *cc; if (fsize->index > 0) return -EINVAL; - cc = imx_media_find_pixel_format(fsize->pixel_format, PIXFMT_SEL_ANY); + cc = imx7_csi_find_pixel_format(fsize->pixel_format, + IMX7_CSI_PIXFMT_SEL_ANY); if (!cc) return -EINVAL; @@ -868,23 +1375,24 @@ static int imx7_csi_video_g_fmt_vid_cap(struct file *file, void *fh, return 0; } -static const struct imx_media_pixfmt * +static const struct imx7_csi_pixfmt * __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; + const struct imx7_csi_pixfmt *cc; /* * Find the pixel format, default to the first supported format if not * found. */ - cc = imx_media_find_pixel_format(pixfmt->pixelformat, PIXFMT_SEL_ANY); + cc = imx7_csi_find_pixel_format(pixfmt->pixelformat, + IMX7_CSI_PIXFMT_SEL_ANY); if (!cc) { - imx_media_enum_pixel_formats(&pixfmt->pixelformat, 0, - PIXFMT_SEL_ANY, 0); - cc = imx_media_find_pixel_format(pixfmt->pixelformat, - PIXFMT_SEL_ANY); + 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); } /* Allow IDMAC interweave but enforce field order from source. */ @@ -902,7 +1410,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, } v4l2_fill_mbus_format(&fmt_src, pixfmt, 0); - imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); + imx7_csi_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src, cc); if (compose) { compose->width = fmt_src.width; @@ -923,7 +1431,7 @@ 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; + const struct imx7_csi_pixfmt *cc; if (vb2_is_busy(&csi->q)) { dev_err(csi->dev, "%s queue busy\n", __func__); @@ -1084,7 +1592,7 @@ static void imx7_csi_video_buf_queue(struct vb2_buffer *vb) static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) { struct v4l2_subdev_format fmt_src; - const struct imx_media_pixfmt *cc; + const struct imx7_csi_pixfmt *cc; int ret; /* Retrieve the media bus format on the source subdev. */ @@ -1279,12 +1787,12 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) 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); + imx7_csi_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; - csi->vdev_cc = imx_media_find_pixel_format(csi->vdev_fmt.pixelformat, - PIXFMT_SEL_ANY); + csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat, + IMX7_CSI_PIXFMT_SEL_ANY); return 0; } @@ -1466,8 +1974,8 @@ 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 = imx_media_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE, - &csi->cc[i]); + ret = imx7_csi_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE, + &csi->cc[i]); if (ret < 0) return ret; } @@ -1490,8 +1998,8 @@ static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd, switch (code->pad) { case IMX7_CSI_PAD_SINK: - ret = imx_media_enum_mbus_formats(&code->code, code->index, - PIXFMT_SEL_ANY); + ret = imx7_csi_enum_mbus_formats(&code->code, code->index, + IMX7_CSI_PIXFMT_SEL_ANY); break; case IMX7_CSI_PAD_SRC: if (code->index != 0) { @@ -1536,12 +2044,74 @@ static int imx7_csi_get_fmt(struct v4l2_subdev *sd, return ret; } +/* + * Default the colorspace in tryfmt to SRGB if set to an unsupported + * colorspace or not initialized. Then set the remaining colorimetry + * parameters based on the colorspace if they are uninitialized. + * + * tryfmt->code must be set on entry. + * + * If this format is destined to be routed through the Image Converter, + * Y`CbCr encoding must be fixed. The IC supports only BT.601 Y`CbCr + * or Rec.709 Y`CbCr encoding. + */ +static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, + bool ic_route) +{ + const struct imx7_csi_pixfmt *cc; + 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->cs == IPUV3_COLORSPACE_RGB) + is_rgb = true; + + switch (tryfmt->colorspace) { + case V4L2_COLORSPACE_SMPTE170M: + case V4L2_COLORSPACE_REC709: + case V4L2_COLORSPACE_JPEG: + case V4L2_COLORSPACE_SRGB: + case V4L2_COLORSPACE_BT2020: + case V4L2_COLORSPACE_OPRGB: + case V4L2_COLORSPACE_DCI_P3: + case V4L2_COLORSPACE_RAW: + break; + default: + tryfmt->colorspace = V4L2_COLORSPACE_SRGB; + break; + } + + if (tryfmt->xfer_func == V4L2_XFER_FUNC_DEFAULT) + tryfmt->xfer_func = + V4L2_MAP_XFER_FUNC_DEFAULT(tryfmt->colorspace); + + if (ic_route) { + if (tryfmt->ycbcr_enc != V4L2_YCBCR_ENC_601 && + tryfmt->ycbcr_enc != V4L2_YCBCR_ENC_709) + tryfmt->ycbcr_enc = V4L2_YCBCR_ENC_601; + } else { + if (tryfmt->ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) { + tryfmt->ycbcr_enc = + V4L2_MAP_YCBCR_ENC_DEFAULT(tryfmt->colorspace); + } + } + + if (tryfmt->quantization == V4L2_QUANTIZATION_DEFAULT) + tryfmt->quantization = + V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb, + tryfmt->colorspace, + tryfmt->ycbcr_enc); +} + static int imx7_csi_try_fmt(struct imx7_csi *csi, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *sdformat, - const struct imx_media_pixfmt **cc) + const struct imx7_csi_pixfmt **cc) { - const struct imx_media_pixfmt *in_cc; + const struct imx7_csi_pixfmt *in_cc; struct v4l2_mbus_framefmt *in_fmt; u32 code; @@ -1552,8 +2122,8 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, switch (sdformat->pad) { case IMX7_CSI_PAD_SRC: - in_cc = imx_media_find_mbus_format(in_fmt->code, - PIXFMT_SEL_ANY); + in_cc = imx7_csi_find_mbus_format(in_fmt->code, + IMX7_CSI_PIXFMT_SEL_ANY); sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; @@ -1567,13 +2137,13 @@ 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 = imx_media_find_mbus_format(sdformat->format.code, - PIXFMT_SEL_ANY); + *cc = imx7_csi_find_mbus_format(sdformat->format.code, + IMX7_CSI_PIXFMT_SEL_ANY); if (!*cc) { - imx_media_enum_mbus_formats(&code, 0, - PIXFMT_SEL_YUV_RGB); - *cc = imx_media_find_mbus_format(code, - PIXFMT_SEL_YUV_RGB); + imx7_csi_enum_mbus_formats(&code, 0, + IMX7_CSI_PIXFMT_SEL_YUV_RGB); + *cc = imx7_csi_find_mbus_format(code, + IMX7_CSI_PIXFMT_SEL_YUV_RGB); sdformat->format.code = (*cc)->codes[0]; } @@ -1584,7 +2154,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, return -EINVAL; } - imx_media_try_colorimetry(&sdformat->format, false); + imx7_csi_try_colorimetry(&sdformat->format, false); return 0; } @@ -1594,9 +2164,9 @@ static int imx7_csi_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *sdformat) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); - const struct imx_media_pixfmt *outcc; + const struct imx7_csi_pixfmt *outcc; struct v4l2_mbus_framefmt *outfmt; - const struct imx_media_pixfmt *cc; + const struct imx7_csi_pixfmt *cc; struct v4l2_mbus_framefmt *fmt; struct v4l2_subdev_format format; int ret = 0; From patchwork Tue May 10 11:51: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: 15874 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E03C7C3270 for ; Tue, 10 May 2022 11:52:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8EF85656A0; Tue, 10 May 2022 13:52:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183554; bh=VdbQSy3P82Rsg+gZHdvz8pmd9A0c/1tnz7bkpEBrIAE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PPSCkwPWfn/hci+2q/2gDr1KKDxTdYR9Xrl2wUh3pEI6SGEcF6M09EvPNpzZw3MK6 7gNC9tNt9AwCf0EkodAIgUCIufIxmznagvXzHgB9tCYq2PGvPHV/gUf3/TaJJA7P0R zd+h281DMGnf7Ioz3YcgOKLZRIvoK24IV1WuSqYdvDBO9MlD8HcvYGyffbE4Z2ZQl4 zGbYCF6gHgoHaxS7jmJr1muaZ98tuuPSdCBPvmF0KNCCxRAYEIEPB3LGt7LWD4cUgP /qhf+bnGz5l/9ugrExOIGZv6quaQV9j0mnGsqOjRwYx3VCFbKosAi2EZ/G7XL0k5x7 4m3lNYLIpRm5g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 258EC65697 for ; Tue, 10 May 2022 13:52:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WcbSf2I+"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E124B60; Tue, 10 May 2022 13:52:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183545; bh=VdbQSy3P82Rsg+gZHdvz8pmd9A0c/1tnz7bkpEBrIAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WcbSf2I+k/Icuees11oOGsugliBtEGit0rFLcLWoOpo/LSKjCNqbzozHlEPF4qPMU FpXF5hUvhYcRtFg2uaCMVT5HUgbhY+x4xgw6t/Sp7gHJ659Mzz+SbIwBkltBMGzLHI mnHySlr7VSYWgtX9IKHLgZKX6KsctP6h2szUdqAk= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:31 +0300 Message-Id: <20220510115147.19360-35-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 34/50] staging: media: imx: imx7-media-csi: Replace ipu_color_space with bool yuv field X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15875 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 65235C3256 for ; Tue, 10 May 2022 11:52:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EBC4365656; Tue, 10 May 2022 13:52:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183556; bh=d3QEcEuWK6z6oOc1biYGe9+5VTFDc2s4Kpf0jtO3sqk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=2WdwD/YX9bkY6KmHG6FFpv4EjTjClarLTGOjgCkQZQnNooVH2H5kb8B6cqPSc3DoG tCj1yUvwbJAFCaOm3vLvg7LT2zN2ADrgmHgOM968GTCal0QLp7FsMHqFiggCY7KaLQ TObt/K/i5PBSxdOG1ys1V9fGLVlZ8m0BFWOMX4jriAAwG4u/7Kjr6u4rH6mAYxyc+6 6CfvRhxoQwfNjDHlsrBjuAETqzevD54jnEP+od0oJigeVx1yymawKXIZmPvI25wuxs Rxg6m+lkCuHZ2WlpcXmakr3WjDNPPkIGlca7r+ddYcGkP7ChEiy1Q90l8FyT0+bmXA qrUtFik+LIPQA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F1D4065694 for ; Tue, 10 May 2022 13:52:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BFlvTIi1"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 16269824; Tue, 10 May 2022 13:52:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183546; bh=d3QEcEuWK6z6oOc1biYGe9+5VTFDc2s4Kpf0jtO3sqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFlvTIi1siMuhiKaocaeuj7uU0fbSPJy0kI41rmfTtqu5xnT+eTbT/8F7YvtkEEbb uM1AmVxakjmJ7QA3437wut9F3REFWxzPX3jDDDLpFg2AIfSz983SS5X1bCBPJAABPp R9DimFqgGNbNm0OkG7GFwbto9N4/wgRRdLuX4D1U= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:32 +0300 Message-Id: <20220510115147.19360-36-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 35/50] staging: media: imx: imx7-media-csi: Drop IC support from imx7_csi_try_colorimetry() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The imx7_csi_try_colorimetry() function supports the unrelated image converter hardware as it originates from shared helpers. Drop that. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index b8ce4fd7c55d..c8ff259452b1 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -2031,13 +2031,8 @@ static int imx7_csi_get_fmt(struct v4l2_subdev *sd, * parameters based on the colorspace if they are uninitialized. * * tryfmt->code must be set on entry. - * - * If this format is destined to be routed through the Image Converter, - * Y`CbCr encoding must be fixed. The IC supports only BT.601 Y`CbCr - * or Rec.709 Y`CbCr encoding. */ -static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, - bool ic_route) +static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt) { const struct imx7_csi_pixfmt *cc; bool is_rgb = false; @@ -2069,16 +2064,9 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, tryfmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(tryfmt->colorspace); - if (ic_route) { - if (tryfmt->ycbcr_enc != V4L2_YCBCR_ENC_601 && - tryfmt->ycbcr_enc != V4L2_YCBCR_ENC_709) - tryfmt->ycbcr_enc = V4L2_YCBCR_ENC_601; - } else { - if (tryfmt->ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) { - tryfmt->ycbcr_enc = - V4L2_MAP_YCBCR_ENC_DEFAULT(tryfmt->colorspace); - } - } + if (tryfmt->ycbcr_enc == V4L2_YCBCR_ENC_DEFAULT) + tryfmt->ycbcr_enc = + V4L2_MAP_YCBCR_ENC_DEFAULT(tryfmt->colorspace); if (tryfmt->quantization == V4L2_QUANTIZATION_DEFAULT) tryfmt->quantization = @@ -2135,7 +2123,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, return -EINVAL; } - imx7_csi_try_colorimetry(&sdformat->format, false); + imx7_csi_try_colorimetry(&sdformat->format); return 0; } From patchwork Tue May 10 11:51: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: 15876 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id EB4F2C3277 for ; Tue, 10 May 2022 11:52:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D081656AE; Tue, 10 May 2022 13:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183556; bh=Nsc9cQrGdNHUTWWL9yyzYak+ErdyW8aB4BwSgWgEAM0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bJp5xBMRL1WlntWaV7ARZC67dNzHIjdMEESKRQW9l6II3SgnRVoJ8AN49fM9efFzN eYpI9Mu5+A7cuMJollOVjrVk4hpGo98B62gfVhn5Q4yELq+tq66ZsjZkZc2H4T7CPO 4B+xrFXKZ+fB/KcRtMXw3vff7uSmqjl/V1xGM6cw17T9UtsjH5kWLqA3RsiLa+gdJw WmtFdO8JYf7SLLX0fHjaGSvyzIvejaCwA59yhD1uO8+t8zSsSv805SOyY7Fsd6vTMk BEQOhv730gIU23azDFfGgBNHrkDn/YowNb42S+fahhI4umzUUrg3Cda2KY/Dg9muFD VT3UxLi0+yUXg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C1DD765652 for ; Tue, 10 May 2022 13:52:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VnA9hCmm"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E7E30BA9; Tue, 10 May 2022 13:52:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183547; bh=Nsc9cQrGdNHUTWWL9yyzYak+ErdyW8aB4BwSgWgEAM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VnA9hCmm+SGSw9e8Edn6yPbfsnAemHSJsxinZmjxlxh+9CQ17A6lF09npC90UEaN4 C5WoWzzbc/CJe5+POaS0zhDT+gcSvdwYOGcArkCdnND3SpcUiq8/ZmNdmI+LlN2GvP ntOKFSiaogJbdshqOJ/mliegGcrFTvhpYKnwKDi4= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:33 +0300 Message-Id: <20220510115147.19360-37-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 36/50] staging: media: imx: imx7-media-csi: Drop IPU-only formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15877 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9FE07C3278 for ; Tue, 10 May 2022 11:52:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 22EF265694; Tue, 10 May 2022 13:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183557; bh=pWBNjOCNvJ0L79D+vMPw5/m+XPE3tTaq0Uoqw8TCT0c=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=i4mXN3aXUhUvg8+sf2M9JqHgOKt8se9axvf/J9LIfyHEhDAvk1UNHfQcTi2noo5BY diyoVNvzmSYxFyJHBmfqXY2HraOp/QLclqnaSr/zdCFUlenWH/AfOinfp+WMh8xsCg oZK3JmqayknIjJRgE/xJf4fM2KeJXKbUe1jw1PSlK2dRtoYkW9uRR3L2NFD5G9O5eO fJdpOwm5bNrgdnKNErW8J5XTlpgRiA9y8HOBNV2bWdDsiQ+2bS6xKC8mVaQbZGfGue 44tNvNj2OO9FV9vW/ow+mAnNa71YW5pI5zA4q4YY7A0Xtf/57QCq7qOpKqhHGJ3Cgw JuqhTsiAWWBLg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A205F6569E for ; Tue, 10 May 2022 13:52:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mpPAIIcl"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD9F4D18; Tue, 10 May 2022 13:52:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183548; bh=pWBNjOCNvJ0L79D+vMPw5/m+XPE3tTaq0Uoqw8TCT0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mpPAIIclHIWx7vWeskS2UIvWTaxj3M5NsBhzV5Yfg4YoA62M1zVPAF3QC6TduA6pe sw3Z5hnpLQ0IyHoZPf+j2o2NNAUm+wttFDt75j0LyClPngOgX+9Y9co49dLSdPpbEp JBVPDbXRNirA9b1TDDXnKV/q0qom4pEeSrf3lMDI= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:34 +0300 Message-Id: <20220510115147.19360-38-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 37/50] staging: media: imx: imx7-media-csi: Drop unsupported YUV and RGB formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A large number of formats defined in the pixel_formats array are not supported, as shown by the switch-case check in imx7_csi_pad_link_validate(). Drop them. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 55 ---------------------- 1 file changed, 55 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 17259922a082..6704e5d4d43b 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -838,61 +838,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { ), .yuv = true, .bpp = 16, - }, { - .fourcc = V4L2_PIX_FMT_YUV420, - .yuv = true, - .bpp = 12, - .planar = true, - }, { - .fourcc = V4L2_PIX_FMT_YVU420, - .yuv = true, - .bpp = 12, - .planar = true, - }, { - .fourcc = V4L2_PIX_FMT_YUV422P, - .yuv = true, - .bpp = 16, - .planar = true, - }, { - .fourcc = V4L2_PIX_FMT_NV12, - .yuv = true, - .bpp = 12, - .planar = true, - }, { - .fourcc = V4L2_PIX_FMT_NV16, - .yuv = true, - .bpp = 16, - .planar = true, - }, - /*** RGB formats start here ***/ - { - .fourcc = V4L2_PIX_FMT_RGB565, - .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_RGB565_2X8_LE), - .bpp = 16, - .cycles = 2, - }, { - .fourcc = V4L2_PIX_FMT_RGB24, - .codes = IMX_BUS_FMTS( - MEDIA_BUS_FMT_RGB888_1X24, - MEDIA_BUS_FMT_RGB888_2X12_LE - ), - .bpp = 24, - }, { - .fourcc = V4L2_PIX_FMT_BGR24, - .bpp = 24, - }, { - .fourcc = V4L2_PIX_FMT_XRGB32, - .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_ARGB8888_1X32), - .bpp = 32, - }, { - .fourcc = V4L2_PIX_FMT_XBGR32, - .bpp = 32, - }, { - .fourcc = V4L2_PIX_FMT_BGRX32, - .bpp = 32, - }, { - .fourcc = V4L2_PIX_FMT_RGBX32, - .bpp = 32, }, /*** raw bayer and grayscale formats start here ***/ { From patchwork Tue May 10 11:51: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: 15878 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 69C4AC3271 for ; Tue, 10 May 2022 11:52:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1D0BC656B5; Tue, 10 May 2022 13:52:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183558; bh=B6WanzxxZOvDy0QJchsYwXbrY8qfDYztQWKS2dM7214=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=rVVhMvjNU6rjTXm+H8Dy/EmRWjRPnzXrNuiCPMW0kcUfBWjLohDqc1PvdvvIGnDBF OaMbxJfefaiek7qcUGgWykcAOUps/Ry3IttC+QZkYz3hE+t91MOlsqaWw+F4TKGbp9 6RS/Q8p3f6M9wNe4gAyp6LMZ/cC0w3VFIYa/faqxdggVlVXWYduItZSDpCDcjo170g 3LcDn/8W0kJnIFiMr+g+ivb6nCjgpyc5PJzC2pJMoZGe3nysJgY4IN+bfx+29AkPgB MXMNL7eM5nVQT4UoFIKcoUmiD3L7VZUIu/EH9+TtKtnbGR+S06ucMrFU2M2c1t9zmk SMxIIn6u7R25g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81ED76566A for ; Tue, 10 May 2022 13:52:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FBHlBG2n"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 99027E0C; Tue, 10 May 2022 13:52:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183549; bh=B6WanzxxZOvDy0QJchsYwXbrY8qfDYztQWKS2dM7214=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBHlBG2n3RQR274QSbda4LMqvCn8B7MbCTffU62WnbmJN4Zld9H0A1t0ZhbG8ZCLX bcqAIi7UCtkv2vms5tXNHHxvYwDJdC8xmGK7+xN/sgL1dqkdUtaRHJgV6QSRHm9qXV okucRyhsxvnvysqki7eUHPAoYTgbrQZ3dbOSWvlw= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:35 +0300 Message-Id: <20220510115147.19360-39-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 38/50] staging: media: imx: imx7-media-csi: Make default formats consistent X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15879 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4D3C9C3272 for ; Tue, 10 May 2022 11:52:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 054A3656BA; Tue, 10 May 2022 13:52:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183560; bh=1XqqnZEZEy88Ls146BNeFzkHY5yYmenhdQ/p58Z+TVs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fF4H3RE4yODhOmeYVRiJA4pqhNnFGKDEHw7nFhdxE7RYYpCJzTiADLP7yJQCXYhyG Bgr+zjWv0kxaPJwlaNFV45PPJRDeXEPh3fxeTgr6CT/NaMK9D3/zzYTtdy+7zOXyop G2H6OXE2tzQTwm7cYEasIxOWsUhAoLxtfpImVgWFw0aXXylk1wL26cnromSS38zJwY 8qeFQGVuBG6cettCZuUnEB/nDE7bpIiJZ+yezNRkPei+2ZmV4KmCW65AAE1CZNj6hP ycxloiGfuUptXTsOuJUcvHH9JM0B4CyuFfP+6U6l7WSAZOMG1MC75gla9evmAxxPcp mXQMBwhPxY//w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DF5865698 for ; Tue, 10 May 2022 13:52:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="mooKxHcN"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 761DFB9A; Tue, 10 May 2022 13:52:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183550; bh=1XqqnZEZEy88Ls146BNeFzkHY5yYmenhdQ/p58Z+TVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mooKxHcNO4jw+IDtFT2wTnK6JKZwFgj55AZvokHj8tbqwaiHP3AppgTGUGZOmKbbM MCPrc3KT01MtVi9bHt3w3q79/kUKgGooPfd8P/ceLQ0xaEB4p2jDK8PaCs7AncaWsT aDhMIecEUIjsXRlpQDzuVwuSAcWcjhlcti8ViSIg= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:36 +0300 Message-Id: <20220510115147.19360-40-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 39/50] staging: media: imx: imx7-media-csi: Define macro for default mbus code X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Define a macro for the default media bus code and use it through the driver to replace a hardcoded value and a dynamic query from the pixel_formats table. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index bcf57aff3572..f2e85e9851e4 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -167,6 +167,7 @@ #define IMX7_CSI_VIDEO_MEM_LIMIT SZ_64M #define IMX7_CSI_VIDEO_EOF_TIMEOUT 2000 +#define IMX7_CSI_DEF_MBUS_CODE MEDIA_BUS_FMT_UYVY8_2X8 #define IMX7_CSI_DEF_PIX_WIDTH 640 #define IMX7_CSI_DEF_PIX_HEIGHT 480 @@ -1096,7 +1097,7 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, mbus->field = field; if (code == 0) - imx7_csi_enum_mbus_formats(&code, 0, IMX7_CSI_PIXFMT_SEL_YUV); + code = IMX7_CSI_DEF_MBUS_CODE; lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); if (!lcc) @@ -1629,7 +1630,7 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) .pad = IMX7_CSI_PAD_SRC, .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; - fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8; + fmt_src.format.code = IMX7_CSI_DEF_MBUS_CODE; fmt_src.format.width = IMX7_CSI_DEF_PIX_WIDTH; fmt_src.format.height = IMX7_CSI_DEF_PIX_HEIGHT; From patchwork Tue May 10 11:51: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: 15880 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 25F4CC326E for ; Tue, 10 May 2022 11:52:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A85B265698; Tue, 10 May 2022 13:52:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183560; bh=aeX1orNGzBDkwKiTIbU/NLaLk/IOSa8sRNi19vKUMfA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=kQXlSPXDQntYXUJLqmCf8pf5UmQ8hyc6suqj9x2UC3dmd+8+5qAOMDfWQWzD0UYjV PTiZhon+tHW9QCZJdCH7hF1Lhq/VZ2aqtAKejhiIuoG3NUX5Uo0MLRTX9EpMY8e7f8 uAbgZmjxav0Ng2ABsgIyyWRDiR5P+jNlu8E4OnTaUaQgUh0ABuwOaf97Qr40bl4DLr IA9WDfbbDXjMnh75fP1Saua2ULZZEj0WoUf/aGfc5S9j3kCily/ofIrZHs45W83PJ7 +dmvx6tAlS0RxzwFZlFdWs8EVYB8t0QlW+hLcXwJz99rhN+Wp9p4w/mY4Vi/CrB23L KCTSdNWofTDGQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 366BC65649 for ; Tue, 10 May 2022 13:52:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DX/5PFK8"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 580021224; Tue, 10 May 2022 13:52:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183551; bh=aeX1orNGzBDkwKiTIbU/NLaLk/IOSa8sRNi19vKUMfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DX/5PFK8XZaRyGf/0zAz8c2WW3HT2sNYLgWjjJv19+3ntfL5ANSgZ5xj8NcaqvgEa dLdJf1gWlYgP1SswDYVDIQPganscneVr8DTRZwmMSztoO3T/8PjJdDlHPmY1taefbm F34tJfkEl83tO2X4tU1BtFqKVMk7IwX2x/m1t4jU= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:37 +0300 Message-Id: <20220510115147.19360-41-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 40/50] staging: media: imx: imx7-media-csi: Simplify default mbus code in try_fmt X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15881 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5BC15C3279 for ; Tue, 10 May 2022 11:52:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5C706569B; Tue, 10 May 2022 13:52:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183561; bh=acBHI4Cc+IejSUvtpcxUVa16XO7kLHAsl0OGhtOqMnE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=O2QKBtfBK7hXcb1JtRLALUK9uMbEFjtLvew/o8EiffyF2ceLLIeefn6Uszxj+VIEc TAhDzl4aS1TxPzjfNhJglZUqcDaJwUfd7Wl8OMn/tdIXQopp78Stl9hlyqUIE59wUg GcJ8BBYO+f6sLhRCUiwqruQautjmMzy/+FEOwS6kivwURiRlQxDckzFQK93+rBFxQq 2GitsfWAzpbJl9oaSL7p52ZwWC1KXE6GNDcy2hWxWKP4kX5BRU8NhTHXiWL7xlhPDQ lu5OEOxm8fai93VN2/JzMnh/40XDNwflEisj5NGk3oVnI803uMzj7iuCb0SJ57n+yG eMinqVkibiwRQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D3316569A for ; Tue, 10 May 2022 13:52:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TnIBQLrW"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3544A1248; Tue, 10 May 2022 13:52:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183551; bh=acBHI4Cc+IejSUvtpcxUVa16XO7kLHAsl0OGhtOqMnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TnIBQLrWlhlauYKtGH75HeTdLv8YpjdM2qUGgbfZ2lz04PioadeuDEU7qbjUuh69x bs7bP+ahHTypdVRHXhmZf5rWMGwt+vI8o0Oxf/0dTrQanMha78ECzsTuRZ61RMnfty F0T2bhABoxY1J/kiRNe0u/CJt7Q5rl2aGgPkC9/Y= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:38 +0300 Message-Id: <20220510115147.19360-42-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 41/50] staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15882 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E6A23C327A for ; Tue, 10 May 2022 11:52:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7901D656B4; Tue, 10 May 2022 13:52:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183562; bh=pioge0W9Z06hO1XUA2h1cbvmUn6QLKoWaFjAWPtWIa4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jxLvCxy/EKpeDjV30bnxAxKY8ah2VONskHZVd1ZuqKkSKbSDqdJ0qgLq2YkSbOa9F 1o+RkbswFZJ//+7gXzq0WOuUsojfIyazl2ZHIObns4uiu7rLwAuTaRz41o3EZtZQE4 lnnBQLDjW+AUrsx0rgBimETDqjO8XzUvnAaCnIoFTYux/I5ojWLH4VW6kNAfuzkyfM WLiyb+QCwGH2pkvU15WaH/AmxmwwtZ6VqsgKCquHkJbN+Sez1jl4OopxWSkiKko+L0 Hh4FxczERWrsvbqgv6bxKTdrahHf65sdiWiVQ57IkOV1GYQztIjb8XBO0ytfjxiMAN Ljas8zLL4cdYg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 120236568E for ; Tue, 10 May 2022 13:52:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="j+2UmfF1"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1712CBA9; Tue, 10 May 2022 13:52:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183552; bh=pioge0W9Z06hO1XUA2h1cbvmUn6QLKoWaFjAWPtWIa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+2UmfF1Qwt25p/9wyR8NSmefhSaOE4CAcGbdpWEPPqDNdYvP1NhruVRvk0WVVTTC +2IC+TrcqbaE3WYsWZY4wPXdQB/1C+VvJDMTURIW4w4TvUlKshc2zXYEwI8mq1ANWF GwpoTijbkqkODiDlc4eDaQg5WzEkQk7gVF5NhvGA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:39 +0300 Message-Id: <20220510115147.19360-43-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 42/50] staging: media: imx: imx7-media-csi: Drop unneeded imx7_csi_pixfmt fields X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The imx7_csi_pixfmt cycles field is never used nor set, the bayer field is never used, and the planar field is never set. Drop them. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 23 ++-------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index ab101d82c253..b3fa3e20873b 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -185,11 +185,7 @@ struct imx7_csi_pixfmt { */ const u32 *codes; int bpp; /* total bpp */ - /* cycles per pixel for generic (bayer) formats for the parallel bus */ - int cycles; bool yuv; - bool planar; /* is a planar format */ - bool bayer; /* is a raw bayer format */ }; struct imx7_csi_vb2_buffer { @@ -836,22 +832,18 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { .fourcc = V4L2_PIX_FMT_SBGGR8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SBGGR8_1X8), .bpp = 8, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGBRG8_1X8), .bpp = 8, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGRBG8_1X8), .bpp = 8, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SRGGB8, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SRGGB8_1X8), .bpp = 8, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SBGGR16, .codes = IMX_BUS_FMTS( @@ -861,7 +853,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SBGGR16_1X16 ), .bpp = 16, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGBRG16, .codes = IMX_BUS_FMTS( @@ -871,7 +862,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SGBRG16_1X16 ), .bpp = 16, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SGRBG16, .codes = IMX_BUS_FMTS( @@ -881,7 +871,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SGRBG16_1X16 ), .bpp = 16, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_SRGGB16, .codes = IMX_BUS_FMTS( @@ -891,7 +880,6 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_SRGGB16_1X16 ), .bpp = 16, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_GREY, .codes = IMX_BUS_FMTS( @@ -900,17 +888,14 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { MEDIA_BUS_FMT_Y12_1X12 ), .bpp = 8, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_Y10, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y10_1X10), .bpp = 16, - .bayer = true, }, { .fourcc = V4L2_PIX_FMT_Y12, .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y12_1X12), .bpp = 16, - .bayer = true, }, }; @@ -1087,10 +1072,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, width = round_up(mbus->width, 8); /* Round up stride for IDMAC line start address alignment */ - if (cc->planar) - stride = round_up(width, 16); - else - stride = round_up((width * cc->bpp) >> 3, 8); + stride = round_up((width * cc->bpp) >> 3, 8); pix->width = width; pix->height = mbus->height; @@ -1101,8 +1083,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, pix->quantization = mbus->quantization; pix->field = mbus->field; pix->bytesperline = stride; - pix->sizeimage = cc->planar ? ((stride * pix->height * cc->bpp) >> 3) : - stride * pix->height; + pix->sizeimage = stride * pix->height; return 0; } From patchwork Tue May 10 11:51: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: 15883 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 51892C327B for ; Tue, 10 May 2022 11:52:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EB056656BF; Tue, 10 May 2022 13:52:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183562; bh=5+B/KoFU+IuzuNW1IpTkLULIo3A9NnPGy92kR6s1BuE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PDZIbxlv2tIjnh9X5DHN+jg+YQ1QaH1qPNV2Ln+F8+Rhd7i9v3dtv2zNFV1fRAD/M t+3xGf7U2drpgwQbS/9ZXi8EL2ZXHU5HL4LyFyHuRxL3fIGDRe1CqC3+2At7B3+XAs EveLNSHc0uxotzGUSqUapGMWBEewyKqXUULst4C2Kda78XoHcIIlpDrBlxI+/Nyv7+ 0dX/558LLsWlZlZkoFJwnO988+BKlbpU+rdjEA6dH0wE+BFohIzHykEzSrpofCMHwh G89rxgAYB72GRvJ+qwwGcDOk09plOLgRBwXMxF+qcUbi6RLgtoPIB54J5vMfs7Q7Ph z1w5bhEexot2Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB861656AB for ; Tue, 10 May 2022 13:52:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FSW0S03M"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DEEDAD18; Tue, 10 May 2022 13:52:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183553; bh=5+B/KoFU+IuzuNW1IpTkLULIo3A9NnPGy92kR6s1BuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FSW0S03MW8kpumA6nbL5gMweMoGFF8ioeBHmqH9LMACoLO8iLi6CweyYmXQvlQ964 Y3+6ybjOCLlLt2tFIp6HmvqGKDDSoGmcQo0Bvksp+rC4uzaTMyIxZqWMr+Q7Jj0I0C sog8/+X2Q2N8fFzRoweeEI4ldTA6a2MIRMz91nT8= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:40 +0300 Message-Id: <20220510115147.19360-44-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 43/50] staging: media: imx: imx7-media-csi: Inline imx7_csi_init_mbus_fmt() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Inline the imx7_csi_init_mbus_fmt() function in its only caller. This allows simplifying the code. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 54 ++++++---------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index b3fa3e20873b..bc3a87656117 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1022,39 +1022,6 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index) return -EINVAL; } -static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, - u32 width, u32 height, u32 code, u32 field, - const struct imx7_csi_pixfmt **cc) -{ - const struct imx7_csi_pixfmt *lcc; - - mbus->width = width; - mbus->height = height; - mbus->field = field; - - if (code == 0) - code = IMX7_CSI_DEF_MBUS_CODE; - - lcc = imx7_csi_find_mbus_format(code); - if (!lcc) - return -EINVAL; - - mbus->code = code; - - mbus->colorspace = V4L2_COLORSPACE_SRGB; - 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->yuv, - mbus->colorspace, - mbus->ycbcr_enc); - - if (cc) - *cc = lcc; - - return 0; -} - static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, const struct v4l2_mbus_framefmt *mbus, const struct imx7_csi_pixfmt *cc) @@ -1738,18 +1705,27 @@ static int imx7_csi_init_cfg(struct v4l2_subdev *sd, const enum v4l2_subdev_format_whence which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; struct imx7_csi *csi = v4l2_get_subdevdata(sd); - int ret; + const struct imx7_csi_pixfmt *cc; int i; + cc = imx7_csi_find_mbus_format(IMX7_CSI_DEF_MBUS_CODE); + for (i = 0; i < IMX7_CSI_PADS_NUM; i++) { struct v4l2_mbus_framefmt *mf = imx7_csi_get_format(csi, sd_state, i, which); - 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; + mf->code = IMX7_CSI_DEF_MBUS_CODE; + mf->width = IMX7_CSI_DEF_PIX_WIDTH; + mf->height = IMX7_CSI_DEF_PIX_HEIGHT; + mf->field = V4L2_FIELD_NONE; + + mf->colorspace = V4L2_COLORSPACE_SRGB; + mf->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(mf->colorspace); + mf->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(mf->colorspace); + mf->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(!cc->yuv, + mf->colorspace, mf->ycbcr_enc); + + csi->cc[i] = cc; } return 0; From patchwork Tue May 10 11:51: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: 15884 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E0587C327C for ; Tue, 10 May 2022 11:52:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67E4A6567F; Tue, 10 May 2022 13:52:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183563; bh=KgBCrsGlH31L2cj6pWaqulM0WKSu9Yyu/7MNfoNUqqk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PEVQFU6w3N4vOo2OWAbpjqaGM6+UykEwJs7bzUgD2S/pHygufC60MO8fxAdY2WwrP H4ZdVjz/AEOFs9DiTcPI5rHz/zCtYZprdOx7Idv3t2OcMR765ENgt3/1+gHeS4rheL DYxeK7lpu4S+KN//V8/Pcbo4EFniNk2/uwmbMzeRnrws7vQEQxVax4YfTu15G6QoRN mWCBxt9ZYFUSEs/Gz0o34l44ExbTDf6O0yRx68js9LvuFdzM21GqQmNk2xSCqq+axk 8/PuxItwpVfvwp9KFkuet6UhIewmY36Zj0zkXNl8xGzMP4gwun6Y6hSsl4nmpORVjf dKTiaWdQNuAZg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A91DD65655 for ; Tue, 10 May 2022 13:52:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kshRNTuV"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6483B9A; Tue, 10 May 2022 13:52:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183554; bh=KgBCrsGlH31L2cj6pWaqulM0WKSu9Yyu/7MNfoNUqqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kshRNTuV7RDBNwvanql8TXZjnaNplbQM/jYRDnRNruAJ5I8tlZ8lu32odbagxSEA1 03jlYcnRGE9s4YPB7Pa7lA3+P6Wc6cDlke889gRm/ccbC0EPZM71gX5Y8VB4/n8fJt etVg7FMX1MN5tuj8sXIAga1l482m5DJBNrxTzSrc= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:41 +0300 Message-Id: <20220510115147.19360-45-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 44/50] staging: media: imx: imx7-media-csi: Simplify default format in try_fmt X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15885 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 141C7C326C for ; Tue, 10 May 2022 11:52:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B8946564D; Tue, 10 May 2022 13:52:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183564; bh=3wfwAYCjwSBDY3gwY+uNhWpFjwm2U/VoRqE0aSgR5tI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=d6PSjq3vnrMJdL7+GKqs7YGmdAs6BzLpWLYQW9CU1fPrwdMt/DC4wYN6NBgVuuoRm YdLsubBGxTI2y9TvHenQj2Qy4q8JzLhSTBS6Q+nm003wZwKdKbTww/zPrlffxSviF3 0yBkWPjHxFDct/QlQrDz4a6axHfBYEpAzaEHErUk9GKBrxKMFZkYraUof42CykyJir TZtsWv5eXwIFML61+kGc0vDYUHjhrHougLhpi7eIXG8UqZ9ehoeaWxkAQSMBR0PyjW oVQkMU1OWCszk8L/5KeQ88Jnjmwf2WNBhCsPkut/MK0fFW3dutaL9L8zzEo2rbJ6SR VjQZmlRe2kByw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81E7C6568D for ; Tue, 10 May 2022 13:52:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VPM1i8mg"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9E4EC1224; Tue, 10 May 2022 13:52:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183555; bh=3wfwAYCjwSBDY3gwY+uNhWpFjwm2U/VoRqE0aSgR5tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VPM1i8mgynpOSC6mJxmce+GWjXb7LmsrBW/Dbcusw1FyN8Px94zTBg1qoPiycSEog iuX22LnnBcOW39Dbf+AjE0RLaaahu/mUte6mF/thEmjgvFbp8YoRZUjHfcvNqfi/xh is8m6vhbrNsntvqpHRijW5ckPL82UGsQsiNJEITg= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:42 +0300 Message-Id: <20220510115147.19360-46-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 45/50] staging: media: imx: imx7-media-csi: Fix list of supported formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The list of supported formats comes from helpers shared with the i.MX6 IPUv3 and is incorrect in multiple regards: - 10-, 12- and 14-bit Bayer formats are stored in memory as SBGGR10, SBGGR12 and SBGGR14 respectively (plus components permutations), not SBGGR16. Same thing for greyscale formats. - 16-bit RAW formats are not supported by the hardware. Fix the supported formats table. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 106 ++++++++++++--------- 1 file changed, 61 insertions(+), 45 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 0fb5e0c03396..1bb60f245861 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -846,56 +846,64 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SRGGB8_1X8), .bpp = 8, }, { - .fourcc = V4L2_PIX_FMT_SBGGR16, - .codes = IMX_BUS_FMTS( - MEDIA_BUS_FMT_SBGGR10_1X10, - MEDIA_BUS_FMT_SBGGR12_1X12, - MEDIA_BUS_FMT_SBGGR14_1X14, - MEDIA_BUS_FMT_SBGGR16_1X16 - ), - .bpp = 16, - }, { - .fourcc = V4L2_PIX_FMT_SGBRG16, - .codes = IMX_BUS_FMTS( - MEDIA_BUS_FMT_SGBRG10_1X10, - MEDIA_BUS_FMT_SGBRG12_1X12, - MEDIA_BUS_FMT_SGBRG14_1X14, - MEDIA_BUS_FMT_SGBRG16_1X16 - ), - .bpp = 16, - }, { - .fourcc = V4L2_PIX_FMT_SGRBG16, - .codes = IMX_BUS_FMTS( - MEDIA_BUS_FMT_SGRBG10_1X10, - MEDIA_BUS_FMT_SGRBG12_1X12, - MEDIA_BUS_FMT_SGRBG14_1X14, - MEDIA_BUS_FMT_SGRBG16_1X16 - ), - .bpp = 16, - }, { - .fourcc = V4L2_PIX_FMT_SRGGB16, - .codes = IMX_BUS_FMTS( - MEDIA_BUS_FMT_SRGGB10_1X10, - MEDIA_BUS_FMT_SRGGB12_1X12, - MEDIA_BUS_FMT_SRGGB14_1X14, - MEDIA_BUS_FMT_SRGGB16_1X16 - ), + .fourcc = V4L2_PIX_FMT_SBGGR10, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SBGGR10_1X10), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG10, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGBRG10_1X10), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG10, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGRBG10_1X10), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB10, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SRGGB10_1X10), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR12, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SBGGR12_1X12), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG12, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGBRG12_1X12), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG12, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGRBG12_1X12), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB12, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SRGGB12_1X12), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SBGGR14, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SBGGR14_1X14), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SGBRG14, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGBRG14_1X14), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SGRBG14, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SGRBG14_1X14), + .bpp = 16, + }, { + .fourcc = V4L2_PIX_FMT_SRGGB14, + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_SRGGB14_1X14), .bpp = 16, }, { .fourcc = V4L2_PIX_FMT_GREY, - .codes = IMX_BUS_FMTS( - MEDIA_BUS_FMT_Y8_1X8, - MEDIA_BUS_FMT_Y10_1X10, - MEDIA_BUS_FMT_Y12_1X12 - ), + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y8_1X8), .bpp = 8, }, { .fourcc = V4L2_PIX_FMT_Y10, - .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y10_1X10), + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y10_1X10), .bpp = 16, }, { .fourcc = V4L2_PIX_FMT_Y12, - .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y12_1X12), + .codes = IMX_BUS_FMTS(MEDIA_BUS_FMT_Y12_1X12), .bpp = 16, }, }; @@ -2015,10 +2023,18 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: - case V4L2_PIX_FMT_SBGGR16: - case V4L2_PIX_FMT_SGBRG16: - case V4L2_PIX_FMT_SGRBG16: - case V4L2_PIX_FMT_SRGGB16: + case V4L2_PIX_FMT_SBGGR10: + case V4L2_PIX_FMT_SGBRG10: + case V4L2_PIX_FMT_SGRBG10: + case V4L2_PIX_FMT_SRGGB10: + case V4L2_PIX_FMT_SBGGR12: + case V4L2_PIX_FMT_SGBRG12: + case V4L2_PIX_FMT_SGRBG12: + case V4L2_PIX_FMT_SRGGB12: + case V4L2_PIX_FMT_SBGGR14: + case V4L2_PIX_FMT_SGBRG14: + case V4L2_PIX_FMT_SGRBG14: + case V4L2_PIX_FMT_SRGGB14: break; default: From patchwork Tue May 10 11:51: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: 15886 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D960AC327D for ; Tue, 10 May 2022 11:52:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 530EE6565E; Tue, 10 May 2022 13:52:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183565; bh=8RjlLCLqB3e6bnEKhzH3wSIoisKEZ2LtKIghyJR8FuI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=x5K5bW0o6KPVC9X/fO/4dTzMUROpbOVDHaSQE6QSXkZIOzPhcxFESunPOQ1K3qwVx Y6Mlk7XeMcL47XgRGGCWKqh/ymzhSAJr+gcKjjDVXvOQEb60vY7KJCX97P0VoLnFRF WSBtxEMWOOgk76hduvQvW6TZ5cMi0tILwKFaM5iV0EY7rht/kNdnNUgMFdJNN3xKZg lGfgjfbpIn7C8o5IclDzwfAzXVHW5X+B/FLoBDPP/jh2zng9QrGCLOy4DwuUh3AhKj L2UnVZC9kiu/xkoluf5JPEjromp/zSKBiWL0FKEGsOGSp7KNBuQhDsR9j6lCSCWFWO JljAi1qRU4+Ag== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A2246569B for ; Tue, 10 May 2022 13:52:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GgRWFW+N"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 77D261248; Tue, 10 May 2022 13:52:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183556; bh=8RjlLCLqB3e6bnEKhzH3wSIoisKEZ2LtKIghyJR8FuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgRWFW+NwmsQ8+v4hA8Bq21+6xGCHRxaxPgbhdyfC2tc4HV8RfCWyCr535U58nwRK IBLlBtYRuPtb/bcrWRUJpOAGXzv3+MbGYIKPnN3S8Gh4fXNnCxWHzUwd+agJwNaary 5nxvU2Pdckp0ZeueodIMX8iUEKLL8ndLWJNzx36Y= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:43 +0300 Message-Id: <20220510115147.19360-47-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 46/50] staging: media: imx: imx7-media-csi: Add V4L2_PIX_FMT_Y14 support X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15887 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9756CC0F2A for ; Tue, 10 May 2022 11:52:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 39642656BE; Tue, 10 May 2022 13:52:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183566; bh=k83DkJluD69YCIeo/EtpffCkhSFp7txn436AUp0SJpM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ZxOj1j4jWdo/Pdvy4ZNUKD/EOTy4yvqkZ8hCCz89JQ/d5L4yyoyW2iyAeV+u5GT22 WtfvJvv1JcjPhRnMpCs9bHuweZcL6f8MeHmVtpZ8SGbTD63lsTk/eXEeW9YJXcPDw7 dNqpvYRXr8HY41p0jvTw8RFXFTU506AgTYCFnZ7f/dYoh2fF3yIgSd9Tez3VJTaQ5O KarT5aPeKV7ZXKwhXVqZQc5r+ua/iB85m7yzgZRiBmWVcbft8aLncOyPViiAOXR/rn S5u1OJWp30+ARRwGbz7a18SYU2Tg+wONjAehjOZiFMyt1tnvAzA8ajI36zhuYpBawL gjKBhn6aE4Jhg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 29DD3656B7 for ; Tue, 10 May 2022 13:52:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PNEwPqdt"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4BF2EBA9; Tue, 10 May 2022 13:52:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183556; bh=k83DkJluD69YCIeo/EtpffCkhSFp7txn436AUp0SJpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNEwPqdtqR8K1TgsuwDtYUX8bwK0cVMltqFu6A9GOGy94swCD6/BFmRfqX8FHwFZ0 ZtS7PvW/qTxw5Tss1r026aIn2+XmSc7YM4qTrxa7TSSW0Ci5/Yz2/T54a+gCbAGzfv sgBB2DveNdOLLGlevgM+lIVJyz3RnvkZGKOfIKz4= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:44 +0300 Message-Id: <20220510115147.19360-48-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 47/50] staging: media: imx: imx7-media-csi: Drop unneeded pixel format validation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The driver won't accept unsupported pixel formats, there's thus no need to validate it in imx7_csi_pad_link_validate(). Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 4d8e3c0a3633..8be6f40588af 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1966,7 +1966,6 @@ 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); - const struct v4l2_pix_format *out_pix = &csi->vdev_fmt; struct media_pad *pad = NULL; unsigned int i; int ret; @@ -2016,38 +2015,6 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, break; } - /* Validate the sink link, ensure the pixel format is supported. */ - switch (out_pix->pixelformat) { - case V4L2_PIX_FMT_UYVY: - case V4L2_PIX_FMT_YUYV: - 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: - case V4L2_PIX_FMT_SRGGB8: - case V4L2_PIX_FMT_SBGGR10: - case V4L2_PIX_FMT_SGBRG10: - case V4L2_PIX_FMT_SGRBG10: - case V4L2_PIX_FMT_SRGGB10: - case V4L2_PIX_FMT_SBGGR12: - case V4L2_PIX_FMT_SGBRG12: - case V4L2_PIX_FMT_SGRBG12: - case V4L2_PIX_FMT_SRGGB12: - case V4L2_PIX_FMT_SBGGR14: - case V4L2_PIX_FMT_SGBRG14: - case V4L2_PIX_FMT_SGRBG14: - case V4L2_PIX_FMT_SRGGB14: - break; - - default: - dev_dbg(csi->dev, "Invalid capture pixel format 0x%08x\n", - out_pix->pixelformat); - return -EINVAL; - } - return 0; } From patchwork Tue May 10 11:51: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: 15888 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 380D9C327E for ; Tue, 10 May 2022 11:52:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2515656AB; Tue, 10 May 2022 13:52:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183566; bh=7n8of1MXRoPvO3JeUjedG56zxX0gutOm/D21RqQZXt4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bKU2n3qfhSOZ5p1vnh9Bld1krjmDufCvKgEOkAMgBft+aWndMbwGCRks4dc+a9S16 mTms+aDrIjsI/IvAdV2EyLR6AbOi54NRCauIkKUJ1VM2A1EsUyvwGToG/d4RTtdNC1 SzN8eVELcIceUvFgu8u287MZkcCmTWBAWDnCfFSRauoa97DDVeFiP0tRYROFCQ1iBk CYGd8jxxji1sLmBnGnRZcCciwEo1hZKyeDU0d0GV65tw3TysgJksJEo808fM5e5SE4 OTLyQs8RyhlbqG6jJ4bbrPhKE6OoMVdXurOmoQetS0q6XI5i/MX1NVlD0yCl9mvVTe hEuac61z1d60g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D5DA656B4 for ; Tue, 10 May 2022 13:52:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="at/UC7Gv"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 22FBAB9A; Tue, 10 May 2022 13:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183557; bh=7n8of1MXRoPvO3JeUjedG56zxX0gutOm/D21RqQZXt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=at/UC7Gvq23CNRSgW5N5LvJFd7FiDBATlYtU5Vj5GRlCggDZSQ+OTlRVaF+0MpK1y LY1HRF27lbidJW0UrlzpTD3J1tBYweQkNVakfw68JtsT2x+MQucXF6A/giYRiklFO6 kKvAH3oSve/2rEtm+P4u7lIvJNgyhuj5JSPCPtbA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:45 +0300 Message-Id: <20220510115147.19360-49-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 48/50] staging: media: imx: imx7-media-csi: Inline imx7_csi_enum_pixel_formats() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15889 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 90CBAC327F for ; Tue, 10 May 2022 11:52:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44B6B6565A; Tue, 10 May 2022 13:52:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183567; bh=7TZAvmLE3VyU/IP2y4JQZc51w8dX52N/5RgRLrzd8oU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=TwGAWWsLIxqbTEa1ey42VPaq3JJ62zTAueHhRn+z9Jm88G1+rB9PLg9TGV+s0Ax8M 7tOOmRxU32R9xy2nJNE3A/T2EME9dQzOhL+/Rc55uDrqUXQDV6X57JBpEHd0Hsxw2e WkZ3fmwhLmD3axW1CIe4uIIZn/U1DIr4/o/Sbuav0CRBqieAJeJ4ufKpz9aPsZMTSA gXuQTMA9N7e08NkVlsy5gC52XhAN9AiO68mVSNTXtDRG4sx+SLlu149KvAM8bB8AvY IUcLgbs80+CcruInvqsJHSz58rhQrWfXnH32g59HcPGDbkGE2YstL/OIzGJDmPZoRb UkhW9dzgH6ylQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D614F656B3 for ; Tue, 10 May 2022 13:52:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FjRrUelU"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 029E6DFF; Tue, 10 May 2022 13:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183558; bh=7TZAvmLE3VyU/IP2y4JQZc51w8dX52N/5RgRLrzd8oU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FjRrUelU3+MP4783xr+OBvUr3IWrsx6/VqOZpnFpivIi8IovyQwhru9sXBmBxxy4g FFPv9o4Z1asCi2yRl1y6OwQYQSTDZrsM6gsQqh9kHc1BgzXApP4ITu2cRrxl/LKM7h 9t2LHEK62svQ9tFqTh9EeK7M5vE85E/rzkdNi1MA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:46 +0300 Message-Id: <20220510115147.19360-50-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 49/50] staging: media: imx: imx7-media-csi: Drop V4L2 events support X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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, }; /* ----------------------------------------------------------------------------- From patchwork Tue May 10 11:51: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: 15890 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 13332C3280 for ; Tue, 10 May 2022 11:52:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A0EC6656CD; Tue, 10 May 2022 13:52:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183567; bh=rxA+S3Y9czX3f8Mgq5gZO4DV4tI/RPfGFDgMPXG/XaE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=I4MLlWpMQrugjaT69TIdzEkyFrTlguk6pEtRkns7P+6YKKfcrceXl6tc8S0PjB+3C tOVtTNlltJsQn8Iz5yM5FOPhhvo+428DtFkgxmACa6qLFUdWVWfOdwUQXvs8D1sjSS xXAZ/RsSqm1dkLG+7rxkht8aWnnBmn3ZjqlZqx4/XrkrWYxWZngFD7hnn0Pwur+m0I pf3BZcUeKjnLaZ8lJPFluQNhB4Lubp7uaKk1J1QJ+rxkEZguzOQYEsNIQm+2AcLgZf bLaXO4wXqZWf5PemX6nDcTBAtrErfdGEJUVxFH0MW+jw3N8gW54MM2TWTxN2UscFrk U+sBlK3UE2VaQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8B31656BC for ; Tue, 10 May 2022 13:52:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ofc9FHCB"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE3AB1224; Tue, 10 May 2022 13:52:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183559; bh=rxA+S3Y9czX3f8Mgq5gZO4DV4tI/RPfGFDgMPXG/XaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ofc9FHCBo9so1iWdajisxLaDshHM1H1KAsO8agdzfxQmdDZA0fRLX/AY86Gm76GxQ 4Yapn8tGTkbJYuVa+12mRZgcJ1addFZrEmiZx92/jhkDI1eP038EMCznWOg7eC1QOS +QU4T2DybVNtpP1wP0TCGpXOi1EO+OOmFx1eCWy8= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:47 +0300 Message-Id: <20220510115147.19360-51-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 50/50] staging: media: imx: imx7-media-csi: Drop usage of shared helpers X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" None of the shared helpers are used anymore. Make this official by dropping inclusion of imx-media.h. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index ae74256755f4..cf35a2a02d8d 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -28,8 +28,6 @@ #include #include -#include "imx-media.h" - #define IMX7_CSI_PAD_SINK 0 #define IMX7_CSI_PAD_SRC 1 #define IMX7_CSI_PADS_NUM 2