From patchwork Thu Dec 8 15:24:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 9466521 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 AB49F607D4 for ; Thu, 8 Dec 2016 15:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C216285A7 for ; Thu, 8 Dec 2016 15:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FCED285B2; Thu, 8 Dec 2016 15:25:52 +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=-6.9 required=2.0 tests=BAYES_00,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 B91AE285A7 for ; Thu, 8 Dec 2016 15:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbcLHPZd (ORCPT ); Thu, 8 Dec 2016 10:25:33 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:42997 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbcLHPZc (ORCPT ); Thu, 8 Dec 2016 10:25:32 -0500 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cF0Yj-0007RP-3m; Thu, 08 Dec 2016 16:24:33 +0100 Received: from mtr by dude.hi.pengutronix.de with local (Exim 4.88) (envelope-from ) id 1cF0Yi-0007Q5-Sv; Thu, 08 Dec 2016 16:24:32 +0100 From: Michael Tretter To: linux-media@vger.kernel.org Cc: p.zabel@pengutronix.de, Michael Tretter Subject: [PATCH 5/9] [media] coda: get VDOA device using dt phandle Date: Thu, 8 Dec 2016 16:24:12 +0100 Message-Id: <20161208152416.16031-5-m.tretter@pengutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161208152416.16031-1-m.tretter@pengutronix.de> References: <20161208152416.16031-1-m.tretter@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org 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 Signed-off-by: Michael Tretter --- drivers/media/platform/coda/coda-common.c | 43 +++++++++++++++++++++++++++++++ drivers/media/platform/coda/coda.h | 1 + 2 files changed, 44 insertions(+) diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index e0184194..1adb6f3 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -41,6 +41,7 @@ #include #include "coda.h" +#include "imx-vdoa.h" #define CODA_NAME "coda" @@ -66,6 +67,10 @@ static int disable_tiling; module_param(disable_tiling, int, 0644); MODULE_PARM_DESC(disable_tiling, "Disable tiled frame buffers"); +static int disable_vdoa; +module_param(disable_vdoa, int, 0644); +MODULE_PARM_DESC(disable_vdoa, "Disable Video Data Order Adapter tiled to raster-scan conversion"); + void coda_write(struct coda_dev *dev, u32 data, u32 reg) { v4l2_dbg(2, coda_debug, &dev->v4l2_dev, @@ -325,6 +330,34 @@ const char *coda_product_name(int product) } } +static struct vdoa_data *coda_get_vdoa_data(struct device_node *np, + const char *name) +{ + struct device_node *vdoa_node; + struct platform_device *vdoa_pdev; + struct vdoa_data *vdoa_data; + + vdoa_node = of_parse_phandle(np, name, 0); + if (!vdoa_node) + return NULL; + + vdoa_pdev = of_find_device_by_node(vdoa_node); + if (!vdoa_pdev) { + vdoa_data = NULL; + goto out; + } + + vdoa_data = platform_get_drvdata(vdoa_pdev); + if (!vdoa_data) + vdoa_data = ERR_PTR(-EPROBE_DEFER); + +out: + if (vdoa_node) + of_node_put(vdoa_node); + + return vdoa_data; +} + /* * V4L2 ioctl() operations. */ @@ -2256,6 +2289,16 @@ static int coda_probe(struct platform_device *pdev) } dev->iram_pool = pool; + /* Get VDOA from device tree if available */ + if (!disable_tiling && !disable_vdoa) { + dev->vdoa = coda_get_vdoa_data(np, "vdoa"); + if (PTR_ERR(dev->vdoa) == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!dev->vdoa) + dev_info(&pdev->dev, + "vdoa not available; not using tiled intermediate format"); + } + ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) return ret; diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/coda/coda.h index 53f9666..ae202dc 100644 --- a/drivers/media/platform/coda/coda.h +++ b/drivers/media/platform/coda/coda.h @@ -75,6 +75,7 @@ struct coda_dev { struct platform_device *plat_dev; const struct coda_devtype *devtype; int firmware; + struct vdoa_data *vdoa; void __iomem *regs_base; struct clk *clk_per;