From patchwork Fri Jan 5 17:49:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10146861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE33F60244 for ; Fri, 5 Jan 2018 17:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9917928689 for ; Fri, 5 Jan 2018 17:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BB562876D; Fri, 5 Jan 2018 17:49:58 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 024B228689 for ; Fri, 5 Jan 2018 17:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbeAERt4 (ORCPT ); Fri, 5 Jan 2018 12:49:56 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35754 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752013AbeAERtz (ORCPT ); Fri, 5 Jan 2018 12:49:55 -0500 Received: by mail-pl0-f67.google.com with SMTP id b96so3440478pli.2 for ; Fri, 05 Jan 2018 09:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=c1rO/3zcQUCxKceWG3vIpJjc++38JRfQ3FTO7eSSlBc=; b=ThasXOq49/gwyUHFdU5gxwf0gkYnl9HWkgaZO5w3jIJaC6IsxzjHZKr7Qcda56cZ4I PoLhx4HayOxcfHJoAWSU7wuQKX2qzRG2/3JjtHmvBOoxOvE7+xdjvIS4xngV6h3quhm9 gWgbq0ACcWl8Pp6tDnNyS68OYBxUC7+is7s39iIYE0tXiUxeidm0g/GsEfvpnwo6x2ok Iqax57m7DBRG5JH3EJadbZDaNrAJ5t1JU8+0tpi/RSOREZbPZykFIAxCdcbWesn9L/zg X2GEozLm640L6LjOBa+ydF8HaI2fMU9H+ygl6Jza23ZYaeUsHdSrZwJqy2pUO/IRQtST 3cZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c1rO/3zcQUCxKceWG3vIpJjc++38JRfQ3FTO7eSSlBc=; b=sXZBM78jfQa7Wda7aCcgLJtk94Q+ny5IoISv8dhNF3nmEuPJ79kr4AeBL0QBrS7ALX cYyra4TCKusPQzN/iOjHESp+70v+G44cW1iZ4ApcDtWRSo4aCw7hmSVbjH/ZviOHVsd+ Lbo3C1PykosPM5lFYC5IBh5HtXq5PMjk7+RaVTUy6RrbuTJEtEP91LLGV3eftDOL2N3d lEHQuBipKSwenK/drtp0Uu4fr0r1yXfZkrgv0WBkVkR58yo9IBOPb3TzhsdSGBad0BKo rjFPxSHP+2lIv0jhgdtT48XRpJNggFZEp3y+mz9NHAAgEhf4I/Pm5+cKNlXk+DyQjCJ2 jhFQ== X-Gm-Message-State: AKGB3mKzF+Si9FszuAq5/AOozJk2ZZSgJJYFaufUq7Jg2QQcre7FMAvf J+9I8oGlkGOra/b+OB7uyZfdww== X-Google-Smtp-Source: ACJfBovzybaP9L93E2BQ5bj93nohyjceMAPOVj2pAVn31EItescUndIPinQK5psEXn/6QZMTZlFi9g== X-Received: by 10.84.240.197 with SMTP id l5mr3947285plt.410.1515174595097; Fri, 05 Jan 2018 09:49:55 -0800 (PST) Received: from localhost.localdomain ([240f:4:c2bc:1:d9a6:e4e2:87de:9764]) by smtp.gmail.com with ESMTPSA id p10sm11312961pgq.23.2018.01.05.09.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 09:49:54 -0800 (PST) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Hyun Kwon , Laurent Pinchart Subject: [PATCH] media: xilinx-video: support pipeline power management Date: Sat, 6 Jan 2018 02:49:43 +0900 Message-Id: <1515174583-31183-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This enables pipeline power management for Xilinx Video IP driver. Some V4L2 subdevices are put their power status into power down mode after their probe function, and require to be powered up by calling s_power() operation when the pipeline is in use. So this change is necessary if the video pipeline contains such a V4L2 subdevice. Cc: Hyun Kwon Cc: Laurent Pinchart Signed-off-by: Akinobu Mita --- drivers/media/platform/xilinx/xilinx-dma.c | 35 +++++++++++++++++++++++++++-- drivers/media/platform/xilinx/xilinx-vipp.c | 7 +++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 522cdfd..cd0b846 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -644,11 +645,41 @@ static const struct v4l2_ioctl_ops xvip_dma_ioctl_ops = { * V4L2 file operations */ +static int xvip_dma_open(struct file *file) +{ + struct video_device *vdev = video_devdata(file); + int ret; + + ret = v4l2_pipeline_pm_use(&vdev->entity, 1); + if (ret) + return ret; + + ret = v4l2_fh_open(file); + if (ret) + v4l2_pipeline_pm_use(&vdev->entity, 0); + + return ret; +} + +static int xvip_dma_release(struct file *file) +{ + struct video_device *vdev = video_devdata(file); + int ret; + + ret = vb2_fop_release(file); + if (ret) + return ret; + + v4l2_pipeline_pm_use(&vdev->entity, 0); + + return 0; +} + static const struct v4l2_file_operations xvip_dma_fops = { .owner = THIS_MODULE, .unlocked_ioctl = video_ioctl2, - .open = v4l2_fh_open, - .release = vb2_fop_release, + .open = xvip_dma_open, + .release = xvip_dma_release, .poll = vb2_fop_poll, .mmap = vb2_fop_mmap, }; diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index f4c3e48..6d098e3 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "xilinx-dma.h" #include "xilinx-vipp.h" @@ -573,6 +574,10 @@ static void xvip_composite_v4l2_cleanup(struct xvip_composite_device *xdev) media_device_cleanup(&xdev->media_dev); } +static const struct media_device_ops xvip_media_ops = { + .link_notify = v4l2_pipeline_link_notify, +}; + static int xvip_composite_v4l2_init(struct xvip_composite_device *xdev) { int ret; @@ -581,7 +586,7 @@ static int xvip_composite_v4l2_init(struct xvip_composite_device *xdev) strlcpy(xdev->media_dev.model, "Xilinx Video Composite Device", sizeof(xdev->media_dev.model)); xdev->media_dev.hw_revision = 0; - + xdev->media_dev.ops = &xvip_media_ops; media_device_init(&xdev->media_dev); xdev->v4l2_dev.mdev = &xdev->media_dev;