From ad5be16342cea9a6bb17f8f9c8d2635a0d6b027f Mon Sep 17 00:00:00 2001
From: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Date: Thu, 7 Feb 2019 17:33:53 +0300
Subject: [PATCH 100/122] lvds: ti9x4: add DVP LSB/MSB selection

This add DVP 8bits LSB/MSB selection from 12bit bus

Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
---
 drivers/media/i2c/soc_camera/ti9x4.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/soc_camera/ti9x4.c b/drivers/media/i2c/soc_camera/ti9x4.c
index 373652a..fdb50e5 100644
--- a/drivers/media/i2c/soc_camera/ti9x4.c
+++ b/drivers/media/i2c/soc_camera/ti9x4.c
@@ -34,6 +34,7 @@ struct ti9x4_priv {
 	const char		*forwarding_mode;
 	int			is_coax;
 	int			dvp_bus;
+	int			dvp_lsb;
 	int			hsync;
 	int			vsync;
 	int			poc_delay;
@@ -62,6 +63,10 @@ static int dvp_bus = 8;
 module_param(dvp_bus, int, 0644);
 MODULE_PARM_DESC(dvp_bus, "  DVP/CSI over FPDLink (default: DVP 8-bit)");
 
+static int dvp_lsb = 0;
+module_param(dvp_lsb, int, 0644);
+MODULE_PARM_DESC(dvp_lsb, "  DVP 8-bit LSB/MSB selection (default: DVP 8-bit MSB)");
+
 static int hsync;
 module_param(hsync, int, 0644);
 MODULE_PARM_DESC(hsync, " HSYNC invertion (default: 0 - not inverted)");
@@ -248,7 +253,7 @@ static void ti9x4_fpdlink3_setup(struct i2c_client *client, int idx)
 
 	switch (priv->dvp_bus) {
 	case 8:
-		port_config2 |= 0x80;				/* RAW10 as 8-bit prosessing using upper bits */
+		port_config2 |= (priv->dvp_lsb ? 0xC0 : 0x80);	/* RAW10 as 8-bit prosessing using LSB/MSB bits  */
 		/* fall through */
 	case 10:
 		port_config |= 0x03;				/* DVP over FPDLink (TI913 compatible) RAW10/RAW8 */
@@ -472,6 +477,10 @@ static int ti9x4_parse_dt(struct i2c_client *client)
 		priv->is_coax = 1;
 	if (of_property_read_u32(np, "ti,dvp_bus", &priv->dvp_bus))
 		priv->dvp_bus = 8;
+	if (of_property_read_bool(np, "ti,dvp_lsb"))
+		priv->dvp_lsb = 1;
+	else
+		priv->dvp_lsb = 0;
 	if (of_property_read_u32(np, "ti,hsync", &priv->hsync))
 		priv->hsync = 0;
 	if (of_property_read_u32(np, "ti,vsync", &priv->vsync))
@@ -512,6 +521,8 @@ static int ti9x4_parse_dt(struct i2c_client *client)
 		priv->is_coax = 0;
 	if (dvp_bus != 8)
 		priv->dvp_bus = dvp_bus;
+	if (dvp_lsb)
+		priv->dvp_lsb = dvp_lsb;
 	if (hsync)
 		priv->hsync = hsync;
 	if (!vsync)
-- 
2.7.4

