aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/w9968cf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/w9968cf.c')
-rw-r--r--drivers/media/video/w9968cf.c930
1 files changed, 465 insertions, 465 deletions
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index b57dec3782e0..20f211b55ad4 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -71,39 +71,39 @@ MODULE_SUPPORTED_DEVICE("Video");
71static int ovmod_load = W9968CF_OVMOD_LOAD; 71static int ovmod_load = W9968CF_OVMOD_LOAD;
72static unsigned short simcams = W9968CF_SIMCAMS; 72static unsigned short simcams = W9968CF_SIMCAMS;
73static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/ 73static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/
74static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] = 74static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] =
75 W9968CF_PACKET_SIZE}; 75 W9968CF_PACKET_SIZE};
76static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] = 76static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] =
77 W9968CF_BUFFERS}; 77 W9968CF_BUFFERS};
78static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] = 78static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] =
79 W9968CF_DOUBLE_BUFFER}; 79 W9968CF_DOUBLE_BUFFER};
80static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING}; 80static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING};
81static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] = 81static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] =
82 W9968CF_FILTER_TYPE}; 82 W9968CF_FILTER_TYPE};
83static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW}; 83static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW};
84static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] = 84static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] =
85 W9968CF_DECOMPRESSION}; 85 W9968CF_DECOMPRESSION};
86static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING}; 86static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING};
87static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0}; 87static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0};
88static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB}; 88static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB};
89static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT}; 89static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT};
90static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP}; 90static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP};
91static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] = 91static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] =
92 W9968CF_LIGHTFREQ}; 92 W9968CF_LIGHTFREQ};
93static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]= 93static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]=
94 W9968CF_BANDINGFILTER}; 94 W9968CF_BANDINGFILTER};
95static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV}; 95static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV};
96static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT}; 96static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT};
97static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR}; 97static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR};
98static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME}; 98static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME};
99static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] = 99static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
100 W9968CF_BRIGHTNESS}; 100 W9968CF_BRIGHTNESS};
101static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE}; 101static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE};
102static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR}; 102static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR};
103static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] = 103static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] =
104 W9968CF_CONTRAST}; 104 W9968CF_CONTRAST};
105static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] = 105static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
106 W9968CF_WHITENESS}; 106 W9968CF_WHITENESS};
107#ifdef W9968CF_DEBUG 107#ifdef W9968CF_DEBUG
108static unsigned short debug = W9968CF_DEBUG_LEVEL; 108static unsigned short debug = W9968CF_DEBUG_LEVEL;
109static int specific_debug = W9968CF_SPECIFIC_DEBUG; 109static int specific_debug = W9968CF_SPECIFIC_DEBUG;
@@ -145,251 +145,251 @@ module_param(specific_debug, bool, 0644);
145#endif 145#endif
146 146
147#ifdef CONFIG_KMOD 147#ifdef CONFIG_KMOD
148MODULE_PARM_DESC(ovmod_load, 148MODULE_PARM_DESC(ovmod_load,
149 "\n<0|1> Automatic 'ovcamchip' module loading." 149 "\n<0|1> Automatic 'ovcamchip' module loading."
150 "\n0 disabled, 1 enabled." 150 "\n0 disabled, 1 enabled."
151 "\nIf enabled,'insmod' searches for the required 'ovcamchip'" 151 "\nIf enabled,'insmod' searches for the required 'ovcamchip'"
152 "\nmodule in the system, according to its configuration, and" 152 "\nmodule in the system, according to its configuration, and"
153 "\nattempts to load that module automatically. This action is" 153 "\nattempts to load that module automatically. This action is"
154 "\nperformed once as soon as the 'w9968cf' module is loaded" 154 "\nperformed once as soon as the 'w9968cf' module is loaded"
155 "\ninto memory." 155 "\ninto memory."
156 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"." 156 "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"."
157 "\n"); 157 "\n");
158#endif 158#endif
159MODULE_PARM_DESC(simcams, 159MODULE_PARM_DESC(simcams,
160 "\n<n> Number of cameras allowed to stream simultaneously." 160 "\n<n> Number of cameras allowed to stream simultaneously."
161 "\nn may vary from 0 to " 161 "\nn may vary from 0 to "
162 __MODULE_STRING(W9968CF_MAX_DEVICES)"." 162 __MODULE_STRING(W9968CF_MAX_DEVICES)"."
163 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"." 163 "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"."
164 "\n"); 164 "\n");
165MODULE_PARM_DESC(video_nr, 165MODULE_PARM_DESC(video_nr,
166 "\n<-1|n[,...]> Specify V4L minor mode number." 166 "\n<-1|n[,...]> Specify V4L minor mode number."
167 "\n -1 = use next available (default)" 167 "\n -1 = use next available (default)"
168 "\n n = use minor number n (integer >= 0)" 168 "\n n = use minor number n (integer >= 0)"
169 "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES) 169 "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES)
170 " cameras this way." 170 " cameras this way."
171 "\nFor example:" 171 "\nFor example:"
172 "\nvideo_nr=-1,2,-1 would assign minor number 2 to" 172 "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
173 "\nthe second camera and use auto for the first" 173 "\nthe second camera and use auto for the first"
174 "\none and for every other camera." 174 "\none and for every other camera."
175 "\n"); 175 "\n");
176MODULE_PARM_DESC(packet_size, 176MODULE_PARM_DESC(packet_size,
177 "\n<n[,...]> Specify the maximum data payload" 177 "\n<n[,...]> Specify the maximum data payload"
178 "\nsize in bytes for alternate settings, for each device." 178 "\nsize in bytes for alternate settings, for each device."
179 "\nn is scaled between 63 and 1023 " 179 "\nn is scaled between 63 and 1023 "
180 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")." 180 "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")."
181 "\n"); 181 "\n");
182MODULE_PARM_DESC(max_buffers, 182MODULE_PARM_DESC(max_buffers,
183 "\n<n[,...]> For advanced users." 183 "\n<n[,...]> For advanced users."
184 "\nSpecify the maximum number of video frame buffers" 184 "\nSpecify the maximum number of video frame buffers"
185 "\nto allocate for each device, from 2 to " 185 "\nto allocate for each device, from 2 to "
186 __MODULE_STRING(W9968CF_MAX_BUFFERS) 186 __MODULE_STRING(W9968CF_MAX_BUFFERS)
187 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")." 187 ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")."
188 "\n"); 188 "\n");
189MODULE_PARM_DESC(double_buffer, 189MODULE_PARM_DESC(double_buffer,
190 "\n<0|1[,...]> " 190 "\n<0|1[,...]> "
191 "Hardware double buffering: 0 disabled, 1 enabled." 191 "Hardware double buffering: 0 disabled, 1 enabled."
192 "\nIt should be enabled if you want smooth video output: if" 192 "\nIt should be enabled if you want smooth video output: if"
193 "\nyou obtain out of sync. video, disable it, or try to" 193 "\nyou obtain out of sync. video, disable it, or try to"
194 "\ndecrease the 'clockdiv' module parameter value." 194 "\ndecrease the 'clockdiv' module parameter value."
195 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER) 195 "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER)
196 " for every device." 196 " for every device."
197 "\n"); 197 "\n");
198MODULE_PARM_DESC(clamping, 198MODULE_PARM_DESC(clamping,
199 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled." 199 "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled."
200 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING) 200 "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING)
201 " for every device." 201 " for every device."
202 "\n"); 202 "\n");
203MODULE_PARM_DESC(filter_type, 203MODULE_PARM_DESC(filter_type,
204 "\n<0|1|2[,...]> Video filter type." 204 "\n<0|1|2[,...]> Video filter type."
205 "\n0 none, 1 (1-2-1) 3-tap filter, " 205 "\n0 none, 1 (1-2-1) 3-tap filter, "
206 "2 (2-3-6-3-2) 5-tap filter." 206 "2 (2-3-6-3-2) 5-tap filter."
207 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE) 207 "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE)
208 " for every device." 208 " for every device."
209 "\nThe filter is used to reduce noise and aliasing artifacts" 209 "\nThe filter is used to reduce noise and aliasing artifacts"
210 "\nproduced by the CCD or CMOS image sensor, and the scaling" 210 "\nproduced by the CCD or CMOS image sensor, and the scaling"
211 " process." 211 " process."
212 "\n"); 212 "\n");
213MODULE_PARM_DESC(largeview, 213MODULE_PARM_DESC(largeview,
214 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled." 214 "\n<0|1[,...]> Large view: 0 disabled, 1 enabled."
215 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW) 215 "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW)
216 " for every device." 216 " for every device."
217 "\n"); 217 "\n");
218MODULE_PARM_DESC(upscaling, 218MODULE_PARM_DESC(upscaling,
219 "\n<0|1[,...]> Software scaling (for non-compressed video):" 219 "\n<0|1[,...]> Software scaling (for non-compressed video):"
220 "\n0 disabled, 1 enabled." 220 "\n0 disabled, 1 enabled."
221 "\nDisable it if you have a slow CPU or you don't have" 221 "\nDisable it if you have a slow CPU or you don't have"
222 " enough memory." 222 " enough memory."
223 "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING) 223 "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING)
224 " for every device." 224 " for every device."
225 "\nIf 'w9968cf-vpp' is not present, this parameter is" 225 "\nIf 'w9968cf-vpp' is not present, this parameter is"
226 " set to 0." 226 " set to 0."
227 "\n"); 227 "\n");
228MODULE_PARM_DESC(decompression, 228MODULE_PARM_DESC(decompression,
229 "\n<0|1|2[,...]> Software video decompression:" 229 "\n<0|1|2[,...]> Software video decompression:"
230 "\n- 0 disables decompression (doesn't allow formats needing" 230 "\n- 0 disables decompression (doesn't allow formats needing"
231 " decompression)" 231 " decompression)"
232 "\n- 1 forces decompression (allows formats needing" 232 "\n- 1 forces decompression (allows formats needing"
233 " decompression only);" 233 " decompression only);"
234 "\n- 2 allows any permitted formats." 234 "\n- 2 allows any permitted formats."
235 "\nFormats supporting compressed video are YUV422P and" 235 "\nFormats supporting compressed video are YUV422P and"
236 " YUV420P/YUV420 " 236 " YUV420P/YUV420 "
237 "\nin any resolutions where both width and height are " 237 "\nin any resolutions where both width and height are "
238 "a multiple of 16." 238 "a multiple of 16."
239 "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION) 239 "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION)
240 " for every device." 240 " for every device."
241 "\nIf 'w9968cf-vpp' is not present, forcing decompression is " 241 "\nIf 'w9968cf-vpp' is not present, forcing decompression is "
242 "\nnot allowed; in this case this parameter is set to 2." 242 "\nnot allowed; in this case this parameter is set to 2."
243 "\n"); 243 "\n");
244MODULE_PARM_DESC(force_palette, 244MODULE_PARM_DESC(force_palette,
245 "\n<0" 245 "\n<0"
246 "|" __MODULE_STRING(VIDEO_PALETTE_UYVY) 246 "|" __MODULE_STRING(VIDEO_PALETTE_UYVY)
247 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420) 247 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420)
248 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P) 248 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P)
249 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P) 249 "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P)
250 "|" __MODULE_STRING(VIDEO_PALETTE_YUYV) 250 "|" __MODULE_STRING(VIDEO_PALETTE_YUYV)
251 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422) 251 "|" __MODULE_STRING(VIDEO_PALETTE_YUV422)
252 "|" __MODULE_STRING(VIDEO_PALETTE_GREY) 252 "|" __MODULE_STRING(VIDEO_PALETTE_GREY)
253 "|" __MODULE_STRING(VIDEO_PALETTE_RGB555) 253 "|" __MODULE_STRING(VIDEO_PALETTE_RGB555)
254 "|" __MODULE_STRING(VIDEO_PALETTE_RGB565) 254 "|" __MODULE_STRING(VIDEO_PALETTE_RGB565)
255 "|" __MODULE_STRING(VIDEO_PALETTE_RGB24) 255 "|" __MODULE_STRING(VIDEO_PALETTE_RGB24)
256 "|" __MODULE_STRING(VIDEO_PALETTE_RGB32) 256 "|" __MODULE_STRING(VIDEO_PALETTE_RGB32)
257 "[,...]>" 257 "[,...]>"
258 " Force picture palette." 258 " Force picture palette."
259 "\nIn order:" 259 "\nIn order:"
260 "\n- 0 allows any of the following formats:" 260 "\n- 0 allows any of the following formats:"
261 "\n- UYVY 16 bpp - Original video, compression disabled" 261 "\n- UYVY 16 bpp - Original video, compression disabled"
262 "\n- YUV420 12 bpp - Original video, compression enabled" 262 "\n- YUV420 12 bpp - Original video, compression enabled"
263 "\n- YUV422P 16 bpp - Original video, compression enabled" 263 "\n- YUV422P 16 bpp - Original video, compression enabled"
264 "\n- YUV420P 12 bpp - Original video, compression enabled" 264 "\n- YUV420P 12 bpp - Original video, compression enabled"
265 "\n- YUVY 16 bpp - Software conversion from UYVY" 265 "\n- YUVY 16 bpp - Software conversion from UYVY"
266 "\n- YUV422 16 bpp - Software conversion from UYVY" 266 "\n- YUV422 16 bpp - Software conversion from UYVY"
267 "\n- GREY 8 bpp - Software conversion from UYVY" 267 "\n- GREY 8 bpp - Software conversion from UYVY"
268 "\n- RGB555 16 bpp - Software conversion from UYVY" 268 "\n- RGB555 16 bpp - Software conversion from UYVY"
269 "\n- RGB565 16 bpp - Software conversion from UYVY" 269 "\n- RGB565 16 bpp - Software conversion from UYVY"
270 "\n- RGB24 24 bpp - Software conversion from UYVY" 270 "\n- RGB24 24 bpp - Software conversion from UYVY"
271 "\n- RGB32 32 bpp - Software conversion from UYVY" 271 "\n- RGB32 32 bpp - Software conversion from UYVY"
272 "\nWhen not 0, this parameter will override 'decompression'." 272 "\nWhen not 0, this parameter will override 'decompression'."
273 "\nDefault value is 0 for every device." 273 "\nDefault value is 0 for every device."
274 "\nInitial palette is " 274 "\nInitial palette is "
275 __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"." 275 __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"."
276 "\nIf 'w9968cf-vpp' is not present, this parameter is" 276 "\nIf 'w9968cf-vpp' is not present, this parameter is"
277 " set to 9 (UYVY)." 277 " set to 9 (UYVY)."
278 "\n"); 278 "\n");
279MODULE_PARM_DESC(force_rgb, 279MODULE_PARM_DESC(force_rgb,
280 "\n<0|1[,...]> Read RGB video data instead of BGR:" 280 "\n<0|1[,...]> Read RGB video data instead of BGR:"
281 "\n 1 = use RGB component ordering." 281 "\n 1 = use RGB component ordering."
282 "\n 0 = use BGR component ordering." 282 "\n 0 = use BGR component ordering."
283 "\nThis parameter has effect when using RGBX palettes only." 283 "\nThis parameter has effect when using RGBX palettes only."
284 "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB) 284 "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB)
285 " for every device." 285 " for every device."
286 "\n"); 286 "\n");
287MODULE_PARM_DESC(autobright, 287MODULE_PARM_DESC(autobright,
288 "\n<0|1[,...]> Image sensor automatically changes brightness:" 288 "\n<0|1[,...]> Image sensor automatically changes brightness:"
289 "\n 0 = no, 1 = yes" 289 "\n 0 = no, 1 = yes"
290 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT) 290 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT)
291 " for every device." 291 " for every device."
292 "\n"); 292 "\n");
293MODULE_PARM_DESC(autoexp, 293MODULE_PARM_DESC(autoexp,
294 "\n<0|1[,...]> Image sensor automatically changes exposure:" 294 "\n<0|1[,...]> Image sensor automatically changes exposure:"
295 "\n 0 = no, 1 = yes" 295 "\n 0 = no, 1 = yes"
296 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP) 296 "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP)
297 " for every device." 297 " for every device."
298 "\n"); 298 "\n");
299MODULE_PARM_DESC(lightfreq, 299MODULE_PARM_DESC(lightfreq,
300 "\n<50|60[,...]> Light frequency in Hz:" 300 "\n<50|60[,...]> Light frequency in Hz:"
301 "\n 50 for European and Asian lighting," 301 "\n 50 for European and Asian lighting,"
302 " 60 for American lighting." 302 " 60 for American lighting."
303 "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ) 303 "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ)
304 " for every device." 304 " for every device."
305 "\n"); 305 "\n");
306MODULE_PARM_DESC(bandingfilter, 306MODULE_PARM_DESC(bandingfilter,
307 "\n<0|1[,...]> Banding filter to reduce effects of" 307 "\n<0|1[,...]> Banding filter to reduce effects of"
308 " fluorescent lighting:" 308 " fluorescent lighting:"
309 "\n 0 disabled, 1 enabled." 309 "\n 0 disabled, 1 enabled."
310 "\nThis filter tries to reduce the pattern of horizontal" 310 "\nThis filter tries to reduce the pattern of horizontal"
311 "\nlight/dark bands caused by some (usually fluorescent)" 311 "\nlight/dark bands caused by some (usually fluorescent)"
312 " lighting." 312 " lighting."
313 "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER) 313 "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER)
314 " for every device." 314 " for every device."
315 "\n"); 315 "\n");
316MODULE_PARM_DESC(clockdiv, 316MODULE_PARM_DESC(clockdiv,
317 "\n<-1|n[,...]> " 317 "\n<-1|n[,...]> "
318 "Force pixel clock divisor to a specific value (for experts):" 318 "Force pixel clock divisor to a specific value (for experts):"
319 "\n n may vary from 0 to 127." 319 "\n n may vary from 0 to 127."
320 "\n -1 for automatic value." 320 "\n -1 for automatic value."
321 "\nSee also the 'double_buffer' module parameter." 321 "\nSee also the 'double_buffer' module parameter."
322 "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV) 322 "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV)
323 " for every device." 323 " for every device."
324 "\n"); 324 "\n");
325MODULE_PARM_DESC(backlight, 325MODULE_PARM_DESC(backlight,
326 "\n<0|1[,...]> Objects are lit from behind:" 326 "\n<0|1[,...]> Objects are lit from behind:"
327 "\n 0 = no, 1 = yes" 327 "\n 0 = no, 1 = yes"
328 "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT) 328 "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT)
329 " for every device." 329 " for every device."
330 "\n"); 330 "\n");
331MODULE_PARM_DESC(mirror, 331MODULE_PARM_DESC(mirror,
332 "\n<0|1[,...]> Reverse image horizontally:" 332 "\n<0|1[,...]> Reverse image horizontally:"
333 "\n 0 = no, 1 = yes" 333 "\n 0 = no, 1 = yes"
334 "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR) 334 "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR)
335 " for every device." 335 " for every device."
336 "\n"); 336 "\n");
337MODULE_PARM_DESC(monochrome, 337MODULE_PARM_DESC(monochrome,
338 "\n<0|1[,...]> Use image sensor as monochrome sensor:" 338 "\n<0|1[,...]> Use image sensor as monochrome sensor:"
339 "\n 0 = no, 1 = yes" 339 "\n 0 = no, 1 = yes"
340 "\nNot all the sensors support monochrome color." 340 "\nNot all the sensors support monochrome color."
341 "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME) 341 "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME)
342 " for every device." 342 " for every device."
343 "\n"); 343 "\n");
344MODULE_PARM_DESC(brightness, 344MODULE_PARM_DESC(brightness,
345 "\n<n[,...]> Set picture brightness (0-65535)." 345 "\n<n[,...]> Set picture brightness (0-65535)."
346 "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS) 346 "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS)
347 " for every device." 347 " for every device."
348 "\nThis parameter has no effect if 'autobright' is enabled." 348 "\nThis parameter has no effect if 'autobright' is enabled."
349 "\n"); 349 "\n");
350MODULE_PARM_DESC(hue, 350MODULE_PARM_DESC(hue,
351 "\n<n[,...]> Set picture hue (0-65535)." 351 "\n<n[,...]> Set picture hue (0-65535)."
352 "\nDefault value is "__MODULE_STRING(W9968CF_HUE) 352 "\nDefault value is "__MODULE_STRING(W9968CF_HUE)
353 " for every device." 353 " for every device."
354 "\n"); 354 "\n");
355MODULE_PARM_DESC(colour, 355MODULE_PARM_DESC(colour,
356 "\n<n[,...]> Set picture saturation (0-65535)." 356 "\n<n[,...]> Set picture saturation (0-65535)."
357 "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR) 357 "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR)
358 " for every device." 358 " for every device."
359 "\n"); 359 "\n");
360MODULE_PARM_DESC(contrast, 360MODULE_PARM_DESC(contrast,
361 "\n<n[,...]> Set picture contrast (0-65535)." 361 "\n<n[,...]> Set picture contrast (0-65535)."
362 "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST) 362 "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST)
363 " for every device." 363 " for every device."
364 "\n"); 364 "\n");
365MODULE_PARM_DESC(whiteness, 365MODULE_PARM_DESC(whiteness,
366 "\n<n[,...]> Set picture whiteness (0-65535)." 366 "\n<n[,...]> Set picture whiteness (0-65535)."
367 "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS) 367 "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS)
368 " for every device." 368 " for every device."
369 "\n"); 369 "\n");
370#ifdef W9968CF_DEBUG 370#ifdef W9968CF_DEBUG
371MODULE_PARM_DESC(debug, 371MODULE_PARM_DESC(debug,
372 "\n<n> Debugging information level, from 0 to 6:" 372 "\n<n> Debugging information level, from 0 to 6:"
373 "\n0 = none (use carefully)" 373 "\n0 = none (use carefully)"
374 "\n1 = critical errors" 374 "\n1 = critical errors"
375 "\n2 = significant informations" 375 "\n2 = significant informations"
376 "\n3 = configuration or general messages" 376 "\n3 = configuration or general messages"
377 "\n4 = warnings" 377 "\n4 = warnings"
378 "\n5 = called functions" 378 "\n5 = called functions"
379 "\n6 = function internals" 379 "\n6 = function internals"
380 "\nLevel 5 and 6 are useful for testing only, when only " 380 "\nLevel 5 and 6 are useful for testing only, when only "
381 "one device is used." 381 "one device is used."
382 "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"." 382 "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"."
383 "\n"); 383 "\n");
384MODULE_PARM_DESC(specific_debug, 384MODULE_PARM_DESC(specific_debug,
385 "\n<0|1> Enable or disable specific debugging messages:" 385 "\n<0|1> Enable or disable specific debugging messages:"
386 "\n0 = print messages concerning every level" 386 "\n0 = print messages concerning every level"
387 " <= 'debug' level." 387 " <= 'debug' level."
388 "\n1 = print messages concerning the level" 388 "\n1 = print messages concerning the level"
389 " indicated by 'debug'." 389 " indicated by 'debug'."
390 "\nDefault value is " 390 "\nDefault value is "
391 __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"." 391 __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"."
392 "\n"); 392 "\n");
393#endif /* W9968CF_DEBUG */ 393#endif /* W9968CF_DEBUG */
394 394
395 395
@@ -406,7 +406,7 @@ static int w9968cf_mmap(struct file*, struct vm_area_struct*);
406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long); 406static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long);
407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*); 407static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*);
408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int, 408static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int,
409 void __user *); 409 void __user *);
410 410
411/* USB-specific */ 411/* USB-specific */
412static int w9968cf_start_transfer(struct w9968cf_device*); 412static int w9968cf_start_transfer(struct w9968cf_device*);
@@ -428,25 +428,25 @@ static int w9968cf_smbus_write_ack(struct w9968cf_device*);
428static int w9968cf_smbus_read_ack(struct w9968cf_device*); 428static int w9968cf_smbus_read_ack(struct w9968cf_device*);
429static int w9968cf_smbus_refresh_bus(struct w9968cf_device*); 429static int w9968cf_smbus_refresh_bus(struct w9968cf_device*);
430static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam, 430static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
431 u16 address, u8* value); 431 u16 address, u8* value);
432static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address, 432static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address,
433 u8 subaddress, u8* value); 433 u8 subaddress, u8* value);
434static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*, 434static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*,
435 u16 address, u8 subaddress); 435 u16 address, u8 subaddress);
436static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*, 436static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*,
437 u16 address, u8 subaddress, 437 u16 address, u8 subaddress,
438 u8 value); 438 u8 value);
439 439
440/* I2C interface to kernel */ 440/* I2C interface to kernel */
441static int w9968cf_i2c_init(struct w9968cf_device*); 441static int w9968cf_i2c_init(struct w9968cf_device*);
442static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr, 442static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr,
443 unsigned short flags, char read_write, 443 unsigned short flags, char read_write,
444 u8 command, int size, union i2c_smbus_data*); 444 u8 command, int size, union i2c_smbus_data*);
445static u32 w9968cf_i2c_func(struct i2c_adapter*); 445static u32 w9968cf_i2c_func(struct i2c_adapter*);
446static int w9968cf_i2c_attach_inform(struct i2c_client*); 446static int w9968cf_i2c_attach_inform(struct i2c_client*);
447static int w9968cf_i2c_detach_inform(struct i2c_client*); 447static int w9968cf_i2c_detach_inform(struct i2c_client*);
448static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd, 448static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd,
449 unsigned long arg); 449 unsigned long arg);
450 450
451/* Memory management */ 451/* Memory management */
452static void* rvmalloc(unsigned long size); 452static void* rvmalloc(unsigned long size);
@@ -458,17 +458,17 @@ static int w9968cf_allocate_memory(struct w9968cf_device*);
458static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val); 458static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val);
459static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val); 459static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val);
460static int w9968cf_sensor_cmd(struct w9968cf_device*, 460static int w9968cf_sensor_cmd(struct w9968cf_device*,
461 unsigned int cmd, void *arg); 461 unsigned int cmd, void *arg);
462static int w9968cf_sensor_init(struct w9968cf_device*); 462static int w9968cf_sensor_init(struct w9968cf_device*);
463static int w9968cf_sensor_update_settings(struct w9968cf_device*); 463static int w9968cf_sensor_update_settings(struct w9968cf_device*);
464static int w9968cf_sensor_get_picture(struct w9968cf_device*); 464static int w9968cf_sensor_get_picture(struct w9968cf_device*);
465static int w9968cf_sensor_update_picture(struct w9968cf_device*, 465static int w9968cf_sensor_update_picture(struct w9968cf_device*,
466 struct video_picture pict); 466 struct video_picture pict);
467 467
468/* Other helper functions */ 468/* Other helper functions */
469static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*, 469static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*,
470 enum w9968cf_model_id, 470 enum w9968cf_model_id,
471 const unsigned short dev_nr); 471 const unsigned short dev_nr);
472static void w9968cf_adjust_configuration(struct w9968cf_device*); 472static void w9968cf_adjust_configuration(struct w9968cf_device*);
473static int w9968cf_turn_on_led(struct w9968cf_device*); 473static int w9968cf_turn_on_led(struct w9968cf_device*);
474static int w9968cf_init_chip(struct w9968cf_device*); 474static int w9968cf_init_chip(struct w9968cf_device*);
@@ -477,8 +477,8 @@ static inline u16 w9968cf_valid_depth(u16 palette);
477static inline u8 w9968cf_need_decompression(u16 palette); 477static inline u8 w9968cf_need_decompression(u16 palette);
478static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture); 478static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture);
479static int w9968cf_set_window(struct w9968cf_device*, struct video_window); 479static int w9968cf_set_window(struct w9968cf_device*, struct video_window);
480static int w9968cf_postprocess_frame(struct w9968cf_device*, 480static int w9968cf_postprocess_frame(struct w9968cf_device*,
481 struct w9968cf_frame_t*); 481 struct w9968cf_frame_t*);
482static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h); 482static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h);
483static void w9968cf_init_framelist(struct w9968cf_device*); 483static void w9968cf_init_framelist(struct w9968cf_device*);
484static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num); 484static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num);
@@ -497,11 +497,11 @@ struct w9968cf_symbolic_list {
497 const char *name; 497 const char *name;
498}; 498};
499 499
500/*-------------------------------------------------------------------------- 500/*--------------------------------------------------------------------------
501 Returns the name of the matching element in the symbolic_list array. The 501 Returns the name of the matching element in the symbolic_list array. The
502 end of the list must be marked with an element that has a NULL name. 502 end of the list must be marked with an element that has a NULL name.
503 --------------------------------------------------------------------------*/ 503 --------------------------------------------------------------------------*/
504static inline const char * 504static inline const char *
505symbolic(struct w9968cf_symbolic_list list[], const int num) 505symbolic(struct w9968cf_symbolic_list list[], const int num)
506{ 506{
507 int i; 507 int i;
@@ -568,7 +568,7 @@ static struct w9968cf_symbolic_list v4l1_plist[] = {
568static struct w9968cf_symbolic_list decoder_errlist[] = { 568static struct w9968cf_symbolic_list decoder_errlist[] = {
569 { W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" }, 569 { W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" },
570 { W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" }, 570 { W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" },
571 { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" }, 571 { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" },
572 { W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" }, 572 { W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" },
573 { W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" }, 573 { W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" },
574 { W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" }, 574 { W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" },
@@ -695,7 +695,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
695 bpp = (w9968cf_vpp) ? 4 : 2; 695 bpp = (w9968cf_vpp) ? 4 : 2;
696 if (cam->upscaling) 696 if (cam->upscaling)
697 vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp, 697 vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp,
698 cam->maxwidth*cam->maxheight*bpp); 698 cam->maxwidth*cam->maxheight*bpp);
699 else 699 else
700 vpp_bufsize = cam->maxwidth*cam->maxheight*bpp; 700 vpp_bufsize = cam->maxwidth*cam->maxheight*bpp;
701 701
@@ -704,7 +704,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
704 if (!(cam->transfer_buffer[i] = 704 if (!(cam->transfer_buffer[i] =
705 kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) { 705 kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) {
706 DBG(1, "Couldn't allocate memory for the isochronous " 706 DBG(1, "Couldn't allocate memory for the isochronous "
707 "transfer buffers (%u bytes)", 707 "transfer buffers (%u bytes)",
708 p_size * W9968CF_ISO_PACKETS) 708 p_size * W9968CF_ISO_PACKETS)
709 return -ENOMEM; 709 return -ENOMEM;
710 } 710 }
@@ -780,7 +780,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
780 of the next video frame; if an error is encountered in a packet, the entire 780 of the next video frame; if an error is encountered in a packet, the entire
781 video frame is discarded and grabbed again. 781 video frame is discarded and grabbed again.
782 If there are no requested frames in the FIFO list, packets are collected into 782 If there are no requested frames in the FIFO list, packets are collected into
783 a temporary buffer. 783 a temporary buffer.
784 --------------------------------------------------------------------------*/ 784 --------------------------------------------------------------------------*/
785static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs) 785static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
786{ 786{
@@ -799,7 +799,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
799 /* "(*f)" will be used instead of "cam->frame_current" */ 799 /* "(*f)" will be used instead of "cam->frame_current" */
800 f = &cam->frame_current; 800 f = &cam->frame_current;
801 801
802 /* If a frame has been requested and we are grabbing into 802 /* If a frame has been requested and we are grabbing into
803 the temporary frame, we'll switch to that requested frame */ 803 the temporary frame, we'll switch to that requested frame */
804 if ((*f) == &cam->frame_tmp && *cam->requested_frame) { 804 if ((*f) == &cam->frame_tmp && *cam->requested_frame) {
805 if (cam->frame_tmp.status == F_GRABBING) { 805 if (cam->frame_tmp.status == F_GRABBING) {
@@ -808,7 +808,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
808 (*f)->length = cam->frame_tmp.length; 808 (*f)->length = cam->frame_tmp.length;
809 memcpy((*f)->buffer, cam->frame_tmp.buffer, 809 memcpy((*f)->buffer, cam->frame_tmp.buffer,
810 (*f)->length); 810 (*f)->length);
811 DBG(6, "Switched from temp. frame to frame #%d", 811 DBG(6, "Switched from temp. frame to frame #%d",
812 (*f)->number) 812 (*f)->number)
813 } 813 }
814 } 814 }
@@ -850,7 +850,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
850 850
851 if (cam->vpp_flag & VPP_DECOMPRESSION) { 851 if (cam->vpp_flag & VPP_DECOMPRESSION) {
852 err = w9968cf_vpp->check_headers((*f)->buffer, 852 err = w9968cf_vpp->check_headers((*f)->buffer,
853 (*f)->length); 853 (*f)->length);
854 if (err) { 854 if (err) {
855 DBG(4, "Skip corrupted frame: %s", 855 DBG(4, "Skip corrupted frame: %s",
856 symbolic(decoder_errlist, err)) 856 symbolic(decoder_errlist, err))
@@ -975,7 +975,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
975 cam->frame_current = &cam->frame_tmp; 975 cam->frame_current = &cam->frame_tmp;
976 976
977 if (!(cam->vpp_flag & VPP_DECOMPRESSION)) 977 if (!(cam->vpp_flag & VPP_DECOMPRESSION))
978 DBG(5, "Isochronous transfer size: %lu bytes/frame", 978 DBG(5, "Isochronous transfer size: %lu bytes/frame",
979 (unsigned long)t_size*2) 979 (unsigned long)t_size*2)
980 980
981 DBG(5, "Starting the isochronous transfer...") 981 DBG(5, "Starting the isochronous transfer...")
@@ -992,7 +992,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
992 usb_free_urb(cam->urb[j]); 992 usb_free_urb(cam->urb[j]);
993 } 993 }
994 DBG(1, "Couldn't send a transfer request to the " 994 DBG(1, "Couldn't send a transfer request to the "
995 "USB core (error #%d, %s)", err, 995 "USB core (error #%d, %s)", err,
996 symbolic(urb_errlist, err)) 996 symbolic(urb_errlist, err))
997 return err; 997 return err;
998 } 998 }
@@ -1016,7 +1016,7 @@ static int w9968cf_stop_transfer(struct w9968cf_device* cam)
1016 if (!cam->streaming) 1016 if (!cam->streaming)
1017 return 0; 1017 return 0;
1018 1018
1019 /* This avoids race conditions with usb_submit_urb() 1019 /* This avoids race conditions with usb_submit_urb()
1020 in the URB completition handler */ 1020 in the URB completition handler */
1021 spin_lock_irqsave(&cam->urb_lock, lock_flags); 1021 spin_lock_irqsave(&cam->urb_lock, lock_flags);
1022 cam->streaming = 0; 1022 cam->streaming = 0;
@@ -1050,7 +1050,7 @@ exit:
1050 1050
1051 1051
1052/*-------------------------------------------------------------------------- 1052/*--------------------------------------------------------------------------
1053 Write a W9968CF register. 1053 Write a W9968CF register.
1054 Return 0 on success, -1 otherwise. 1054 Return 0 on success, -1 otherwise.
1055 --------------------------------------------------------------------------*/ 1055 --------------------------------------------------------------------------*/
1056static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index) 1056static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
@@ -1059,8 +1059,8 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
1059 int res; 1059 int res;
1060 1060
1061 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 1061 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
1062 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 1062 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
1063 value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT); 1063 value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT);
1064 1064
1065 if (res < 0) 1065 if (res < 0)
1066 DBG(4, "Failed to write a register " 1066 DBG(4, "Failed to write a register "
@@ -1072,7 +1072,7 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
1072 1072
1073 1073
1074/*-------------------------------------------------------------------------- 1074/*--------------------------------------------------------------------------
1075 Read a W9968CF register. 1075 Read a W9968CF register.
1076 Return the register value on success, -1 otherwise. 1076 Return the register value on success, -1 otherwise.
1077 --------------------------------------------------------------------------*/ 1077 --------------------------------------------------------------------------*/
1078static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index) 1078static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index)
@@ -1082,8 +1082,8 @@ static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index)
1082 int res; 1082 int res;
1083 1083
1084 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1, 1084 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1,
1085 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 1085 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
1086 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT); 1086 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT);
1087 1087
1088 if (res < 0) 1088 if (res < 0)
1089 DBG(4, "Failed to read a register " 1089 DBG(4, "Failed to read a register "
@@ -1107,8 +1107,8 @@ static int w9968cf_write_fsb(struct w9968cf_device* cam, u16* data)
1107 value = *data++; 1107 value = *data++;
1108 1108
1109 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0, 1109 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
1110 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 1110 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
1111 value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT); 1111 value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT);
1112 1112
1113 if (res < 0) 1113 if (res < 0)
1114 DBG(4, "Failed to write the FSB registers " 1114 DBG(4, "Failed to write the FSB registers "
@@ -1287,9 +1287,9 @@ static int w9968cf_smbus_refresh_bus(struct w9968cf_device* cam)
1287 1287
1288 1288
1289/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ 1289/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */
1290static int 1290static int
1291w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam, 1291w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1292 u16 address, u8 subaddress,u8 value) 1292 u16 address, u8 subaddress,u8 value)
1293{ 1293{
1294 u16* data = cam->data_buffer; 1294 u16* data = cam->data_buffer;
1295 int err = 0; 1295 int err = 0;
@@ -1348,7 +1348,7 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1348 "value 0x%02X", address, subaddress, value) 1348 "value 0x%02X", address, subaddress, value)
1349 else 1349 else
1350 DBG(5, "I2C write byte data failed, addr.0x%04X, " 1350 DBG(5, "I2C write byte data failed, addr.0x%04X, "
1351 "subaddr.0x%02X, value 0x%02X", 1351 "subaddr.0x%02X, value 0x%02X",
1352 address, subaddress, value) 1352 address, subaddress, value)
1353 1353
1354 return err; 1354 return err;
@@ -1356,10 +1356,10 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
1356 1356
1357 1357
1358/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ 1358/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */
1359static int 1359static int
1360w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam, 1360w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1361 u16 address, u8 subaddress, 1361 u16 address, u8 subaddress,
1362 u8* value) 1362 u8* value)
1363{ 1363{
1364 int err = 0; 1364 int err = 0;
1365 1365
@@ -1384,7 +1384,7 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1384 1384
1385 if (!err) 1385 if (!err)
1386 DBG(5, "I2C read byte data done, addr.0x%04X, " 1386 DBG(5, "I2C read byte data done, addr.0x%04X, "
1387 "subaddr.0x%02X, value 0x%02X", 1387 "subaddr.0x%02X, value 0x%02X",
1388 address, subaddress, *value) 1388 address, subaddress, *value)
1389 else 1389 else
1390 DBG(5, "I2C read byte data failed, addr.0x%04X, " 1390 DBG(5, "I2C read byte data failed, addr.0x%04X, "
@@ -1396,9 +1396,9 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
1396 1396
1397 1397
1398/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */ 1398/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */
1399static int 1399static int
1400w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam, 1400w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1401 u16 address, u8* value) 1401 u16 address, u8* value)
1402{ 1402{
1403 int err = 0; 1403 int err = 0;
1404 1404
@@ -1411,7 +1411,7 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1411 err += w9968cf_smbus_read_byte(cam, value); 1411 err += w9968cf_smbus_read_byte(cam, value);
1412 err += w9968cf_smbus_write_ack(cam); 1412 err += w9968cf_smbus_write_ack(cam);
1413 err += w9968cf_smbus_stop(cam); 1413 err += w9968cf_smbus_stop(cam);
1414 1414
1415 /* Serial data disable */ 1415 /* Serial data disable */
1416 err += w9968cf_write_sb(cam, 0x0000); 1416 err += w9968cf_write_sb(cam, 0x0000);
1417 1417
@@ -1427,9 +1427,9 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
1427 1427
1428 1428
1429/* SMBus protocol: S Addr Wr [A] Value [A] P */ 1429/* SMBus protocol: S Addr Wr [A] Value [A] P */
1430static int 1430static int
1431w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam, 1431w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
1432 u16 address, u8 value) 1432 u16 address, u8 value)
1433{ 1433{
1434 DBG(4, "i2c_write_byte() is an unsupported transfer mode") 1434 DBG(4, "i2c_write_byte() is an unsupported transfer mode")
1435 return -EINVAL; 1435 return -EINVAL;
@@ -1442,13 +1442,13 @@ w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
1442 ****************************************************************************/ 1442 ****************************************************************************/
1443 1443
1444static int 1444static int
1445w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, 1445w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
1446 unsigned short flags, char read_write, u8 command, 1446 unsigned short flags, char read_write, u8 command,
1447 int size, union i2c_smbus_data *data) 1447 int size, union i2c_smbus_data *data)
1448{ 1448{
1449 struct w9968cf_device* cam = i2c_get_adapdata(adapter); 1449 struct w9968cf_device* cam = i2c_get_adapdata(adapter);
1450 u8 i; 1450 u8 i;
1451 int err = 0; 1451 int err = 0;
1452 1452
1453 switch (addr) { 1453 switch (addr) {
1454 case OV6xx0_SID: 1454 case OV6xx0_SID:
@@ -1464,20 +1464,20 @@ w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
1464 addr <<= 1; 1464 addr <<= 1;
1465 1465
1466 if (read_write == I2C_SMBUS_WRITE) 1466 if (read_write == I2C_SMBUS_WRITE)
1467 err = w9968cf_i2c_adap_write_byte(cam, addr, command); 1467 err = w9968cf_i2c_adap_write_byte(cam, addr, command);
1468 else if (read_write == I2C_SMBUS_READ) 1468 else if (read_write == I2C_SMBUS_READ)
1469 err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte); 1469 err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte);
1470 1470
1471 } else if (size == I2C_SMBUS_BYTE_DATA) { 1471 } else if (size == I2C_SMBUS_BYTE_DATA) {
1472 addr <<= 1; 1472 addr <<= 1;
1473 1473
1474 if (read_write == I2C_SMBUS_WRITE) 1474 if (read_write == I2C_SMBUS_WRITE)
1475 err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr, 1475 err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr,
1476 command, data->byte); 1476 command, data->byte);
1477 else if (read_write == I2C_SMBUS_READ) { 1477 else if (read_write == I2C_SMBUS_READ) {
1478 for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) { 1478 for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) {
1479 err = w9968cf_i2c_adap_read_byte_data(cam,addr, 1479 err = w9968cf_i2c_adap_read_byte_data(cam,addr,
1480 command, &data->byte); 1480 command, &data->byte);
1481 if (err) { 1481 if (err) {
1482 if (w9968cf_smbus_refresh_bus(cam)) { 1482 if (w9968cf_smbus_refresh_bus(cam)) {
1483 err = -EIO; 1483 err = -EIO;
@@ -1520,7 +1520,7 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1520 return err; 1520 return err;
1521 } 1521 }
1522 } else { 1522 } else {
1523 DBG(4, "Rejected client [%s] with driver [%s]", 1523 DBG(4, "Rejected client [%s] with driver [%s]",
1524 client->name, client->driver->driver.name) 1524 client->name, client->driver->driver.name)
1525 return -EINVAL; 1525 return -EINVAL;
1526 } 1526 }
@@ -1545,9 +1545,9 @@ static int w9968cf_i2c_detach_inform(struct i2c_client* client)
1545} 1545}
1546 1546
1547 1547
1548static int 1548static int
1549w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd, 1549w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd,
1550 unsigned long arg) 1550 unsigned long arg)
1551{ 1551{
1552 return 0; 1552 return 0;
1553} 1553}
@@ -1625,12 +1625,12 @@ static int w9968cf_turn_on_led(struct w9968cf_device* cam)
1625static int w9968cf_init_chip(struct w9968cf_device* cam) 1625static int w9968cf_init_chip(struct w9968cf_device* cam)
1626{ 1626{
1627 unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2, 1627 unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2,
1628 y0 = 0x0000, 1628 y0 = 0x0000,
1629 u0 = y0 + hw_bufsize/2, 1629 u0 = y0 + hw_bufsize/2,
1630 v0 = u0 + hw_bufsize/4, 1630 v0 = u0 + hw_bufsize/4,
1631 y1 = v0 + hw_bufsize/4, 1631 y1 = v0 + hw_bufsize/4,
1632 u1 = y1 + hw_bufsize/2, 1632 u1 = y1 + hw_bufsize/2,
1633 v1 = u1 + hw_bufsize/4; 1633 v1 = u1 + hw_bufsize/4;
1634 int err = 0; 1634 int err = 0;
1635 1635
1636 err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */ 1636 err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */
@@ -1762,7 +1762,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
1762 cam->vpp_flag = VPP_SWAP_YUV_BYTES; 1762 cam->vpp_flag = VPP_SWAP_YUV_BYTES;
1763 hw_palette = VIDEO_PALETTE_UYVY; 1763 hw_palette = VIDEO_PALETTE_UYVY;
1764 break; 1764 break;
1765 /* Original video is used instead of RGBX palettes. 1765 /* Original video is used instead of RGBX palettes.
1766 Software conversion later. */ 1766 Software conversion later. */
1767 case VIDEO_PALETTE_GREY: 1767 case VIDEO_PALETTE_GREY:
1768 case VIDEO_PALETTE_RGB555: 1768 case VIDEO_PALETTE_RGB555:
@@ -1777,7 +1777,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
1777 } 1777 }
1778 1778
1779 /* NOTE: due to memory issues, it is better to disable the hardware 1779 /* NOTE: due to memory issues, it is better to disable the hardware
1780 double buffering during compression */ 1780 double buffering during compression */
1781 if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION)) 1781 if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION))
1782 reg_v |= 0x0080; 1782 reg_v |= 0x0080;
1783 1783
@@ -1832,8 +1832,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1832 #define __UNSC(x) ((x) >> 10) 1832 #define __UNSC(x) ((x) >> 10)
1833 1833
1834 /* Make sure we are using a supported resolution */ 1834 /* Make sure we are using a supported resolution */
1835 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 1835 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
1836 (u16*)&win.height))) 1836 (u16*)&win.height)))
1837 goto error; 1837 goto error;
1838 1838
1839 /* Scaling factors */ 1839 /* Scaling factors */
@@ -1962,7 +1962,7 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
1962 /* Settings changed, so we clear the frame buffers */ 1962 /* Settings changed, so we clear the frame buffers */
1963 memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size); 1963 memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size);
1964 1964
1965 DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)", 1965 DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)",
1966 win.width, win.height, win.x, win.y) 1966 win.width, win.height, win.x, win.y)
1967 1967
1968 PDBGG("x=%u ,y=%u, w=%u, h=%u, ax=%u, ay=%u, s_win.x=%u, s_win.y=%u, " 1968 PDBGG("x=%u ,y=%u, w=%u, h=%u, ax=%u, ay=%u, s_win.x=%u, s_win.y=%u, "
@@ -1978,11 +1978,11 @@ error:
1978} 1978}
1979 1979
1980 1980
1981/*-------------------------------------------------------------------------- 1981/*--------------------------------------------------------------------------
1982 Adjust the asked values for window width and height. 1982 Adjust the asked values for window width and height.
1983 Return 0 on success, -1 otherwise. 1983 Return 0 on success, -1 otherwise.
1984 --------------------------------------------------------------------------*/ 1984 --------------------------------------------------------------------------*/
1985static int 1985static int
1986w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height) 1986w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
1987{ 1987{
1988 u16 maxw, maxh; 1988 u16 maxw, maxh;
@@ -1992,10 +1992,10 @@ w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
1992 1992
1993 maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && 1993 maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
1994 w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 1994 w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
1995 : cam->maxwidth; 1995 : cam->maxwidth;
1996 maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && 1996 maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
1997 w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) 1997 w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
1998 : cam->maxheight; 1998 : cam->maxheight;
1999 1999
2000 if (*width > maxw) 2000 if (*width > maxw)
2001 *width = maxw; 2001 *width = maxw;
@@ -2054,7 +2054,7 @@ static void w9968cf_push_frame(struct w9968cf_device* cam, u8 f_num)
2054 Read, store and remove the first pointer in the FIFO list of requested 2054 Read, store and remove the first pointer in the FIFO list of requested
2055 frames. This function is called in interrupt context. 2055 frames. This function is called in interrupt context.
2056 --------------------------------------------------------------------------*/ 2056 --------------------------------------------------------------------------*/
2057static void 2057static void
2058w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep) 2058w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
2059{ 2059{
2060 u8 i; 2060 u8 i;
@@ -2078,9 +2078,9 @@ w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
2078 High-level video post-processing routine on grabbed frames. 2078 High-level video post-processing routine on grabbed frames.
2079 Return 0 on success, a negative number otherwise. 2079 Return 0 on success, a negative number otherwise.
2080 --------------------------------------------------------------------------*/ 2080 --------------------------------------------------------------------------*/
2081static int 2081static int
2082w9968cf_postprocess_frame(struct w9968cf_device* cam, 2082w9968cf_postprocess_frame(struct w9968cf_device* cam,
2083 struct w9968cf_frame_t* fr) 2083 struct w9968cf_frame_t* fr)
2084{ 2084{
2085 void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp; 2085 void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp;
2086 u16 w = cam->window.width, 2086 u16 w = cam->window.width,
@@ -2127,7 +2127,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
2127 w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb); 2127 w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb);
2128 fr->length = (w*h*d)/8; 2128 fr->length = (w*h*d)/8;
2129 _PSWAP(pIn, pOut) 2129 _PSWAP(pIn, pOut)
2130 DBG(6, "UYVY-16bit to %s conversion done", 2130 DBG(6, "UYVY-16bit to %s conversion done",
2131 symbolic(v4l1_plist, fmt)) 2131 symbolic(v4l1_plist, fmt))
2132 } 2132 }
2133 2133
@@ -2143,7 +2143,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
2143 * Image sensor control routines * 2143 * Image sensor control routines *
2144 ****************************************************************************/ 2144 ****************************************************************************/
2145 2145
2146static int 2146static int
2147w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val) 2147w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
2148{ 2148{
2149 struct ovcamchip_control ctl; 2149 struct ovcamchip_control ctl;
@@ -2158,7 +2158,7 @@ w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
2158} 2158}
2159 2159
2160 2160
2161static int 2161static int
2162w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val) 2162w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val)
2163{ 2163{
2164 struct ovcamchip_control ctl; 2164 struct ovcamchip_control ctl;
@@ -2198,38 +2198,38 @@ static int w9968cf_sensor_update_settings(struct w9968cf_device* cam)
2198 int err = 0; 2198 int err = 0;
2199 2199
2200 /* Auto brightness */ 2200 /* Auto brightness */
2201 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT, 2201 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT,
2202 cam->auto_brt); 2202 cam->auto_brt);
2203 if (err) 2203 if (err)
2204 return err; 2204 return err;
2205 2205
2206 /* Auto exposure */ 2206 /* Auto exposure */
2207 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP, 2207 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP,
2208 cam->auto_exp); 2208 cam->auto_exp);
2209 if (err) 2209 if (err)
2210 return err; 2210 return err;
2211 2211
2212 /* Banding filter */ 2212 /* Banding filter */
2213 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT, 2213 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT,
2214 cam->bandfilt); 2214 cam->bandfilt);
2215 if (err) 2215 if (err)
2216 return err; 2216 return err;
2217 2217
2218 /* Light frequency */ 2218 /* Light frequency */
2219 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ, 2219 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ,
2220 cam->lightfreq); 2220 cam->lightfreq);
2221 if (err) 2221 if (err)
2222 return err; 2222 return err;
2223 2223
2224 /* Back light */ 2224 /* Back light */
2225 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT, 2225 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT,
2226 cam->backlight); 2226 cam->backlight);
2227 if (err) 2227 if (err)
2228 return err; 2228 return err;
2229 2229
2230 /* Mirror */ 2230 /* Mirror */
2231 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR, 2231 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR,
2232 cam->mirror); 2232 cam->mirror);
2233 if (err) 2233 if (err)
2234 return err; 2234 return err;
2235 2235
@@ -2281,15 +2281,15 @@ static int w9968cf_sensor_get_picture(struct w9968cf_device* cam)
2281 Returns: 0 on success, a negative number otherwise. 2281 Returns: 0 on success, a negative number otherwise.
2282 --------------------------------------------------------------------------*/ 2282 --------------------------------------------------------------------------*/
2283static int 2283static int
2284w9968cf_sensor_update_picture(struct w9968cf_device* cam, 2284w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2285 struct video_picture pict) 2285 struct video_picture pict)
2286{ 2286{
2287 int err = 0; 2287 int err = 0;
2288 2288
2289 if ((!cam->sensor_initialized) 2289 if ((!cam->sensor_initialized)
2290 || pict.contrast != cam->picture.contrast) { 2290 || pict.contrast != cam->picture.contrast) {
2291 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT, 2291 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT,
2292 pict.contrast); 2292 pict.contrast);
2293 if (err) 2293 if (err)
2294 goto fail; 2294 goto fail;
2295 DBG(4, "Contrast changed from %u to %u", 2295 DBG(4, "Contrast changed from %u to %u",
@@ -2297,10 +2297,10 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2297 cam->picture.contrast = pict.contrast; 2297 cam->picture.contrast = pict.contrast;
2298 } 2298 }
2299 2299
2300 if (((!cam->sensor_initialized) || 2300 if (((!cam->sensor_initialized) ||
2301 pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) { 2301 pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) {
2302 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT, 2302 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT,
2303 pict.brightness); 2303 pict.brightness);
2304 if (err) 2304 if (err)
2305 goto fail; 2305 goto fail;
2306 DBG(4, "Brightness changed from %u to %u", 2306 DBG(4, "Brightness changed from %u to %u",
@@ -2309,8 +2309,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2309 } 2309 }
2310 2310
2311 if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) { 2311 if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) {
2312 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT, 2312 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT,
2313 pict.colour); 2313 pict.colour);
2314 if (err) 2314 if (err)
2315 goto fail; 2315 goto fail;
2316 DBG(4, "Colour changed from %u to %u", 2316 DBG(4, "Colour changed from %u to %u",
@@ -2319,8 +2319,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
2319 } 2319 }
2320 2320
2321 if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) { 2321 if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) {
2322 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE, 2322 err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE,
2323 pict.hue); 2323 pict.hue);
2324 if (err) 2324 if (err)
2325 goto fail; 2325 goto fail;
2326 DBG(4, "Hue changed from %u to %u", 2326 DBG(4, "Hue changed from %u to %u",
@@ -2349,12 +2349,12 @@ static int w9968cf_sensor_init(struct w9968cf_device* cam)
2349{ 2349{
2350 int err = 0; 2350 int err = 0;
2351 2351
2352 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE, 2352 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE,
2353 &cam->monochrome))) 2353 &cam->monochrome)))
2354 goto error; 2354 goto error;
2355 2355
2356 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE, 2356 if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE,
2357 &cam->sensor))) 2357 &cam->sensor)))
2358 goto error; 2358 goto error;
2359 2359
2360 /* NOTE: Make sure width and height are a multiple of 16 */ 2360 /* NOTE: Make sure width and height are a multiple of 16 */
@@ -2416,14 +2416,14 @@ error:
2416 2416
2417/*-------------------------------------------------------------------------- 2417/*--------------------------------------------------------------------------
2418 Fill some basic fields in the main device data structure. 2418 Fill some basic fields in the main device data structure.
2419 This function is called once on w9968cf_usb_probe() for each recognized 2419 This function is called once on w9968cf_usb_probe() for each recognized
2420 camera. 2420 camera.
2421 --------------------------------------------------------------------------*/ 2421 --------------------------------------------------------------------------*/
2422static void 2422static void
2423w9968cf_configure_camera(struct w9968cf_device* cam, 2423w9968cf_configure_camera(struct w9968cf_device* cam,
2424 struct usb_device* udev, 2424 struct usb_device* udev,
2425 enum w9968cf_model_id mod_id, 2425 enum w9968cf_model_id mod_id,
2426 const unsigned short dev_nr) 2426 const unsigned short dev_nr)
2427{ 2427{
2428 mutex_init(&cam->fileop_mutex); 2428 mutex_init(&cam->fileop_mutex);
2429 init_waitqueue_head(&cam->open); 2429 init_waitqueue_head(&cam->open);
@@ -2444,60 +2444,60 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2444 packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1]; 2444 packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1];
2445 cam->altsetting++); 2445 cam->altsetting++);
2446 2446
2447 cam->max_buffers = (max_buffers[dev_nr] < 2 || 2447 cam->max_buffers = (max_buffers[dev_nr] < 2 ||
2448 max_buffers[dev_nr] > W9968CF_MAX_BUFFERS) 2448 max_buffers[dev_nr] > W9968CF_MAX_BUFFERS)
2449 ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr]; 2449 ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr];
2450 2450
2451 cam->double_buffer = (double_buffer[dev_nr] == 0 || 2451 cam->double_buffer = (double_buffer[dev_nr] == 0 ||
2452 double_buffer[dev_nr] == 1) 2452 double_buffer[dev_nr] == 1)
2453 ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER; 2453 ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER;
2454 2454
2455 cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1) 2455 cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1)
2456 ? (u8)clamping[dev_nr] : W9968CF_CLAMPING; 2456 ? (u8)clamping[dev_nr] : W9968CF_CLAMPING;
2457 2457
2458 cam->filter_type = (filter_type[dev_nr] == 0 || 2458 cam->filter_type = (filter_type[dev_nr] == 0 ||
2459 filter_type[dev_nr] == 1 || 2459 filter_type[dev_nr] == 1 ||
2460 filter_type[dev_nr] == 2) 2460 filter_type[dev_nr] == 2)
2461 ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE; 2461 ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE;
2462 2462
2463 cam->capture = 1; 2463 cam->capture = 1;
2464 2464
2465 cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1) 2465 cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1)
2466 ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW; 2466 ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW;
2467 2467
2468 cam->decompression = (decompression[dev_nr] == 0 || 2468 cam->decompression = (decompression[dev_nr] == 0 ||
2469 decompression[dev_nr] == 1 || 2469 decompression[dev_nr] == 1 ||
2470 decompression[dev_nr] == 2) 2470 decompression[dev_nr] == 2)
2471 ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION; 2471 ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION;
2472 2472
2473 cam->upscaling = (upscaling[dev_nr] == 0 || 2473 cam->upscaling = (upscaling[dev_nr] == 0 ||
2474 upscaling[dev_nr] == 1) 2474 upscaling[dev_nr] == 1)
2475 ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING; 2475 ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING;
2476 2476
2477 cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1) 2477 cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1)
2478 ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT; 2478 ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT;
2479 2479
2480 cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1) 2480 cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1)
2481 ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP; 2481 ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP;
2482 2482
2483 cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60) 2483 cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60)
2484 ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ; 2484 ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ;
2485 2485
2486 cam->bandfilt = (bandingfilter[dev_nr] == 0 || 2486 cam->bandfilt = (bandingfilter[dev_nr] == 0 ||
2487 bandingfilter[dev_nr] == 1) 2487 bandingfilter[dev_nr] == 1)
2488 ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER; 2488 ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER;
2489 2489
2490 cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1) 2490 cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1)
2491 ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT; 2491 ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT;
2492 2492
2493 cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0) 2493 cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0)
2494 ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV; 2494 ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV;
2495 2495
2496 cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1) 2496 cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1)
2497 ? (u8)mirror[dev_nr] : W9968CF_MIRROR; 2497 ? (u8)mirror[dev_nr] : W9968CF_MIRROR;
2498 2498
2499 cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1) 2499 cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1)
2500 ? monochrome[dev_nr] : W9968CF_MONOCHROME; 2500 ? monochrome[dev_nr] : W9968CF_MONOCHROME;
2501 2501
2502 cam->picture.brightness = (u16)brightness[dev_nr]; 2502 cam->picture.brightness = (u16)brightness[dev_nr];
2503 cam->picture.hue = (u16)hue[dev_nr]; 2503 cam->picture.hue = (u16)hue[dev_nr];
@@ -2519,7 +2519,7 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2519 cam->picture.depth = w9968cf_valid_depth(cam->picture.palette); 2519 cam->picture.depth = w9968cf_valid_depth(cam->picture.palette);
2520 2520
2521 cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1) 2521 cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1)
2522 ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB; 2522 ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB;
2523 2523
2524 cam->window.x = 0; 2524 cam->window.x = 0;
2525 cam->window.y = 0; 2525 cam->window.y = 0;
@@ -2531,16 +2531,16 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
2531 2531
2532 DBG(3, "%s configured with settings #%u:", 2532 DBG(3, "%s configured with settings #%u:",
2533 symbolic(camlist, cam->id), dev_nr) 2533 symbolic(camlist, cam->id), dev_nr)
2534 2534
2535 DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes", 2535 DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes",
2536 wMaxPacketSize[cam->altsetting-1]) 2536 wMaxPacketSize[cam->altsetting-1])
2537 2537
2538 DBG(3, "- Number of requested video frame buffers: %u", 2538 DBG(3, "- Number of requested video frame buffers: %u",
2539 cam->max_buffers) 2539 cam->max_buffers)
2540 2540
2541 if (cam->double_buffer) 2541 if (cam->double_buffer)
2542 DBG(3, "- Hardware double buffering enabled") 2542 DBG(3, "- Hardware double buffering enabled")
2543 else 2543 else
2544 DBG(3, "- Hardware double buffering disabled") 2544 DBG(3, "- Hardware double buffering disabled")
2545 2545
2546 if (cam->filter_type == 0) 2546 if (cam->filter_type == 0)
@@ -2648,7 +2648,7 @@ static void w9968cf_adjust_configuration(struct w9968cf_device* cam)
2648 2648
2649/*-------------------------------------------------------------------------- 2649/*--------------------------------------------------------------------------
2650 Release the resources used by the driver. 2650 Release the resources used by the driver.
2651 This function is called on disconnect 2651 This function is called on disconnect
2652 (or on close if deallocation has been deferred) 2652 (or on close if deallocation has been deferred)
2653 --------------------------------------------------------------------------*/ 2653 --------------------------------------------------------------------------*/
2654static void w9968cf_release_resources(struct w9968cf_device* cam) 2654static void w9968cf_release_resources(struct w9968cf_device* cam)
@@ -2706,8 +2706,8 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
2706 } 2706 }
2707 mutex_unlock(&cam->dev_mutex); 2707 mutex_unlock(&cam->dev_mutex);
2708 err = wait_event_interruptible_exclusive(cam->open, 2708 err = wait_event_interruptible_exclusive(cam->open,
2709 cam->disconnected || 2709 cam->disconnected ||
2710 !cam->users); 2710 !cam->users);
2711 if (err) { 2711 if (err) {
2712 up_read(&w9968cf_disconnect); 2712 up_read(&w9968cf_disconnect);
2713 return err; 2713 return err;
@@ -2820,9 +2820,9 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
2820 w9968cf_push_frame(cam, 1); 2820 w9968cf_push_frame(cam, 1);
2821 2821
2822 err = wait_event_interruptible(cam->wait_queue, 2822 err = wait_event_interruptible(cam->wait_queue,
2823 cam->frame[0].status == F_READY || 2823 cam->frame[0].status == F_READY ||
2824 cam->frame[1].status == F_READY || 2824 cam->frame[1].status == F_READY ||
2825 cam->disconnected); 2825 cam->disconnected);
2826 if (err) { 2826 if (err) {
2827 mutex_unlock(&cam->fileop_mutex); 2827 mutex_unlock(&cam->fileop_mutex);
2828 return err; 2828 return err;
@@ -2859,12 +2859,12 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
2859static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma) 2859static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2860{ 2860{
2861 struct w9968cf_device* cam = (struct w9968cf_device*) 2861 struct w9968cf_device* cam = (struct w9968cf_device*)
2862 video_get_drvdata(video_devdata(filp)); 2862 video_get_drvdata(video_devdata(filp));
2863 unsigned long vsize = vma->vm_end - vma->vm_start, 2863 unsigned long vsize = vma->vm_end - vma->vm_start,
2864 psize = cam->nbuffers * cam->frame[0].size, 2864 psize = cam->nbuffers * cam->frame[0].size,
2865 start = vma->vm_start, 2865 start = vma->vm_start,
2866 pos = (unsigned long)cam->frame[0].buffer, 2866 pos = (unsigned long)cam->frame[0].buffer,
2867 page; 2867 page;
2868 2868
2869 if (cam->disconnected) { 2869 if (cam->disconnected) {
2870 DBG(2, "Device not present") 2870 DBG(2, "Device not present")
@@ -2898,7 +2898,7 @@ static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
2898 2898
2899static int 2899static int
2900w9968cf_ioctl(struct inode* inode, struct file* filp, 2900w9968cf_ioctl(struct inode* inode, struct file* filp,
2901 unsigned int cmd, unsigned long arg) 2901 unsigned int cmd, unsigned long arg)
2902{ 2902{
2903 struct w9968cf_device* cam; 2903 struct w9968cf_device* cam;
2904 int err; 2904 int err;
@@ -2928,21 +2928,21 @@ w9968cf_ioctl(struct inode* inode, struct file* filp,
2928 2928
2929 2929
2930static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp, 2930static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2931 unsigned int cmd, void __user * arg) 2931 unsigned int cmd, void __user * arg)
2932{ 2932{
2933 struct w9968cf_device* cam; 2933 struct w9968cf_device* cam;
2934 const char* v4l1_ioctls[] = { 2934 const char* v4l1_ioctls[] = {
2935 "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", 2935 "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER",
2936 "GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF", 2936 "GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF",
2937 "SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO", 2937 "SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO",
2938 "SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE", 2938 "SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE",
2939 "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE", 2939 "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE",
2940 "GVBIFMT", "SVBIFMT" 2940 "GVBIFMT", "SVBIFMT"
2941 }; 2941 };
2942 2942
2943 #define V4L1_IOCTL(cmd) \ 2943 #define V4L1_IOCTL(cmd) \
2944 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \ 2944 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
2945 v4l1_ioctls[_IOC_NR((cmd))] : "?") 2945 v4l1_ioctls[_IOC_NR((cmd))] : "?")
2946 2946
2947 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); 2947 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
2948 2948
@@ -2957,14 +2957,14 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2957 .minwidth = cam->minwidth, 2957 .minwidth = cam->minwidth,
2958 .minheight = cam->minheight, 2958 .minheight = cam->minheight,
2959 }; 2959 };
2960 sprintf(cap.name, "W996[87]CF USB Camera #%d", 2960 sprintf(cap.name, "W996[87]CF USB Camera #%d",
2961 cam->v4ldev->minor); 2961 cam->v4ldev->minor);
2962 cap.maxwidth = (cam->upscaling && w9968cf_vpp) 2962 cap.maxwidth = (cam->upscaling && w9968cf_vpp)
2963 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) 2963 ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
2964 : cam->maxwidth; 2964 : cam->maxwidth;
2965 cap.maxheight = (cam->upscaling && w9968cf_vpp) 2965 cap.maxheight = (cam->upscaling && w9968cf_vpp)
2966 ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) 2966 ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
2967 : cam->maxheight; 2967 : cam->maxheight;
2968 2968
2969 if (copy_to_user(arg, &cap, sizeof(cap))) 2969 if (copy_to_user(arg, &cap, sizeof(cap)))
2970 return -EFAULT; 2970 return -EFAULT;
@@ -3029,7 +3029,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3029 if (copy_from_user(&pict, arg, sizeof(pict))) 3029 if (copy_from_user(&pict, arg, sizeof(pict)))
3030 return -EFAULT; 3030 return -EFAULT;
3031 3031
3032 if ( (cam->force_palette || !w9968cf_vpp) 3032 if ( (cam->force_palette || !w9968cf_vpp)
3033 && pict.palette != cam->picture.palette ) { 3033 && pict.palette != cam->picture.palette ) {
3034 DBG(4, "Palette %s rejected: only %s is allowed", 3034 DBG(4, "Palette %s rejected: only %s is allowed",
3035 symbolic(v4l1_plist, pict.palette), 3035 symbolic(v4l1_plist, pict.palette),
@@ -3046,24 +3046,24 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3046 if (!cam->force_palette) { 3046 if (!cam->force_palette) {
3047 if (cam->decompression == 0) { 3047 if (cam->decompression == 0) {
3048 if (w9968cf_need_decompression(pict.palette)) { 3048 if (w9968cf_need_decompression(pict.palette)) {
3049 DBG(4, "Decompression disabled: palette %s is not " 3049 DBG(4, "Decompression disabled: palette %s is not "
3050 "allowed. VIDIOCSPICT failed", 3050 "allowed. VIDIOCSPICT failed",
3051 symbolic(v4l1_plist, pict.palette)) 3051 symbolic(v4l1_plist, pict.palette))
3052 return -EINVAL; 3052 return -EINVAL;
3053 } 3053 }
3054 } else if (cam->decompression == 1) { 3054 } else if (cam->decompression == 1) {
3055 if (!w9968cf_need_decompression(pict.palette)) { 3055 if (!w9968cf_need_decompression(pict.palette)) {
3056 DBG(4, "Decompression forced: palette %s is not " 3056 DBG(4, "Decompression forced: palette %s is not "
3057 "allowed. VIDIOCSPICT failed", 3057 "allowed. VIDIOCSPICT failed",
3058 symbolic(v4l1_plist, pict.palette)) 3058 symbolic(v4l1_plist, pict.palette))
3059 return -EINVAL; 3059 return -EINVAL;
3060 } 3060 }
3061 } 3061 }
3062 } 3062 }
3063 3063
3064 if (pict.depth != w9968cf_valid_depth(pict.palette)) { 3064 if (pict.depth != w9968cf_valid_depth(pict.palette)) {
3065 DBG(4, "Requested depth %u bpp is not valid for %s " 3065 DBG(4, "Requested depth %u bpp is not valid for %s "
3066 "palette: ignored and changed to %u bpp", 3066 "palette: ignored and changed to %u bpp",
3067 pict.depth, symbolic(v4l1_plist, pict.palette), 3067 pict.depth, symbolic(v4l1_plist, pict.palette),
3068 w9968cf_valid_depth(pict.palette)) 3068 w9968cf_valid_depth(pict.palette))
3069 pict.depth = w9968cf_valid_depth(pict.palette); 3069 pict.depth = w9968cf_valid_depth(pict.palette);
@@ -3074,9 +3074,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3074 || cam->frame_current->queued) { 3074 || cam->frame_current->queued) {
3075 err = wait_event_interruptible 3075 err = wait_event_interruptible
3076 ( cam->wait_queue, 3076 ( cam->wait_queue,
3077 cam->disconnected || 3077 cam->disconnected ||
3078 (!*cam->requested_frame && 3078 (!*cam->requested_frame &&
3079 !cam->frame_current->queued) ); 3079 !cam->frame_current->queued) );
3080 if (err) 3080 if (err)
3081 return err; 3081 return err;
3082 if (cam->disconnected) 3082 if (cam->disconnected)
@@ -3116,7 +3116,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3116 return -EINVAL; 3116 return -EINVAL;
3117 3117
3118 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, 3118 if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
3119 (u16*)&win.height))) { 3119 (u16*)&win.height))) {
3120 DBG(4, "Resolution not supported (%ux%u). " 3120 DBG(4, "Resolution not supported (%ux%u). "
3121 "VIDIOCSWIN failed", win.width, win.height) 3121 "VIDIOCSWIN failed", win.width, win.height)
3122 return err; 3122 return err;
@@ -3130,9 +3130,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3130 || cam->frame_current->queued) { 3130 || cam->frame_current->queued) {
3131 err = wait_event_interruptible 3131 err = wait_event_interruptible
3132 ( cam->wait_queue, 3132 ( cam->wait_queue,
3133 cam->disconnected || 3133 cam->disconnected ||
3134 (!*cam->requested_frame && 3134 (!*cam->requested_frame &&
3135 !cam->frame_current->queued) ); 3135 !cam->frame_current->queued) );
3136 if (err) 3136 if (err)
3137 return err; 3137 return err;
3138 if (cam->disconnected) 3138 if (cam->disconnected)
@@ -3175,7 +3175,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3175 mbuf.frames = cam->nbuffers; 3175 mbuf.frames = cam->nbuffers;
3176 for (i = 0; i < cam->nbuffers; i++) 3176 for (i = 0; i < cam->nbuffers; i++)
3177 mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer - 3177 mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer -
3178 (unsigned long)cam->frame[0].buffer; 3178 (unsigned long)cam->frame[0].buffer;
3179 3179
3180 if (copy_to_user(arg, &mbuf, sizeof(mbuf))) 3180 if (copy_to_user(arg, &mbuf, sizeof(mbuf)))
3181 return -EFAULT; 3181 return -EFAULT;
@@ -3194,7 +3194,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3194 return -EFAULT; 3194 return -EFAULT;
3195 3195
3196 DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d", 3196 DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d",
3197 mmap.frame, symbolic(v4l1_plist, mmap.format), 3197 mmap.frame, symbolic(v4l1_plist, mmap.format),
3198 mmap.width, mmap.height) 3198 mmap.width, mmap.height)
3199 3199
3200 if (mmap.frame >= cam->nbuffers) { 3200 if (mmap.frame >= cam->nbuffers) {
@@ -3203,7 +3203,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3203 return -EINVAL; 3203 return -EINVAL;
3204 } 3204 }
3205 3205
3206 if (mmap.format!=cam->picture.palette && 3206 if (mmap.format!=cam->picture.palette &&
3207 (cam->force_palette || !w9968cf_vpp)) { 3207 (cam->force_palette || !w9968cf_vpp)) {
3208 DBG(4, "Palette %s rejected: only %s is allowed", 3208 DBG(4, "Palette %s rejected: only %s is allowed",
3209 symbolic(v4l1_plist, mmap.format), 3209 symbolic(v4l1_plist, mmap.format),
@@ -3213,7 +3213,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3213 3213
3214 if (!w9968cf_valid_palette(mmap.format)) { 3214 if (!w9968cf_valid_palette(mmap.format)) {
3215 DBG(4, "Palette %s not supported. " 3215 DBG(4, "Palette %s not supported. "
3216 "VIDIOCMCAPTURE failed", 3216 "VIDIOCMCAPTURE failed",
3217 symbolic(v4l1_plist, mmap.format)) 3217 symbolic(v4l1_plist, mmap.format))
3218 return -EINVAL; 3218 return -EINVAL;
3219 } 3219 }
@@ -3221,23 +3221,23 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3221 if (!cam->force_palette) { 3221 if (!cam->force_palette) {
3222 if (cam->decompression == 0) { 3222 if (cam->decompression == 0) {
3223 if (w9968cf_need_decompression(mmap.format)) { 3223 if (w9968cf_need_decompression(mmap.format)) {
3224 DBG(4, "Decompression disabled: palette %s is not " 3224 DBG(4, "Decompression disabled: palette %s is not "
3225 "allowed. VIDIOCSPICT failed", 3225 "allowed. VIDIOCSPICT failed",
3226 symbolic(v4l1_plist, mmap.format)) 3226 symbolic(v4l1_plist, mmap.format))
3227 return -EINVAL; 3227 return -EINVAL;
3228 } 3228 }
3229 } else if (cam->decompression == 1) { 3229 } else if (cam->decompression == 1) {
3230 if (!w9968cf_need_decompression(mmap.format)) { 3230 if (!w9968cf_need_decompression(mmap.format)) {
3231 DBG(4, "Decompression forced: palette %s is not " 3231 DBG(4, "Decompression forced: palette %s is not "
3232 "allowed. VIDIOCSPICT failed", 3232 "allowed. VIDIOCSPICT failed",
3233 symbolic(v4l1_plist, mmap.format)) 3233 symbolic(v4l1_plist, mmap.format))
3234 return -EINVAL; 3234 return -EINVAL;
3235 } 3235 }
3236 } 3236 }
3237 } 3237 }
3238 3238
3239 if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width, 3239 if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width,
3240 (u16*)&mmap.height))) { 3240 (u16*)&mmap.height))) {
3241 DBG(4, "Resolution not supported (%dx%d). " 3241 DBG(4, "Resolution not supported (%dx%d). "
3242 "VIDIOCMCAPTURE failed", 3242 "VIDIOCMCAPTURE failed",
3243 mmap.width, mmap.height) 3243 mmap.width, mmap.height)
@@ -3258,12 +3258,12 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3258 DBG(6, "VIDIOCMCAPTURE. Change settings for " 3258 DBG(6, "VIDIOCMCAPTURE. Change settings for "
3259 "frame #%u: %dx%d, format %s. Wait...", 3259 "frame #%u: %dx%d, format %s. Wait...",
3260 mmap.frame, mmap.width, mmap.height, 3260 mmap.frame, mmap.width, mmap.height,
3261 symbolic(v4l1_plist, mmap.format)) 3261 symbolic(v4l1_plist, mmap.format))
3262 err = wait_event_interruptible 3262 err = wait_event_interruptible
3263 ( cam->wait_queue, 3263 ( cam->wait_queue,
3264 cam->disconnected || 3264 cam->disconnected ||
3265 (!*cam->requested_frame && 3265 (!*cam->requested_frame &&
3266 !cam->frame_current->queued) ); 3266 !cam->frame_current->queued) );
3267 if (err) 3267 if (err)
3268 return err; 3268 return err;
3269 if (cam->disconnected) 3269 if (cam->disconnected)
@@ -3280,7 +3280,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3280 goto ioctl_fail; 3280 goto ioctl_fail;
3281 3281
3282 /* This before set_window */ 3282 /* This before set_window */
3283 if (w9968cf_set_picture(cam, pict)) 3283 if (w9968cf_set_picture(cam, pict))
3284 goto ioctl_fail; 3284 goto ioctl_fail;
3285 3285
3286 if (w9968cf_set_window(cam, win)) 3286 if (w9968cf_set_window(cam, win))
@@ -3292,10 +3292,10 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3292 } else if (fr->queued) { 3292 } else if (fr->queued) {
3293 3293
3294 DBG(6, "Wait until frame #%u is free", mmap.frame) 3294 DBG(6, "Wait until frame #%u is free", mmap.frame)
3295 3295
3296 err = wait_event_interruptible(cam->wait_queue, 3296 err = wait_event_interruptible(cam->wait_queue,
3297 cam->disconnected || 3297 cam->disconnected ||
3298 (!fr->queued)); 3298 (!fr->queued));
3299 if (err) 3299 if (err)
3300 return err; 3300 return err;
3301 if (cam->disconnected) 3301 if (cam->disconnected)
@@ -3335,9 +3335,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3335 } 3335 }
3336 case F_ERROR: 3336 case F_ERROR:
3337 case F_GRABBING: 3337 case F_GRABBING:
3338 err = wait_event_interruptible(cam->wait_queue, 3338 err = wait_event_interruptible(cam->wait_queue,
3339 (fr->status == F_READY) 3339 (fr->status == F_READY)
3340 || cam->disconnected); 3340 || cam->disconnected);
3341 if (err) 3341 if (err)
3342 return err; 3342 return err;
3343 if (cam->disconnected) 3343 if (cam->disconnected)
@@ -3439,7 +3439,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
3439 DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s " 3439 DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s "
3440 "(type 0x%01X, " 3440 "(type 0x%01X, "
3441 "n. 0x%01X, " 3441 "n. 0x%01X, "
3442 "dir. 0x%01X, " 3442 "dir. 0x%01X, "
3443 "size 0x%02X)", 3443 "size 0x%02X)",
3444 V4L1_IOCTL(cmd), 3444 V4L1_IOCTL(cmd),
3445 _IOC_TYPE(cmd),_IOC_NR(cmd),_IOC_DIR(cmd),_IOC_SIZE(cmd)) 3445 _IOC_TYPE(cmd),_IOC_NR(cmd),_IOC_DIR(cmd),_IOC_SIZE(cmd))
@@ -3499,13 +3499,13 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3499 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct) 3499 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct)
3500 mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */ 3500 mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */
3501 else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor && 3501 else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor &&
3502 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct) 3502 le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct)
3503 mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */ 3503 mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */
3504 else 3504 else
3505 return -ENODEV; 3505 return -ENODEV;
3506 3506
3507 cam = (struct w9968cf_device*) 3507 cam = (struct w9968cf_device*)
3508 kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL); 3508 kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL);
3509 if (!cam) 3509 if (!cam)
3510 return -ENOMEM; 3510 return -ENOMEM;
3511 3511
@@ -3569,7 +3569,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3569 cam->v4ldev->dev = &cam->dev; 3569 cam->v4ldev->dev = &cam->dev;
3570 3570
3571 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, 3571 err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
3572 video_nr[dev_nr]); 3572 video_nr[dev_nr]);
3573 if (err) { 3573 if (err) {
3574 DBG(1, "V4L device registration failed") 3574 DBG(1, "V4L device registration failed")
3575 if (err == -ENFILE && video_nr[dev_nr] == -1) 3575 if (err == -ENFILE && video_nr[dev_nr] == -1)
@@ -3611,7 +3611,7 @@ fail: /* Free unused memory */
3611 3611
3612static void w9968cf_usb_disconnect(struct usb_interface* intf) 3612static void w9968cf_usb_disconnect(struct usb_interface* intf)
3613{ 3613{
3614 struct w9968cf_device* cam = 3614 struct w9968cf_device* cam =
3615 (struct w9968cf_device*)usb_get_intfdata(intf); 3615 (struct w9968cf_device*)usb_get_intfdata(intf);
3616 3616
3617 down_write(&w9968cf_disconnect); 3617 down_write(&w9968cf_disconnect);