From: "Lad, Prabhakar"<prabhakar.csengg@xxxxxxxxx>
add OF support for the tvp7002 driver.
Signed-off-by: Lad, Prabhakar<prabhakar.csengg@xxxxxxxxx>
Cc: Hans Verkuil<hans.verkuil@xxxxxxxxx>
Cc: Laurent Pinchart<laurent.pinchart@xxxxxxxxxxxxxxxx>
Cc: Mauro Carvalho Chehab<mchehab@xxxxxxxxxx>
Cc: Guennadi Liakhovetski<g.liakhovetski@xxxxxx>
Cc: Sylwester Nawrocki<s.nawrocki@xxxxxxxxxxx>
Cc: Sakari Ailus<sakari.ailus@xxxxxx>
Cc: Grant Likely<grant.likely@xxxxxxxxxxxx>
Cc: Rob Herring<rob.herring@xxxxxxxxxxx>
Cc: Rob Landley<rob@xxxxxxxxxxx>
Cc: devicetree-discuss@xxxxxxxxxxxxxxxx
Cc: linux-doc@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: davinci-linux-open-source@xxxxxxxxxxxxxxxxxxxx
---
Depends on patch https://patchwork.kernel.org/patch/2765851/
.../devicetree/bindings/media/i2c/tvp7002.txt | 43 +++++++++++++
drivers/media/i2c/tvp7002.c | 67 ++++++++++++++++++--
2 files changed, 103 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp7002.txt
diff --git a/Documentation/devicetree/bindings/media/i2c/tvp7002.txt b/Documentation/devicetree/bindings/media/i2c/tvp7002.txt
new file mode 100644
index 0000000..9daebe1
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/tvp7002.txt
@@ -0,0 +1,43 @@
+* Texas Instruments TV7002 video decoder
+
+The TVP7002 device supports digitizing of video and graphics signal in RGB and
+YPbPr color space.
+
+Required Properties :
+- compatible : Must be "ti,tvp7002"
+
+- hsync-active: HSYNC Polarity configuration for endpoint.
+
+- vsync-active: VSYNC Polarity configuration for endpoint.
+
+- pclk-sample: Clock polarity of the endpoint.
+
+- video-sync: Video sync property of the endpoint.
+
+- ti,tvp7002-fid-polarity: Active-high Field ID polarity of the endpoint.
+
+For further reading of port node refer Documentation/devicetree/bindings/media/
+video-interfaces.txt.
+
+Example:
+
+ i2c0@1c22000 {
+ ...
+ ...
+ tvp7002@5c {
+ compatible = "ti,tvp7002";
+ reg =<0x5c>;
+
+ port {
+ tvp7002_1: endpoint {
+ hsync-active =<1>;
+ vsync-active =<1>;
+ pclk-sample =<0>;
+ video-sync =<V4L2_MBUS_VIDEO_SYNC_ON_GREEN>;
+ ti,tvp7002-fid-polarity;
+ };
+ };
+ };
+ ...
+ };
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index b577548..4896024 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -35,6 +35,8 @@
#include<media/v4l2-device.h>
#include<media/v4l2-common.h>
#include<media/v4l2-ctrls.h>
+#include<media/v4l2-of.h>
+
#include "tvp7002_reg.h"
MODULE_DESCRIPTION("TI TVP7002 Video and Graphics Digitizer driver");
@@ -943,6 +945,48 @@ static const struct v4l2_subdev_ops tvp7002_ops = {
.pad =&tvp7002_pad_ops,
};
+static struct tvp7002_config *
+tvp7002_get_pdata(struct i2c_client *client)
+{
+ struct v4l2_of_endpoint bus_cfg;
+ struct tvp7002_config *pdata;
+ struct device_node *endpoint;
+ unsigned int flags;
+
+ if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
+ return client->dev.platform_data;
+
+ endpoint = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
+ if (!endpoint)
+ return NULL;
+
+ pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ goto done;
+
+ v4l2_of_parse_endpoint(endpoint,&bus_cfg);
+ flags = bus_cfg.bus.parallel.flags;
+
+ if (flags& V4L2_MBUS_HSYNC_ACTIVE_HIGH)
+ pdata->hs_polarity = 1;
+
+ if (flags& V4L2_MBUS_VSYNC_ACTIVE_HIGH)
+ pdata->vs_polarity = 1;
+
+ if (flags& V4L2_MBUS_PCLK_SAMPLE_RISING)
+ pdata->clk_polarity = 1;
+
+ if (flags& V4L2_MBUS_VIDEO_SYNC_ON_GREEN)
+ pdata->sog_polarity = 1;
+ pdata->fid_polarity = of_property_read_bool(endpoint,
+ "ti,tvp7002-fid-polarity");
+done:
+ of_node_put(endpoint);
+ return pdata;
+}