From patchwork Wed Nov 2 13:23:05 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: 9409187 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 83AE160722 for ; Wed, 2 Nov 2016 13:30:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EF012A17E for ; Wed, 2 Nov 2016 13:30:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63F6D2A17F; Wed, 2 Nov 2016 13:30:57 +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 E0CBF2A17D for ; Wed, 2 Nov 2016 13:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755338AbcKBNax (ORCPT ); Wed, 2 Nov 2016 09:30:53 -0400 Received: from smtp-4.sys.kth.se ([130.237.48.193]:49486 "EHLO smtp-4.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754186AbcKBN3j (ORCPT ); Wed, 2 Nov 2016 09:29:39 -0400 Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id 5D50631D8; Wed, 2 Nov 2016 14:29:37 +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 jRULO6qkB1kW; 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 3504AC12; Wed, 2 Nov 2016 14:29:36 +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 08/32] media: rcar-vin: move subdev source and sink pad index to rvin_graph_entity Date: Wed, 2 Nov 2016 14:23:05 +0100 Message-Id: <20161102132329.436-9-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 Move the sink and source pad index from struct rvin_dev to struct rvin_graph_entity. This is done in preparation of Gen3 support where the active subdeivce can be changed during runtime. And if the subdevice is changed the pad numbers are different so it's better to read them a rvin_graph_entity then from directly from the rvin_dev. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 45 ++++++++++++++++++++++------- drivers/media/platform/rcar-vin/rcar-vin.h | 17 ++++++----- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 370bb18..f8ff7c4 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -109,9 +109,14 @@ static int rvin_reset_format(struct rvin_dev *vin) .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; struct v4l2_mbus_framefmt *mf = &fmt.format; + struct rvin_graph_entity *rent; int ret; - fmt.pad = vin->src_pad_idx; + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; + + fmt.pad = rent->source_pad_idx; ret = v4l2_subdev_call(vin_to_source(vin), pad, get_fmt, NULL, &fmt); if (ret) @@ -182,7 +187,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin, if (pad_cfg == NULL) return -ENOMEM; - format.pad = vin->src_pad_idx; + format.pad = rent->source_pad_idx; field = pix->field; @@ -560,12 +565,17 @@ static int rvin_enum_dv_timings(struct file *file, void *priv_fh, { struct rvin_dev *vin = video_drvdata(file); struct v4l2_subdev *sd = vin_to_source(vin); + struct rvin_graph_entity *rent; int ret; + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; + if (timings->pad) return -EINVAL; - timings->pad = vin->sink_pad_idx; + timings->pad = rent->sink_pad_idx; ret = v4l2_subdev_call(sd, pad, enum_dv_timings, timings); @@ -612,12 +622,17 @@ static int rvin_dv_timings_cap(struct file *file, void *priv_fh, { struct rvin_dev *vin = video_drvdata(file); struct v4l2_subdev *sd = vin_to_source(vin); + struct rvin_graph_entity *rent; int ret; + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; + if (cap->pad) return -EINVAL; - cap->pad = vin->sink_pad_idx; + cap->pad = rent->sink_pad_idx; ret = v4l2_subdev_call(sd, pad, dv_timings_cap, cap); @@ -630,12 +645,17 @@ static int rvin_g_edid(struct file *file, void *fh, struct v4l2_edid *edid) { struct rvin_dev *vin = video_drvdata(file); struct v4l2_subdev *sd = vin_to_source(vin); + struct rvin_graph_entity *rent; int ret; + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; + if (edid->pad) return -EINVAL; - edid->pad = vin->sink_pad_idx; + edid->pad = rent->sink_pad_idx; ret = v4l2_subdev_call(sd, pad, get_edid, edid); @@ -648,12 +668,17 @@ static int rvin_s_edid(struct file *file, void *fh, struct v4l2_edid *edid) { struct rvin_dev *vin = video_drvdata(file); struct v4l2_subdev *sd = vin_to_source(vin); + struct rvin_graph_entity *rent; int ret; + rent = vin_to_entity(vin); + if (!rent) + return -ENODEV; + if (edid->pad) return -EINVAL; - edid->pad = vin->sink_pad_idx; + edid->pad = rent->sink_pad_idx; ret = v4l2_subdev_call(sd, pad, set_edid, edid); @@ -926,19 +951,19 @@ int rvin_v4l2_probe(struct rvin_dev *vin) vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; - vin->src_pad_idx = 0; + vin->digital.source_pad_idx = 0; for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++) if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SOURCE) break; if (pad_idx >= sd->entity.num_pads) return -EINVAL; - vin->src_pad_idx = pad_idx; + vin->digital.source_pad_idx = pad_idx; - vin->sink_pad_idx = 0; + vin->digital.sink_pad_idx = 0; for (pad_idx = 0; pad_idx < sd->entity.num_pads; pad_idx++) if (sd->entity.pads[pad_idx].flags == MEDIA_PAD_FL_SINK) { - vin->sink_pad_idx = pad_idx; + vin->digital.sink_pad_idx = pad_idx; break; } diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h index daec26a..d31212a 100644 --- a/drivers/media/platform/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/rcar-vin/rcar-vin.h @@ -70,10 +70,12 @@ struct rvin_video_format { /** * struct rvin_graph_entity - Video endpoint from async framework - * @asd: sub-device descriptor for async framework - * @subdev: subdevice matched using async framework - * @code: Media bus format from source - * @mbus_cfg: Media bus format from DT + * @asd: sub-device descriptor for async framework + * @subdev: subdevice matched using async framework + * @code: Media bus format from source + * @mbus_cfg: Media bus format from DT + * @source_pad_idx: source pad index on remote device + * @sink_pad_idx: sink pad index on remote device */ struct rvin_graph_entity { struct v4l2_async_subdev asd; @@ -81,6 +83,9 @@ struct rvin_graph_entity { u32 code; struct v4l2_mbus_config mbus_cfg; + + int source_pad_idx; + int sink_pad_idx; }; /** @@ -91,8 +96,6 @@ struct rvin_graph_entity { * * @vdev: V4L2 video device associated with VIN * @v4l2_dev: V4L2 device - * @src_pad_idx: source pad index for media controller drivers - * @sink_pad_idx: sink pad index for media controller drivers * @ctrl_handler: V4L2 control handler * @notifier: V4L2 asynchronous subdevs notifier * @digital: entity in the DT for local digital subdevice @@ -121,8 +124,6 @@ struct rvin_dev { struct video_device vdev; struct v4l2_device v4l2_dev; - int src_pad_idx; - int sink_pad_idx; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_async_notifier notifier; struct rvin_graph_entity digital;