From patchwork Wed Feb 18 16:20:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5845211 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0A08BBF440 for ; Wed, 18 Feb 2015 16:25:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 208AB20225 for ; Wed, 18 Feb 2015 16:25:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1262320221 for ; Wed, 18 Feb 2015 16:25:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752978AbbBRQZt (ORCPT ); Wed, 18 Feb 2015 11:25:49 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:62577 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbbBRQZq (ORCPT ); Wed, 18 Feb 2015 11:25:46 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NJZ00H6S6YX9440@mailout4.samsung.com>; Thu, 19 Feb 2015 01:25:45 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-6e-54e4bd08c5df Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id E1.A9.20081.80DB4E45; Thu, 19 Feb 2015 01:25:45 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NJZ003WS6QJDJ20@mmp1.samsung.com>; Thu, 19 Feb 2015 01:25:44 +0900 (KST) From: Jacek Anaszewski To: linux-leds@vger.kernel.org, linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: kyungmin.park@samsung.com, pavel@ucw.cz, cooloney@gmail.com, rpurdie@rpsys.net, sakari.ailus@iki.fi, s.nawrocki@samsung.com, Jacek Anaszewski Subject: [PATCH/RFC v11 14/20] exynos4-is: Add support for v4l2-flash subdevs Date: Wed, 18 Feb 2015 17:20:35 +0100 Message-id: <1424276441-3969-15-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1424276441-3969-1-git-send-email-j.anaszewski@samsung.com> References: <1424276441-3969-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsVy+t9jAV3OvU9CDA5tZ7I4unMik8X8I+dY LXqvPme0ONv0ht1i65t1jBY9G7ayWtw9dZTNYveup6wWh9+0s1qc2b+SzYHLY+esu+weh78u ZPHYM/8Hq0ffllWMHitWf2f3+LxJLoAtissmJTUnsyy1SN8ugStjyadNrAULVSsmvOlhaWBs l+9i5OSQEDCReLz4NzOELSZx4d56NhBbSGARo8SLx3ldjFxAdjuTxMtJu9hBEmwChhI/X7xm ArFFBCIl3h29xAxSxCywgVHi8oRGFpCEsICvxKwtz8BsFgFVifvv+8AaeAU8JCbsOwO0gQNo m4LEnEk2ICYnUPjCcw+Ive4S02++Y53AyLuAkWEVo2hqQXJBcVJ6rqFecWJucWleul5yfu4m RnDoPZPawbiyweIQowAHoxIPb8PvxyFCrIllxZW5hxglOJiVRHhzVz4JEeJNSaysSi3Kjy8q zUktPsQozcGiJM6rZN8WIiSQnliSmp2aWpBaBJNl4uCUamA8GXbevuhKtVEYm13Y7k9650Pv aZqY2e9PuB3M+2WKlCjPS9NZL2a2qsjnZvHF8b/fNeGRp2Hdwo+tATOUd6r9eL/4X1f7LacL G4o+tbdzyJg9aznD80051TBgFqf62n5p0x3yr/+kL1utOdk69GnEO0mpOe+K53VlS3/e5Sk2 w6uLYe/7sg1KLMUZiYZazEXFiQBer8JuOQIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for external v4l2-flash devices. The support includes parsing "flashes" DT property and asynchronous subdevice registration. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park Cc: Sylwester Nawrocki --- drivers/media/platform/exynos4-is/media-dev.c | 36 +++++++++++++++++++++++-- drivers/media/platform/exynos4-is/media-dev.h | 13 ++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index f315ef9..8dd0e5d 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -451,6 +451,25 @@ rpm_put: return ret; } +static void fimc_md_register_flash_entities(struct fimc_md *fmd) +{ + struct device_node *parent = fmd->pdev->dev.of_node; + struct device_node *np; + int i = 0; + + do { + np = of_parse_phandle(parent, "flashes", i); + if (np) { + fmd->flash[fmd->num_flashes].asd.match_type = + V4L2_ASYNC_MATCH_OF; + fmd->flash[fmd->num_flashes].asd.match.of.node = np; + fmd->num_flashes++; + fmd->async_subdevs[fmd->num_sensors + i] = + &fmd->flash[i].asd; + } + } while (np && (++i < FIMC_MAX_FLASHES)); +} + static int __of_get_csis_id(struct device_node *np) { u32 reg = 0; @@ -1275,6 +1294,15 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier, struct fimc_sensor_info *si = NULL; int i; + /* Register flash subdev if detected any */ + for (i = 0; i < ARRAY_SIZE(fmd->flash); i++) { + if (fmd->flash[i].asd.match.of.node == subdev->dev->of_node) { + fmd->flash[i].subdev = subdev; + fmd->num_flashes++; + return 0; + } + } + /* Find platform data for this sensor subdev */ for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++) if (fmd->sensor[i].asd.match.of.node == subdev->dev->of_node) @@ -1385,6 +1413,8 @@ static int fimc_md_probe(struct platform_device *pdev) goto err_m_ent; } + fimc_md_register_flash_entities(fmd); + mutex_unlock(&fmd->media_dev.graph_mutex); ret = device_create_file(&pdev->dev, &dev_attr_subdev_conf_mode); @@ -1401,12 +1431,14 @@ static int fimc_md_probe(struct platform_device *pdev) goto err_attr; } - if (fmd->num_sensors > 0) { + if (fmd->num_sensors > 0 || fmd->num_flashes > 0) { fmd->subdev_notifier.subdevs = fmd->async_subdevs; - fmd->subdev_notifier.num_subdevs = fmd->num_sensors; + fmd->subdev_notifier.num_subdevs = fmd->num_sensors + + fmd->num_flashes; fmd->subdev_notifier.bound = subdev_notifier_bound; fmd->subdev_notifier.complete = subdev_notifier_complete; fmd->num_sensors = 0; + fmd->num_flashes = 0; ret = v4l2_async_notifier_register(&fmd->v4l2_dev, &fmd->subdev_notifier); diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index 0321454..feff9c8 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -34,6 +34,8 @@ #define FIMC_MAX_SENSORS 4 #define FIMC_MAX_CAMCLKS 2 +#define FIMC_MAX_FLASHES 2 +#define FIMC_MAX_ASYNC_SUBDEVS (FIMC_MAX_SENSORS + FIMC_MAX_FLASHES) #define DEFAULT_SENSOR_CLK_FREQ 24000000U /* LCD/ISP Writeback clocks (PIXELASYNCMx) */ @@ -93,6 +95,11 @@ struct fimc_sensor_info { struct fimc_dev *host; }; +struct fimc_flash_info { + struct v4l2_subdev *subdev; + struct v4l2_async_subdev asd; +}; + struct cam_clk { struct clk_hw hw; struct fimc_md *fmd; @@ -104,6 +111,8 @@ struct cam_clk { * @csis: MIPI CSIS subdevs data * @sensor: array of registered sensor subdevs * @num_sensors: actual number of registered sensors + * @flash: array of registered flash subdevs + * @num_flashes: actual number of registered flashes * @camclk: external sensor clock information * @fimc: array of registered fimc devices * @fimc_is: fimc-is data structure @@ -123,6 +132,8 @@ struct fimc_md { struct fimc_csis_info csis[CSIS_MAX_ENTITIES]; struct fimc_sensor_info sensor[FIMC_MAX_SENSORS]; int num_sensors; + struct fimc_flash_info flash[FIMC_MAX_FLASHES]; + int num_flashes; struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS]; struct clk *wbclk[FIMC_MAX_WBCLKS]; struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS]; @@ -149,7 +160,7 @@ struct fimc_md { } clk_provider; struct v4l2_async_notifier subdev_notifier; - struct v4l2_async_subdev *async_subdevs[FIMC_MAX_SENSORS]; + struct v4l2_async_subdev *async_subdevs[FIMC_MAX_ASYNC_SUBDEVS]; bool user_subdev_api; spinlock_t slock;