All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Towle <william.towle@codethink.co.uk>
To: linux-media@vger.kernel.org, linux-kernel@lists.codethink.co.uk
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Subject: [PATCH 08/15] v4l: subdev: Add pad config allocator and init
Date: Wed, 27 May 2015 17:10:46 +0100	[thread overview]
Message-ID: <1432743053-13479-9-git-send-email-william.towle@codethink.co.uk> (raw)
In-Reply-To: <1432743053-13479-1-git-send-email-william.towle@codethink.co.uk>

From: Laurent Pinchart <laurent.pinchart@linaro.org>

Add a new subdev operation to initialize a subdev pad config array, and
a helper function to allocate and initialize the array. This can be used
by bridge drivers to implement try format based on subdev pad
operations.

Signed-off-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Acked-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 19 ++++++++++++++++++-
 include/media/v4l2-subdev.h           | 10 ++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

Changes since v1:

- Added v4l2_subdev_free_pad_config
---
 drivers/media/v4l2-core/v4l2-subdev.c |   19 ++++++++++++++++++-
 include/media/v4l2-subdev.h           |   10 ++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..d594fe5 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -35,7 +35,7 @@
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
-	fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
+	fh->pad = v4l2_subdev_alloc_pad_config(sd);
 	if (fh->pad == NULL)
 		return -ENOMEM;
 #endif
@@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link)
 		sink, link, &source_fmt, &sink_fmt);
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
+{
+	struct v4l2_subdev_pad_config *cfg;
+
+	if (!sd->entity.num_pads)
+		return NULL;
+
+	cfg = kcalloc(sd->entity.num_pads, sizeof(*cfg), GFP_KERNEL);
+	if (!cfg)
+		return NULL;
+
+	v4l2_subdev_call(sd, pad, init_cfg, cfg);
+
+	return cfg;
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
 void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index dc20102..4a609f6 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -485,6 +485,8 @@ struct v4l2_subdev_pad_config {
  *                  may be adjusted by the subdev driver to device capabilities.
  */
 struct v4l2_subdev_pad_ops {
+	void (*init_cfg)(struct v4l2_subdev *sd,
+			 struct v4l2_subdev_pad_config *cfg);
 	int (*enum_mbus_code)(struct v4l2_subdev *sd,
 			      struct v4l2_subdev_pad_config *cfg,
 			      struct v4l2_subdev_mbus_code_enum *code);
@@ -677,7 +679,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
 				      struct v4l2_subdev_format *source_fmt,
 				      struct v4l2_subdev_format *sink_fmt);
 int v4l2_subdev_link_validate(struct media_link *link);
+
+struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
+
+static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
+{
+	kfree(cfg);
+}
 #endif /* CONFIG_MEDIA_CONTROLLER */
+
 void v4l2_subdev_init(struct v4l2_subdev *sd,
 		      const struct v4l2_subdev_ops *ops);
 
-- 
1.7.10.4


  parent reply	other threads:[~2015-05-27 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 16:10 HDMI and Composite capture on Lager, for kernel 4.1, version 2 William Towle
2015-05-27 16:10 ` [PATCH 01/15] ARM: shmobile: lager dts: Add entries for VIN HDMI input support William Towle
2015-05-27 16:10 ` [PATCH 02/15] media: soc_camera: rcar_vin: Add BT.709 24-bit RGB888 " William Towle
2015-05-27 16:10 ` [PATCH 03/15] media: adv7180: add of match table William Towle
2015-05-27 16:10 ` [PATCH 04/15] media: adv7604: chip info and formats for ADV7612 William Towle
2015-05-27 16:10 ` [PATCH 05/15] media: adv7604: document support for ADV7612 dual HDMI input decoder William Towle
2015-05-27 16:10 ` [PATCH 06/15] media: adv7604: ability to read default input port from DT William Towle
2015-05-27 16:10 ` [PATCH 07/15] ARM: shmobile: lager dts: specify default-input for ADV7612 William Towle
2015-05-27 16:10 ` William Towle [this message]
2015-05-27 16:10 ` [PATCH 09/15] media: soc_camera pad-aware driver initialisation William Towle
2015-05-27 16:10 ` [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt William Towle
2015-05-29 10:24   ` Hans Verkuil
2015-05-27 16:10 ` [PATCH 11/15] media: soc_camera: soc_scale_crop: Use correct pad when calling subdev try_fmt William Towle
2015-05-27 16:10 ` [PATCH 12/15] media: soc_camera: Fill std field in enum_input William Towle
2015-05-27 16:10 ` [PATCH 13/15] media: soc_camera: Fix error reporting in expbuf William Towle
2015-05-27 16:10 ` [PATCH 14/15] media: soc_camera: v4l2-compliance fixes for querycap William Towle
2015-05-27 16:10 ` [PATCH 15/15] media: rcar_vin: Reject videobufs that are too small for current format William Towle
2015-06-03 13:59 HDMI and Composite capture on Lager, for kernel 4.1, version 3 William Towle
2015-06-03 13:59 ` [PATCH 08/15] v4l: subdev: Add pad config allocator and init William Towle
2015-06-25  9:30 HDMI and Composite capture on Lager, for kernel 4.1, version 4 William Towle
2015-06-25  9:31 ` [PATCH 08/15] v4l: subdev: Add pad config allocator and init William Towle

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=1432743053-13479-9-git-send-email-william.towle@codethink.co.uk \
    --to=william.towle@codethink.co.uk \
    --cc=g.liakhovetski@gmx.de \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@lists.codethink.co.uk \
    --cc=linux-media@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.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 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.