From patchwork Wed Oct 8 08:46:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5052241 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E405D9F295 for ; Wed, 8 Oct 2014 08:47:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C63D201F2 for ; Wed, 8 Oct 2014 08:47:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08B5E2018E for ; Wed, 8 Oct 2014 08:47:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755051AbaJHIrO (ORCPT ); Wed, 8 Oct 2014 04:47:14 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:36241 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755015AbaJHIrM (ORCPT ); Wed, 8 Oct 2014 04:47:12 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ND4005U7B2MFY90@mailout3.samsung.com> for linux-media@vger.kernel.org; Wed, 08 Oct 2014 17:47:10 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-4d-5434fa0d71d5 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id CB.B5.09430.D0AF4345; Wed, 08 Oct 2014 17:47:09 +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 <0ND400IRIB275M60@mmp1.samsung.com>; Wed, 08 Oct 2014 17:47:09 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org, kyungmin.park@samsung.com Cc: s.nawrocki@samsung.com, Jacek Anaszewski Subject: [PATCH 3/3] exynos4-is: Open shouldn't fail when sensor entity is not linked Date: Wed, 08 Oct 2014 10:46:53 +0200 Message-id: <1412758013-23608-3-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1412758013-23608-1-git-send-email-j.anaszewski@samsung.com> References: <1412758013-23608-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKJMWRmVeSWpSXmKPExsVy+t9jAV3eXyYhBje+KFv0Xn3OaHG26Q27 Rc+GrawWh9+0szqwePRtWcXo8XmTXABTFJdNSmpOZllqkb5dAldGz/zlbAXXxSq2LnzN0sDY ItTFyMkhIWAi8bv9DRuELSZx4d56IJuLQ0hgEaPE5AtT2SGcdiaJF03PGUGq2AQMJX6+eM0E YosIWEls2P6KFcRmFnCXWNsyEcwWFgiXaFmyCMxmEVCVaHq5iR3E5hXwkDi48iBLFyMH0DYF iTmTbEDCnAKeEscXPgArEQIq+f/lOtsERt4FjAyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3 MYID45n0DsZVDRaHGAU4GJV4eA2aTUKEWBPLiitzDzFKcDArifBKngAK8aYkVlalFuXHF5Xm pBYfYpTmYFES5z3Yah0oJJCeWJKanZpakFoEk2Xi4JRqYOydsX7TT6nm6QJP2OQPB9/Q/ia0 8mf1hZWzKiddntP8QaToWnDRtTfF+xzttL6r3Nc15bdYnmDj0lYgP0+2U3GqU6LX26oOX8Zm h5mrfs0yuT6ZReiJe56z/Nq61UFanG3OCWbP1QMsBYSTQt4k5DBqMf9ql30zc62KRNHd3f11 XwVeX3x+Q4mlOCPRUIu5qDgRAB25uDgIAgAA 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 In order to allow for automatic media device entities linking from the level of libv4l plugin the open system call shouldn't fail, as the libv4l plugins can begin their job not until it succeeds. This patch allows for leaving the pipeline not linked on open and postpones verifying it to the moment when streamon callback is called. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- drivers/media/platform/exynos4-is/media-dev.c | 45 ++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index c867c46..3732663 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -217,7 +217,7 @@ static int __fimc_pipeline_open(struct exynos_media_pipeline *ep, fimc_pipeline_prepare(p, me); sd = p->subdevs[IDX_SENSOR]; - if (sd == NULL) + if (sd == NULL && !fmd->user_subdev_api) return -EINVAL; /* Disable PXLASYNC clock if this pipeline includes FIMC-IS */ @@ -277,10 +277,46 @@ static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on) { IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP }, }; struct fimc_pipeline *p = to_fimc_pipeline(ep); - int i, ret = 0; + struct fimc_md *fmd = entity_to_fimc_mdev(&p->subdevs[IDX_CSIS]->entity); + enum fimc_subdev_index sd_id; + int i = 0, ret = 0; - if (p->subdevs[IDX_SENSOR] == NULL) - return -ENODEV; + /* + * Sensor might not be discovered upon device open + * due to not linked pipeline. User space is expected to + * link the pipeline prior calling VIDIOC_STREAMON ioctl, + * when in user_subdev_api mode. + */ + while (p->subdevs[IDX_SENSOR] == NULL) { + /* + * Sensor must be already discovered if + * we are in non user_subdev_api mode. + */ + if (!fmd->user_subdev_api) { + return -ENODEV; + } else if (i++ == 0) { + /* Determine which entity is last in the pipeline */ + if (p->subdevs[IDX_FIMC]) + sd_id = IDX_FIMC; + else if (p->subdevs[IDX_IS_ISP]) + sd_id = IDX_IS_ISP; + else if (p->subdevs[IDX_FLITE]) + sd_id = IDX_FLITE; + else + return -ENODEV; + + ret = __fimc_pipeline_open(ep, + &p->subdevs[sd_id]->entity, + true); + if (ret < 0) + return ret; + + if (p->subdevs[IDX_SENSOR] == NULL) + return -ENODEV; + } else { + return -ENODEV; + } + } /* Wait until all devices in the chain are powered up */ async_synchronize_full_domain(&ep->async_domain); @@ -293,6 +329,7 @@ static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on) if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) goto error; } + return 0; error: for (; i >= 0; i--) {