aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/gl860/gl860-mi2020.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/gl860/gl860-mi2020.c')
-rw-r--r--drivers/media/video/gspca/gl860/gl860-mi2020.c731
1 files changed, 264 insertions, 467 deletions
diff --git a/drivers/media/video/gspca/gl860/gl860-mi2020.c b/drivers/media/video/gspca/gl860/gl860-mi2020.c
index 7c31b4f2abea..57782e011c9e 100644
--- a/drivers/media/video/gspca/gl860/gl860-mi2020.c
+++ b/drivers/media/video/gspca/gl860/gl860-mi2020.c
@@ -1,6 +1,7 @@
1/* Subdriver for the GL860 chip with the MI2020 sensor 1/* Subdriver for the GL860 chip with the MI2020 sensor
2 * Author Olivier LORIN, from Ice/Soro2005's logs(A), Fret_saw/Hulkie's 2 * Author Olivier LORIN, from logs by Iceman/Soro2005 + Fret_saw/Hulkie/Tricid
3 * logs(B) and Tricid"s logs(C). With the help of Kytrix/BUGabundo/Blazercist. 3 * with the help of Kytrix/BUGabundo/Blazercist.
4 * Driver achieved thanks to a webcam gift by Kytrix.
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify 6 * 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 * it under the terms of the GNU General Public License as published by
@@ -20,47 +21,70 @@
20 21
21#include "gl860.h" 22#include "gl860.h"
22 23
24static u8 dat_wbal1[] = {0x8c, 0xa2, 0x0c};
25
23static u8 dat_bright1[] = {0x8c, 0xa2, 0x06}; 26static u8 dat_bright1[] = {0x8c, 0xa2, 0x06};
24static u8 dat_bright3[] = {0x8c, 0xa1, 0x02}; 27static u8 dat_bright3[] = {0x8c, 0xa1, 0x02};
25static u8 dat_bright4[] = {0x90, 0x00, 0x0f}; 28static u8 dat_bright4[] = {0x90, 0x00, 0x0f};
26static u8 dat_bright5[] = {0x8c, 0xa1, 0x03}; 29static u8 dat_bright5[] = {0x8c, 0xa1, 0x03};
27static u8 dat_bright6[] = {0x90, 0x00, 0x05}; 30static u8 dat_bright6[] = {0x90, 0x00, 0x05};
28 31
29static u8 dat_dummy1[] = {0x90, 0x00, 0x06};
30/*static u8 dummy2[] = {0x8c, 0xa1, 0x02};*/
31/*static u8 dummy3[] = {0x90, 0x00, 0x1f};*/
32
33static u8 dat_hvflip1[] = {0x8c, 0x27, 0x19}; 32static u8 dat_hvflip1[] = {0x8c, 0x27, 0x19};
34static u8 dat_hvflip3[] = {0x8c, 0x27, 0x3b}; 33static u8 dat_hvflip3[] = {0x8c, 0x27, 0x3b};
35static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03}; 34static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03};
36static u8 dat_hvflip6[] = {0x90, 0x00, 0x06}; 35static u8 dat_hvflip6[] = {0x90, 0x00, 0x06};
37 36
37static struct idxdata tbl_middle_hvflip_low[] = {
38 {0x33, "\x90\x00\x06"},
39 {6, "\xff\xff\xff"},
40 {0x33, "\x90\x00\x06"},
41 {6, "\xff\xff\xff"},
42 {0x33, "\x90\x00\x06"},
43 {6, "\xff\xff\xff"},
44 {0x33, "\x90\x00\x06"},
45 {6, "\xff\xff\xff"},
46};
47
48static struct idxdata tbl_middle_hvflip_big[] = {
49 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa1\x20"},
50 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
51 {102, "\xff\xff\xff"},
52 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x20"},
53 {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
54};
55
56static struct idxdata tbl_end_hvflip[] = {
57 {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
58 {6, "\xff\xff\xff"},
59 {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
60 {6, "\xff\xff\xff"},
61 {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
62 {6, "\xff\xff\xff"},
63 {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
64};
65
38static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 }; 66static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 };
39 67
40static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 }; 68static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 };
41static u8 dat_multi6[] = { 0x90, 0x00, 0x05 }; 69static u8 dat_multi6[] = { 0x90, 0x00, 0x05 };
42 70
43static struct validx tbl_common1[] = { 71static struct validx tbl_init_at_startup[] = {
44 {0x0000, 0x0000}, 72 {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001,0x00c1},
45 {1, 0xffff}, /* msleep(35); */ 73 {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d},
46 {0x006a, 0x0007}, {0x0063, 0x0006}, {0x006a, 0x000d}, {0x0000, 0x00c0}, 74 {53, 0xffff},
47 {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, {0x0004, 0x00d8}, 75 {0x0040, 0x0000}, {0x0063, 0x0006},
48 {0x0000, 0x0058}, {0x0002, 0x0004}, {0x0041, 0x0000},
49}; 76};
50 77
51static struct validx tbl_common2[] = { 78static struct validx tbl_common_0B[] = {
52 {0x006a, 0x0007}, 79 {0x0002, 0x0004}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a,0x000d},
53 {35, 0xffff}, 80 {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042,0x00c2},
54 {0x00ef, 0x0006},
55 {35, 0xffff},
56 {0x006a, 0x000d},
57 {35, 0xffff},
58 {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2},
59 {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000}, 81 {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000},
60}; 82};
61 83
62static struct idxdata tbl_common3[] = { 84static struct idxdata tbl_common_3B[] = {
63 {0x32, "\x02\x00\x08"}, {0x33, "\xf4\x03\x1d"}, 85 {0x33, "\x86\x25\x01"}, {0x33, "\x86\x25\x00"},
86 {2, "\xff\xff\xff"},
87 {0x30, "\x1a\x0a\xcc"}, {0x32, "\x02\x00\x08"}, {0x33, "\xf4\x03\x1d"},
64 {6, "\xff\xff\xff"}, /* 12 */ 88 {6, "\xff\xff\xff"}, /* 12 */
65 {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, 89 {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
66 {2, "\xff\xff\xff"}, /* - */ 90 {2, "\xff\xff\xff"}, /* - */
@@ -98,85 +122,58 @@ static struct idxdata tbl_common3[] = {
98 {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"}, 122 {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
99 {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"}, 123 {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
100 {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"}, 124 {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"},
101 {1, "\xff\xff\xff"},
102 {0x33, "\x78\x00\x00"}, 125 {0x33, "\x78\x00\x00"},
103 {1, "\xff\xff\xff"}, 126 {2, "\xff\xff\xff"},
104 {0x35, "\xb8\x1f\x20"}, {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x10"}, 127 {0x35, "\xb8\x1f\x20"}, {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x10"},
105 {0x33, "\x8c\xa2\x07"}, {0x33, "\x90\x00\x08"}, {0x33, "\x8c\xa2\x42"}, 128 {0x33, "\x8c\xa2\x07"}, {0x33, "\x90\x00\x08"}, {0x33, "\x8c\xa2\x42"},
106 {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x4a"}, {0x33, "\x90\x00\x8c"}, 129 {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x4a"}, {0x33, "\x90\x00\x8c"},
107 {0x35, "\xba\xfa\x08"}, {0x33, "\x8c\xa2\x02"}, {0x33, "\x90\x00\x22"}, 130 {0x35, "\xba\xfa\x08"}, {0x33, "\x8c\xa2\x02"}, {0x33, "\x90\x00\x22"},
108 {0x33, "\x8c\xa2\x03"}, {0x33, "\x90\x00\xbb"}, 131 {0x33, "\x8c\xa2\x03"}, {0x33, "\x90\x00\xbb"}, {0x33, "\x8c\xa4\x04"},
109}; 132 {0x33, "\x90\x00\x80"}, {0x33, "\x8c\xa7\x9d"}, {0x33, "\x90\x00\x00"},
110 133 {0x33, "\x8c\xa7\x9e"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0c"},
111static struct idxdata tbl_common4[] = { 134 {0x33, "\x90\x00\x17"}, {0x33, "\x8c\xa2\x15"}, {0x33, "\x90\x00\x04"},
112 {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa0"}, {0x33, "\x8c\xa4\x08"}, 135 {0x33, "\x8c\xa2\x14"}, {0x33, "\x90\x00\x20"}, {0x33, "\x8c\xa1\x03"},
136 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, {0x33, "\x90\x21\x11"},
137 {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x25"},
138 {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x39"}, {0x33, "\x90\x21\x11"},
139 {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, {0x33, "\x8c\x27\x47"},
140 {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x02\x84"},
141 {0x33, "\x8c\x27\x05"}, {0x33, "\x90\x01\xe2"}, {0x33, "\x8c\x27\x07"},
142 {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x09"}, {0x33, "\x90\x04\xb0"},
143 {0x33, "\x8c\x27\x0d"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x0f"},
144 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x11"}, {0x33, "\x90\x04\xbd"},
145 {0x33, "\x8c\x27\x13"}, {0x33, "\x90\x06\x4d"}, {0x33, "\x8c\x27\x15"},
146 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, {0x33, "\x90\x21\x11"},
147 {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"}, {0x33, "\x8c\x27\x1b"},
148 {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x1d"}, {0x33, "\x90\x01\x02"},
149 {0x33, "\x8c\x27\x1f"}, {0x33, "\x90\x02\x79"}, {0x33, "\x8c\x27\x21"},
150 {0x33, "\x90\x01\x55"}, {0x33, "\x8c\x27\x23"}, {0x33, "\x90\x02\x85"},
151 {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x27"},
152 {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x29"}, {0x33, "\x90\x20\x20"},
153 {0x33, "\x8c\x27\x2b"}, {0x33, "\x90\x10\x20"}, {0x33, "\x8c\x27\x2d"},
154 {0x33, "\x90\x20\x07"}, {0x33, "\x8c\x27\x2f"}, {0x33, "\x90\x00\x04"},
155 {0x33, "\x8c\x27\x31"}, {0x33, "\x90\x00\x04"}, {0x33, "\x8c\x27\x33"},
156 {0x33, "\x90\x04\xbb"}, {0x33, "\x8c\x27\x35"}, {0x33, "\x90\x06\x4b"},
157 {0x33, "\x8c\x27\x37"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x39"},
158 {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3b"}, {0x33, "\x90\x00\x24"},
159 {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, {0x33, "\x8c\x27\x41"},
160 {0x33, "\x90\x01\x69"}, {0x33, "\x8c\x27\x45"}, {0x33, "\x90\x04\xed"},
161 {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x51"},
162 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x53"}, {0x33, "\x90\x03\x20"},
163 {0x33, "\x8c\x27\x55"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x57"},
164 {0x33, "\x90\x02\x58"}, {0x33, "\x8c\x27\x5f"}, {0x33, "\x90\x00\x00"},
165 {0x33, "\x8c\x27\x61"}, {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x63"},
166 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x65"}, {0x33, "\x90\x04\xb0"},
167 {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa1"}, {0x33, "\x8c\xa4\x08"},
113 {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x21"}, 168 {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x21"},
114 {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\xa4\x0b"}, 169 {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\xa4\x0b"},
115 {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\xa0"}, 170 {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\xa1"},
116 {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc0"}, {0x33, "\x8c\x24\x15"}, 171 {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc1"}, {0x33, "\x8c\x24\x15"},
117 {0x33, "\x90\x00\xa0"}, {0x33, "\x8c\x24\x17"}, {0x33, "\x90\x00\xc0"}, 172 {0x33, "\x90\x00\x6a"}, {0x33, "\x8c\x24\x17"}, {0x33, "\x90\x00\x80"},
118}; 173 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
119 174 {2, "\xff\xff\xff"},
120static struct idxdata tbl_common5[] = { 175 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
121 {0x33, "\x8c\xa4\x04"}, {0x33, "\x90\x00\x80"}, {0x33, "\x8c\xa7\x9d"}, 176 {3, "\xff\xff\xff"},
122 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa7\x9e"}, {0x33, "\x90\x00\x00"},
123 {0x33, "\x8c\xa2\x0c"}, {0x33, "\x90\x00\x17"}, {0x33, "\x8c\xa2\x15"},
124 {0x33, "\x90\x00\x04"}, {0x33, "\x8c\xa2\x14"}, {0x33, "\x90\x00\x20"},
125 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"},
126 /* msleep(53); */
127 {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"},
128 {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x39"},
129 {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"},
130 {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x03"},
131 {0x33, "\x90\x02\x84"}, {0x33, "\x8c\x27\x05"}, {0x33, "\x90\x01\xe2"},
132 {0x33, "\x8c\x27\x07"}, {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x09"},
133 {0x33, "\x90\x04\xb0"}, {0x33, "\x8c\x27\x0d"}, {0x33, "\x90\x00\x00"},
134 {0x33, "\x8c\x27\x0f"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x11"},
135 {0x33, "\x90\x04\xbd"}, {0x33, "\x8c\x27\x13"}, {0x33, "\x90\x06\x4d"},
136 {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"},
137 {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"},
138 {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x1d"},
139 {0x33, "\x90\x01\x02"}, {0x33, "\x8c\x27\x1f"}, {0x33, "\x90\x02\x79"},
140 {0x33, "\x8c\x27\x21"}, {0x33, "\x90\x01\x55"}, {0x33, "\x8c\x27\x23"},
141 {0x33, "\x90\x02\x85"}, {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"},
142 {0x33, "\x8c\x27\x27"}, {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x29"},
143 {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x2b"}, {0x33, "\x90\x10\x20"},
144 {0x33, "\x8c\x27\x2d"}, {0x33, "\x90\x20\x07"}, {0x33, "\x8c\x27\x2f"},
145 {0x33, "\x90\x00\x04"}, {0x33, "\x8c\x27\x31"}, {0x33, "\x90\x00\x04"},
146 {0x33, "\x8c\x27\x33"}, {0x33, "\x90\x04\xbb"}, {0x33, "\x8c\x27\x35"},
147 {0x33, "\x90\x06\x4b"}, {0x33, "\x8c\x27\x37"}, {0x33, "\x90\x00\x00"},
148 {0x33, "\x8c\x27\x39"}, {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3b"},
149 {0x33, "\x90\x00\x24"}, {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"},
150 {0x33, "\x8c\x27\x41"}, {0x33, "\x90\x01\x69"}, {0x33, "\x8c\x27\x45"},
151 {0x33, "\x90\x04\xed"}, {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"},
152 {0x33, "\x8c\x27\x51"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x53"},
153 {0x33, "\x90\x03\x20"}, {0x33, "\x8c\x27\x55"}, {0x33, "\x90\x00\x00"},
154 {0x33, "\x8c\x27\x57"}, {0x33, "\x90\x02\x58"}, {0x33, "\x8c\x27\x5f"},
155 {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x61"}, {0x33, "\x90\x06\x40"},
156 {0x33, "\x8c\x27\x63"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x65"},
157 {0x33, "\x90\x04\xb0"}, {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa1"},
158 {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"},
159 {0x33, "\x90\x00\x21"}, {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"},
160 {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"},
161 {0x33, "\x90\x00\xa1"}, {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc1"},
162 {0x33, "\x8c\x24\x15"},
163};
164
165static struct validx tbl_init_at_startup[] = {
166 {0x0000, 0x0000},
167 {53, 0xffff},
168 {0x0010, 0x0010},
169 {53, 0xffff},
170 {0x0008, 0x00c0},
171 {53, 0xffff},
172 {0x0001, 0x00c1},
173 {53, 0xffff},
174 {0x0001, 0x00c2},
175 {53, 0xffff},
176 {0x0020, 0x0006},
177 {53, 0xffff},
178 {0x006a, 0x000d},
179 {53, 0xffff},
180}; 177};
181 178
182static struct idxdata tbl_init_post_alt_low1[] = { 179static struct idxdata tbl_init_post_alt_low1[] = {
@@ -209,7 +206,7 @@ static struct idxdata tbl_init_post_alt_low3[] = {
209 {2, "\xff\xff\xff"}, 206 {2, "\xff\xff\xff"},
210 {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, 207 {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"},
211 {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"}, 208 {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
212 {2, "\xff\xff\xff"}, /* - * */ 209 {2, "\xff\xff\xff"},
213 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, 210 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
214 {2, "\xff\xff\xff"}, 211 {2, "\xff\xff\xff"},
215 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, 212 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
@@ -217,61 +214,15 @@ static struct idxdata tbl_init_post_alt_low3[] = {
217 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, 214 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
218 {2, "\xff\xff\xff"}, 215 {2, "\xff\xff\xff"},
219 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, 216 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
220 {1, "\xff\xff\xff"},
221};
222
223static struct idxdata tbl_init_post_alt_low4[] = {
224 {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
225 {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
226 {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
227 {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"},
228 {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"},
229 {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"},
230 {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"},
231 {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"},
232 {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"},
233 {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"},
234 {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"},
235 {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"},
236 {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"},
237 {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"},
238 {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"},
239 {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"},
240 {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"},
241 {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"},
242 {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"},
243 {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"},
244 {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"},
245 {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"},
246 {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"},
247 {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
248 {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
249 {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"},
250 /* Flip/Mirror h/v=1 */
251 {0x33, "\x90\x00\x3c"}, {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"},
252 {0x33, "\x8c\x27\x3b"}, {0x33, "\x90\x00\x24"}, {0x33, "\x8c\xa1\x03"},
253 {0x33, "\x90\x00\x06"},
254 {130, "\xff\xff\xff"},
255 {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"},
256 {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"},
257 {100, "\xff\xff\xff"},
258 /* ?? */
259 {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa1\x02"},
260 {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
261 {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
262 /* Brigthness=70 */
263 {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x46"}, {0x33, "\x8c\xa1\x02"},
264 {0x33, "\x90\x00\x0f"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
265 /* Sharpness=20 */
266 {0x32, "\x6c\x14\x08"},
267}; 217};
268 218
269static struct idxdata tbl_init_post_alt_big1[] = { 219static struct idxdata tbl_init_post_alt_big[] = {
270 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, 220 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
271 {2, "\xff\xff\xff"}, 221 {2, "\xff\xff\xff"},
272 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, 222 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
273 {2, "\xff\xff\xff"}, 223 {2, "\xff\xff\xff"},
274 {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, 224 {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
225 {2, "\xff\xff\xff"},
275 {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x03"}, 226 {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x03"},
276 {0x33, "\x90\x00\x05"}, 227 {0x33, "\x90\x00\x05"},
277 {2, "\xff\xff\xff"}, 228 {2, "\xff\xff\xff"},
@@ -285,9 +236,17 @@ static struct idxdata tbl_init_post_alt_big1[] = {
285 {0x33, "\x90\x00\x03"}, {0x33, "\x8c\xa1\x34"}, {0x33, "\x90\x00\x03"}, 236 {0x33, "\x90\x00\x03"}, {0x33, "\x8c\xa1\x34"}, {0x33, "\x90\x00\x03"},
286 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x2e\x01\x00"}, 237 {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x2e\x01\x00"},
287 {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, 238 {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
239 {0x33, "\x8c\x27\x97"}, {0x33, "\x90\x01\x00"},
240 {51, "\xff\xff\xff"},
241 {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"},
242 {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
243 {51, "\xff\xff\xff"},
244 {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"},
245 {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
246 {51, "\xff\xff\xff"},
288}; 247};
289 248
290static struct idxdata tbl_init_post_alt_big2[] = { 249static struct idxdata tbl_init_post_alt_3B[] = {
291 {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"}, 250 {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
292 {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"}, 251 {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
293 {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"}, 252 {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
@@ -316,17 +275,6 @@ static struct idxdata tbl_init_post_alt_big2[] = {
316 {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"}, 275 {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"},
317}; 276};
318 277
319static struct idxdata tbl_init_post_alt_big3[] = {
320 {0x33, "\x8c\xa1\x02"},
321 {0x33, "\x90\x00\x1f"},
322 {0x33, "\x8c\xa1\x02"},
323 {0x33, "\x90\x00\x1f"},
324 {0x33, "\x8c\xa1\x02"},
325 {0x33, "\x90\x00\x1f"},
326 {0x33, "\x8c\xa1\x02"},
327 {0x33, "\x90\x00\x1f"},
328};
329
330static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81"; 278static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81";
331static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21"; 279static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21";
332static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01"; 280static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01";
@@ -351,7 +299,7 @@ void mi2020_init_settings(struct gspca_dev *gspca_dev)
351 sd->vcur.gamma = 0; 299 sd->vcur.gamma = 0;
352 sd->vcur.hue = 0; 300 sd->vcur.hue = 0;
353 sd->vcur.saturation = 60; 301 sd->vcur.saturation = 60;
354 sd->vcur.whitebal = 50; 302 sd->vcur.whitebal = 0; /* 50, not done by hardware */
355 sd->vcur.mirror = 0; 303 sd->vcur.mirror = 0;
356 sd->vcur.flip = 0; 304 sd->vcur.flip = 0;
357 sd->vcur.AC50Hz = 1; 305 sd->vcur.AC50Hz = 1;
@@ -361,17 +309,12 @@ void mi2020_init_settings(struct gspca_dev *gspca_dev)
361 sd->vmax.sharpness = 40; 309 sd->vmax.sharpness = 40;
362 sd->vmax.contrast = 3; 310 sd->vmax.contrast = 3;
363 sd->vmax.gamma = 2; 311 sd->vmax.gamma = 2;
364 sd->vmax.hue = 0 + 1; /* 200 */ 312 sd->vmax.hue = 0 + 1; /* 200, not done by hardware */
365 sd->vmax.saturation = 0; /* 100 */ 313 sd->vmax.saturation = 0; /* 100, not done by hardware */
366 sd->vmax.whitebal = 0; /* 100 */ 314 sd->vmax.whitebal = 2; /* 100, not done by hardware */
367 sd->vmax.mirror = 1; 315 sd->vmax.mirror = 1;
368 sd->vmax.flip = 1; 316 sd->vmax.flip = 1;
369 sd->vmax.AC50Hz = 1; 317 sd->vmax.AC50Hz = 1;
370 if (_MI2020b_) {
371 sd->vmax.contrast = 0;
372 sd->vmax.gamma = 0;
373 sd->vmax.backlight = 0;
374 }
375 318
376 sd->dev_camera_settings = mi2020_camera_settings; 319 sd->dev_camera_settings = mi2020_camera_settings;
377 sd->dev_init_at_startup = mi2020_init_at_startup; 320 sd->dev_init_at_startup = mi2020_init_at_startup;
@@ -384,51 +327,9 @@ void mi2020_init_settings(struct gspca_dev *gspca_dev)
384 327
385static void common(struct gspca_dev *gspca_dev) 328static void common(struct gspca_dev *gspca_dev)
386{ 329{
387 s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 330 fetch_validx(gspca_dev, tbl_common_0B, ARRAY_SIZE(tbl_common_0B));
388 331 fetch_idxdata(gspca_dev, tbl_common_3B, ARRAY_SIZE(tbl_common_3B));
389 if (_MI2020b_) { 332 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL);
390 fetch_validx(gspca_dev, tbl_common1, ARRAY_SIZE(tbl_common1));
391 } else {
392 if (_MI2020_)
393 ctrl_out(gspca_dev, 0x40, 1, 0x0008, 0x0004, 0, NULL);
394 else
395 ctrl_out(gspca_dev, 0x40, 1, 0x0002, 0x0004, 0, NULL);
396 msleep(35);
397 fetch_validx(gspca_dev, tbl_common2, ARRAY_SIZE(tbl_common2));
398 }
399 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x86\x25\x01");
400 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x86\x25\x00");
401 msleep(2); /* - * */
402 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0030, 3, "\x1a\x0a\xcc");
403 if (reso == IMAGE_1600)
404 msleep(2); /* 1600 */
405 fetch_idxdata(gspca_dev, tbl_common3, ARRAY_SIZE(tbl_common3));
406
407 if (_MI2020b_ || _MI2020_)
408 fetch_idxdata(gspca_dev, tbl_common4,
409 ARRAY_SIZE(tbl_common4));
410
411 fetch_idxdata(gspca_dev, tbl_common5, ARRAY_SIZE(tbl_common5));
412 if (_MI2020b_ || _MI2020_) {
413 /* Different from fret */
414 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x78");
415 /* Same as fret */
416 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x24\x17");
417 /* Different from fret */
418 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x90");
419 } else {
420 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x6a");
421 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x24\x17");
422 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x80");
423 }
424 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
425 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x05");
426 msleep(2);
427 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
428 if (reso == IMAGE_1600)
429 msleep(14); /* 1600 */
430 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x06");
431 msleep(2);
432} 333}
433 334
434static int mi2020_init_at_startup(struct gspca_dev *gspca_dev) 335static int mi2020_init_at_startup(struct gspca_dev *gspca_dev)
@@ -441,8 +342,16 @@ static int mi2020_init_at_startup(struct gspca_dev *gspca_dev)
441 fetch_validx(gspca_dev, tbl_init_at_startup, 342 fetch_validx(gspca_dev, tbl_init_at_startup,
442 ARRAY_SIZE(tbl_init_at_startup)); 343 ARRAY_SIZE(tbl_init_at_startup));
443 344
345 ctrl_out(gspca_dev, 0x40, 1, 0x7a00, 0x8030, 0, NULL);
346 ctrl_in(gspca_dev, 0xc0, 2, 0x7a00, 0x8030, 1, &c);
347
444 common(gspca_dev); 348 common(gspca_dev);
445 349
350 msleep(61);
351/* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */
352/* msleep(36); */
353 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL);
354
446 return 0; 355 return 0;
447} 356}
448 357
@@ -450,17 +359,17 @@ static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev)
450{ 359{
451 struct sd *sd = (struct sd *) gspca_dev; 360 struct sd *sd = (struct sd *) gspca_dev;
452 361
453 sd->mirrorMask = 0; 362 sd->mirrorMask = 0;
363 sd->vold.hue = -1;
454 364
455 sd->vold.backlight = -1; 365 /* These controls need to be reset */
456 sd->vold.brightness = -1; 366 sd->vold.brightness = -1;
457 sd->vold.sharpness = -1; 367 sd->vold.sharpness = -1;
458 sd->vold.contrast = -1; 368
459 sd->vold.gamma = -1; 369 /* If not different from default, they do not need to be set */
460 sd->vold.hue = -1; 370 sd->vold.contrast = 0;
461 sd->vold.mirror = -1; 371 sd->vold.gamma = 0;
462 sd->vold.flip = -1; 372 sd->vold.backlight = 0;
463 sd->vold.AC50Hz = -1;
464 373
465 mi2020_init_post_alt(gspca_dev); 374 mi2020_init_post_alt(gspca_dev);
466 375
@@ -472,10 +381,10 @@ static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
472 struct sd *sd = (struct sd *) gspca_dev; 381 struct sd *sd = (struct sd *) gspca_dev;
473 s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv; 382 s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
474 383
475 s32 backlight = sd->vcur.backlight;
476 s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); 384 s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
477 s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); 385 s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
478 s32 freq = (sd->vcur.AC50Hz > 0); 386 s32 freq = (sd->vcur.AC50Hz > 0);
387 s32 wbal = sd->vcur.whitebal;
479 388
480 u8 dat_freq2[] = {0x90, 0x00, 0x80}; 389 u8 dat_freq2[] = {0x90, 0x00, 0x80};
481 u8 dat_multi1[] = {0x8c, 0xa7, 0x00}; 390 u8 dat_multi1[] = {0x8c, 0xa7, 0x00};
@@ -484,6 +393,7 @@ static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
484 u8 dat_multi4[] = {0x90, 0x00, 0x00}; 393 u8 dat_multi4[] = {0x90, 0x00, 0x00};
485 u8 dat_hvflip2[] = {0x90, 0x04, 0x6c}; 394 u8 dat_hvflip2[] = {0x90, 0x04, 0x6c};
486 u8 dat_hvflip4[] = {0x90, 0x00, 0x24}; 395 u8 dat_hvflip4[] = {0x90, 0x00, 0x24};
396 u8 dat_wbal2[] = {0x90, 0x00, 0x00};
487 u8 c; 397 u8 c;
488 398
489 sd->nbIm = -1; 399 sd->nbIm = -1;
@@ -491,23 +401,26 @@ static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
491 dat_freq2[2] = freq ? 0xc0 : 0x80; 401 dat_freq2[2] = freq ? 0xc0 : 0x80;
492 dat_multi1[2] = 0x9d; 402 dat_multi1[2] = 0x9d;
493 dat_multi3[2] = dat_multi1[2] + 1; 403 dat_multi3[2] = dat_multi1[2] + 1;
494 dat_multi4[2] = dat_multi2[2] = backlight; 404 if (wbal == 0) {
405 dat_multi4[2] = dat_multi2[2] = 0;
406 dat_wbal2[2] = 0x17;
407 } else if (wbal == 1) {
408 dat_multi4[2] = dat_multi2[2] = 0;
409 dat_wbal2[2] = 0x35;
410 } else if (wbal == 2) {
411 dat_multi4[2] = dat_multi2[2] = 0x20;
412 dat_wbal2[2] = 0x17;
413 }
495 dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror); 414 dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror);
496 dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror); 415 dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror);
497 416
498 msleep(200); 417 msleep(200);
499
500 ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL); 418 ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL);
501 msleep(3); /* 35 * */ 419 msleep(2);
502 420
503 common(gspca_dev); 421 common(gspca_dev);
504 422
505 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL); 423 msleep(142);
506 msleep(70);
507
508 if (_MI2020b_)
509 ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
510
511 ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL); 424 ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
512 ctrl_out(gspca_dev, 0x40, 1, 0x0003, 0x00c1, 0, NULL); 425 ctrl_out(gspca_dev, 0x40, 1, 0x0003, 0x00c1, 0, NULL);
513 ctrl_out(gspca_dev, 0x40, 1, 0x0042, 0x00c2, 0, NULL); 426 ctrl_out(gspca_dev, 0x40, 1, 0x0042, 0x00c2, 0, NULL);
@@ -523,8 +436,7 @@ static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
523 ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200, 436 ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
524 12, dat_800); 437 12, dat_800);
525 438
526 if (_MI2020c_) 439 fetch_idxdata(gspca_dev, tbl_init_post_alt_low1,
527 fetch_idxdata(gspca_dev, tbl_init_post_alt_low1,
528 ARRAY_SIZE(tbl_init_post_alt_low1)); 440 ARRAY_SIZE(tbl_init_post_alt_low1));
529 441
530 if (reso == IMAGE_800) 442 if (reso == IMAGE_800)
@@ -534,87 +446,10 @@ static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
534 fetch_idxdata(gspca_dev, tbl_init_post_alt_low3, 446 fetch_idxdata(gspca_dev, tbl_init_post_alt_low3,
535 ARRAY_SIZE(tbl_init_post_alt_low3)); 447 ARRAY_SIZE(tbl_init_post_alt_low3));
536 448
537 if (_MI2020b_) { 449 ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
538 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL); 450 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
539 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL); 451 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
540 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL); 452 msleep(120);
541 msleep(150);
542 } else if (_MI2020c_) {
543 ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
544 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
545 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
546 msleep(120);
547 ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
548 msleep(30);
549 } else if (_MI2020_) {
550 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
551 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
552 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
553 msleep(120);
554 ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
555 msleep(30);
556 }
557
558 /* AC power frequency */
559 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
560 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
561 msleep(20);
562 /* backlight */
563 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
564 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
565 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
566 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
567 /* at init time but not after */
568 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa2\x0c");
569 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x17");
570 /* finish the backlight */
571 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
572 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
573 msleep(5);/* " */
574
575 if (_MI2020c_) {
576 fetch_idxdata(gspca_dev, tbl_init_post_alt_low4,
577 ARRAY_SIZE(tbl_init_post_alt_low4));
578 } else {
579 ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c);
580 msleep(14); /* 0xd8 */
581
582 /* flip/mirror */
583 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
584 3, dat_hvflip1);
585 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
586 3, dat_hvflip2);
587 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
588 3, dat_hvflip3);
589 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
590 3, dat_hvflip4);
591 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
592 3, dat_hvflip5);
593 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
594 3, dat_hvflip6);
595 msleep(21);
596 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
597 3, dat_dummy1);
598 msleep(5);
599 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
600 3, dat_dummy1);
601 msleep(5);
602 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
603 3, dat_dummy1);
604 msleep(5);
605 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
606 3, dat_dummy1);
607 msleep(5);
608 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
609 3, dat_dummy1);
610 msleep(5);
611 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
612 3, dat_dummy1);
613 /* end of flip/mirror main part */
614 msleep(246); /* 146 */
615
616 sd->nbIm = 0;
617 }
618 break; 453 break;
619 454
620 case IMAGE_1280: 455 case IMAGE_1280:
@@ -643,108 +478,62 @@ static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
643 3, "\x90\x04\xb0"); 478 3, "\x90\x04\xb0");
644 } 479 }
645 480
646 fetch_idxdata(gspca_dev, tbl_init_post_alt_big1, 481 fetch_idxdata(gspca_dev, tbl_init_post_alt_big,
647 ARRAY_SIZE(tbl_init_post_alt_big1)); 482 ARRAY_SIZE(tbl_init_post_alt_big));
648
649 if (reso == IMAGE_1600)
650 msleep(13); /* 1600 */
651 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x27\x97");
652 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x01\x00");
653 msleep(53);
654 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
655 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
656 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
657 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
658 if (reso == IMAGE_1600)
659 msleep(13); /* 1600 */
660 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
661 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
662 msleep(53);
663 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
664 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x72");
665 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
666 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x02");
667 if (reso == IMAGE_1600)
668 msleep(13); /* 1600 */
669 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
670 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
671 msleep(53);
672
673 if (_MI2020b_) {
674 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
675 if (reso == IMAGE_1600)
676 msleep(500); /* 1600 */
677 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
678 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
679 msleep(1850);
680 } else if (_MI2020c_ || _MI2020_) {
681 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
682 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
683 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
684 msleep(1850);
685 ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
686 msleep(30);
687 }
688 483
689 /* AC power frequency */ 484 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
690 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1); 485 ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
691 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2); 486 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
692 msleep(20); 487 msleep(1850);
693 /* backlight */ 488 }
694 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
695 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
696 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
697 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
698 /* at init time but not after */
699 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa2\x0c");
700 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x17");
701 /* finish the backlight */
702 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
703 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
704 msleep(6); /* " */
705 489
706 ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c); 490 ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
707 msleep(14); 491 msleep(40);
492
493 /* AC power frequency */
494 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
495 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
496 msleep(33);
497 /* light source */
498 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
499 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
500 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
501 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
502 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal1);
503 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal2);
504 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
505 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
506 msleep(7);
507 ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c);
508
509 fetch_idxdata(gspca_dev, tbl_init_post_alt_3B,
510 ARRAY_SIZE(tbl_init_post_alt_3B));
511
512 /* hvflip */
513 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
514 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
515 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
516 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
517 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
518 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
519 msleep(250);
520
521 if (reso == IMAGE_640 || reso == IMAGE_800)
522 fetch_idxdata(gspca_dev, tbl_middle_hvflip_low,
523 ARRAY_SIZE(tbl_middle_hvflip_low));
524 else
525 fetch_idxdata(gspca_dev, tbl_middle_hvflip_big,
526 ARRAY_SIZE(tbl_middle_hvflip_big));
708 527
709 if (_MI2020c_) 528 fetch_idxdata(gspca_dev, tbl_end_hvflip,
710 fetch_idxdata(gspca_dev, tbl_init_post_alt_big2, 529 ARRAY_SIZE(tbl_end_hvflip));
711 ARRAY_SIZE(tbl_init_post_alt_big2));
712 530
713 /* flip/mirror */ 531 sd->nbIm = 0;
714 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
715 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
716 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
717 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
718 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
719 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
720 /* end of flip/mirror main part */
721 msleep(16);
722 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
723 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
724 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
725 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
726 if (reso == IMAGE_1600)
727 msleep(25); /* 1600 */
728 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
729 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
730 msleep(103);
731 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
732 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x02");
733 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
734 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x72");
735 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
736 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
737 sd->nbIm = 0;
738
739 if (_MI2020c_)
740 fetch_idxdata(gspca_dev, tbl_init_post_alt_big3,
741 ARRAY_SIZE(tbl_init_post_alt_big3));
742 }
743 532
744 sd->vold.mirror = mirror; 533 sd->vold.mirror = mirror;
745 sd->vold.flip = flip; 534 sd->vold.flip = flip;
746 sd->vold.AC50Hz = freq; 535 sd->vold.AC50Hz = freq;
747 sd->vold.backlight = backlight; 536 sd->vold.whitebal = wbal;
748 537
749 mi2020_camera_settings(gspca_dev); 538 mi2020_camera_settings(gspca_dev);
750 539
@@ -772,6 +561,7 @@ static int mi2020_configure_alt(struct gspca_dev *gspca_dev)
772static int mi2020_camera_settings(struct gspca_dev *gspca_dev) 561static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
773{ 562{
774 struct sd *sd = (struct sd *) gspca_dev; 563 struct sd *sd = (struct sd *) gspca_dev;
564 s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
775 565
776 s32 backlight = sd->vcur.backlight; 566 s32 backlight = sd->vcur.backlight;
777 s32 bright = sd->vcur.brightness; 567 s32 bright = sd->vcur.brightness;
@@ -782,6 +572,7 @@ static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
782 s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0); 572 s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
783 s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0); 573 s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
784 s32 freq = (sd->vcur.AC50Hz > 0); 574 s32 freq = (sd->vcur.AC50Hz > 0);
575 s32 wbal = sd->vcur.whitebal;
785 576
786 u8 dat_sharp[] = {0x6c, 0x00, 0x08}; 577 u8 dat_sharp[] = {0x6c, 0x00, 0x08};
787 u8 dat_bright2[] = {0x90, 0x00, 0x00}; 578 u8 dat_bright2[] = {0x90, 0x00, 0x00};
@@ -792,6 +583,7 @@ static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
792 u8 dat_multi4[] = {0x90, 0x00, 0x00}; 583 u8 dat_multi4[] = {0x90, 0x00, 0x00};
793 u8 dat_hvflip2[] = {0x90, 0x04, 0x6c}; 584 u8 dat_hvflip2[] = {0x90, 0x04, 0x6c};
794 u8 dat_hvflip4[] = {0x90, 0x00, 0x24}; 585 u8 dat_hvflip4[] = {0x90, 0x00, 0x24};
586 u8 dat_wbal2[] = {0x90, 0x00, 0x00};
795 587
796 /* Less than 4 images received -> too early to set the settings */ 588 /* Less than 4 images received -> too early to set the settings */
797 if (sd->nbIm < 4) { 589 if (sd->nbIm < 4) {
@@ -809,67 +601,89 @@ static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
809 msleep(20); 601 msleep(20);
810 } 602 }
811 603
604 if (wbal != sd->vold.whitebal) {
605 sd->vold.whitebal = wbal;
606 if (wbal < 0 || wbal > sd->vmax.whitebal)
607 wbal = 0;
608
609 dat_multi1[2] = 0x9d;
610 dat_multi3[2] = dat_multi1[2] + 1;
611 if (wbal == 0) {
612 dat_multi4[2] = dat_multi2[2] = 0;
613 dat_wbal2[2] = 0x17;
614 } else if (wbal == 1) {
615 dat_multi4[2] = dat_multi2[2] = 0;
616 dat_wbal2[2] = 0x35;
617 } else if (wbal == 2) {
618 dat_multi4[2] = dat_multi2[2] = 0x20;
619 dat_wbal2[2] = 0x17;
620 }
621 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
622 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
623 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
624 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
625 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal1);
626 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal2);
627 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
628 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
629 }
630
812 if (mirror != sd->vold.mirror || flip != sd->vold.flip) { 631 if (mirror != sd->vold.mirror || flip != sd->vold.flip) {
813 sd->vold.mirror = mirror; 632 sd->vold.mirror = mirror;
814 sd->vold.flip = flip; 633 sd->vold.flip = flip;
815 634
816 dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror); 635 dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror);
817 dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror); 636 dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror);
637
638 fetch_idxdata(gspca_dev, tbl_init_post_alt_3B,
639 ARRAY_SIZE(tbl_init_post_alt_3B));
640
818 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1); 641 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
819 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2); 642 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
820 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3); 643 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
821 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4); 644 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
822 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5); 645 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
823 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6); 646 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
824 msleep(130); 647 msleep(40);
825 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); 648
826 msleep(6); 649 if (reso == IMAGE_640 || reso == IMAGE_800)
827 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); 650 fetch_idxdata(gspca_dev, tbl_middle_hvflip_low,
828 msleep(6); 651 ARRAY_SIZE(tbl_middle_hvflip_low));
829 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); 652 else
830 msleep(6); 653 fetch_idxdata(gspca_dev, tbl_middle_hvflip_big,
831 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); 654 ARRAY_SIZE(tbl_middle_hvflip_big));
832 msleep(6); 655
833 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1); 656 fetch_idxdata(gspca_dev, tbl_end_hvflip,
834 msleep(6); 657 ARRAY_SIZE(tbl_end_hvflip));
835 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
836 msleep(6);
837
838 /* Sometimes present, sometimes not, useful? */
839 /* ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
840 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);
841 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
842 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);
843 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
844 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);
845 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
846 * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);*/
847 } 658 }
848 659
849 if (backlight != sd->vold.backlight) { 660 if (bright != sd->vold.brightness) {
850 sd->vold.backlight = backlight; 661 sd->vold.brightness = bright;
851 if (backlight < 0 || backlight > sd->vmax.backlight) 662 if (bright < 0 || bright > sd->vmax.brightness)
852 backlight = 0; 663 bright = 0;
853 664
854 dat_multi1[2] = 0x9d; 665 dat_bright2[2] = bright;
855 dat_multi3[2] = dat_multi1[2] + 1; 666 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright1);
856 dat_multi4[2] = dat_multi2[2] = backlight; 667 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright2);
857 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 668 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright3);
858 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 669 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright4);
859 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 670 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright5);
860 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4); 671 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright6);
861 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
862 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
863 } 672 }
864 673
865 if (gam != sd->vold.gamma) { 674 if (cntr != sd->vold.contrast || gam != sd->vold.gamma) {
675 sd->vold.contrast = cntr;
676 if (cntr < 0 || cntr > sd->vmax.contrast)
677 cntr = 0;
866 sd->vold.gamma = gam; 678 sd->vold.gamma = gam;
867 if (gam < 0 || gam > sd->vmax.gamma) 679 if (gam < 0 || gam > sd->vmax.gamma)
868 gam = 0; 680 gam = 0;
869 681
870 dat_multi1[2] = 0x6d; 682 dat_multi1[2] = 0x6d;
871 dat_multi3[2] = dat_multi1[2] + 1; 683 dat_multi3[2] = dat_multi1[2] + 1;
872 dat_multi4[2] = dat_multi2[2] = 0x40 + gam; 684 if (cntr == 0)
685 cntr = 4;
686 dat_multi4[2] = dat_multi2[2] = cntr * 0x10 + 2 - gam;
873 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 687 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
874 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 688 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
875 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 689 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
@@ -878,14 +692,14 @@ static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
878 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); 692 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
879 } 693 }
880 694
881 if (cntr != sd->vold.contrast) { 695 if (backlight != sd->vold.backlight) {
882 sd->vold.contrast = cntr; 696 sd->vold.backlight = backlight;
883 if (cntr < 0 || cntr > sd->vmax.contrast) 697 if (backlight < 0 || backlight > sd->vmax.backlight)
884 cntr = 0; 698 backlight = 0;
885 699
886 dat_multi1[2] = 0x6d; 700 dat_multi1[2] = 0x9d;
887 dat_multi3[2] = dat_multi1[2] + 1; 701 dat_multi3[2] = dat_multi1[2] + 1;
888 dat_multi4[2] = dat_multi2[2] = 0x12 + 16 * cntr; 702 dat_multi4[2] = dat_multi2[2] = backlight;
889 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1); 703 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
890 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2); 704 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
891 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3); 705 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
@@ -894,20 +708,6 @@ static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
894 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6); 708 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
895 } 709 }
896 710
897 if (bright != sd->vold.brightness) {
898 sd->vold.brightness = bright;
899 if (bright < 0 || bright > sd->vmax.brightness)
900 bright = 0;
901
902 dat_bright2[2] = bright;
903 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright1);
904 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright2);
905 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright3);
906 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright4);
907 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright5);
908 ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright6);
909 }
910
911 if (sharp != sd->vold.sharpness) { 711 if (sharp != sd->vold.sharpness) {
912 sd->vold.sharpness = sharp; 712 sd->vold.sharpness = sharp;
913 if (sharp < 0 || sharp > sd->vmax.sharpness) 713 if (sharp < 0 || sharp > sd->vmax.sharpness)
@@ -928,9 +728,6 @@ static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
928static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev) 728static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev)
929{ 729{
930 ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL); 730 ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL);
931 msleep(20); 731 msleep(40);
932 if (_MI2020c_ || _MI2020_) 732 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL);
933 ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL);
934 else
935 ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL);
936} 733}