From patchwork Thu Feb 24 14:33:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 587641 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1OEdbXO006436 for ; Thu, 24 Feb 2011 14:39:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756150Ab1BXOjf (ORCPT ); Thu, 24 Feb 2011 09:39:35 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:38863 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754921Ab1BXOjc (ORCPT ); Thu, 24 Feb 2011 09:39:32 -0500 Received: from eu_spt1 (mailout1.w1.samsung.com [210.118.77.11]) by mailout1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0LH400K0AM1U4I@mailout1.w1.samsung.com>; Thu, 24 Feb 2011 14:39:30 +0000 (GMT) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LH4009WJM1TS0@spt1.w1.samsung.com>; Thu, 24 Feb 2011 14:39:29 +0000 (GMT) Received: from localhost.localdomain (unknown [106.116.38.10]) by linux.samsung.com (Postfix) with ESMTP id 9FCCF27004D; Thu, 24 Feb 2011 15:40:00 +0100 (CET) Date: Thu, 24 Feb 2011 15:33:51 +0100 From: Sylwester Nawrocki Subject: [PATCH 4/7] s5p-fimc: Allow defining number of sensors at runtime In-reply-to: <1298558034-10768-1-git-send-email-s.nawrocki@samsung.com> To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: m.szyprowski@samsung.com, kyungmin.park@samsung.com, kgene.kim@samsung.com, s.nawrocki@samsung.com Message-id: <1298558034-10768-5-git-send-email-s.nawrocki@samsung.com> MIME-version: 1.0 X-Mailer: git-send-email 1.7.2.3 Content-type: TEXT/PLAIN Content-transfer-encoding: 7BIT References: <1298558034-10768-1-git-send-email-s.nawrocki@samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Feb 2011 14:39:39 +0000 (UTC) diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 9aa767e..3d717f9 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c @@ -91,7 +91,7 @@ static int fimc_subdev_attach(struct fimc_dev *fimc, int index) struct v4l2_subdev *sd; int i; - for (i = 0; i < FIMC_MAX_CAMIF_CLIENTS; ++i) { + for (i = 0; i < pdata->num_clients; ++i) { isp_info = pdata->isp_info[i]; if (!isp_info || (index >= 0 && i != index)) @@ -116,12 +116,13 @@ static int fimc_subdev_attach(struct fimc_dev *fimc, int index) static int fimc_isp_subdev_init(struct fimc_dev *fimc, unsigned int index) { struct s5p_fimc_isp_info *isp_info; + struct s5p_platform_fimc *pdata = fimc->pdata; int ret; - if (index >= FIMC_MAX_CAMIF_CLIENTS) + if (index >= pdata->num_clients) return -EINVAL; - isp_info = fimc->pdata->isp_info[index]; + isp_info = pdata->isp_info[index]; if (!isp_info) return -EINVAL; @@ -564,7 +565,7 @@ static int fimc_cap_enum_input(struct file *file, void *priv, struct s5p_platform_fimc *pldata = ctx->fimc_dev->pdata; struct s5p_fimc_isp_info *isp_info; - if (i->index >= FIMC_MAX_CAMIF_CLIENTS) + if (i->index >= pldata->num_clients) return -EINVAL; isp_info = pldata->isp_info[i->index]; @@ -586,7 +587,7 @@ static int fimc_cap_s_input(struct file *file, void *priv, if (fimc_capture_active(ctx->fimc_dev)) return -EBUSY; - if (i >= FIMC_MAX_CAMIF_CLIENTS || !pdata->isp_info[i]) + if (i >= pdata->num_clients || !pdata->isp_info[i]) return -EINVAL; diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index f20e286..1ad9bc6 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -1578,6 +1578,7 @@ static int fimc_probe(struct platform_device *pdev) struct fimc_dev *fimc; struct resource *res; struct samsung_fimc_driverdata *drv_data; + struct s5p_platform_fimc *pdata; int ret = 0; int cap_input_index = -1; @@ -1599,7 +1600,8 @@ static int fimc_probe(struct platform_device *pdev) fimc->id = pdev->id; fimc->variant = drv_data->variant[fimc->id]; fimc->pdev = pdev; - fimc->pdata = pdev->dev.platform_data; + pdata = pdev->dev.platform_data; + fimc->pdata = pdata; fimc->state = ST_IDLE; init_waitqueue_head(&fimc->irq_queue); @@ -1630,19 +1632,11 @@ static int fimc_probe(struct platform_device *pdev) } fimc->num_clocks = MAX_FIMC_CLOCKS - 1; - /* - * Check if vide capture node needs to be registered for this device - * instance. - */ - if (fimc->pdata) { - int i; - for (i = 0; i < FIMC_MAX_CAMIF_CLIENTS; ++i) - if (fimc->pdata->isp_info[i]) - break; - if (i < FIMC_MAX_CAMIF_CLIENTS) { - cap_input_index = i; - fimc->num_clocks++; - } + + /* Check if a video capture node needs to be registered. */ + if (pdata && pdata->num_clients >= 1 && pdata->isp_info[0]) { + cap_input_index = 0; + fimc->num_clocks++; } ret = fimc_clk_get(fimc); diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h index 0d457ca..96cd6fc 100644 --- a/include/media/s5p_fimc.h +++ b/include/media/s5p_fimc.h @@ -46,15 +46,14 @@ struct s5p_fimc_isp_info { u16 flags; }; - -#define FIMC_MAX_CAMIF_CLIENTS 2 - /** * struct s5p_platform_fimc - camera host interface platform data * * @isp_info: properties of camera sensor required for host interface setup + * @num_clients: the number of attached image sensors */ struct s5p_platform_fimc { - struct s5p_fimc_isp_info *isp_info[FIMC_MAX_CAMIF_CLIENTS]; + struct s5p_fimc_isp_info **isp_info; + int num_clients; }; #endif /* S5P_FIMC_H_ */