diff options
-rw-r--r-- | Documentation/video4linux/gspca.txt | 2 | ||||
-rw-r--r-- | drivers/media/video/gspca/Kconfig | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/Kconfig | 8 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/Makefile | 10 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/gl860-mi1320.c | 537 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/gl860-mi2020.c | 937 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/gl860-ov2640.c | 505 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/gl860-ov9655.c | 337 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/gl860.c | 783 | ||||
-rw-r--r-- | drivers/media/video/gspca/gl860/gl860.h | 108 |
11 files changed, 3229 insertions, 0 deletions
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt index 4686e84dd800..3f61825be499 100644 --- a/Documentation/video4linux/gspca.txt +++ b/Documentation/video4linux/gspca.txt | |||
@@ -173,6 +173,8 @@ ov519 05a9:8519 OmniVision | |||
173 | ov519 05a9:a518 D-Link DSB-C310 Webcam | 173 | ov519 05a9:a518 D-Link DSB-C310 Webcam |
174 | sunplus 05da:1018 Digital Dream Enigma 1.3 | 174 | sunplus 05da:1018 Digital Dream Enigma 1.3 |
175 | stk014 05e1:0893 Syntek DV4000 | 175 | stk014 05e1:0893 Syntek DV4000 |
176 | gl860 05e3:0503 Genesys Logic PC Camera | ||
177 | gl860 05e3:f191 Genesys Logic PC Camera | ||
176 | spca561 060b:a001 Maxell Compact Pc PM3 | 178 | spca561 060b:a001 Maxell Compact Pc PM3 |
177 | zc3xx 0698:2003 CTX M730V built in | 179 | zc3xx 0698:2003 CTX M730V built in |
178 | spca500 06bd:0404 Agfa CL20 | 180 | spca500 06bd:0404 Agfa CL20 |
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig index 8897283b0bb4..fe2e490ebc52 100644 --- a/drivers/media/video/gspca/Kconfig +++ b/drivers/media/video/gspca/Kconfig | |||
@@ -19,6 +19,7 @@ if USB_GSPCA && VIDEO_V4L2 | |||
19 | 19 | ||
20 | source "drivers/media/video/gspca/m5602/Kconfig" | 20 | source "drivers/media/video/gspca/m5602/Kconfig" |
21 | source "drivers/media/video/gspca/stv06xx/Kconfig" | 21 | source "drivers/media/video/gspca/stv06xx/Kconfig" |
22 | source "drivers/media/video/gspca/gl860/Kconfig" | ||
22 | 23 | ||
23 | config USB_GSPCA_CONEX | 24 | config USB_GSPCA_CONEX |
24 | tristate "Conexant Camera Driver" | 25 | tristate "Conexant Camera Driver" |
diff --git a/drivers/media/video/gspca/Makefile b/drivers/media/video/gspca/Makefile index 035616b5e867..b7420818037e 100644 --- a/drivers/media/video/gspca/Makefile +++ b/drivers/media/video/gspca/Makefile | |||
@@ -58,3 +58,4 @@ gspca_zc3xx-objs := zc3xx.o | |||
58 | 58 | ||
59 | obj-$(CONFIG_USB_M5602) += m5602/ | 59 | obj-$(CONFIG_USB_M5602) += m5602/ |
60 | obj-$(CONFIG_USB_STV06XX) += stv06xx/ | 60 | obj-$(CONFIG_USB_STV06XX) += stv06xx/ |
61 | obj-$(CONFIG_USB_GL860) += gl860/ | ||
diff --git a/drivers/media/video/gspca/gl860/Kconfig b/drivers/media/video/gspca/gl860/Kconfig new file mode 100644 index 000000000000..22772f53ec7b --- /dev/null +++ b/drivers/media/video/gspca/gl860/Kconfig | |||
@@ -0,0 +1,8 @@ | |||
1 | config USB_GL860 | ||
2 | tristate "GL860 USB Camera Driver" | ||
3 | depends on VIDEO_V4L2 && USB_GSPCA | ||
4 | help | ||
5 | Say Y here if you want support for cameras based on the GL860 chip. | ||
6 | |||
7 | To compile this driver as a module, choose M here: the | ||
8 | module will be called gspca_gl860. | ||
diff --git a/drivers/media/video/gspca/gl860/Makefile b/drivers/media/video/gspca/gl860/Makefile new file mode 100644 index 000000000000..13c9403cc87d --- /dev/null +++ b/drivers/media/video/gspca/gl860/Makefile | |||
@@ -0,0 +1,10 @@ | |||
1 | obj-$(CONFIG_USB_GL860) += gspca_gl860.o | ||
2 | |||
3 | gspca_gl860-objs := gl860.o \ | ||
4 | gl860-mi1320.o \ | ||
5 | gl860-ov2640.o \ | ||
6 | gl860-ov9655.o \ | ||
7 | gl860-mi2020.o | ||
8 | |||
9 | EXTRA_CFLAGS += -Idrivers/media/video/gspca | ||
10 | |||
diff --git a/drivers/media/video/gspca/gl860/gl860-mi1320.c b/drivers/media/video/gspca/gl860/gl860-mi1320.c new file mode 100644 index 000000000000..39f6261c1a0c --- /dev/null +++ b/drivers/media/video/gspca/gl860/gl860-mi1320.c | |||
@@ -0,0 +1,537 @@ | |||
1 | /* @file gl860-mi1320.c | ||
2 | * @author Olivier LORIN from my logs | ||
3 | * @date 2009-08-27 | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /* Sensor : MI1320 */ | ||
20 | |||
21 | #include "gl860.h" | ||
22 | |||
23 | static struct validx tbl_common[] = { | ||
24 | {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba51, 0x0066}, {0xba02, 0x00f1}, | ||
25 | {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1}, | ||
26 | {0xffff, 0xffff}, | ||
27 | {0xba00, 0x00f0}, {0xba02, 0x00f1}, {0xbafa, 0x0028}, {0xba02, 0x00f1}, | ||
28 | {0xba00, 0x00f0}, {0xba01, 0x00f1}, {0xbaf0, 0x0006}, {0xba0e, 0x00f1}, | ||
29 | {0xba70, 0x0006}, {0xba0e, 0x00f1}, | ||
30 | {0xffff, 0xffff}, | ||
31 | {0xba74, 0x0006}, {0xba0e, 0x00f1}, | ||
32 | {0xffff, 0xffff}, | ||
33 | {0x0061, 0x0000}, {0x0068, 0x000d}, | ||
34 | }; | ||
35 | |||
36 | static struct validx tbl_init_at_startup[] = { | ||
37 | {0x0000, 0x0000}, {0x0010, 0x0010}, | ||
38 | {35, 0xffff}, | ||
39 | {0x0008, 0x00c0}, {0x0001, 0x00c1}, {0x0001, 0x00c2}, {0x0020, 0x0006}, | ||
40 | {0x006a, 0x000d}, | ||
41 | }; | ||
42 | |||
43 | static struct validx tbl_sensor_settings_common[] = { | ||
44 | {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, {0x0040, 0x0000}, | ||
45 | {0x006a, 0x0007}, {0x006a, 0x000d}, {0x0063, 0x0006}, | ||
46 | }; | ||
47 | static struct validx tbl_sensor_settings_1280[] = { | ||
48 | {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba5a, 0x0066}, {0xba02, 0x00f1}, | ||
49 | {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xba20, 0x0065}, {0xba00, 0x00f1}, | ||
50 | }; | ||
51 | static struct validx tbl_sensor_settings_800[] = { | ||
52 | {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xba5a, 0x0066}, {0xba02, 0x00f1}, | ||
53 | {0xba05, 0x0067}, {0xba05, 0x00f1}, {0xba20, 0x0065}, {0xba00, 0x00f1}, | ||
54 | }; | ||
55 | static struct validx tbl_sensor_settings_640[] = { | ||
56 | {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1}, | ||
57 | {0xba51, 0x0066}, {0xba02, 0x00f1}, {0xba05, 0x0067}, {0xba05, 0x00f1}, | ||
58 | {0xba20, 0x0065}, {0xba00, 0x00f1}, | ||
59 | }; | ||
60 | static struct validx tbl_post_unset_alt[] = { | ||
61 | {0xba00, 0x00f0}, {0xba00, 0x00f1}, {0xbaa0, 0x0065}, {0xba00, 0x00f1}, | ||
62 | {0x0061, 0x0000}, {0x0068, 0x000d}, | ||
63 | }; | ||
64 | |||
65 | static u8 *tbl_1280[] = { | ||
66 | "\x0d\x80\xf1\x08\x03\x04\xf1\x00" "\x04\x05\xf1\x02\x05\x00\xf1\xf1" | ||
67 | "\x06\x00\xf1\x0d\x20\x01\xf1\x00" "\x21\x84\xf1\x00\x0d\x00\xf1\x08" | ||
68 | "\xf0\x00\xf1\x01\x34\x00\xf1\x00" "\x9b\x43\xf1\x00\xa6\x05\xf1\x00" | ||
69 | "\xa9\x04\xf1\x00\xa1\x05\xf1\x00" "\xa4\x04\xf1\x00\xae\x0a\xf1\x08" | ||
70 | , | ||
71 | "\xf0\x00\xf1\x02\x3a\x05\xf1\xf1" "\x3c\x05\xf1\xf1\x59\x01\xf1\x47" | ||
72 | "\x5a\x01\xf1\x88\x5c\x0a\xf1\x06" "\x5d\x0e\xf1\x0a\x64\x5e\xf1\x1c" | ||
73 | "\xd2\x00\xf1\xcf\xcb\x00\xf1\x01" | ||
74 | , | ||
75 | "\xd3\x02\xd4\x28\xd5\x01\xd0\x02" "\xd1\x18\xd2\xc1" | ||
76 | }; | ||
77 | |||
78 | static u8 *tbl_800[] = { | ||
79 | "\x0d\x80\xf1\x08\x03\x03\xf1\xc0" "\x04\x05\xf1\x02\x05\x00\xf1\xf1" | ||
80 | "\x06\x00\xf1\x0d\x20\x01\xf1\x00" "\x21\x84\xf1\x00\x0d\x00\xf1\x08" | ||
81 | "\xf0\x00\xf1\x01\x34\x00\xf1\x00" "\x9b\x43\xf1\x00\xa6\x05\xf1\x00" | ||
82 | "\xa9\x03\xf1\xc0\xa1\x03\xf1\x20" "\xa4\x02\xf1\x5a\xae\x0a\xf1\x08" | ||
83 | , | ||
84 | "\xf0\x00\xf1\x02\x3a\x05\xf1\xf1" "\x3c\x05\xf1\xf1\x59\x01\xf1\x47" | ||
85 | "\x5a\x01\xf1\x88\x5c\x0a\xf1\x06" "\x5d\x0e\xf1\x0a\x64\x5e\xf1\x1c" | ||
86 | "\xd2\x00\xf1\xcf\xcb\x00\xf1\x01" | ||
87 | , | ||
88 | "\xd3\x02\xd4\x18\xd5\x21\xd0\x02" "\xd1\x10\xd2\x59" | ||
89 | }; | ||
90 | |||
91 | static u8 *tbl_640[] = { | ||
92 | "\x0d\x80\xf1\x08\x03\x04\xf1\x04" "\x04\x05\xf1\x02\x07\x01\xf1\x7c" | ||
93 | "\x08\x00\xf1\x0e\x21\x80\xf1\x00" "\x0d\x00\xf1\x08\xf0\x00\xf1\x01" | ||
94 | "\x34\x10\xf1\x10\x3a\x43\xf1\x00" "\xa6\x05\xf1\x02\xa9\x04\xf1\x04" | ||
95 | "\xa7\x02\xf1\x81\xaa\x01\xf1\xe2" "\xae\x0c\xf1\x09" | ||
96 | , | ||
97 | "\xf0\x00\xf1\x02\x39\x03\xf1\xfc" "\x3b\x04\xf1\x04\x57\x01\xf1\xb6" | ||
98 | "\x58\x02\xf1\x0d\x5c\x1f\xf1\x19" "\x5d\x24\xf1\x1e\x64\x5e\xf1\x1c" | ||
99 | "\xd2\x00\xf1\x00\xcb\x00\xf1\x01" | ||
100 | , | ||
101 | "\xd3\x02\xd4\x10\xd5\x81\xd0\x02" "\xd1\x08\xd2\xe1" | ||
102 | }; | ||
103 | |||
104 | static s32 tbl_sat[] = {0x25, 0x1d, 0x15, 0x0d, 0x05, 0x4d, 0x55, 0x5d, 0x2d}; | ||
105 | static s32 tbl_bright[] = {0, 8, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70}; | ||
106 | static s32 tbl_backlight[] = {0x0e, 0x06, 0x02}; | ||
107 | |||
108 | static s32 tbl_cntr1[] = { | ||
109 | 0x90, 0x98, 0xa0, 0xa8, 0xb0, 0xb8, 0xc0, 0xc8, 0xd0, 0xe0, 0xf0}; | ||
110 | static s32 tbl_cntr2[] = { | ||
111 | 0x70, 0x68, 0x60, 0x58, 0x50, 0x48, 0x40, 0x38, 0x30, 0x20, 0x10}; | ||
112 | |||
113 | static u8 dat_wbalNL[] = | ||
114 | "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x3b\x04\xf1\x2a\x47\x10\xf1\x10" | ||
115 | "\x9d\x3c\xf1\xae\xaf\x10\xf1\x00" "\xf0\x00\xf1\x02\x2f\x91\xf1\x20" | ||
116 | "\x9c\x91\xf1\x20\x37\x03\xf1\x00" "\x9d\xc5\xf1\x0f\xf0\x00\xf1\x00"; | ||
117 | |||
118 | static u8 dat_wbalLL[] = | ||
119 | "\xf0\x00\xf1\x01\x05\x00\xf1\x0c" "\x3b\x04\xf1\x2a\x47\x40\xf1\x40" | ||
120 | "\x9d\x20\xf1\xae\xaf\x10\xf1\x00" "\xf0\x00\xf1\x02\x2f\xd1\xf1\x00" | ||
121 | "\x9c\xd1\xf1\x00\x37\x03\xf1\x00" "\x9d\xc5\xf1\x3f\xf0\x00\xf1\x00"; | ||
122 | |||
123 | static u8 dat_wbalBL[] = | ||
124 | "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x47\x10\xf1\x30\x9d\x3c\xf1\xae" | ||
125 | "\xaf\x10\xf1\x00\xf0\x00\xf1\x02" "\x2f\x91\xf1\x20\x9c\x91\xf1\x20" | ||
126 | "\x37\x03\xf1\x00\x9d\xc5\xf1\x2f" "\xf0\x00\xf1\x00"; | ||
127 | |||
128 | static u8 dat_hvflip1[] = {0xf0, 0x00, 0xf1, 0x00}; | ||
129 | |||
130 | static u8 s000[] = | ||
131 | "\x00\x01\x07\x6a\x06\x63\x0d\x6a" "\xc0\x00\x10\x10\xc1\x03\xc2\x42" | ||
132 | "\xd8\x04\x58\x00\x04\x02"; | ||
133 | static u8 s001[] = | ||
134 | "\x0d\x00\xf1\x0b\x0d\x00\xf1\x08" "\x35\x00\xf1\x22\x68\x00\xf1\x5d" | ||
135 | "\xf0\x00\xf1\x01\x06\x70\xf1\x0e" "\xf0\x00\xf1\x02\xdd\x18\xf1\xe0"; | ||
136 | static u8 s002[] = | ||
137 | "\x05\x01\xf1\x84\x06\x00\xf1\x44" "\x07\x00\xf1\xbe\x08\x00\xf1\x1e" | ||
138 | "\x20\x01\xf1\x03\x21\x84\xf1\x00" "\x22\x0d\xf1\x0f\x24\x80\xf1\x00" | ||
139 | "\x34\x18\xf1\x2d\x35\x00\xf1\x22" "\x43\x83\xf1\x83\x59\x00\xf1\xff"; | ||
140 | static u8 s003[] = | ||
141 | "\xf0\x00\xf1\x02\x39\x06\xf1\x8c" "\x3a\x06\xf1\x8c\x3b\x03\xf1\xda" | ||
142 | "\x3c\x05\xf1\x30\x57\x01\xf1\x0c" "\x58\x01\xf1\x42\x59\x01\xf1\x0c" | ||
143 | "\x5a\x01\xf1\x42\x5c\x13\xf1\x0e" "\x5d\x17\xf1\x12\x64\x1e\xf1\x1c"; | ||
144 | static u8 s004[] = | ||
145 | "\xf0\x00\xf1\x02\x24\x5f\xf1\x20" "\x28\xea\xf1\x02\x5f\x41\xf1\x43"; | ||
146 | static u8 s005[] = | ||
147 | "\x02\x00\xf1\xee\x03\x29\xf1\x1a" "\x04\x02\xf1\xa4\x09\x00\xf1\x68" | ||
148 | "\x0a\x00\xf1\x2a\x0b\x00\xf1\x04" "\x0c\x00\xf1\x93\x0d\x00\xf1\x82" | ||
149 | "\x0e\x00\xf1\x40\x0f\x00\xf1\x5f" "\x10\x00\xf1\x4e\x11\x00\xf1\x5b"; | ||
150 | static u8 s006[] = | ||
151 | "\x15\x00\xf1\xc9\x16\x00\xf1\x5e" "\x17\x00\xf1\x9d\x18\x00\xf1\x06" | ||
152 | "\x19\x00\xf1\x89\x1a\x00\xf1\x12" "\x1b\x00\xf1\xa1\x1c\x00\xf1\xe4" | ||
153 | "\x1d\x00\xf1\x7a\x1e\x00\xf1\x64" "\xf6\x00\xf1\x5f"; | ||
154 | static u8 s007[] = | ||
155 | "\xf0\x00\xf1\x01\x53\x09\xf1\x03" "\x54\x3d\xf1\x1c\x55\x99\xf1\x72" | ||
156 | "\x56\xc1\xf1\xb1\x57\xd8\xf1\xce" "\x58\xe0\xf1\x00\xdc\x0a\xf1\x03" | ||
157 | "\xdd\x45\xf1\x20\xde\xae\xf1\x82" "\xdf\xdc\xf1\xc9\xe0\xf6\xf1\xea" | ||
158 | "\xe1\xff\xf1\x00"; | ||
159 | static u8 s008[] = | ||
160 | "\xf0\x00\xf1\x01\x80\x00\xf1\x06" "\x81\xf6\xf1\x08\x82\xfb\xf1\xf7" | ||
161 | "\x83\x00\xf1\xfe\xb6\x07\xf1\x03" "\xb7\x18\xf1\x0c\x84\xfb\xf1\x06" | ||
162 | "\x85\xfb\xf1\xf9\x86\x00\xf1\xff" "\xb8\x07\xf1\x04\xb9\x16\xf1\x0a"; | ||
163 | static u8 s009[] = | ||
164 | "\x87\xfa\xf1\x05\x88\xfc\xf1\xf9" "\x89\x00\xf1\xff\xba\x06\xf1\x03" | ||
165 | "\xbb\x17\xf1\x09\x8a\xe8\xf1\x14" "\x8b\xf7\xf1\xf0\x8c\xfd\xf1\xfa" | ||
166 | "\x8d\x00\xf1\x00\xbc\x05\xf1\x01" "\xbd\x0c\xf1\x08\xbe\x00\xf1\x14"; | ||
167 | static u8 s010[] = | ||
168 | "\x8e\xea\xf1\x13\x8f\xf7\xf1\xf2" "\x90\xfd\xf1\xfa\x91\x00\xf1\x00" | ||
169 | "\xbf\x05\xf1\x01\xc0\x0a\xf1\x08" "\xc1\x00\xf1\x0c\x92\xed\xf1\x0f" | ||
170 | "\x93\xf9\xf1\xf4\x94\xfe\xf1\xfb" "\x95\x00\xf1\x00\xc2\x04\xf1\x01" | ||
171 | "\xc3\x0a\xf1\x07\xc4\x00\xf1\x10"; | ||
172 | static u8 s011[] = | ||
173 | "\xf0\x00\xf1\x01\x05\x00\xf1\x06" "\x25\x00\xf1\x55\x34\x10\xf1\x10" | ||
174 | "\x35\xf0\xf1\x10\x3a\x02\xf1\x03" "\x3b\x04\xf1\x2a\x9b\x43\xf1\x00" | ||
175 | "\xa4\x03\xf1\xc0\xa7\x02\xf1\x81"; | ||
176 | |||
177 | static int mi1320_init_at_startup(struct gspca_dev *gspca_dev); | ||
178 | static int mi1320_configure_alt(struct gspca_dev *gspca_dev); | ||
179 | static int mi1320_init_pre_alt(struct gspca_dev *gspca_dev); | ||
180 | static int mi1320_init_post_alt(struct gspca_dev *gspca_dev); | ||
181 | static void mi1320_post_unset_alt(struct gspca_dev *gspca_dev); | ||
182 | static int mi1320_sensor_settings(struct gspca_dev *gspca_dev); | ||
183 | static int mi1320_camera_settings(struct gspca_dev *gspca_dev); | ||
184 | /*==========================================================================*/ | ||
185 | |||
186 | void mi1320_init_settings(struct gspca_dev *gspca_dev) | ||
187 | { | ||
188 | struct sd *sd = (struct sd *) gspca_dev; | ||
189 | |||
190 | sd->vcur.backlight = 0; | ||
191 | sd->vcur.brightness = 0; | ||
192 | sd->vcur.sharpness = 6; | ||
193 | sd->vcur.contrast = 10; | ||
194 | sd->vcur.gamma = 20; | ||
195 | sd->vcur.hue = 0; | ||
196 | sd->vcur.saturation = 6; | ||
197 | sd->vcur.whitebal = 0; | ||
198 | sd->vcur.mirror = 0; | ||
199 | sd->vcur.flip = 0; | ||
200 | sd->vcur.AC50Hz = 1; | ||
201 | |||
202 | sd->vmax.backlight = 2; | ||
203 | sd->vmax.brightness = 8; | ||
204 | sd->vmax.sharpness = 7; | ||
205 | sd->vmax.contrast = 0; /* 10 but not working with tihs driver */ | ||
206 | sd->vmax.gamma = 40; | ||
207 | sd->vmax.hue = 5 + 1; | ||
208 | sd->vmax.saturation = 8; | ||
209 | sd->vmax.whitebal = 2; | ||
210 | sd->vmax.mirror = 1; | ||
211 | sd->vmax.flip = 1; | ||
212 | sd->vmax.AC50Hz = 1; | ||
213 | |||
214 | sd->dev_camera_settings = mi1320_camera_settings; | ||
215 | sd->dev_init_at_startup = mi1320_init_at_startup; | ||
216 | sd->dev_configure_alt = mi1320_configure_alt; | ||
217 | sd->dev_init_pre_alt = mi1320_init_pre_alt; | ||
218 | sd->dev_post_unset_alt = mi1320_post_unset_alt; | ||
219 | } | ||
220 | |||
221 | /*==========================================================================*/ | ||
222 | |||
223 | static void common(struct gspca_dev *gspca_dev) | ||
224 | { | ||
225 | s32 n; /* reserved for FETCH macros */ | ||
226 | |||
227 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 22, s000); | ||
228 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL); | ||
229 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 32, s001); | ||
230 | n = fetch_validx(gspca_dev, tbl_common, ARRAY_SIZE(tbl_common)); | ||
231 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, s002); | ||
232 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, s003); | ||
233 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 16, s004); | ||
234 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, s005); | ||
235 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 44, s006); | ||
236 | keep_on_fetching_validx(gspca_dev, tbl_common, | ||
237 | ARRAY_SIZE(tbl_common), n); | ||
238 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 52, s007); | ||
239 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, s008); | ||
240 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 48, s009); | ||
241 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 56, s010); | ||
242 | keep_on_fetching_validx(gspca_dev, tbl_common, | ||
243 | ARRAY_SIZE(tbl_common), n); | ||
244 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, s011); | ||
245 | keep_on_fetching_validx(gspca_dev, tbl_common, | ||
246 | ARRAY_SIZE(tbl_common), n); | ||
247 | } | ||
248 | |||
249 | static int mi1320_init_at_startup(struct gspca_dev *gspca_dev) | ||
250 | { | ||
251 | fetch_validx(gspca_dev, tbl_init_at_startup, | ||
252 | ARRAY_SIZE(tbl_init_at_startup)); | ||
253 | |||
254 | common(gspca_dev); | ||
255 | |||
256 | /* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */ | ||
257 | |||
258 | return 0; | ||
259 | } | ||
260 | |||
261 | static int mi1320_init_pre_alt(struct gspca_dev *gspca_dev) | ||
262 | { | ||
263 | struct sd *sd = (struct sd *) gspca_dev; | ||
264 | |||
265 | sd->mirrorMask = 0; | ||
266 | |||
267 | sd->vold.backlight = -1; | ||
268 | sd->vold.brightness = -1; | ||
269 | sd->vold.sharpness = -1; | ||
270 | sd->vold.contrast = -1; | ||
271 | sd->vold.saturation = -1; | ||
272 | sd->vold.gamma = -1; | ||
273 | sd->vold.hue = -1; | ||
274 | sd->vold.whitebal = -1; | ||
275 | sd->vold.mirror = -1; | ||
276 | sd->vold.flip = -1; | ||
277 | sd->vold.AC50Hz = -1; | ||
278 | |||
279 | common(gspca_dev); | ||
280 | |||
281 | mi1320_sensor_settings(gspca_dev); | ||
282 | |||
283 | mi1320_init_post_alt(gspca_dev); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static int mi1320_init_post_alt(struct gspca_dev *gspca_dev) | ||
289 | { | ||
290 | mi1320_camera_settings(gspca_dev); | ||
291 | |||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | static int mi1320_sensor_settings(struct gspca_dev *gspca_dev) | ||
296 | { | ||
297 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
298 | |||
299 | ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); | ||
300 | |||
301 | fetch_validx(gspca_dev, tbl_sensor_settings_common, | ||
302 | ARRAY_SIZE(tbl_sensor_settings_common)); | ||
303 | |||
304 | switch (reso) { | ||
305 | case IMAGE_1280: | ||
306 | fetch_validx(gspca_dev, tbl_sensor_settings_1280, | ||
307 | ARRAY_SIZE(tbl_sensor_settings_1280)); | ||
308 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 64, tbl_1280[0]); | ||
309 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_1280[1]); | ||
310 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_1280[2]); | ||
311 | break; | ||
312 | |||
313 | case IMAGE_800: | ||
314 | fetch_validx(gspca_dev, tbl_sensor_settings_800, | ||
315 | ARRAY_SIZE(tbl_sensor_settings_800)); | ||
316 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 64, tbl_800[0]); | ||
317 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_800[1]); | ||
318 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_800[2]); | ||
319 | break; | ||
320 | |||
321 | default: | ||
322 | fetch_validx(gspca_dev, tbl_sensor_settings_640, | ||
323 | ARRAY_SIZE(tbl_sensor_settings_640)); | ||
324 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 60, tbl_640[0]); | ||
325 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 40, tbl_640[1]); | ||
326 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, tbl_640[2]); | ||
327 | break; | ||
328 | } | ||
329 | return 0; | ||
330 | } | ||
331 | |||
332 | static int mi1320_configure_alt(struct gspca_dev *gspca_dev) | ||
333 | { | ||
334 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
335 | |||
336 | switch (reso) { | ||
337 | case IMAGE_640: | ||
338 | gspca_dev->alt = 3 + 1; | ||
339 | break; | ||
340 | |||
341 | case IMAGE_800: | ||
342 | case IMAGE_1280: | ||
343 | gspca_dev->alt = 1 + 1; | ||
344 | break; | ||
345 | } | ||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | int mi1320_camera_settings(struct gspca_dev *gspca_dev) | ||
350 | { | ||
351 | struct sd *sd = (struct sd *) gspca_dev; | ||
352 | |||
353 | s32 backlight = sd->vcur.backlight; | ||
354 | s32 bright = sd->vcur.brightness; | ||
355 | s32 sharp = sd->vcur.sharpness; | ||
356 | s32 cntr = sd->vcur.contrast; | ||
357 | s32 gam = sd->vcur.gamma; | ||
358 | s32 hue = sd->vcur.hue; | ||
359 | s32 sat = sd->vcur.saturation; | ||
360 | s32 wbal = sd->vcur.whitebal; | ||
361 | s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); | ||
362 | s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); | ||
363 | s32 freq = (sd->vcur.AC50Hz > 0); | ||
364 | s32 i; | ||
365 | |||
366 | if (freq != sd->vold.AC50Hz) { | ||
367 | sd->vold.AC50Hz = freq; | ||
368 | |||
369 | freq = 2 * (freq == 0); | ||
370 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
371 | ctrl_out(gspca_dev, 0x40, 1, 0xba02, 0x00f1, 0, NULL); | ||
372 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x005b, 0, NULL); | ||
373 | ctrl_out(gspca_dev, 0x40, 1, 0xba01 + freq, 0x00f1, 0, NULL); | ||
374 | } | ||
375 | |||
376 | if (wbal != sd->vold.whitebal) { | ||
377 | sd->vold.whitebal = wbal; | ||
378 | if (wbal < 0 || wbal > sd->vmax.whitebal) | ||
379 | wbal = 0; | ||
380 | |||
381 | for (i = 0; i < 2; i++) { | ||
382 | if (wbal == 0) { /* Normal light */ | ||
383 | ctrl_out(gspca_dev, 0x40, 1, | ||
384 | 0x0010, 0x0010, 0, NULL); | ||
385 | ctrl_out(gspca_dev, 0x40, 1, | ||
386 | 0x0003, 0x00c1, 0, NULL); | ||
387 | ctrl_out(gspca_dev, 0x40, 1, | ||
388 | 0x0042, 0x00c2, 0, NULL); | ||
389 | ctrl_out(gspca_dev, 0x40, 3, | ||
390 | 0xba00, 0x0200, 48, dat_wbalNL); | ||
391 | } | ||
392 | |||
393 | if (wbal == 1) { /* Low light */ | ||
394 | ctrl_out(gspca_dev, 0x40, 1, | ||
395 | 0x0010, 0x0010, 0, NULL); | ||
396 | ctrl_out(gspca_dev, 0x40, 1, | ||
397 | 0x0004, 0x00c1, 0, NULL); | ||
398 | ctrl_out(gspca_dev, 0x40, 1, | ||
399 | 0x0043, 0x00c2, 0, NULL); | ||
400 | ctrl_out(gspca_dev, 0x40, 3, | ||
401 | 0xba00, 0x0200, 48, dat_wbalLL); | ||
402 | } | ||
403 | |||
404 | if (wbal == 2) { /* Back light */ | ||
405 | ctrl_out(gspca_dev, 0x40, 1, | ||
406 | 0x0010, 0x0010, 0, NULL); | ||
407 | ctrl_out(gspca_dev, 0x40, 1, | ||
408 | 0x0003, 0x00c1, 0, NULL); | ||
409 | ctrl_out(gspca_dev, 0x40, 1, | ||
410 | 0x0042, 0x00c2, 0, NULL); | ||
411 | ctrl_out(gspca_dev, 0x40, 3, | ||
412 | 0xba00, 0x0200, 44, dat_wbalBL); | ||
413 | } | ||
414 | } | ||
415 | } | ||
416 | |||
417 | if (bright != sd->vold.brightness) { | ||
418 | sd->vold.brightness = bright; | ||
419 | if (bright < 0 || bright > sd->vmax.brightness) | ||
420 | bright = 0; | ||
421 | |||
422 | bright = tbl_bright[bright]; | ||
423 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
424 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
425 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + bright, 0x0034, 0, NULL); | ||
426 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + bright, 0x00f1, 0, NULL); | ||
427 | } | ||
428 | |||
429 | if (sat != sd->vold.saturation) { | ||
430 | sd->vold.saturation = sat; | ||
431 | if (sat < 0 || sat > sd->vmax.saturation) | ||
432 | sat = 0; | ||
433 | |||
434 | sat = tbl_sat[sat]; | ||
435 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
436 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
437 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x0025, 0, NULL); | ||
438 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + sat, 0x00f1, 0, NULL); | ||
439 | } | ||
440 | |||
441 | if (sharp != sd->vold.sharpness) { | ||
442 | sd->vold.sharpness = sharp; | ||
443 | if (sharp < 0 || sharp > sd->vmax.sharpness) | ||
444 | sharp = 0; | ||
445 | |||
446 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
447 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
448 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 , 0x0005, 0, NULL); | ||
449 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + sharp, 0x00f1, 0, NULL); | ||
450 | } | ||
451 | |||
452 | if (hue != sd->vold.hue) { | ||
453 | /* 0=normal 1=NB 2="sepia" 3=negative 4=other 5=other2 */ | ||
454 | if (hue < 0 || hue > sd->vmax.hue) | ||
455 | hue = 0; | ||
456 | if (hue == sd->vmax.hue) | ||
457 | sd->swapRB = 1; | ||
458 | else | ||
459 | sd->swapRB = 0; | ||
460 | |||
461 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
462 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
463 | ctrl_out(gspca_dev, 0x40, 1, 0xba70, 0x00e2, 0, NULL); | ||
464 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + hue * (hue < 6), 0x00f1, | ||
465 | 0, NULL); | ||
466 | } | ||
467 | |||
468 | if (backlight != sd->vold.backlight) { | ||
469 | sd->vold.backlight = backlight; | ||
470 | if (backlight < 0 || backlight > sd->vmax.backlight) | ||
471 | backlight = 0; | ||
472 | |||
473 | backlight = tbl_backlight[backlight]; | ||
474 | for (i = 0; i < 2; i++) { | ||
475 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
476 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
477 | ctrl_out(gspca_dev, 0x40, 1, 0xba74, 0x0006, 0, NULL); | ||
478 | ctrl_out(gspca_dev, 0x40, 1, 0xba80 + backlight, 0x00f1, | ||
479 | 0, NULL); | ||
480 | } | ||
481 | } | ||
482 | |||
483 | if (hue != sd->vold.hue) { | ||
484 | sd->vold.hue = hue; | ||
485 | |||
486 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
487 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
488 | ctrl_out(gspca_dev, 0x40, 1, 0xba70, 0x00e2, 0, NULL); | ||
489 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + hue * (hue < 6), 0x00f1, | ||
490 | 0, NULL); | ||
491 | } | ||
492 | |||
493 | if (mirror != sd->vold.mirror || flip != sd->vold.flip) { | ||
494 | u8 dat_hvflip2[4] = {0x20, 0x01, 0xf1, 0x00}; | ||
495 | sd->vold.mirror = mirror; | ||
496 | sd->vold.flip = flip; | ||
497 | |||
498 | dat_hvflip2[3] = flip + 2 * mirror; | ||
499 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 4, dat_hvflip1); | ||
500 | ctrl_out(gspca_dev, 0x40, 3, 0xba00, 0x0200, 4, dat_hvflip2); | ||
501 | } | ||
502 | |||
503 | if (gam != sd->vold.gamma) { | ||
504 | sd->vold.gamma = gam; | ||
505 | if (gam < 0 || gam > sd->vmax.gamma) | ||
506 | gam = 0; | ||
507 | |||
508 | gam = 2 * gam; | ||
509 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
510 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
511 | ctrl_out(gspca_dev, 0x40, 1, 0xba04 , 0x003b, 0, NULL); | ||
512 | ctrl_out(gspca_dev, 0x40, 1, 0xba02 + gam, 0x00f1, 0, NULL); | ||
513 | } | ||
514 | |||
515 | if (cntr != sd->vold.contrast) { | ||
516 | sd->vold.contrast = cntr; | ||
517 | if (cntr < 0 || cntr > sd->vmax.contrast) | ||
518 | cntr = 0; | ||
519 | |||
520 | ctrl_out(gspca_dev, 0x40, 1, 0xba00, 0x00f0, 0, NULL); | ||
521 | ctrl_out(gspca_dev, 0x40, 1, 0xba01, 0x00f1, 0, NULL); | ||
522 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + tbl_cntr1[cntr], 0x0035, | ||
523 | 0, NULL); | ||
524 | ctrl_out(gspca_dev, 0x40, 1, 0xba00 + tbl_cntr2[cntr], 0x00f1, | ||
525 | 0, NULL); | ||
526 | } | ||
527 | |||
528 | return 0; | ||
529 | } | ||
530 | |||
531 | static void mi1320_post_unset_alt(struct gspca_dev *gspca_dev) | ||
532 | { | ||
533 | ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); | ||
534 | |||
535 | fetch_validx(gspca_dev, tbl_post_unset_alt, | ||
536 | ARRAY_SIZE(tbl_post_unset_alt)); | ||
537 | } | ||
diff --git a/drivers/media/video/gspca/gl860/gl860-mi2020.c b/drivers/media/video/gspca/gl860/gl860-mi2020.c new file mode 100644 index 000000000000..ffb09fed3e8c --- /dev/null +++ b/drivers/media/video/gspca/gl860/gl860-mi2020.c | |||
@@ -0,0 +1,937 @@ | |||
1 | /* @file gl860-mi2020.c | ||
2 | * @author Olivier LORIN, from Ice/Soro2005's logs(A), Fret_saw/Hulkie's | ||
3 | * logs(B) and Tricid"s logs(C). With the help of Kytrix/BUGabundo/Blazercist. | ||
4 | * @date 2009-08-27 | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | /* Sensor : MI2020 */ | ||
21 | |||
22 | #include "gl860.h" | ||
23 | |||
24 | static u8 dat_bright1[] = {0x8c, 0xa2, 0x06}; | ||
25 | static u8 dat_bright3[] = {0x8c, 0xa1, 0x02}; | ||
26 | static u8 dat_bright4[] = {0x90, 0x00, 0x0f}; | ||
27 | static u8 dat_bright5[] = {0x8c, 0xa1, 0x03}; | ||
28 | static u8 dat_bright6[] = {0x90, 0x00, 0x05}; | ||
29 | |||
30 | static u8 dat_dummy1[] = {0x90, 0x00, 0x06}; | ||
31 | /*static u8 dummy2[] = {0x8c, 0xa1, 0x02};*/ | ||
32 | /*static u8 dummy3[] = {0x90, 0x00, 0x1f};*/ | ||
33 | |||
34 | static u8 dat_hvflip1[] = {0x8c, 0x27, 0x19}; | ||
35 | static u8 dat_hvflip3[] = {0x8c, 0x27, 0x3b}; | ||
36 | static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03}; | ||
37 | static u8 dat_hvflip6[] = {0x90, 0x00, 0x06}; | ||
38 | |||
39 | static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 }; | ||
40 | |||
41 | static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 }; | ||
42 | static u8 dat_multi6[] = { 0x90, 0x00, 0x05 }; | ||
43 | |||
44 | static struct validx tbl_common_a[] = { | ||
45 | {0x0000, 0x0000}, | ||
46 | {1, 0xffff}, /* msleep(35); */ | ||
47 | {0x006a, 0x0007}, {0x0063, 0x0006}, {0x006a, 0x000d}, {0x0000, 0x00c0}, | ||
48 | {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, {0x0004, 0x00d8}, | ||
49 | {0x0000, 0x0058}, {0x0002, 0x0004}, {0x0041, 0x0000}, | ||
50 | }; | ||
51 | |||
52 | static struct validx tbl_common_b[] = { | ||
53 | {0x006a, 0x0007}, | ||
54 | {35, 0xffff}, | ||
55 | {0x00ef, 0x0006}, | ||
56 | {35, 0xffff}, | ||
57 | {0x006a, 0x000d}, | ||
58 | {35, 0xffff}, | ||
59 | {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, | ||
60 | {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000}, | ||
61 | }; | ||
62 | |||
63 | static struct idxdata tbl_common_c[] = { | ||
64 | {0x32, "\x02\x00\x08"}, {0x33, "\xf4\x03\x1d"}, | ||
65 | {6, "\xff\xff\xff"}, /* 12 */ | ||
66 | {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, | ||
67 | {2, "\xff\xff\xff"}, /* - */ | ||
68 | {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\x22\x23"}, | ||
69 | {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0f"}, {0x33, "\x90\x00\x0d"}, | ||
70 | {0x33, "\x8c\xa2\x10"}, {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x11"}, | ||
71 | {0x33, "\x90\x00\x07"}, {0x33, "\xf4\x03\x1d"}, {0x35, "\xa2\x00\xe2"}, | ||
72 | {0x33, "\x8c\xab\x05"}, {0x33, "\x90\x00\x01"}, {0x32, "\x6e\x00\x86"}, | ||
73 | {0x32, "\x70\x0f\xaa"}, {0x32, "\x72\x0f\xe4"}, {0x33, "\x8c\xa3\x4a"}, | ||
74 | {0x33, "\x90\x00\x5a"}, {0x33, "\x8c\xa3\x4b"}, {0x33, "\x90\x00\xa6"}, | ||
75 | {0x33, "\x8c\xa3\x61"}, {0x33, "\x90\x00\xc8"}, {0x33, "\x8c\xa3\x62"}, | ||
76 | {0x33, "\x90\x00\xe1"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"}, | ||
77 | {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"}, | ||
78 | {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"}, | ||
79 | {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"}, | ||
80 | {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"}, | ||
81 | {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"}, | ||
82 | {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"}, | ||
83 | {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"}, | ||
84 | {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"}, | ||
85 | {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"}, | ||
86 | {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"}, | ||
87 | {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"}, | ||
88 | {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"}, | ||
89 | {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"}, | ||
90 | {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"}, | ||
91 | {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"}, | ||
92 | {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"}, | ||
93 | {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"}, | ||
94 | {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"}, | ||
95 | {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"}, | ||
96 | {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"}, | ||
97 | {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"}, | ||
98 | {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"}, | ||
99 | {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"}, | ||
100 | {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"}, | ||
101 | {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"}, | ||
102 | {1, "\xff\xff\xff"}, | ||
103 | {0x33, "\x78\x00\x00"}, | ||
104 | {1, "\xff\xff\xff"}, | ||
105 | {0x35, "\xb8\x1f\x20"}, {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x10"}, | ||
106 | {0x33, "\x8c\xa2\x07"}, {0x33, "\x90\x00\x08"}, {0x33, "\x8c\xa2\x42"}, | ||
107 | {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x4a"}, {0x33, "\x90\x00\x8c"}, | ||
108 | {0x35, "\xba\xfa\x08"}, {0x33, "\x8c\xa2\x02"}, {0x33, "\x90\x00\x22"}, | ||
109 | {0x33, "\x8c\xa2\x03"}, {0x33, "\x90\x00\xbb"}, | ||
110 | }; | ||
111 | |||
112 | static struct idxdata tbl_common_d[] = { | ||
113 | {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa0"}, {0x33, "\x8c\xa4\x08"}, | ||
114 | {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x21"}, | ||
115 | {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\xa4\x0b"}, | ||
116 | {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\xa0"}, | ||
117 | {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc0"}, {0x33, "\x8c\x24\x15"}, | ||
118 | {0x33, "\x90\x00\xa0"}, {0x33, "\x8c\x24\x17"}, {0x33, "\x90\x00\xc0"}, | ||
119 | }; | ||
120 | |||
121 | static struct idxdata tbl_common_e[] = { | ||
122 | {0x33, "\x8c\xa4\x04"}, {0x33, "\x90\x00\x80"}, {0x33, "\x8c\xa7\x9d"}, | ||
123 | {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa7\x9e"}, {0x33, "\x90\x00\x00"}, | ||
124 | {0x33, "\x8c\xa2\x0c"}, {0x33, "\x90\x00\x17"}, {0x33, "\x8c\xa2\x15"}, | ||
125 | {0x33, "\x90\x00\x04"}, {0x33, "\x8c\xa2\x14"}, {0x33, "\x90\x00\x20"}, | ||
126 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, | ||
127 | /* msleep(53); */ | ||
128 | {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, | ||
129 | {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x39"}, | ||
130 | {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, | ||
131 | {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x03"}, | ||
132 | {0x33, "\x90\x02\x84"}, {0x33, "\x8c\x27\x05"}, {0x33, "\x90\x01\xe2"}, | ||
133 | {0x33, "\x8c\x27\x07"}, {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x09"}, | ||
134 | {0x33, "\x90\x04\xb0"}, {0x33, "\x8c\x27\x0d"}, {0x33, "\x90\x00\x00"}, | ||
135 | {0x33, "\x8c\x27\x0f"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x11"}, | ||
136 | {0x33, "\x90\x04\xbd"}, {0x33, "\x8c\x27\x13"}, {0x33, "\x90\x06\x4d"}, | ||
137 | {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, | ||
138 | {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"}, | ||
139 | {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x1d"}, | ||
140 | {0x33, "\x90\x01\x02"}, {0x33, "\x8c\x27\x1f"}, {0x33, "\x90\x02\x79"}, | ||
141 | {0x33, "\x8c\x27\x21"}, {0x33, "\x90\x01\x55"}, {0x33, "\x8c\x27\x23"}, | ||
142 | {0x33, "\x90\x02\x85"}, {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, | ||
143 | {0x33, "\x8c\x27\x27"}, {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x29"}, | ||
144 | {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x2b"}, {0x33, "\x90\x10\x20"}, | ||
145 | {0x33, "\x8c\x27\x2d"}, {0x33, "\x90\x20\x07"}, {0x33, "\x8c\x27\x2f"}, | ||
146 | {0x33, "\x90\x00\x04"}, {0x33, "\x8c\x27\x31"}, {0x33, "\x90\x00\x04"}, | ||
147 | {0x33, "\x8c\x27\x33"}, {0x33, "\x90\x04\xbb"}, {0x33, "\x8c\x27\x35"}, | ||
148 | {0x33, "\x90\x06\x4b"}, {0x33, "\x8c\x27\x37"}, {0x33, "\x90\x00\x00"}, | ||
149 | {0x33, "\x8c\x27\x39"}, {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3b"}, | ||
150 | {0x33, "\x90\x00\x24"}, {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, | ||
151 | {0x33, "\x8c\x27\x41"}, {0x33, "\x90\x01\x69"}, {0x33, "\x8c\x27\x45"}, | ||
152 | {0x33, "\x90\x04\xed"}, {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, | ||
153 | {0x33, "\x8c\x27\x51"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x53"}, | ||
154 | {0x33, "\x90\x03\x20"}, {0x33, "\x8c\x27\x55"}, {0x33, "\x90\x00\x00"}, | ||
155 | {0x33, "\x8c\x27\x57"}, {0x33, "\x90\x02\x58"}, {0x33, "\x8c\x27\x5f"}, | ||
156 | {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x61"}, {0x33, "\x90\x06\x40"}, | ||
157 | {0x33, "\x8c\x27\x63"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x65"}, | ||
158 | {0x33, "\x90\x04\xb0"}, {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa1"}, | ||
159 | {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, | ||
160 | {0x33, "\x90\x00\x21"}, {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, | ||
161 | {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, | ||
162 | {0x33, "\x90\x00\xa1"}, {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc1"}, | ||
163 | {0x33, "\x8c\x24\x15"}, | ||
164 | }; | ||
165 | |||
166 | static struct validx tbl_init_at_startup[] = { | ||
167 | {0x0000, 0x0000}, | ||
168 | {53, 0xffff}, | ||
169 | {0x0010, 0x0010}, | ||
170 | {53, 0xffff}, | ||
171 | {0x0008, 0x00c0}, | ||
172 | {53, 0xffff}, | ||
173 | {0x0001, 0x00c1}, | ||
174 | {53, 0xffff}, | ||
175 | {0x0001, 0x00c2}, | ||
176 | {53, 0xffff}, | ||
177 | {0x0020, 0x0006}, | ||
178 | {53, 0xffff}, | ||
179 | {0x006a, 0x000d}, | ||
180 | {53, 0xffff}, | ||
181 | }; | ||
182 | |||
183 | static struct idxdata tbl_init_post_alt_low_a[] = { | ||
184 | {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\x22\x2e"}, | ||
185 | {0x33, "\x90\x00\x81"}, {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x17"}, | ||
186 | {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x1a"}, {0x33, "\x8c\xa4\x0a"}, | ||
187 | {0x33, "\x90\x00\x1d"}, {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x20"}, | ||
188 | {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\x81"}, {0x33, "\x8c\x24\x13"}, | ||
189 | {0x33, "\x90\x00\x9b"}, | ||
190 | }; | ||
191 | |||
192 | static struct idxdata tbl_init_post_alt_low_b[] = { | ||
193 | {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x03\x24"}, {0x33, "\x8c\x27\x05"}, | ||
194 | {0x33, "\x90\x02\x58"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, | ||
195 | {2, "\xff\xff\xff"}, | ||
196 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, | ||
197 | {2, "\xff\xff\xff"}, | ||
198 | }; | ||
199 | |||
200 | static struct idxdata tbl_init_post_alt_low_c[] = { | ||
201 | {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, | ||
202 | {2, "\xff\xff\xff"}, | ||
203 | {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x20"}, | ||
204 | {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"}, | ||
205 | {0x33, "\x2e\x01\x00"}, {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, | ||
206 | {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x95"}, {0x33, "\x90\x01\x00"}, | ||
207 | {2, "\xff\xff\xff"}, | ||
208 | {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"}, | ||
209 | {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, | ||
210 | {2, "\xff\xff\xff"}, | ||
211 | {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, | ||
212 | {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"}, | ||
213 | {2, "\xff\xff\xff"}, /* - * */ | ||
214 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, | ||
215 | {2, "\xff\xff\xff"}, | ||
216 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, | ||
217 | {2, "\xff\xff\xff"}, | ||
218 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, | ||
219 | {2, "\xff\xff\xff"}, | ||
220 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, | ||
221 | {1, "\xff\xff\xff"}, | ||
222 | }; | ||
223 | |||
224 | static struct idxdata tbl_init_post_alt_low_d[] = { | ||
225 | {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"}, | ||
226 | {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"}, | ||
227 | {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"}, | ||
228 | {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"}, | ||
229 | {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"}, | ||
230 | {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"}, | ||
231 | {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"}, | ||
232 | {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"}, | ||
233 | {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"}, | ||
234 | {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"}, | ||
235 | {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"}, | ||
236 | {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"}, | ||
237 | {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"}, | ||
238 | {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"}, | ||
239 | {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"}, | ||
240 | {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"}, | ||
241 | {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"}, | ||
242 | {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"}, | ||
243 | {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"}, | ||
244 | {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"}, | ||
245 | {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"}, | ||
246 | {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"}, | ||
247 | {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"}, | ||
248 | {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"}, | ||
249 | {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"}, | ||
250 | {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, | ||
251 | /* Flip/Mirror h/v=1 */ | ||
252 | {0x33, "\x90\x00\x3c"}, {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"}, | ||
253 | {0x33, "\x8c\x27\x3b"}, {0x33, "\x90\x00\x24"}, {0x33, "\x8c\xa1\x03"}, | ||
254 | {0x33, "\x90\x00\x06"}, | ||
255 | {130, "\xff\xff\xff"}, | ||
256 | {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, | ||
257 | {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, | ||
258 | {100, "\xff\xff\xff"}, | ||
259 | /* ?? */ | ||
260 | {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa1\x02"}, | ||
261 | {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, | ||
262 | {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, | ||
263 | /* Brigthness=70 */ | ||
264 | {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x46"}, {0x33, "\x8c\xa1\x02"}, | ||
265 | {0x33, "\x90\x00\x0f"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, | ||
266 | /* Sharpness=20 */ | ||
267 | {0x32, "\x6c\x14\x08"}, | ||
268 | }; | ||
269 | |||
270 | static struct idxdata tbl_init_post_alt_big_a[] = { | ||
271 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, | ||
272 | {2, "\xff\xff\xff"}, | ||
273 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, | ||
274 | {2, "\xff\xff\xff"}, | ||
275 | {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, | ||
276 | {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x03"}, | ||
277 | {0x33, "\x90\x00\x05"}, | ||
278 | {2, "\xff\xff\xff"}, | ||
279 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, | ||
280 | {2, "\xff\xff\xff"}, | ||
281 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, | ||
282 | {2, "\xff\xff\xff"}, | ||
283 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, {0x33, "\x8c\xa1\x20"}, | ||
284 | {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x30"}, {0x33, "\x90\x00\x03"}, | ||
285 | {0x33, "\x8c\xa1\x31"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x32"}, | ||
286 | {0x33, "\x90\x00\x03"}, {0x33, "\x8c\xa1\x34"}, {0x33, "\x90\x00\x03"}, | ||
287 | {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x2e\x01\x00"}, | ||
288 | {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, | ||
289 | }; | ||
290 | |||
291 | static struct idxdata tbl_init_post_alt_big_b[] = { | ||
292 | {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"}, | ||
293 | {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"}, | ||
294 | {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"}, | ||
295 | {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"}, | ||
296 | {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"}, | ||
297 | {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"}, | ||
298 | {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"}, | ||
299 | {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"}, | ||
300 | {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"}, | ||
301 | {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"}, | ||
302 | {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"}, | ||
303 | {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"}, | ||
304 | {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"}, | ||
305 | {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"}, | ||
306 | {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"}, | ||
307 | {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"}, | ||
308 | {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"}, | ||
309 | {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"}, | ||
310 | {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"}, | ||
311 | {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"}, | ||
312 | {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"}, | ||
313 | {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"}, | ||
314 | {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"}, | ||
315 | {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"}, | ||
316 | {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"}, | ||
317 | {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"}, | ||
318 | }; | ||
319 | |||
320 | static struct idxdata tbl_init_post_alt_big_c[] = { | ||
321 | {0x33, "\x8c\xa1\x02"}, | ||
322 | {0x33, "\x90\x00\x1f"}, | ||
323 | {0x33, "\x8c\xa1\x02"}, | ||
324 | {0x33, "\x90\x00\x1f"}, | ||
325 | {0x33, "\x8c\xa1\x02"}, | ||
326 | {0x33, "\x90\x00\x1f"}, | ||
327 | {0x33, "\x8c\xa1\x02"}, | ||
328 | {0x33, "\x90\x00\x1f"}, | ||
329 | }; | ||
330 | |||
331 | static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81"; | ||
332 | static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21"; | ||
333 | static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01"; | ||
334 | static u8 *dat_1600 = "\xd0\x02\xd1\x20\xd2\xaf\xd3\x02\xd4\x30\xd5\x41"; | ||
335 | |||
336 | static int mi2020_init_at_startup(struct gspca_dev *gspca_dev); | ||
337 | static int mi2020_configure_alt(struct gspca_dev *gspca_dev); | ||
338 | static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev); | ||
339 | static int mi2020_init_post_alt(struct gspca_dev *gspca_dev); | ||
340 | static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev); | ||
341 | static int mi2020_camera_settings(struct gspca_dev *gspca_dev); | ||
342 | /*==========================================================================*/ | ||
343 | |||
344 | void mi2020_init_settings(struct gspca_dev *gspca_dev) | ||
345 | { | ||
346 | struct sd *sd = (struct sd *) gspca_dev; | ||
347 | |||
348 | sd->vcur.backlight = 0; | ||
349 | sd->vcur.brightness = 70; | ||
350 | sd->vcur.sharpness = 20; | ||
351 | sd->vcur.contrast = 0; | ||
352 | sd->vcur.gamma = 0; | ||
353 | sd->vcur.hue = 0; | ||
354 | sd->vcur.saturation = 60; | ||
355 | sd->vcur.whitebal = 50; | ||
356 | sd->vcur.mirror = 0; | ||
357 | sd->vcur.flip = 0; | ||
358 | sd->vcur.AC50Hz = 1; | ||
359 | |||
360 | sd->vmax.backlight = 64; | ||
361 | sd->vmax.brightness = 128; | ||
362 | sd->vmax.sharpness = 40; | ||
363 | sd->vmax.contrast = 3; | ||
364 | sd->vmax.gamma = 2; | ||
365 | sd->vmax.hue = 0 + 1; /* 200 */ | ||
366 | sd->vmax.saturation = 0; /* 100 */ | ||
367 | sd->vmax.whitebal = 0; /* 100 */ | ||
368 | sd->vmax.mirror = 1; | ||
369 | sd->vmax.flip = 1; | ||
370 | sd->vmax.AC50Hz = 1; | ||
371 | if (_MI2020b_) { | ||
372 | sd->vmax.contrast = 0; | ||
373 | sd->vmax.gamma = 0; | ||
374 | sd->vmax.backlight = 0; | ||
375 | } | ||
376 | |||
377 | sd->dev_camera_settings = mi2020_camera_settings; | ||
378 | sd->dev_init_at_startup = mi2020_init_at_startup; | ||
379 | sd->dev_configure_alt = mi2020_configure_alt; | ||
380 | sd->dev_init_pre_alt = mi2020_init_pre_alt; | ||
381 | sd->dev_post_unset_alt = mi2020_post_unset_alt; | ||
382 | } | ||
383 | |||
384 | /*==========================================================================*/ | ||
385 | |||
386 | static void common(struct gspca_dev *gspca_dev) | ||
387 | { | ||
388 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
389 | |||
390 | if (_MI2020b_) { | ||
391 | fetch_validx(gspca_dev, tbl_common_a, ARRAY_SIZE(tbl_common_a)); | ||
392 | } else { | ||
393 | if (_MI2020_) | ||
394 | ctrl_out(gspca_dev, 0x40, 1, 0x0008, 0x0004, 0, NULL); | ||
395 | else | ||
396 | ctrl_out(gspca_dev, 0x40, 1, 0x0002, 0x0004, 0, NULL); | ||
397 | msleep(35); | ||
398 | fetch_validx(gspca_dev, tbl_common_b, ARRAY_SIZE(tbl_common_b)); | ||
399 | } | ||
400 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x86\x25\x01"); | ||
401 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x86\x25\x00"); | ||
402 | msleep(2); /* - * */ | ||
403 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0030, 3, "\x1a\x0a\xcc"); | ||
404 | if (reso == IMAGE_1600) | ||
405 | msleep(2); /* 1600 */ | ||
406 | fetch_idxdata(gspca_dev, tbl_common_c, ARRAY_SIZE(tbl_common_c)); | ||
407 | |||
408 | if (_MI2020b_ || _MI2020_) | ||
409 | fetch_idxdata(gspca_dev, tbl_common_d, | ||
410 | ARRAY_SIZE(tbl_common_d)); | ||
411 | |||
412 | fetch_idxdata(gspca_dev, tbl_common_e, ARRAY_SIZE(tbl_common_e)); | ||
413 | if (_MI2020b_ || _MI2020_) { | ||
414 | /* Different from fret */ | ||
415 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x78"); | ||
416 | /* Same as fret */ | ||
417 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x24\x17"); | ||
418 | /* Different from fret */ | ||
419 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x90"); | ||
420 | } else { | ||
421 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x6a"); | ||
422 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x24\x17"); | ||
423 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x80"); | ||
424 | } | ||
425 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03"); | ||
426 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x05"); | ||
427 | msleep(2); | ||
428 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03"); | ||
429 | if (reso == IMAGE_1600) | ||
430 | msleep(14); /* 1600 */ | ||
431 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x06"); | ||
432 | msleep(2); | ||
433 | } | ||
434 | |||
435 | static int mi2020_init_at_startup(struct gspca_dev *gspca_dev) | ||
436 | { | ||
437 | u8 c; | ||
438 | |||
439 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c); | ||
440 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c); | ||
441 | |||
442 | fetch_validx(gspca_dev, tbl_init_at_startup, | ||
443 | ARRAY_SIZE(tbl_init_at_startup)); | ||
444 | |||
445 | common(gspca_dev); | ||
446 | |||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev) | ||
451 | { | ||
452 | struct sd *sd = (struct sd *) gspca_dev; | ||
453 | |||
454 | sd->mirrorMask = 0; | ||
455 | |||
456 | sd->vold.backlight = -1; | ||
457 | sd->vold.brightness = -1; | ||
458 | sd->vold.sharpness = -1; | ||
459 | sd->vold.contrast = -1; | ||
460 | sd->vold.gamma = -1; | ||
461 | sd->vold.hue = -1; | ||
462 | sd->vold.mirror = -1; | ||
463 | sd->vold.flip = -1; | ||
464 | sd->vold.AC50Hz = -1; | ||
465 | |||
466 | mi2020_init_post_alt(gspca_dev); | ||
467 | |||
468 | return 0; | ||
469 | } | ||
470 | |||
471 | static int mi2020_init_post_alt(struct gspca_dev *gspca_dev) | ||
472 | { | ||
473 | struct sd *sd = (struct sd *) gspca_dev; | ||
474 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
475 | |||
476 | s32 backlight = sd->vcur.backlight; | ||
477 | s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); | ||
478 | s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); | ||
479 | s32 freq = (sd->vcur.AC50Hz > 0); | ||
480 | |||
481 | u8 dat_freq2[] = {0x90, 0x00, 0x80}; | ||
482 | u8 dat_multi1[] = {0x8c, 0xa7, 0x00}; | ||
483 | u8 dat_multi2[] = {0x90, 0x00, 0x00}; | ||
484 | u8 dat_multi3[] = {0x8c, 0xa7, 0x00}; | ||
485 | u8 dat_multi4[] = {0x90, 0x00, 0x00}; | ||
486 | u8 dat_hvflip2[] = {0x90, 0x04, 0x6c}; | ||
487 | u8 dat_hvflip4[] = {0x90, 0x00, 0x24}; | ||
488 | u8 c; | ||
489 | |||
490 | sd->nbIm = -1; | ||
491 | |||
492 | dat_freq2[2] = freq ? 0xc0 : 0x80; | ||
493 | dat_multi1[2] = 0x9d; | ||
494 | dat_multi3[2] = dat_multi1[2] + 1; | ||
495 | dat_multi4[2] = dat_multi2[2] = backlight; | ||
496 | dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror); | ||
497 | dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror); | ||
498 | |||
499 | msleep(200); | ||
500 | |||
501 | ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); | ||
502 | msleep(3); /* 35 * */ | ||
503 | |||
504 | common(gspca_dev); | ||
505 | |||
506 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL); | ||
507 | msleep(70); | ||
508 | |||
509 | if (_MI2020b_) | ||
510 | ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); | ||
511 | |||
512 | ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL); | ||
513 | ctrl_out(gspca_dev, 0x40, 1, 0x0003, 0x00c1, 0, NULL); | ||
514 | ctrl_out(gspca_dev, 0x40, 1, 0x0042, 0x00c2, 0, NULL); | ||
515 | ctrl_out(gspca_dev, 0x40, 1, 0x006a, 0x000d, 0, NULL); | ||
516 | |||
517 | switch (reso) { | ||
518 | case IMAGE_640: | ||
519 | case IMAGE_800: | ||
520 | if (reso != IMAGE_800) | ||
521 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
522 | 12, dat_640); | ||
523 | else | ||
524 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
525 | 12, dat_800); | ||
526 | |||
527 | if (_MI2020c_) | ||
528 | fetch_idxdata(gspca_dev, tbl_init_post_alt_low_a, | ||
529 | ARRAY_SIZE(tbl_init_post_alt_low_a)); | ||
530 | |||
531 | if (reso == IMAGE_800) | ||
532 | fetch_idxdata(gspca_dev, tbl_init_post_alt_low_b, | ||
533 | ARRAY_SIZE(tbl_init_post_alt_low_b)); | ||
534 | |||
535 | fetch_idxdata(gspca_dev, tbl_init_post_alt_low_c, | ||
536 | ARRAY_SIZE(tbl_init_post_alt_low_c)); | ||
537 | |||
538 | if (_MI2020b_) { | ||
539 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL); | ||
540 | ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); | ||
541 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); | ||
542 | msleep(150); | ||
543 | } else if (_MI2020c_) { | ||
544 | ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL); | ||
545 | ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); | ||
546 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); | ||
547 | msleep(120); | ||
548 | ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); | ||
549 | msleep(30); | ||
550 | } else if (_MI2020_) { | ||
551 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL); | ||
552 | ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); | ||
553 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); | ||
554 | msleep(120); | ||
555 | ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); | ||
556 | msleep(30); | ||
557 | } | ||
558 | |||
559 | /* AC power frequency */ | ||
560 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1); | ||
561 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2); | ||
562 | msleep(20); | ||
563 | /* backlight */ | ||
564 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); | ||
565 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); | ||
566 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); | ||
567 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); | ||
568 | /* at init time but not after */ | ||
569 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa2\x0c"); | ||
570 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x17"); | ||
571 | /* finish the backlight */ | ||
572 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); | ||
573 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); | ||
574 | msleep(5);/* " */ | ||
575 | |||
576 | if (_MI2020c_) { | ||
577 | fetch_idxdata(gspca_dev, tbl_init_post_alt_low_d, | ||
578 | ARRAY_SIZE(tbl_init_post_alt_low_d)); | ||
579 | } else { | ||
580 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c); | ||
581 | msleep(14); /* 0xd8 */ | ||
582 | |||
583 | /* flip/mirror */ | ||
584 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
585 | 3, dat_hvflip1); | ||
586 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
587 | 3, dat_hvflip2); | ||
588 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
589 | 3, dat_hvflip3); | ||
590 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
591 | 3, dat_hvflip4); | ||
592 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
593 | 3, dat_hvflip5); | ||
594 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
595 | 3, dat_hvflip6); | ||
596 | msleep(21); | ||
597 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
598 | 3, dat_dummy1); | ||
599 | msleep(5); | ||
600 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
601 | 3, dat_dummy1); | ||
602 | msleep(5); | ||
603 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
604 | 3, dat_dummy1); | ||
605 | msleep(5); | ||
606 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
607 | 3, dat_dummy1); | ||
608 | msleep(5); | ||
609 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
610 | 3, dat_dummy1); | ||
611 | msleep(5); | ||
612 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
613 | 3, dat_dummy1); | ||
614 | /* end of flip/mirror main part */ | ||
615 | msleep(246); /* 146 */ | ||
616 | |||
617 | sd->nbIm = 0; | ||
618 | } | ||
619 | break; | ||
620 | |||
621 | case IMAGE_1280: | ||
622 | case IMAGE_1600: | ||
623 | if (reso == IMAGE_1280) { | ||
624 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
625 | 12, dat_1280); | ||
626 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
627 | 3, "\x8c\x27\x07"); | ||
628 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
629 | 3, "\x90\x05\x04"); | ||
630 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
631 | 3, "\x8c\x27\x09"); | ||
632 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
633 | 3, "\x90\x04\x02"); | ||
634 | } else { | ||
635 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
636 | 12, dat_1600); | ||
637 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
638 | 3, "\x8c\x27\x07"); | ||
639 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
640 | 3, "\x90\x06\x40"); | ||
641 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
642 | 3, "\x8c\x27\x09"); | ||
643 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, | ||
644 | 3, "\x90\x04\xb0"); | ||
645 | } | ||
646 | |||
647 | fetch_idxdata(gspca_dev, tbl_init_post_alt_big_a, | ||
648 | ARRAY_SIZE(tbl_init_post_alt_big_a)); | ||
649 | |||
650 | if (reso == IMAGE_1600) | ||
651 | msleep(13); /* 1600 */ | ||
652 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x27\x97"); | ||
653 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x01\x00"); | ||
654 | msleep(53); | ||
655 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20"); | ||
656 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00"); | ||
657 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03"); | ||
658 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01"); | ||
659 | if (reso == IMAGE_1600) | ||
660 | msleep(13); /* 1600 */ | ||
661 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02"); | ||
662 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00"); | ||
663 | msleep(53); | ||
664 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20"); | ||
665 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x72"); | ||
666 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03"); | ||
667 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x02"); | ||
668 | if (reso == IMAGE_1600) | ||
669 | msleep(13); /* 1600 */ | ||
670 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02"); | ||
671 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01"); | ||
672 | msleep(53); | ||
673 | |||
674 | if (_MI2020b_) { | ||
675 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL); | ||
676 | if (reso == IMAGE_1600) | ||
677 | msleep(500); /* 1600 */ | ||
678 | ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); | ||
679 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); | ||
680 | msleep(1850); | ||
681 | } else if (_MI2020c_ || _MI2020_) { | ||
682 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL); | ||
683 | ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); | ||
684 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); | ||
685 | msleep(1850); | ||
686 | ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); | ||
687 | msleep(30); | ||
688 | } | ||
689 | |||
690 | /* AC power frequency */ | ||
691 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1); | ||
692 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2); | ||
693 | msleep(20); | ||
694 | /* backlight */ | ||
695 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); | ||
696 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); | ||
697 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); | ||
698 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); | ||
699 | /* at init time but not after */ | ||
700 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa2\x0c"); | ||
701 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x17"); | ||
702 | /* finish the backlight */ | ||
703 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); | ||
704 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); | ||
705 | msleep(6); /* " */ | ||
706 | |||
707 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c); | ||
708 | msleep(14); | ||
709 | |||
710 | if (_MI2020c_) | ||
711 | fetch_idxdata(gspca_dev, tbl_init_post_alt_big_b, | ||
712 | ARRAY_SIZE(tbl_init_post_alt_big_b)); | ||
713 | |||
714 | /* flip/mirror */ | ||
715 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1); | ||
716 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2); | ||
717 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3); | ||
718 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4); | ||
719 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5); | ||
720 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6); | ||
721 | /* end of flip/mirror main part */ | ||
722 | msleep(16); | ||
723 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03"); | ||
724 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01"); | ||
725 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20"); | ||
726 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00"); | ||
727 | if (reso == IMAGE_1600) | ||
728 | msleep(25); /* 1600 */ | ||
729 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02"); | ||
730 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00"); | ||
731 | msleep(103); | ||
732 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03"); | ||
733 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x02"); | ||
734 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20"); | ||
735 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x72"); | ||
736 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02"); | ||
737 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01"); | ||
738 | sd->nbIm = 0; | ||
739 | |||
740 | if (_MI2020c_) | ||
741 | fetch_idxdata(gspca_dev, tbl_init_post_alt_big_c, | ||
742 | ARRAY_SIZE(tbl_init_post_alt_big_c)); | ||
743 | } | ||
744 | |||
745 | sd->vold.mirror = mirror; | ||
746 | sd->vold.flip = flip; | ||
747 | sd->vold.AC50Hz = freq; | ||
748 | sd->vold.backlight = backlight; | ||
749 | |||
750 | mi2020_camera_settings(gspca_dev); | ||
751 | |||
752 | return 0; | ||
753 | } | ||
754 | |||
755 | static int mi2020_configure_alt(struct gspca_dev *gspca_dev) | ||
756 | { | ||
757 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
758 | |||
759 | switch (reso) { | ||
760 | case IMAGE_640: | ||
761 | gspca_dev->alt = 3 + 1; | ||
762 | break; | ||
763 | |||
764 | case IMAGE_800: | ||
765 | case IMAGE_1280: | ||
766 | case IMAGE_1600: | ||
767 | gspca_dev->alt = 1 + 1; | ||
768 | break; | ||
769 | } | ||
770 | return 0; | ||
771 | } | ||
772 | |||
773 | int mi2020_camera_settings(struct gspca_dev *gspca_dev) | ||
774 | { | ||
775 | struct sd *sd = (struct sd *) gspca_dev; | ||
776 | |||
777 | s32 backlight = sd->vcur.backlight; | ||
778 | s32 bright = sd->vcur.brightness; | ||
779 | s32 sharp = sd->vcur.sharpness; | ||
780 | s32 cntr = sd->vcur.contrast; | ||
781 | s32 gam = sd->vcur.gamma; | ||
782 | s32 hue = (sd->vcur.hue > 0); | ||
783 | s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); | ||
784 | s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); | ||
785 | s32 freq = (sd->vcur.AC50Hz > 0); | ||
786 | |||
787 | u8 dat_sharp[] = {0x6c, 0x00, 0x08}; | ||
788 | u8 dat_bright2[] = {0x90, 0x00, 0x00}; | ||
789 | u8 dat_freq2[] = {0x90, 0x00, 0x80}; | ||
790 | u8 dat_multi1[] = {0x8c, 0xa7, 0x00}; | ||
791 | u8 dat_multi2[] = {0x90, 0x00, 0x00}; | ||
792 | u8 dat_multi3[] = {0x8c, 0xa7, 0x00}; | ||
793 | u8 dat_multi4[] = {0x90, 0x00, 0x00}; | ||
794 | u8 dat_hvflip2[] = {0x90, 0x04, 0x6c}; | ||
795 | u8 dat_hvflip4[] = {0x90, 0x00, 0x24}; | ||
796 | |||
797 | /* Less than 4 images received -> too early to set the settings */ | ||
798 | if (sd->nbIm < 4) { | ||
799 | sd->waitSet = 1; | ||
800 | return 0; | ||
801 | } | ||
802 | sd->waitSet = 0; | ||
803 | |||
804 | if (freq != sd->vold.AC50Hz) { | ||
805 | sd->vold.AC50Hz = freq; | ||
806 | |||
807 | dat_freq2[2] = freq ? 0xc0 : 0x80; | ||
808 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1); | ||
809 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2); | ||
810 | msleep(20); | ||
811 | } | ||
812 | |||
813 | if (mirror != sd->vold.mirror || flip != sd->vold.flip) { | ||
814 | sd->vold.mirror = mirror; | ||
815 | sd->vold.flip = flip; | ||
816 | |||
817 | dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror); | ||
818 | dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror); | ||
819 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1); | ||
820 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2); | ||
821 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3); | ||
822 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4); | ||
823 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5); | ||
824 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6); | ||
825 | msleep(130); | ||
826 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); | ||
827 | msleep(6); | ||
828 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); | ||
829 | msleep(6); | ||
830 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); | ||
831 | msleep(6); | ||
832 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); | ||
833 | msleep(6); | ||
834 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); | ||
835 | msleep(6); | ||
836 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); | ||
837 | msleep(6); | ||
838 | |||
839 | /* Sometimes present, sometimes not, useful? */ | ||
840 | /* ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2); | ||
841 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3); | ||
842 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2); | ||
843 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3); | ||
844 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2); | ||
845 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3); | ||
846 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2); | ||
847 | * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);*/ | ||
848 | } | ||
849 | |||
850 | if (backlight != sd->vold.backlight) { | ||
851 | sd->vold.backlight = backlight; | ||
852 | if (backlight < 0 || backlight > sd->vmax.backlight) | ||
853 | backlight = 0; | ||
854 | |||
855 | dat_multi1[2] = 0x9d; | ||
856 | dat_multi3[2] = dat_multi1[2] + 1; | ||
857 | dat_multi4[2] = dat_multi2[2] = backlight; | ||
858 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); | ||
859 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); | ||
860 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); | ||
861 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); | ||
862 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); | ||
863 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); | ||
864 | } | ||
865 | |||
866 | if (gam != sd->vold.gamma) { | ||
867 | sd->vold.gamma = gam; | ||
868 | if (gam < 0 || gam > sd->vmax.gamma) | ||
869 | gam = 0; | ||
870 | |||
871 | dat_multi1[2] = 0x6d; | ||
872 | dat_multi3[2] = dat_multi1[2] + 1; | ||
873 | dat_multi4[2] = dat_multi2[2] = 0x40 + gam; | ||
874 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); | ||
875 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); | ||
876 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); | ||
877 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); | ||
878 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); | ||
879 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); | ||
880 | } | ||
881 | |||
882 | if (cntr != sd->vold.contrast) { | ||
883 | sd->vold.contrast = cntr; | ||
884 | if (cntr < 0 || cntr > sd->vmax.contrast) | ||
885 | cntr = 0; | ||
886 | |||
887 | dat_multi1[2] = 0x6d; | ||
888 | dat_multi3[2] = dat_multi1[2] + 1; | ||
889 | dat_multi4[2] = dat_multi2[2] = 0x12 + 16 * cntr; | ||
890 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); | ||
891 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); | ||
892 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); | ||
893 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); | ||
894 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5); | ||
895 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); | ||
896 | } | ||
897 | |||
898 | if (bright != sd->vold.brightness) { | ||
899 | sd->vold.brightness = bright; | ||
900 | if (bright < 0 || bright > sd->vmax.brightness) | ||
901 | bright = 0; | ||
902 | |||
903 | dat_bright2[2] = bright; | ||
904 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright1); | ||
905 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright2); | ||
906 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright3); | ||
907 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright4); | ||
908 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright5); | ||
909 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright6); | ||
910 | } | ||
911 | |||
912 | if (sharp != sd->vold.sharpness) { | ||
913 | sd->vold.sharpness = sharp; | ||
914 | if (sharp < 0 || sharp > sd->vmax.sharpness) | ||
915 | sharp = 0; | ||
916 | |||
917 | dat_sharp[1] = sharp; | ||
918 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0032, 3, dat_sharp); | ||
919 | } | ||
920 | |||
921 | if (hue != sd->vold.hue) { | ||
922 | sd->swapRB = hue; | ||
923 | sd->vold.hue = hue; | ||
924 | } | ||
925 | |||
926 | return 0; | ||
927 | } | ||
928 | |||
929 | static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev) | ||
930 | { | ||
931 | ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); | ||
932 | msleep(20); | ||
933 | if (_MI2020c_ || _MI2020_) | ||
934 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL); | ||
935 | else | ||
936 | ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL); | ||
937 | } | ||
diff --git a/drivers/media/video/gspca/gl860/gl860-ov2640.c b/drivers/media/video/gspca/gl860/gl860-ov2640.c new file mode 100644 index 000000000000..14b9c373f9f7 --- /dev/null +++ b/drivers/media/video/gspca/gl860/gl860-ov2640.c | |||
@@ -0,0 +1,505 @@ | |||
1 | /* @file gl860-ov2640.c | ||
2 | * @author Olivier LORIN, from Malmostoso's logs | ||
3 | * @date 2009-08-27 | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /* Sensor : OV2640 */ | ||
20 | |||
21 | #include "gl860.h" | ||
22 | |||
23 | static u8 dat_init1[] = "\x00\x41\x07\x6a\x06\x61\x0d\x6a" "\x10\x10\xc1\x01"; | ||
24 | static u8 dat_init2[] = {0x61}; /* expected */ | ||
25 | static u8 dat_init3[] = {0x51}; /* expected */ | ||
26 | |||
27 | static u8 dat_post[] = | ||
28 | "\x00\x41\x07\x6a\x06\xef\x0d\x6a" "\x10\x10\xc1\x01"; | ||
29 | |||
30 | static u8 dat_640[] = "\xd0\x01\xd1\x08\xd2\xe0\xd3\x02\xd4\x10\xd5\x81"; | ||
31 | static u8 dat_800[] = "\xd0\x01\xd1\x10\xd2\x58\xd3\x02\xd4\x18\xd5\x21"; | ||
32 | static u8 dat_1280[] = "\xd0\x01\xd1\x18\xd2\xc0\xd3\x02\xd4\x28\xd5\x01"; | ||
33 | static u8 dat_1600[] = "\xd0\x01\xd1\x20\xd2\xb0\xd3\x02\xd4\x30\xd5\x41"; | ||
34 | |||
35 | static u8 c50[] = {0x50}; /* expected */ | ||
36 | static u8 c28[] = {0x28}; /* expected */ | ||
37 | static u8 ca8[] = {0xa8}; /* expected */ | ||
38 | |||
39 | static struct validx tbl_init_at_startup[] = { | ||
40 | {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1}, | ||
41 | {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d}, | ||
42 | {0x0050, 0x0000}, {0x0041, 0x0000}, {0x006a, 0x0007}, {0x0061, 0x0006}, | ||
43 | {0x006a, 0x000d}, {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0001, 0x00c1}, | ||
44 | {0x0041, 0x00c2}, {0x0004, 0x00d8}, {0x0012, 0x0004}, {0x0000, 0x0058}, | ||
45 | {0x0041, 0x0000}, {0x0061, 0x0000}, | ||
46 | }; | ||
47 | |||
48 | static struct validx tbl_common[] = { | ||
49 | {0x6000, 0x00ff}, {0x60ff, 0x002c}, {0x60df, 0x002e}, {0x6001, 0x00ff}, | ||
50 | {0x6080, 0x0012}, {0x6000, 0x0000}, {0x6000, 0x0045}, {0x6000, 0x0010}, | ||
51 | {0x6035, 0x003c}, {0x6000, 0x0011}, {0x6028, 0x0004}, {0x60e5, 0x0013}, | ||
52 | {0x6088, 0x0014}, {0x600c, 0x002c}, {0x6078, 0x0033}, {0x60f7, 0x003b}, | ||
53 | {0x6000, 0x003e}, {0x6011, 0x0043}, {0x6010, 0x0016}, {0x6082, 0x0039}, | ||
54 | {0x6088, 0x0035}, {0x600a, 0x0022}, {0x6040, 0x0037}, {0x6000, 0x0023}, | ||
55 | {0x60a0, 0x0034}, {0x601a, 0x0036}, {0x6002, 0x0006}, {0x60c0, 0x0007}, | ||
56 | {0x60b7, 0x000d}, {0x6001, 0x000e}, {0x6000, 0x004c}, {0x6081, 0x004a}, | ||
57 | {0x6099, 0x0021}, {0x6002, 0x0009}, {0x603e, 0x0024}, {0x6034, 0x0025}, | ||
58 | {0x6081, 0x0026}, {0x6000, 0x0000}, {0x6000, 0x0045}, {0x6000, 0x0010}, | ||
59 | {0x6000, 0x005c}, {0x6000, 0x0063}, {0x6000, 0x007c}, {0x6070, 0x0061}, | ||
60 | {0x6080, 0x0062}, {0x6080, 0x0020}, {0x6030, 0x0028}, {0x6000, 0x006c}, | ||
61 | {0x6000, 0x006e}, {0x6002, 0x0070}, {0x6094, 0x0071}, {0x60c1, 0x0073}, | ||
62 | {0x6034, 0x003d}, {0x6057, 0x005a}, {0x60bb, 0x004f}, {0x609c, 0x0050}, | ||
63 | {0x6080, 0x006d}, {0x6002, 0x0039}, {0x6033, 0x003a}, {0x60f1, 0x003b}, | ||
64 | {0x6031, 0x003c}, {0x6000, 0x00ff}, {0x6014, 0x00e0}, {0x60ff, 0x0076}, | ||
65 | {0x60a0, 0x0033}, {0x6020, 0x0042}, {0x6018, 0x0043}, {0x6000, 0x004c}, | ||
66 | {0x60d0, 0x0087}, {0x600f, 0x0088}, {0x6003, 0x00d7}, {0x6010, 0x00d9}, | ||
67 | {0x6005, 0x00da}, {0x6082, 0x00d3}, {0x60c0, 0x00f9}, {0x6006, 0x0044}, | ||
68 | {0x6007, 0x00d1}, {0x6002, 0x00d2}, {0x6000, 0x00d2}, {0x6011, 0x00d8}, | ||
69 | {0x6008, 0x00c8}, {0x6080, 0x00c9}, {0x6008, 0x007c}, {0x6020, 0x007d}, | ||
70 | {0x6020, 0x007d}, {0x6000, 0x0090}, {0x600e, 0x0091}, {0x601a, 0x0091}, | ||
71 | {0x6031, 0x0091}, {0x605a, 0x0091}, {0x6069, 0x0091}, {0x6075, 0x0091}, | ||
72 | {0x607e, 0x0091}, {0x6088, 0x0091}, {0x608f, 0x0091}, {0x6096, 0x0091}, | ||
73 | {0x60a3, 0x0091}, {0x60af, 0x0091}, {0x60c4, 0x0091}, {0x60d7, 0x0091}, | ||
74 | {0x60e8, 0x0091}, {0x6020, 0x0091}, {0x6000, 0x0092}, {0x6006, 0x0093}, | ||
75 | {0x60e3, 0x0093}, {0x6005, 0x0093}, {0x6005, 0x0093}, {0x6000, 0x0093}, | ||
76 | {0x6004, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093}, | ||
77 | {0x6000, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093}, {0x6000, 0x0093}, | ||
78 | {0x6000, 0x0096}, {0x6008, 0x0097}, {0x6019, 0x0097}, {0x6002, 0x0097}, | ||
79 | {0x600c, 0x0097}, {0x6024, 0x0097}, {0x6030, 0x0097}, {0x6028, 0x0097}, | ||
80 | {0x6026, 0x0097}, {0x6002, 0x0097}, {0x6098, 0x0097}, {0x6080, 0x0097}, | ||
81 | {0x6000, 0x0097}, {0x6000, 0x0097}, {0x60ed, 0x00c3}, {0x609a, 0x00c4}, | ||
82 | {0x6000, 0x00a4}, {0x6011, 0x00c5}, {0x6051, 0x00c6}, {0x6010, 0x00c7}, | ||
83 | {0x6066, 0x00b6}, {0x60a5, 0x00b8}, {0x6064, 0x00b7}, {0x607c, 0x00b9}, | ||
84 | {0x60af, 0x00b3}, {0x6097, 0x00b4}, {0x60ff, 0x00b5}, {0x60c5, 0x00b0}, | ||
85 | {0x6094, 0x00b1}, {0x600f, 0x00b2}, {0x605c, 0x00c4}, {0x6000, 0x00a8}, | ||
86 | {0x60c8, 0x00c0}, {0x6096, 0x00c1}, {0x601d, 0x0086}, {0x6000, 0x0050}, | ||
87 | {0x6090, 0x0051}, {0x6018, 0x0052}, {0x6000, 0x0053}, {0x6000, 0x0054}, | ||
88 | {0x6088, 0x0055}, {0x6000, 0x0057}, {0x6090, 0x005a}, {0x6018, 0x005b}, | ||
89 | {0x6005, 0x005c}, {0x60ed, 0x00c3}, {0x6000, 0x007f}, {0x6005, 0x00da}, | ||
90 | {0x601f, 0x00e5}, {0x6067, 0x00e1}, {0x6000, 0x00e0}, {0x60ff, 0x00dd}, | ||
91 | {0x6000, 0x0005}, {0x6001, 0x00ff}, {0x6000, 0x0000}, {0x6000, 0x0045}, | ||
92 | {0x6000, 0x0010}, | ||
93 | }; | ||
94 | |||
95 | static struct validx tbl_sensor_settings_common_a[] = { | ||
96 | {0x0041, 0x0000}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a, 0x000d}, | ||
97 | {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0001, 0x00c1}, {0x0041, 0x00c2}, | ||
98 | {0x0004, 0x00d8}, {0x0012, 0x0004}, {0x0000, 0x0058}, {0x0041, 0x0000}, | ||
99 | {50, 0xffff}, | ||
100 | {0x0061, 0x0000}, | ||
101 | {0xffff, 0xffff}, | ||
102 | {0x6000, 0x00ff}, {0x6000, 0x007c}, {0x6007, 0x007d}, | ||
103 | {30, 0xffff}, | ||
104 | {0x0040, 0x0000}, | ||
105 | }; | ||
106 | |||
107 | static struct validx tbl_sensor_settings_common_b[] = { | ||
108 | {0x6001, 0x00ff}, {0x6038, 0x000c}, | ||
109 | {10, 0xffff}, | ||
110 | {0x6000, 0x0011}, | ||
111 | /* backlight=31/64 */ | ||
112 | {0x6001, 0x00ff}, {0x603e, 0x0024}, {0x6034, 0x0025}, | ||
113 | /* bright=0/256 */ | ||
114 | {0x6000, 0x00ff}, {0x6009, 0x007c}, {0x6000, 0x007d}, | ||
115 | /* wbal=64/128 */ | ||
116 | {0x6000, 0x00ff}, {0x6003, 0x007c}, {0x6040, 0x007d}, | ||
117 | /* cntr=0/256 */ | ||
118 | {0x6000, 0x00ff}, {0x6007, 0x007c}, {0x6000, 0x007d}, | ||
119 | /* sat=128/256 */ | ||
120 | {0x6000, 0x00ff}, {0x6001, 0x007c}, {0x6080, 0x007d}, | ||
121 | /* sharpness=0/32 */ | ||
122 | {0x6000, 0x00ff}, {0x6001, 0x0092}, {0x60c0, 0x0093}, | ||
123 | /* hue=0/256 */ | ||
124 | {0x6000, 0x00ff}, {0x6002, 0x007c}, {0x6000, 0x007d}, | ||
125 | /* gam=32/64 */ | ||
126 | {0x6000, 0x00ff}, {0x6008, 0x007c}, {0x6020, 0x007d}, | ||
127 | /* image right up */ | ||
128 | {0xffff, 0xffff}, | ||
129 | {15, 0xffff}, | ||
130 | {0x6001, 0x00ff}, {0x6000, 0x8004}, | ||
131 | {0xffff, 0xffff}, | ||
132 | {0x60a8, 0x0004}, | ||
133 | {15, 0xffff}, | ||
134 | {0x6001, 0x00ff}, {0x6000, 0x8004}, | ||
135 | {0xffff, 0xffff}, | ||
136 | {0x60f8, 0x0004}, | ||
137 | /* image right up */ | ||
138 | {0xffff, 0xffff}, | ||
139 | /* backlight=31/64 */ | ||
140 | {0x6001, 0x00ff}, {0x603e, 0x0024}, {0x6034, 0x0025}, | ||
141 | }; | ||
142 | |||
143 | static struct validx tbl_640[] = { | ||
144 | {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, {0x6067, 0x00e1}, | ||
145 | {0x6004, 0x00da}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, | ||
146 | {0x6001, 0x00ff}, {0x6000, 0x0012}, {0x6000, 0x0011}, {0x6011, 0x0017}, | ||
147 | {0x6075, 0x0018}, {0x6001, 0x0019}, {0x6097, 0x001a}, {0x6036, 0x0032}, | ||
148 | {0x60bb, 0x004f}, {0x6057, 0x005a}, {0x609c, 0x0050}, {0x6080, 0x006d}, | ||
149 | {0x6092, 0x0026}, {0x60ff, 0x0020}, {0x6000, 0x0027}, {0x6000, 0x00ff}, | ||
150 | {0x60c8, 0x00c0}, {0x6096, 0x00c1}, {0x6000, 0x008c}, {0x603d, 0x0086}, | ||
151 | {0x6089, 0x0050}, {0x6090, 0x0051}, {0x602c, 0x0052}, {0x6000, 0x0053}, | ||
152 | {0x6000, 0x0054}, {0x6088, 0x0055}, {0x6000, 0x0057}, {0x60a0, 0x005a}, | ||
153 | {0x6078, 0x005b}, {0x6000, 0x005c}, {0x6004, 0x00d3}, {0x6000, 0x00e0}, | ||
154 | {0x60ff, 0x00dd}, {0x60a1, 0x005a}, | ||
155 | }; | ||
156 | |||
157 | static struct validx tbl_800[] = { | ||
158 | {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, {0x6067, 0x00e1}, | ||
159 | {0x6004, 0x00da}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, | ||
160 | {0x6001, 0x00ff}, {0x6040, 0x0012}, {0x6000, 0x0011}, {0x6011, 0x0017}, | ||
161 | {0x6043, 0x0018}, {0x6000, 0x0019}, {0x604b, 0x001a}, {0x6009, 0x0032}, | ||
162 | {0x60ca, 0x004f}, {0x60a8, 0x0050}, {0x6000, 0x006d}, {0x6038, 0x003d}, | ||
163 | {0x60c8, 0x0035}, {0x6000, 0x0022}, {0x6092, 0x0026}, {0x60ff, 0x0020}, | ||
164 | {0x6000, 0x0027}, {0x6000, 0x00ff}, {0x6064, 0x00c0}, {0x604b, 0x00c1}, | ||
165 | {0x6000, 0x008c}, {0x601d, 0x0086}, {0x6082, 0x00d3}, {0x6000, 0x00e0}, | ||
166 | {0x60ff, 0x00dd}, {0x6020, 0x008c}, {0x6001, 0x00ff}, {0x6044, 0x0018}, | ||
167 | }; | ||
168 | |||
169 | static struct validx tbl_big_a[] = { | ||
170 | {0x0002, 0x00c1}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, | ||
171 | {0x6001, 0x00ff}, {0x6000, 0x0012}, {0x6000, 0x0000}, {0x6000, 0x0045}, | ||
172 | {0x6000, 0x0010}, {0x6000, 0x0011}, {0x6011, 0x0017}, {0x6075, 0x0018}, | ||
173 | {0x6001, 0x0019}, {0x6097, 0x001a}, {0x6036, 0x0032}, {0x60bb, 0x004f}, | ||
174 | {0x609c, 0x0050}, {0x6057, 0x005a}, {0x6080, 0x006d}, {0x6043, 0x000f}, | ||
175 | {0x608f, 0x0003}, {0x6005, 0x007c}, {0x6081, 0x0026}, {0x6000, 0x00ff}, | ||
176 | {0x60c8, 0x00c0}, {0x6096, 0x00c1}, {0x6000, 0x008c}, | ||
177 | }; | ||
178 | |||
179 | static struct validx tbl_big_b[] = { | ||
180 | {0x603d, 0x0086}, {0x6000, 0x0050}, {0x6090, 0x0051}, {0x602c, 0x0052}, | ||
181 | {0x6000, 0x0053}, {0x6000, 0x0054}, {0x6088, 0x0055}, {0x6000, 0x0057}, | ||
182 | {0x6040, 0x005a}, {0x60f0, 0x005b}, {0x6001, 0x005c}, {0x6082, 0x00d3}, | ||
183 | {0x6000, 0x008e}, | ||
184 | }; | ||
185 | |||
186 | static struct validx tbl_big_c[] = { | ||
187 | {0x6004, 0x00da}, {0x6000, 0x00e0}, {0x6067, 0x00e1}, {0x60ff, 0x00dd}, | ||
188 | {0x6001, 0x00ff}, {0x6000, 0x00ff}, {0x60f1, 0x00dd}, {0x6004, 0x00e0}, | ||
189 | {0x6001, 0x00ff}, {0x6000, 0x0011}, {0x6000, 0x00ff}, {0x6010, 0x00c7}, | ||
190 | {0x6000, 0x0092}, {0x6006, 0x0093}, {0x60e3, 0x0093}, {0x6005, 0x0093}, | ||
191 | {0x6005, 0x0093}, {0x60ed, 0x00c3}, {0x6000, 0x00a4}, {0x60d0, 0x0087}, | ||
192 | {0x6003, 0x0096}, {0x600c, 0x0097}, {0x6024, 0x0097}, {0x6030, 0x0097}, | ||
193 | {0x6028, 0x0097}, {0x6026, 0x0097}, {0x6002, 0x0097}, {0x6001, 0x00ff}, | ||
194 | {0x6043, 0x000f}, {0x608f, 0x0003}, {0x6000, 0x002d}, {0x6000, 0x002e}, | ||
195 | {0x600a, 0x0022}, {0x6002, 0x0070}, {0x6008, 0x0014}, {0x6048, 0x0014}, | ||
196 | {0x6000, 0x00ff}, {0x6000, 0x00e0}, {0x60ff, 0x00dd}, | ||
197 | }; | ||
198 | |||
199 | static struct validx tbl_post_unset_alt[] = { | ||
200 | {0x006a, 0x000d}, {0x6001, 0x00ff}, {0x6081, 0x0026}, {0x6000, 0x0000}, | ||
201 | {0x6000, 0x0045}, {0x6000, 0x0010}, {0x6068, 0x000d}, | ||
202 | {50, 0xffff}, | ||
203 | {0x0021, 0x0000}, | ||
204 | }; | ||
205 | |||
206 | static int ov2640_init_at_startup(struct gspca_dev *gspca_dev); | ||
207 | static int ov2640_configure_alt(struct gspca_dev *gspca_dev); | ||
208 | static int ov2640_init_pre_alt(struct gspca_dev *gspca_dev); | ||
209 | static int ov2640_init_post_alt(struct gspca_dev *gspca_dev); | ||
210 | static void ov2640_post_unset_alt(struct gspca_dev *gspca_dev); | ||
211 | static int ov2640_camera_settings(struct gspca_dev *gspca_dev); | ||
212 | /*==========================================================================*/ | ||
213 | |||
214 | void ov2640_init_settings(struct gspca_dev *gspca_dev) | ||
215 | { | ||
216 | struct sd *sd = (struct sd *) gspca_dev; | ||
217 | |||
218 | sd->vcur.backlight = 32; | ||
219 | sd->vcur.brightness = 0; | ||
220 | sd->vcur.sharpness = 6; | ||
221 | sd->vcur.contrast = 0; | ||
222 | sd->vcur.gamma = 32; | ||
223 | sd->vcur.hue = 0; | ||
224 | sd->vcur.saturation = 128; | ||
225 | sd->vcur.whitebal = 64; | ||
226 | |||
227 | sd->vmax.backlight = 64; | ||
228 | sd->vmax.brightness = 255; | ||
229 | sd->vmax.sharpness = 31; | ||
230 | sd->vmax.contrast = 255; | ||
231 | sd->vmax.gamma = 64; | ||
232 | sd->vmax.hue = 255 + 1; | ||
233 | sd->vmax.saturation = 255; | ||
234 | sd->vmax.whitebal = 128; | ||
235 | sd->vmax.mirror = 0; | ||
236 | sd->vmax.flip = 0; | ||
237 | sd->vmax.AC50Hz = 0; | ||
238 | |||
239 | sd->dev_camera_settings = ov2640_camera_settings; | ||
240 | sd->dev_init_at_startup = ov2640_init_at_startup; | ||
241 | sd->dev_configure_alt = ov2640_configure_alt; | ||
242 | sd->dev_init_pre_alt = ov2640_init_pre_alt; | ||
243 | sd->dev_post_unset_alt = ov2640_post_unset_alt; | ||
244 | } | ||
245 | |||
246 | /*==========================================================================*/ | ||
247 | |||
248 | static void common(struct gspca_dev *gspca_dev) | ||
249 | { | ||
250 | fetch_validx(gspca_dev, tbl_common, ARRAY_SIZE(tbl_common)); | ||
251 | } | ||
252 | |||
253 | static int ov2640_init_at_startup(struct gspca_dev *gspca_dev) | ||
254 | { | ||
255 | fetch_validx(gspca_dev, tbl_init_at_startup, | ||
256 | ARRAY_SIZE(tbl_init_at_startup)); | ||
257 | |||
258 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_init1); | ||
259 | |||
260 | common(gspca_dev); | ||
261 | |||
262 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0006, 1, dat_init2); | ||
263 | |||
264 | ctrl_out(gspca_dev, 0x40, 1, 0x00ef, 0x0006, 0, NULL); | ||
265 | |||
266 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, dat_init3); | ||
267 | |||
268 | ctrl_out(gspca_dev, 0x40, 1, 0x0051, 0x0000, 0, NULL); | ||
269 | /* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */ | ||
270 | |||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static int ov2640_init_pre_alt(struct gspca_dev *gspca_dev) | ||
275 | { | ||
276 | struct sd *sd = (struct sd *) gspca_dev; | ||
277 | |||
278 | sd->vold.backlight = -1; | ||
279 | sd->vold.brightness = -1; | ||
280 | sd->vold.sharpness = -1; | ||
281 | sd->vold.contrast = -1; | ||
282 | sd->vold.saturation = -1; | ||
283 | sd->vold.gamma = -1; | ||
284 | sd->vold.hue = -1; | ||
285 | sd->vold.whitebal = -1; | ||
286 | |||
287 | ov2640_init_post_alt(gspca_dev); | ||
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int ov2640_init_post_alt(struct gspca_dev *gspca_dev) | ||
293 | { | ||
294 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
295 | s32 n; /* reserved for FETCH macros */ | ||
296 | |||
297 | ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); | ||
298 | |||
299 | n = fetch_validx(gspca_dev, tbl_sensor_settings_common_a, | ||
300 | ARRAY_SIZE(tbl_sensor_settings_common_a)); | ||
301 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_post); | ||
302 | common(gspca_dev); | ||
303 | keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common_a, | ||
304 | ARRAY_SIZE(tbl_sensor_settings_common_a), n); | ||
305 | |||
306 | switch (reso) { | ||
307 | case IMAGE_640: | ||
308 | n = fetch_validx(gspca_dev, tbl_640, ARRAY_SIZE(tbl_640)); | ||
309 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_640); | ||
310 | break; | ||
311 | |||
312 | case IMAGE_800: | ||
313 | n = fetch_validx(gspca_dev, tbl_800, ARRAY_SIZE(tbl_800)); | ||
314 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 12, dat_800); | ||
315 | break; | ||
316 | |||
317 | case IMAGE_1600: | ||
318 | case IMAGE_1280: | ||
319 | n = fetch_validx(gspca_dev, tbl_big_a, ARRAY_SIZE(tbl_big_a)); | ||
320 | |||
321 | if (reso == IMAGE_1280) { | ||
322 | n = fetch_validx(gspca_dev, tbl_big_b, | ||
323 | ARRAY_SIZE(tbl_big_b)); | ||
324 | } else { | ||
325 | ctrl_out(gspca_dev, 0x40, 1, 0x601d, 0x0086, 0, NULL); | ||
326 | ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00d7, 0, NULL); | ||
327 | ctrl_out(gspca_dev, 0x40, 1, 0x6082, 0x00d3, 0, NULL); | ||
328 | } | ||
329 | |||
330 | n = fetch_validx(gspca_dev, tbl_big_c, ARRAY_SIZE(tbl_big_c)); | ||
331 | |||
332 | if (reso == IMAGE_1280) { | ||
333 | ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL); | ||
334 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
335 | 12, dat_1280); | ||
336 | } else { | ||
337 | ctrl_out(gspca_dev, 0x40, 1, 0x6020, 0x008c, 0, NULL); | ||
338 | ctrl_out(gspca_dev, 0x40, 1, 0x6001, 0x00ff, 0, NULL); | ||
339 | ctrl_out(gspca_dev, 0x40, 1, 0x6076, 0x0018, 0, NULL); | ||
340 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
341 | 12, dat_1600); | ||
342 | } | ||
343 | break; | ||
344 | } | ||
345 | |||
346 | n = fetch_validx(gspca_dev, tbl_sensor_settings_common_b, | ||
347 | ARRAY_SIZE(tbl_sensor_settings_common_b)); | ||
348 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, c50); | ||
349 | keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common_b, | ||
350 | ARRAY_SIZE(tbl_sensor_settings_common_b), n); | ||
351 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x8004, 1, c28); | ||
352 | keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common_b, | ||
353 | ARRAY_SIZE(tbl_sensor_settings_common_b), n); | ||
354 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x8004, 1, ca8); | ||
355 | keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common_b, | ||
356 | ARRAY_SIZE(tbl_sensor_settings_common_b), n); | ||
357 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, c50); | ||
358 | keep_on_fetching_validx(gspca_dev, tbl_sensor_settings_common_b, | ||
359 | ARRAY_SIZE(tbl_sensor_settings_common_b), n); | ||
360 | |||
361 | ov2640_camera_settings(gspca_dev); | ||
362 | |||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | static int ov2640_configure_alt(struct gspca_dev *gspca_dev) | ||
367 | { | ||
368 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
369 | |||
370 | switch (reso) { | ||
371 | case IMAGE_640: | ||
372 | gspca_dev->alt = 3 + 1; | ||
373 | break; | ||
374 | |||
375 | case IMAGE_800: | ||
376 | case IMAGE_1280: | ||
377 | case IMAGE_1600: | ||
378 | gspca_dev->alt = 1 + 1; | ||
379 | break; | ||
380 | } | ||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | static int ov2640_camera_settings(struct gspca_dev *gspca_dev) | ||
385 | { | ||
386 | struct sd *sd = (struct sd *) gspca_dev; | ||
387 | |||
388 | s32 backlight = sd->vcur.backlight; | ||
389 | s32 bright = sd->vcur.brightness; | ||
390 | s32 sharp = sd->vcur.sharpness; | ||
391 | s32 gam = sd->vcur.gamma; | ||
392 | s32 cntr = sd->vcur.contrast; | ||
393 | s32 sat = sd->vcur.saturation; | ||
394 | s32 hue = sd->vcur.hue; | ||
395 | s32 wbal = sd->vcur.whitebal; | ||
396 | |||
397 | if (backlight != sd->vold.backlight) { | ||
398 | if (backlight < 0 || backlight > sd->vmax.backlight) | ||
399 | backlight = 0; | ||
400 | |||
401 | ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x00ff, | ||
402 | 0, NULL); | ||
403 | ctrl_out(gspca_dev, 0x40, 1, 0x601f + backlight , 0x0024, | ||
404 | 0, NULL); | ||
405 | ctrl_out(gspca_dev, 0x40, 1, 0x601f + backlight - 10, 0x0025, | ||
406 | 0, NULL); | ||
407 | /* No sd->vold.backlight=backlight; (to be done again later) */ | ||
408 | } | ||
409 | |||
410 | if (bright != sd->vold.brightness) { | ||
411 | sd->vold.brightness = bright; | ||
412 | if (bright < 0 || bright > sd->vmax.brightness) | ||
413 | bright = 0; | ||
414 | |||
415 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
416 | ctrl_out(gspca_dev, 0x40, 1, 0x6009 , 0x007c, 0, NULL); | ||
417 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 + bright, 0x007d, 0, NULL); | ||
418 | } | ||
419 | |||
420 | if (wbal != sd->vold.whitebal) { | ||
421 | sd->vold.whitebal = wbal; | ||
422 | if (wbal < 0 || wbal > sd->vmax.whitebal) | ||
423 | wbal = 0; | ||
424 | |||
425 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
426 | ctrl_out(gspca_dev, 0x40, 1, 0x6003 , 0x007c, 0, NULL); | ||
427 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 + wbal, 0x007d, 0, NULL); | ||
428 | } | ||
429 | |||
430 | if (cntr != sd->vold.contrast) { | ||
431 | sd->vold.contrast = cntr; | ||
432 | if (cntr < 0 || cntr > sd->vmax.contrast) | ||
433 | cntr = 0; | ||
434 | |||
435 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
436 | ctrl_out(gspca_dev, 0x40, 1, 0x6007 , 0x007c, 0, NULL); | ||
437 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 + cntr, 0x007d, 0, NULL); | ||
438 | } | ||
439 | |||
440 | if (sat != sd->vold.saturation) { | ||
441 | sd->vold.saturation = sat; | ||
442 | if (sat < 0 || sat > sd->vmax.saturation) | ||
443 | sat = 0; | ||
444 | |||
445 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
446 | ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x007c, 0, NULL); | ||
447 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 + sat, 0x007d, 0, NULL); | ||
448 | } | ||
449 | |||
450 | if (sharp != sd->vold.sharpness) { | ||
451 | sd->vold.sharpness = sharp; | ||
452 | if (sharp < 0 || sharp > sd->vmax.sharpness) | ||
453 | sharp = 0; | ||
454 | |||
455 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
456 | ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x0092, 0, NULL); | ||
457 | ctrl_out(gspca_dev, 0x40, 1, 0x60c0 + sharp, 0x0093, 0, NULL); | ||
458 | } | ||
459 | |||
460 | if (hue != sd->vold.hue) { | ||
461 | sd->vold.hue = hue; | ||
462 | if (hue < 0 || hue > sd->vmax.hue) | ||
463 | hue = 0; | ||
464 | |||
465 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
466 | ctrl_out(gspca_dev, 0x40, 1, 0x6002 , 0x007c, 0, NULL); | ||
467 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 + hue * (hue < 255), 0x007d, | ||
468 | 0, NULL); | ||
469 | if (hue >= sd->vmax.hue) | ||
470 | sd->swapRB = 1; | ||
471 | else | ||
472 | sd->swapRB = 0; | ||
473 | } | ||
474 | |||
475 | if (gam != sd->vold.gamma) { | ||
476 | sd->vold.gamma = gam; | ||
477 | if (gam < 0 || gam > sd->vmax.gamma) | ||
478 | gam = 0; | ||
479 | |||
480 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 , 0x00ff, 0, NULL); | ||
481 | ctrl_out(gspca_dev, 0x40, 1, 0x6008 , 0x007c, 0, NULL); | ||
482 | ctrl_out(gspca_dev, 0x40, 1, 0x6000 + gam, 0x007d, 0, NULL); | ||
483 | } | ||
484 | |||
485 | if (backlight != sd->vold.backlight) { | ||
486 | sd->vold.backlight = backlight; | ||
487 | |||
488 | ctrl_out(gspca_dev, 0x40, 1, 0x6001 , 0x00ff, | ||
489 | 0, NULL); | ||
490 | ctrl_out(gspca_dev, 0x40, 1, 0x601f + backlight , 0x0024, | ||
491 | 0, NULL); | ||
492 | ctrl_out(gspca_dev, 0x40, 1, 0x601f + backlight - 10, 0x0025, | ||
493 | 0, NULL); | ||
494 | } | ||
495 | |||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | static void ov2640_post_unset_alt(struct gspca_dev *gspca_dev) | ||
500 | { | ||
501 | ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); | ||
502 | msleep(20); | ||
503 | fetch_validx(gspca_dev, tbl_post_unset_alt, | ||
504 | ARRAY_SIZE(tbl_post_unset_alt)); | ||
505 | } | ||
diff --git a/drivers/media/video/gspca/gl860/gl860-ov9655.c b/drivers/media/video/gspca/gl860/gl860-ov9655.c new file mode 100644 index 000000000000..eda3346f939c --- /dev/null +++ b/drivers/media/video/gspca/gl860/gl860-ov9655.c | |||
@@ -0,0 +1,337 @@ | |||
1 | /* @file gl860-ov9655.c | ||
2 | * @author Olivier LORIN, from logs done by Simon (Sur3) and Almighurt | ||
3 | * on dsd's weblog | ||
4 | * @date 2009-08-27 | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | /* Sensor : OV9655 */ | ||
21 | |||
22 | #include "gl860.h" | ||
23 | |||
24 | static struct validx tbl_init_at_startup[] = { | ||
25 | {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1}, | ||
26 | {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d}, | ||
27 | |||
28 | {0x0040, 0x0000}, | ||
29 | }; | ||
30 | |||
31 | static struct validx tbl_commmon[] = { | ||
32 | {0x0041, 0x0000}, {0x006a, 0x0007}, {0x0063, 0x0006}, {0x006a, 0x000d}, | ||
33 | {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0001, 0x00c1}, {0x0041, 0x00c2}, | ||
34 | {0x0004, 0x00d8}, {0x0012, 0x0004}, {0x0000, 0x0058}, {0x0040, 0x0000}, | ||
35 | {0x00f3, 0x0006}, {0x0058, 0x0000}, {0x0048, 0x0000}, {0x0061, 0x0000}, | ||
36 | }; | ||
37 | |||
38 | static s32 tbl_length[] = {12, 56, 52, 54, 56, 42, 32, 12}; | ||
39 | |||
40 | static u8 *tbl_640[] = { | ||
41 | "\x00\x40\x07\x6a\x06\xf3\x0d\x6a" "\x10\x10\xc1\x01" | ||
42 | , | ||
43 | "\x12\x80\x00\x00\x01\x98\x02\x80" "\x03\x12\x04\x03\x0b\x57\x0e\x61" | ||
44 | "\x0f\x42\x11\x01\x12\x60\x13\x00" "\x14\x3a\x16\x24\x17\x14\x18\x00" | ||
45 | "\x19\x01\x1a\x3d\x1e\x04\x24\x3c" "\x25\x36\x26\x72\x27\x08\x28\x08" | ||
46 | "\x29\x15\x2a\x00\x2b\x00\x2c\x08" | ||
47 | , | ||
48 | "\x32\xff\x33\x00\x34\x3d\x35\x00" "\x36\xfa\x38\x72\x39\x57\x3a\x00" | ||
49 | "\x3b\x0c\x3d\x99\x3e\x0c\x3f\xc1" "\x40\xc0\x41\x00\x42\xc0\x43\x0a" | ||
50 | "\x44\xf0\x45\x46\x46\x62\x47\x2a" "\x48\x3c\x4a\xee\x4b\xe7\x4c\xe7" | ||
51 | "\x4d\xe7\x4e\xe7" | ||
52 | , | ||
53 | "\x4f\x98\x50\x98\x51\x00\x52\x28" "\x53\x70\x54\x98\x58\x1a\x59\x85" | ||
54 | "\x5a\xa9\x5b\x64\x5c\x84\x5d\x53" "\x5e\x0e\x5f\xf0\x60\xf0\x61\xf0" | ||
55 | "\x62\x00\x63\x00\x64\x02\x65\x20" "\x66\x00\x69\x0a\x6b\x5a\x6c\x04" | ||
56 | "\x6d\x55\x6e\x00\x6f\x9d" | ||
57 | , | ||
58 | "\x70\x15\x71\x78\x72\x00\x73\x00" "\x74\x3a\x75\x35\x76\x01\x77\x02" | ||
59 | "\x7a\x24\x7b\x04\x7c\x07\x7d\x10" "\x7e\x28\x7f\x36\x80\x44\x81\x52" | ||
60 | "\x82\x60\x83\x6c\x84\x78\x85\x8c" "\x86\x9e\x87\xbb\x88\xd2\x89\xe5" | ||
61 | "\x8a\x23\x8c\x8d\x90\x7c\x91\x7b" | ||
62 | , | ||
63 | "\x9d\x02\x9e\x02\x9f\x74\xa0\x73" "\xa1\x40\xa4\x50\xa5\x68\xa6\x70" | ||
64 | "\xa8\xc1\xa9\xef\xaa\x92\xab\x04" "\xac\x80\xad\x80\xae\x80\xaf\x80" | ||
65 | "\xb2\xf2\xb3\x20\xb4\x20\xb5\x00" "\xb6\xaf" | ||
66 | , | ||
67 | "\xbb\xae\xbc\x4f\xbd\x4e\xbe\x6a" "\xbf\x68\xc0\xaa\xc1\xc0\xc2\x01" | ||
68 | "\xc3\x4e\xc6\x85\xc7\x81\xc9\xe0" "\xca\xe8\xcb\xf0\xcc\xd8\xcd\x93" | ||
69 | , | ||
70 | "\xd0\x01\xd1\x08\xd2\xe0\xd3\x01" "\xd4\x10\xd5\x80" | ||
71 | }; | ||
72 | |||
73 | static u8 *tbl_800[] = { | ||
74 | "\x00\x40\x07\x6a\x06\xf3\x0d\x6a" "\x10\x10\xc1\x01" | ||
75 | , | ||
76 | "\x12\x80\x00\x00\x01\x98\x02\x80" "\x03\x12\x04\x01\x0b\x57\x0e\x61" | ||
77 | "\x0f\x42\x11\x00\x12\x00\x13\x00" "\x14\x3a\x16\x24\x17\x1b\x18\xbb" | ||
78 | "\x19\x01\x1a\x81\x1e\x04\x24\x3c" "\x25\x36\x26\x72\x27\x08\x28\x08" | ||
79 | "\x29\x15\x2a\x00\x2b\x00\x2c\x08" | ||
80 | , | ||
81 | "\x32\xa4\x33\x00\x34\x3d\x35\x00" "\x36\xf8\x38\x72\x39\x57\x3a\x00" | ||
82 | "\x3b\x0c\x3d\x99\x3e\x0c\x3f\xc2" "\x40\xc0\x41\x00\x42\xc0\x43\x0a" | ||
83 | "\x44\xf0\x45\x46\x46\x62\x47\x2a" "\x48\x3c\x4a\xec\x4b\xe8\x4c\xe8" | ||
84 | "\x4d\xe8\x4e\xe8" | ||
85 | , | ||
86 | "\x4f\x98\x50\x98\x51\x00\x52\x28" "\x53\x70\x54\x98\x58\x1a\x59\x85" | ||
87 | "\x5a\xa9\x5b\x64\x5c\x84\x5d\x53" "\x5e\x0e\x5f\xf0\x60\xf0\x61\xf0" | ||
88 | "\x62\x00\x63\x00\x64\x02\x65\x20" "\x66\x00\x69\x02\x6b\x5a\x6c\x04" | ||
89 | "\x6d\x55\x6e\x00\x6f\x9d" | ||
90 | , | ||
91 | "\x70\x08\x71\x78\x72\x00\x73\x01" "\x74\x3a\x75\x35\x76\x01\x77\x02" | ||
92 | "\x7a\x24\x7b\x04\x7c\x07\x7d\x10" "\x7e\x28\x7f\x36\x80\x44\x81\x52" | ||
93 | "\x82\x60\x83\x6c\x84\x78\x85\x8c" "\x86\x9e\x87\xbb\x88\xd2\x89\xe5" | ||
94 | "\x8a\x23\x8c\x0d\x90\x90\x91\x90" | ||
95 | , | ||
96 | "\x9d\x02\x9e\x02\x9f\x94\xa0\x94" "\xa1\x01\xa4\x50\xa5\x68\xa6\x70" | ||
97 | "\xa8\xc1\xa9\xef\xaa\x92\xab\x04" "\xac\x80\xad\x80\xae\x80\xaf\x80" | ||
98 | "\xb2\xf2\xb3\x20\xb4\x20\xb5\x00" "\xb6\xaf" | ||
99 | , | ||
100 | "\xbb\xae\xbc\x38\xbd\x39\xbe\x01" "\xbf\x01\xc0\xe2\xc1\xc0\xc2\x01" | ||
101 | "\xc3\x4e\xc6\x85\xc7\x81\xc9\xe0" "\xca\xe8\xcb\xf0\xcc\xd8\xcd\x93" | ||
102 | , | ||
103 | "\xd0\x21\xd1\x18\xd2\xe0\xd3\x01" "\xd4\x28\xd5\x00" | ||
104 | }; | ||
105 | |||
106 | static u8 c04[] = {0x04}; | ||
107 | static u8 dat_post_1[] = "\x04\x00\x10\x20\xa1\x00\x00\x02"; | ||
108 | static u8 dat_post_2[] = "\x10\x10\xc1\x02"; | ||
109 | static u8 dat_post_3[] = "\x04\x00\x10\x7c\xa1\x00\x00\x04"; | ||
110 | static u8 dat_post_4[] = "\x10\x02\xc1\x06"; | ||
111 | static u8 dat_post_5[] = "\x04\x00\x10\x7b\xa1\x00\x00\x08"; | ||
112 | static u8 dat_post_6[] = "\x10\x10\xc1\x05"; | ||
113 | static u8 dat_post_7[] = "\x04\x00\x10\x7c\xa1\x00\x00\x08"; | ||
114 | static u8 dat_post_8[] = "\x04\x00\x10\x7c\xa1\x00\x00\x09"; | ||
115 | |||
116 | static struct validx tbl_init_post_alt[] = { | ||
117 | {0x6032, 0x00ff}, {0x6032, 0x00ff}, {0x6032, 0x00ff}, {0x603c, 0x00ff}, | ||
118 | {0x6003, 0x00ff}, {0x6032, 0x00ff}, {0x6032, 0x00ff}, {0x6001, 0x00ff}, | ||
119 | {0x6000, 0x801e}, | ||
120 | {0xffff, 0xffff}, | ||
121 | {0x6004, 0x001e}, {0x6000, 0x801e}, | ||
122 | {0xffff, 0xffff}, | ||
123 | {0x6004, 0x001e}, {0x6012, 0x0003}, {0x6000, 0x801e}, | ||
124 | {0xffff, 0xffff}, | ||
125 | {0x6004, 0x001e}, {0x6000, 0x801e}, | ||
126 | {0xffff, 0xffff}, | ||
127 | {0x6004, 0x001e}, {0x6012, 0x0003}, | ||
128 | {0xffff, 0xffff}, | ||
129 | {0x6000, 0x801e}, | ||
130 | {0xffff, 0xffff}, | ||
131 | {0x6004, 0x001e}, {0x6000, 0x801e}, | ||
132 | {0xffff, 0xffff}, | ||
133 | {0x6004, 0x001e}, {0x6012, 0x0003}, {0x6000, 0x801e}, | ||
134 | {0xffff, 0xffff}, | ||
135 | {0x6004, 0x001e}, {0x6000, 0x801e}, | ||
136 | {0xffff, 0xffff}, | ||
137 | {0x6004, 0x001e}, {0x6012, 0x0003}, | ||
138 | {0xffff, 0xffff}, | ||
139 | {0x6000, 0x801e}, | ||
140 | {0xffff, 0xffff}, | ||
141 | {0x6004, 0x001e}, {0x6000, 0x801e}, | ||
142 | {0xffff, 0xffff}, | ||
143 | {0x6004, 0x001e}, {0x6012, 0x0003}, | ||
144 | }; | ||
145 | |||
146 | static int ov9655_init_at_startup(struct gspca_dev *gspca_dev); | ||
147 | static int ov9655_configure_alt(struct gspca_dev *gspca_dev); | ||
148 | static int ov9655_init_pre_alt(struct gspca_dev *gspca_dev); | ||
149 | static int ov9655_init_post_alt(struct gspca_dev *gspca_dev); | ||
150 | static void ov9655_post_unset_alt(struct gspca_dev *gspca_dev); | ||
151 | static int ov9655_camera_settings(struct gspca_dev *gspca_dev); | ||
152 | /*==========================================================================*/ | ||
153 | |||
154 | void ov9655_init_settings(struct gspca_dev *gspca_dev) | ||
155 | { | ||
156 | struct sd *sd = (struct sd *) gspca_dev; | ||
157 | |||
158 | sd->vcur.backlight = 0; | ||
159 | sd->vcur.brightness = 128; | ||
160 | sd->vcur.sharpness = 0; | ||
161 | sd->vcur.contrast = 0; | ||
162 | sd->vcur.gamma = 0; | ||
163 | sd->vcur.hue = 0; | ||
164 | sd->vcur.saturation = 0; | ||
165 | sd->vcur.whitebal = 0; | ||
166 | |||
167 | sd->vmax.backlight = 0; | ||
168 | sd->vmax.brightness = 255; | ||
169 | sd->vmax.sharpness = 0; | ||
170 | sd->vmax.contrast = 0; | ||
171 | sd->vmax.gamma = 0; | ||
172 | sd->vmax.hue = 0 + 1; | ||
173 | sd->vmax.saturation = 0; | ||
174 | sd->vmax.whitebal = 0; | ||
175 | sd->vmax.mirror = 0; | ||
176 | sd->vmax.flip = 0; | ||
177 | sd->vmax.AC50Hz = 0; | ||
178 | |||
179 | sd->dev_camera_settings = ov9655_camera_settings; | ||
180 | sd->dev_init_at_startup = ov9655_init_at_startup; | ||
181 | sd->dev_configure_alt = ov9655_configure_alt; | ||
182 | sd->dev_init_pre_alt = ov9655_init_pre_alt; | ||
183 | sd->dev_post_unset_alt = ov9655_post_unset_alt; | ||
184 | } | ||
185 | |||
186 | /*==========================================================================*/ | ||
187 | |||
188 | static int ov9655_init_at_startup(struct gspca_dev *gspca_dev) | ||
189 | { | ||
190 | fetch_validx(gspca_dev, tbl_init_at_startup, | ||
191 | ARRAY_SIZE(tbl_init_at_startup)); | ||
192 | fetch_validx(gspca_dev, tbl_commmon, ARRAY_SIZE(tbl_commmon)); | ||
193 | /* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL);*/ | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static int ov9655_init_pre_alt(struct gspca_dev *gspca_dev) | ||
199 | { | ||
200 | struct sd *sd = (struct sd *) gspca_dev; | ||
201 | |||
202 | sd->vold.brightness = -1; | ||
203 | sd->vold.hue = -1; | ||
204 | |||
205 | fetch_validx(gspca_dev, tbl_commmon, ARRAY_SIZE(tbl_commmon)); | ||
206 | |||
207 | ov9655_init_post_alt(gspca_dev); | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static int ov9655_init_post_alt(struct gspca_dev *gspca_dev) | ||
213 | { | ||
214 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
215 | s32 n; /* reserved for FETCH macros */ | ||
216 | s32 i; | ||
217 | u8 **tbl; | ||
218 | |||
219 | ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); | ||
220 | |||
221 | tbl = (reso == IMAGE_640) ? tbl_640 : tbl_800; | ||
222 | |||
223 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
224 | tbl_length[0], tbl[0]); | ||
225 | for (i = 1; i < 7; i++) | ||
226 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, | ||
227 | tbl_length[i], tbl[i]); | ||
228 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, | ||
229 | tbl_length[7], tbl[7]); | ||
230 | |||
231 | n = fetch_validx(gspca_dev, tbl_init_post_alt, | ||
232 | ARRAY_SIZE(tbl_init_post_alt)); | ||
233 | |||
234 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
235 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
236 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
237 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
238 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
239 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
240 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
241 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
242 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
243 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
244 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
245 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
246 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_1); | ||
247 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
248 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
249 | |||
250 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
251 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
252 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
253 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
254 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
255 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
256 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
257 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
258 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
259 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
260 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
261 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
262 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_1); | ||
263 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
264 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
265 | |||
266 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
267 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
268 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
269 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x801e, 1, c04); | ||
270 | keep_on_fetching_validx(gspca_dev, tbl_init_post_alt, | ||
271 | ARRAY_SIZE(tbl_init_post_alt), n); | ||
272 | |||
273 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_1); | ||
274 | |||
275 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4, dat_post_2); | ||
276 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_3); | ||
277 | |||
278 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4, dat_post_4); | ||
279 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_5); | ||
280 | |||
281 | ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 4, dat_post_6); | ||
282 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_7); | ||
283 | |||
284 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_post_8); | ||
285 | |||
286 | ov9655_camera_settings(gspca_dev); | ||
287 | |||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static int ov9655_configure_alt(struct gspca_dev *gspca_dev) | ||
292 | { | ||
293 | s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; | ||
294 | |||
295 | switch (reso) { | ||
296 | case IMAGE_640: | ||
297 | gspca_dev->alt = 1 + 1; | ||
298 | break; | ||
299 | |||
300 | default: | ||
301 | gspca_dev->alt = 1 + 1; | ||
302 | break; | ||
303 | } | ||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static int ov9655_camera_settings(struct gspca_dev *gspca_dev) | ||
308 | { | ||
309 | struct sd *sd = (struct sd *) gspca_dev; | ||
310 | |||
311 | u8 dat_bright[] = "\x04\x00\x10\x7c\xa1\x00\x00\x70"; | ||
312 | |||
313 | s32 bright = sd->vcur.brightness; | ||
314 | s32 hue = sd->vcur.hue; | ||
315 | |||
316 | if (bright != sd->vold.brightness) { | ||
317 | sd->vold.brightness = bright; | ||
318 | if (bright < 0 || bright > sd->vmax.brightness) | ||
319 | bright = 0; | ||
320 | |||
321 | dat_bright[3] = bright; | ||
322 | ctrl_out(gspca_dev, 0x40, 3, 0x6000, 0x0200, 8, dat_bright); | ||
323 | } | ||
324 | |||
325 | if (hue != sd->vold.hue) { | ||
326 | sd->vold.hue = hue; | ||
327 | sd->swapRB = (hue != 0); | ||
328 | } | ||
329 | |||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static void ov9655_post_unset_alt(struct gspca_dev *gspca_dev) | ||
334 | { | ||
335 | ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); | ||
336 | ctrl_out(gspca_dev, 0x40, 1, 0x0061, 0x0000, 0, NULL); | ||
337 | } | ||
diff --git a/drivers/media/video/gspca/gl860/gl860.c b/drivers/media/video/gspca/gl860/gl860.c new file mode 100644 index 000000000000..62f4320fd9d8 --- /dev/null +++ b/drivers/media/video/gspca/gl860/gl860.c | |||
@@ -0,0 +1,783 @@ | |||
1 | /* @file gl860.c | ||
2 | * @date 2009-08-27 | ||
3 | * | ||
4 | * Genesys Logic webcam with gl860 subdrivers | ||
5 | * | ||
6 | * Driver by Olivier Lorin <o.lorin@laposte.net> | ||
7 | * GSPCA by Jean-Francois Moine <http://moinejf.free.fr> | ||
8 | * Thanks BUGabundo and Malmostoso for your amazing help! | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | ||
23 | #include "gspca.h" | ||
24 | #include "gl860.h" | ||
25 | |||
26 | MODULE_AUTHOR("Olivier Lorin <lorin@laposte.net>"); | ||
27 | MODULE_DESCRIPTION("GSPCA/Genesys Logic GL860 USB Camera Driver"); | ||
28 | MODULE_LICENSE("GPL"); | ||
29 | |||
30 | /*======================== static function declarations ====================*/ | ||
31 | |||
32 | static void (*dev_init_settings)(struct gspca_dev *gspca_dev); | ||
33 | |||
34 | static int sd_config(struct gspca_dev *gspca_dev, | ||
35 | const struct usb_device_id *id); | ||
36 | static int sd_init(struct gspca_dev *gspca_dev); | ||
37 | static int sd_isoc_init(struct gspca_dev *gspca_dev); | ||
38 | static int sd_start(struct gspca_dev *gspca_dev); | ||
39 | static void sd_stop0(struct gspca_dev *gspca_dev); | ||
40 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
41 | struct gspca_frame *frame, u8 *data, s32 len); | ||
42 | static void sd_callback(struct gspca_dev *gspca_dev); | ||
43 | |||
44 | static int gl860_guess_sensor(struct gspca_dev *gspca_dev, | ||
45 | s32 vendor_id, s32 product_id); | ||
46 | |||
47 | /*============================ driver options ==============================*/ | ||
48 | |||
49 | static s32 AC50Hz = 0xff; | ||
50 | module_param(AC50Hz, int, 0644); | ||
51 | MODULE_PARM_DESC(AC50Hz, " Does AC power frequency is 50Hz? (0/1)"); | ||
52 | |||
53 | static char sensor[7]; | ||
54 | module_param_string(sensor, sensor, sizeof(sensor), 0644); | ||
55 | MODULE_PARM_DESC(sensor, | ||
56 | " Driver sensor ('MI1320'/'MI2020'/'OV9655'/'OV2640'/'')"); | ||
57 | |||
58 | /*============================ webcam controls =============================*/ | ||
59 | |||
60 | /* Functions to get and set a control value */ | ||
61 | #define SD_SETGET(thename) \ | ||
62 | static int sd_set_##thename(struct gspca_dev *gspca_dev, s32 val)\ | ||
63 | {\ | ||
64 | struct sd *sd = (struct sd *) gspca_dev;\ | ||
65 | \ | ||
66 | sd->vcur.thename = val;\ | ||
67 | if (gspca_dev->streaming)\ | ||
68 | sd->dev_camera_settings(gspca_dev);\ | ||
69 | return 0;\ | ||
70 | } \ | ||
71 | static int sd_get_##thename(struct gspca_dev *gspca_dev, s32 *val)\ | ||
72 | {\ | ||
73 | struct sd *sd = (struct sd *) gspca_dev;\ | ||
74 | \ | ||
75 | *val = sd->vcur.thename;\ | ||
76 | return 0;\ | ||
77 | } | ||
78 | |||
79 | SD_SETGET(mirror) | ||
80 | SD_SETGET(flip) | ||
81 | SD_SETGET(AC50Hz) | ||
82 | SD_SETGET(backlight) | ||
83 | SD_SETGET(brightness) | ||
84 | SD_SETGET(gamma) | ||
85 | SD_SETGET(hue) | ||
86 | SD_SETGET(saturation) | ||
87 | SD_SETGET(sharpness) | ||
88 | SD_SETGET(whitebal) | ||
89 | SD_SETGET(contrast) | ||
90 | |||
91 | #define GL860_NCTRLS 11 | ||
92 | |||
93 | /* control table */ | ||
94 | static struct ctrl sd_ctrls_mi1320[GL860_NCTRLS]; | ||
95 | static struct ctrl sd_ctrls_mi2020[GL860_NCTRLS]; | ||
96 | static struct ctrl sd_ctrls_mi2020b[GL860_NCTRLS]; | ||
97 | static struct ctrl sd_ctrls_ov2640[GL860_NCTRLS]; | ||
98 | static struct ctrl sd_ctrls_ov9655[GL860_NCTRLS]; | ||
99 | |||
100 | #define SET_MY_CTRL(theid, \ | ||
101 | thetype, thelabel, thename) \ | ||
102 | if (sd->vmax.thename != 0) {\ | ||
103 | sd_ctrls[nCtrls].qctrl.id = theid;\ | ||
104 | sd_ctrls[nCtrls].qctrl.type = thetype;\ | ||
105 | strcpy(sd_ctrls[nCtrls].qctrl.name, thelabel);\ | ||
106 | sd_ctrls[nCtrls].qctrl.minimum = 0;\ | ||
107 | sd_ctrls[nCtrls].qctrl.maximum = sd->vmax.thename;\ | ||
108 | sd_ctrls[nCtrls].qctrl.default_value = sd->vcur.thename;\ | ||
109 | sd_ctrls[nCtrls].qctrl.step = \ | ||
110 | (sd->vmax.thename < 16) ? 1 : sd->vmax.thename/16;\ | ||
111 | sd_ctrls[nCtrls].set = sd_set_##thename;\ | ||
112 | sd_ctrls[nCtrls].get = sd_get_##thename;\ | ||
113 | nCtrls++;\ | ||
114 | } | ||
115 | |||
116 | static int gl860_build_control_table(struct gspca_dev *gspca_dev) | ||
117 | { | ||
118 | struct sd *sd = (struct sd *) gspca_dev; | ||
119 | struct ctrl *sd_ctrls; | ||
120 | int nCtrls = 0; | ||
121 | |||
122 | if (_MI1320_) | ||
123 | sd_ctrls = sd_ctrls_mi1320; | ||
124 | else if (_MI2020_) | ||
125 | sd_ctrls = sd_ctrls_mi2020; | ||
126 | else if (_MI2020b_) | ||
127 | sd_ctrls = sd_ctrls_mi2020b; | ||
128 | else if (_OV2640_) | ||
129 | sd_ctrls = sd_ctrls_ov2640; | ||
130 | else if (_OV9655_) | ||
131 | sd_ctrls = sd_ctrls_ov9655; | ||
132 | |||
133 | memset(sd_ctrls, 0, GL860_NCTRLS * sizeof(struct ctrl)); | ||
134 | |||
135 | SET_MY_CTRL(V4L2_CID_BRIGHTNESS, | ||
136 | V4L2_CTRL_TYPE_INTEGER, "Brightness", brightness) | ||
137 | SET_MY_CTRL(V4L2_CID_SHARPNESS, | ||
138 | V4L2_CTRL_TYPE_INTEGER, "Sharpness", sharpness) | ||
139 | SET_MY_CTRL(V4L2_CID_CONTRAST, | ||
140 | V4L2_CTRL_TYPE_INTEGER, "Contrast", contrast) | ||
141 | SET_MY_CTRL(V4L2_CID_GAMMA, | ||
142 | V4L2_CTRL_TYPE_INTEGER, "Gamma", gamma) | ||
143 | SET_MY_CTRL(V4L2_CID_HUE, | ||
144 | V4L2_CTRL_TYPE_INTEGER, "Palette", hue) | ||
145 | SET_MY_CTRL(V4L2_CID_SATURATION, | ||
146 | V4L2_CTRL_TYPE_INTEGER, "Saturation", saturation) | ||
147 | SET_MY_CTRL(V4L2_CID_WHITE_BALANCE_TEMPERATURE, | ||
148 | V4L2_CTRL_TYPE_INTEGER, "White Bal.", whitebal) | ||
149 | SET_MY_CTRL(V4L2_CID_BACKLIGHT_COMPENSATION, | ||
150 | V4L2_CTRL_TYPE_INTEGER, "Backlight" , backlight) | ||
151 | |||
152 | SET_MY_CTRL(V4L2_CID_HFLIP, | ||
153 | V4L2_CTRL_TYPE_BOOLEAN, "Mirror", mirror) | ||
154 | SET_MY_CTRL(V4L2_CID_VFLIP, | ||
155 | V4L2_CTRL_TYPE_BOOLEAN, "Flip", flip) | ||
156 | SET_MY_CTRL(V4L2_CID_POWER_LINE_FREQUENCY, | ||
157 | V4L2_CTRL_TYPE_BOOLEAN, "50Hz", AC50Hz) | ||
158 | |||
159 | return nCtrls; | ||
160 | } | ||
161 | |||
162 | /*==================== sud-driver structure initialisation =================*/ | ||
163 | |||
164 | static struct sd_desc sd_desc_mi1320 = { | ||
165 | .name = MODULE_NAME, | ||
166 | .ctrls = sd_ctrls_mi1320, | ||
167 | .nctrls = GL860_NCTRLS, | ||
168 | .config = sd_config, | ||
169 | .init = sd_init, | ||
170 | .isoc_init = sd_isoc_init, | ||
171 | .start = sd_start, | ||
172 | .stop0 = sd_stop0, | ||
173 | .pkt_scan = sd_pkt_scan, | ||
174 | .dq_callback = sd_callback, | ||
175 | }; | ||
176 | |||
177 | static struct sd_desc sd_desc_mi2020 = { | ||
178 | .name = MODULE_NAME, | ||
179 | .ctrls = sd_ctrls_mi2020, | ||
180 | .nctrls = GL860_NCTRLS, | ||
181 | .config = sd_config, | ||
182 | .init = sd_init, | ||
183 | .isoc_init = sd_isoc_init, | ||
184 | .start = sd_start, | ||
185 | .stop0 = sd_stop0, | ||
186 | .pkt_scan = sd_pkt_scan, | ||
187 | .dq_callback = sd_callback, | ||
188 | }; | ||
189 | |||
190 | static struct sd_desc sd_desc_mi2020b = { | ||
191 | .name = MODULE_NAME, | ||
192 | .ctrls = sd_ctrls_mi2020b, | ||
193 | .nctrls = GL860_NCTRLS, | ||
194 | .config = sd_config, | ||
195 | .init = sd_init, | ||
196 | .isoc_init = sd_isoc_init, | ||
197 | .start = sd_start, | ||
198 | .stop0 = sd_stop0, | ||
199 | .pkt_scan = sd_pkt_scan, | ||
200 | .dq_callback = sd_callback, | ||
201 | }; | ||
202 | |||
203 | static struct sd_desc sd_desc_ov2640 = { | ||
204 | .name = MODULE_NAME, | ||
205 | .ctrls = sd_ctrls_ov2640, | ||
206 | .nctrls = GL860_NCTRLS, | ||
207 | .config = sd_config, | ||
208 | .init = sd_init, | ||
209 | .isoc_init = sd_isoc_init, | ||
210 | .start = sd_start, | ||
211 | .stop0 = sd_stop0, | ||
212 | .pkt_scan = sd_pkt_scan, | ||
213 | .dq_callback = sd_callback, | ||
214 | }; | ||
215 | |||
216 | static struct sd_desc sd_desc_ov9655 = { | ||
217 | .name = MODULE_NAME, | ||
218 | .ctrls = sd_ctrls_ov9655, | ||
219 | .nctrls = GL860_NCTRLS, | ||
220 | .config = sd_config, | ||
221 | .init = sd_init, | ||
222 | .isoc_init = sd_isoc_init, | ||
223 | .start = sd_start, | ||
224 | .stop0 = sd_stop0, | ||
225 | .pkt_scan = sd_pkt_scan, | ||
226 | .dq_callback = sd_callback, | ||
227 | }; | ||
228 | |||
229 | /*=========================== sub-driver image sizes =======================*/ | ||
230 | |||
231 | static struct v4l2_pix_format mi2020_mode[] = { | ||
232 | { 640, 480, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
233 | .bytesperline = 640, | ||
234 | .sizeimage = 640 * 480, | ||
235 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
236 | .priv = 0 | ||
237 | }, | ||
238 | { 800, 600, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
239 | .bytesperline = 800, | ||
240 | .sizeimage = 800 * 600, | ||
241 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
242 | .priv = 1 | ||
243 | }, | ||
244 | {1280, 1024, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
245 | .bytesperline = 1280, | ||
246 | .sizeimage = 1280 * 1024, | ||
247 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
248 | .priv = 2 | ||
249 | }, | ||
250 | {1600, 1200, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
251 | .bytesperline = 1600, | ||
252 | .sizeimage = 1600 * 1200, | ||
253 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
254 | .priv = 3 | ||
255 | }, | ||
256 | }; | ||
257 | |||
258 | static struct v4l2_pix_format ov2640_mode[] = { | ||
259 | { 640, 480, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
260 | .bytesperline = 640, | ||
261 | .sizeimage = 640 * 480, | ||
262 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
263 | .priv = 0 | ||
264 | }, | ||
265 | { 800, 600, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
266 | .bytesperline = 800, | ||
267 | .sizeimage = 800 * 600, | ||
268 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
269 | .priv = 1 | ||
270 | }, | ||
271 | {1280, 960, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
272 | .bytesperline = 1280, | ||
273 | .sizeimage = 1280 * 960, | ||
274 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
275 | .priv = 2 | ||
276 | }, | ||
277 | {1600, 1200, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
278 | .bytesperline = 1600, | ||
279 | .sizeimage = 1600 * 1200, | ||
280 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
281 | .priv = 3 | ||
282 | }, | ||
283 | }; | ||
284 | |||
285 | static struct v4l2_pix_format mi1320_mode[] = { | ||
286 | { 640, 480, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
287 | .bytesperline = 640, | ||
288 | .sizeimage = 640 * 480, | ||
289 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
290 | .priv = 0 | ||
291 | }, | ||
292 | { 800, 600, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
293 | .bytesperline = 800, | ||
294 | .sizeimage = 800 * 600, | ||
295 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
296 | .priv = 1 | ||
297 | }, | ||
298 | {1280, 960, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
299 | .bytesperline = 1280, | ||
300 | .sizeimage = 1280 * 960, | ||
301 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
302 | .priv = 2 | ||
303 | }, | ||
304 | }; | ||
305 | |||
306 | static struct v4l2_pix_format ov9655_mode[] = { | ||
307 | { 640, 480, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
308 | .bytesperline = 640, | ||
309 | .sizeimage = 640 * 480, | ||
310 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
311 | .priv = 0 | ||
312 | }, | ||
313 | {1280, 960, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, | ||
314 | .bytesperline = 1280, | ||
315 | .sizeimage = 1280 * 960, | ||
316 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
317 | .priv = 1 | ||
318 | }, | ||
319 | }; | ||
320 | |||
321 | /*========================= sud-driver functions ===========================*/ | ||
322 | |||
323 | /* This function is called at probe time */ | ||
324 | static int sd_config(struct gspca_dev *gspca_dev, | ||
325 | const struct usb_device_id *id) | ||
326 | { | ||
327 | struct sd *sd = (struct sd *) gspca_dev; | ||
328 | struct cam *cam; | ||
329 | s32 vendor_id, product_id; | ||
330 | |||
331 | /* Get USB VendorID and ProductID */ | ||
332 | vendor_id = le16_to_cpu(id->idVendor); | ||
333 | product_id = le16_to_cpu(id->idProduct); | ||
334 | |||
335 | sd->nbRightUp = 1; | ||
336 | sd->nbIm = -1; | ||
337 | |||
338 | sd->sensor = 0xff; | ||
339 | if (strcmp(sensor, "MI1320") == 0) | ||
340 | sd->sensor = ID_MI1320; | ||
341 | else if (strcmp(sensor, "OV2640") == 0) | ||
342 | sd->sensor = ID_OV2640; | ||
343 | else if (strcmp(sensor, "OV9655") == 0) | ||
344 | sd->sensor = ID_OV9655; | ||
345 | else if (strcmp(sensor, "MI2020") == 0) | ||
346 | sd->sensor = ID_MI2020; | ||
347 | else if (strcmp(sensor, "MI2020b") == 0) | ||
348 | sd->sensor = ID_MI2020b; | ||
349 | |||
350 | /* Get sensor and set the suitable init/start/../stop functions */ | ||
351 | if (gl860_guess_sensor(gspca_dev, vendor_id, product_id) == -1) | ||
352 | return -1; | ||
353 | |||
354 | cam = &gspca_dev->cam; | ||
355 | gspca_dev->nbalt = 4; | ||
356 | |||
357 | switch (sd->sensor) { | ||
358 | case ID_MI1320: | ||
359 | gspca_dev->sd_desc = &sd_desc_mi1320; | ||
360 | cam->cam_mode = mi1320_mode; | ||
361 | cam->nmodes = ARRAY_SIZE(mi1320_mode); | ||
362 | dev_init_settings = mi1320_init_settings; | ||
363 | break; | ||
364 | |||
365 | case ID_MI2020: | ||
366 | gspca_dev->sd_desc = &sd_desc_mi2020; | ||
367 | cam->cam_mode = mi2020_mode; | ||
368 | cam->nmodes = ARRAY_SIZE(mi2020_mode); | ||
369 | dev_init_settings = mi2020_init_settings; | ||
370 | break; | ||
371 | |||
372 | case ID_MI2020b: | ||
373 | gspca_dev->sd_desc = &sd_desc_mi2020b; | ||
374 | cam->cam_mode = mi2020_mode; | ||
375 | cam->nmodes = ARRAY_SIZE(mi2020_mode); | ||
376 | dev_init_settings = mi2020_init_settings; | ||
377 | break; | ||
378 | |||
379 | case ID_OV2640: | ||
380 | gspca_dev->sd_desc = &sd_desc_ov2640; | ||
381 | cam->cam_mode = ov2640_mode; | ||
382 | cam->nmodes = ARRAY_SIZE(ov2640_mode); | ||
383 | dev_init_settings = ov2640_init_settings; | ||
384 | break; | ||
385 | |||
386 | case ID_OV9655: | ||
387 | gspca_dev->sd_desc = &sd_desc_ov9655; | ||
388 | cam->cam_mode = ov9655_mode; | ||
389 | cam->nmodes = ARRAY_SIZE(ov9655_mode); | ||
390 | dev_init_settings = ov9655_init_settings; | ||
391 | break; | ||
392 | } | ||
393 | |||
394 | dev_init_settings(gspca_dev); | ||
395 | if (AC50Hz != 0xff) | ||
396 | ((struct sd *) gspca_dev)->vcur.AC50Hz = AC50Hz; | ||
397 | gl860_build_control_table(gspca_dev); | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | /* This function is called at probe time after sd_config */ | ||
403 | static int sd_init(struct gspca_dev *gspca_dev) | ||
404 | { | ||
405 | struct sd *sd = (struct sd *) gspca_dev; | ||
406 | |||
407 | return sd->dev_init_at_startup(gspca_dev); | ||
408 | } | ||
409 | |||
410 | /* This function is called before to choose the alt setting */ | ||
411 | static int sd_isoc_init(struct gspca_dev *gspca_dev) | ||
412 | { | ||
413 | struct sd *sd = (struct sd *) gspca_dev; | ||
414 | |||
415 | return sd->dev_configure_alt(gspca_dev); | ||
416 | } | ||
417 | |||
418 | /* This function is called to start the webcam */ | ||
419 | static int sd_start(struct gspca_dev *gspca_dev) | ||
420 | { | ||
421 | struct sd *sd = (struct sd *) gspca_dev; | ||
422 | |||
423 | return sd->dev_init_pre_alt(gspca_dev); | ||
424 | } | ||
425 | |||
426 | /* This function is called to stop the webcam */ | ||
427 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
428 | { | ||
429 | struct sd *sd = (struct sd *) gspca_dev; | ||
430 | |||
431 | return sd->dev_post_unset_alt(gspca_dev); | ||
432 | } | ||
433 | |||
434 | /* This function is called when an image is being received */ | ||
435 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
436 | struct gspca_frame *frame, u8 *data, s32 len) | ||
437 | { | ||
438 | struct sd *sd = (struct sd *) gspca_dev; | ||
439 | static s32 nSkipped; | ||
440 | |||
441 | s32 mode = (s32) gspca_dev->curr_mode; | ||
442 | s32 nToSkip = | ||
443 | sd->swapRB * (gspca_dev->cam.cam_mode[mode].bytesperline + 1); | ||
444 | |||
445 | /* Test only against 0202h, so endianess does not matter */ | ||
446 | switch (*(s16 *) data) { | ||
447 | case 0x0202: /* End of frame, start a new one */ | ||
448 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); | ||
449 | nSkipped = 0; | ||
450 | if (sd->nbIm >= 0 && sd->nbIm < 10) | ||
451 | sd->nbIm++; | ||
452 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); | ||
453 | break; | ||
454 | |||
455 | default: | ||
456 | data += 2; | ||
457 | len -= 2; | ||
458 | if (nSkipped + len <= nToSkip) | ||
459 | nSkipped += len; | ||
460 | else { | ||
461 | if (nSkipped < nToSkip && nSkipped + len > nToSkip) { | ||
462 | data += nToSkip - nSkipped; | ||
463 | len -= nToSkip - nSkipped; | ||
464 | nSkipped = nToSkip + 1; | ||
465 | } | ||
466 | gspca_frame_add(gspca_dev, | ||
467 | INTER_PACKET, frame, data, len); | ||
468 | } | ||
469 | break; | ||
470 | } | ||
471 | } | ||
472 | |||
473 | /* This function is called when an image has been read */ | ||
474 | /* This function is used to monitor webcam orientation */ | ||
475 | static void sd_callback(struct gspca_dev *gspca_dev) | ||
476 | { | ||
477 | struct sd *sd = (struct sd *) gspca_dev; | ||
478 | |||
479 | if (!_OV9655_) { | ||
480 | u8 state; | ||
481 | u8 upsideDown; | ||
482 | |||
483 | /* Probe sensor orientation */ | ||
484 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, (void *)&state); | ||
485 | |||
486 | /* C8/40 means upside-down (looking backwards) */ | ||
487 | /* D8/50 means right-up (looking onwards) */ | ||
488 | upsideDown = (state == 0xc8 || state == 0x40); | ||
489 | |||
490 | if (upsideDown && sd->nbRightUp > -4) { | ||
491 | if (sd->nbRightUp > 0) | ||
492 | sd->nbRightUp = 0; | ||
493 | if (sd->nbRightUp == -3) { | ||
494 | sd->mirrorMask = 1; | ||
495 | sd->waitSet = 1; | ||
496 | } | ||
497 | sd->nbRightUp--; | ||
498 | } | ||
499 | if (!upsideDown && sd->nbRightUp < 4) { | ||
500 | if (sd->nbRightUp < 0) | ||
501 | sd->nbRightUp = 0; | ||
502 | if (sd->nbRightUp == 3) { | ||
503 | sd->mirrorMask = 0; | ||
504 | sd->waitSet = 1; | ||
505 | } | ||
506 | sd->nbRightUp++; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | if (sd->waitSet) | ||
511 | sd->dev_camera_settings(gspca_dev); | ||
512 | } | ||
513 | |||
514 | /*=================== USB driver structure initialisation ==================*/ | ||
515 | |||
516 | static const __devinitdata struct usb_device_id device_table[] = { | ||
517 | {USB_DEVICE(0x05e3, 0x0503)}, | ||
518 | {USB_DEVICE(0x05e3, 0xf191)}, | ||
519 | {} | ||
520 | }; | ||
521 | |||
522 | MODULE_DEVICE_TABLE(usb, device_table); | ||
523 | |||
524 | static int sd_probe(struct usb_interface *intf, | ||
525 | const struct usb_device_id *id) | ||
526 | { | ||
527 | struct gspca_dev *gspca_dev; | ||
528 | s32 ret; | ||
529 | |||
530 | ret = gspca_dev_probe(intf, id, | ||
531 | &sd_desc_mi1320, sizeof(struct sd), THIS_MODULE); | ||
532 | |||
533 | if (ret >= 0) { | ||
534 | gspca_dev = usb_get_intfdata(intf); | ||
535 | |||
536 | PDEBUG(D_PROBE, | ||
537 | "Camera is now controlling video device /dev/video%d", | ||
538 | gspca_dev->vdev.minor); | ||
539 | } | ||
540 | |||
541 | return ret; | ||
542 | } | ||
543 | |||
544 | static void sd_disconnect(struct usb_interface *intf) | ||
545 | { | ||
546 | gspca_disconnect(intf); | ||
547 | } | ||
548 | |||
549 | static struct usb_driver sd_driver = { | ||
550 | .name = MODULE_NAME, | ||
551 | .id_table = device_table, | ||
552 | .probe = sd_probe, | ||
553 | .disconnect = sd_disconnect, | ||
554 | #ifdef CONFIG_PM | ||
555 | .suspend = gspca_suspend, | ||
556 | .resume = gspca_resume, | ||
557 | #endif | ||
558 | }; | ||
559 | |||
560 | /*====================== Init and Exit module functions ====================*/ | ||
561 | |||
562 | static int __init sd_mod_init(void) | ||
563 | { | ||
564 | PDEBUG(D_PROBE, "driver startup - version %s", DRIVER_VERSION); | ||
565 | |||
566 | if (usb_register(&sd_driver) < 0) | ||
567 | return -1; | ||
568 | PDEBUG(D_PROBE, "driver registered"); | ||
569 | |||
570 | return 0; | ||
571 | } | ||
572 | |||
573 | static void __exit sd_mod_exit(void) | ||
574 | { | ||
575 | usb_deregister(&sd_driver); | ||
576 | PDEBUG(D_PROBE, "driver deregistered"); | ||
577 | } | ||
578 | |||
579 | module_init(sd_mod_init); | ||
580 | module_exit(sd_mod_exit); | ||
581 | |||
582 | /*==========================================================================*/ | ||
583 | |||
584 | int gl860_RTx(struct gspca_dev *gspca_dev, | ||
585 | unsigned char pref, u32 req, u16 val, u16 index, | ||
586 | s32 len, void *pdata) | ||
587 | { | ||
588 | struct usb_device *udev = gspca_dev->dev; | ||
589 | s32 r = 0; | ||
590 | |||
591 | if (pref == 0x40) { /* Send */ | ||
592 | if (len > 0) { | ||
593 | memcpy(gspca_dev->usb_buf, pdata, len); | ||
594 | r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
595 | req, pref, val, index, | ||
596 | gspca_dev->usb_buf, | ||
597 | len, 400 + 200 * (len > 1)); | ||
598 | } else { | ||
599 | r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
600 | req, pref, val, index, NULL, len, 400); | ||
601 | } | ||
602 | } else { /* Receive */ | ||
603 | if (len > 0) { | ||
604 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
605 | req, pref, val, index, | ||
606 | gspca_dev->usb_buf, | ||
607 | len, 400 + 200 * (len > 1)); | ||
608 | memcpy(pdata, gspca_dev->usb_buf, len); | ||
609 | } else { | ||
610 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
611 | req, pref, val, index, NULL, len, 400); | ||
612 | } | ||
613 | } | ||
614 | |||
615 | if (r < 0) | ||
616 | PDEBUG(D_ERR, | ||
617 | "ctrl transfer failed %4d " | ||
618 | "[p%02x r%d v%04x i%04x len%d]", | ||
619 | r, pref, req, val, index, len); | ||
620 | else if (len > 1 && r < len) | ||
621 | PDEBUG(D_ERR, "short ctrl transfer %d/%d", r, len); | ||
622 | |||
623 | if ((_MI2020_ || _MI2020b_ || _MI2020c_) && (val || index)) | ||
624 | msleep(1); | ||
625 | if (_OV2640_) | ||
626 | msleep(1); | ||
627 | |||
628 | return r; | ||
629 | } | ||
630 | |||
631 | int fetch_validx(struct gspca_dev *gspca_dev, struct validx *tbl, int len) | ||
632 | { | ||
633 | int n; | ||
634 | |||
635 | for (n = 0; n < len; n++) { | ||
636 | if (tbl[n].idx != 0xffff) | ||
637 | ctrl_out(gspca_dev, 0x40, 1, tbl[n].val, | ||
638 | tbl[n].idx, 0, NULL); | ||
639 | else if (tbl[n].val == 0xffff) | ||
640 | break; | ||
641 | else | ||
642 | msleep(tbl[n].val); | ||
643 | } | ||
644 | return n; | ||
645 | } | ||
646 | |||
647 | int keep_on_fetching_validx(struct gspca_dev *gspca_dev, struct validx *tbl, | ||
648 | int len, int n) | ||
649 | { | ||
650 | while (++n < len) { | ||
651 | if (tbl[n].idx != 0xffff) | ||
652 | ctrl_out(gspca_dev, 0x40, 1, tbl[n].val, tbl[n].idx, | ||
653 | 0, NULL); | ||
654 | else if (tbl[n].val == 0xffff) | ||
655 | break; | ||
656 | else | ||
657 | msleep(tbl[n].val); | ||
658 | } | ||
659 | return n; | ||
660 | } | ||
661 | |||
662 | void fetch_idxdata(struct gspca_dev *gspca_dev, struct idxdata *tbl, int len) | ||
663 | { | ||
664 | int n; | ||
665 | |||
666 | for (n = 0; n < len; n++) { | ||
667 | if (memcmp(tbl[n].data, "\xff\xff\xff", 3) != 0) | ||
668 | ctrl_out(gspca_dev, 0x40, 3, 0x7a00, tbl[n].idx, | ||
669 | 3, tbl[n].data); | ||
670 | else | ||
671 | msleep(tbl[n].idx); | ||
672 | } | ||
673 | } | ||
674 | |||
675 | static int gl860_guess_sensor(struct gspca_dev *gspca_dev, | ||
676 | s32 vendor_id, s32 product_id) | ||
677 | { | ||
678 | struct sd *sd = (struct sd *) gspca_dev; | ||
679 | u8 probe, nb26, nb96, nOV, ntry; | ||
680 | |||
681 | if (product_id == 0xf191) | ||
682 | sd->sensor = ID_MI1320; | ||
683 | |||
684 | if (sd->sensor == 0xff) { | ||
685 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &probe); | ||
686 | ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &probe); | ||
687 | |||
688 | ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x0000, 0, NULL); | ||
689 | msleep(3); | ||
690 | ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL); | ||
691 | msleep(3); | ||
692 | ctrl_out(gspca_dev, 0x40, 1, 0x0008, 0x00c0, 0, NULL); | ||
693 | msleep(3); | ||
694 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x00c1, 0, NULL); | ||
695 | msleep(3); | ||
696 | ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x00c2, 0, NULL); | ||
697 | msleep(3); | ||
698 | ctrl_out(gspca_dev, 0x40, 1, 0x0020, 0x0006, 0, NULL); | ||
699 | msleep(3); | ||
700 | ctrl_out(gspca_dev, 0x40, 1, 0x006a, 0x000d, 0, NULL); | ||
701 | msleep(56); | ||
702 | |||
703 | nOV = 0; | ||
704 | for (ntry = 0; ntry < 4; ntry++) { | ||
705 | ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL); | ||
706 | msleep(3); | ||
707 | ctrl_out(gspca_dev, 0x40, 1, 0x0063, 0x0006, 0, NULL); | ||
708 | msleep(3); | ||
709 | ctrl_out(gspca_dev, 0x40, 1, 0x7a00, 0x8030, 0, NULL); | ||
710 | msleep(10); | ||
711 | ctrl_in(gspca_dev, 0xc0, 2, 0x7a00, 0x8030, 1, &probe); | ||
712 | PDEBUG(D_PROBE, "1st probe=%02x", probe); | ||
713 | if (probe == 0xff) | ||
714 | nOV++; | ||
715 | } | ||
716 | |||
717 | if (nOV) { | ||
718 | PDEBUG(D_PROBE, "0xff -> sensor OVXXXX"); | ||
719 | PDEBUG(D_PROBE, "Probing for sensor OV2640 or OV9655"); | ||
720 | |||
721 | nb26 = nb96 = 0; | ||
722 | for (ntry = 0; ntry < 4; ntry++) { | ||
723 | ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, | ||
724 | 0, NULL); | ||
725 | msleep(3); | ||
726 | ctrl_out(gspca_dev, 0x40, 1, 0x6000, 0x800a, | ||
727 | 0, NULL); | ||
728 | msleep(10); | ||
729 | /* Wait for 26(OV2640) or 96(OV9655) */ | ||
730 | ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x800a, | ||
731 | 1, &probe); | ||
732 | |||
733 | PDEBUG(D_PROBE, "2nd probe=%02x", probe); | ||
734 | if (probe == 0x00) | ||
735 | nb26++; | ||
736 | if (probe == 0x26 || probe == 0x40) { | ||
737 | sd->sensor = ID_OV2640; | ||
738 | nb26 += 4; | ||
739 | break; | ||
740 | } | ||
741 | if (probe == 0x96 || probe == 0x55) { | ||
742 | sd->sensor = ID_OV9655; | ||
743 | nb96 += 4; | ||
744 | break; | ||
745 | } | ||
746 | if (probe == 0xff) | ||
747 | nb96++; | ||
748 | msleep(3); | ||
749 | } | ||
750 | if (nb26 < 4 && nb96 < 4) { | ||
751 | PDEBUG(D_PROBE, "No relevant answer "); | ||
752 | PDEBUG(D_PROBE, "* 1.3Mpixels -> use OV9655"); | ||
753 | PDEBUG(D_PROBE, "* 2.0Mpixels -> use OV2640"); | ||
754 | PDEBUG(D_PROBE, | ||
755 | "To force a sensor, add that line to " | ||
756 | "/etc/modprobe.d/options.conf:"); | ||
757 | PDEBUG(D_PROBE, "options gspca_gl860 " | ||
758 | "sensor=\"OV2640\" or \"OV9655\""); | ||
759 | return -1; | ||
760 | } | ||
761 | } else { /* probe = 0 */ | ||
762 | PDEBUG(D_PROBE, "No 0xff -> sensor MI2020"); | ||
763 | sd->sensor = ID_MI2020; | ||
764 | } | ||
765 | } | ||
766 | |||
767 | if (_MI1320_) { | ||
768 | PDEBUG(D_PROBE, "05e3:f191 sensor MI1320 (1.3M)"); | ||
769 | } else if (_MI2020_) { | ||
770 | PDEBUG(D_PROBE, "05e3:0503 sensor MI2020 (2.0M)"); | ||
771 | } else if (_MI2020b_) { | ||
772 | PDEBUG(D_PROBE, "05e3:0503 sensor MI2020 alt. driver (2.0M)"); | ||
773 | } else if (_OV9655_) { | ||
774 | PDEBUG(D_PROBE, "05e3:0503 sensor OV9655 (1.3M)"); | ||
775 | } else if (_OV2640_) { | ||
776 | PDEBUG(D_PROBE, "05e3:0503 sensor OV2640 (2.0M)"); | ||
777 | } else { | ||
778 | PDEBUG(D_PROBE, "***** Unknown sensor *****"); | ||
779 | return -1; | ||
780 | } | ||
781 | |||
782 | return 0; | ||
783 | } | ||
diff --git a/drivers/media/video/gspca/gl860/gl860.h b/drivers/media/video/gspca/gl860/gl860.h new file mode 100644 index 000000000000..cef4e24c1e61 --- /dev/null +++ b/drivers/media/video/gspca/gl860/gl860.h | |||
@@ -0,0 +1,108 @@ | |||
1 | /* @file gl860.h | ||
2 | * @author Olivier LORIN, tiré du pilote Syntek par Nicolas VIVIEN | ||
3 | * @date 2009-08-27 | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | #ifndef GL860_DEV_H | ||
19 | #define GL860_DEV_H | ||
20 | #include <linux/version.h> | ||
21 | |||
22 | #include "gspca.h" | ||
23 | |||
24 | #define MODULE_NAME "gspca_gl860" | ||
25 | #define DRIVER_VERSION "0.9d10" | ||
26 | |||
27 | #define ctrl_in gl860_RTx | ||
28 | #define ctrl_out gl860_RTx | ||
29 | |||
30 | #define ID_MI1320 1 | ||
31 | #define ID_OV2640 2 | ||
32 | #define ID_OV9655 4 | ||
33 | #define ID_MI2020 8 | ||
34 | #define ID_MI2020b 16 | ||
35 | |||
36 | #define _MI1320_ (((struct sd *) gspca_dev)->sensor == ID_MI1320) | ||
37 | #define _MI2020_ (((struct sd *) gspca_dev)->sensor == ID_MI2020) | ||
38 | #define _MI2020b_ (((struct sd *) gspca_dev)->sensor == ID_MI2020b) | ||
39 | #define _MI2020c_ 0 | ||
40 | #define _OV2640_ (((struct sd *) gspca_dev)->sensor == ID_OV2640) | ||
41 | #define _OV9655_ (((struct sd *) gspca_dev)->sensor == ID_OV9655) | ||
42 | |||
43 | #define IMAGE_640 0 | ||
44 | #define IMAGE_800 1 | ||
45 | #define IMAGE_1280 2 | ||
46 | #define IMAGE_1600 3 | ||
47 | |||
48 | struct sd_gl860 { | ||
49 | u16 backlight; | ||
50 | u16 brightness; | ||
51 | u16 sharpness; | ||
52 | u16 contrast; | ||
53 | u16 gamma; | ||
54 | u16 hue; | ||
55 | u16 saturation; | ||
56 | u16 whitebal; | ||
57 | u8 mirror; | ||
58 | u8 flip; | ||
59 | u8 AC50Hz; | ||
60 | }; | ||
61 | |||
62 | /* Specific webcam descriptor */ | ||
63 | struct sd { | ||
64 | struct gspca_dev gspca_dev; /* !! must be the first item */ | ||
65 | |||
66 | struct sd_gl860 vcur; | ||
67 | struct sd_gl860 vold; | ||
68 | struct sd_gl860 vmax; | ||
69 | |||
70 | int (*dev_configure_alt) (struct gspca_dev *); | ||
71 | int (*dev_init_at_startup)(struct gspca_dev *); | ||
72 | int (*dev_init_pre_alt) (struct gspca_dev *); | ||
73 | void (*dev_post_unset_alt) (struct gspca_dev *); | ||
74 | int (*dev_camera_settings)(struct gspca_dev *); | ||
75 | |||
76 | u8 swapRB; | ||
77 | u8 mirrorMask; | ||
78 | u8 sensor; | ||
79 | s32 nbIm; | ||
80 | s32 nbRightUp; | ||
81 | u8 waitSet; | ||
82 | }; | ||
83 | |||
84 | struct validx { | ||
85 | u16 val; | ||
86 | u16 idx; | ||
87 | }; | ||
88 | |||
89 | struct idxdata { | ||
90 | u8 idx; | ||
91 | u8 data[3]; | ||
92 | }; | ||
93 | |||
94 | int fetch_validx(struct gspca_dev *gspca_dev, struct validx *tbl, int len); | ||
95 | int keep_on_fetching_validx(struct gspca_dev *gspca_dev, struct validx *tbl, | ||
96 | int len, int n); | ||
97 | void fetch_idxdata(struct gspca_dev *gspca_dev, struct idxdata *tbl, int len); | ||
98 | |||
99 | int gl860_RTx(struct gspca_dev *gspca_dev, | ||
100 | unsigned char pref, u32 req, u16 val, u16 index, | ||
101 | s32 len, void *pdata); | ||
102 | |||
103 | void mi1320_init_settings(struct gspca_dev *); | ||
104 | void ov2640_init_settings(struct gspca_dev *); | ||
105 | void ov9655_init_settings(struct gspca_dev *); | ||
106 | void mi2020_init_settings(struct gspca_dev *); | ||
107 | |||
108 | #endif | ||