All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
Subject: [PATCH v2 26/54] v4l: vsp1: Consolidate entity ops in a struct vsp1_entity_operations
Date: Fri, 25 Mar 2016 12:44:00 +0200	[thread overview]
Message-ID: <1458902668-1141-27-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1458902668-1141-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

Entities have two operations, a destroy operation stored directly in
vsp1_entity and a set_memory operation stored in a vsp1_rwpf_operations
structure. Move the two to a more generic vsp1_entity_operations
structure that will serve to implement additional operations.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_entity.c |  4 ++--
 drivers/media/platform/vsp1/vsp1_entity.h | 14 +++++++++++++-
 drivers/media/platform/vsp1/vsp1_rpf.c    | 11 ++++++-----
 drivers/media/platform/vsp1/vsp1_rwpf.h   | 18 ++++++------------
 drivers/media/platform/vsp1/vsp1_wpf.c    | 27 ++++++++++++++-------------
 5 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
index dcb331fb5549..f09a54b396ec 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -223,8 +223,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
 
 void vsp1_entity_destroy(struct vsp1_entity *entity)
 {
-	if (entity->destroy)
-		entity->destroy(entity);
+	if (entity->ops && entity->ops->destroy)
+		entity->ops->destroy(entity);
 	if (entity->subdev.ctrl_handler)
 		v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
 	media_entity_cleanup(&entity->subdev.entity);
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h
index 056391105ee5..f46ba20c30b1 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -53,10 +53,22 @@ struct vsp1_route {
 	unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
 };
 
+/**
+ * struct vsp1_entity_operations - Entity operations
+ * @destroy:	Destroy the entity.
+ * @set_memory:	Setup memory buffer access. This operation applies the settings
+ *		stored in the rwpf mem field to the hardware. Valid for RPF and
+ *		WPF only.
+ */
+struct vsp1_entity_operations {
+	void (*destroy)(struct vsp1_entity *);
+	void (*set_memory)(struct vsp1_entity *);
+};
+
 struct vsp1_entity {
 	struct vsp1_device *vsp1;
 
-	void (*destroy)(struct vsp1_entity *);
+	const struct vsp1_entity_operations *ops;
 
 	enum vsp1_entity_type type;
 	unsigned int index;
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index d9cc9b8fc0b6..5c84a92c975c 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -141,11 +141,13 @@ static struct v4l2_subdev_ops rpf_ops = {
 };
 
 /* -----------------------------------------------------------------------------
- * Video Device Operations
+ * VSP1 Entity Operations
  */
 
-static void rpf_set_memory(struct vsp1_rwpf *rpf)
+static void rpf_set_memory(struct vsp1_entity *entity)
 {
+	struct vsp1_rwpf *rpf = entity_to_rwpf(entity);
+
 	vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_Y,
 		       rpf->mem.addr[0] + rpf->offsets[0]);
 	vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C0,
@@ -154,7 +156,7 @@ static void rpf_set_memory(struct vsp1_rwpf *rpf)
 		       rpf->mem.addr[2] + rpf->offsets[1]);
 }
 
-static const struct vsp1_rwpf_operations rpf_vdev_ops = {
+static const struct vsp1_entity_operations rpf_entity_ops = {
 	.set_memory = rpf_set_memory,
 };
 
@@ -172,11 +174,10 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 	if (rpf == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	rpf->ops = &rpf_vdev_ops;
-
 	rpf->max_width = RPF_MAX_WIDTH;
 	rpf->max_height = RPF_MAX_HEIGHT;
 
+	rpf->entity.ops = &rpf_entity_ops;
 	rpf->entity.type = VSP1_ENTITY_RPF;
 	rpf->entity.index = index;
 
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index 2bbcc331959b..e8ca9b6ee689 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -32,23 +32,12 @@ struct vsp1_rwpf_memory {
 	dma_addr_t addr[3];
 };
 
-/**
- * struct vsp1_rwpf_operations - RPF and WPF operations
- * @set_memory: Setup memory buffer access. This operation applies the settings
- *		stored in the rwpf mem field to the hardware.
- */
-struct vsp1_rwpf_operations {
-	void (*set_memory)(struct vsp1_rwpf *rwpf);
-};
-
 struct vsp1_rwpf {
 	struct vsp1_entity entity;
 	struct v4l2_ctrl_handler ctrls;
 
 	struct vsp1_video *video;
 
-	const struct vsp1_rwpf_operations *ops;
-
 	unsigned int max_width;
 	unsigned int max_height;
 
@@ -73,6 +62,11 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev)
 	return container_of(subdev, struct vsp1_rwpf, entity.subdev);
 }
 
+static inline struct vsp1_rwpf *entity_to_rwpf(struct vsp1_entity *entity)
+{
+	return container_of(entity, struct vsp1_rwpf, entity);
+}
+
 struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index);
 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index);
 
@@ -105,7 +99,7 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
  */
 static inline void vsp1_rwpf_set_memory(struct vsp1_rwpf *rwpf)
 {
-	rwpf->ops->set_memory(rwpf);
+	rwpf->entity.ops->set_memory(&rwpf->entity);
 }
 
 #endif /* __VSP1_RWPF_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c
index f4861a2d2002..8cc19ef49f45 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -152,17 +152,27 @@ static struct v4l2_subdev_ops wpf_ops = {
 };
 
 /* -----------------------------------------------------------------------------
- * Video Device Operations
+ * VSP1 Entity Operations
  */
 
-static void wpf_set_memory(struct vsp1_rwpf *wpf)
+static void vsp1_wpf_destroy(struct vsp1_entity *entity)
 {
+	struct vsp1_rwpf *wpf = entity_to_rwpf(entity);
+
+	vsp1_dlm_destroy(wpf->dlm);
+}
+
+static void wpf_set_memory(struct vsp1_entity *entity)
+{
+	struct vsp1_rwpf *wpf = entity_to_rwpf(entity);
+
 	vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, wpf->mem.addr[0]);
 	vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, wpf->mem.addr[1]);
 	vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, wpf->mem.addr[2]);
 }
 
-static const struct vsp1_rwpf_operations wpf_vdev_ops = {
+static const struct vsp1_entity_operations wpf_entity_ops = {
+	.destroy = vsp1_wpf_destroy,
 	.set_memory = wpf_set_memory,
 };
 
@@ -170,13 +180,6 @@ static const struct vsp1_rwpf_operations wpf_vdev_ops = {
  * Initialization and Cleanup
  */
 
-static void vsp1_wpf_destroy(struct vsp1_entity *entity)
-{
-	struct vsp1_rwpf *wpf = container_of(entity, struct vsp1_rwpf, entity);
-
-	vsp1_dlm_destroy(wpf->dlm);
-}
-
 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 {
 	struct vsp1_rwpf *wpf;
@@ -187,12 +190,10 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 	if (wpf == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	wpf->ops = &wpf_vdev_ops;
-
 	wpf->max_width = WPF_MAX_WIDTH;
 	wpf->max_height = WPF_MAX_HEIGHT;
 
-	wpf->entity.destroy = vsp1_wpf_destroy;
+	wpf->entity.ops = &wpf_entity_ops;
 	wpf->entity.type = VSP1_ENTITY_WPF;
 	wpf->entity.index = index;
 
-- 
2.7.3


  parent reply	other threads:[~2016-03-25 10:44 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-25 10:43 [PATCH v2 00/54] R-Car VSP improvements for v4.7 Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 01/54] media: Add video processing entity functions Laurent Pinchart
2016-03-25 12:44   ` Hans Verkuil
2016-03-25 13:57     ` Laurent Pinchart
2016-03-25 14:19     ` [PATCH v3] " Laurent Pinchart
2016-03-25 15:14       ` Hans Verkuil
2016-03-25 15:23         ` Laurent Pinchart
2016-04-10  0:03           ` Laurent Pinchart
2016-03-28 23:01   ` [PATCH v2 01/54] " Sakari Ailus
2016-03-29  7:40     ` Laurent Pinchart
2016-04-10  0:00       ` Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 02/54] v4l: subdev: Add pad config allocator and init Laurent Pinchart
2016-03-25 15:27   ` [PATCH v3] " Laurent Pinchart
2016-03-28 23:11     ` Sakari Ailus
2016-03-25 10:43 ` [PATCH v2 03/54] v4l: subdev: Call pad init_cfg operation when opening subdevs Laurent Pinchart
2016-03-25 12:40   ` Hans Verkuil
2016-03-25 14:17     ` Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 04/54] v4l: vsp1: Fix vsp1_du_atomic_(begin|flush) declarations Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 05/54] v4l: vsp1: drm: Include correct header file Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 06/54] v4l: vsp1: video: Fix coding style Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 07/54] v4l: vsp1: Set entities functions Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 08/54] v4l: vsp1: VSPD instances have no LUT on Gen3 Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 09/54] v4l: vsp1: Use pipeline display list to decide how to write to modules Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 10/54] v4l: vsp1: Always setup the display list Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 11/54] v4l: vsp1: Simplify frame end processing Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 12/54] v4l: vsp1: Split display list manager from display list Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 13/54] v4l: vsp1: Store the display list manager in the WPF Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 14/54] v4l: vsp1: bru: Don't program background color in control set handler Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 15/54] v4l: vsp1: rwpf: Don't program alpha value " Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 16/54] v4l: vsp1: sru: Don't program intensity " Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 17/54] v4l: vsp1: Don't setup control handler when starting streaming Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 18/54] v4l: vsp1: Enable display list support for the HS[IT], LUT, SRU and UDS Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 19/54] v4l: vsp1: Don't configure RPF memory buffers before calculating offsets Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 20/54] v4l: vsp1: Remove unneeded entity streaming flag Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 21/54] v4l: vsp1: Document calling context of vsp1_pipeline_propagate_alpha() Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 22/54] v4l: vsp1: Fix 80 characters per line violations Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 23/54] v4l: vsp1: Add header display list support Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 24/54] v4l: vsp1: Use display lists with the userspace API Laurent Pinchart
2016-03-25 10:43 ` [PATCH v2 25/54] v4l: vsp1: Move subdev initialization code to vsp1_entity_init() Laurent Pinchart
2016-03-25 10:44 ` Laurent Pinchart [this message]
2016-03-25 10:44 ` [PATCH v2 27/54] v4l: vsp1: Fix BRU try compose rectangle storage Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 28/54] v4l: vsp1: Add race condition FIXME comment Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 29/54] v4l: vsp1: Implement and use the subdev pad::init_cfg configuration Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 30/54] v4l: vsp1: Store active formats in a pad config structure Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 31/54] v4l: vsp1: Store active selection rectangles " Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 32/54] v4l: vsp1: Create a new configure operation to setup modules Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 33/54] v4l: vsp1: Merge RPF and WPF pad ops structures Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 34/54] v4l: vsp1: Use __vsp1_video_try_format to initialize format at init time Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 35/54] v4l: vsp1: Pass display list explicitly to configure functions Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 36/54] v4l: vsp1: Rename pipeline validate functions to pipeline build Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 37/54] v4l: vsp1: Pass pipe pointer to entity configure functions Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 38/54] v4l: vsp1: Store pipeline pointer in rwpf Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 39/54] v4l: vsp1: video: Reorder functions Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 40/54] v4l: vsp1: Allocate pipelines on demand Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 41/54] v4l: vsp1: RPF entities can't be target nodes Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 42/54] v4l: vsp1: Factorize get pad format code Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 43/54] v4l: vsp1: Factorize media bus codes enumeration code Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 44/54] v4l: vsp1: Factorize frame size " Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 45/54] v4l: vsp1: Fix LUT format setting Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 46/54] v4l: vsp1: dl: Make reg_count field unsigned Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 47/54] v4l: vsp1: dl: Fix race conditions Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 48/54] v4l: vsp1: dl: Add support for multi-body display lists Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 49/54] v4l: vsp1: lut: Use display list fragments to fill LUT Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 50/54] v4l: vsp1: Add support for the RPF alpha multiplier on Gen3 Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 51/54] v4l: vsp1: Add Z-order support for DRM pipeline Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 52/54] v4l: vsp1: Add global alpha " Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 53/54] v4l: vsp1: Fix V4L2_PIX_FMT_XRGB444 format definition Laurent Pinchart
2016-03-25 10:44 ` [PATCH v2 54/54] v4l: vsp1: Update WPF and LIF maximum sizes for Gen3 Laurent Pinchart

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=1458902668-1141-27-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.