From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
tomoharu.fukawa.eb@renesas.com,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 25/32] media: rcar-vin: enable CSI2 group subdevices in lookup helpers
Date: Wed, 2 Nov 2016 14:23:22 +0100 [thread overview]
Message-ID: <20161102132329.436-26-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20161102132329.436-1-niklas.soderlund+renesas@ragnatech.se>
Make the subdevice helpers look not only at the local digital subdevice
but also for the CSI2 group subdevices which can be present on Gen3.
Which CSI2 group subdevices are found depends on the CSI2 subgroup
routing which is stored in the CHSEL register of the subgroup master
(VIN0 for VIN0-3 and VIN4 for VIN4-7). The lookup functions look at this
value and returns the correct information or NULL if there is no
attached subdevices for the current routing for this device.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/platform/rcar-vin/rcar-core.c | 66 ++++++++++++++++++++++++++++-
drivers/media/platform/rcar-vin/rcar-vin.h | 2 +-
2 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 06876a8..f382f91 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -330,9 +330,73 @@ static void rvin_group_delete(struct rvin_dev *vin)
* Subdevice helpers
*/
+static int rvin_group_vin_to_csi(struct rvin_dev *vin)
+{
+ int i, vin_num, vin_master, chsel, csi;
+
+ /*
+ * Only try to translate to a CSI2 number if there is a enabled
+ * link from the VIN sink pad. However if there are no links at
+ * all we are at probe time so ignore the need for enabled links
+ * to be able to make a better guess of initial format
+ */
+ if (vin->pads[RVIN_SINK].entity->num_links &&
+ !media_entity_remote_pad(&vin->pads[RVIN_SINK]))
+ return -1;
+
+ /* Find which VIN we are */
+ vin_num = -1;
+ for (i = 0; i < RCAR_VIN_NUM; i++)
+ if (vin == vin->group->vin[i])
+ vin_num = i;
+
+ if (vin_num == -1)
+ return -1;
+
+ vin_master = vin_num < 4 ? 0 : 4;
+ if (!vin->group->vin[vin_master])
+ return -1;
+
+ chsel = rvin_get_chsel(vin->group->vin[vin_master]);
+
+ csi = vin->info->chsels[vin_num][chsel].csi;
+ if (csi >= RVIN_CSI_MAX)
+ return -1;
+
+ if (!vin->group->source[csi].subdev || !vin->group->bridge[csi].subdev)
+ return -1;
+
+ return csi;
+}
+
struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin)
{
- return &vin->digital;
+ int csi;
+
+ /* If there is a digital subdev use it */
+ if (vin->digital.subdev)
+ return &vin->digital;
+
+ csi = rvin_group_vin_to_csi(vin);
+ if (csi < 0)
+ return NULL;
+
+ return &vin->group->source[csi];
+}
+
+struct v4l2_subdev *vin_to_source(struct rvin_dev *vin)
+{
+ int csi;
+
+ /* If there is a digital subdev use it */
+ if (vin->digital.subdev)
+ return vin->digital.subdev;
+
+ csi = rvin_group_vin_to_csi(vin);
+ if (csi < 0)
+ return NULL;
+
+ return vin->group->source[csi].subdev;
}
/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
index cd7d959..2f1e087 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -207,7 +207,7 @@ struct rvin_dev {
};
struct rvin_graph_entity *vin_to_entity(struct rvin_dev *vin);
-#define vin_to_source(vin) vin->digital.subdev
+struct v4l2_subdev *vin_to_source(struct rvin_dev *vin);
/* Debug */
#define vin_dbg(d, fmt, arg...) dev_dbg(d->dev, fmt, ##arg)
--
2.10.2
next prev parent reply other threads:[~2016-11-02 13:29 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-02 13:22 [PATCH 00/32] rcar-vin: Add Gen3 with media controller support Niklas Söderlund
2016-11-02 13:22 ` [PATCH 01/32] media: entity: Add has_route entity operation Niklas Söderlund
2016-11-08 12:43 ` Sakari Ailus
2016-11-02 13:22 ` [PATCH 02/32] media: entity: Add media_entity_has_route() function Niklas Söderlund
2016-11-08 12:42 ` Sakari Ailus
2016-11-08 12:54 ` [PATCH 1/1] " Sakari Ailus
2016-11-11 21:08 ` Niklas Söderlund
2016-11-02 13:23 ` [PATCH 03/32] media: rcar-vin: reset bytesperline and sizeimage when resetting format Niklas Söderlund
2016-11-02 16:43 ` Sergei Shtylyov
2016-11-02 13:23 ` [PATCH 04/32] media: rcar-vin: use rvin_reset_format() in S_DV_TIMINGS Niklas Söderlund
2016-11-02 13:23 ` [PATCH 05/32] media: rcar-vin: fix how pads are handled for v4l2 subdeivce operations Niklas Söderlund
2016-11-02 13:23 ` [PATCH 06/32] media: rcar-vin: fix standard in input enumeration Niklas Söderlund
2016-11-02 13:23 ` [PATCH 07/32] media: rcar-vin: add wrapper to get rvin_graph_entity Niklas Söderlund
2016-11-02 13:23 ` [PATCH 08/32] media: rcar-vin: move subdev source and sink pad index to rvin_graph_entity Niklas Söderlund
2016-11-02 13:23 ` [PATCH 09/32] media: rcar-vin: move pad number discovery to async complete handler Niklas Söderlund
2016-11-02 13:23 ` [PATCH 10/32] media: rcar-vin: use pad information when verifying media bus format Niklas Söderlund
2016-11-02 13:23 ` [PATCH 11/32] media: rcar-vin: refactor pad lookup code Niklas Söderlund
2016-11-02 13:23 ` [PATCH 12/32] media: rcar-vin: split rvin_s_fmt_vid_cap() Niklas Söderlund
2016-11-02 13:23 ` [PATCH 13/32] media: rcar-vin: register the video device early Niklas Söderlund
2016-11-02 13:23 ` [PATCH 14/32] media: rcar-vin: move chip information to own struct Niklas Söderlund
2016-11-07 12:40 ` Geert Uytterhoeven
2016-11-02 13:23 ` [PATCH 15/32] media: rcar-vin: move max width and height information to chip information Niklas Söderlund
2016-11-02 13:23 ` [PATCH 16/32] media: rcar-vin: change name of video device Niklas Söderlund
2016-11-02 13:23 ` [PATCH 17/32] media: rcar-vin: clarify error message from the digital notifier Niklas Söderlund
2016-11-02 13:23 ` [PATCH 18/32] media: rcar-vin: enable Gen3 hardware configuration Niklas Söderlund
2016-11-02 13:23 ` [PATCH 19/32] media: rcar-vin: add functions to manipulate Gen3 CHSEL value Niklas Söderlund
2016-11-02 13:23 ` [PATCH 20/32] media: rcar-vin: expose a sink pad if we are on Gen3 Niklas Söderlund
2016-11-02 17:15 ` Sergei Shtylyov
2016-11-02 13:23 ` [PATCH 21/32] media: rcar-vin: add group allocator functions Niklas Söderlund
2016-11-02 13:23 ` [PATCH 22/32] media: rcar-vin: add chsel information to rvin_info Niklas Söderlund
2016-11-02 13:23 ` [PATCH 23/32] media: rcar-vin: parse Gen3 OF and setup media graph Niklas Söderlund
2016-11-02 13:23 ` [PATCH 24/32] media: rcar-vin: add link notify for Gen3 Niklas Söderlund
2016-11-02 13:23 ` Niklas Söderlund [this message]
2016-11-02 13:23 ` [PATCH 26/32] media: rcar-vin: add helpers for bridge Niklas Söderlund
2016-11-02 13:23 ` [PATCH 27/32] media: rcar-vin: start/stop the CSI2 bridge stream Niklas Söderlund
2016-11-02 13:23 ` [PATCH 28/32] media: rcar-vin: propagate format to bridge Niklas Söderlund
2016-11-02 13:23 ` [PATCH 29/32] media: rcar-vin: attach to CSI2 group when the video device is opened Niklas Söderlund
2016-11-02 13:23 ` [PATCH 30/32] media: rcar-vin: add Gen3 devicetree bindings documentation Niklas Söderlund
2016-11-07 12:47 ` Geert Uytterhoeven
2016-11-02 13:23 ` [PATCH 31/32] media: rcar-vin: enable support for r8a7795 Niklas Söderlund
2016-11-07 12:42 ` Geert Uytterhoeven
2016-11-02 13:23 ` [PATCH 32/32] media: rcar-vin: enable support for r8a7796 Niklas Söderlund
2016-11-07 12:44 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161102132329.436-26-niklas.soderlund+renesas@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tomoharu.fukawa.eb@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).