aboutsummaryrefslogtreecommitdiffstats
path: root/extras/recipes-kernel/linux/linux-omap-psp-2.6.32/cam/0066-mt9t112-Add-Context-selection-to-configuration.patch
blob: 0afb340d859151a00dddde7417a2c85b8dee5aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From a1066fd19c56f96201b877b394247db9c41c3c18 Mon Sep 17 00:00:00 2001
From: Sergio Aguirre <saaguirre@ti.com>
Date: Sun, 18 Jul 2010 01:12:41 -0500
Subject: [PATCH 66/75] mt9t112: Add Context selection to configuration

Thsi makes always start at least with preview mode
(context A), and then, if needed, transition to capture
mode (context B)

Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
---
 drivers/media/video/mt9t112.c |   54 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/mt9t112.c b/drivers/media/video/mt9t112.c
index ee991ef..ec7514f 100644
--- a/drivers/media/video/mt9t112.c
+++ b/drivers/media/video/mt9t112.c
@@ -73,6 +73,9 @@
 #define mt9t112_reg_read(ret, client, a) \
 	ECHECKER(ret, __mt9t112_reg_read(client, a))
 
+#define mt9t112_mcu_read(ret, client, a) \
+	ECHECKER(ret, __mt9t112_mcu_read(client, a))
+
 /*
  * Logical address
  */
@@ -737,6 +740,50 @@ static int mt9t112_auto_focus_trigger(const struct i2c_client *client)
 	return ret;
 }
 
+static int mt9t112_goto_preview(const struct i2c_client *client)
+{
+	int ret, trycount = 0;
+
+	/* Is it already in preview mode? */
+	mt9t112_mcu_read(ret, client, VAR8(1, 1));
+	if (ret == 0x3)
+		return 0;
+
+	/* Go to preview mode */
+	mt9t112_mcu_write(ret, client, VAR8(1, 0), 1);
+	do {
+		mt9t112_mcu_read(ret, client, VAR8(1, 1));
+		mdelay(1);
+	} while ((ret != 0x3) && (++trycount < 100));
+
+	if (trycount >= 100)
+		return -EBUSY;
+
+	return 0;
+}
+
+static int mt9t112_goto_capture(const struct i2c_client *client)
+{
+	int ret, trycount = 0;
+
+	/* Is it already in capture mode? */
+	mt9t112_mcu_read(ret, client, VAR8(1, 1));
+	if (ret == 0x7)
+		return 0;
+
+	/* Go to capture mode */
+	mt9t112_mcu_write(ret, client, VAR8(1, 0), 2);
+	do {
+		mt9t112_mcu_read(ret, client, VAR8(1, 1));
+		mdelay(1);
+	} while ((ret != 0x7) && (++trycount < 100));
+
+	if (trycount >= 100)
+		return -EBUSY;
+
+	return 0;
+}
+
 static int mt9t112_init_camera(const struct i2c_client *client)
 {
 	int ret;
@@ -1034,6 +1081,13 @@ static int mt9t112_v4l2_int_s_power(struct v4l2_int_device *s,
 
 		ECHECKER(ret, mt9t112_auto_focus_trigger(client));
 
+		ECHECKER(ret, mt9t112_goto_preview(client));
+
+		if ((priv->pix.width == MAX_WIDTH) &&
+		    (priv->pix.height == MAX_HEIGHT)) {
+			ECHECKER(ret, mt9t112_goto_capture(client));
+		}
+
 		dev_dbg(&client->dev, "format : %d\n", priv->pix.pixelformat);
 		dev_dbg(&client->dev, "size   : %d x %d\n",
 			priv->pix.width,
-- 
1.6.6.1