From patchwork Thu May 16 01:14:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945445 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E45B17EE for ; Thu, 16 May 2019 01:46:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0BB72874A for ; Thu, 16 May 2019 01:46:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4ACD288BD; Thu, 16 May 2019 01:46:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E298288AD for ; Thu, 16 May 2019 01:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbfEPBqg (ORCPT ); Wed, 15 May 2019 21:46:36 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:58987 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726927AbfEPBPE (ORCPT ); Wed, 15 May 2019 21:15:04 -0400 X-Halon-ID: 05dc61c1-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 05dc61c1-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:14:59 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 1/8] rcar-vin: Do not call pm_runtime_{resume,suspend}() Date: Thu, 16 May 2019 03:14:10 +0200 Message-Id: <20190516011417.10590-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver does not implement runtime resume and suspend function so there is little point in trying to call them. This is a leftover from the drivers soc_camera beginnings. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 7cbdcbf9b090c638..b821ea01786eb1ff 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -798,9 +798,6 @@ static int rvin_initialize_device(struct file *file) return ret; pm_runtime_enable(&vin->vdev.dev); - ret = pm_runtime_resume(&vin->vdev.dev); - if (ret < 0 && ret != -ENOSYS) - goto eresume; /* * Try to configure with default parameters. Notice: this is the @@ -817,7 +814,6 @@ static int rvin_initialize_device(struct file *file) return 0; esfmt: pm_runtime_disable(&vin->vdev.dev); -eresume: rvin_power_off(vin); return ret; @@ -868,7 +864,6 @@ static int rvin_release(struct file *file) * Then de-initialize hw module. */ if (fh_singular) { - pm_runtime_suspend(&vin->vdev.dev); pm_runtime_disable(&vin->vdev.dev); rvin_power_off(vin); } From patchwork Thu May 16 01:14:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945479 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3B84912 for ; Thu, 16 May 2019 01:48:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D61872874A for ; Thu, 16 May 2019 01:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA11B288AD; Thu, 16 May 2019 01:48:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8226D2874A for ; Thu, 16 May 2019 01:48:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726927AbfEPBqh (ORCPT ); Wed, 15 May 2019 21:46:37 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:38162 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726928AbfEPBPF (ORCPT ); Wed, 15 May 2019 21:15:05 -0400 X-Halon-ID: 074218d5-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 074218d5-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:01 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 2/8] rcar-vin: Remove unneeded calls to pm_runtime_{enable,disable} Date: Thu, 16 May 2019 03:14:11 +0200 Message-Id: <20190516011417.10590-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Runtime PM is already enabled unconditionally when the driver is probed and disabled when it's removed. There is no point in doing it again for Gen2 when opening and closing the video device. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index b821ea01786eb1ff..0841f1a0bfd7ba3a 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -797,8 +797,6 @@ static int rvin_initialize_device(struct file *file) if (ret < 0) return ret; - pm_runtime_enable(&vin->vdev.dev); - /* * Try to configure with default parameters. Notice: this is the * very first open, so, we cannot race against other calls, @@ -813,7 +811,6 @@ static int rvin_initialize_device(struct file *file) return 0; esfmt: - pm_runtime_disable(&vin->vdev.dev); rvin_power_off(vin); return ret; @@ -863,10 +860,8 @@ static int rvin_release(struct file *file) * If this was the last open file. * Then de-initialize hw module. */ - if (fh_singular) { - pm_runtime_disable(&vin->vdev.dev); + if (fh_singular) rvin_power_off(vin); - } mutex_unlock(&vin->lock); From patchwork Thu May 16 01:14:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945477 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6C511390 for ; Thu, 16 May 2019 01:48:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C607D2874A for ; Thu, 16 May 2019 01:48:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA65728871; Thu, 16 May 2019 01:48:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68E152874A for ; Thu, 16 May 2019 01:48:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727540AbfEPBqh (ORCPT ); Wed, 15 May 2019 21:46:37 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:59014 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbfEPBPH (ORCPT ); Wed, 15 May 2019 21:15:07 -0400 X-Halon-ID: 08405dd3-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 08405dd3-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:03 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 3/8] rcar-vin: Allow interrupting lock when trying to open the video device Date: Thu, 16 May 2019 03:14:12 +0200 Message-Id: <20190516011417.10590-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The user should be allowed to break waiting for the lock when opening the video device. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht Reviewed-by: Laurent Pinchart --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 0841f1a0bfd7ba3a..f67cef97b89a3bd4 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -821,7 +821,9 @@ static int rvin_open(struct file *file) struct rvin_dev *vin = video_drvdata(file); int ret; - mutex_lock(&vin->lock); + ret = mutex_lock_interruptible(&vin->lock); + if (ret) + return ret; file->private_data = vin; From patchwork Thu May 16 01:14:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945475 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4DCD1708 for ; Thu, 16 May 2019 01:48:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D370F2874A for ; Thu, 16 May 2019 01:48:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C791428871; Thu, 16 May 2019 01:48:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 744E42874A for ; Thu, 16 May 2019 01:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726937AbfEPBqh (ORCPT ); Wed, 15 May 2019 21:46:37 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:59029 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbfEPBPK (ORCPT ); Wed, 15 May 2019 21:15:10 -0400 X-Halon-ID: 096dcc77-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 096dcc77-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:05 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 4/8] rcar-vin: Do not sync subdevice format when opening the video device Date: Thu, 16 May 2019 03:14:13 +0200 Message-Id: <20190516011417.10590-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The format is already synced when the subdevice is bound, there is no need to do do it every time the video device is opened. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht Reviewed-by: Laurent Pinchart --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 25 --------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index f67cef97b89a3bd4..71651c5a69483367 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -782,38 +782,13 @@ static int rvin_initialize_device(struct file *file) struct rvin_dev *vin = video_drvdata(file); int ret; - struct v4l2_format f = { - .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, - .fmt.pix = { - .width = vin->format.width, - .height = vin->format.height, - .field = vin->format.field, - .colorspace = vin->format.colorspace, - .pixelformat = vin->format.pixelformat, - }, - }; - ret = rvin_power_on(vin); if (ret < 0) return ret; - /* - * Try to configure with default parameters. Notice: this is the - * very first open, so, we cannot race against other calls, - * apart from someone else calling open() simultaneously, but - * .host_lock is protecting us against it. - */ - ret = rvin_s_fmt_vid_cap(file, NULL, &f); - if (ret < 0) - goto esfmt; - v4l2_ctrl_handler_setup(&vin->ctrl_handler); return 0; -esfmt: - rvin_power_off(vin); - - return ret; } static int rvin_open(struct file *file) From patchwork Thu May 16 01:14:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945469 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CF81912 for ; Thu, 16 May 2019 01:48:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C5FC2874A for ; Thu, 16 May 2019 01:48:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4134F288AD; Thu, 16 May 2019 01:48:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAE162874A for ; Thu, 16 May 2019 01:48:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726580AbfEPBqi (ORCPT ); Wed, 15 May 2019 21:46:38 -0400 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:54613 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbfEPBPM (ORCPT ); Wed, 15 May 2019 21:15:12 -0400 X-Halon-ID: 0b37a071-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 0b37a071-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:08 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 5/8] rcar-vin: Move pm_runtime_{get,put} out of helpers Date: Thu, 16 May 2019 03:14:14 +0200 Message-Id: <20190516011417.10590-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The helpers rvin_power_{on,off} deal with both VIN and the parallel subdevice power. This makes it hard to merge the Gen2 and Gen3 open/release functions. Move the VIN power handling directly to the open/release functions to prepare for the merge. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht Reviewed-by: Laurent Pinchart --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 34 +++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 71651c5a69483367..5a9658b7d848fc86 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -754,8 +754,6 @@ static int rvin_power_on(struct rvin_dev *vin) int ret; struct v4l2_subdev *sd = vin_to_source(vin); - pm_runtime_get_sync(vin->v4l2_dev.dev); - ret = v4l2_subdev_call(sd, core, s_power, 1); if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) return ret; @@ -768,9 +766,6 @@ static int rvin_power_off(struct rvin_dev *vin) struct v4l2_subdev *sd = vin_to_source(vin); ret = v4l2_subdev_call(sd, core, s_power, 0); - - pm_runtime_put(vin->v4l2_dev.dev); - if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) return ret; @@ -802,20 +797,31 @@ static int rvin_open(struct file *file) file->private_data = vin; + ret = pm_runtime_get_sync(vin->dev); + if (ret < 0) + goto err_unlock; + ret = v4l2_fh_open(file); if (ret) - goto unlock; + goto err_pm; - if (!v4l2_fh_is_singular_file(file)) - goto unlock; - - if (rvin_initialize_device(file)) { - v4l2_fh_release(file); - ret = -ENODEV; + if (v4l2_fh_is_singular_file(file)) { + if (rvin_initialize_device(file)) { + ret = -ENODEV; + goto err_open; + } } -unlock: mutex_unlock(&vin->lock); + + return 0; +err_open: + v4l2_fh_release(file); +err_pm: + pm_runtime_put(vin->dev); +err_unlock: + mutex_unlock(&vin->lock); + return ret; } @@ -840,6 +846,8 @@ static int rvin_release(struct file *file) if (fh_singular) rvin_power_off(vin); + pm_runtime_put(vin->dev); + mutex_unlock(&vin->lock); return ret; From patchwork Thu May 16 01:14:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945449 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E78B1390 for ; Thu, 16 May 2019 01:46:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F24F82874A for ; Thu, 16 May 2019 01:46:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6C1C288BD; Thu, 16 May 2019 01:46:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92F812874A for ; Thu, 16 May 2019 01:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726948AbfEPBqi (ORCPT ); Wed, 15 May 2019 21:46:38 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:10400 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726950AbfEPBPO (ORCPT ); Wed, 15 May 2019 21:15:14 -0400 X-Halon-ID: 0c63be46-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 0c63be46-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:10 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 6/8] rcar-vin: Merge helpers dealing with powering the parallel subdevice Date: Thu, 16 May 2019 03:14:15 +0200 Message-Id: <20190516011417.10590-7-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The two power helpers are now only dealing with the parallel subdevice, merge them into a single rvin_power_parallel() helper to reduce code duplication. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht Reviewed-by: Laurent Pinchart --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 5a9658b7d848fc86..7c8ba4b310706ceb 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -749,23 +749,13 @@ static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = { * File Operations */ -static int rvin_power_on(struct rvin_dev *vin) +static int rvin_power_parallel(struct rvin_dev *vin, bool on) { - int ret; struct v4l2_subdev *sd = vin_to_source(vin); - - ret = v4l2_subdev_call(sd, core, s_power, 1); - if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) - return ret; - return 0; -} - -static int rvin_power_off(struct rvin_dev *vin) -{ + int power = on ? 1 : 0; int ret; - struct v4l2_subdev *sd = vin_to_source(vin); - ret = v4l2_subdev_call(sd, core, s_power, 0); + ret = v4l2_subdev_call(sd, core, s_power, power); if (ret < 0 && ret != -ENOIOCTLCMD && ret != -ENODEV) return ret; @@ -777,7 +767,7 @@ static int rvin_initialize_device(struct file *file) struct rvin_dev *vin = video_drvdata(file); int ret; - ret = rvin_power_on(vin); + ret = rvin_power_parallel(vin, true); if (ret < 0) return ret; @@ -844,7 +834,7 @@ static int rvin_release(struct file *file) * Then de-initialize hw module. */ if (fh_singular) - rvin_power_off(vin); + rvin_power_parallel(vin, false); pm_runtime_put(vin->dev); From patchwork Thu May 16 01:14:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945451 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 620721708 for ; Thu, 16 May 2019 01:46:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F5602874A for ; Thu, 16 May 2019 01:46:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4386128871; Thu, 16 May 2019 01:46:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDE6F288AD for ; Thu, 16 May 2019 01:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726898AbfEPBqj (ORCPT ); Wed, 15 May 2019 21:46:39 -0400 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:56137 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbfEPBPQ (ORCPT ); Wed, 15 May 2019 21:15:16 -0400 X-Halon-ID: 0d90662a-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 0d90662a-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:12 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 7/8] rcar-vin: Fold rvin_initialize_device() into rvin_open() Date: Thu, 16 May 2019 03:14:16 +0200 Message-Id: <20190516011417.10590-8-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function no longer serve a purpose as most tasks it performed have been refactored, fold what remains of it into the only caller. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 7c8ba4b310706ceb..169639416121f204 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -762,20 +762,6 @@ static int rvin_power_parallel(struct rvin_dev *vin, bool on) return 0; } -static int rvin_initialize_device(struct file *file) -{ - struct rvin_dev *vin = video_drvdata(file); - int ret; - - ret = rvin_power_parallel(vin, true); - if (ret < 0) - return ret; - - v4l2_ctrl_handler_setup(&vin->ctrl_handler); - - return 0; -} - static int rvin_open(struct file *file) { struct rvin_dev *vin = video_drvdata(file); @@ -796,10 +782,11 @@ static int rvin_open(struct file *file) goto err_pm; if (v4l2_fh_is_singular_file(file)) { - if (rvin_initialize_device(file)) { - ret = -ENODEV; + ret = rvin_power_parallel(vin, true); + if (ret < 0) goto err_open; - } + + v4l2_ctrl_handler_setup(&vin->ctrl_handler); } mutex_unlock(&vin->lock); From patchwork Thu May 16 01:14:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10945463 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9ED94912 for ; Thu, 16 May 2019 01:48:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DB542874A for ; Thu, 16 May 2019 01:48:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80D6B288AD; Thu, 16 May 2019 01:48:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A9F22874A for ; Thu, 16 May 2019 01:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727010AbfEPBqj (ORCPT ); Wed, 15 May 2019 21:46:39 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:63414 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbfEPBPT (ORCPT ); Wed, 15 May 2019 21:15:19 -0400 X-Halon-ID: 0ed3fabe-7778-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 0ed3fabe-7778-11e9-8ab4-005056917a89; Thu, 16 May 2019 03:15:14 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Ulrich Hecht , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Ulrich Hecht Subject: [PATCH v2 8/8] rcar-vin: Merge Gen2 and Gen3 file operations Date: Thu, 16 May 2019 03:14:17 +0200 Message-Id: <20190516011417.10590-9-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> References: <20190516011417.10590-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After the rework of the Gen2 file operations it's now trivial to merge the Gen2 and Gen3 versions. Signed-off-by: Niklas Söderlund Reviewed-by: Ulrich Hecht --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 96 ++++----------------- 1 file changed, 16 insertions(+), 80 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 169639416121f204..8e4afa4278fe9d30 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -781,14 +781,19 @@ static int rvin_open(struct file *file) if (ret) goto err_pm; - if (v4l2_fh_is_singular_file(file)) { - ret = rvin_power_parallel(vin, true); + if (vin->info->use_mc) { + ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1); if (ret < 0) goto err_open; + } else { + if (v4l2_fh_is_singular_file(file)) { + ret = rvin_power_parallel(vin, true); + if (ret < 0) + goto err_open; - v4l2_ctrl_handler_setup(&vin->ctrl_handler); + v4l2_ctrl_handler_setup(&vin->ctrl_handler); + } } - mutex_unlock(&vin->lock); return 0; @@ -816,12 +821,12 @@ static int rvin_release(struct file *file) /* the release helper will cleanup any on-going streaming */ ret = _vb2_fop_release(file, NULL); - /* - * If this was the last open file. - * Then de-initialize hw module. - */ - if (fh_singular) - rvin_power_parallel(vin, false); + if (vin->info->use_mc) { + v4l2_pipeline_pm_use(&vin->vdev.entity, 0); + } else { + if (fh_singular) + rvin_power_parallel(vin, false); + } pm_runtime_put(vin->dev); @@ -840,74 +845,6 @@ static const struct v4l2_file_operations rvin_fops = { .read = vb2_fop_read, }; -/* ----------------------------------------------------------------------------- - * Media controller file operations - */ - -static int rvin_mc_open(struct file *file) -{ - struct rvin_dev *vin = video_drvdata(file); - int ret; - - ret = mutex_lock_interruptible(&vin->lock); - if (ret) - return ret; - - ret = pm_runtime_get_sync(vin->dev); - if (ret < 0) - goto err_unlock; - - ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1); - if (ret < 0) - goto err_pm; - - file->private_data = vin; - - ret = v4l2_fh_open(file); - if (ret) - goto err_v4l2pm; - - mutex_unlock(&vin->lock); - - return 0; -err_v4l2pm: - v4l2_pipeline_pm_use(&vin->vdev.entity, 0); -err_pm: - pm_runtime_put(vin->dev); -err_unlock: - mutex_unlock(&vin->lock); - - return ret; -} - -static int rvin_mc_release(struct file *file) -{ - struct rvin_dev *vin = video_drvdata(file); - int ret; - - mutex_lock(&vin->lock); - - /* the release helper will cleanup any on-going streaming. */ - ret = _vb2_fop_release(file, NULL); - - v4l2_pipeline_pm_use(&vin->vdev.entity, 0); - pm_runtime_put(vin->dev); - - mutex_unlock(&vin->lock); - - return ret; -} - -static const struct v4l2_file_operations rvin_mc_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = video_ioctl2, - .open = rvin_mc_open, - .release = rvin_mc_release, - .poll = vb2_fop_poll, - .mmap = vb2_fop_mmap, - .read = vb2_fop_read, -}; - void rvin_v4l2_unregister(struct rvin_dev *vin) { if (!video_is_registered(&vin->vdev)) @@ -948,6 +885,7 @@ int rvin_v4l2_register(struct rvin_dev *vin) snprintf(vdev->name, sizeof(vdev->name), "VIN%u output", vin->id); vdev->release = video_device_release_empty; vdev->lock = &vin->lock; + vdev->fops = &rvin_fops; vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; @@ -959,10 +897,8 @@ int rvin_v4l2_register(struct rvin_dev *vin) vin->format.colorspace = RVIN_DEFAULT_COLORSPACE; if (vin->info->use_mc) { - vdev->fops = &rvin_mc_fops; vdev->ioctl_ops = &rvin_mc_ioctl_ops; } else { - vdev->fops = &rvin_fops; vdev->ioctl_ops = &rvin_ioctl_ops; rvin_reset_format(vin); }