All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: niklas.soderlund@ragnatech.se, maxime.ripard@free-electrons.com,
	hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com,
	pavel@ucw.cz, sre@kernel.org
Subject: [PATCH v15 25/32] v4l: fwnode: Add convenience function for parsing common external refs
Date: Thu,  5 Oct 2017 00:50:44 +0300	[thread overview]
Message-ID: <20171004215051.13385-26-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20171004215051.13385-1-sakari.ailus@linux.intel.com>

Add v4l2_fwnode_parse_reference_sensor_common for parsing common
sensor properties that refer to adjacent devices such as flash or lens
driver chips.

As this is an association only, there's little a regular driver needs to
know about these devices as such.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 35 +++++++++++++++++++++++++++++++++++
 include/media/v4l2-async.h            |  3 ++-
 include/media/v4l2-fwnode.h           | 21 +++++++++++++++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index c8acf5bf9916..18ea7cd34f21 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -785,6 +785,41 @@ static int v4l2_fwnode_reference_parse_int_props(
 	return ret;
 }
 
+int v4l2_async_notifier_parse_fwnode_sensor_common(
+	struct device *dev, struct v4l2_async_notifier *notifier)
+{
+	static const char *led_props[] = { "led" };
+	static const struct {
+		const char *name;
+		const char **props;
+		unsigned int nprops;
+	} props[] = {
+		{ "flash-leds", led_props, ARRAY_SIZE(led_props) },
+		{ "lens-focus", NULL, 0 },
+	};
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(props); i++) {
+		int ret;
+
+		if (props[i].props && is_acpi_node(dev_fwnode(dev)))
+			ret = v4l2_fwnode_reference_parse_int_props(
+				dev, notifier, props[i].name,
+				props[i].props, props[i].nprops);
+		else
+			ret = v4l2_fwnode_reference_parse(
+				dev, notifier, props[i].name);
+		if (ret && ret != -ENOENT) {
+			dev_warn(dev, "parsing property \"%s\" failed (%d)\n",
+				 props[i].name, ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_async_notifier_parse_fwnode_sensor_common);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus <sakari.ailus@linux.intel.com>");
 MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index d33a52be2501..1e5e3f186b38 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -155,7 +155,8 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier);
  * Release memory resources related to a notifier, including the async
  * sub-devices allocated for the purposes of the notifier but not the notifier
  * itself. The user is responsible for calling this function to clean up the
- * notifier after calling @v4l2_async_notifier_parse_fwnode_endpoints.
+ * notifier after calling @v4l2_async_notifier_parse_fwnode_endpoints or
+ * @v4l2_fwnode_reference_parse_sensor_common.
  *
  * There is no harm from calling v4l2_async_notifier_cleanup in other
  * cases as long as its memory has been zeroed after it has been
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 671e76e2d285..43fd1a278bcc 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -319,4 +319,25 @@ int v4l2_async_notifier_parse_fwnode_endpoints_by_port(
 			      struct v4l2_fwnode_endpoint *vep,
 			      struct v4l2_async_subdev *asd));
 
+/**
+ * v4l2_fwnode_reference_parse_sensor_common - parse common references on
+ *					       sensors for async sub-devices
+ * @dev: the device node the properties of which are parsed for references
+ * @notifier: the async notifier where the async subdevs will be added
+ *
+ * Parse common sensor properties for remote devices related to the
+ * sensor and set up async sub-devices for them.
+ *
+ * Any notifier populated using this function must be released with a call to
+ * v4l2_async_notifier_release() after it has been unregistered and the async
+ * sub-devices are no longer in use, even in the case the function returned an
+ * error.
+ *
+ * Return: 0 on success
+ *	   -ENOMEM if memory allocation failed
+ *	   -EINVAL if property parsing failed
+ */
+int v4l2_async_notifier_parse_fwnode_sensor_common(
+	struct device *dev, struct v4l2_async_notifier *notifier);
+
 #endif /* _V4L2_FWNODE_H */
-- 
2.11.0

  parent reply	other threads:[~2017-10-04 21:51 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 21:50 [PATCH v15 00/32] Unified fwnode endpoint parser, async sub-device notifier support, N9 flash DTS Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 01/32] v4l: async: Remove re-probing support Sakari Ailus
2017-10-08 21:50   ` Sebastian Reichel
2017-10-09 11:22   ` Mauro Carvalho Chehab
2017-10-09 14:06     ` Sakari Ailus
2017-10-09 14:08       ` Hans Verkuil
2017-10-09 14:18         ` Sakari Ailus
2017-10-09 14:20           ` Hans Verkuil
2017-10-09 15:27             ` Mauro Carvalho Chehab
     [not found]           ` <CGME20171009164457epcas1p3c5e134e4bb5d85498fe8d4f00332f2fc@epcas1p3.samsung.com>
2017-10-09 16:44             ` Sylwester Nawrocki
2017-10-09 19:18               ` Laurent Pinchart
2017-10-10 12:18               ` Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 02/32] v4l: async: Don't set sd->dev NULL in v4l2_async_cleanup Sakari Ailus
2017-10-08 21:50   ` Sebastian Reichel
2017-10-09 11:21   ` Hans Verkuil
2017-10-04 21:50 ` [PATCH v15 03/32] v4l: async: fix unbind error in v4l2_async_notifier_unregister() Sakari Ailus
2017-10-08 21:50   ` Sebastian Reichel
2017-10-09 11:23   ` Hans Verkuil
2017-10-04 21:50 ` [PATCH v15 04/32] v4l: async: Fix notifier complete callback error handling Sakari Ailus
2017-10-09 11:45   ` Hans Verkuil
2017-10-10 12:57     ` Sakari Ailus
2017-10-10 13:18       ` Hans Verkuil
2017-10-10 14:21         ` Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 05/32] v4l: async: Correctly serialise async sub-device unregistration Sakari Ailus
2017-10-08 21:52   ` Sebastian Reichel
2017-10-09 11:45   ` Hans Verkuil
2017-10-04 21:50 ` [PATCH v15 06/32] v4l: async: Use more intuitive names for internal functions Sakari Ailus
2017-10-08 21:53   ` Sebastian Reichel
2017-10-04 21:50 ` [PATCH v15 07/32] v4l: async: Add V4L2 async documentation to the documentation build Sakari Ailus
2017-10-08 21:54   ` Sebastian Reichel
2017-10-09 11:31   ` Mauro Carvalho Chehab
2017-10-04 21:50 ` [PATCH v15 08/32] v4l: fwnode: Support generic parsing of graph endpoints in a device Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 09/32] omap3isp: Use generic parser for parsing fwnode endpoints Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 10/32] rcar-vin: " Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 11/32] omap3isp: Fix check for our own sub-devices Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 12/32] omap3isp: Print the name of the entity where no source pads could be found Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 13/32] v4l: async: Move async subdev notifier operations to a separate structure Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 14/32] v4l: async: Introduce helpers for calling async ops callbacks Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 15/32] v4l: async: Register sub-devices before calling bound callback Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 16/32] v4l: async: Allow async notifier register call succeed with no subdevs Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 17/32] v4l: async: Prepare for async sub-device notifiers Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 18/32] v4l: async: Allow binding notifiers to sub-devices Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 19/32] v4l: async: Ensure only unique fwnodes are registered to notifiers Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 20/32] dt: bindings: Add a binding for flash LED devices associated to a sensor Sakari Ailus
     [not found]   ` <20171004215051.13385-21-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-10-13 13:41     ` Rob Herring
2017-10-13 13:41       ` Rob Herring
2017-10-04 21:50 ` [PATCH v15 21/32] dt: bindings: Add lens-focus binding for image sensors Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 22/32] v4l: fwnode: Move KernelDoc documentation to the header Sakari Ailus
2017-10-05 12:03   ` [PATCH v15.1 " Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 23/32] v4l: fwnode: Add a helper function for parsing generic references Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 24/32] v4l: fwnode: Add a helper function to obtain device / integer references Sakari Ailus
2017-10-18 13:56   ` [PATCH v15.1 " Sakari Ailus
2017-10-18 15:32     ` Sakari Ailus
2017-10-19  6:52       ` Hans Verkuil
2017-10-20 11:35         ` Sakari Ailus
2017-10-24 20:32         ` [PATCH v15.2 " Sakari Ailus
2017-10-24 20:36           ` Sakari Ailus
2017-10-25  7:28           ` Hans Verkuil
2017-10-04 21:50 ` Sakari Ailus [this message]
2017-10-04 21:50 ` [PATCH v15 26/32] v4l: fwnode: Add a convenience function for registering sensors Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 27/32] dt: bindings: smiapp: Document lens-focus and flash-leds properties Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 28/32] smiapp: Add support for flash and lens devices Sakari Ailus
2017-10-06 11:21   ` Pavel Machek
2017-10-04 21:50 ` [PATCH v15 29/32] et8ek8: " Sakari Ailus
2017-10-06 11:21   ` Pavel Machek
2017-10-04 21:50 ` [PATCH v15 30/32] ov5670: " Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 31/32] ov13858: " Sakari Ailus
2017-10-04 21:50 ` [PATCH v15 32/32] arm: dts: omap3: N9/N950: Add flash references to the camera Sakari Ailus
2017-10-05  6:11 ` [PATCH v15 00/32] Unified fwnode endpoint parser, async sub-device notifier support, N9 flash DTS Sakari Ailus

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=20171004215051.13385-26-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=pavel@ucw.cz \
    --cc=sre@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.