diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2009-01-22 12:56:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:34 -0400 |
commit | 16631aedb23bac40332549dcaed90c804271cc5b (patch) | |
tree | 4b0390fcbec1e57344044400782e6c0836b4b516 /drivers/media/video | |
parent | 409b11dd74e653dd4dace01b0f3f8e987fe7fe81 (diff) |
V4L/DVB (10383): gspca - spca505: Cleanup and optimize code.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/gspca/spca505.c | 429 |
1 files changed, 208 insertions, 221 deletions
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c index 25e2bec9dc52..c99bf62614f3 100644 --- a/drivers/media/video/gspca/spca505.c +++ b/drivers/media/video/gspca/spca505.c | |||
@@ -31,9 +31,9 @@ MODULE_LICENSE("GPL"); | |||
31 | struct sd { | 31 | struct sd { |
32 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 32 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
33 | 33 | ||
34 | unsigned char brightness; | 34 | u8 brightness; |
35 | 35 | ||
36 | char subtype; | 36 | u8 subtype; |
37 | #define IntelPCCameraPro 0 | 37 | #define IntelPCCameraPro 0 |
38 | #define Nxultra 1 | 38 | #define Nxultra 1 |
39 | }; | 39 | }; |
@@ -43,7 +43,6 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | |||
43 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 43 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); |
44 | 44 | ||
45 | static struct ctrl sd_ctrls[] = { | 45 | static struct ctrl sd_ctrls[] = { |
46 | #define SD_BRIGHTNESS 0 | ||
47 | { | 46 | { |
48 | { | 47 | { |
49 | .id = V4L2_CID_BRIGHTNESS, | 48 | .id = V4L2_CID_BRIGHTNESS, |
@@ -52,7 +51,8 @@ static struct ctrl sd_ctrls[] = { | |||
52 | .minimum = 0, | 51 | .minimum = 0, |
53 | .maximum = 255, | 52 | .maximum = 255, |
54 | .step = 1, | 53 | .step = 1, |
55 | .default_value = 127, | 54 | #define BRIGHTNESS_DEF 127 |
55 | .default_value = BRIGHTNESS_DEF, | ||
56 | }, | 56 | }, |
57 | .set = sd_setbrightness, | 57 | .set = sd_setbrightness, |
58 | .get = sd_getbrightness, | 58 | .get = sd_getbrightness, |
@@ -104,227 +104,224 @@ static const struct v4l2_pix_format vga_mode[] = { | |||
104 | /* | 104 | /* |
105 | * Data to initialize a SPCA505. Common to the CCD and external modes | 105 | * Data to initialize a SPCA505. Common to the CCD and external modes |
106 | */ | 106 | */ |
107 | static const __u16 spca505_init_data[][3] = { | 107 | static const u8 spca505_init_data[][3] = { |
108 | /* line bmRequest,value,index */ | 108 | /* bmRequest,value,index */ |
109 | /* 1819 */ | ||
110 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3}, | 109 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3}, |
111 | /* Sensor reset */ | 110 | /* Sensor reset */ |
112 | /* 1822 */ {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3}, | 111 | {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3}, |
113 | /* 1825 */ {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1}, | 112 | {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1}, |
114 | /* Block USB reset */ | 113 | /* Block USB reset */ |
115 | /* 1828 */ {SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL, | 114 | {SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL, SPCA50X_GLOBAL_MISC0}, |
116 | SPCA50X_GLOBAL_MISC0}, | ||
117 | 115 | ||
118 | /* 1831 */ {0x5, 0x01, 0x10}, | 116 | {0x05, 0x01, 0x10}, |
119 | /* Maybe power down some stuff */ | 117 | /* Maybe power down some stuff */ |
120 | /* 1834 */ {0x5, 0x0f, 0x11}, | 118 | {0x05, 0x0f, 0x11}, |
121 | 119 | ||
122 | /* Setup internal CCD ? */ | 120 | /* Setup internal CCD ? */ |
123 | /* 1837 */ {0x6, 0x10, 0x08}, | 121 | {0x06, 0x10, 0x08}, |
124 | /* 1840 */ {0x6, 0x00, 0x09}, | 122 | {0x06, 0x00, 0x09}, |
125 | /* 1843 */ {0x6, 0x00, 0x0a}, | 123 | {0x06, 0x00, 0x0a}, |
126 | /* 1846 */ {0x6, 0x00, 0x0b}, | 124 | {0x06, 0x00, 0x0b}, |
127 | /* 1849 */ {0x6, 0x10, 0x0c}, | 125 | {0x06, 0x10, 0x0c}, |
128 | /* 1852 */ {0x6, 0x00, 0x0d}, | 126 | {0x06, 0x00, 0x0d}, |
129 | /* 1855 */ {0x6, 0x00, 0x0e}, | 127 | {0x06, 0x00, 0x0e}, |
130 | /* 1858 */ {0x6, 0x00, 0x0f}, | 128 | {0x06, 0x00, 0x0f}, |
131 | /* 1861 */ {0x6, 0x10, 0x10}, | 129 | {0x06, 0x10, 0x10}, |
132 | /* 1864 */ {0x6, 0x02, 0x11}, | 130 | {0x06, 0x02, 0x11}, |
133 | /* 1867 */ {0x6, 0x00, 0x12}, | 131 | {0x06, 0x00, 0x12}, |
134 | /* 1870 */ {0x6, 0x04, 0x13}, | 132 | {0x06, 0x04, 0x13}, |
135 | /* 1873 */ {0x6, 0x02, 0x14}, | 133 | {0x06, 0x02, 0x14}, |
136 | /* 1876 */ {0x6, 0x8a, 0x51}, | 134 | {0x06, 0x8a, 0x51}, |
137 | /* 1879 */ {0x6, 0x40, 0x52}, | 135 | {0x06, 0x40, 0x52}, |
138 | /* 1882 */ {0x6, 0xb6, 0x53}, | 136 | {0x06, 0xb6, 0x53}, |
139 | /* 1885 */ {0x6, 0x3d, 0x54}, | 137 | {0x06, 0x3d, 0x54}, |
140 | {} | 138 | {} |
141 | }; | 139 | }; |
142 | 140 | ||
143 | /* | 141 | /* |
144 | * Data to initialize the camera using the internal CCD | 142 | * Data to initialize the camera using the internal CCD |
145 | */ | 143 | */ |
146 | static const __u16 spca505_open_data_ccd[][3] = { | 144 | static const u8 spca505_open_data_ccd[][3] = { |
147 | /* line bmRequest,value,index */ | 145 | /* bmRequest,value,index */ |
148 | /* Internal CCD data set */ | 146 | /* Internal CCD data set */ |
149 | /* 1891 */ {0x3, 0x04, 0x01}, | 147 | {0x03, 0x04, 0x01}, |
150 | /* This could be a reset */ | 148 | /* This could be a reset */ |
151 | /* 1894 */ {0x3, 0x00, 0x01}, | 149 | {0x03, 0x00, 0x01}, |
152 | 150 | ||
153 | /* Setup compression and image registers. 0x6 and 0x7 seem to be | 151 | /* Setup compression and image registers. 0x6 and 0x7 seem to be |
154 | related to H&V hold, and are resolution mode specific */ | 152 | related to H&V hold, and are resolution mode specific */ |
155 | /* 1897 */ {0x4, 0x10, 0x01}, | 153 | {0x04, 0x10, 0x01}, |
156 | /* DIFF(0x50), was (0x10) */ | 154 | /* DIFF(0x50), was (0x10) */ |
157 | /* 1900 */ {0x4, 0x00, 0x04}, | 155 | {0x04, 0x00, 0x04}, |
158 | /* 1903 */ {0x4, 0x00, 0x05}, | 156 | {0x04, 0x00, 0x05}, |
159 | /* 1906 */ {0x4, 0x20, 0x06}, | 157 | {0x04, 0x20, 0x06}, |
160 | /* 1909 */ {0x4, 0x20, 0x07}, | 158 | {0x04, 0x20, 0x07}, |
161 | 159 | ||
162 | /* 1912 */ {0x8, 0x0a, 0x00}, | 160 | {0x08, 0x0a, 0x00}, |
163 | /* DIFF (0x4a), was (0xa) */ | 161 | /* DIFF (0x4a), was (0xa) */ |
164 | 162 | ||
165 | /* 1915 */ {0x5, 0x00, 0x10}, | 163 | {0x05, 0x00, 0x10}, |
166 | /* 1918 */ {0x5, 0x00, 0x11}, | 164 | {0x05, 0x00, 0x11}, |
167 | /* 1921 */ {0x5, 0x00, 0x00}, | 165 | {0x05, 0x00, 0x00}, |
168 | /* DIFF not written */ | 166 | /* DIFF not written */ |
169 | /* 1924 */ {0x5, 0x00, 0x01}, | 167 | {0x05, 0x00, 0x01}, |
170 | /* DIFF not written */ | 168 | /* DIFF not written */ |
171 | /* 1927 */ {0x5, 0x00, 0x02}, | 169 | {0x05, 0x00, 0x02}, |
172 | /* DIFF not written */ | 170 | /* DIFF not written */ |
173 | /* 1930 */ {0x5, 0x00, 0x03}, | 171 | {0x05, 0x00, 0x03}, |
174 | /* DIFF not written */ | 172 | /* DIFF not written */ |
175 | /* 1933 */ {0x5, 0x00, 0x04}, | 173 | {0x05, 0x00, 0x04}, |
176 | /* DIFF not written */ | 174 | /* DIFF not written */ |
177 | /* 1936 */ {0x5, 0x80, 0x05}, | 175 | {0x05, 0x80, 0x05}, |
178 | /* DIFF not written */ | 176 | /* DIFF not written */ |
179 | /* 1939 */ {0x5, 0xe0, 0x06}, | 177 | {0x05, 0xe0, 0x06}, |
180 | /* DIFF not written */ | 178 | /* DIFF not written */ |
181 | /* 1942 */ {0x5, 0x20, 0x07}, | 179 | {0x05, 0x20, 0x07}, |
182 | /* DIFF not written */ | 180 | /* DIFF not written */ |
183 | /* 1945 */ {0x5, 0xa0, 0x08}, | 181 | {0x05, 0xa0, 0x08}, |
184 | /* DIFF not written */ | 182 | /* DIFF not written */ |
185 | /* 1948 */ {0x5, 0x0, 0x12}, | 183 | {0x05, 0x0, 0x12}, |
186 | /* DIFF not written */ | 184 | /* DIFF not written */ |
187 | /* 1951 */ {0x5, 0x02, 0x0f}, | 185 | {0x05, 0x02, 0x0f}, |
188 | /* DIFF not written */ | 186 | /* DIFF not written */ |
189 | /* 1954 */ {0x5, 0x10, 0x46}, | 187 | {0x05, 0x10, 0x46}, |
190 | /* DIFF not written */ | 188 | /* DIFF not written */ |
191 | /* 1957 */ {0x5, 0x8, 0x4a}, | 189 | {0x05, 0x8, 0x4a}, |
192 | /* DIFF not written */ | 190 | /* DIFF not written */ |
193 | 191 | ||
194 | /* 1960 */ {0x3, 0x08, 0x03}, | 192 | {0x03, 0x08, 0x03}, |
195 | /* DIFF (0x3,0x28,0x3) */ | 193 | /* DIFF (0x3,0x28,0x3) */ |
196 | /* 1963 */ {0x3, 0x08, 0x01}, | 194 | {0x03, 0x08, 0x01}, |
197 | /* 1966 */ {0x3, 0x0c, 0x03}, | 195 | {0x03, 0x0c, 0x03}, |
198 | /* DIFF not written */ | 196 | /* DIFF not written */ |
199 | /* 1969 */ {0x3, 0x21, 0x00}, | 197 | {0x03, 0x21, 0x00}, |
200 | /* DIFF (0x39) */ | 198 | /* DIFF (0x39) */ |
201 | 199 | ||
202 | /* Extra block copied from init to hopefully ensure CCD is in a sane state */ | 200 | /* Extra block copied from init to hopefully ensure CCD is in a sane state */ |
203 | /* 1837 */ {0x6, 0x10, 0x08}, | 201 | {0x06, 0x10, 0x08}, |
204 | /* 1840 */ {0x6, 0x00, 0x09}, | 202 | {0x06, 0x00, 0x09}, |
205 | /* 1843 */ {0x6, 0x00, 0x0a}, | 203 | {0x06, 0x00, 0x0a}, |
206 | /* 1846 */ {0x6, 0x00, 0x0b}, | 204 | {0x06, 0x00, 0x0b}, |
207 | /* 1849 */ {0x6, 0x10, 0x0c}, | 205 | {0x06, 0x10, 0x0c}, |
208 | /* 1852 */ {0x6, 0x00, 0x0d}, | 206 | {0x06, 0x00, 0x0d}, |
209 | /* 1855 */ {0x6, 0x00, 0x0e}, | 207 | {0x06, 0x00, 0x0e}, |
210 | /* 1858 */ {0x6, 0x00, 0x0f}, | 208 | {0x06, 0x00, 0x0f}, |
211 | /* 1861 */ {0x6, 0x10, 0x10}, | 209 | {0x06, 0x10, 0x10}, |
212 | /* 1864 */ {0x6, 0x02, 0x11}, | 210 | {0x06, 0x02, 0x11}, |
213 | /* 1867 */ {0x6, 0x00, 0x12}, | 211 | {0x06, 0x00, 0x12}, |
214 | /* 1870 */ {0x6, 0x04, 0x13}, | 212 | {0x06, 0x04, 0x13}, |
215 | /* 1873 */ {0x6, 0x02, 0x14}, | 213 | {0x06, 0x02, 0x14}, |
216 | /* 1876 */ {0x6, 0x8a, 0x51}, | 214 | {0x06, 0x8a, 0x51}, |
217 | /* 1879 */ {0x6, 0x40, 0x52}, | 215 | {0x06, 0x40, 0x52}, |
218 | /* 1882 */ {0x6, 0xb6, 0x53}, | 216 | {0x06, 0xb6, 0x53}, |
219 | /* 1885 */ {0x6, 0x3d, 0x54}, | 217 | {0x06, 0x3d, 0x54}, |
220 | /* End of extra block */ | 218 | /* End of extra block */ |
221 | 219 | ||
222 | /* 1972 */ {0x6, 0x3f, 0x1}, | 220 | {0x06, 0x3f, 0x1}, |
223 | /* Block skipped */ | 221 | /* Block skipped */ |
224 | /* 1975 */ {0x6, 0x10, 0x02}, | 222 | {0x06, 0x10, 0x02}, |
225 | /* 1978 */ {0x6, 0x64, 0x07}, | 223 | {0x06, 0x64, 0x07}, |
226 | /* 1981 */ {0x6, 0x10, 0x08}, | 224 | {0x06, 0x10, 0x08}, |
227 | /* 1984 */ {0x6, 0x00, 0x09}, | 225 | {0x06, 0x00, 0x09}, |
228 | /* 1987 */ {0x6, 0x00, 0x0a}, | 226 | {0x06, 0x00, 0x0a}, |
229 | /* 1990 */ {0x6, 0x00, 0x0b}, | 227 | {0x06, 0x00, 0x0b}, |
230 | /* 1993 */ {0x6, 0x10, 0x0c}, | 228 | {0x06, 0x10, 0x0c}, |
231 | /* 1996 */ {0x6, 0x00, 0x0d}, | 229 | {0x06, 0x00, 0x0d}, |
232 | /* 1999 */ {0x6, 0x00, 0x0e}, | 230 | {0x06, 0x00, 0x0e}, |
233 | /* 2002 */ {0x6, 0x00, 0x0f}, | 231 | {0x06, 0x00, 0x0f}, |
234 | /* 2005 */ {0x6, 0x10, 0x10}, | 232 | {0x06, 0x10, 0x10}, |
235 | /* 2008 */ {0x6, 0x02, 0x11}, | 233 | {0x06, 0x02, 0x11}, |
236 | /* 2011 */ {0x6, 0x00, 0x12}, | 234 | {0x06, 0x00, 0x12}, |
237 | /* 2014 */ {0x6, 0x04, 0x13}, | 235 | {0x06, 0x04, 0x13}, |
238 | /* 2017 */ {0x6, 0x02, 0x14}, | 236 | {0x06, 0x02, 0x14}, |
239 | /* 2020 */ {0x6, 0x8a, 0x51}, | 237 | {0x06, 0x8a, 0x51}, |
240 | /* 2023 */ {0x6, 0x40, 0x52}, | 238 | {0x06, 0x40, 0x52}, |
241 | /* 2026 */ {0x6, 0xb6, 0x53}, | 239 | {0x06, 0xb6, 0x53}, |
242 | /* 2029 */ {0x6, 0x3d, 0x54}, | 240 | {0x06, 0x3d, 0x54}, |
243 | /* 2032 */ {0x6, 0x60, 0x57}, | 241 | {0x06, 0x60, 0x57}, |
244 | /* 2035 */ {0x6, 0x20, 0x58}, | 242 | {0x06, 0x20, 0x58}, |
245 | /* 2038 */ {0x6, 0x15, 0x59}, | 243 | {0x06, 0x15, 0x59}, |
246 | /* 2041 */ {0x6, 0x05, 0x5a}, | 244 | {0x06, 0x05, 0x5a}, |
247 | 245 | ||
248 | /* 2044 */ {0x5, 0x01, 0xc0}, | 246 | {0x05, 0x01, 0xc0}, |
249 | /* 2047 */ {0x5, 0x10, 0xcb}, | 247 | {0x05, 0x10, 0xcb}, |
250 | /* 2050 */ {0x5, 0x80, 0xc1}, | 248 | {0x05, 0x80, 0xc1}, |
251 | /* */ | 249 | /* */ |
252 | /* 2053 */ {0x5, 0x0, 0xc2}, | 250 | {0x05, 0x0, 0xc2}, |
253 | /* 4 was 0 */ | 251 | /* 4 was 0 */ |
254 | /* 2056 */ {0x5, 0x00, 0xca}, | 252 | {0x05, 0x00, 0xca}, |
255 | /* 2059 */ {0x5, 0x80, 0xc1}, | 253 | {0x05, 0x80, 0xc1}, |
256 | /* */ | 254 | /* */ |
257 | /* 2062 */ {0x5, 0x04, 0xc2}, | 255 | {0x05, 0x04, 0xc2}, |
258 | /* 2065 */ {0x5, 0x00, 0xca}, | 256 | {0x05, 0x00, 0xca}, |
259 | /* 2068 */ {0x5, 0x0, 0xc1}, | 257 | {0x05, 0x0, 0xc1}, |
260 | /* */ | 258 | /* */ |
261 | /* 2071 */ {0x5, 0x00, 0xc2}, | 259 | {0x05, 0x00, 0xc2}, |
262 | /* 2074 */ {0x5, 0x00, 0xca}, | 260 | {0x05, 0x00, 0xca}, |
263 | /* 2077 */ {0x5, 0x40, 0xc1}, | 261 | {0x05, 0x40, 0xc1}, |
264 | /* */ | 262 | /* */ |
265 | /* 2080 */ {0x5, 0x17, 0xc2}, | 263 | {0x05, 0x17, 0xc2}, |
266 | /* 2083 */ {0x5, 0x00, 0xca}, | 264 | {0x05, 0x00, 0xca}, |
267 | /* 2086 */ {0x5, 0x80, 0xc1}, | 265 | {0x05, 0x80, 0xc1}, |
268 | /* */ | 266 | /* */ |
269 | /* 2089 */ {0x5, 0x06, 0xc2}, | 267 | {0x05, 0x06, 0xc2}, |
270 | /* 2092 */ {0x5, 0x00, 0xca}, | 268 | {0x05, 0x00, 0xca}, |
271 | /* 2095 */ {0x5, 0x80, 0xc1}, | 269 | {0x05, 0x80, 0xc1}, |
272 | /* */ | 270 | /* */ |
273 | /* 2098 */ {0x5, 0x04, 0xc2}, | 271 | {0x05, 0x04, 0xc2}, |
274 | /* 2101 */ {0x5, 0x00, 0xca}, | 272 | {0x05, 0x00, 0xca}, |
275 | 273 | ||
276 | /* 2104 */ {0x3, 0x4c, 0x3}, | 274 | {0x03, 0x4c, 0x3}, |
277 | /* 2107 */ {0x3, 0x18, 0x1}, | 275 | {0x03, 0x18, 0x1}, |
278 | 276 | ||
279 | /* 2110 */ {0x6, 0x70, 0x51}, | 277 | {0x06, 0x70, 0x51}, |
280 | /* 2113 */ {0x6, 0xbe, 0x53}, | 278 | {0x06, 0xbe, 0x53}, |
281 | /* 2116 */ {0x6, 0x71, 0x57}, | 279 | {0x06, 0x71, 0x57}, |
282 | /* 2119 */ {0x6, 0x20, 0x58}, | 280 | {0x06, 0x20, 0x58}, |
283 | /* 2122 */ {0x6, 0x05, 0x59}, | 281 | {0x06, 0x05, 0x59}, |
284 | /* 2125 */ {0x6, 0x15, 0x5a}, | 282 | {0x06, 0x15, 0x5a}, |
285 | 283 | ||
286 | /* 2128 */ {0x4, 0x00, 0x08}, | 284 | {0x04, 0x00, 0x08}, |
287 | /* Compress = OFF (0x1 to turn on) */ | 285 | /* Compress = OFF (0x1 to turn on) */ |
288 | /* 2131 */ {0x4, 0x12, 0x09}, | 286 | {0x04, 0x12, 0x09}, |
289 | /* 2134 */ {0x4, 0x21, 0x0a}, | 287 | {0x04, 0x21, 0x0a}, |
290 | /* 2137 */ {0x4, 0x10, 0x0b}, | 288 | {0x04, 0x10, 0x0b}, |
291 | /* 2140 */ {0x4, 0x21, 0x0c}, | 289 | {0x04, 0x21, 0x0c}, |
292 | /* 2143 */ {0x4, 0x05, 0x00}, | 290 | {0x04, 0x05, 0x00}, |
293 | /* was 5 (Image Type ? ) */ | 291 | /* was 5 (Image Type ? ) */ |
294 | /* 2146 */ {0x4, 0x00, 0x01}, | 292 | {0x04, 0x00, 0x01}, |
295 | 293 | ||
296 | /* 2149 */ {0x6, 0x3f, 0x01}, | 294 | {0x06, 0x3f, 0x01}, |
297 | 295 | ||
298 | /* 2152 */ {0x4, 0x00, 0x04}, | 296 | {0x04, 0x00, 0x04}, |
299 | /* 2155 */ {0x4, 0x00, 0x05}, | 297 | {0x04, 0x00, 0x05}, |
300 | /* 2158 */ {0x4, 0x40, 0x06}, | 298 | {0x04, 0x40, 0x06}, |
301 | /* 2161 */ {0x4, 0x40, 0x07}, | 299 | {0x04, 0x40, 0x07}, |
302 | 300 | ||
303 | /* 2164 */ {0x6, 0x1c, 0x17}, | 301 | {0x06, 0x1c, 0x17}, |
304 | /* 2167 */ {0x6, 0xe2, 0x19}, | 302 | {0x06, 0xe2, 0x19}, |
305 | /* 2170 */ {0x6, 0x1c, 0x1b}, | 303 | {0x06, 0x1c, 0x1b}, |
306 | /* 2173 */ {0x6, 0xe2, 0x1d}, | 304 | {0x06, 0xe2, 0x1d}, |
307 | /* 2176 */ {0x6, 0xaa, 0x1f}, | 305 | {0x06, 0xaa, 0x1f}, |
308 | /* 2179 */ {0x6, 0x70, 0x20}, | 306 | {0x06, 0x70, 0x20}, |
309 | 307 | ||
310 | /* 2182 */ {0x5, 0x01, 0x10}, | 308 | {0x05, 0x01, 0x10}, |
311 | /* 2185 */ {0x5, 0x00, 0x11}, | 309 | {0x05, 0x00, 0x11}, |
312 | /* 2188 */ {0x5, 0x01, 0x00}, | 310 | {0x05, 0x01, 0x00}, |
313 | /* 2191 */ {0x5, 0x05, 0x01}, | 311 | {0x05, 0x05, 0x01}, |
314 | /* 2194 */ {0x5, 0x00, 0xc1}, | 312 | {0x05, 0x00, 0xc1}, |
315 | /* */ | 313 | /* */ |
316 | /* 2197 */ {0x5, 0x00, 0xc2}, | 314 | {0x05, 0x00, 0xc2}, |
317 | /* 2200 */ {0x5, 0x00, 0xca}, | 315 | {0x05, 0x00, 0xca}, |
318 | 316 | ||
319 | /* 2203 */ {0x6, 0x70, 0x51}, | 317 | {0x06, 0x70, 0x51}, |
320 | /* 2206 */ {0x6, 0xbe, 0x53}, | 318 | {0x06, 0xbe, 0x53}, |
321 | {} | 319 | {} |
322 | }; | 320 | }; |
323 | 321 | ||
324 | /* | 322 | /* |
325 | Made by Tomasz Zablocki (skalamandra@poczta.onet.pl) | 323 | * Made by Tomasz Zablocki (skalamandra@poczta.onet.pl) |
326 | * SPCA505b chip based cameras initialization data | 324 | * SPCA505b chip based cameras initialization data |
327 | * | ||
328 | */ | 325 | */ |
329 | /* jfm */ | 326 | /* jfm */ |
330 | #define initial_brightness 0x7f /* 0x0(white)-0xff(black) */ | 327 | #define initial_brightness 0x7f /* 0x0(white)-0xff(black) */ |
@@ -332,7 +329,7 @@ static const __u16 spca505_open_data_ccd[][3] = { | |||
332 | /* | 329 | /* |
333 | * Data to initialize a SPCA505. Common to the CCD and external modes | 330 | * Data to initialize a SPCA505. Common to the CCD and external modes |
334 | */ | 331 | */ |
335 | static const __u16 spca505b_init_data[][3] = { | 332 | static const u8 spca505b_init_data[][3] = { |
336 | /* start */ | 333 | /* start */ |
337 | {0x02, 0x00, 0x00}, /* init */ | 334 | {0x02, 0x00, 0x00}, /* init */ |
338 | {0x02, 0x00, 0x01}, | 335 | {0x02, 0x00, 0x01}, |
@@ -396,7 +393,7 @@ static const __u16 spca505b_init_data[][3] = { | |||
396 | /* | 393 | /* |
397 | * Data to initialize the camera using the internal CCD | 394 | * Data to initialize the camera using the internal CCD |
398 | */ | 395 | */ |
399 | static const __u16 spca505b_open_data_ccd[][3] = { | 396 | static const u8 spca505b_open_data_ccd[][3] = { |
400 | 397 | ||
401 | /* {0x02,0x00,0x00}, */ | 398 | /* {0x02,0x00,0x00}, */ |
402 | {0x03, 0x04, 0x01}, /* rst */ | 399 | {0x03, 0x04, 0x01}, /* rst */ |
@@ -425,8 +422,8 @@ static const __u16 spca505b_open_data_ccd[][3] = { | |||
425 | {0x05, 0x00, 0x11}, | 422 | {0x05, 0x00, 0x11}, |
426 | {0x05, 0x00, 0x12}, | 423 | {0x05, 0x00, 0x12}, |
427 | {0x05, 0x6f, 0x00}, | 424 | {0x05, 0x6f, 0x00}, |
428 | {0x05, initial_brightness >> 6, 0x00}, | 425 | {0x05, (u8) (initial_brightness >> 6), 0x00}, |
429 | {0x05, initial_brightness << 2, 0x01}, | 426 | {0x05, (u8) (initial_brightness << 2), 0x01}, |
430 | {0x05, 0x00, 0x02}, | 427 | {0x05, 0x00, 0x02}, |
431 | {0x05, 0x01, 0x03}, | 428 | {0x05, 0x01, 0x03}, |
432 | {0x05, 0x00, 0x04}, | 429 | {0x05, 0x00, 0x04}, |
@@ -436,7 +433,7 @@ static const __u16 spca505b_open_data_ccd[][3] = { | |||
436 | {0x05, 0xa0, 0x08}, | 433 | {0x05, 0xa0, 0x08}, |
437 | {0x05, 0x00, 0x12}, | 434 | {0x05, 0x00, 0x12}, |
438 | {0x05, 0x02, 0x0f}, | 435 | {0x05, 0x02, 0x0f}, |
439 | {0x05, 128, 0x14}, /* max exposure off (0=on) */ | 436 | {0x05, 0x80, 0x14}, /* max exposure off (0=on) */ |
440 | {0x05, 0x01, 0xb0}, | 437 | {0x05, 0x01, 0xb0}, |
441 | {0x05, 0x01, 0xbf}, | 438 | {0x05, 0x01, 0xbf}, |
442 | {0x03, 0x02, 0x06}, | 439 | {0x03, 0x02, 0x06}, |
@@ -559,27 +556,27 @@ static const __u16 spca505b_open_data_ccd[][3] = { | |||
559 | {0x06, 0x5f, 0x1f}, | 556 | {0x06, 0x5f, 0x1f}, |
560 | {0x06, 0x32, 0x20}, | 557 | {0x06, 0x32, 0x20}, |
561 | 558 | ||
562 | {0x05, initial_brightness >> 6, 0x00}, | 559 | {0x05, (u8) (initial_brightness >> 6), 0x00}, |
563 | {0x05, initial_brightness << 2, 0x01}, | 560 | {0x05, (u8) (initial_brightness << 2), 0x01}, |
564 | {0x05, 0x06, 0xc1}, | 561 | {0x05, 0x06, 0xc1}, |
565 | {0x05, 0x58, 0xc2}, | 562 | {0x05, 0x58, 0xc2}, |
566 | {0x05, 0x0, 0xca}, | 563 | {0x05, 0x00, 0xca}, |
567 | {0x05, 0x0, 0x11}, | 564 | {0x05, 0x00, 0x11}, |
568 | {} | 565 | {} |
569 | }; | 566 | }; |
570 | 567 | ||
571 | static int reg_write(struct usb_device *dev, | 568 | static int reg_write(struct usb_device *dev, |
572 | __u16 reg, __u16 index, __u16 value) | 569 | u16 req, u16 index, u16 value) |
573 | { | 570 | { |
574 | int ret; | 571 | int ret; |
575 | 572 | ||
576 | ret = usb_control_msg(dev, | 573 | ret = usb_control_msg(dev, |
577 | usb_sndctrlpipe(dev, 0), | 574 | usb_sndctrlpipe(dev, 0), |
578 | reg, | 575 | req, |
579 | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 576 | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
580 | value, index, NULL, 0, 500); | 577 | value, index, NULL, 0, 500); |
581 | PDEBUG(D_PACK, "reg write: 0x%02x,0x%02x:0x%02x, 0x%x", | 578 | PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d", |
582 | reg, index, value, ret); | 579 | req, index, value, ret); |
583 | if (ret < 0) | 580 | if (ret < 0) |
584 | PDEBUG(D_ERR, "reg write: error %d", ret); | 581 | PDEBUG(D_ERR, "reg write: error %d", ret); |
585 | return ret; | 582 | return ret; |
@@ -587,42 +584,34 @@ static int reg_write(struct usb_device *dev, | |||
587 | 584 | ||
588 | /* returns: negative is error, pos or zero is data */ | 585 | /* returns: negative is error, pos or zero is data */ |
589 | static int reg_read(struct gspca_dev *gspca_dev, | 586 | static int reg_read(struct gspca_dev *gspca_dev, |
590 | __u16 reg, /* bRequest */ | 587 | u16 req, /* bRequest */ |
591 | __u16 index, /* wIndex */ | 588 | u16 index) /* wIndex */ |
592 | __u16 length) /* wLength (1 or 2 only) */ | ||
593 | { | 589 | { |
594 | int ret; | 590 | int ret; |
595 | 591 | ||
596 | gspca_dev->usb_buf[1] = 0; | ||
597 | ret = usb_control_msg(gspca_dev->dev, | 592 | ret = usb_control_msg(gspca_dev->dev, |
598 | usb_rcvctrlpipe(gspca_dev->dev, 0), | 593 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
599 | reg, | 594 | req, |
600 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 595 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
601 | (__u16) 0, /* value */ | 596 | 0, /* value */ |
602 | (__u16) index, | 597 | index, |
603 | gspca_dev->usb_buf, length, | 598 | gspca_dev->usb_buf, 2, |
604 | 500); /* timeout */ | 599 | 500); /* timeout */ |
605 | if (ret < 0) { | 600 | if (ret < 0) |
606 | PDEBUG(D_ERR, "reg_read err %d", ret); | 601 | return ret; |
607 | return -1; | ||
608 | } | ||
609 | return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; | 602 | return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; |
610 | } | 603 | } |
611 | 604 | ||
612 | static int write_vector(struct gspca_dev *gspca_dev, | 605 | static int write_vector(struct gspca_dev *gspca_dev, |
613 | const __u16 data[][3]) | 606 | const u8 data[][3]) |
614 | { | 607 | { |
615 | struct usb_device *dev = gspca_dev->dev; | 608 | struct usb_device *dev = gspca_dev->dev; |
616 | int ret, i = 0; | 609 | int ret, i = 0; |
617 | 610 | ||
618 | while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { | 611 | while (data[i][0] != 0) { |
619 | ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); | 612 | ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); |
620 | if (ret < 0) { | 613 | if (ret < 0) |
621 | PDEBUG(D_ERR, | ||
622 | "Register write failed for 0x%x,0x%x,0x%x", | ||
623 | data[i][0], data[i][1], data[i][2]); | ||
624 | return ret; | 614 | return ret; |
625 | } | ||
626 | i++; | 615 | i++; |
627 | } | 616 | } |
628 | return 0; | 617 | return 0; |
@@ -639,10 +628,10 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
639 | cam->cam_mode = vga_mode; | 628 | cam->cam_mode = vga_mode; |
640 | sd->subtype = id->driver_info; | 629 | sd->subtype = id->driver_info; |
641 | if (sd->subtype != IntelPCCameraPro) | 630 | if (sd->subtype != IntelPCCameraPro) |
642 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; | 631 | cam->nmodes = ARRAY_SIZE(vga_mode); |
643 | else /* no 640x480 for IntelPCCameraPro */ | 632 | else /* no 640x480 for IntelPCCameraPro */ |
644 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0] - 1; | 633 | cam->nmodes = ARRAY_SIZE(vga_mode) - 1; |
645 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; | 634 | sd->brightness = BRIGHTNESS_DEF; |
646 | 635 | ||
647 | if (sd->subtype == Nxultra) { | 636 | if (sd->subtype == Nxultra) { |
648 | if (write_vector(gspca_dev, spca505b_init_data)) | 637 | if (write_vector(gspca_dev, spca505b_init_data)) |
@@ -660,30 +649,28 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
660 | struct sd *sd = (struct sd *) gspca_dev; | 649 | struct sd *sd = (struct sd *) gspca_dev; |
661 | int ret; | 650 | int ret; |
662 | 651 | ||
663 | PDEBUG(D_STREAM, "Initializing SPCA505"); | ||
664 | if (sd->subtype == Nxultra) | 652 | if (sd->subtype == Nxultra) |
665 | write_vector(gspca_dev, spca505b_open_data_ccd); | 653 | write_vector(gspca_dev, spca505b_open_data_ccd); |
666 | else | 654 | else |
667 | write_vector(gspca_dev, spca505_open_data_ccd); | 655 | write_vector(gspca_dev, spca505_open_data_ccd); |
668 | ret = reg_read(gspca_dev, 6, 0x16, 2); | 656 | ret = reg_read(gspca_dev, 0x06, 0x16); |
669 | 657 | ||
670 | if (ret < 0) { | 658 | if (ret < 0) { |
671 | PDEBUG(D_ERR|D_STREAM, | 659 | PDEBUG(D_ERR|D_CONF, |
672 | "register read failed for after vector read err = %d", | 660 | "register read failed err: %d", |
673 | ret); | 661 | ret); |
674 | return -EIO; | 662 | return ret; |
675 | } | 663 | } |
676 | PDEBUG(D_STREAM, | 664 | if (ret != 0x0101) { |
677 | "After vector read returns : 0x%x should be 0x0101", | 665 | PDEBUG(D_ERR|D_CONF, |
678 | ret & 0xffff); | 666 | "After vector read returns 0x%04x should be 0x0101", |
679 | 667 | ret); | |
680 | ret = reg_write(gspca_dev->dev, 6, 0x16, 0x0a); | ||
681 | if (ret < 0) { | ||
682 | PDEBUG(D_ERR, "register write failed for (6,0xa,0x16) err=%d", | ||
683 | ret); | ||
684 | return -EIO; | ||
685 | } | 668 | } |
686 | reg_write(gspca_dev->dev, 5, 0xc2, 18); | 669 | |
670 | ret = reg_write(gspca_dev->dev, 0x06, 0x16, 0x0a); | ||
671 | if (ret < 0) | ||
672 | return ret; | ||
673 | reg_write(gspca_dev->dev, 0x05, 0xc2, 18); | ||
687 | return 0; | 674 | return 0; |
688 | } | 675 | } |
689 | 676 | ||
@@ -749,15 +736,15 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
749 | 736 | ||
750 | /* This maybe reset or power control */ | 737 | /* This maybe reset or power control */ |
751 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); | 738 | reg_write(gspca_dev->dev, 0x03, 0x03, 0x20); |
752 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x0); | 739 | reg_write(gspca_dev->dev, 0x03, 0x01, 0x00); |
753 | reg_write(gspca_dev->dev, 0x03, 0x00, 0x1); | 740 | reg_write(gspca_dev->dev, 0x03, 0x00, 0x01); |
754 | reg_write(gspca_dev->dev, 0x05, 0x10, 0x1); | 741 | reg_write(gspca_dev->dev, 0x05, 0x10, 0x01); |
755 | reg_write(gspca_dev->dev, 0x05, 0x11, 0xf); | 742 | reg_write(gspca_dev->dev, 0x05, 0x11, 0x0f); |
756 | } | 743 | } |
757 | 744 | ||
758 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 745 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
759 | struct gspca_frame *frame, /* target */ | 746 | struct gspca_frame *frame, /* target */ |
760 | __u8 *data, /* isoc packet */ | 747 | u8 *data, /* isoc packet */ |
761 | int len) /* iso packet length */ | 748 | int len) /* iso packet length */ |
762 | { | 749 | { |
763 | switch (data[0]) { | 750 | switch (data[0]) { |
@@ -770,7 +757,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
770 | data, len); | 757 | data, len); |
771 | break; | 758 | break; |
772 | case 0xff: /* drop */ | 759 | case 0xff: /* drop */ |
773 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ | ||
774 | break; | 760 | break; |
775 | default: | 761 | default: |
776 | data += 1; | 762 | data += 1; |
@@ -784,10 +770,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
784 | static void setbrightness(struct gspca_dev *gspca_dev) | 770 | static void setbrightness(struct gspca_dev *gspca_dev) |
785 | { | 771 | { |
786 | struct sd *sd = (struct sd *) gspca_dev; | 772 | struct sd *sd = (struct sd *) gspca_dev; |
773 | u8 brightness = sd->brightness; | ||
787 | 774 | ||
788 | __u8 brightness = sd->brightness; | 775 | reg_write(gspca_dev->dev, 0x05, 0x00, (255 - brightness) >> 6); |
789 | reg_write(gspca_dev->dev, 5, 0x00, (255 - brightness) >> 6); | 776 | reg_write(gspca_dev->dev, 0x05, 0x01, (255 - brightness) << 2); |
790 | reg_write(gspca_dev->dev, 5, 0x01, (255 - brightness) << 2); | ||
791 | 777 | ||
792 | } | 778 | } |
793 | 779 | ||
@@ -854,6 +840,7 @@ static struct usb_driver sd_driver = { | |||
854 | static int __init sd_mod_init(void) | 840 | static int __init sd_mod_init(void) |
855 | { | 841 | { |
856 | int ret; | 842 | int ret; |
843 | |||
857 | ret = usb_register(&sd_driver); | 844 | ret = usb_register(&sd_driver); |
858 | if (ret < 0) | 845 | if (ret < 0) |
859 | return ret; | 846 | return ret; |