On 7 January 2009 18:11:03 Vasily Khoruzhick wrote:
> This patch adds gain control for ov9650 sensor.
>
> Regards
> Vasily

Oops, forgot to attach patch :)
Here it is.
From 5280ad318549ecf1585cbb5e0c38ba471a126ed1 Mon Sep 17 00:00:00 2001
From: Vasily Khoruzhick <[email protected]>
Date: Wed, 7 Jan 2009 18:09:26 +0200
Subject: [PATCH] Added OV9650 gain control


Signed-off-by: Vasily Khoruzhick <[email protected]>
---
 omnivision.c  |   39 +++++++++++++++++++++++++++++++++++++++
 omnivision.h  |    1 +
 sn9c20x-dev.c |    1 +
 3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/omnivision.c b/omnivision.c
index f14df4c..cbd5a59 100644
--- a/omnivision.c
+++ b/omnivision.c
@@ -721,6 +721,45 @@ int soi968_set_gain(struct usb_sn9c20x *dev)
 	return ret;
 }
 
+/*
+ * @brief Set gain for ov9650 sensor
+ *
+ * @param dev
+ *
+ * @returns 0 or negative error value
+ *
+ * @author Vasily Khoruzhick
+ *
+ */
+int ov9650_set_gain(struct usb_sn9c20x *dev)
+{
+	__u8 buf[1];
+	int ret = 0;
+
+	buf[0] = (dev->vsettings.gain >> 1) & 0x0F;
+	switch (dev->vsettings.gain >> 1 & 0xF0) {
+	case 0x00:
+		break;
+	case 0x10:
+		buf[0] |= 0x10;
+		break;
+	case 0x20:
+		buf[0] |= 0x30;
+		break;
+	case 0x30:
+		buf[0] |= 0x70;
+		break;
+	case 0x40:
+		buf[0] |= 0xF0;
+		break;
+	default:
+		buf[0] |= 0xFF;
+		break;
+	}
+	ret |= sn9c20x_write_i2c_data(dev, 1, OV965X_CTL_GAIN, buf);
+
+	return ret;
+}
 
 /**
  * @brief Detect whether the image for 6260 has to be flipped
diff --git a/omnivision.h b/omnivision.h
index ebf2a01..c67c237 100644
--- a/omnivision.h
+++ b/omnivision.h
@@ -541,6 +541,7 @@ int soi968_set_autoexposure(struct usb_sn9c20x *dev);
 
 int ov965x_set_hvflip(struct usb_sn9c20x *);
 int ov965x_flip_detect(struct usb_sn9c20x *dev);
+int ov9650_set_gain(struct usb_sn9c20x *dev);
 
 int ov_set_exposure(struct usb_sn9c20x *);
 int ov_set_autogain(struct usb_sn9c20x *dev);
diff --git a/sn9c20x-dev.c b/sn9c20x-dev.c
index e0d4e13..ce6dc48 100644
--- a/sn9c20x-dev.c
+++ b/sn9c20x-dev.c
@@ -145,6 +145,7 @@ int sn9c20x_initialize_sensor(struct usb_sn9c20x *dev)
 		dev->camera.set_hvflip = ov965x_set_hvflip;
 		dev->camera.set_exposure = ov_set_exposure;
 		dev->camera.set_auto_gain = ov_set_autogain;
+		dev->camera.set_gain = ov9650_set_gain;
 		dev->camera.flip_detect = ov965x_flip_detect;
 		UDIA_INFO("Detected OV9650 Sensor.\n");
 		break;
-- 
1.6.0.6

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to