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);