From patchwork Tue Mar 26 18:38:21 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: 2343541 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 CFE363FC54 for ; Tue, 26 Mar 2013 18:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760125Ab3CZSjJ (ORCPT ); Tue, 26 Mar 2013 14:39:09 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:51566 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760098Ab3CZSjH (ORCPT ); Tue, 26 Mar 2013 14:39:07 -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 <0MKA004IA6GW9O70@mailout3.samsung.com>; Wed, 27 Mar 2013 03:39:06 +0900 (KST) X-AuditID: cbfee61b-b7f076d0000034b6-b2-5151eb4a714b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B0.11.13494.A4BE1515; Wed, 27 Mar 2013 03:39:06 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MKA00K8O6G0S100@mmp2.samsung.com>; Wed, 27 Mar 2013 03:39:06 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, myungjoo.ham@samsung.com, dh09.lee@samsung.com, shaik.samsung@gmail.com, arun.kk@samsung.com, a.hajda@samsung.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH v2 5/5] exynos4-is: Ensure proper media pipeline state on device close Date: Tue, 26 Mar 2013 19:38:21 +0100 Message-id: <1364323101-22046-10-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1364323101-22046-1-git-send-email-s.nawrocki@samsung.com> References: <1364323101-22046-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jQV2v14GBBodbDSxurTvHavHx1G1W i+vn7SzONr1ht+jZsJXVYsb5fUwWtxtXsFkcftPOarFu5yR2B06PnbPusnv0bVnF6PF5k1wA cxSXTUpqTmZZapG+XQJXxul/Z5gLNqtUtM6ezd7AuFOui5GTQ0LARGLv3/PMELaYxIV769m6 GLk4hASmM0r8vz2PGcLpYJJYePEoG0gVm4ChRO/RPkYQW0RAXuJJ7w2wDmaBJ4wSf04cYAJJ CAtESJxsXAdmswioSqyZfJ4FxOYVcJc4uX4hUAMH0DoFiTmTbEDCnEDhf303wGYKCbhJzGr4 zTqBkXcBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOCgeia9g3FVg8UhRgEORiUeXo6w gEAh1sSy4srcQ4wSHMxKIryCGwMDhXhTEiurUovy44tKc1KLDzFKc7AoifMebLUOFBJITyxJ zU5NLUgtgskycXBKNTBqGYZbtFWsUBaesvzpZEdjubmm6ndN3Yy0LGfUvriSbiMy1+RiR7nX AoN3FZfrq1ZfFJrceenM11Xf94TO2Kj+79nH//znHB99luipCA2I6yx6cmi96qa+1BkVri9X +/T2cr8oXF4gc685wuauU2DWP6c9fgv3Pr5SNyNWUJdt14ltOhVH4w8rsRRnJBpqMRcVJwIA cxLMvSYCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Make sure media_entity_pipeline_stop() is called on video device close in cases where there was VIDIOC_STREAMON ioctl and no VIDIOC_STREAMOFF. This patch fixes media entities stream_count state which could prevent links from being disconnected, due to non-zero stream_count. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/platform/exynos4-is/fimc-capture.c | 18 +++++++++++++----- drivers/media/platform/exynos4-is/fimc-core.h | 1 + drivers/media/platform/exynos4-is/fimc-lite.c | 18 ++++++++++++++---- drivers/media/platform/exynos4-is/fimc-lite.h | 1 + 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index b9c0817..0ae6bdb 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -551,6 +551,7 @@ unlock: static int fimc_capture_release(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); + struct fimc_vid_cap *vc = &fimc->vid_cap; int ret; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); @@ -558,6 +559,10 @@ static int fimc_capture_release(struct file *file) mutex_lock(&fimc->lock); if (v4l2_fh_is_singular_file(file)) { + if (vc->streaming) { + media_entity_pipeline_stop(&vc->vfd.entity); + vc->streaming = false; + } clear_bit(ST_CAPT_BUSY, &fimc->state); fimc_stop_capture(fimc, false); fimc_pipeline_call(fimc, close, &fimc->pipeline); @@ -1243,8 +1248,10 @@ static int fimc_cap_streamon(struct file *file, void *priv, } ret = vb2_ioctl_streamon(file, priv, type); - if (!ret) + if (!ret) { + vc->streaming = true; return ret; + } err_p_stop: media_entity_pipeline_stop(entity); @@ -1258,11 +1265,12 @@ static int fimc_cap_streamoff(struct file *file, void *priv, int ret; ret = vb2_ioctl_streamoff(file, priv, type); + if (ret < 0) + return ret; - if (ret == 0) - media_entity_pipeline_stop(&fimc->vid_cap.vfd.entity); - - return ret; + media_entity_pipeline_stop(&fimc->vid_cap.vfd.entity); + fimc->vid_cap.streaming = false; + return 0; } static int fimc_cap_reqbufs(struct file *file, void *priv, diff --git a/drivers/media/platform/exynos4-is/fimc-core.h b/drivers/media/platform/exynos4-is/fimc-core.h index 793333a..de2b57e 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.h +++ b/drivers/media/platform/exynos4-is/fimc-core.h @@ -318,6 +318,7 @@ struct fimc_vid_cap { int buf_index; unsigned int frame_count; unsigned int reqbufs_count; + bool streaming; int input_index; int refcnt; u32 input; diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index b11e358..cb196b8 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -507,6 +507,10 @@ static int fimc_lite_release(struct file *file) if (v4l2_fh_is_singular_file(file) && atomic_read(&fimc->out_path) == FIMC_IO_DMA) { + if (fimc->streaming) { + media_entity_pipeline_stop(&fimc->vfd.entity); + fimc->streaming = false; + } clear_bit(ST_FLITE_IN_USE, &fimc->state); fimc_lite_stop_capture(fimc, false); fimc_pipeline_call(fimc, close, &fimc->pipeline); @@ -798,8 +802,11 @@ static int fimc_lite_streamon(struct file *file, void *priv, goto err_p_stop; ret = vb2_ioctl_streamon(file, priv, type); - if (!ret) + if (!ret) { + fimc->streaming = true; return ret; + } + err_p_stop: media_entity_pipeline_stop(entity); return 0; @@ -812,9 +819,12 @@ static int fimc_lite_streamoff(struct file *file, void *priv, int ret; ret = vb2_ioctl_streamoff(file, priv, type); - if (ret == 0) - media_entity_pipeline_stop(&fimc->vfd.entity); - return ret; + if (ret < 0) + return ret; + + media_entity_pipeline_stop(&fimc->vfd.entity); + fimc->streaming = false; + return 0; } static int fimc_lite_reqbufs(struct file *file, void *priv, diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h b/drivers/media/platform/exynos4-is/fimc-lite.h index 8a8d26f..71fed51 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.h +++ b/drivers/media/platform/exynos4-is/fimc-lite.h @@ -166,6 +166,7 @@ struct fimc_lite { int ref_count; struct fimc_lite_events events; + bool streaming; }; static inline bool fimc_lite_active(struct fimc_lite *fimc)