[PATCH 3/5] Cherry-pick (manually)
From: Pavel
Date: Fri Apr 29 2016 - 06:06:32 EST
commit b3691ff97a99bcf28790c4da906ffc17c822844a
Author: Sakari Ailus <sakari.ailus@xxxxxx>
Date: Sat May 16 23:56:03 2015 +0300
omap3isp: Support the ti,camera-flashes property
Before this patch the omap3isp driver only supported external
devices that
are connected to it by a data bus. This patch adds support for
flash
devices, in form of an array of phandles to sensor and
associated flash
devices, respectively, in the "ti,camera-flashes" property.
The non image source devices are recognised by empty bus field in
struct
isp_async_subdev, which is made a pointer by the patch.
Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxx>
---
drivers/media/platform/omap3isp/isp.c | 90 +++++++++++++++++++++--------
drivers/media/platform/omap3isp/isp.h | 2 +-
drivers/media/platform/omap3isp/ispcsiphy.c | 2 +-
3 files changed, 67 insertions(+), 27 deletions(-)
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 7419404..a1c3bdb 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2095,13 +2095,20 @@ static void isp_of_parse_node_csi2(struct device *dev,
buscfg->bus.csi2.crc = 1;
}
-static int isp_of_parse_node(struct device *dev, struct device_node *node,
- struct isp_async_subdev *isd)
+static int isp_of_parse_node_endpoint(struct device *dev,
+ struct device_node *node,
+ struct isp_async_subdev *isd)
{
- struct isp_bus_cfg *buscfg = &isd->bus;
+ struct isp_bus_cfg *buscfg;
struct v4l2_of_endpoint vep;
int ret;
+ isd->bus = devm_kzalloc(dev, sizeof(*isd->bus), GFP_KERNEL);
+ if (!isd->bus)
+ return -ENOMEM;
+
+ buscfg = isd->bus;
+
ret = v4l2_of_parse_endpoint(node, &vep);
if (ret)
return ret;
@@ -2144,10 +2151,48 @@ static int isp_of_parse_node(struct device *dev, struct device_node *node,
return 0;
}
+static int isp_of_parse_node(struct device *dev, struct device_node *node,
+ struct v4l2_async_notifier *notifier, bool link)
+{
+ struct isp_async_subdev *isd;
+
+ isd = devm_kzalloc(dev, sizeof(*isd), GFP_KERNEL);
+ if (!isd) {
+ of_node_put(node);
+ return -ENOMEM;
+ }
+
+ notifier->subdevs[notifier->num_subdevs] = &isd->asd;
+
+ if (link) {
+ if (isp_of_parse_node_endpoint(dev, node, isd)) {
+ of_node_put(node);
+ return -EINVAL;
+ }
+
+ isd->asd.match.of.node = of_graph_get_remote_port_parent(node);
+ of_node_put(node);
+ } else {
+ isd->asd.match.of.node = node;
+ }
+
+ if (!isd->asd.match.of.node) {
+ dev_warn(dev, "bad remote port parent\n");
+ return -EINVAL;
+ }
+
+ isd->asd.match_type = V4L2_ASYNC_MATCH_OF;
+ notifier->num_subdevs++;
+
+ return 0;
+}
+
static int isp_of_parse_nodes(struct device *dev,
struct v4l2_async_notifier *notifier)
{
struct device_node *node = NULL;
+ int ret;
+ unsigned int flash = 0;
notifier->subdevs = devm_kcalloc(
dev, ISP_MAX_SUBDEVS, sizeof(*notifier->subdevs), GFP_KERNEL);
@@ -2156,30 +2201,25 @@ static int isp_of_parse_nodes(struct device *dev,
while (notifier->num_subdevs < ISP_MAX_SUBDEVS &&
(node = of_graph_get_next_endpoint(dev->of_node, node))) {
- struct isp_async_subdev *isd;
-
- isd = devm_kzalloc(dev, sizeof(*isd), GFP_KERNEL);
- if (!isd) {
- of_node_put(node);
- return -ENOMEM;
- }
-
- notifier->subdevs[notifier->num_subdevs] = &isd->asd;
-
- if (isp_of_parse_node(dev, node, isd)) {
- of_node_put(node);
- return -EINVAL;
- }
+ ret = isp_of_parse_node(dev, node, notifier, true);
+ if (ret)
+ return ret;
+ }
- isd->asd.match.of.node = of_graph_get_remote_port_parent(node);
- of_node_put(node);
- if (!isd->asd.match.of.node) {
- dev_warn(dev, "bad remote port parent\n");
+ while (notifier->num_subdevs < ISP_MAX_SUBDEVS &&
+ (node = of_parse_phandle(dev->of_node, "ti,camera-flashes",
+ flash++))) {
+ struct device_node *sensor_node =
+ of_parse_phandle(dev->of_node, "ti,camera-flashes",
+ flash++);
+ unsigned int i;
+
+ if (!sensor_node)
return -EINVAL;
- }
- isd->asd.match_type = V4L2_ASYNC_MATCH_OF;
- notifier->num_subdevs++;
+ ret = isp_of_parse_node(dev, node, notifier, false);
+ if (ret)
+ return ret;
}
return notifier->num_subdevs;
@@ -2193,7 +2233,7 @@ static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async,
container_of(asd, struct isp_async_subdev, asd);
isd->sd = subdev;
- isd->sd->host_priv = &isd->bus;
+ isd->sd->host_priv = isd->bus;
return 0;
}
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 7e6f663..c0b9d1d 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -228,7 +228,7 @@ struct isp_device {
struct isp_async_subdev {
struct v4l2_subdev *sd;
- struct isp_bus_cfg bus;
+ struct isp_bus_cfg *bus;
struct v4l2_async_subdev asd;
};
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c b/drivers/media/platform/omap3isp/ispcsiphy.c
index 495447d..750ce93 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -177,7 +177,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
struct isp_async_subdev *isd =
container_of(pipe->external->asd,
struct isp_async_subdev, asd);
- buscfg = &isd->bus;
+ buscfg = isd->bus;
}
if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
--
2.1.4
--azLHFNyN32YCQGCU
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0004-omap3isp-Assign-a-group-ID-for-sensor-and-flash-enti.patch"