From patchwork Wed Apr 10 10:42:37 2013 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: 2420541 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E31C13FD8C for ; Wed, 10 Apr 2013 10:43:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965200Ab3DJKnu (ORCPT ); Wed, 10 Apr 2013 06:43:50 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:23200 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751746Ab3DJKnt (ORCPT ); Wed, 10 Apr 2013 06:43:49 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ML100FK7CG33MI0@mailout2.samsung.com>; Wed, 10 Apr 2013 19:43:48 +0900 (KST) X-AuditID: cbfee61a-b7fa86d0000045ae-bb-51654264df41 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 85.7F.17838.46245615; Wed, 10 Apr 2013 19:43:48 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ML1001RKCFDPL00@mmp1.samsung.com>; Wed, 10 Apr 2013 19:43:48 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, shaik.samsung@gmail.com, arun.kk@samsung.com, Sylwester Nawrocki Subject: [PATCH 2/7] exynos4-is: Make fimc-lite independent of the pipeline->subdevs array Date: Wed, 10 Apr 2013 12:42:37 +0200 Message-id: <1365590562-5747-3-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1365590562-5747-1-git-send-email-s.nawrocki@samsung.com> References: <1365590562-5747-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkluLIzCtJLcpLzFFi42I5/e+xgG6KU2qgwcWTOhYfT91mtTjb9Ibd omfDVlaLGef3MVkcftPOarFu5yR2BzaPnbPusnv0bVnF6PF5k1wAcxSXTUpqTmZZapG+XQJX xuKjj1kKPktV3NzzmrmBsVmsi5GTQ0LARKL31EZWCFtM4sK99WxdjFwcQgKLGCVmLJgG5XQw SWw/cYwNpIpNwFCi92gfI4gtIiAv8aT3BlicWWA+o0TLHg4QW1ggRmLTmjtMIDaLgKrE1yXX gOo5OHgFXCXOt+eBmBICChJzJtmAmJwCbhINtyJATCGggu+71CYw8i5gZFjFKJpakFxQnJSe a6hXnJhbXJqXrpecn7uJERwwz6R2MK5ssDjEKMDBqMTD66GfEijEmlhWXJl7iFGCg1lJhNdC KzVQiDclsbIqtSg/vqg0J7X4EKM0B4uSOO+BVutAIYH0xJLU7NTUgtQimCwTB6dUA2ON7vsO vvyIC8tcpzOFT63NK/+4WyBKMWnrueg5HzkOTds/d15dr8WVPyfmsYVe/yXMqjTV2MnKb8Gz 039uZ0+rXhJ0cPPLt5IChn+Ndkp2zRPQk7nMezDkT+WfswtC1ofLMXzQclv/Q1NnvomV4ESm f5Ou5B9Z9vvlw1J50cWpavo291I053YqsRRnJBpqMRcVJwIAlj2gvxQCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Get the sensor subdev by walking media graph in both cases: when the device is used as a subdev only and through video node. This allows to not dereference the pipeline->subdevs[] array and makes the module more generic and easier to re-use in other media driver. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/platform/exynos4-is/fimc-lite.c | 57 ++++++++++++------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index cb196b8..3ea4fc7 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -130,23 +130,43 @@ static const struct fimc_fmt *fimc_lite_find_format(const u32 *pixelformat, return def_fmt; } +/* Called with the media graph mutex held or @me stream_count > 0. */ +static struct v4l2_subdev *__find_remote_sensor(struct media_entity *me) +{ + struct media_pad *pad = &me->pads[0]; + struct v4l2_subdev *sd; + + while (pad->flags & MEDIA_PAD_FL_SINK) { + /* source pad */ + pad = media_entity_remote_source(pad); + if (pad == NULL || + media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + break; + + sd = media_entity_to_v4l2_subdev(pad->entity); + + if (sd->grp_id == GRP_ID_FIMC_IS_SENSOR || + sd->grp_id == GRP_ID_SENSOR) + return sd; + /* sink pad */ + pad = &sd->entity.pads[0]; + } + return NULL; +} + static int fimc_lite_hw_init(struct fimc_lite *fimc, bool isp_output) { - struct fimc_pipeline *pipeline = &fimc->pipeline; - struct v4l2_subdev *sensor; struct fimc_sensor_info *si; unsigned long flags; - sensor = isp_output ? fimc->sensor : pipeline->subdevs[IDX_SENSOR]; - - if (sensor == NULL) + if (fimc->sensor == NULL) return -ENXIO; if (fimc->inp_frame.fmt == NULL || fimc->out_frame.fmt == NULL) return -EINVAL; /* Get sensor configuration data from the sensor subdev */ - si = v4l2_get_subdev_hostdata(sensor); + si = v4l2_get_subdev_hostdata(fimc->sensor); spin_lock_irqsave(&fimc->slock, flags); flite_hw_set_camera_bus(fimc, &si->pdata); @@ -801,6 +821,8 @@ static int fimc_lite_streamon(struct file *file, void *priv, if (ret < 0) goto err_p_stop; + fimc->sensor = __find_remote_sensor(&fimc->subdev.entity); + ret = vb2_ioctl_streamon(file, priv, type); if (!ret) { fimc->streaming = true; @@ -929,29 +951,6 @@ static const struct v4l2_ioctl_ops fimc_lite_ioctl_ops = { .vidioc_streamoff = fimc_lite_streamoff, }; -/* Called with the media graph mutex held */ -static struct v4l2_subdev *__find_remote_sensor(struct media_entity *me) -{ - struct media_pad *pad = &me->pads[0]; - struct v4l2_subdev *sd; - - while (pad->flags & MEDIA_PAD_FL_SINK) { - /* source pad */ - pad = media_entity_remote_source(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) - break; - - sd = media_entity_to_v4l2_subdev(pad->entity); - - if (sd->grp_id == GRP_ID_FIMC_IS_SENSOR) - return sd; - /* sink pad */ - pad = &sd->entity.pads[0]; - } - return NULL; -} - /* Capture subdev media entity operations */ static int fimc_lite_link_setup(struct media_entity *entity, const struct media_pad *local,