Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
m5602_s5k83a.h
Go to the documentation of this file.
1 /*
2  * Driver for the s5k83a sensor
3  *
4  * Copyright (C) 2008 Erik AndrĂ©n
5  * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6  * Copyright (C) 2005 m5603x Linux Driver Project <[email protected]>
7  *
8  * Portions of code to USB interface and ALi driver software,
9  * Copyright (c) 2006 Willem Duinker
10  * v4l2 interface modeled after the V4L2 driver
11  * for SN9C10x PC Camera Controllers
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License as
15  * published by the Free Software Foundation, version 2.
16  *
17  */
18 
19 #ifndef M5602_S5K83A_H_
20 #define M5602_S5K83A_H_
21 
22 #include "m5602_sensor.h"
23 
24 #define S5K83A_FLIP 0x01
25 #define S5K83A_HFLIP_TUNE 0x03
26 #define S5K83A_VFLIP_TUNE 0x05
27 #define S5K83A_BRIGHTNESS 0x0a
28 #define S5K83A_EXPOSURE 0x18
29 #define S5K83A_GAIN 0x1b
30 #define S5K83A_PAGE_MAP 0xec
31 
32 #define S5K83A_DEFAULT_GAIN 0x71
33 #define S5K83A_DEFAULT_BRIGHTNESS 0x7e
34 #define S5K83A_DEFAULT_EXPOSURE 0x00
35 #define S5K83A_MAXIMUM_EXPOSURE 0x3c
36 #define S5K83A_FLIP_MASK 0x10
37 #define S5K83A_GPIO_LED_MASK 0x10
38 #define S5K83A_GPIO_ROTATION_MASK 0x40
39 
40 /*****************************************************************************/
41 
42 /* Kernel module parameters */
43 extern int force_sensor;
44 extern bool dump_sensor;
45 
46 int s5k83a_probe(struct sd *sd);
47 int s5k83a_init(struct sd *sd);
48 int s5k83a_start(struct sd *sd);
49 int s5k83a_stop(struct sd *sd);
50 void s5k83a_disconnect(struct sd *sd);
51 
52 static const struct m5602_sensor s5k83a = {
53  .name = "S5K83A",
54  .probe = s5k83a_probe,
55  .init = s5k83a_init,
56  .start = s5k83a_start,
57  .stop = s5k83a_stop,
58  .disconnect = s5k83a_disconnect,
59  .i2c_slave_id = 0x5a,
60  .i2c_regW = 2,
61 };
62 
63 struct s5k83a_priv {
64  /* We use another thread periodically
65  probing the orientation of the camera */
68 };
69 
70 static const unsigned char preinit_s5k83a[][4] = {
71  {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
72  {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
73  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
74  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
75  {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
76  {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d, 0x00},
77  {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00, 0x00},
78 
79  {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
80  {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
81  {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
82  {BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},
83  {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},
84  {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
85  {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
86  {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
87  {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
88  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},
89  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},
90  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
91  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
92  {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
93  {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
94  {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
95  {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
96  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
97  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
98  {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
99  {BRIDGE, M5602_XB_GPIO_DAT, 0x1c, 0x00},
100  {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
101  {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
102  {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
103  {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
104  {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},
105 };
106 
107 /* This could probably be considerably shortened.
108  I don't have the hardware to experiment with it, patches welcome
109 */
110 static const unsigned char init_s5k83a[][4] = {
111  /* The following sequence is useless after a clean boot
112  but is necessary after resume from suspend */
113  {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
114  {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
115  {BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},
116  {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},
117  {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
118  {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
119  {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
120  {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
121  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},
122  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},
123  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
124  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
125  {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
126  {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
127  {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
128  {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
129  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
130  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
131  {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
132  {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
133  {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
134  {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
135  {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
136  {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
137  {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},
138 
139  {SENSOR, S5K83A_PAGE_MAP, 0x04, 0x00},
140  {SENSOR, 0xaf, 0x01, 0x00},
141  {SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
142  {SENSOR, 0x7b, 0xff, 0x00},
143  {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
144  {SENSOR, 0x01, 0x50, 0x00},
145  {SENSOR, 0x12, 0x20, 0x00},
146  {SENSOR, 0x17, 0x40, 0x00},
147  {SENSOR, 0x1c, 0x00, 0x00},
148  {SENSOR, 0x02, 0x70, 0x00},
149  {SENSOR, 0x03, 0x0b, 0x00},
150  {SENSOR, 0x04, 0xf0, 0x00},
151  {SENSOR, 0x05, 0x0b, 0x00},
152  {SENSOR, 0x06, 0x71, 0x00},
153  {SENSOR, 0x07, 0xe8, 0x00}, /* 488 */
154  {SENSOR, 0x08, 0x02, 0x00},
155  {SENSOR, 0x09, 0x88, 0x00}, /* 648 */
156  {SENSOR, 0x14, 0x00, 0x00},
157  {SENSOR, 0x15, 0x20, 0x00}, /* 32 */
158  {SENSOR, 0x19, 0x00, 0x00},
159  {SENSOR, 0x1a, 0x98, 0x00}, /* 152 */
160  {SENSOR, 0x0f, 0x02, 0x00},
161  {SENSOR, 0x10, 0xe5, 0x00}, /* 741 */
162  /* normal colors
163  (this is value after boot, but after tries can be different) */
164  {SENSOR, 0x00, 0x06, 0x00},
165 };
166 
167 static const unsigned char start_s5k83a[][4] = {
168  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
169  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
170  {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
171  {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
172  {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
173  {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
174  {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
175  {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
176  {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
177  {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
178  {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
179  {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
180  {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00}, /* 484 */
181  {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
182  {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
183  {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
184  {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
185  {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
186  {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
187  {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
188  {BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00}, /* 639 */
189  {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
190  {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
191  {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
192 };
193 #endif