summaryrefslogtreecommitdiff
path: root/drivers/media/platform/rcar-vin/rcar-vin.h
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>2018-04-14 14:57:18 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2018-04-20 17:08:04 +0300
commit3bb4c3bc85bf77a76c921671800bde2e1bf82a88 (patch)
tree14ca2e566f5a0c78b90626a84fdc5a9aaea167a9 /drivers/media/platform/rcar-vin/rcar-vin.h
parent68ee48d66648f8c800a640733ce774d0bdc06329 (diff)
downloadlinux-3bb4c3bc85bf77a76c921671800bde2e1bf82a88.tar.xz
media: rcar-vin: add group allocator functions
In media controller mode all VIN instances needs to be part of the same media graph. There is also a need for each VIN instance to know about and in some cases be able to communicate with other VIN instances. Add an allocator framework where the first VIN instance to be probed creates a shared data structure and registers a media device. Consecutive VINs insert themself into the global group. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform/rcar-vin/rcar-vin.h')
-rw-r--r--drivers/media/platform/rcar-vin/rcar-vin.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h
index 5102ad254bff..cf5c467d45e1 100644
--- a/drivers/media/platform/rcar-vin/rcar-vin.h
+++ b/drivers/media/platform/rcar-vin/rcar-vin.h
@@ -17,6 +17,8 @@
#ifndef __RCAR_VIN__
#define __RCAR_VIN__
+#include <linux/kref.h>
+
#include <media/v4l2-async.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
@@ -29,6 +31,11 @@
/* Address alignment mask for HW buffers */
#define HW_BUFFER_MASK 0x7f
+/* Max number on VIN instances that can be in a system */
+#define RCAR_VIN_NUM 8
+
+struct rvin_group;
+
enum model_id {
RCAR_H1,
RCAR_M1,
@@ -99,6 +106,8 @@ struct rvin_info {
* @notifier: V4L2 asynchronous subdevs notifier
* @digital: entity in the DT for local digital subdevice
*
+ * @group: Gen3 CSI group
+ * @id: Gen3 group id for this VIN
* @pad: media pad for the video device entity
*
* @lock: protects @queue
@@ -133,6 +142,8 @@ struct rvin_dev {
struct v4l2_async_notifier notifier;
struct rvin_graph_entity *digital;
+ struct rvin_group *group;
+ unsigned int id;
struct media_pad pad;
struct mutex lock;
@@ -164,6 +175,26 @@ struct rvin_dev {
#define vin_warn(d, fmt, arg...) dev_warn(d->dev, fmt, ##arg)
#define vin_err(d, fmt, arg...) dev_err(d->dev, fmt, ##arg)
+/**
+ * struct rvin_group - VIN CSI2 group information
+ * @refcount: number of VIN instances using the group
+ *
+ * @mdev: media device which represents the group
+ *
+ * @lock: protects the count and vin members
+ * @count: number of enabled VIN instances found in DT
+ * @vin: VIN instances which are part of the group
+ */
+struct rvin_group {
+ struct kref refcount;
+
+ struct media_device mdev;
+
+ struct mutex lock;
+ unsigned int count;
+ struct rvin_dev *vin[RCAR_VIN_NUM];
+};
+
int rvin_dma_register(struct rvin_dev *vin, int irq);
void rvin_dma_unregister(struct rvin_dev *vin);