From patchwork Mon May 25 15:14:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 29823 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Ywu5T-0005iD-NJ; Mon, 25 May 2015 17:14:43 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-8) with esmtp id 1Ywu5R-0005w1-lK; Mon, 25 May 2015 17:14:43 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964AbbEYPOj (ORCPT + 1 other); Mon, 25 May 2015 11:14:39 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:23376 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751908AbbEYPOh (ORCPT ); Mon, 25 May 2015 11:14:37 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NOW006FIVOB8500@mailout4.samsung.com>; Tue, 26 May 2015 00:14:35 +0900 (KST) X-AuditID: cbfee61b-f79416d0000014c0-dc-55633c5bb500 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id AD.E7.05312.B5C33655; Tue, 26 May 2015 00:14:35 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NOW004EQVNH5790@mmp1.samsung.com>; Tue, 26 May 2015 00:14:35 +0900 (KST) From: Jacek Anaszewski To: linux-leds@vger.kernel.org, linux-media@vger.kernel.org Cc: devicetree@vger.kernel.org, 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 v9 6/8] exynos4-is: Improve the mechanism of async subdevs verification Date: Mon, 25 May 2015 17:14:01 +0200 Message-id: <1432566843-6391-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1432566843-6391-1-git-send-email-j.anaszewski@samsung.com> References: <1432566843-6391-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t9jAd1om+RQg9XzhC2O7pzIZDH/yDlW i96rzxktzja9YbfY+mYdo0XPhq2sFndPHWWz2L3rKavF4TftrBZn9q9kc+Dy2DnrLrvH4a8L WTz2zP/B6tG3ZRWjx4rV39k9Pm+SC2CL4rJJSc3JLEst0rdL4Mo42PWVqWCpWkXbsV9MDYzT FLoYOTkkBEwkNs+bxgZhi0lcuLceyObiEBJYxCixb/0edgjnJ6PEubnbmEGq2AQMJX6+eM0E YosIWEvMOjSdBcRmFjjDKDFtqi2ILSwQKfFs9gOwGhYBVYlTkz4xgti8Au4SZ1Y8BprDAbRN QWLOJBuQMKeAh0TDwa9gY4SASi4dmsg4gZF3ASPDKkbR1ILkguKk9FwjveLE3OLSvHS95Pzc TYzg4HsmvYNxVYPFIUYBDkYlHt6IjKRQIdbEsuLK3EOMEhzMSiK8iSbJoUK8KYmVValF+fFF pTmpxYcYpTlYlMR5T+b7hAoJpCeWpGanphakFsFkmTg4pRoYtT3FT+RHW5vVLt1yhP3+2jOC +Xv4VvD1dT87fl980o71H9pvM1/XUHqm63b0uajH64l9zexaN9fNCF0a92XTATEnw5SOZSEP 7hzjmXb3oG7DbsfTBjEi+/b0bWrV/n99tf4LXe8zKy1WaljPteVsv3H4kWfgIaPA3BgDF42s Y3PLCh9e1jgtpMRSnJFoqMVcVJwIALu0dic6AgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.5.25.150617 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_4000_4999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Avoid verifying bound async sensor sub-devices by their of_nodes, which duplicates v4l2-async functionality, in favour of matching them by the corresponding struct v4l2_async_subdev. The structures are now being aggregated in the newly introduced struct fimc_async_subdevs which allows for categorizing async sub-devices by their type upon DT node parsing and recognizing the type easily when they're being bound. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park Cc: Sylwester Nawrocki --- drivers/media/platform/exynos4-is/media-dev.c | 34 +++++++++++++++++++------ drivers/media/platform/exynos4-is/media-dev.h | 8 ++++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index f315ef9..ff36a3b 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -331,6 +331,8 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, unsigned int index) { struct fimc_source_info *pd = &fmd->sensor[index].pdata; + struct v4l2_async_notifier *notifier = &fmd->subdev_notifier; + struct v4l2_async_subdev *asd; struct device_node *rem, *ep, *np; struct v4l2_of_endpoint endpoint; @@ -387,9 +389,11 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd, if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) return -EINVAL; - fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_OF; - fmd->sensor[index].asd.match.of.node = rem; - fmd->async_subdevs[index] = &fmd->sensor[index].asd; + asd = &fmd->async_subdevs.sensors[index]; + asd->match_type = V4L2_ASYNC_MATCH_OF; + asd->match.of.node = rem; + notifier->subdevs[notifier->num_subdevs++] = asd; + fmd->sensor[index].asd = asd; fmd->num_sensors++; @@ -1272,12 +1276,13 @@ static int subdev_notifier_bound(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd) { struct fimc_md *fmd = notifier_to_fimc_md(notifier); + struct fimc_async_subdevs *async_subdevs = &fmd->async_subdevs; struct fimc_sensor_info *si = NULL; int i; /* 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) + for (i = 0; i < ARRAY_SIZE(async_subdevs->sensors); i++) + if (fmd->sensor[i].asd == asd) si = &fmd->sensor[i]; if (si == NULL) @@ -1317,6 +1322,19 @@ unlock: return ret; } +static int fimc_md_register_async_entities(struct fimc_md *fmd) +{ + struct device *dev = fmd->media_dev.dev; + struct v4l2_async_notifier *notifier = &fmd->subdev_notifier; + + notifier->subdevs = devm_kcalloc(dev, FIMC_MAX_SENSORS, + sizeof(*notifier->subdevs), GFP_KERNEL); + if (!notifier->subdevs) + return -ENOMEM; + + return fimc_md_register_sensor_entities(fmd); +} + static int fimc_md_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1379,7 +1397,7 @@ static int fimc_md_probe(struct platform_device *pdev) goto err_clk; } - ret = fimc_md_register_sensor_entities(fmd); + ret = fimc_md_register_async_entities(fmd); if (ret) { mutex_unlock(&fmd->media_dev.graph_mutex); goto err_m_ent; @@ -1402,8 +1420,6 @@ static int fimc_md_probe(struct platform_device *pdev) } if (fmd->num_sensors > 0) { - fmd->subdev_notifier.subdevs = fmd->async_subdevs; - fmd->subdev_notifier.num_subdevs = fmd->num_sensors; fmd->subdev_notifier.bound = subdev_notifier_bound; fmd->subdev_notifier.complete = subdev_notifier_complete; fmd->num_sensors = 0; @@ -1412,6 +1428,8 @@ static int fimc_md_probe(struct platform_device *pdev) &fmd->subdev_notifier); if (ret) goto err_clk_p; + } else { + devm_kfree(dev, fmd->subdev_notifier.subdevs); } return 0; diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index 0321454..ff6d020 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -88,11 +88,15 @@ struct fimc_camclk_info { */ struct fimc_sensor_info { struct fimc_source_info pdata; - struct v4l2_async_subdev asd; + struct v4l2_async_subdev *asd; struct v4l2_subdev *subdev; struct fimc_dev *host; }; +struct fimc_async_subdevs { + struct v4l2_async_subdev sensors[FIMC_MAX_SENSORS]; +}; + struct cam_clk { struct clk_hw hw; struct fimc_md *fmd; @@ -149,7 +153,7 @@ struct fimc_md { } clk_provider; struct v4l2_async_notifier subdev_notifier; - struct v4l2_async_subdev *async_subdevs[FIMC_MAX_SENSORS]; + struct fimc_async_subdevs async_subdevs; bool user_subdev_api; spinlock_t slock;