From patchwork Wed Nov 2 13:23:04 2016 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: 9409153 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 7349860724 for ; Wed, 2 Nov 2016 13:30:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60F122A17B for ; Wed, 2 Nov 2016 13:30:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5421B2A17E; Wed, 2 Nov 2016 13:30:30 +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=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 DE5A12A17B for ; Wed, 2 Nov 2016 13:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754423AbcKBN3l (ORCPT ); Wed, 2 Nov 2016 09:29:41 -0400 Received: from smtp-4.sys.kth.se ([130.237.48.193]:49477 "EHLO smtp-4.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754175AbcKBN3i (ORCPT ); Wed, 2 Nov 2016 09:29:38 -0400 Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id CCC8C3289; Wed, 2 Nov 2016 14:29:36 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id CTTKpenvcZEd; Wed, 2 Nov 2016 14:29:36 +0100 (CET) X-KTH-Auth: niso [89.233.230.99] X-KTH-mail-from: niklas.soderlund+renesas@ragnatech.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id B0D8B1E7E; Wed, 2 Nov 2016 14:29:35 +0100 (CET) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Laurent Pinchart , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, tomoharu.fukawa.eb@renesas.com, Sakari Ailus , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH 07/32] media: rcar-vin: add wrapper to get rvin_graph_entity Date: Wed, 2 Nov 2016 14:23:04 +0100 Message-Id: <20161102132329.436-8-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161102132329.436-1-niklas.soderlund+renesas@ragnatech.se> References: <20161102132329.436-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 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 Update the driver to retrieve the code and mbus_cfg values from a rvin_graph_entity retrieved from a wrapper function instead of directly accessing the entity for the digital port. This is done to prepare for Gen3 support where the subdeivce might change during runtime, so to directly accesses a specific rvin_graph_entity is bad. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-core.c | 9 +++++++++ drivers/media/platform/rcar-vin/rcar-dma.c | 15 ++++++++++----- drivers/media/platform/rcar-vin/rcar-v4l2.c | 6 +++++- drivers/media/platform/rcar-vin/rcar-vin.h | 1 + 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 098a0b1..89a9280 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -26,6 +26,15 @@ #include "rcar-vin.h" /* ----------------------------------------------------------------------------- + * Subdevice helpers + */ + +struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin) +{ + return &vin->digital; +} + +/* ----------------------------------------------------------------------------- * Async notifier */ diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index 9ccd5ff..eac5c19 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -131,10 +131,15 @@ static u32 rvin_read(struct rvin_dev *vin, u32 offset) static int rvin_setup(struct rvin_dev *vin) { + struct rvin_graph_entity *rent; u32 vnmc, dmr, dmr2, interrupts; v4l2_std_id std; bool progressive = false, output_is_yuv = false, input_is_yuv = false; + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; + switch (vin->format.field) { case V4L2_FIELD_TOP: vnmc = VNMC_IM_ODD; @@ -174,7 +179,7 @@ static int rvin_setup(struct rvin_dev *vin) /* * Input interface */ - switch (vin->digital.code) { + switch (rent->code) { case MEDIA_BUS_FMT_YUYV8_1X16: /* BT.601/BT.1358 16bit YCbCr422 */ vnmc |= VNMC_INF_YUV16; @@ -182,7 +187,7 @@ static int rvin_setup(struct rvin_dev *vin) break; case MEDIA_BUS_FMT_UYVY8_2X8: /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ - vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ? + vnmc |= rent->mbus_cfg.type == V4L2_MBUS_BT656 ? VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; input_is_yuv = true; break; @@ -191,7 +196,7 @@ static int rvin_setup(struct rvin_dev *vin) break; case MEDIA_BUS_FMT_UYVY10_2X10: /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */ - vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ? + vnmc |= rent->mbus_cfg.type == V4L2_MBUS_BT656 ? VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601; input_is_yuv = true; break; @@ -203,11 +208,11 @@ static int rvin_setup(struct rvin_dev *vin) dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1); /* Hsync Signal Polarity Select */ - if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) + if (!(rent->mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) dmr2 |= VNDMR2_HPS; /* Vsync Signal Polarity Select */ - if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) + if (!(rent->mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) dmr2 |= VNDMR2_VPS; /* diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index f9218f2..370bb18 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -164,6 +164,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin, { struct v4l2_subdev *sd; struct v4l2_subdev_pad_config *pad_cfg; + struct rvin_graph_entity *rent; struct v4l2_subdev_format format = { .which = which, }; @@ -171,8 +172,11 @@ static int __rvin_try_format_source(struct rvin_dev *vin, int ret; sd = vin_to_source(vin); + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; - v4l2_fill_mbus_format(&format.format, pix, vin->digital.code); + v4l2_fill_mbus_format(&format.format, pix, rent->code); pad_cfg = v4l2_subdev_alloc_pad_config(sd); if (pad_cfg == NULL) diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h index 727e215..daec26a 100644 --- a/drivers/media/platform/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/rcar-vin/rcar-vin.h @@ -144,6 +144,7 @@ struct rvin_dev { struct v4l2_rect compose; }; +struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin); #define vin_to_source(vin) vin->digital.subdev /* Debug */