From patchwork Sun Jun 9 20:14:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 18819 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Ulm1j-0004NX-3c; Sun, 09 Jun 2013 22:15:47 +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.72/mailfrontend-7) with esmtp id 1Ulm1h-00011n-0H; Sun, 09 Jun 2013 22:15:47 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751315Ab3FIUPn (ORCPT + 1 other); Sun, 9 Jun 2013 16:15:43 -0400 Received: from mail-bk0-f50.google.com ([209.85.214.50]:45342 "EHLO mail-bk0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116Ab3FIUPm (ORCPT ); Sun, 9 Jun 2013 16:15:42 -0400 Received: by mail-bk0-f50.google.com with SMTP id ik8so1104224bkc.9 for ; Sun, 09 Jun 2013 13:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=/a68iuG9LXHzvgdPDKvnN0qH9wl3ahVl0Xq3IC5tzN8=; b=0O15UpKXdVSpJf5pkCUU/WvrXMDUNIQ+rfV1MgxlKL1kk7RYtyQURoD/LCchNstCKF LYfUkhvRG4nUYJJo6SEpvY3piyQSOhXzKSSjBqf66s1K/sMqqcy6g72/HR9tHiwdy3YR iuZYz5AtiG4VFPE9VwEmiB0x64SRM/JqDkH4rnSD3NurUi/DSuw/3EpGhwfXdvvLXz2X kJz+uOiLZKQ6dMFNA37cG34JTr7Xq06fBUHYQ1QL9M7ZEABZBNtSgXPd85VvgZpNoIiq Lm8V2BiuUzn5AlfWOSVTY2oQwkPLNzOMXWYB390zTPbeFW51IbiX+KKBTQfztgp7HkqG NpUA== X-Received: by 10.205.32.77 with SMTP id sj13mr1023319bkb.162.1370808941343; Sun, 09 Jun 2013 13:15:41 -0700 (PDT) Received: from localhost.localdomain (093105185086.warszawa.vectranet.pl. [93.105.185.86]) by mx.google.com with ESMTPSA id qw6sm1833109bkb.4.2013.06.09.13.15.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 09 Jun 2013 13:15:40 -0700 (PDT) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi, kyungmin.park@samsung.com, sw0312.kim@samsung.com, a.hajda@samsung.com, hj210.choi@samsung.com, shaik.ameer@samsung.com, arun.kk@samsung.com, s.nawrocki@samsung.com Subject: [REVIEW PATCH v3 2/2] exynos4-is: Extend link_notify handler to support fimc-is/lite pipelines Date: Sun, 9 Jun 2013 22:14:38 +0200 Message-Id: <1370808878-11379-3-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1370808878-11379-1-git-send-email-s.nawrocki@samsung.com> References: <1370808878-11379-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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.6.9.200321 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 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, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' This patch corrects the link_notify handler to support more complex pipelines, including fimc-lite and fimc-is entities. After the FIMC-IS driver addition the assumptions made in the link_notify callback are no longer valid, e.g. the link between fimc-lite subdev and its video node is not immutable any more and there is more subdevs than just sensor, MIPI-CSIS and FIMC(-LITE). The graph is now walked and for each video node found a media pipeline which ends at this node is disabled/enabled (the subdevs are powered on/off). Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- Changes since v1: - check link->flags instead of the flags argument of link_notify handler to see if the pipelines' should be powered back on. --- drivers/media/platform/exynos4-is/media-dev.c | 103 +++++++++++++++++++----- 1 files changed, 81 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 045a6ae..ec79ebb 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1287,39 +1287,98 @@ int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) return __fimc_md_set_camclk(fmd, si, on); } -static int fimc_md_link_notify(struct media_link *link, u32 flags, - unsigned int notification) +static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable) { - struct media_entity *sink = link->sink->entity; struct exynos_video_entity *ve; + struct fimc_pipeline *p; struct video_device *vdev; - struct fimc_pipeline *pipeline; - int i, ret = 0; + int ret; - if (media_entity_type(sink) != MEDIA_ENT_T_DEVNODE_V4L || - notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) + vdev = media_entity_to_video_device(entity); + if (vdev->entity.use_count == 0) return 0; - vdev = media_entity_to_video_device(sink); ve = vdev_to_exynos_video_entity(vdev); - pipeline = to_fimc_pipeline(ve->pipe); + p = to_fimc_pipeline(ve->pipe); + /* + * Nothing to do if we are disabling the pipeline, some link + * has been disconnected and p->subdevs array is cleared now. + */ + if (!enable && p->subdevs[IDX_SENSOR] == NULL) + return 0; - if (!(link->flags & MEDIA_LNK_FL_ENABLED) && pipeline->subdevs[IDX_SENSOR]) { - if (sink->use_count > 0) - ret = __fimc_pipeline_close(ve->pipe); + if (enable) + ret = __fimc_pipeline_open(ve->pipe, entity, true); + else + ret = __fimc_pipeline_close(ve->pipe); - for (i = 0; i < IDX_MAX; i++) - pipeline->subdevs[i] = NULL; - } else if (sink->use_count > 0) { - /* - * Link activation. Enable power of pipeline elements only if - * the pipeline is already in use, i.e. its video node is open. - * Recreate the controls destroyed during the link deactivation. - */ - ret = __fimc_pipeline_open(ve->pipe, sink, true); + if (ret == 0 && !enable) + memset(p->subdevs, 0, sizeof(p->subdevs)); + + return ret; +} + +/* Locking: called with entity->parent->graph_mutex mutex held. */ +static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) +{ + struct media_entity *entity_err = entity; + struct media_entity_graph graph; + int ret; + + /* + * Walk current graph and call the pipeline open/close routine for each + * opened video node that belongs to the graph of entities connected + * through active links. This is needed as we cannot power on/off the + * subdevs in random order. + */ + media_entity_graph_walk_start(&graph, entity); + + while ((entity = media_entity_graph_walk_next(&graph))) { + if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + continue; + + ret = __fimc_md_modify_pipeline(entity, enable); + + if (ret < 0) + goto err; + } + + return 0; + err: + media_entity_graph_walk_start(&graph, entity_err); + + while ((entity_err = media_entity_graph_walk_next(&graph))) { + if (media_entity_type(entity_err) != MEDIA_ENT_T_DEVNODE) + continue; + + __fimc_md_modify_pipeline(entity_err, !enable); + + if (entity_err == entity) + break; + } + + return ret; +} + +static int fimc_md_link_notify(struct media_link *link, unsigned int flags, + unsigned int notification) +{ + struct media_entity *sink = link->sink->entity; + int ret = 0; + + /* Before link disconnection */ + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { + if (!(flags & MEDIA_LNK_FL_ENABLED)) + ret = __fimc_md_modify_pipelines(sink, false); + else + ; /* TODO: Link state change validation */ + /* After link activation */ + } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && + (link->flags & MEDIA_LNK_FL_ENABLED)) { + ret = __fimc_md_modify_pipelines(sink, true); } - return ret ? -EPIPE : ret; + return ret ? -EPIPE : 0; } static ssize_t fimc_md_sysfs_show(struct device *dev,