From 98b1559d3a38984a949afaf06a8684ca2f1d118a Mon Sep 17 00:00:00 2001
From: Brian Johnson <brijohn@gmail.com>
Date: Fri, 9 Jan 2009 14:19:03 -0500
Subject: [PATCH] Added support for om6802 sensor

Signed-off-by: Brian Johnson <brijohn@gmail.com>
---
 Makefile      |    2 +-
 om6802.c      |   39 +++++++++++++++++++++++++++++++++++++++
 sn9c20x-dev.c |    6 ++++++
 sn9c20x-usb.c |    2 +-
 sn9c20x.h     |    2 ++
 5 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 om6802.c

diff --git a/Makefile b/Makefile
index 45a0506..2c4b2ca 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ include $(src)/.config
 
 sn9c20x-objs := sn9c20x-usb.o sn9c20x-v4l2.o sn9c20x-sysfs.o
 sn9c20x-objs += sn9c20x-dev.o sn9c20x-queue.o
-sn9c20x-objs += sn9c20x-bridge.o omnivision.o micron.o hv7131r.o
+sn9c20x-objs += sn9c20x-bridge.o omnivision.o micron.o hv7131r.o om6802.o
 
 ifeq ($(CONFIG_SN9C20X_DEBUGFS),y)
 sn9c20x-objs += sn9c20x-debugfs.o
diff --git a/om6802.c b/om6802.c
new file mode 100644
index 0000000..556bd84
--- /dev/null
+++ b/om6802.c
@@ -0,0 +1,39 @@
+/**
+ * @file om6802.c
+ * @date 2009-1-9
+ *
+ * @brief Common control functions for OM6802 Image Sensor.
+ *
+ * @par Licences
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "sn9c20x.h"
+#include "sn9c20x-bridge.h"
+#include "micron.h"
+
+struct sn9c20x_i2c_regs om6802_init[] = {
+	{0x90, 0x05},
+	{0x4d, 0x05},
+	{0xc9, 0x58},
+	{0x49, 0x85},
+	{0x5a, 0xc0},
+	{0xdd, 0x18},
+	{0xf0, 0x04},
+	{0xe9, 0x0f},
+	{0xe4, 0xff},
+	{0xff, 0xff},
+};
diff --git a/sn9c20x-dev.c b/sn9c20x-dev.c
index 78eae92..228b96e 100644
--- a/sn9c20x-dev.c
+++ b/sn9c20x-dev.c
@@ -221,6 +221,12 @@ int sn9c20x_initialize_sensor(struct usb_sn9c20x *dev)
 		dev->camera.vstart = 1;
 		UDIA_INFO("Detected HV7131R Sensor.\n");
 		break;
+	case OM6802_SENSOR:
+		sn9c20x_write_i2c_array(dev, om6802_init, 0);
+		dev->camera.hstart = 0;
+		dev->camera.vstart = 1;
+		UDIA_INFO("Detected OM6802 Sensor.\n");
+		break;
 	default:
 		ret = -EINVAL;
 		UDIA_INFO("Unsupported sensor.\n");
diff --git a/sn9c20x-usb.c b/sn9c20x-usb.c
index f001016..3aa0e5c 100644
--- a/sn9c20x-usb.c
+++ b/sn9c20x-usb.c
@@ -197,7 +197,7 @@ static struct usb_device_id sn9c20x_table[] = {
 	/* SN9C201 + OV7670ISP */
 	{SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6260_PID, OV7670_SENSOR, 0x21)},
 	/* SN9C201 + OM6802 */
-	{SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6262_PID, 0, 0)},
+	{SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6262_PID, OM6802_SENSOR, 0x34)},
 	/* SN9C201 + MI0360/MT9V111 */
 	{SN9C20X_USB_DEVICE(USB_0C45_VID, USB_6270_PID, 0, 0)},
 	/* SN9C201 + S5K53BEB */
diff --git a/sn9c20x.h b/sn9c20x.h
index d5d2473..64bfa00 100644
--- a/sn9c20x.h
+++ b/sn9c20x.h
@@ -326,6 +326,7 @@ enum sn9c20x_sensors {
 	MT9M001_SENSOR		= 9,
 	HV7131R_SENSOR		= 10,
 	MT9V112_SENSOR		= 11,
+	OM6802_SENSOR		= 12,
 };
 
 
@@ -362,6 +363,7 @@ extern struct sn9c20x_i2c_regs ov9655_init[];
 extern struct sn9c20x_i2c_regs ov7660_init[];
 extern struct sn9c20x_i2c_regs ov7670_init[];
 extern struct sn9c20x_i2c_regs hv7131r_init[];
+extern struct sn9c20x_i2c_regs om6802_init[];
 
 #define SN9C20X_N_FMTS	4
 #define SN9C20X_N_MODES	6
-- 
1.5.6.3

