2 * USB IBM C-It Video Camera driver
4 * Supports Xirlink C-It Video Camera, IBM PC Camera,
5 * IBM NetCamera and Veo Stingray.
7 * This driver is based on earlier work of:
9 * (C) Copyright 1999 Johannes Erdfelt
10 * (C) Copyright 1999 Randy Dunlap
12 * 5/24/00 Removed optional (and unnecessary) locking of the driver while
13 * the device remains plugged in. Corrected race conditions in ibmcam_open
14 * and ibmcam_probe() routines using this as a guideline:
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/module.h>
20 #include <linux/init.h>
24 #define IBMCAM_VENDOR_ID 0x0545
25 #define IBMCAM_PRODUCT_ID 0x8080
26 #define NETCAM_PRODUCT_ID 0x8002 /* IBM NetCamera, close to model 2 */
27 #define VEO_800C_PRODUCT_ID 0x800C /* Veo Stingray, repackaged Model 2 */
28 #define VEO_800D_PRODUCT_ID 0x800D /* Veo Stingray, repackaged Model 4 */
30 #define MAX_IBMCAM 4 /* How many devices we allow to connect */
31 #define USES_IBMCAM_PUTPIXEL 0 /* 0=Fast/oops 1=Slow/secure */
33 /* Header signatures */
35 /* Model 1 header: 00 FF 00 xx */
36 #define HDRSIG_MODEL1_128x96 0x06 /* U Y V Y ... */
37 #define HDRSIG_MODEL1_176x144 0x0e /* U Y V Y ... */
38 #define HDRSIG_MODEL1_352x288 0x00 /* V Y U Y ... */
40 #define IBMCAM_MODEL_1 1 /* XVP-501, 3 interfaces, rev. 0.02 */
41 #define IBMCAM_MODEL_2 2 /* KSX-X9903, 2 interfaces, rev. 3.0a */
42 #define IBMCAM_MODEL_3 3 /* KSX-X9902, 2 interfaces, rev. 3.01 */
43 #define IBMCAM_MODEL_4 4 /* IBM NetCamera, 0545/8002/3.0a */
45 /* Video sizes supported */
46 #define VIDEOSIZE_128x96 VIDEOSIZE(128, 96)
47 #define VIDEOSIZE_176x144 VIDEOSIZE(176,144)
48 #define VIDEOSIZE_352x288 VIDEOSIZE(352,288)
49 #define VIDEOSIZE_320x240 VIDEOSIZE(320,240)
50 #define VIDEOSIZE_352x240 VIDEOSIZE(352,240)
51 #define VIDEOSIZE_640x480 VIDEOSIZE(640,480)
52 #define VIDEOSIZE_160x120 VIDEOSIZE(160,120)
54 /* Video sizes supported */
63 /* Add/remove/rearrange items before this line */
68 * This structure lives in uvd->user field.
71 int initialized
; /* Had we already sent init sequence? */
72 int camera_model
; /* What type of IBM camera we got? */
75 #define IBMCAM_T(uvd) ((ibmcam_t *)((uvd)->user_data))
77 static struct usbvideo
*cams
;
81 static int flags
; /* = FLAGS_DISPLAY_HINTS | FLAGS_OVERLAY_STATS; */
83 static const int min_canvasWidth
= 8;
84 static const int min_canvasHeight
= 4;
86 static int lighting
= 1; /* Medium */
88 #define SHARPNESS_MIN 0
89 #define SHARPNESS_MAX 6
90 static int sharpness
= 4; /* Low noise, good details */
92 #define FRAMERATE_MIN 0
93 #define FRAMERATE_MAX 6
94 static int framerate
= -1;
96 static int size
= SIZE_352x288
;
99 * Here we define several initialization variables. They may
100 * be used to automatically set color, hue, brightness and
101 * contrast to desired values. This is particularly useful in
102 * case of webcams (which have no controls and no on-screen
103 * output) and also when a client V4L software is used that
104 * does not have some of those controls. In any case it's
105 * good to have startup values as options.
107 * These values are all in [0..255] range. This simplifies
108 * operation. Note that actual values of V4L variables may
109 * be scaled up (as much as << 8). User can see that only
110 * on overlay output, however, or through a V4L client.
112 static int init_brightness
= 128;
113 static int init_contrast
= 192;
114 static int init_color
= 128;
115 static int init_hue
= 128;
116 static int hue_correction
= 128;
118 /* Settings for camera model 2 */
119 static int init_model2_rg2
= -1;
120 static int init_model2_sat
= -1;
121 static int init_model2_yb
= -1;
123 /* 01.01.08 - Added for RCA video in support -LO */
124 /* Settings for camera model 3 */
125 static int init_model3_input
= 0;
127 module_param(debug
, int, 0);
128 MODULE_PARM_DESC(debug
, "Debug level: 0-9 (default=0)");
129 module_param(flags
, int, 0);
130 MODULE_PARM_DESC(flags
, "Bitfield: 0=VIDIOCSYNC, 1=B/W, 2=show hints, 3=show stats, 4=test pattern, 5=separate frames, 6=clean frames");
131 module_param(framerate
, int, 0);
132 MODULE_PARM_DESC(framerate
, "Framerate setting: 0=slowest, 6=fastest (default=2)");
133 module_param(lighting
, int, 0);
134 MODULE_PARM_DESC(lighting
, "Photosensitivity: 0=bright, 1=medium (default), 2=low light");
135 module_param(sharpness
, int, 0);
136 MODULE_PARM_DESC(sharpness
, "Model1 noise reduction: 0=smooth, 6=sharp (default=4)");
137 module_param(size
, int, 0);
138 MODULE_PARM_DESC(size
, "Image size: 0=128x96 1=160x120 2=176x144 3=320x240 4=352x240 5=352x288 6=640x480 (default=5)");
139 module_param(init_brightness
, int, 0);
140 MODULE_PARM_DESC(init_brightness
, "Brightness preconfiguration: 0-255 (default=128)");
141 module_param(init_contrast
, int, 0);
142 MODULE_PARM_DESC(init_contrast
, "Contrast preconfiguration: 0-255 (default=192)");
143 module_param(init_color
, int, 0);
144 MODULE_PARM_DESC(init_color
, "Color preconfiguration: 0-255 (default=128)");
145 module_param(init_hue
, int, 0);
146 MODULE_PARM_DESC(init_hue
, "Hue preconfiguration: 0-255 (default=128)");
147 module_param(hue_correction
, int, 0);
148 MODULE_PARM_DESC(hue_correction
, "YUV colorspace regulation: 0-255 (default=128)");
150 module_param(init_model2_rg2
, int, 0);
151 MODULE_PARM_DESC(init_model2_rg2
, "Model2 preconfiguration: 0-255 (default=47)");
152 module_param(init_model2_sat
, int, 0);
153 MODULE_PARM_DESC(init_model2_sat
, "Model2 preconfiguration: 0-255 (default=52)");
154 module_param(init_model2_yb
, int, 0);
155 MODULE_PARM_DESC(init_model2_yb
, "Model2 preconfiguration: 0-255 (default=160)");
157 /* 01.01.08 - Added for RCA video in support -LO */
158 module_param(init_model3_input
, int, 0);
159 MODULE_PARM_DESC(init_model3_input
, "Model3 input: 0=CCD 1=RCA");
161 MODULE_AUTHOR ("Dmitri");
162 MODULE_DESCRIPTION ("IBM/Xirlink C-it USB Camera Driver for Linux (c) 2000");
163 MODULE_LICENSE("GPL");
165 /* Still mysterious i2c commands */
166 static const unsigned short unknown_88
= 0x0088;
167 static const unsigned short unknown_89
= 0x0089;
168 static const unsigned short bright_3x
[3] = { 0x0031, 0x0032, 0x0033 };
169 static const unsigned short contrast_14
= 0x0014;
170 static const unsigned short light_27
= 0x0027;
171 static const unsigned short sharp_13
= 0x0013;
173 /* i2c commands for Model 2 cameras */
174 static const unsigned short mod2_brightness
= 0x001a; /* $5b .. $ee; default=$5a */
175 static const unsigned short mod2_set_framerate
= 0x001c; /* 0 (fast).. $1F (slow) */
176 static const unsigned short mod2_color_balance_rg2
= 0x001e; /* 0 (red) .. $7F (green) */
177 static const unsigned short mod2_saturation
= 0x0020; /* 0 (b/w) - $7F (full color) */
178 static const unsigned short mod2_color_balance_yb
= 0x0022; /* 0..$7F, $50 is about right */
179 static const unsigned short mod2_hue
= 0x0024; /* 0..$7F, $70 is about right */
180 static const unsigned short mod2_sensitivity
= 0x0028; /* 0 (min) .. $1F (max) */
182 struct struct_initData
{
184 unsigned short value
;
185 unsigned short index
;
189 * ibmcam_size_to_videosize()
191 * This procedure converts module option 'size' into the actual
192 * videosize_t that defines the image size in pixels. We need
193 * simplified 'size' because user wants a simple enumerated list
194 * of choices, not an infinite set of possibilities.
196 static videosize_t
ibmcam_size_to_videosize(int size
)
198 videosize_t vs
= VIDEOSIZE_352x288
;
199 RESTRICT_TO_RANGE(size
, 0, (SIZE_LastItem
-1));
202 vs
= VIDEOSIZE_128x96
;
205 vs
= VIDEOSIZE_160x120
;
208 vs
= VIDEOSIZE_176x144
;
211 vs
= VIDEOSIZE_320x240
;
214 vs
= VIDEOSIZE_352x240
;
217 vs
= VIDEOSIZE_352x288
;
220 vs
= VIDEOSIZE_640x480
;
223 err("size=%d. is not valid", size
);
230 * ibmcam_find_header()
232 * Locate one of supported header markers in the queue.
233 * Once found, remove all preceding bytes AND the marker (4 bytes)
234 * from the data pump queue. Whatever follows must be video lines.
239 static enum ParseState
ibmcam_find_header(struct uvd
*uvd
) /* FIXME: Add frame here */
241 struct usbvideo_frame
*frame
;
244 if ((uvd
->curframe
) < 0 || (uvd
->curframe
>= USBVIDEO_NUMFRAMES
)) {
245 err("ibmcam_find_header: Illegal frame %d.", uvd
->curframe
);
246 return scan_EndParse
;
248 icam
= IBMCAM_T(uvd
);
249 assert(icam
!= NULL
);
250 frame
= &uvd
->frame
[uvd
->curframe
];
252 switch (icam
->camera_model
) {
255 const int marker_len
= 4;
256 while (RingQueue_GetLength(&uvd
->dp
) >= marker_len
) {
257 if ((RING_QUEUE_PEEK(&uvd
->dp
, 0) == 0x00) &&
258 (RING_QUEUE_PEEK(&uvd
->dp
, 1) == 0xFF) &&
259 (RING_QUEUE_PEEK(&uvd
->dp
, 2) == 0x00))
261 #if 0 /* This code helps to detect new frame markers */
262 info("Header sig: 00 FF 00 %02X", RING_QUEUE_PEEK(&uvd
->dp
, 3));
264 frame
->header
= RING_QUEUE_PEEK(&uvd
->dp
, 3);
265 if ((frame
->header
== HDRSIG_MODEL1_128x96
) ||
266 (frame
->header
== HDRSIG_MODEL1_176x144
) ||
267 (frame
->header
== HDRSIG_MODEL1_352x288
))
270 info("Header found.");
272 RING_QUEUE_DEQUEUE_BYTES(&uvd
->dp
, marker_len
);
277 /* If we are still here then this doesn't look like a header */
278 RING_QUEUE_DEQUEUE_BYTES(&uvd
->dp
, 1);
286 switch (uvd
->videosize
) {
287 case VIDEOSIZE_176x144
:
294 while (RingQueue_GetLength(&uvd
->dp
) >= marker_len
) {
295 if ((RING_QUEUE_PEEK(&uvd
->dp
, 0) == 0x00) &&
296 (RING_QUEUE_PEEK(&uvd
->dp
, 1) == 0xFF))
299 info("Header found.");
301 RING_QUEUE_DEQUEUE_BYTES(&uvd
->dp
, marker_len
);
303 frame
->header
= HDRSIG_MODEL1_176x144
;
306 /* If we are still here then this doesn't look like a header */
307 RING_QUEUE_DEQUEUE_BYTES(&uvd
->dp
, 1);
313 * Headers: (one precedes every frame). nc=no compression,
314 * bq=best quality bf=best frame rate.
316 * 176x144: 00 FF 02 { 0A=nc CA=bq EA=bf }
317 * 320x240: 00 FF 02 { 08=nc 28=bq 68=bf }
318 * 640x480: 00 FF 03 { 08=nc 28=bq 68=bf }
320 * Bytes '00 FF' seem to indicate header. Other two bytes
321 * encode the frame type. This is a set of bit fields that
322 * encode image size, compression type etc. These fields
323 * do NOT contain frame number because all frames carry
326 const int marker_len
= 4;
327 while (RingQueue_GetLength(&uvd
->dp
) >= marker_len
) {
328 if ((RING_QUEUE_PEEK(&uvd
->dp
, 0) == 0x00) &&
329 (RING_QUEUE_PEEK(&uvd
->dp
, 1) == 0xFF) &&
330 (RING_QUEUE_PEEK(&uvd
->dp
, 2) != 0xFF))
333 * Combine 2 bytes of frame type into one
336 unsigned long byte3
, byte4
;
338 byte3
= RING_QUEUE_PEEK(&uvd
->dp
, 2);
339 byte4
= RING_QUEUE_PEEK(&uvd
->dp
, 3);
340 frame
->header
= (byte3
<< 8) | byte4
;
342 info("Header found.");
344 RING_QUEUE_DEQUEUE_BYTES(&uvd
->dp
, marker_len
);
348 /* If we are still here then this doesn't look like a header */
349 RING_QUEUE_DEQUEUE_BYTES(&uvd
->dp
, 1);
356 if (!icam
->has_hdr
) {
358 info("Skipping frame, no header");
359 return scan_EndParse
;
364 uvd
->stats
.header_count
++;
365 frame
->scanstate
= ScanState_Lines
;
368 if (flags
& FLAGS_FORCE_TESTPATTERN
) {
369 usbvideo_TestPattern(uvd
, 1, 1);
370 return scan_NextFrame
;
372 return scan_Continue
;
376 * ibmcam_parse_lines()
378 * Parse one line (interlaced) from the buffer, put
379 * decoded RGB value into the current frame buffer
380 * and add the written number of bytes (RGB) to
384 * 21-Jan-2000 Created.
385 * 12-Oct-2000 Reworked to reflect interlaced nature of the data.
387 static enum ParseState
ibmcam_parse_lines(
389 struct usbvideo_frame
*frame
,
394 unsigned int len
, scanLength
, scanHeight
, order_uv
, order_yc
;
395 int v4l_linesize
; /* V4L line offset */
396 const int hue_corr
= (uvd
->vpic
.hue
- 0x8000) >> 10; /* -32..+31 */
397 const int hue2_corr
= (hue_correction
- 128) / 4; /* -32..+31 */
398 const int ccm
= 128; /* Color correction median - see below */
399 int y
, u
, v
, i
, frame_done
=0, color_corr
;
400 static unsigned char lineBuffer
[640*3];
401 unsigned const char *chromaLine
, *lumaLine
;
404 assert(frame
!= NULL
);
405 icam
= IBMCAM_T(uvd
);
406 assert(icam
!= NULL
);
407 color_corr
= (uvd
->vpic
.colour
- 0x8000) >> 8; /* -128..+127 = -ccm..+(ccm-1)*/
408 RESTRICT_TO_RANGE(color_corr
, -ccm
, ccm
+1);
410 v4l_linesize
= VIDEOSIZE_X(frame
->request
) * V4L_BYTES_PER_PIXEL
;
412 if (IBMCAM_T(uvd
)->camera_model
== IBMCAM_MODEL_4
) {
413 /* Model 4 frame markers do not carry image size identification */
414 switch (uvd
->videosize
) {
415 case VIDEOSIZE_128x96
:
416 case VIDEOSIZE_160x120
:
417 case VIDEOSIZE_176x144
:
418 scanLength
= VIDEOSIZE_X(uvd
->videosize
);
419 scanHeight
= VIDEOSIZE_Y(uvd
->videosize
);
422 err("ibmcam_parse_lines: Wrong mode.");
425 order_yc
= 1; /* order_yc: true=Yc false=cY ('c'=either U or V) */
426 order_uv
= 1; /* Always true in this algorithm */
428 switch (frame
->header
) {
429 case HDRSIG_MODEL1_128x96
:
432 order_uv
= 1; /* U Y V Y ... */
434 case HDRSIG_MODEL1_176x144
:
437 order_uv
= 1; /* U Y V Y ... */
439 case HDRSIG_MODEL1_352x288
:
442 order_uv
= 0; /* Y V Y V ... */
445 err("Unknown header signature 00 FF 00 %02lX", frame
->header
);
446 return scan_NextFrame
;
448 /* order_yc: true=Yc false=cY ('c'=either U or V) */
449 order_yc
= (IBMCAM_T(uvd
)->camera_model
== IBMCAM_MODEL_2
);
452 len
= scanLength
* 3;
453 assert(len
<= sizeof(lineBuffer
));
456 * Lines are organized this way:
461 * ___________________________________
462 * |-----Y-----|---UVUVUV...UVUV-----| \
463 * |-----------+---------------------| \
464 * |<-- 176 -->|<------ 176*2 ------>| Total 72. lines (interlaced)
466 * |<-- 352 -->|<------ 352*2 ------>| Total 144. lines (interlaced)
467 * |___________|_____________________| /
469 * lumaLine chromaLine
472 /* Make sure there's enough data for the entire line */
473 if (RingQueue_GetLength(&uvd
->dp
) < len
)
476 /* Suck one line out of the ring queue */
477 RingQueue_Dequeue(&uvd
->dp
, lineBuffer
, len
);
480 * Make sure that our writing into output buffer
481 * will not exceed the buffer. Mind that we may write
482 * not into current output scanline but in several after
483 * it as well (if we enlarge image vertically.)
485 if ((frame
->curline
+ 2) >= VIDEOSIZE_Y(frame
->request
))
486 return scan_NextFrame
;
489 * Now we are sure that entire line (representing all 'scanLength'
490 * pixels from the camera) is available in the buffer. We
491 * start copying the line left-aligned to the V4L buffer.
492 * If the camera line is shorter then we should pad the V4L
493 * buffer with something (black) to complete the line.
495 assert(frame
->data
!= NULL
);
496 f
= frame
->data
+ (v4l_linesize
* frame
->curline
);
499 * To obtain chrominance data from the 'chromaLine' use this:
500 * v = chromaLine[0]; // 0-1:[0], 2-3:[4], 4-5:[8]...
501 * u = chromaLine[2]; // 0-1:[2], 2-3:[6], 4-5:[10]...
503 * Indices must be calculated this way:
504 * v_index = (i >> 1) << 2;
505 * u_index = (i >> 1) << 2 + 2;
507 * where 'i' is the column number [0..VIDEOSIZE_X(frame->request)-1]
509 lumaLine
= lineBuffer
;
510 chromaLine
= lineBuffer
+ scanLength
;
511 for (i
= 0; i
< VIDEOSIZE_X(frame
->request
); i
++)
513 unsigned char rv
, gv
, bv
; /* RGB components */
515 /* Check for various visual debugging hints (colorized pixels) */
516 if ((flags
& FLAGS_DISPLAY_HINTS
) && (icam
->has_hdr
)) {
518 * This is bad and should not happen. This means that
519 * we somehow overshoot the line and encountered new
520 * frame! Obviously our camera/V4L frame size is out
521 * of whack. This cyan dot will help you to figure
522 * out where exactly the new frame arrived.
524 if (icam
->has_hdr
== 1) {
525 bv
= 0; /* Yellow marker */
529 bv
= 0xFF; /* Cyan marker */
538 * Check if we are still in range. We may be out of range if our
539 * V4L canvas is wider or taller than the camera "native" image.
540 * Then we quickly fill the remainder of the line with zeros to
541 * make black color and quit the horizontal scanning loop.
543 if (((frame
->curline
+ 2) >= scanHeight
) || (i
>= scanLength
)) {
544 const int j
= i
* V4L_BYTES_PER_PIXEL
;
545 #if USES_IBMCAM_PUTPIXEL
546 /* Refresh 'f' because we don't use it much with PUTPIXEL */
547 f
= frame
->data
+ (v4l_linesize
* frame
->curline
) + j
;
549 memset(f
, 0, v4l_linesize
- j
);
554 if (flags
& FLAGS_MONOCHROME
) /* Use monochrome for debugging */
559 off_0
= (i
>> 1) << 2;
570 u
= chromaLine
[off_0
] + hue_corr
;
571 v
= chromaLine
[off_2
] + hue2_corr
;
573 /* Apply color correction */
574 if (color_corr
!= 0) {
575 /* Magnify up to 2 times, reduce down to zero saturation */
576 u
= 128 + ((ccm
+ color_corr
) * (u
- 128)) / ccm
;
577 v
= 128 + ((ccm
+ color_corr
) * (v
- 128)) / ccm
;
579 YUV_TO_RGB_BY_THE_BOOK(y
, u
, v
, rv
, gv
, bv
);
584 * The purpose of creating the pixel here, in one,
585 * dedicated place is that we may need to make the
586 * pixel wider and taller than it actually is. This
587 * may be used if camera generates small frames for
588 * sake of frame rate (or any other reason.)
590 * The output data consists of B, G, R bytes
593 #if USES_IBMCAM_PUTPIXEL
594 RGB24_PUTPIXEL(frame
, i
, frame
->curline
, rv
, gv
, bv
);
601 * Typically we do not decide within a legitimate frame
602 * that we want to end the frame. However debugging code
603 * may detect marker of new frame within the data. Then
604 * this condition activates. The 'data' pointer is already
605 * pointing at the new marker, so we'd better leave it as is.
608 break; /* End scanning of lines */
611 * Account for number of bytes that we wrote into output V4L frame.
612 * We do it here, after we are done with the scanline, because we
613 * may fill more than one output scanline if we do vertical
617 if (pcopylen
!= NULL
)
618 *pcopylen
+= 2 * v4l_linesize
;
619 frame
->deinterlace
= Deinterlace_FillOddLines
;
621 if (frame_done
|| (frame
->curline
>= VIDEOSIZE_Y(frame
->request
)))
622 return scan_NextFrame
;
624 return scan_Continue
;
628 * ibmcam_model2_320x240_parse_lines()
630 * This procedure deals with a weird RGB format that is produced by IBM
631 * camera model 2 in modes 320x240 and above; 'x' below is 159 or 175,
632 * depending on horizontal size of the picture:
634 * <--- 160 or 176 pairs of RA,RB bytes ----->
635 * *-----------------------------------------* \
636 * | RA0 | RB0 | RA1 | RB1 | ... | RAx | RBx | \ This is pair of horizontal lines,
637 * |-----+-----+-----+-----+ ... +-----+-----| *- or one interlaced line, total
638 * | B0 | G0 | B1 | G1 | ... | Bx | Gx | / 120 or 144 such pairs which yield
639 * |=====+=====+=====+=====+ ... +=====+=====| / 240 or 288 lines after deinterlacing.
641 * Each group of FOUR bytes (RAi, RBi, Bi, Gi) where i=0..frame_width/2-1
642 * defines ONE pixel. Therefore this format yields 176x144 "decoded"
643 * resolution at best. I do not know why camera sends such format - the
644 * previous model (1) just used interlaced I420 and everyone was happy.
646 * I do not know what is the difference between RAi and RBi bytes. Both
647 * seemingly represent R component, but slightly vary in value (so that
648 * the picture looks a bit colored if one or another is used). I use
649 * them both as R component in attempt to at least partially recover the
652 static enum ParseState
ibmcam_model2_320x240_parse_lines(
654 struct usbvideo_frame
*frame
,
657 unsigned char *f
, *la
, *lb
;
659 int v4l_linesize
; /* V4L line offset */
660 int i
, j
, frame_done
=0, color_corr
;
661 int scanLength
, scanHeight
;
662 static unsigned char lineBuffer
[352*2];
664 switch (uvd
->videosize
) {
665 case VIDEOSIZE_320x240
:
666 case VIDEOSIZE_352x240
:
667 case VIDEOSIZE_352x288
:
668 scanLength
= VIDEOSIZE_X(uvd
->videosize
);
669 scanHeight
= VIDEOSIZE_Y(uvd
->videosize
);
672 err("ibmcam_model2_320x240_parse_lines: Wrong mode.");
676 color_corr
= (uvd
->vpic
.colour
) >> 8; /* 0..+255 */
677 v4l_linesize
= VIDEOSIZE_X(frame
->request
) * V4L_BYTES_PER_PIXEL
;
679 len
= scanLength
* 2; /* See explanation above */
680 assert(len
<= sizeof(lineBuffer
));
682 /* Make sure there's enough data for the entire line */
683 if (RingQueue_GetLength(&uvd
->dp
) < len
)
686 /* Suck one line out of the ring queue */
687 RingQueue_Dequeue(&uvd
->dp
, lineBuffer
, len
);
690 * Make sure that our writing into output buffer
691 * will not exceed the buffer. Mind that we may write
692 * not into current output scanline but in several after
693 * it as well (if we enlarge image vertically.)
695 if ((frame
->curline
+ 2) >= VIDEOSIZE_Y(frame
->request
))
696 return scan_NextFrame
;
699 lb
= lineBuffer
+ scanLength
;
702 * Now we are sure that entire line (representing all
703 * VIDEOSIZE_X(frame->request)
704 * pixels from the camera) is available in the scratch buffer. We
705 * start copying the line left-aligned to the V4L buffer (which
706 * might be larger - not smaller, hopefully). If the camera
707 * line is shorter then we should pad the V4L buffer with something
708 * (black in this case) to complete the line.
710 f
= frame
->data
+ (v4l_linesize
* frame
->curline
);
712 /* Fill the 2-line strip */
713 for (i
= 0; i
< VIDEOSIZE_X(frame
->request
); i
++) {
714 int y
, rv
, gv
, bv
; /* RGB components */
718 /* Check for various visual debugging hints (colorized pixels) */
719 if ((flags
& FLAGS_DISPLAY_HINTS
) && (IBMCAM_T(uvd
)->has_hdr
)) {
720 if (IBMCAM_T(uvd
)->has_hdr
== 1) {
721 bv
= 0; /* Yellow marker */
725 bv
= 0xFF; /* Cyan marker */
729 IBMCAM_T(uvd
)->has_hdr
= 0;
734 * Check if we are still in range. We may be out of range if our
735 * V4L canvas is wider or taller than the camera "native" image.
736 * Then we quickly fill the remainder of the line with zeros to
737 * make black color and quit the horizontal scanning loop.
739 if (((frame
->curline
+ 2) >= scanHeight
) || (i
>= scanLength
)) {
740 const int j
= i
* V4L_BYTES_PER_PIXEL
;
741 #if USES_IBMCAM_PUTPIXEL
742 /* Refresh 'f' because we don't use it much with PUTPIXEL */
743 f
= frame
->data
+ (v4l_linesize
* frame
->curline
) + j
;
745 memset(f
, 0, v4l_linesize
- j
);
750 * Here I use RA and RB components, one per physical pixel.
751 * This causes fine vertical grid on the picture but may improve
752 * horizontal resolution. If you prefer replicating, use this:
753 * rv = la[j + 0]; ... or ... rv = la[j + 1];
754 * then the pixel will be replicated.
760 y
= (rv
+ gv
+ bv
) / 3; /* Brightness (badly calculated) */
762 if (flags
& FLAGS_MONOCHROME
) /* Use monochrome for debugging */
764 else if (color_corr
!= 128) {
766 /* Calculate difference between color and brightness */
771 /* Scale differences */
772 rv
= (rv
* color_corr
) / 128;
773 gv
= (gv
* color_corr
) / 128;
774 bv
= (bv
* color_corr
) / 128;
776 /* Reapply brightness */
781 /* Watch for overflows */
782 RESTRICT_TO_RANGE(rv
, 0, 255);
783 RESTRICT_TO_RANGE(gv
, 0, 255);
784 RESTRICT_TO_RANGE(bv
, 0, 255);
788 RGB24_PUTPIXEL(frame
, i
, frame
->curline
, rv
, gv
, bv
);
791 * Account for number of bytes that we wrote into output V4L frame.
792 * We do it here, after we are done with the scanline, because we
793 * may fill more than one output scanline if we do vertical
797 *pcopylen
+= v4l_linesize
* 2;
798 frame
->deinterlace
= Deinterlace_FillOddLines
;
800 if (frame_done
|| (frame
->curline
>= VIDEOSIZE_Y(frame
->request
)))
801 return scan_NextFrame
;
803 return scan_Continue
;
806 static enum ParseState
ibmcam_model3_parse_lines(
808 struct usbvideo_frame
*frame
,
812 const unsigned char *color
;
814 int v4l_linesize
; /* V4L line offset */
815 const int hue_corr
= (uvd
->vpic
.hue
- 0x8000) >> 10; /* -32..+31 */
816 const int hue2_corr
= (hue_correction
- 128) / 4; /* -32..+31 */
817 const int ccm
= 128; /* Color correction median - see below */
818 int i
, u
, v
, rw
, data_w
=0, data_h
=0, color_corr
;
819 static unsigned char lineBuffer
[640*3];
821 color_corr
= (uvd
->vpic
.colour
- 0x8000) >> 8; /* -128..+127 = -ccm..+(ccm-1)*/
822 RESTRICT_TO_RANGE(color_corr
, -ccm
, ccm
+1);
824 v4l_linesize
= VIDEOSIZE_X(frame
->request
) * V4L_BYTES_PER_PIXEL
;
826 /* The header tells us what sort of data is in this frame */
827 switch (frame
->header
) {
829 * Uncompressed modes (that are easy to decode).
844 * Compressed modes (ViCE - that I don't know how to decode).
846 case 0x0328: /* 640x480, best quality compression */
847 case 0x0368: /* 640x480, best frame rate compression */
848 case 0x0228: /* 320x240, best quality compression */
849 case 0x0268: /* 320x240, best frame rate compression */
850 case 0x02CA: /* 160x120, best quality compression */
851 case 0x02EA: /* 160x120, best frame rate compression */
852 /* Do nothing with this - not supported */
853 err("Unsupported mode $%04lx", frame
->header
);
854 return scan_NextFrame
;
856 /* Catch unknown headers, may help in learning new headers */
857 err("Strange frame->header=$%08lx", frame
->header
);
858 return scan_NextFrame
;
862 * Make sure that our writing into output buffer
863 * will not exceed the buffer. Note that we may write
864 * not into current output scanline but in several after
865 * it as well (if we enlarge image vertically.)
867 if ((frame
->curline
+ 1) >= data_h
) {
869 info("Reached line %d. (frame is done)", frame
->curline
);
870 return scan_NextFrame
;
873 /* Make sure there's enough data for the entire line */
874 len
= 3 * data_w
; /* <y-data> <uv-data> */
875 assert(len
<= sizeof(lineBuffer
));
877 /* Make sure there's enough data for the entire line */
878 if (RingQueue_GetLength(&uvd
->dp
) < len
)
881 /* Suck one line out of the ring queue */
882 RingQueue_Dequeue(&uvd
->dp
, lineBuffer
, len
);
885 color
= data
+ data_w
; /* Point to where color planes begin */
887 /* Bottom-to-top scanning */
888 rw
= (int)VIDEOSIZE_Y(frame
->request
) - (int)(frame
->curline
) - 1;
889 RESTRICT_TO_RANGE(rw
, 0, VIDEOSIZE_Y(frame
->request
)-1);
891 for (i
= 0; i
< VIDEOSIZE_X(frame
->request
); i
++) {
892 int y
, rv
, gv
, bv
; /* RGB components */
895 y
= data
[i
]; /* Luminosity is the first line */
897 /* Apply static color correction */
898 u
= color
[i
*2] + hue_corr
;
899 v
= color
[i
*2 + 1] + hue2_corr
;
901 /* Apply color correction */
902 if (color_corr
!= 0) {
903 /* Magnify up to 2 times, reduce down to zero saturation */
904 u
= 128 + ((ccm
+ color_corr
) * (u
- 128)) / ccm
;
905 v
= 128 + ((ccm
+ color_corr
) * (v
- 128)) / ccm
;
910 YUV_TO_RGB_BY_THE_BOOK(y
, u
, v
, rv
, gv
, bv
);
911 RGB24_PUTPIXEL(frame
, i
, rw
, rv
, gv
, bv
); /* Done by deinterlacing now */
913 frame
->deinterlace
= Deinterlace_FillEvenLines
;
916 * Account for number of bytes that we wrote into output V4L frame.
917 * We do it here, after we are done with the scanline, because we
918 * may fill more than one output scanline if we do vertical
922 *pcopylen
+= 2 * v4l_linesize
;
924 if (frame
->curline
>= VIDEOSIZE_Y(frame
->request
)) {
925 if (uvd
->debug
>= 3) {
926 info("All requested lines (%ld.) done.",
927 VIDEOSIZE_Y(frame
->request
));
929 return scan_NextFrame
;
931 return scan_Continue
;
935 * ibmcam_model4_128x96_parse_lines()
937 * This decoder is for one strange data format that is produced by Model 4
938 * camera only in 128x96 mode. This is RGB format and here is its description.
939 * First of all, this is non-interlaced stream, meaning that all scan lines
940 * are present in the datastream. There are 96 consecutive blocks of data
941 * that describe all 96 lines of the image. Each block is 5*128 bytes long
942 * and carries R, G, B components. The format of the block is shown in the
943 * code below. First 128*2 bytes are interleaved R and G components. Then
944 * we have a gap (junk data) 64 bytes long. Then follow B and something
945 * else, also interleaved (this makes another 128*2 bytes). After that
946 * probably another 64 bytes of junk follow.
949 * 10-Feb-2001 Created.
951 static enum ParseState
ibmcam_model4_128x96_parse_lines(
953 struct usbvideo_frame
*frame
,
956 const unsigned char *data_rv
, *data_gv
, *data_bv
;
958 int i
, v4l_linesize
; /* V4L line offset */
959 const int data_w
=128, data_h
=96;
960 static unsigned char lineBuffer
[128*5];
962 v4l_linesize
= VIDEOSIZE_X(frame
->request
) * V4L_BYTES_PER_PIXEL
;
965 * Make sure that our writing into output buffer
966 * will not exceed the buffer. Note that we may write
967 * not into current output scanline but in several after
968 * it as well (if we enlarge image vertically.)
970 if ((frame
->curline
+ 1) >= data_h
) {
972 info("Reached line %d. (frame is done)", frame
->curline
);
973 return scan_NextFrame
;
977 * RGRGRG .... RGRG_____________B?B?B? ... B?B?____________
978 * <---- 128*2 ---><---- 64 ---><--- 128*2 ---><--- 64 --->
981 /* Make sure there's enough data for the entire line */
983 assert(len
<= sizeof(lineBuffer
));
985 /* Make sure there's enough data for the entire line */
986 if (RingQueue_GetLength(&uvd
->dp
) < len
)
989 /* Suck one line out of the ring queue */
990 RingQueue_Dequeue(&uvd
->dp
, lineBuffer
, len
);
992 data_rv
= lineBuffer
;
993 data_gv
= lineBuffer
+ 1;
994 data_bv
= lineBuffer
+ data_w
*2 + data_w
/2;
995 for (i
= 0; i
< VIDEOSIZE_X(frame
->request
); i
++) {
996 int rv
, gv
, bv
; /* RGB components */
1002 if (flags
& FLAGS_MONOCHROME
) {
1008 rv
= gv
= bv
= (unsigned char) y
;
1013 RGB24_PUTPIXEL(frame
, i
, frame
->curline
, rv
, gv
, bv
);
1015 frame
->deinterlace
= Deinterlace_None
;
1017 *pcopylen
+= v4l_linesize
;
1019 if (frame
->curline
>= VIDEOSIZE_Y(frame
->request
)) {
1020 if (uvd
->debug
>= 3) {
1021 info("All requested lines (%ld.) done.",
1022 VIDEOSIZE_Y(frame
->request
));
1024 return scan_NextFrame
;
1026 return scan_Continue
;
1030 * ibmcam_ProcessIsocData()
1032 * Generic routine to parse the ring queue data. It employs either
1033 * ibmcam_find_header() or ibmcam_parse_lines() to do most
1039 static void ibmcam_ProcessIsocData(struct uvd
*uvd
,
1040 struct usbvideo_frame
*frame
)
1042 enum ParseState newstate
;
1044 int mod
= IBMCAM_T(uvd
)->camera_model
;
1047 newstate
= scan_Out
;
1048 if (RingQueue_GetLength(&uvd
->dp
) > 0) {
1049 if (frame
->scanstate
== ScanState_Scanning
) {
1050 newstate
= ibmcam_find_header(uvd
);
1051 } else if (frame
->scanstate
== ScanState_Lines
) {
1052 if ((mod
== IBMCAM_MODEL_2
) &&
1053 ((uvd
->videosize
== VIDEOSIZE_352x288
) ||
1054 (uvd
->videosize
== VIDEOSIZE_320x240
) ||
1055 (uvd
->videosize
== VIDEOSIZE_352x240
)))
1057 newstate
= ibmcam_model2_320x240_parse_lines(
1058 uvd
, frame
, ©len
);
1059 } else if (mod
== IBMCAM_MODEL_4
) {
1061 * Model 4 cameras (IBM NetCamera) use Model 2 decoder (RGB)
1062 * for 320x240 and above; 160x120 and 176x144 uses Model 1
1063 * decoder (YUV), and 128x96 mode uses ???
1065 if ((uvd
->videosize
== VIDEOSIZE_352x288
) ||
1066 (uvd
->videosize
== VIDEOSIZE_320x240
) ||
1067 (uvd
->videosize
== VIDEOSIZE_352x240
))
1069 newstate
= ibmcam_model2_320x240_parse_lines(uvd
, frame
, ©len
);
1070 } else if (uvd
->videosize
== VIDEOSIZE_128x96
) {
1071 newstate
= ibmcam_model4_128x96_parse_lines(uvd
, frame
, ©len
);
1073 newstate
= ibmcam_parse_lines(uvd
, frame
, ©len
);
1075 } else if (mod
== IBMCAM_MODEL_3
) {
1076 newstate
= ibmcam_model3_parse_lines(uvd
, frame
, ©len
);
1078 newstate
= ibmcam_parse_lines(uvd
, frame
, ©len
);
1082 if (newstate
== scan_Continue
)
1084 else if ((newstate
== scan_NextFrame
) || (newstate
== scan_Out
))
1087 return; /* scan_EndParse */
1090 if (newstate
== scan_NextFrame
) {
1091 frame
->frameState
= FrameState_Done
;
1093 uvd
->stats
.frame_num
++;
1094 if ((mod
== IBMCAM_MODEL_2
) || (mod
== IBMCAM_MODEL_4
)) {
1095 /* Need software contrast adjustment for those cameras */
1096 frame
->flags
|= USBVIDEO_FRAME_FLAG_SOFTWARE_CONTRAST
;
1100 /* Update the frame's uncompressed length. */
1101 frame
->seqRead_Length
+= copylen
;
1105 static unsigned char j
=0;
1106 memset(frame
->data
, j
++, uvd
->max_frame_size
);
1107 frame
->frameState
= FrameState_Ready
;
1116 * 1/27/00 Added check for dev == NULL; this happens if camera is unplugged.
1118 static int ibmcam_veio(
1121 unsigned short value
,
1122 unsigned short index
)
1124 static const char proc
[] = "ibmcam_veio";
1125 unsigned char cp
[8] /* = { 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef } */;
1128 if (!CAMERA_IS_OPERATIONAL(uvd
))
1132 i
= usb_control_msg(
1134 usb_rcvctrlpipe(uvd
->dev
, 0),
1136 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_ENDPOINT
,
1143 info("USB => %02x%02x%02x%02x%02x%02x%02x%02x "
1144 "(req=$%02x val=$%04x ind=$%04x)",
1145 cp
[0],cp
[1],cp
[2],cp
[3],cp
[4],cp
[5],cp
[6],cp
[7],
1149 i
= usb_control_msg(
1151 usb_sndctrlpipe(uvd
->dev
, 0),
1153 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_ENDPOINT
,
1161 err("%s: ERROR=%d. Camera stopped; Reconnect or reload driver.",
1163 uvd
->last_error
= i
;
1169 * ibmcam_calculate_fps()
1171 * This procedure roughly calculates the real frame rate based
1172 * on FPS code (framerate=NNN option). Actual FPS differs
1173 * slightly depending on lighting conditions, so that actual frame
1174 * rate is determined by the camera. Since I don't know how to ask
1175 * the camera what FPS is now I have to use the FPS code instead.
1177 * The FPS code is in range [0..6], 0 is slowest, 6 is fastest.
1178 * Corresponding real FPS should be in range [3..30] frames per second.
1179 * The conversion formula is obvious:
1181 * real_fps = 3 + (fps_code * 4.5)
1186 static int ibmcam_calculate_fps(struct uvd
*uvd
)
1188 return 3 + framerate
*4 + framerate
/2;
1192 * ibmcam_send_FF_04_02()
1194 * This procedure sends magic 3-command prefix to the camera.
1195 * The purpose of this prefix is not known.
1200 static void ibmcam_send_FF_04_02(struct uvd
*uvd
)
1202 ibmcam_veio(uvd
, 0, 0x00FF, 0x0127);
1203 ibmcam_veio(uvd
, 0, 0x0004, 0x0124);
1204 ibmcam_veio(uvd
, 0, 0x0002, 0x0124);
1207 static void ibmcam_send_00_04_06(struct uvd
*uvd
)
1209 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
1210 ibmcam_veio(uvd
, 0, 0x0004, 0x0124);
1211 ibmcam_veio(uvd
, 0, 0x0006, 0x0124);
1214 static void ibmcam_send_x_00(struct uvd
*uvd
, unsigned short x
)
1216 ibmcam_veio(uvd
, 0, x
, 0x0127);
1217 ibmcam_veio(uvd
, 0, 0x0000, 0x0124);
1220 static void ibmcam_send_x_00_05(struct uvd
*uvd
, unsigned short x
)
1222 ibmcam_send_x_00(uvd
, x
);
1223 ibmcam_veio(uvd
, 0, 0x0005, 0x0124);
1226 static void ibmcam_send_x_00_05_02(struct uvd
*uvd
, unsigned short x
)
1228 ibmcam_veio(uvd
, 0, x
, 0x0127);
1229 ibmcam_veio(uvd
, 0, 0x0000, 0x0124);
1230 ibmcam_veio(uvd
, 0, 0x0005, 0x0124);
1231 ibmcam_veio(uvd
, 0, 0x0002, 0x0124);
1234 static void ibmcam_send_x_01_00_05(struct uvd
*uvd
, unsigned short x
)
1236 ibmcam_veio(uvd
, 0, x
, 0x0127);
1237 ibmcam_veio(uvd
, 0, 0x0001, 0x0124);
1238 ibmcam_veio(uvd
, 0, 0x0000, 0x0124);
1239 ibmcam_veio(uvd
, 0, 0x0005, 0x0124);
1242 static void ibmcam_send_x_00_05_02_01(struct uvd
*uvd
, unsigned short x
)
1244 ibmcam_veio(uvd
, 0, x
, 0x0127);
1245 ibmcam_veio(uvd
, 0, 0x0000, 0x0124);
1246 ibmcam_veio(uvd
, 0, 0x0005, 0x0124);
1247 ibmcam_veio(uvd
, 0, 0x0002, 0x0124);
1248 ibmcam_veio(uvd
, 0, 0x0001, 0x0124);
1251 static void ibmcam_send_x_00_05_02_08_01(struct uvd
*uvd
, unsigned short x
)
1253 ibmcam_veio(uvd
, 0, x
, 0x0127);
1254 ibmcam_veio(uvd
, 0, 0x0000, 0x0124);
1255 ibmcam_veio(uvd
, 0, 0x0005, 0x0124);
1256 ibmcam_veio(uvd
, 0, 0x0002, 0x0124);
1257 ibmcam_veio(uvd
, 0, 0x0008, 0x0124);
1258 ibmcam_veio(uvd
, 0, 0x0001, 0x0124);
1261 static void ibmcam_Packet_Format1(struct uvd
*uvd
, unsigned char fkey
, unsigned char val
)
1263 ibmcam_send_x_01_00_05(uvd
, unknown_88
);
1264 ibmcam_send_x_00_05(uvd
, fkey
);
1265 ibmcam_send_x_00_05_02_08_01(uvd
, val
);
1266 ibmcam_send_x_00_05(uvd
, unknown_88
);
1267 ibmcam_send_x_00_05_02_01(uvd
, fkey
);
1268 ibmcam_send_x_00_05(uvd
, unknown_89
);
1269 ibmcam_send_x_00(uvd
, fkey
);
1270 ibmcam_send_00_04_06(uvd
);
1271 ibmcam_veio(uvd
, 1, 0x0000, 0x0126);
1272 ibmcam_send_FF_04_02(uvd
);
1275 static void ibmcam_PacketFormat2(struct uvd
*uvd
, unsigned char fkey
, unsigned char val
)
1277 ibmcam_send_x_01_00_05 (uvd
, unknown_88
);
1278 ibmcam_send_x_00_05 (uvd
, fkey
);
1279 ibmcam_send_x_00_05_02 (uvd
, val
);
1282 static void ibmcam_model2_Packet2(struct uvd
*uvd
)
1284 ibmcam_veio(uvd
, 0, 0x00ff, 0x012d);
1285 ibmcam_veio(uvd
, 0, 0xfea3, 0x0124);
1288 static void ibmcam_model2_Packet1(struct uvd
*uvd
, unsigned short v1
, unsigned short v2
)
1290 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
1291 ibmcam_veio(uvd
, 0, 0x00ff, 0x012e);
1292 ibmcam_veio(uvd
, 0, v1
, 0x012f);
1293 ibmcam_veio(uvd
, 0, 0x00ff, 0x0130);
1294 ibmcam_veio(uvd
, 0, 0xc719, 0x0124);
1295 ibmcam_veio(uvd
, 0, v2
, 0x0127);
1297 ibmcam_model2_Packet2(uvd
);
1301 * ibmcam_model3_Packet1()
1309 static void ibmcam_model3_Packet1(struct uvd
*uvd
, unsigned short v1
, unsigned short v2
)
1311 ibmcam_veio(uvd
, 0, 0x0078, 0x012d);
1312 ibmcam_veio(uvd
, 0, v1
, 0x012f);
1313 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
1314 ibmcam_veio(uvd
, 0, v2
, 0x0127);
1315 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
1318 static void ibmcam_model4_BrightnessPacket(struct uvd
*uvd
, int i
)
1320 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
1321 ibmcam_veio(uvd
, 0, 0x0026, 0x012f);
1322 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
1323 ibmcam_veio(uvd
, 0, i
, 0x0127);
1324 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
1325 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
1326 ibmcam_veio(uvd
, 0, 0x0038, 0x012d);
1327 ibmcam_veio(uvd
, 0, 0x0004, 0x012f);
1328 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
1329 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
1333 * ibmcam_adjust_contrast()
1335 * The contrast value changes from 0 (high contrast) to 15 (low contrast).
1336 * This is in reverse to usual order of things (such as TV controls), so
1337 * we reverse it again here.
1339 * TODO: we probably don't need to send the setup 5 times...
1344 static void ibmcam_adjust_contrast(struct uvd
*uvd
)
1346 unsigned char a_contrast
= uvd
->vpic
.contrast
>> 12;
1347 unsigned char new_contrast
;
1349 if (a_contrast
>= 16)
1351 new_contrast
= 15 - a_contrast
;
1352 if (new_contrast
== uvd
->vpic_old
.contrast
)
1354 uvd
->vpic_old
.contrast
= new_contrast
;
1355 switch (IBMCAM_T(uvd
)->camera_model
) {
1356 case IBMCAM_MODEL_1
:
1358 const int ntries
= 5;
1360 for (i
=0; i
< ntries
; i
++) {
1361 ibmcam_Packet_Format1(uvd
, contrast_14
, new_contrast
);
1362 ibmcam_send_FF_04_02(uvd
);
1366 case IBMCAM_MODEL_2
:
1367 case IBMCAM_MODEL_4
:
1368 /* Models 2, 4 do not have this control; implemented in software. */
1370 case IBMCAM_MODEL_3
:
1371 { /* Preset hardware values */
1372 static const struct {
1377 { 0x05, 0x05, 0x0f }, /* Minimum */
1378 { 0x04, 0x04, 0x16 },
1379 { 0x02, 0x03, 0x16 },
1380 { 0x02, 0x08, 0x16 },
1381 { 0x01, 0x0c, 0x16 },
1382 { 0x01, 0x0e, 0x16 },
1383 { 0x01, 0x10, 0x16 } /* Maximum */
1385 int i
= a_contrast
/ 2;
1386 RESTRICT_TO_RANGE(i
, 0, 6);
1387 ibmcam_veio(uvd
, 0, 0x0000, 0x010c); /* Stop */
1388 ibmcam_model3_Packet1(uvd
, 0x0067, cv
[i
].cv1
);
1389 ibmcam_model3_Packet1(uvd
, 0x005b, cv
[i
].cv2
);
1390 ibmcam_model3_Packet1(uvd
, 0x005c, cv
[i
].cv3
);
1391 ibmcam_veio(uvd
, 0, 0x0001, 0x0114);
1392 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c); /* Go! */
1393 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
1402 * ibmcam_change_lighting_conditions()
1405 * We have 3 levels of lighting conditions: 0=Bright, 1=Medium, 2=Low.
1408 * We have 16 levels of lighting, 0 for bright light and up to 15 for
1409 * low light. But values above 5 or so are useless because camera is
1410 * not really capable to produce anything worth viewing at such light.
1411 * This setting may be altered only in certain camera state.
1413 * Low lighting forces slower FPS. Lighting is set as a module parameter.
1417 * 2/20/00 Added support for Model 2 cameras.
1419 static void ibmcam_change_lighting_conditions(struct uvd
*uvd
)
1421 static const char proc
[] = "ibmcam_change_lighting_conditions";
1424 info("%s: Set lighting to %hu.", proc
, lighting
);
1426 switch (IBMCAM_T(uvd
)->camera_model
) {
1427 case IBMCAM_MODEL_1
:
1429 const int ntries
= 5;
1431 for (i
=0; i
< ntries
; i
++)
1432 ibmcam_Packet_Format1(uvd
, light_27
, (unsigned short) lighting
);
1435 case IBMCAM_MODEL_2
:
1438 * This command apparently requires camera to be stopped. My
1439 * experiments showed that it -is- possible to alter the lighting
1440 * conditions setting "on the fly", but why bother? This setting does
1441 * not work reliably in all cases, so I decided simply to leave the
1442 * setting where Xirlink put it - in the camera setup phase. This code
1443 * is commented out because it does not work at -any- moment, so its
1444 * presence makes no sense. You may use it for experiments.
1446 ibmcam_veio(uvd
, 0, 0x0000, 0x010c); /* Stop camera */
1447 ibmcam_model2_Packet1(uvd
, mod2_sensitivity
, lighting
);
1448 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c); /* Start camera */
1451 case IBMCAM_MODEL_3
:
1452 case IBMCAM_MODEL_4
:
1459 * ibmcam_set_sharpness()
1461 * Cameras model 1 have internal smoothing feature. It is controlled by value in
1462 * range [0..6], where 0 is most smooth and 6 is most sharp (raw image, I guess).
1463 * Recommended value is 4. Cameras model 2 do not have this feature at all.
1465 static void ibmcam_set_sharpness(struct uvd
*uvd
)
1467 static const char proc
[] = "ibmcam_set_sharpness";
1469 switch (IBMCAM_T(uvd
)->camera_model
) {
1470 case IBMCAM_MODEL_1
:
1472 static const unsigned short sa
[] = { 0x11, 0x13, 0x16, 0x18, 0x1a, 0x8, 0x0a };
1473 unsigned short i
, sv
;
1475 RESTRICT_TO_RANGE(sharpness
, SHARPNESS_MIN
, SHARPNESS_MAX
);
1477 info("%s: Set sharpness to %hu.", proc
, sharpness
);
1479 sv
= sa
[sharpness
- SHARPNESS_MIN
];
1480 for (i
=0; i
< 2; i
++) {
1481 ibmcam_send_x_01_00_05 (uvd
, unknown_88
);
1482 ibmcam_send_x_00_05 (uvd
, sharp_13
);
1483 ibmcam_send_x_00_05_02 (uvd
, sv
);
1487 case IBMCAM_MODEL_2
:
1488 case IBMCAM_MODEL_4
:
1489 /* Models 2, 4 do not have this control */
1491 case IBMCAM_MODEL_3
:
1493 * "Use a table of magic numbers.
1494 * This setting doesn't really change much.
1495 * But that's how Windows does it."
1497 static const struct {
1503 { 0x00, 0x00, 0x05, 0x14 }, /* Smoothest */
1504 { 0x01, 0x04, 0x05, 0x14 },
1505 { 0x02, 0x04, 0x05, 0x14 },
1506 { 0x03, 0x04, 0x05, 0x14 },
1507 { 0x03, 0x05, 0x05, 0x14 },
1508 { 0x03, 0x06, 0x05, 0x14 },
1509 { 0x03, 0x07, 0x05, 0x14 } /* Sharpest */
1511 RESTRICT_TO_RANGE(sharpness
, SHARPNESS_MIN
, SHARPNESS_MAX
);
1512 RESTRICT_TO_RANGE(sharpness
, 0, 6);
1513 ibmcam_veio(uvd
, 0, 0x0000, 0x010c); /* Stop */
1514 ibmcam_model3_Packet1(uvd
, 0x0060, sv
[sharpness
].sv1
);
1515 ibmcam_model3_Packet1(uvd
, 0x0061, sv
[sharpness
].sv2
);
1516 ibmcam_model3_Packet1(uvd
, 0x0062, sv
[sharpness
].sv3
);
1517 ibmcam_model3_Packet1(uvd
, 0x0063, sv
[sharpness
].sv4
);
1518 ibmcam_veio(uvd
, 0, 0x0001, 0x0114);
1519 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c); /* Go! */
1520 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
1521 ibmcam_veio(uvd
, 0, 0x0001, 0x0113);
1530 * ibmcam_set_brightness()
1532 * This procedure changes brightness of the picture.
1534 static void ibmcam_set_brightness(struct uvd
*uvd
)
1536 static const char proc
[] = "ibmcam_set_brightness";
1537 static const unsigned short n
= 1;
1540 info("%s: Set brightness to %hu.", proc
, uvd
->vpic
.brightness
);
1542 switch (IBMCAM_T(uvd
)->camera_model
) {
1543 case IBMCAM_MODEL_1
:
1545 unsigned short i
, j
, bv
[3];
1546 bv
[0] = bv
[1] = bv
[2] = uvd
->vpic
.brightness
>> 10;
1547 if (bv
[0] == (uvd
->vpic_old
.brightness
>> 10))
1549 uvd
->vpic_old
.brightness
= bv
[0];
1550 for (j
=0; j
< 3; j
++)
1551 for (i
=0; i
< n
; i
++)
1552 ibmcam_Packet_Format1(uvd
, bright_3x
[j
], bv
[j
]);
1555 case IBMCAM_MODEL_2
:
1557 unsigned short i
, j
;
1558 i
= uvd
->vpic
.brightness
>> 12; /* 0 .. 15 */
1559 j
= 0x60 + i
* ((0xee - 0x60) / 16); /* 0x60 .. 0xee or so */
1560 if (uvd
->vpic_old
.brightness
== j
)
1562 uvd
->vpic_old
.brightness
= j
;
1563 ibmcam_model2_Packet1(uvd
, mod2_brightness
, j
);
1566 case IBMCAM_MODEL_3
:
1568 /* Model 3: Brightness range 'i' in [0x0C..0x3F] */
1570 0x0C + (uvd
->vpic
.brightness
/ (0xFFFF / (0x3F - 0x0C + 1)));
1571 RESTRICT_TO_RANGE(i
, 0x0C, 0x3F);
1572 if (uvd
->vpic_old
.brightness
== i
)
1574 uvd
->vpic_old
.brightness
= i
;
1575 ibmcam_veio(uvd
, 0, 0x0000, 0x010c); /* Stop */
1576 ibmcam_model3_Packet1(uvd
, 0x0036, i
);
1577 ibmcam_veio(uvd
, 0, 0x0001, 0x0114);
1578 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c); /* Go! */
1579 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
1580 ibmcam_veio(uvd
, 0, 0x0001, 0x0113);
1583 case IBMCAM_MODEL_4
:
1585 /* Model 4: Brightness range 'i' in [0x04..0xb4] */
1586 unsigned short i
= 0x04 + (uvd
->vpic
.brightness
/ (0xFFFF / (0xb4 - 0x04 + 1)));
1587 RESTRICT_TO_RANGE(i
, 0x04, 0xb4);
1588 if (uvd
->vpic_old
.brightness
== i
)
1590 uvd
->vpic_old
.brightness
= i
;
1591 ibmcam_model4_BrightnessPacket(uvd
, i
);
1599 static void ibmcam_set_hue(struct uvd
*uvd
)
1601 switch (IBMCAM_T(uvd
)->camera_model
) {
1602 case IBMCAM_MODEL_2
:
1604 unsigned short hue
= uvd
->vpic
.hue
>> 9; /* 0 .. 7F */
1605 if (uvd
->vpic_old
.hue
== hue
)
1607 uvd
->vpic_old
.hue
= hue
;
1608 ibmcam_model2_Packet1(uvd
, mod2_hue
, hue
);
1609 /* ibmcam_model2_Packet1(uvd, mod2_saturation, sat); */
1612 case IBMCAM_MODEL_3
:
1614 #if 0 /* This seems not to work. No problem, will fix programmatically */
1615 unsigned short hue
= 0x05 + (uvd
->vpic
.hue
/ (0xFFFF / (0x37 - 0x05 + 1)));
1616 RESTRICT_TO_RANGE(hue
, 0x05, 0x37);
1617 if (uvd
->vpic_old
.hue
== hue
)
1619 uvd
->vpic_old
.hue
= hue
;
1620 ibmcam_veio(uvd
, 0, 0x0000, 0x010c); /* Stop */
1621 ibmcam_model3_Packet1(uvd
, 0x007e, hue
);
1622 ibmcam_veio(uvd
, 0, 0x0001, 0x0114);
1623 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c); /* Go! */
1624 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
1625 ibmcam_veio(uvd
, 0, 0x0001, 0x0113);
1629 case IBMCAM_MODEL_4
:
1631 unsigned short r_gain
, g_gain
, b_gain
, hue
;
1634 * I am not sure r/g/b_gain variables exactly control gain
1635 * of those channels. Most likely they subtly change some
1636 * very internal image processing settings in the camera.
1637 * In any case, here is what they do, and feel free to tweak:
1639 * r_gain: seriously affects red gain
1640 * g_gain: seriously affects green gain
1641 * b_gain: seriously affects blue gain
1642 * hue: changes average color from violet (0) to red (0xFF)
1644 * These settings are preset for a decent white balance in
1645 * 320x240, 352x288 modes. Low-res modes exhibit higher contrast
1646 * and therefore may need different values here.
1648 hue
= 20 + (uvd
->vpic
.hue
>> 9);
1649 switch (uvd
->videosize
) {
1650 case VIDEOSIZE_128x96
:
1655 case VIDEOSIZE_160x120
:
1660 case VIDEOSIZE_176x144
:
1671 RESTRICT_TO_RANGE(hue
, 1, 0x7f);
1673 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
1674 ibmcam_veio(uvd
, 0, 0x001e, 0x012f);
1675 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
1676 ibmcam_veio(uvd
, 0, g_gain
, 0x0127); /* Green gain */
1677 ibmcam_veio(uvd
, 0, r_gain
, 0x012e); /* Red gain */
1678 ibmcam_veio(uvd
, 0, b_gain
, 0x0130); /* Blue gain */
1679 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
1680 ibmcam_veio(uvd
, 0, hue
, 0x012d); /* Hue */
1681 ibmcam_veio(uvd
, 0, 0xf545, 0x0124);
1690 * ibmcam_adjust_picture()
1692 * This procedure gets called from V4L interface to update picture settings.
1693 * Here we change brightness and contrast.
1695 static void ibmcam_adjust_picture(struct uvd
*uvd
)
1697 ibmcam_adjust_contrast(uvd
);
1698 ibmcam_set_brightness(uvd
);
1699 ibmcam_set_hue(uvd
);
1702 static int ibmcam_model1_setup(struct uvd
*uvd
)
1704 const int ntries
= 5;
1707 ibmcam_veio(uvd
, 1, 0x00, 0x0128);
1708 ibmcam_veio(uvd
, 1, 0x00, 0x0100);
1709 ibmcam_veio(uvd
, 0, 0x01, 0x0100); /* LED On */
1710 ibmcam_veio(uvd
, 1, 0x00, 0x0100);
1711 ibmcam_veio(uvd
, 0, 0x81, 0x0100); /* LED Off */
1712 ibmcam_veio(uvd
, 1, 0x00, 0x0100);
1713 ibmcam_veio(uvd
, 0, 0x01, 0x0100); /* LED On */
1714 ibmcam_veio(uvd
, 0, 0x01, 0x0108);
1716 ibmcam_veio(uvd
, 0, 0x03, 0x0112);
1717 ibmcam_veio(uvd
, 1, 0x00, 0x0115);
1718 ibmcam_veio(uvd
, 0, 0x06, 0x0115);
1719 ibmcam_veio(uvd
, 1, 0x00, 0x0116);
1720 ibmcam_veio(uvd
, 0, 0x44, 0x0116);
1721 ibmcam_veio(uvd
, 1, 0x00, 0x0116);
1722 ibmcam_veio(uvd
, 0, 0x40, 0x0116);
1723 ibmcam_veio(uvd
, 1, 0x00, 0x0115);
1724 ibmcam_veio(uvd
, 0, 0x0e, 0x0115);
1725 ibmcam_veio(uvd
, 0, 0x19, 0x012c);
1727 ibmcam_Packet_Format1(uvd
, 0x00, 0x1e);
1728 ibmcam_Packet_Format1(uvd
, 0x39, 0x0d);
1729 ibmcam_Packet_Format1(uvd
, 0x39, 0x09);
1730 ibmcam_Packet_Format1(uvd
, 0x3b, 0x00);
1731 ibmcam_Packet_Format1(uvd
, 0x28, 0x22);
1732 ibmcam_Packet_Format1(uvd
, light_27
, 0);
1733 ibmcam_Packet_Format1(uvd
, 0x2b, 0x1f);
1734 ibmcam_Packet_Format1(uvd
, 0x39, 0x08);
1736 for (i
=0; i
< ntries
; i
++)
1737 ibmcam_Packet_Format1(uvd
, 0x2c, 0x00);
1739 for (i
=0; i
< ntries
; i
++)
1740 ibmcam_Packet_Format1(uvd
, 0x30, 0x14);
1742 ibmcam_PacketFormat2(uvd
, 0x39, 0x02);
1743 ibmcam_PacketFormat2(uvd
, 0x01, 0xe1);
1744 ibmcam_PacketFormat2(uvd
, 0x02, 0xcd);
1745 ibmcam_PacketFormat2(uvd
, 0x03, 0xcd);
1746 ibmcam_PacketFormat2(uvd
, 0x04, 0xfa);
1747 ibmcam_PacketFormat2(uvd
, 0x3f, 0xff);
1748 ibmcam_PacketFormat2(uvd
, 0x39, 0x00);
1750 ibmcam_PacketFormat2(uvd
, 0x39, 0x02);
1751 ibmcam_PacketFormat2(uvd
, 0x0a, 0x37);
1752 ibmcam_PacketFormat2(uvd
, 0x0b, 0xb8);
1753 ibmcam_PacketFormat2(uvd
, 0x0c, 0xf3);
1754 ibmcam_PacketFormat2(uvd
, 0x0d, 0xe3);
1755 ibmcam_PacketFormat2(uvd
, 0x0e, 0x0d);
1756 ibmcam_PacketFormat2(uvd
, 0x0f, 0xf2);
1757 ibmcam_PacketFormat2(uvd
, 0x10, 0xd5);
1758 ibmcam_PacketFormat2(uvd
, 0x11, 0xba);
1759 ibmcam_PacketFormat2(uvd
, 0x12, 0x53);
1760 ibmcam_PacketFormat2(uvd
, 0x3f, 0xff);
1761 ibmcam_PacketFormat2(uvd
, 0x39, 0x00);
1763 ibmcam_PacketFormat2(uvd
, 0x39, 0x02);
1764 ibmcam_PacketFormat2(uvd
, 0x16, 0x00);
1765 ibmcam_PacketFormat2(uvd
, 0x17, 0x28);
1766 ibmcam_PacketFormat2(uvd
, 0x18, 0x7d);
1767 ibmcam_PacketFormat2(uvd
, 0x19, 0xbe);
1768 ibmcam_PacketFormat2(uvd
, 0x3f, 0xff);
1769 ibmcam_PacketFormat2(uvd
, 0x39, 0x00);
1771 for (i
=0; i
< ntries
; i
++)
1772 ibmcam_Packet_Format1(uvd
, 0x00, 0x18);
1773 for (i
=0; i
< ntries
; i
++)
1774 ibmcam_Packet_Format1(uvd
, 0x13, 0x18);
1775 for (i
=0; i
< ntries
; i
++)
1776 ibmcam_Packet_Format1(uvd
, 0x14, 0x06);
1778 /* This is default brightness */
1779 for (i
=0; i
< ntries
; i
++)
1780 ibmcam_Packet_Format1(uvd
, 0x31, 0x37);
1781 for (i
=0; i
< ntries
; i
++)
1782 ibmcam_Packet_Format1(uvd
, 0x32, 0x46);
1783 for (i
=0; i
< ntries
; i
++)
1784 ibmcam_Packet_Format1(uvd
, 0x33, 0x55);
1786 ibmcam_Packet_Format1(uvd
, 0x2e, 0x04);
1787 for (i
=0; i
< ntries
; i
++)
1788 ibmcam_Packet_Format1(uvd
, 0x2d, 0x04);
1789 for (i
=0; i
< ntries
; i
++)
1790 ibmcam_Packet_Format1(uvd
, 0x29, 0x80);
1791 ibmcam_Packet_Format1(uvd
, 0x2c, 0x01);
1792 ibmcam_Packet_Format1(uvd
, 0x30, 0x17);
1793 ibmcam_Packet_Format1(uvd
, 0x39, 0x08);
1794 for (i
=0; i
< ntries
; i
++)
1795 ibmcam_Packet_Format1(uvd
, 0x34, 0x00);
1797 ibmcam_veio(uvd
, 0, 0x00, 0x0101);
1798 ibmcam_veio(uvd
, 0, 0x00, 0x010a);
1800 switch (uvd
->videosize
) {
1801 case VIDEOSIZE_128x96
:
1802 ibmcam_veio(uvd
, 0, 0x80, 0x0103);
1803 ibmcam_veio(uvd
, 0, 0x60, 0x0105);
1804 ibmcam_veio(uvd
, 0, 0x0c, 0x010b);
1805 ibmcam_veio(uvd
, 0, 0x04, 0x011b); /* Same everywhere */
1806 ibmcam_veio(uvd
, 0, 0x0b, 0x011d);
1807 ibmcam_veio(uvd
, 0, 0x00, 0x011e); /* Same everywhere */
1808 ibmcam_veio(uvd
, 0, 0x00, 0x0129);
1810 case VIDEOSIZE_176x144
:
1811 ibmcam_veio(uvd
, 0, 0xb0, 0x0103);
1812 ibmcam_veio(uvd
, 0, 0x8f, 0x0105);
1813 ibmcam_veio(uvd
, 0, 0x06, 0x010b);
1814 ibmcam_veio(uvd
, 0, 0x04, 0x011b); /* Same everywhere */
1815 ibmcam_veio(uvd
, 0, 0x0d, 0x011d);
1816 ibmcam_veio(uvd
, 0, 0x00, 0x011e); /* Same everywhere */
1817 ibmcam_veio(uvd
, 0, 0x03, 0x0129);
1819 case VIDEOSIZE_352x288
:
1820 ibmcam_veio(uvd
, 0, 0xb0, 0x0103);
1821 ibmcam_veio(uvd
, 0, 0x90, 0x0105);
1822 ibmcam_veio(uvd
, 0, 0x02, 0x010b);
1823 ibmcam_veio(uvd
, 0, 0x04, 0x011b); /* Same everywhere */
1824 ibmcam_veio(uvd
, 0, 0x05, 0x011d);
1825 ibmcam_veio(uvd
, 0, 0x00, 0x011e); /* Same everywhere */
1826 ibmcam_veio(uvd
, 0, 0x00, 0x0129);
1830 ibmcam_veio(uvd
, 0, 0xff, 0x012b);
1832 /* This is another brightness - don't know why */
1833 for (i
=0; i
< ntries
; i
++)
1834 ibmcam_Packet_Format1(uvd
, 0x31, 0xc3);
1835 for (i
=0; i
< ntries
; i
++)
1836 ibmcam_Packet_Format1(uvd
, 0x32, 0xd2);
1837 for (i
=0; i
< ntries
; i
++)
1838 ibmcam_Packet_Format1(uvd
, 0x33, 0xe1);
1840 /* Default contrast */
1841 for (i
=0; i
< ntries
; i
++)
1842 ibmcam_Packet_Format1(uvd
, contrast_14
, 0x0a);
1844 /* Default sharpness */
1845 for (i
=0; i
< 2; i
++)
1846 ibmcam_PacketFormat2(uvd
, sharp_13
, 0x1a); /* Level 4 FIXME */
1848 /* Default lighting conditions */
1849 ibmcam_Packet_Format1(uvd
, light_27
, lighting
); /* 0=Bright 2=Low */
1853 switch (uvd
->videosize
) {
1854 case VIDEOSIZE_128x96
:
1855 ibmcam_Packet_Format1(uvd
, 0x2b, 0x1e);
1856 ibmcam_veio(uvd
, 0, 0xc9, 0x0119); /* Same everywhere */
1857 ibmcam_veio(uvd
, 0, 0x80, 0x0109); /* Same everywhere */
1858 ibmcam_veio(uvd
, 0, 0x36, 0x0102);
1859 ibmcam_veio(uvd
, 0, 0x1a, 0x0104);
1860 ibmcam_veio(uvd
, 0, 0x04, 0x011a); /* Same everywhere */
1861 ibmcam_veio(uvd
, 0, 0x2b, 0x011c);
1862 ibmcam_veio(uvd
, 0, 0x23, 0x012a); /* Same everywhere */
1864 ibmcam_veio(uvd
, 0, 0x00, 0x0106);
1865 ibmcam_veio(uvd
, 0, 0x38, 0x0107);
1867 ibmcam_veio(uvd
, 0, 0x02, 0x0106);
1868 ibmcam_veio(uvd
, 0, 0x2a, 0x0107);
1871 case VIDEOSIZE_176x144
:
1872 ibmcam_Packet_Format1(uvd
, 0x2b, 0x1e);
1873 ibmcam_veio(uvd
, 0, 0xc9, 0x0119); /* Same everywhere */
1874 ibmcam_veio(uvd
, 0, 0x80, 0x0109); /* Same everywhere */
1875 ibmcam_veio(uvd
, 0, 0x04, 0x0102);
1876 ibmcam_veio(uvd
, 0, 0x02, 0x0104);
1877 ibmcam_veio(uvd
, 0, 0x04, 0x011a); /* Same everywhere */
1878 ibmcam_veio(uvd
, 0, 0x2b, 0x011c);
1879 ibmcam_veio(uvd
, 0, 0x23, 0x012a); /* Same everywhere */
1880 ibmcam_veio(uvd
, 0, 0x01, 0x0106);
1881 ibmcam_veio(uvd
, 0, 0xca, 0x0107);
1883 case VIDEOSIZE_352x288
:
1884 ibmcam_Packet_Format1(uvd
, 0x2b, 0x1f);
1885 ibmcam_veio(uvd
, 0, 0xc9, 0x0119); /* Same everywhere */
1886 ibmcam_veio(uvd
, 0, 0x80, 0x0109); /* Same everywhere */
1887 ibmcam_veio(uvd
, 0, 0x08, 0x0102);
1888 ibmcam_veio(uvd
, 0, 0x01, 0x0104);
1889 ibmcam_veio(uvd
, 0, 0x04, 0x011a); /* Same everywhere */
1890 ibmcam_veio(uvd
, 0, 0x2f, 0x011c);
1891 ibmcam_veio(uvd
, 0, 0x23, 0x012a); /* Same everywhere */
1892 ibmcam_veio(uvd
, 0, 0x03, 0x0106);
1893 ibmcam_veio(uvd
, 0, 0xf6, 0x0107);
1896 return (CAMERA_IS_OPERATIONAL(uvd
) ? 0 : -EFAULT
);
1899 static int ibmcam_model2_setup(struct uvd
*uvd
)
1901 ibmcam_veio(uvd
, 0, 0x0000, 0x0100); /* LED on */
1902 ibmcam_veio(uvd
, 1, 0x0000, 0x0116);
1903 ibmcam_veio(uvd
, 0, 0x0060, 0x0116);
1904 ibmcam_veio(uvd
, 0, 0x0002, 0x0112);
1905 ibmcam_veio(uvd
, 0, 0x00bc, 0x012c);
1906 ibmcam_veio(uvd
, 0, 0x0008, 0x012b);
1907 ibmcam_veio(uvd
, 0, 0x0000, 0x0108);
1908 ibmcam_veio(uvd
, 0, 0x0001, 0x0133);
1909 ibmcam_veio(uvd
, 0, 0x0001, 0x0102);
1910 switch (uvd
->videosize
) {
1911 case VIDEOSIZE_176x144
:
1912 ibmcam_veio(uvd
, 0, 0x002c, 0x0103); /* All except 320x240 */
1913 ibmcam_veio(uvd
, 0, 0x0000, 0x0104); /* Same */
1914 ibmcam_veio(uvd
, 0, 0x0024, 0x0105); /* 176x144, 352x288 */
1915 ibmcam_veio(uvd
, 0, 0x00b9, 0x010a); /* Unique to this mode */
1916 ibmcam_veio(uvd
, 0, 0x0038, 0x0119); /* Unique to this mode */
1917 ibmcam_veio(uvd
, 0, 0x0003, 0x0106); /* Same */
1918 ibmcam_veio(uvd
, 0, 0x0090, 0x0107); /* Unique to every mode*/
1920 case VIDEOSIZE_320x240
:
1921 ibmcam_veio(uvd
, 0, 0x0028, 0x0103); /* Unique to this mode */
1922 ibmcam_veio(uvd
, 0, 0x0000, 0x0104); /* Same */
1923 ibmcam_veio(uvd
, 0, 0x001e, 0x0105); /* 320x240, 352x240 */
1924 ibmcam_veio(uvd
, 0, 0x0039, 0x010a); /* All except 176x144 */
1925 ibmcam_veio(uvd
, 0, 0x0070, 0x0119); /* All except 176x144 */
1926 ibmcam_veio(uvd
, 0, 0x0003, 0x0106); /* Same */
1927 ibmcam_veio(uvd
, 0, 0x0098, 0x0107); /* Unique to every mode*/
1929 case VIDEOSIZE_352x240
:
1930 ibmcam_veio(uvd
, 0, 0x002c, 0x0103); /* All except 320x240 */
1931 ibmcam_veio(uvd
, 0, 0x0000, 0x0104); /* Same */
1932 ibmcam_veio(uvd
, 0, 0x001e, 0x0105); /* 320x240, 352x240 */
1933 ibmcam_veio(uvd
, 0, 0x0039, 0x010a); /* All except 176x144 */
1934 ibmcam_veio(uvd
, 0, 0x0070, 0x0119); /* All except 176x144 */
1935 ibmcam_veio(uvd
, 0, 0x0003, 0x0106); /* Same */
1936 ibmcam_veio(uvd
, 0, 0x00da, 0x0107); /* Unique to every mode*/
1938 case VIDEOSIZE_352x288
:
1939 ibmcam_veio(uvd
, 0, 0x002c, 0x0103); /* All except 320x240 */
1940 ibmcam_veio(uvd
, 0, 0x0000, 0x0104); /* Same */
1941 ibmcam_veio(uvd
, 0, 0x0024, 0x0105); /* 176x144, 352x288 */
1942 ibmcam_veio(uvd
, 0, 0x0039, 0x010a); /* All except 176x144 */
1943 ibmcam_veio(uvd
, 0, 0x0070, 0x0119); /* All except 176x144 */
1944 ibmcam_veio(uvd
, 0, 0x0003, 0x0106); /* Same */
1945 ibmcam_veio(uvd
, 0, 0x00fe, 0x0107); /* Unique to every mode*/
1948 return (CAMERA_IS_OPERATIONAL(uvd
) ? 0 : -EFAULT
);
1952 * ibmcam_model1_setup_after_video_if()
1954 * This code adds finishing touches to the video data interface.
1955 * Here we configure the frame rate and turn on the LED.
1957 static void ibmcam_model1_setup_after_video_if(struct uvd
*uvd
)
1959 unsigned short internal_frame_rate
;
1961 RESTRICT_TO_RANGE(framerate
, FRAMERATE_MIN
, FRAMERATE_MAX
);
1962 internal_frame_rate
= FRAMERATE_MAX
- framerate
; /* 0=Fast 6=Slow */
1963 ibmcam_veio(uvd
, 0, 0x01, 0x0100); /* LED On */
1964 ibmcam_veio(uvd
, 0, internal_frame_rate
, 0x0111);
1965 ibmcam_veio(uvd
, 0, 0x01, 0x0114);
1966 ibmcam_veio(uvd
, 0, 0xc0, 0x010c);
1969 static void ibmcam_model2_setup_after_video_if(struct uvd
*uvd
)
1971 unsigned short setup_model2_rg2
, setup_model2_sat
, setup_model2_yb
;
1973 ibmcam_veio(uvd
, 0, 0x0000, 0x0100); /* LED on */
1975 switch (uvd
->videosize
) {
1976 case VIDEOSIZE_176x144
:
1977 ibmcam_veio(uvd
, 0, 0x0050, 0x0111);
1978 ibmcam_veio(uvd
, 0, 0x00d0, 0x0111);
1980 case VIDEOSIZE_320x240
:
1981 case VIDEOSIZE_352x240
:
1982 case VIDEOSIZE_352x288
:
1983 ibmcam_veio(uvd
, 0, 0x0040, 0x0111);
1984 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
1987 ibmcam_veio(uvd
, 0, 0x009b, 0x010f);
1988 ibmcam_veio(uvd
, 0, 0x00bb, 0x010f);
1991 * Hardware settings, may affect CMOS sensor; not user controls!
1992 * -------------------------------------------------------------
1994 * 0x0006: hardware effect
1996 * 0x000a: stops video stream, probably important h/w setting
1997 * 0x000c: changes color in hardware manner (not user setting)
1998 * 0x0012: changes number of colors (does not affect speed)
2000 * 0x002c: hardware setting (related to scan lines)
2001 * 0x002e: stops video stream, probably important h/w setting
2003 ibmcam_model2_Packet1(uvd
, 0x000a, 0x005c);
2004 ibmcam_model2_Packet1(uvd
, 0x0004, 0x0000);
2005 ibmcam_model2_Packet1(uvd
, 0x0006, 0x00fb);
2006 ibmcam_model2_Packet1(uvd
, 0x0008, 0x0000);
2007 ibmcam_model2_Packet1(uvd
, 0x000c, 0x0009);
2008 ibmcam_model2_Packet1(uvd
, 0x0012, 0x000a);
2009 ibmcam_model2_Packet1(uvd
, 0x002a, 0x0000);
2010 ibmcam_model2_Packet1(uvd
, 0x002c, 0x0000);
2011 ibmcam_model2_Packet1(uvd
, 0x002e, 0x0008);
2014 * Function 0x0030 pops up all over the place. Apparently
2015 * it is a hardware control register, with every bit assigned to
2018 ibmcam_model2_Packet1(uvd
, 0x0030, 0x0000);
2021 * Magic control of CMOS sensor. Only lower values like
2022 * 0-3 work, and picture shifts left or right. Don't change.
2024 switch (uvd
->videosize
) {
2025 case VIDEOSIZE_176x144
:
2026 ibmcam_model2_Packet1(uvd
, 0x0014, 0x0002);
2027 ibmcam_model2_Packet1(uvd
, 0x0016, 0x0002); /* Horizontal shift */
2028 ibmcam_model2_Packet1(uvd
, 0x0018, 0x004a); /* Another hardware setting */
2030 case VIDEOSIZE_320x240
:
2031 ibmcam_model2_Packet1(uvd
, 0x0014, 0x0009);
2032 ibmcam_model2_Packet1(uvd
, 0x0016, 0x0005); /* Horizontal shift */
2033 ibmcam_model2_Packet1(uvd
, 0x0018, 0x0044); /* Another hardware setting */
2035 case VIDEOSIZE_352x240
:
2036 /* This mode doesn't work as Windows programs it; changed to work */
2037 ibmcam_model2_Packet1(uvd
, 0x0014, 0x0009); /* Windows sets this to 8 */
2038 ibmcam_model2_Packet1(uvd
, 0x0016, 0x0003); /* Horizontal shift */
2039 ibmcam_model2_Packet1(uvd
, 0x0018, 0x0044); /* Windows sets this to 0x0045 */
2041 case VIDEOSIZE_352x288
:
2042 ibmcam_model2_Packet1(uvd
, 0x0014, 0x0003);
2043 ibmcam_model2_Packet1(uvd
, 0x0016, 0x0002); /* Horizontal shift */
2044 ibmcam_model2_Packet1(uvd
, 0x0018, 0x004a); /* Another hardware setting */
2048 ibmcam_model2_Packet1(uvd
, mod2_brightness
, 0x005a);
2051 * We have our own frame rate setting varying from 0 (slowest) to 6 (fastest).
2052 * The camera model 2 allows frame rate in range [0..0x1F] where 0 is also the
2053 * slowest setting. However for all practical reasons high settings make no
2054 * sense because USB is not fast enough to support high FPS. Be aware that
2055 * the picture datastream will be severely disrupted if you ask for
2056 * frame rate faster than allowed for the video size - see below:
2058 * Allowable ranges (obtained experimentally on OHCI, K6-3, 450 MHz):
2059 * -----------------------------------------------------------------
2063 * 352x288: [16..31] I have to raise lower threshold for stability...
2065 * As usual, slower FPS provides better sensitivity.
2068 short hw_fps
=31, i_framerate
;
2070 RESTRICT_TO_RANGE(framerate
, FRAMERATE_MIN
, FRAMERATE_MAX
);
2071 i_framerate
= FRAMERATE_MAX
- framerate
+ FRAMERATE_MIN
;
2072 switch (uvd
->videosize
) {
2073 case VIDEOSIZE_176x144
:
2074 hw_fps
= 6 + i_framerate
*4;
2076 case VIDEOSIZE_320x240
:
2077 hw_fps
= 8 + i_framerate
*3;
2079 case VIDEOSIZE_352x240
:
2080 hw_fps
= 10 + i_framerate
*2;
2082 case VIDEOSIZE_352x288
:
2083 hw_fps
= 28 + i_framerate
/2;
2087 info("Framerate (hardware): %hd.", hw_fps
);
2088 RESTRICT_TO_RANGE(hw_fps
, 0, 31);
2089 ibmcam_model2_Packet1(uvd
, mod2_set_framerate
, hw_fps
);
2093 * This setting does not visibly affect pictures; left it here
2094 * because it was present in Windows USB data stream. This function
2095 * does not allow arbitrary values and apparently is a bit mask, to
2096 * be activated only at appropriate time. Don't change it randomly!
2098 switch (uvd
->videosize
) {
2099 case VIDEOSIZE_176x144
:
2100 ibmcam_model2_Packet1(uvd
, 0x0026, 0x00c2);
2102 case VIDEOSIZE_320x240
:
2103 ibmcam_model2_Packet1(uvd
, 0x0026, 0x0044);
2105 case VIDEOSIZE_352x240
:
2106 ibmcam_model2_Packet1(uvd
, 0x0026, 0x0046);
2108 case VIDEOSIZE_352x288
:
2109 ibmcam_model2_Packet1(uvd
, 0x0026, 0x0048);
2113 ibmcam_model2_Packet1(uvd
, mod2_sensitivity
, lighting
);
2115 if (init_model2_rg2
>= 0) {
2116 RESTRICT_TO_RANGE(init_model2_rg2
, 0, 255);
2117 setup_model2_rg2
= init_model2_rg2
;
2119 setup_model2_rg2
= 0x002f;
2121 if (init_model2_sat
>= 0) {
2122 RESTRICT_TO_RANGE(init_model2_sat
, 0, 255);
2123 setup_model2_sat
= init_model2_sat
;
2125 setup_model2_sat
= 0x0034;
2127 if (init_model2_yb
>= 0) {
2128 RESTRICT_TO_RANGE(init_model2_yb
, 0, 255);
2129 setup_model2_yb
= init_model2_yb
;
2131 setup_model2_yb
= 0x00a0;
2133 ibmcam_model2_Packet1(uvd
, mod2_color_balance_rg2
, setup_model2_rg2
);
2134 ibmcam_model2_Packet1(uvd
, mod2_saturation
, setup_model2_sat
);
2135 ibmcam_model2_Packet1(uvd
, mod2_color_balance_yb
, setup_model2_yb
);
2136 ibmcam_model2_Packet1(uvd
, mod2_hue
, uvd
->vpic
.hue
>> 9); /* 0 .. 7F */;
2138 /* Hardware control command */
2139 ibmcam_model2_Packet1(uvd
, 0x0030, 0x0004);
2141 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c); /* Go camera, go! */
2142 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
2145 static void ibmcam_model4_setup_after_video_if(struct uvd
*uvd
)
2147 switch (uvd
->videosize
) {
2148 case VIDEOSIZE_128x96
:
2149 ibmcam_veio(uvd
, 0, 0x0000, 0x0100);
2150 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
2151 ibmcam_veio(uvd
, 0, 0x00bc, 0x012c);
2152 ibmcam_veio(uvd
, 0, 0x0080, 0x012b);
2153 ibmcam_veio(uvd
, 0, 0x0000, 0x0108);
2154 ibmcam_veio(uvd
, 0, 0x0001, 0x0133);
2155 ibmcam_veio(uvd
, 0, 0x009b, 0x010f);
2156 ibmcam_veio(uvd
, 0, 0x00bb, 0x010f);
2157 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2158 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2159 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2160 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2161 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2162 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2163 ibmcam_veio(uvd
, 0, 0x000a, 0x012f);
2164 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2165 ibmcam_veio(uvd
, 0, 0x005c, 0x0127);
2166 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2167 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2168 ibmcam_veio(uvd
, 0, 0x0004, 0x012f);
2169 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2170 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2171 ibmcam_veio(uvd
, 0, 0x00fb, 0x012e);
2172 ibmcam_veio(uvd
, 0, 0x0000, 0x0130);
2173 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2174 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2175 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2176 ibmcam_veio(uvd
, 0, 0x000c, 0x0127);
2177 ibmcam_veio(uvd
, 0, 0x0009, 0x012e);
2178 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2179 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2180 ibmcam_veio(uvd
, 0, 0x0012, 0x012f);
2181 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2182 ibmcam_veio(uvd
, 0, 0x0008, 0x0127);
2183 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2184 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2185 ibmcam_veio(uvd
, 0, 0x002a, 0x012d);
2186 ibmcam_veio(uvd
, 0, 0x0000, 0x012f);
2187 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2188 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2189 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2190 ibmcam_veio(uvd
, 0, 0x0034, 0x012f);
2191 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2192 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2193 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2194 ibmcam_veio(uvd
, 0, 0x0070, 0x0119);
2195 ibmcam_veio(uvd
, 0, 0x00d2, 0x0107);
2196 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2197 ibmcam_veio(uvd
, 0, 0x005e, 0x0107);
2198 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2199 ibmcam_veio(uvd
, 0, 0x00d0, 0x0111);
2200 ibmcam_veio(uvd
, 0, 0x0039, 0x010a);
2201 ibmcam_veio(uvd
, 0, 0x0001, 0x0102);
2202 ibmcam_veio(uvd
, 0, 0x0028, 0x0103);
2203 ibmcam_veio(uvd
, 0, 0x0000, 0x0104);
2204 ibmcam_veio(uvd
, 0, 0x001e, 0x0105);
2205 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2206 ibmcam_veio(uvd
, 0, 0x0016, 0x012f);
2207 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2208 ibmcam_veio(uvd
, 0, 0x000a, 0x0127);
2209 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2210 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2211 ibmcam_veio(uvd
, 0, 0x0014, 0x012d);
2212 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2213 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2214 ibmcam_veio(uvd
, 0, 0x00aa, 0x012e);
2215 ibmcam_veio(uvd
, 0, 0x001a, 0x0130);
2216 ibmcam_veio(uvd
, 0, 0x8a0a, 0x0124);
2217 ibmcam_veio(uvd
, 0, 0x005a, 0x012d);
2218 ibmcam_veio(uvd
, 0, 0x9545, 0x0124);
2219 ibmcam_veio(uvd
, 0, 0x00aa, 0x0127);
2220 ibmcam_veio(uvd
, 0, 0x0018, 0x012e);
2221 ibmcam_veio(uvd
, 0, 0x0043, 0x0130);
2222 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2223 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2224 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2225 ibmcam_veio(uvd
, 0, 0x001c, 0x0127);
2226 ibmcam_veio(uvd
, 0, 0x00eb, 0x012e);
2227 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2228 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2229 ibmcam_veio(uvd
, 0, 0x0032, 0x012f);
2230 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2231 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2232 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2233 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2234 ibmcam_veio(uvd
, 0, 0x0036, 0x012d);
2235 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2236 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2237 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2238 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2239 ibmcam_veio(uvd
, 0, 0x001e, 0x012f);
2240 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2241 ibmcam_veio(uvd
, 0, 0x0017, 0x0127);
2242 ibmcam_veio(uvd
, 0, 0x0013, 0x012e);
2243 ibmcam_veio(uvd
, 0, 0x0031, 0x0130);
2244 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2245 ibmcam_veio(uvd
, 0, 0x0017, 0x012d);
2246 ibmcam_veio(uvd
, 0, 0x0078, 0x012f);
2247 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2248 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2249 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2250 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2251 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2252 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2253 ibmcam_veio(uvd
, 0, 0x0004, 0x0127);
2254 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2255 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
2257 case VIDEOSIZE_160x120
:
2258 ibmcam_veio(uvd
, 0, 0x0000, 0x0100);
2259 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
2260 ibmcam_veio(uvd
, 0, 0x00bc, 0x012c);
2261 ibmcam_veio(uvd
, 0, 0x0080, 0x012b);
2262 ibmcam_veio(uvd
, 0, 0x0000, 0x0108);
2263 ibmcam_veio(uvd
, 0, 0x0001, 0x0133);
2264 ibmcam_veio(uvd
, 0, 0x009b, 0x010f);
2265 ibmcam_veio(uvd
, 0, 0x00bb, 0x010f);
2266 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2267 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2268 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2269 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2270 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2271 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2272 ibmcam_veio(uvd
, 0, 0x000a, 0x012f);
2273 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2274 ibmcam_veio(uvd
, 0, 0x005c, 0x0127);
2275 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2276 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2277 ibmcam_veio(uvd
, 0, 0x0004, 0x012f);
2278 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2279 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2280 ibmcam_veio(uvd
, 0, 0x00fb, 0x012e);
2281 ibmcam_veio(uvd
, 0, 0x0000, 0x0130);
2282 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2283 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2284 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2285 ibmcam_veio(uvd
, 0, 0x000c, 0x0127);
2286 ibmcam_veio(uvd
, 0, 0x0009, 0x012e);
2287 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2288 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2289 ibmcam_veio(uvd
, 0, 0x0012, 0x012f);
2290 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2291 ibmcam_veio(uvd
, 0, 0x0008, 0x0127);
2292 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2293 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2294 ibmcam_veio(uvd
, 0, 0x002a, 0x012d);
2295 ibmcam_veio(uvd
, 0, 0x0000, 0x012f);
2296 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2297 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2298 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2299 ibmcam_veio(uvd
, 0, 0x0034, 0x012f);
2300 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2301 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2302 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2303 ibmcam_veio(uvd
, 0, 0x0038, 0x0119);
2304 ibmcam_veio(uvd
, 0, 0x00d8, 0x0107);
2305 ibmcam_veio(uvd
, 0, 0x0002, 0x0106);
2306 ibmcam_veio(uvd
, 0, 0x00d0, 0x0111);
2307 ibmcam_veio(uvd
, 0, 0x00b9, 0x010a);
2308 ibmcam_veio(uvd
, 0, 0x0001, 0x0102);
2309 ibmcam_veio(uvd
, 0, 0x0028, 0x0103);
2310 ibmcam_veio(uvd
, 0, 0x0000, 0x0104);
2311 ibmcam_veio(uvd
, 0, 0x001e, 0x0105);
2312 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2313 ibmcam_veio(uvd
, 0, 0x0016, 0x012f);
2314 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2315 ibmcam_veio(uvd
, 0, 0x000b, 0x0127);
2316 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2317 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2318 ibmcam_veio(uvd
, 0, 0x0014, 0x012d);
2319 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2320 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2321 ibmcam_veio(uvd
, 0, 0x00aa, 0x012e);
2322 ibmcam_veio(uvd
, 0, 0x001a, 0x0130);
2323 ibmcam_veio(uvd
, 0, 0x8a0a, 0x0124);
2324 ibmcam_veio(uvd
, 0, 0x005a, 0x012d);
2325 ibmcam_veio(uvd
, 0, 0x9545, 0x0124);
2326 ibmcam_veio(uvd
, 0, 0x00aa, 0x0127);
2327 ibmcam_veio(uvd
, 0, 0x0018, 0x012e);
2328 ibmcam_veio(uvd
, 0, 0x0043, 0x0130);
2329 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2330 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2331 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2332 ibmcam_veio(uvd
, 0, 0x001c, 0x0127);
2333 ibmcam_veio(uvd
, 0, 0x00c7, 0x012e);
2334 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2335 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2336 ibmcam_veio(uvd
, 0, 0x0032, 0x012f);
2337 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2338 ibmcam_veio(uvd
, 0, 0x0025, 0x0127);
2339 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2340 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2341 ibmcam_veio(uvd
, 0, 0x0036, 0x012d);
2342 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2343 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2344 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2345 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2346 ibmcam_veio(uvd
, 0, 0x001e, 0x012f);
2347 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2348 ibmcam_veio(uvd
, 0, 0x0048, 0x0127);
2349 ibmcam_veio(uvd
, 0, 0x0035, 0x012e);
2350 ibmcam_veio(uvd
, 0, 0x00d0, 0x0130);
2351 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2352 ibmcam_veio(uvd
, 0, 0x0048, 0x012d);
2353 ibmcam_veio(uvd
, 0, 0x0090, 0x012f);
2354 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2355 ibmcam_veio(uvd
, 0, 0x0001, 0x0127);
2356 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2357 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2358 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2359 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2360 ibmcam_veio(uvd
, 0, 0x0004, 0x0127);
2361 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2362 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
2364 case VIDEOSIZE_176x144
:
2365 ibmcam_veio(uvd
, 0, 0x0000, 0x0100);
2366 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
2367 ibmcam_veio(uvd
, 0, 0x00bc, 0x012c);
2368 ibmcam_veio(uvd
, 0, 0x0080, 0x012b);
2369 ibmcam_veio(uvd
, 0, 0x0000, 0x0108);
2370 ibmcam_veio(uvd
, 0, 0x0001, 0x0133);
2371 ibmcam_veio(uvd
, 0, 0x009b, 0x010f);
2372 ibmcam_veio(uvd
, 0, 0x00bb, 0x010f);
2373 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2374 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2375 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2376 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2377 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2378 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2379 ibmcam_veio(uvd
, 0, 0x000a, 0x012f);
2380 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2381 ibmcam_veio(uvd
, 0, 0x005c, 0x0127);
2382 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2383 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2384 ibmcam_veio(uvd
, 0, 0x0004, 0x012f);
2385 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2386 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2387 ibmcam_veio(uvd
, 0, 0x00fb, 0x012e);
2388 ibmcam_veio(uvd
, 0, 0x0000, 0x0130);
2389 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2390 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2391 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2392 ibmcam_veio(uvd
, 0, 0x000c, 0x0127);
2393 ibmcam_veio(uvd
, 0, 0x0009, 0x012e);
2394 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2395 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2396 ibmcam_veio(uvd
, 0, 0x0012, 0x012f);
2397 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2398 ibmcam_veio(uvd
, 0, 0x0008, 0x0127);
2399 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2400 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2401 ibmcam_veio(uvd
, 0, 0x002a, 0x012d);
2402 ibmcam_veio(uvd
, 0, 0x0000, 0x012f);
2403 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2404 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2405 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2406 ibmcam_veio(uvd
, 0, 0x0034, 0x012f);
2407 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2408 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2409 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2410 ibmcam_veio(uvd
, 0, 0x0038, 0x0119);
2411 ibmcam_veio(uvd
, 0, 0x00d6, 0x0107);
2412 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2413 ibmcam_veio(uvd
, 0, 0x0018, 0x0107);
2414 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2415 ibmcam_veio(uvd
, 0, 0x00d0, 0x0111);
2416 ibmcam_veio(uvd
, 0, 0x00b9, 0x010a);
2417 ibmcam_veio(uvd
, 0, 0x0001, 0x0102);
2418 ibmcam_veio(uvd
, 0, 0x002c, 0x0103);
2419 ibmcam_veio(uvd
, 0, 0x0000, 0x0104);
2420 ibmcam_veio(uvd
, 0, 0x0024, 0x0105);
2421 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2422 ibmcam_veio(uvd
, 0, 0x0016, 0x012f);
2423 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2424 ibmcam_veio(uvd
, 0, 0x0007, 0x0127);
2425 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2426 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2427 ibmcam_veio(uvd
, 0, 0x0014, 0x012d);
2428 ibmcam_veio(uvd
, 0, 0x0001, 0x012f);
2429 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2430 ibmcam_veio(uvd
, 0, 0x00aa, 0x012e);
2431 ibmcam_veio(uvd
, 0, 0x001a, 0x0130);
2432 ibmcam_veio(uvd
, 0, 0x8a0a, 0x0124);
2433 ibmcam_veio(uvd
, 0, 0x005e, 0x012d);
2434 ibmcam_veio(uvd
, 0, 0x9545, 0x0124);
2435 ibmcam_veio(uvd
, 0, 0x00aa, 0x0127);
2436 ibmcam_veio(uvd
, 0, 0x0018, 0x012e);
2437 ibmcam_veio(uvd
, 0, 0x0049, 0x0130);
2438 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2439 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2440 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2441 ibmcam_veio(uvd
, 0, 0x001c, 0x0127);
2442 ibmcam_veio(uvd
, 0, 0x00c7, 0x012e);
2443 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2444 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2445 ibmcam_veio(uvd
, 0, 0x0032, 0x012f);
2446 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2447 ibmcam_veio(uvd
, 0, 0x0028, 0x0127);
2448 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2449 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2450 ibmcam_veio(uvd
, 0, 0x0036, 0x012d);
2451 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2452 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2453 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2454 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2455 ibmcam_veio(uvd
, 0, 0x001e, 0x012f);
2456 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2457 ibmcam_veio(uvd
, 0, 0x0010, 0x0127);
2458 ibmcam_veio(uvd
, 0, 0x0013, 0x012e);
2459 ibmcam_veio(uvd
, 0, 0x002a, 0x0130);
2460 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2461 ibmcam_veio(uvd
, 0, 0x0010, 0x012d);
2462 ibmcam_veio(uvd
, 0, 0x006d, 0x012f);
2463 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2464 ibmcam_veio(uvd
, 0, 0x0001, 0x0127);
2465 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2466 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2467 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2468 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2469 ibmcam_veio(uvd
, 0, 0x0004, 0x0127);
2470 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2471 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
2473 case VIDEOSIZE_320x240
:
2474 ibmcam_veio(uvd
, 0, 0x0000, 0x0100);
2475 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
2476 ibmcam_veio(uvd
, 0, 0x00bc, 0x012c);
2477 ibmcam_veio(uvd
, 0, 0x0080, 0x012b);
2478 ibmcam_veio(uvd
, 0, 0x0000, 0x0108);
2479 ibmcam_veio(uvd
, 0, 0x0001, 0x0133);
2480 ibmcam_veio(uvd
, 0, 0x009b, 0x010f);
2481 ibmcam_veio(uvd
, 0, 0x00bb, 0x010f);
2482 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2483 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2484 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2485 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2486 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2487 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2488 ibmcam_veio(uvd
, 0, 0x000a, 0x012f);
2489 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2490 ibmcam_veio(uvd
, 0, 0x005c, 0x0127);
2491 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2492 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2493 ibmcam_veio(uvd
, 0, 0x0004, 0x012f);
2494 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2495 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2496 ibmcam_veio(uvd
, 0, 0x00fb, 0x012e);
2497 ibmcam_veio(uvd
, 0, 0x0000, 0x0130);
2498 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2499 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2500 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2501 ibmcam_veio(uvd
, 0, 0x000c, 0x0127);
2502 ibmcam_veio(uvd
, 0, 0x0009, 0x012e);
2503 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2504 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2505 ibmcam_veio(uvd
, 0, 0x0012, 0x012f);
2506 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2507 ibmcam_veio(uvd
, 0, 0x0008, 0x0127);
2508 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2509 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2510 ibmcam_veio(uvd
, 0, 0x002a, 0x012d);
2511 ibmcam_veio(uvd
, 0, 0x0000, 0x012f);
2512 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2513 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2514 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2515 ibmcam_veio(uvd
, 0, 0x0034, 0x012f);
2516 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2517 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2518 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2519 ibmcam_veio(uvd
, 0, 0x0070, 0x0119);
2520 ibmcam_veio(uvd
, 0, 0x00d2, 0x0107);
2521 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2522 ibmcam_veio(uvd
, 0, 0x005e, 0x0107);
2523 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2524 ibmcam_veio(uvd
, 0, 0x00d0, 0x0111);
2525 ibmcam_veio(uvd
, 0, 0x0039, 0x010a);
2526 ibmcam_veio(uvd
, 0, 0x0001, 0x0102);
2527 ibmcam_veio(uvd
, 0, 0x0028, 0x0103);
2528 ibmcam_veio(uvd
, 0, 0x0000, 0x0104);
2529 ibmcam_veio(uvd
, 0, 0x001e, 0x0105);
2530 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2531 ibmcam_veio(uvd
, 0, 0x0016, 0x012f);
2532 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2533 ibmcam_veio(uvd
, 0, 0x000a, 0x0127);
2534 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2535 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2536 ibmcam_veio(uvd
, 0, 0x0014, 0x012d);
2537 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2538 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2539 ibmcam_veio(uvd
, 0, 0x00aa, 0x012e);
2540 ibmcam_veio(uvd
, 0, 0x001a, 0x0130);
2541 ibmcam_veio(uvd
, 0, 0x8a0a, 0x0124);
2542 ibmcam_veio(uvd
, 0, 0x005a, 0x012d);
2543 ibmcam_veio(uvd
, 0, 0x9545, 0x0124);
2544 ibmcam_veio(uvd
, 0, 0x00aa, 0x0127);
2545 ibmcam_veio(uvd
, 0, 0x0018, 0x012e);
2546 ibmcam_veio(uvd
, 0, 0x0043, 0x0130);
2547 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2548 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2549 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2550 ibmcam_veio(uvd
, 0, 0x001c, 0x0127);
2551 ibmcam_veio(uvd
, 0, 0x00eb, 0x012e);
2552 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2553 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2554 ibmcam_veio(uvd
, 0, 0x0032, 0x012f);
2555 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2556 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2557 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2558 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2559 ibmcam_veio(uvd
, 0, 0x0036, 0x012d);
2560 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2561 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2562 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2563 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2564 ibmcam_veio(uvd
, 0, 0x001e, 0x012f);
2565 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2566 ibmcam_veio(uvd
, 0, 0x0017, 0x0127);
2567 ibmcam_veio(uvd
, 0, 0x0013, 0x012e);
2568 ibmcam_veio(uvd
, 0, 0x0031, 0x0130);
2569 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2570 ibmcam_veio(uvd
, 0, 0x0017, 0x012d);
2571 ibmcam_veio(uvd
, 0, 0x0078, 0x012f);
2572 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2573 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2574 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2575 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2576 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2577 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2578 ibmcam_veio(uvd
, 0, 0x0004, 0x0127);
2579 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2580 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
2582 case VIDEOSIZE_352x288
:
2583 ibmcam_veio(uvd
, 0, 0x0000, 0x0100);
2584 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
2585 ibmcam_veio(uvd
, 0, 0x00bc, 0x012c);
2586 ibmcam_veio(uvd
, 0, 0x0080, 0x012b);
2587 ibmcam_veio(uvd
, 0, 0x0000, 0x0108);
2588 ibmcam_veio(uvd
, 0, 0x0001, 0x0133);
2589 ibmcam_veio(uvd
, 0, 0x009b, 0x010f);
2590 ibmcam_veio(uvd
, 0, 0x00bb, 0x010f);
2591 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2592 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2593 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2594 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2595 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2596 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2597 ibmcam_veio(uvd
, 0, 0x000a, 0x012f);
2598 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2599 ibmcam_veio(uvd
, 0, 0x005c, 0x0127);
2600 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2601 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2602 ibmcam_veio(uvd
, 0, 0x0004, 0x012f);
2603 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2604 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2605 ibmcam_veio(uvd
, 0, 0x00fb, 0x012e);
2606 ibmcam_veio(uvd
, 0, 0x0000, 0x0130);
2607 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2608 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2609 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2610 ibmcam_veio(uvd
, 0, 0x000c, 0x0127);
2611 ibmcam_veio(uvd
, 0, 0x0009, 0x012e);
2612 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2613 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2614 ibmcam_veio(uvd
, 0, 0x0012, 0x012f);
2615 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2616 ibmcam_veio(uvd
, 0, 0x0008, 0x0127);
2617 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2618 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2619 ibmcam_veio(uvd
, 0, 0x002a, 0x012d);
2620 ibmcam_veio(uvd
, 0, 0x0000, 0x012f);
2621 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2622 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2623 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2624 ibmcam_veio(uvd
, 0, 0x0034, 0x012f);
2625 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2626 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2627 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2628 ibmcam_veio(uvd
, 0, 0x0070, 0x0119);
2629 ibmcam_veio(uvd
, 0, 0x00f2, 0x0107);
2630 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2631 ibmcam_veio(uvd
, 0, 0x008c, 0x0107);
2632 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
2633 ibmcam_veio(uvd
, 0, 0x00c0, 0x0111);
2634 ibmcam_veio(uvd
, 0, 0x0039, 0x010a);
2635 ibmcam_veio(uvd
, 0, 0x0001, 0x0102);
2636 ibmcam_veio(uvd
, 0, 0x002c, 0x0103);
2637 ibmcam_veio(uvd
, 0, 0x0000, 0x0104);
2638 ibmcam_veio(uvd
, 0, 0x0024, 0x0105);
2639 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2640 ibmcam_veio(uvd
, 0, 0x0016, 0x012f);
2641 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2642 ibmcam_veio(uvd
, 0, 0x0006, 0x0127);
2643 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2644 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2645 ibmcam_veio(uvd
, 0, 0x0014, 0x012d);
2646 ibmcam_veio(uvd
, 0, 0x0002, 0x012f);
2647 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2648 ibmcam_veio(uvd
, 0, 0x00aa, 0x012e);
2649 ibmcam_veio(uvd
, 0, 0x001a, 0x0130);
2650 ibmcam_veio(uvd
, 0, 0x8a0a, 0x0124);
2651 ibmcam_veio(uvd
, 0, 0x005e, 0x012d);
2652 ibmcam_veio(uvd
, 0, 0x9545, 0x0124);
2653 ibmcam_veio(uvd
, 0, 0x00aa, 0x0127);
2654 ibmcam_veio(uvd
, 0, 0x0018, 0x012e);
2655 ibmcam_veio(uvd
, 0, 0x0049, 0x0130);
2656 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2657 ibmcam_veio(uvd
, 0, 0x00aa, 0x012f);
2658 ibmcam_veio(uvd
, 0, 0xd055, 0x0124);
2659 ibmcam_veio(uvd
, 0, 0x001c, 0x0127);
2660 ibmcam_veio(uvd
, 0, 0x00cf, 0x012e);
2661 ibmcam_veio(uvd
, 0, 0xaa28, 0x0124);
2662 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2663 ibmcam_veio(uvd
, 0, 0x0032, 0x012f);
2664 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2665 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2666 ibmcam_veio(uvd
, 0, 0x00aa, 0x0130);
2667 ibmcam_veio(uvd
, 0, 0x82a8, 0x0124);
2668 ibmcam_veio(uvd
, 0, 0x0036, 0x012d);
2669 ibmcam_veio(uvd
, 0, 0x0008, 0x012f);
2670 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2671 ibmcam_veio(uvd
, 0, 0xfffa, 0x0124);
2672 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2673 ibmcam_veio(uvd
, 0, 0x001e, 0x012f);
2674 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2675 ibmcam_veio(uvd
, 0, 0x0010, 0x0127);
2676 ibmcam_veio(uvd
, 0, 0x0013, 0x012e);
2677 ibmcam_veio(uvd
, 0, 0x0025, 0x0130);
2678 ibmcam_veio(uvd
, 0, 0x8a28, 0x0124);
2679 ibmcam_veio(uvd
, 0, 0x0010, 0x012d);
2680 ibmcam_veio(uvd
, 0, 0x0048, 0x012f);
2681 ibmcam_veio(uvd
, 0, 0xd145, 0x0124);
2682 ibmcam_veio(uvd
, 0, 0x0000, 0x0127);
2683 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2684 ibmcam_veio(uvd
, 0, 0x00aa, 0x012d);
2685 ibmcam_veio(uvd
, 0, 0x0038, 0x012f);
2686 ibmcam_veio(uvd
, 0, 0xd141, 0x0124);
2687 ibmcam_veio(uvd
, 0, 0x0004, 0x0127);
2688 ibmcam_veio(uvd
, 0, 0xfea8, 0x0124);
2689 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
2692 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
2695 static void ibmcam_model3_setup_after_video_if(struct uvd
*uvd
)
2699 * 01.01.08 - Added for RCA video in support -LO
2700 * This struct is used to init the Model3 cam to use the RCA video in port
2701 * instead of the CCD sensor.
2703 static const struct struct_initData initData
[] = {
2704 {0, 0x0000, 0x010c},
2705 {0, 0x0006, 0x012c},
2706 {0, 0x0078, 0x012d},
2707 {0, 0x0046, 0x012f},
2708 {0, 0xd141, 0x0124},
2709 {0, 0x0000, 0x0127},
2710 {0, 0xfea8, 0x0124},
2711 {1, 0x0000, 0x0116},
2712 {0, 0x0064, 0x0116},
2713 {1, 0x0000, 0x0115},
2714 {0, 0x0003, 0x0115},
2715 {0, 0x0008, 0x0123},
2716 {0, 0x0000, 0x0117},
2717 {0, 0x0000, 0x0112},
2718 {0, 0x0080, 0x0100},
2719 {0, 0x0000, 0x0100},
2720 {1, 0x0000, 0x0116},
2721 {0, 0x0060, 0x0116},
2722 {0, 0x0002, 0x0112},
2723 {0, 0x0000, 0x0123},
2724 {0, 0x0001, 0x0117},
2725 {0, 0x0040, 0x0108},
2726 {0, 0x0019, 0x012c},
2727 {0, 0x0040, 0x0116},
2728 {0, 0x000a, 0x0115},
2729 {0, 0x000b, 0x0115},
2730 {0, 0x0078, 0x012d},
2731 {0, 0x0046, 0x012f},
2732 {0, 0xd141, 0x0124},
2733 {0, 0x0000, 0x0127},
2734 {0, 0xfea8, 0x0124},
2735 {0, 0x0064, 0x0116},
2736 {0, 0x0000, 0x0115},
2737 {0, 0x0001, 0x0115},
2738 {0, 0xffff, 0x0124},
2739 {0, 0xfff9, 0x0124},
2740 {0, 0x0086, 0x0127},
2741 {0, 0xfff8, 0x0124},
2742 {0, 0xfffd, 0x0124},
2743 {0, 0x00aa, 0x0127},
2744 {0, 0xfff8, 0x0124},
2745 {0, 0xfffd, 0x0124},
2746 {0, 0x0000, 0x0127},
2747 {0, 0xfff8, 0x0124},
2748 {0, 0xfffd, 0x0124},
2749 {0, 0xfffa, 0x0124},
2750 {0, 0xffff, 0x0124},
2751 {0, 0xfff9, 0x0124},
2752 {0, 0x0086, 0x0127},
2753 {0, 0xfff8, 0x0124},
2754 {0, 0xfffd, 0x0124},
2755 {0, 0x00f2, 0x0127},
2756 {0, 0xfff8, 0x0124},
2757 {0, 0xfffd, 0x0124},
2758 {0, 0x000f, 0x0127},
2759 {0, 0xfff8, 0x0124},
2760 {0, 0xfffd, 0x0124},
2761 {0, 0xfffa, 0x0124},
2762 {0, 0xffff, 0x0124},
2763 {0, 0xfff9, 0x0124},
2764 {0, 0x0086, 0x0127},
2765 {0, 0xfff8, 0x0124},
2766 {0, 0xfffd, 0x0124},
2767 {0, 0x00f8, 0x0127},
2768 {0, 0xfff8, 0x0124},
2769 {0, 0xfffd, 0x0124},
2770 {0, 0x00fc, 0x0127},
2771 {0, 0xfff8, 0x0124},
2772 {0, 0xfffd, 0x0124},
2773 {0, 0xfffa, 0x0124},
2774 {0, 0xffff, 0x0124},
2775 {0, 0xfff9, 0x0124},
2776 {0, 0x0086, 0x0127},
2777 {0, 0xfff8, 0x0124},
2778 {0, 0xfffd, 0x0124},
2779 {0, 0x00f9, 0x0127},
2780 {0, 0xfff8, 0x0124},
2781 {0, 0xfffd, 0x0124},
2782 {0, 0x003c, 0x0127},
2783 {0, 0xfff8, 0x0124},
2784 {0, 0xfffd, 0x0124},
2785 {0, 0xfffa, 0x0124},
2786 {0, 0xffff, 0x0124},
2787 {0, 0xfff9, 0x0124},
2788 {0, 0x0086, 0x0127},
2789 {0, 0xfff8, 0x0124},
2790 {0, 0xfffd, 0x0124},
2791 {0, 0x0027, 0x0127},
2792 {0, 0xfff8, 0x0124},
2793 {0, 0xfffd, 0x0124},
2794 {0, 0x0019, 0x0127},
2795 {0, 0xfff8, 0x0124},
2796 {0, 0xfffd, 0x0124},
2797 {0, 0xfffa, 0x0124},
2798 {0, 0xfff9, 0x0124},
2799 {0, 0x0086, 0x0127},
2800 {0, 0xfff8, 0x0124},
2801 {0, 0xfffd, 0x0124},
2802 {0, 0x0037, 0x0127},
2803 {0, 0xfff8, 0x0124},
2804 {0, 0xfffd, 0x0124},
2805 {0, 0x0000, 0x0127},
2806 {0, 0xfff8, 0x0124},
2807 {0, 0xfffd, 0x0124},
2808 {0, 0x0021, 0x0127},
2809 {0, 0xfff8, 0x0124},
2810 {0, 0xfffd, 0x0124},
2811 {0, 0xfffa, 0x0124},
2812 {0, 0xfff9, 0x0124},
2813 {0, 0x0086, 0x0127},
2814 {0, 0xfff8, 0x0124},
2815 {0, 0xfffd, 0x0124},
2816 {0, 0x0038, 0x0127},
2817 {0, 0xfff8, 0x0124},
2818 {0, 0xfffd, 0x0124},
2819 {0, 0x0006, 0x0127},
2820 {0, 0xfff8, 0x0124},
2821 {0, 0xfffd, 0x0124},
2822 {0, 0x0045, 0x0127},
2823 {0, 0xfff8, 0x0124},
2824 {0, 0xfffd, 0x0124},
2825 {0, 0xfffa, 0x0124},
2826 {0, 0xfff9, 0x0124},
2827 {0, 0x0086, 0x0127},
2828 {0, 0xfff8, 0x0124},
2829 {0, 0xfffd, 0x0124},
2830 {0, 0x0037, 0x0127},
2831 {0, 0xfff8, 0x0124},
2832 {0, 0xfffd, 0x0124},
2833 {0, 0x0001, 0x0127},
2834 {0, 0xfff8, 0x0124},
2835 {0, 0xfffd, 0x0124},
2836 {0, 0x002a, 0x0127},
2837 {0, 0xfff8, 0x0124},
2838 {0, 0xfffd, 0x0124},
2839 {0, 0xfffa, 0x0124},
2840 {0, 0xfff9, 0x0124},
2841 {0, 0x0086, 0x0127},
2842 {0, 0xfff8, 0x0124},
2843 {0, 0xfffd, 0x0124},
2844 {0, 0x0038, 0x0127},
2845 {0, 0xfff8, 0x0124},
2846 {0, 0xfffd, 0x0124},
2847 {0, 0x0000, 0x0127},
2848 {0, 0xfff8, 0x0124},
2849 {0, 0xfffd, 0x0124},
2850 {0, 0x000e, 0x0127},
2851 {0, 0xfff8, 0x0124},
2852 {0, 0xfffd, 0x0124},
2853 {0, 0xfffa, 0x0124},
2854 {0, 0xfff9, 0x0124},
2855 {0, 0x0086, 0x0127},
2856 {0, 0xfff8, 0x0124},
2857 {0, 0xfffd, 0x0124},
2858 {0, 0x0037, 0x0127},
2859 {0, 0xfff8, 0x0124},
2860 {0, 0xfffd, 0x0124},
2861 {0, 0x0001, 0x0127},
2862 {0, 0xfff8, 0x0124},
2863 {0, 0xfffd, 0x0124},
2864 {0, 0x002b, 0x0127},
2865 {0, 0xfff8, 0x0124},
2866 {0, 0xfffd, 0x0124},
2867 {0, 0xfffa, 0x0124},
2868 {0, 0xfff9, 0x0124},
2869 {0, 0x0086, 0x0127},
2870 {0, 0xfff8, 0x0124},
2871 {0, 0xfffd, 0x0124},
2872 {0, 0x0038, 0x0127},
2873 {0, 0xfff8, 0x0124},
2874 {0, 0xfffd, 0x0124},
2875 {0, 0x0001, 0x0127},
2876 {0, 0xfff8, 0x0124},
2877 {0, 0xfffd, 0x0124},
2878 {0, 0x00f4, 0x0127},
2879 {0, 0xfff8, 0x0124},
2880 {0, 0xfffd, 0x0124},
2881 {0, 0xfffa, 0x0124},
2882 {0, 0xfff9, 0x0124},
2883 {0, 0x0086, 0x0127},
2884 {0, 0xfff8, 0x0124},
2885 {0, 0xfffd, 0x0124},
2886 {0, 0x0037, 0x0127},
2887 {0, 0xfff8, 0x0124},
2888 {0, 0xfffd, 0x0124},
2889 {0, 0x0001, 0x0127},
2890 {0, 0xfff8, 0x0124},
2891 {0, 0xfffd, 0x0124},
2892 {0, 0x002c, 0x0127},
2893 {0, 0xfff8, 0x0124},
2894 {0, 0xfffd, 0x0124},
2895 {0, 0xfffa, 0x0124},
2896 {0, 0xfff9, 0x0124},
2897 {0, 0x0086, 0x0127},
2898 {0, 0xfff8, 0x0124},
2899 {0, 0xfffd, 0x0124},
2900 {0, 0x0038, 0x0127},
2901 {0, 0xfff8, 0x0124},
2902 {0, 0xfffd, 0x0124},
2903 {0, 0x0001, 0x0127},
2904 {0, 0xfff8, 0x0124},
2905 {0, 0xfffd, 0x0124},
2906 {0, 0x0004, 0x0127},
2907 {0, 0xfff8, 0x0124},
2908 {0, 0xfffd, 0x0124},
2909 {0, 0xfffa, 0x0124},
2910 {0, 0xfff9, 0x0124},
2911 {0, 0x0086, 0x0127},
2912 {0, 0xfff8, 0x0124},
2913 {0, 0xfffd, 0x0124},
2914 {0, 0x0037, 0x0127},
2915 {0, 0xfff8, 0x0124},
2916 {0, 0xfffd, 0x0124},
2917 {0, 0x0001, 0x0127},
2918 {0, 0xfff8, 0x0124},
2919 {0, 0xfffd, 0x0124},
2920 {0, 0x002d, 0x0127},
2921 {0, 0xfff8, 0x0124},
2922 {0, 0xfffd, 0x0124},
2923 {0, 0xfffa, 0x0124},
2924 {0, 0xfff9, 0x0124},
2925 {0, 0x0086, 0x0127},
2926 {0, 0xfff8, 0x0124},
2927 {0, 0xfffd, 0x0124},
2928 {0, 0x0038, 0x0127},
2929 {0, 0xfff8, 0x0124},
2930 {0, 0xfffd, 0x0124},
2931 {0, 0x0000, 0x0127},
2932 {0, 0xfff8, 0x0124},
2933 {0, 0xfffd, 0x0124},
2934 {0, 0x0014, 0x0127},
2935 {0, 0xfff8, 0x0124},
2936 {0, 0xfffd, 0x0124},
2937 {0, 0xfffa, 0x0124},
2938 {0, 0xfff9, 0x0124},
2939 {0, 0x0086, 0x0127},
2940 {0, 0xfff8, 0x0124},
2941 {0, 0xfffd, 0x0124},
2942 {0, 0x0037, 0x0127},
2943 {0, 0xfff8, 0x0124},
2944 {0, 0xfffd, 0x0124},
2945 {0, 0x0001, 0x0127},
2946 {0, 0xfff8, 0x0124},
2947 {0, 0xfffd, 0x0124},
2948 {0, 0x002e, 0x0127},
2949 {0, 0xfff8, 0x0124},
2950 {0, 0xfffd, 0x0124},
2951 {0, 0xfffa, 0x0124},
2952 {0, 0xfff9, 0x0124},
2953 {0, 0x0086, 0x0127},
2954 {0, 0xfff8, 0x0124},
2955 {0, 0xfffd, 0x0124},
2956 {0, 0x0038, 0x0127},
2957 {0, 0xfff8, 0x0124},
2958 {0, 0xfffd, 0x0124},
2959 {0, 0x0003, 0x0127},
2960 {0, 0xfff8, 0x0124},
2961 {0, 0xfffd, 0x0124},
2962 {0, 0x0000, 0x0127},
2963 {0, 0xfff8, 0x0124},
2964 {0, 0xfffd, 0x0124},
2965 {0, 0xfffa, 0x0124},
2966 {0, 0xfff9, 0x0124},
2967 {0, 0x0086, 0x0127},
2968 {0, 0xfff8, 0x0124},
2969 {0, 0xfffd, 0x0124},
2970 {0, 0x0037, 0x0127},
2971 {0, 0xfff8, 0x0124},
2972 {0, 0xfffd, 0x0124},
2973 {0, 0x0001, 0x0127},
2974 {0, 0xfff8, 0x0124},
2975 {0, 0xfffd, 0x0124},
2976 {0, 0x002f, 0x0127},
2977 {0, 0xfff8, 0x0124},
2978 {0, 0xfffd, 0x0124},
2979 {0, 0xfffa, 0x0124},
2980 {0, 0xfff9, 0x0124},
2981 {0, 0x0086, 0x0127},
2982 {0, 0xfff8, 0x0124},
2983 {0, 0xfffd, 0x0124},
2984 {0, 0x0038, 0x0127},
2985 {0, 0xfff8, 0x0124},
2986 {0, 0xfffd, 0x0124},
2987 {0, 0x0003, 0x0127},
2988 {0, 0xfff8, 0x0124},
2989 {0, 0xfffd, 0x0124},
2990 {0, 0x0014, 0x0127},
2991 {0, 0xfff8, 0x0124},
2992 {0, 0xfffd, 0x0124},
2993 {0, 0xfffa, 0x0124},
2994 {0, 0xfff9, 0x0124},
2995 {0, 0x0086, 0x0127},
2996 {0, 0xfff8, 0x0124},
2997 {0, 0xfffd, 0x0124},
2998 {0, 0x0037, 0x0127},
2999 {0, 0xfff8, 0x0124},
3000 {0, 0xfffd, 0x0124},
3001 {0, 0x0001, 0x0127},
3002 {0, 0xfff8, 0x0124},
3003 {0, 0xfffd, 0x0124},
3004 {0, 0x0040, 0x0127},
3005 {0, 0xfff8, 0x0124},
3006 {0, 0xfffd, 0x0124},
3007 {0, 0xfffa, 0x0124},
3008 {0, 0xfff9, 0x0124},
3009 {0, 0x0086, 0x0127},
3010 {0, 0xfff8, 0x0124},
3011 {0, 0xfffd, 0x0124},
3012 {0, 0x0038, 0x0127},
3013 {0, 0xfff8, 0x0124},
3014 {0, 0xfffd, 0x0124},
3015 {0, 0x0000, 0x0127},
3016 {0, 0xfff8, 0x0124},
3017 {0, 0xfffd, 0x0124},
3018 {0, 0x0040, 0x0127},
3019 {0, 0xfff8, 0x0124},
3020 {0, 0xfffd, 0x0124},
3021 {0, 0xfffa, 0x0124},
3022 {0, 0xfff9, 0x0124},
3023 {0, 0x0086, 0x0127},
3024 {0, 0xfff8, 0x0124},
3025 {0, 0xfffd, 0x0124},
3026 {0, 0x0037, 0x0127},
3027 {0, 0xfff8, 0x0124},
3028 {0, 0xfffd, 0x0124},
3029 {0, 0x0001, 0x0127},
3030 {0, 0xfff8, 0x0124},
3031 {0, 0xfffd, 0x0124},
3032 {0, 0x0053, 0x0127},
3033 {0, 0xfff8, 0x0124},
3034 {0, 0xfffd, 0x0124},
3035 {0, 0xfffa, 0x0124},
3036 {0, 0xfff9, 0x0124},
3037 {0, 0x0086, 0x0127},
3038 {0, 0xfff8, 0x0124},
3039 {0, 0xfffd, 0x0124},
3040 {0, 0x0038, 0x0127},
3041 {0, 0xfff8, 0x0124},
3042 {0, 0xfffd, 0x0124},
3043 {0, 0x0000, 0x0127},
3044 {0, 0xfff8, 0x0124},
3045 {0, 0xfffd, 0x0124},
3046 {0, 0x0038, 0x0127},
3047 {0, 0xfff8, 0x0124},
3048 {0, 0xfffd, 0x0124},
3049 {0, 0xfffa, 0x0124},
3050 {0, 0x0000, 0x0101},
3051 {0, 0x00a0, 0x0103},
3052 {0, 0x0078, 0x0105},
3053 {0, 0x0000, 0x010a},
3054 {0, 0x0024, 0x010b},
3055 {0, 0x0028, 0x0119},
3056 {0, 0x0088, 0x011b},
3057 {0, 0x0002, 0x011d},
3058 {0, 0x0003, 0x011e},
3059 {0, 0x0000, 0x0129},
3060 {0, 0x00fc, 0x012b},
3061 {0, 0x0008, 0x0102},
3062 {0, 0x0000, 0x0104},
3063 {0, 0x0008, 0x011a},
3064 {0, 0x0028, 0x011c},
3065 {0, 0x0021, 0x012a},
3066 {0, 0x0000, 0x0118},
3067 {0, 0x0000, 0x0132},
3068 {0, 0x0000, 0x0109},
3069 {0, 0xfff9, 0x0124},
3070 {0, 0x0086, 0x0127},
3071 {0, 0xfff8, 0x0124},
3072 {0, 0xfffd, 0x0124},
3073 {0, 0x0037, 0x0127},
3074 {0, 0xfff8, 0x0124},
3075 {0, 0xfffd, 0x0124},
3076 {0, 0x0001, 0x0127},
3077 {0, 0xfff8, 0x0124},
3078 {0, 0xfffd, 0x0124},
3079 {0, 0x0031, 0x0127},
3080 {0, 0xfff8, 0x0124},
3081 {0, 0xfffd, 0x0124},
3082 {0, 0xfffa, 0x0124},
3083 {0, 0xfff9, 0x0124},
3084 {0, 0x0086, 0x0127},
3085 {0, 0xfff8, 0x0124},
3086 {0, 0xfffd, 0x0124},
3087 {0, 0x0038, 0x0127},
3088 {0, 0xfff8, 0x0124},
3089 {0, 0xfffd, 0x0124},
3090 {0, 0x0000, 0x0127},
3091 {0, 0xfff8, 0x0124},
3092 {0, 0xfffd, 0x0124},
3093 {0, 0x0000, 0x0127},
3094 {0, 0xfff8, 0x0124},
3095 {0, 0xfffd, 0x0124},
3096 {0, 0xfffa, 0x0124},
3097 {0, 0xfff9, 0x0124},
3098 {0, 0x0086, 0x0127},
3099 {0, 0xfff8, 0x0124},
3100 {0, 0xfffd, 0x0124},
3101 {0, 0x0037, 0x0127},
3102 {0, 0xfff8, 0x0124},
3103 {0, 0xfffd, 0x0124},
3104 {0, 0x0001, 0x0127},
3105 {0, 0xfff8, 0x0124},
3106 {0, 0xfffd, 0x0124},
3107 {0, 0x0040, 0x0127},
3108 {0, 0xfff8, 0x0124},
3109 {0, 0xfffd, 0x0124},
3110 {0, 0xfffa, 0x0124},
3111 {0, 0xfff9, 0x0124},
3112 {0, 0x0086, 0x0127},
3113 {0, 0xfff8, 0x0124},
3114 {0, 0xfffd, 0x0124},
3115 {0, 0x0038, 0x0127},
3116 {0, 0xfff8, 0x0124},
3117 {0, 0xfffd, 0x0124},
3118 {0, 0x0000, 0x0127},
3119 {0, 0xfff8, 0x0124},
3120 {0, 0xfffd, 0x0124},
3121 {0, 0x0040, 0x0127},
3122 {0, 0xfff8, 0x0124},
3123 {0, 0xfffd, 0x0124},
3124 {0, 0xfffa, 0x0124},
3125 {0, 0xfff9, 0x0124},
3126 {0, 0x0086, 0x0127},
3127 {0, 0xfff8, 0x0124},
3128 {0, 0xfffd, 0x0124},
3129 {0, 0x0037, 0x0127},
3130 {0, 0xfff8, 0x0124},
3131 {0, 0xfffd, 0x0124},
3132 {0, 0x0000, 0x0127},
3133 {0, 0xfff8, 0x0124},
3134 {0, 0xfffd, 0x0124},
3135 {0, 0x00dc, 0x0127},
3136 {0, 0xfff8, 0x0124},
3137 {0, 0xfffd, 0x0124},
3138 {0, 0xfffa, 0x0124},
3139 {0, 0xfff9, 0x0124},
3140 {0, 0x0086, 0x0127},
3141 {0, 0xfff8, 0x0124},
3142 {0, 0xfffd, 0x0124},
3143 {0, 0x0038, 0x0127},
3144 {0, 0xfff8, 0x0124},
3145 {0, 0xfffd, 0x0124},
3146 {0, 0x0000, 0x0127},
3147 {0, 0xfff8, 0x0124},
3148 {0, 0xfffd, 0x0124},
3149 {0, 0x0000, 0x0127},
3150 {0, 0xfff8, 0x0124},
3151 {0, 0xfffd, 0x0124},
3152 {0, 0xfffa, 0x0124},
3153 {0, 0xfff9, 0x0124},
3154 {0, 0x0086, 0x0127},
3155 {0, 0xfff8, 0x0124},
3156 {0, 0xfffd, 0x0124},
3157 {0, 0x0037, 0x0127},
3158 {0, 0xfff8, 0x0124},
3159 {0, 0xfffd, 0x0124},
3160 {0, 0x0001, 0x0127},
3161 {0, 0xfff8, 0x0124},
3162 {0, 0xfffd, 0x0124},
3163 {0, 0x0032, 0x0127},
3164 {0, 0xfff8, 0x0124},
3165 {0, 0xfffd, 0x0124},
3166 {0, 0xfffa, 0x0124},
3167 {0, 0xfff9, 0x0124},
3168 {0, 0x0086, 0x0127},
3169 {0, 0xfff8, 0x0124},
3170 {0, 0xfffd, 0x0124},
3171 {0, 0x0038, 0x0127},
3172 {0, 0xfff8, 0x0124},
3173 {0, 0xfffd, 0x0124},
3174 {0, 0x0001, 0x0127},
3175 {0, 0xfff8, 0x0124},
3176 {0, 0xfffd, 0x0124},
3177 {0, 0x0020, 0x0127},
3178 {0, 0xfff8, 0x0124},
3179 {0, 0xfffd, 0x0124},
3180 {0, 0xfffa, 0x0124},
3181 {0, 0xfff9, 0x0124},
3182 {0, 0x0086, 0x0127},
3183 {0, 0xfff8, 0x0124},
3184 {0, 0xfffd, 0x0124},
3185 {0, 0x0037, 0x0127},
3186 {0, 0xfff8, 0x0124},
3187 {0, 0xfffd, 0x0124},
3188 {0, 0x0001, 0x0127},
3189 {0, 0xfff8, 0x0124},
3190 {0, 0xfffd, 0x0124},
3191 {0, 0x0040, 0x0127},
3192 {0, 0xfff8, 0x0124},
3193 {0, 0xfffd, 0x0124},
3194 {0, 0xfffa, 0x0124},
3195 {0, 0xfff9, 0x0124},
3196 {0, 0x0086, 0x0127},
3197 {0, 0xfff8, 0x0124},
3198 {0, 0xfffd, 0x0124},
3199 {0, 0x0038, 0x0127},
3200 {0, 0xfff8, 0x0124},
3201 {0, 0xfffd, 0x0124},
3202 {0, 0x0000, 0x0127},
3203 {0, 0xfff8, 0x0124},
3204 {0, 0xfffd, 0x0124},
3205 {0, 0x0040, 0x0127},
3206 {0, 0xfff8, 0x0124},
3207 {0, 0xfffd, 0x0124},
3208 {0, 0xfffa, 0x0124},
3209 {0, 0xfff9, 0x0124},
3210 {0, 0x0086, 0x0127},
3211 {0, 0xfff8, 0x0124},
3212 {0, 0xfffd, 0x0124},
3213 {0, 0x0037, 0x0127},
3214 {0, 0xfff8, 0x0124},
3215 {0, 0xfffd, 0x0124},
3216 {0, 0x0000, 0x0127},
3217 {0, 0xfff8, 0x0124},
3218 {0, 0xfffd, 0x0124},
3219 {0, 0x0030, 0x0127},
3220 {0, 0xfff8, 0x0124},
3221 {0, 0xfffd, 0x0124},
3222 {0, 0xfffa, 0x0124},
3223 {0, 0xfff9, 0x0124},
3224 {0, 0x0086, 0x0127},
3225 {0, 0xfff8, 0x0124},
3226 {0, 0xfffd, 0x0124},
3227 {0, 0x0038, 0x0127},
3228 {0, 0xfff8, 0x0124},
3229 {0, 0xfffd, 0x0124},
3230 {0, 0x0008, 0x0127},
3231 {0, 0xfff8, 0x0124},
3232 {0, 0xfffd, 0x0124},
3233 {0, 0x0000, 0x0127},
3234 {0, 0xfff8, 0x0124},
3235 {0, 0xfffd, 0x0124},
3236 {0, 0xfffa, 0x0124},
3237 {0, 0x0003, 0x0106},
3238 {0, 0x0062, 0x0107},
3239 {0, 0x0003, 0x0111},
3241 #define NUM_INIT_DATA
3243 unsigned short compression
= 0; /* 0=none, 7=best frame rate */
3244 int f_rate
; /* 0=Fastest 7=slowest */
3246 if (IBMCAM_T(uvd
)->initialized
)
3249 /* Internal frame rate is controlled by f_rate value */
3250 f_rate
= 7 - framerate
;
3251 RESTRICT_TO_RANGE(f_rate
, 0, 7);
3253 ibmcam_veio(uvd
, 0, 0x0000, 0x0100);
3254 ibmcam_veio(uvd
, 1, 0x0000, 0x0116);
3255 ibmcam_veio(uvd
, 0, 0x0060, 0x0116);
3256 ibmcam_veio(uvd
, 0, 0x0002, 0x0112);
3257 ibmcam_veio(uvd
, 0, 0x0000, 0x0123);
3258 ibmcam_veio(uvd
, 0, 0x0001, 0x0117);
3259 ibmcam_veio(uvd
, 0, 0x0040, 0x0108);
3260 ibmcam_veio(uvd
, 0, 0x0019, 0x012c);
3261 ibmcam_veio(uvd
, 0, 0x0060, 0x0116);
3262 ibmcam_veio(uvd
, 0, 0x0002, 0x0115);
3263 ibmcam_veio(uvd
, 0, 0x0003, 0x0115);
3264 ibmcam_veio(uvd
, 1, 0x0000, 0x0115);
3265 ibmcam_veio(uvd
, 0, 0x000b, 0x0115);
3266 ibmcam_model3_Packet1(uvd
, 0x000a, 0x0040);
3267 ibmcam_model3_Packet1(uvd
, 0x000b, 0x00f6);
3268 ibmcam_model3_Packet1(uvd
, 0x000c, 0x0002);
3269 ibmcam_model3_Packet1(uvd
, 0x000d, 0x0020);
3270 ibmcam_model3_Packet1(uvd
, 0x000e, 0x0033);
3271 ibmcam_model3_Packet1(uvd
, 0x000f, 0x0007);
3272 ibmcam_model3_Packet1(uvd
, 0x0010, 0x0000);
3273 ibmcam_model3_Packet1(uvd
, 0x0011, 0x0070);
3274 ibmcam_model3_Packet1(uvd
, 0x0012, 0x0030);
3275 ibmcam_model3_Packet1(uvd
, 0x0013, 0x0000);
3276 ibmcam_model3_Packet1(uvd
, 0x0014, 0x0001);
3277 ibmcam_model3_Packet1(uvd
, 0x0015, 0x0001);
3278 ibmcam_model3_Packet1(uvd
, 0x0016, 0x0001);
3279 ibmcam_model3_Packet1(uvd
, 0x0017, 0x0001);
3280 ibmcam_model3_Packet1(uvd
, 0x0018, 0x0000);
3281 ibmcam_model3_Packet1(uvd
, 0x001e, 0x00c3);
3282 ibmcam_model3_Packet1(uvd
, 0x0020, 0x0000);
3283 ibmcam_model3_Packet1(uvd
, 0x0028, 0x0010);
3284 ibmcam_model3_Packet1(uvd
, 0x0029, 0x0054);
3285 ibmcam_model3_Packet1(uvd
, 0x002a, 0x0013);
3286 ibmcam_model3_Packet1(uvd
, 0x002b, 0x0007);
3287 ibmcam_model3_Packet1(uvd
, 0x002d, 0x0028);
3288 ibmcam_model3_Packet1(uvd
, 0x002e, 0x0000);
3289 ibmcam_model3_Packet1(uvd
, 0x0031, 0x0000);
3290 ibmcam_model3_Packet1(uvd
, 0x0032, 0x0000);
3291 ibmcam_model3_Packet1(uvd
, 0x0033, 0x0000);
3292 ibmcam_model3_Packet1(uvd
, 0x0034, 0x0000);
3293 ibmcam_model3_Packet1(uvd
, 0x0035, 0x0038);
3294 ibmcam_model3_Packet1(uvd
, 0x003a, 0x0001);
3295 ibmcam_model3_Packet1(uvd
, 0x003c, 0x001e);
3296 ibmcam_model3_Packet1(uvd
, 0x003f, 0x000a);
3297 ibmcam_model3_Packet1(uvd
, 0x0041, 0x0000);
3298 ibmcam_model3_Packet1(uvd
, 0x0046, 0x003f);
3299 ibmcam_model3_Packet1(uvd
, 0x0047, 0x0000);
3300 ibmcam_model3_Packet1(uvd
, 0x0050, 0x0005);
3301 ibmcam_model3_Packet1(uvd
, 0x0052, 0x001a);
3302 ibmcam_model3_Packet1(uvd
, 0x0053, 0x0003);
3303 ibmcam_model3_Packet1(uvd
, 0x005a, 0x006b);
3304 ibmcam_model3_Packet1(uvd
, 0x005d, 0x001e);
3305 ibmcam_model3_Packet1(uvd
, 0x005e, 0x0030);
3306 ibmcam_model3_Packet1(uvd
, 0x005f, 0x0041);
3307 ibmcam_model3_Packet1(uvd
, 0x0064, 0x0008);
3308 ibmcam_model3_Packet1(uvd
, 0x0065, 0x0015);
3309 ibmcam_model3_Packet1(uvd
, 0x0068, 0x000f);
3310 ibmcam_model3_Packet1(uvd
, 0x0079, 0x0000);
3311 ibmcam_model3_Packet1(uvd
, 0x007a, 0x0000);
3312 ibmcam_model3_Packet1(uvd
, 0x007c, 0x003f);
3313 ibmcam_model3_Packet1(uvd
, 0x0082, 0x000f);
3314 ibmcam_model3_Packet1(uvd
, 0x0085, 0x0000);
3315 ibmcam_model3_Packet1(uvd
, 0x0099, 0x0000);
3316 ibmcam_model3_Packet1(uvd
, 0x009b, 0x0023);
3317 ibmcam_model3_Packet1(uvd
, 0x009c, 0x0022);
3318 ibmcam_model3_Packet1(uvd
, 0x009d, 0x0096);
3319 ibmcam_model3_Packet1(uvd
, 0x009e, 0x0096);
3320 ibmcam_model3_Packet1(uvd
, 0x009f, 0x000a);
3322 switch (uvd
->videosize
) {
3323 case VIDEOSIZE_160x120
:
3324 ibmcam_veio(uvd
, 0, 0x0000, 0x0101); /* Same on 176x144, 320x240 */
3325 ibmcam_veio(uvd
, 0, 0x00a0, 0x0103); /* Same on 176x144, 320x240 */
3326 ibmcam_veio(uvd
, 0, 0x0078, 0x0105); /* Same on 176x144, 320x240 */
3327 ibmcam_veio(uvd
, 0, 0x0000, 0x010a); /* Same */
3328 ibmcam_veio(uvd
, 0, 0x0024, 0x010b); /* Differs everywhere */
3329 ibmcam_veio(uvd
, 0, 0x00a9, 0x0119);
3330 ibmcam_veio(uvd
, 0, 0x0016, 0x011b);
3331 ibmcam_veio(uvd
, 0, 0x0002, 0x011d); /* Same on 176x144, 320x240 */
3332 ibmcam_veio(uvd
, 0, 0x0003, 0x011e); /* Same on 176x144, 640x480 */
3333 ibmcam_veio(uvd
, 0, 0x0000, 0x0129); /* Same */
3334 ibmcam_veio(uvd
, 0, 0x00fc, 0x012b); /* Same */
3335 ibmcam_veio(uvd
, 0, 0x0018, 0x0102);
3336 ibmcam_veio(uvd
, 0, 0x0004, 0x0104);
3337 ibmcam_veio(uvd
, 0, 0x0004, 0x011a);
3338 ibmcam_veio(uvd
, 0, 0x0028, 0x011c);
3339 ibmcam_veio(uvd
, 0, 0x0022, 0x012a); /* Same */
3340 ibmcam_veio(uvd
, 0, 0x0000, 0x0118);
3341 ibmcam_veio(uvd
, 0, 0x0000, 0x0132);
3342 ibmcam_model3_Packet1(uvd
, 0x0021, 0x0001); /* Same */
3343 ibmcam_veio(uvd
, 0, compression
, 0x0109);
3345 case VIDEOSIZE_320x240
:
3346 ibmcam_veio(uvd
, 0, 0x0000, 0x0101); /* Same on 176x144, 320x240 */
3347 ibmcam_veio(uvd
, 0, 0x00a0, 0x0103); /* Same on 176x144, 320x240 */
3348 ibmcam_veio(uvd
, 0, 0x0078, 0x0105); /* Same on 176x144, 320x240 */
3349 ibmcam_veio(uvd
, 0, 0x0000, 0x010a); /* Same */
3350 ibmcam_veio(uvd
, 0, 0x0028, 0x010b); /* Differs everywhere */
3351 ibmcam_veio(uvd
, 0, 0x0002, 0x011d); /* Same */
3352 ibmcam_veio(uvd
, 0, 0x0000, 0x011e);
3353 ibmcam_veio(uvd
, 0, 0x0000, 0x0129); /* Same */
3354 ibmcam_veio(uvd
, 0, 0x00fc, 0x012b); /* Same */
3355 /* 4 commands from 160x120 skipped */
3356 ibmcam_veio(uvd
, 0, 0x0022, 0x012a); /* Same */
3357 ibmcam_model3_Packet1(uvd
, 0x0021, 0x0001); /* Same */
3358 ibmcam_veio(uvd
, 0, compression
, 0x0109);
3359 ibmcam_veio(uvd
, 0, 0x00d9, 0x0119);
3360 ibmcam_veio(uvd
, 0, 0x0006, 0x011b);
3361 ibmcam_veio(uvd
, 0, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
3362 ibmcam_veio(uvd
, 0, 0x0010, 0x0104);
3363 ibmcam_veio(uvd
, 0, 0x0004, 0x011a);
3364 ibmcam_veio(uvd
, 0, 0x003f, 0x011c);
3365 ibmcam_veio(uvd
, 0, 0x001c, 0x0118);
3366 ibmcam_veio(uvd
, 0, 0x0000, 0x0132);
3368 case VIDEOSIZE_640x480
:
3369 ibmcam_veio(uvd
, 0, 0x00f0, 0x0105);
3370 ibmcam_veio(uvd
, 0, 0x0000, 0x010a); /* Same */
3371 ibmcam_veio(uvd
, 0, 0x0038, 0x010b); /* Differs everywhere */
3372 ibmcam_veio(uvd
, 0, 0x00d9, 0x0119); /* Same on 320x240, 640x480 */
3373 ibmcam_veio(uvd
, 0, 0x0006, 0x011b); /* Same on 320x240, 640x480 */
3374 ibmcam_veio(uvd
, 0, 0x0004, 0x011d); /* NC */
3375 ibmcam_veio(uvd
, 0, 0x0003, 0x011e); /* Same on 176x144, 640x480 */
3376 ibmcam_veio(uvd
, 0, 0x0000, 0x0129); /* Same */
3377 ibmcam_veio(uvd
, 0, 0x00fc, 0x012b); /* Same */
3378 ibmcam_veio(uvd
, 0, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
3379 ibmcam_veio(uvd
, 0, 0x0016, 0x0104); /* NC */
3380 ibmcam_veio(uvd
, 0, 0x0004, 0x011a); /* Same on 320x240, 640x480 */
3381 ibmcam_veio(uvd
, 0, 0x003f, 0x011c); /* Same on 320x240, 640x480 */
3382 ibmcam_veio(uvd
, 0, 0x0022, 0x012a); /* Same */
3383 ibmcam_veio(uvd
, 0, 0x001c, 0x0118); /* Same on 320x240, 640x480 */
3384 ibmcam_model3_Packet1(uvd
, 0x0021, 0x0001); /* Same */
3385 ibmcam_veio(uvd
, 0, compression
, 0x0109);
3386 ibmcam_veio(uvd
, 0, 0x0040, 0x0101);
3387 ibmcam_veio(uvd
, 0, 0x0040, 0x0103);
3388 ibmcam_veio(uvd
, 0, 0x0000, 0x0132); /* Same on 320x240, 640x480 */
3391 ibmcam_model3_Packet1(uvd
, 0x007e, 0x000e); /* Hue */
3392 ibmcam_model3_Packet1(uvd
, 0x0036, 0x0011); /* Brightness */
3393 ibmcam_model3_Packet1(uvd
, 0x0060, 0x0002); /* Sharpness */
3394 ibmcam_model3_Packet1(uvd
, 0x0061, 0x0004); /* Sharpness */
3395 ibmcam_model3_Packet1(uvd
, 0x0062, 0x0005); /* Sharpness */
3396 ibmcam_model3_Packet1(uvd
, 0x0063, 0x0014); /* Sharpness */
3397 ibmcam_model3_Packet1(uvd
, 0x0096, 0x00a0); /* Red gain */
3398 ibmcam_model3_Packet1(uvd
, 0x0097, 0x0096); /* Blue gain */
3399 ibmcam_model3_Packet1(uvd
, 0x0067, 0x0001); /* Contrast */
3400 ibmcam_model3_Packet1(uvd
, 0x005b, 0x000c); /* Contrast */
3401 ibmcam_model3_Packet1(uvd
, 0x005c, 0x0016); /* Contrast */
3402 ibmcam_model3_Packet1(uvd
, 0x0098, 0x000b);
3403 ibmcam_model3_Packet1(uvd
, 0x002c, 0x0003); /* Was 1, broke 640x480 */
3404 ibmcam_model3_Packet1(uvd
, 0x002f, 0x002a);
3405 ibmcam_model3_Packet1(uvd
, 0x0030, 0x0029);
3406 ibmcam_model3_Packet1(uvd
, 0x0037, 0x0002);
3407 ibmcam_model3_Packet1(uvd
, 0x0038, 0x0059);
3408 ibmcam_model3_Packet1(uvd
, 0x003d, 0x002e);
3409 ibmcam_model3_Packet1(uvd
, 0x003e, 0x0028);
3410 ibmcam_model3_Packet1(uvd
, 0x0078, 0x0005);
3411 ibmcam_model3_Packet1(uvd
, 0x007b, 0x0011);
3412 ibmcam_model3_Packet1(uvd
, 0x007d, 0x004b);
3413 ibmcam_model3_Packet1(uvd
, 0x007f, 0x0022);
3414 ibmcam_model3_Packet1(uvd
, 0x0080, 0x000c);
3415 ibmcam_model3_Packet1(uvd
, 0x0081, 0x000b);
3416 ibmcam_model3_Packet1(uvd
, 0x0083, 0x00fd);
3417 ibmcam_model3_Packet1(uvd
, 0x0086, 0x000b);
3418 ibmcam_model3_Packet1(uvd
, 0x0087, 0x000b);
3419 ibmcam_model3_Packet1(uvd
, 0x007e, 0x000e);
3420 ibmcam_model3_Packet1(uvd
, 0x0096, 0x00a0); /* Red gain */
3421 ibmcam_model3_Packet1(uvd
, 0x0097, 0x0096); /* Blue gain */
3422 ibmcam_model3_Packet1(uvd
, 0x0098, 0x000b);
3424 switch (uvd
->videosize
) {
3425 case VIDEOSIZE_160x120
:
3426 ibmcam_veio(uvd
, 0, 0x0002, 0x0106);
3427 ibmcam_veio(uvd
, 0, 0x0008, 0x0107);
3428 ibmcam_veio(uvd
, 0, f_rate
, 0x0111); /* Frame rate */
3429 ibmcam_model3_Packet1(uvd
, 0x001f, 0x0000); /* Same */
3430 ibmcam_model3_Packet1(uvd
, 0x0039, 0x001f); /* Same */
3431 ibmcam_model3_Packet1(uvd
, 0x003b, 0x003c); /* Same */
3432 ibmcam_model3_Packet1(uvd
, 0x0040, 0x000a);
3433 ibmcam_model3_Packet1(uvd
, 0x0051, 0x000a);
3435 case VIDEOSIZE_320x240
:
3436 ibmcam_veio(uvd
, 0, 0x0003, 0x0106);
3437 ibmcam_veio(uvd
, 0, 0x0062, 0x0107);
3438 ibmcam_veio(uvd
, 0, f_rate
, 0x0111); /* Frame rate */
3439 ibmcam_model3_Packet1(uvd
, 0x001f, 0x0000); /* Same */
3440 ibmcam_model3_Packet1(uvd
, 0x0039, 0x001f); /* Same */
3441 ibmcam_model3_Packet1(uvd
, 0x003b, 0x003c); /* Same */
3442 ibmcam_model3_Packet1(uvd
, 0x0040, 0x0008);
3443 ibmcam_model3_Packet1(uvd
, 0x0051, 0x000b);
3445 case VIDEOSIZE_640x480
:
3446 ibmcam_veio(uvd
, 0, 0x0002, 0x0106); /* Adjustments */
3447 ibmcam_veio(uvd
, 0, 0x00b4, 0x0107); /* Adjustments */
3448 ibmcam_veio(uvd
, 0, f_rate
, 0x0111); /* Frame rate */
3449 ibmcam_model3_Packet1(uvd
, 0x001f, 0x0002); /* !Same */
3450 ibmcam_model3_Packet1(uvd
, 0x0039, 0x003e); /* !Same */
3451 ibmcam_model3_Packet1(uvd
, 0x0040, 0x0008);
3452 ibmcam_model3_Packet1(uvd
, 0x0051, 0x000a);
3456 /* 01.01.08 - Added for RCA video in support -LO */
3457 if(init_model3_input
) {
3459 info("Setting input to RCA.");
3460 for (i
=0; i
< (sizeof(initData
)/sizeof(initData
[0])); i
++) {
3461 ibmcam_veio(uvd
, initData
[i
].req
, initData
[i
].value
, initData
[i
].index
);
3465 ibmcam_veio(uvd
, 0, 0x0001, 0x0114);
3466 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
3467 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
3471 * ibmcam_video_stop()
3473 * This code tells camera to stop streaming. The interface remains
3474 * configured and bandwidth - claimed.
3476 static void ibmcam_video_stop(struct uvd
*uvd
)
3478 switch (IBMCAM_T(uvd
)->camera_model
) {
3479 case IBMCAM_MODEL_1
:
3480 ibmcam_veio(uvd
, 0, 0x00, 0x010c);
3481 ibmcam_veio(uvd
, 0, 0x00, 0x010c);
3482 ibmcam_veio(uvd
, 0, 0x01, 0x0114);
3483 ibmcam_veio(uvd
, 0, 0xc0, 0x010c);
3484 ibmcam_veio(uvd
, 0, 0x00, 0x010c);
3485 ibmcam_send_FF_04_02(uvd
);
3486 ibmcam_veio(uvd
, 1, 0x00, 0x0100);
3487 ibmcam_veio(uvd
, 0, 0x81, 0x0100); /* LED Off */
3489 case IBMCAM_MODEL_2
:
3490 case IBMCAM_MODEL_4
:
3491 ibmcam_veio(uvd
, 0, 0x0000, 0x010c); /* Stop the camera */
3493 ibmcam_model2_Packet1(uvd
, 0x0030, 0x0004);
3495 ibmcam_veio(uvd
, 0, 0x0080, 0x0100); /* LED Off */
3496 ibmcam_veio(uvd
, 0, 0x0020, 0x0111);
3497 ibmcam_veio(uvd
, 0, 0x00a0, 0x0111);
3499 ibmcam_model2_Packet1(uvd
, 0x0030, 0x0002);
3501 ibmcam_veio(uvd
, 0, 0x0020, 0x0111);
3502 ibmcam_veio(uvd
, 0, 0x0000, 0x0112);
3504 case IBMCAM_MODEL_3
:
3506 ibmcam_veio(uvd
, 0, 0x0000, 0x010c);
3508 /* Here we are supposed to select video interface alt. setting 0 */
3509 ibmcam_veio(uvd
, 0, 0x0006, 0x012c);
3511 ibmcam_model3_Packet1(uvd
, 0x0046, 0x0000);
3513 ibmcam_veio(uvd
, 1, 0x0000, 0x0116);
3514 ibmcam_veio(uvd
, 0, 0x0064, 0x0116);
3515 ibmcam_veio(uvd
, 1, 0x0000, 0x0115);
3516 ibmcam_veio(uvd
, 0, 0x0003, 0x0115);
3517 ibmcam_veio(uvd
, 0, 0x0008, 0x0123);
3518 ibmcam_veio(uvd
, 0, 0x0000, 0x0117);
3519 ibmcam_veio(uvd
, 0, 0x0000, 0x0112);
3520 ibmcam_veio(uvd
, 0, 0x0080, 0x0100);
3521 IBMCAM_T(uvd
)->initialized
= 0;
3528 * ibmcam_reinit_iso()
3530 * This procedure sends couple of commands to the camera and then
3531 * resets the video pipe. This sequence was observed to reinit the
3532 * camera or, at least, to initiate ISO data stream.
3537 static void ibmcam_reinit_iso(struct uvd
*uvd
, int do_stop
)
3539 switch (IBMCAM_T(uvd
)->camera_model
) {
3540 case IBMCAM_MODEL_1
:
3542 ibmcam_video_stop(uvd
);
3543 ibmcam_veio(uvd
, 0, 0x0001, 0x0114);
3544 ibmcam_veio(uvd
, 0, 0x00c0, 0x010c);
3545 usb_clear_halt(uvd
->dev
, usb_rcvisocpipe(uvd
->dev
, uvd
->video_endp
));
3546 ibmcam_model1_setup_after_video_if(uvd
);
3548 case IBMCAM_MODEL_2
:
3549 ibmcam_model2_setup_after_video_if(uvd
);
3551 case IBMCAM_MODEL_3
:
3552 ibmcam_video_stop(uvd
);
3553 ibmcam_model3_setup_after_video_if(uvd
);
3555 case IBMCAM_MODEL_4
:
3556 ibmcam_model4_setup_after_video_if(uvd
);
3561 static void ibmcam_video_start(struct uvd
*uvd
)
3563 ibmcam_change_lighting_conditions(uvd
);
3564 ibmcam_set_sharpness(uvd
);
3565 ibmcam_reinit_iso(uvd
, 0);
3569 * Return negative code on failure, 0 on success.
3571 static int ibmcam_setup_on_open(struct uvd
*uvd
)
3573 int setup_ok
= 0; /* Success by default */
3574 /* Send init sequence only once, it's large! */
3575 if (!IBMCAM_T(uvd
)->initialized
) { /* FIXME rename */
3576 switch (IBMCAM_T(uvd
)->camera_model
) {
3577 case IBMCAM_MODEL_1
:
3578 setup_ok
= ibmcam_model1_setup(uvd
);
3580 case IBMCAM_MODEL_2
:
3581 setup_ok
= ibmcam_model2_setup(uvd
);
3583 case IBMCAM_MODEL_3
:
3584 case IBMCAM_MODEL_4
:
3585 /* We do all setup when Isoc stream is requested */
3588 IBMCAM_T(uvd
)->initialized
= (setup_ok
!= 0);
3593 static void ibmcam_configure_video(struct uvd
*uvd
)
3598 RESTRICT_TO_RANGE(init_brightness
, 0, 255);
3599 RESTRICT_TO_RANGE(init_contrast
, 0, 255);
3600 RESTRICT_TO_RANGE(init_color
, 0, 255);
3601 RESTRICT_TO_RANGE(init_hue
, 0, 255);
3602 RESTRICT_TO_RANGE(hue_correction
, 0, 255);
3604 memset(&uvd
->vpic
, 0, sizeof(uvd
->vpic
));
3605 memset(&uvd
->vpic_old
, 0x55, sizeof(uvd
->vpic_old
));
3607 uvd
->vpic
.colour
= init_color
<< 8;
3608 uvd
->vpic
.hue
= init_hue
<< 8;
3609 uvd
->vpic
.brightness
= init_brightness
<< 8;
3610 uvd
->vpic
.contrast
= init_contrast
<< 8;
3611 uvd
->vpic
.whiteness
= 105 << 8; /* This one isn't used */
3612 uvd
->vpic
.depth
= 24;
3613 uvd
->vpic
.palette
= VIDEO_PALETTE_RGB24
;
3615 memset(&uvd
->vcap
, 0, sizeof(uvd
->vcap
));
3616 strcpy(uvd
->vcap
.name
, "IBM USB Camera");
3617 uvd
->vcap
.type
= VID_TYPE_CAPTURE
;
3618 uvd
->vcap
.channels
= 1;
3619 uvd
->vcap
.audios
= 0;
3620 uvd
->vcap
.maxwidth
= VIDEOSIZE_X(uvd
->canvas
);
3621 uvd
->vcap
.maxheight
= VIDEOSIZE_Y(uvd
->canvas
);
3622 uvd
->vcap
.minwidth
= min_canvasWidth
;
3623 uvd
->vcap
.minheight
= min_canvasHeight
;
3625 memset(&uvd
->vchan
, 0, sizeof(uvd
->vchan
));
3626 uvd
->vchan
.flags
= 0;
3627 uvd
->vchan
.tuners
= 0;
3628 uvd
->vchan
.channel
= 0;
3629 uvd
->vchan
.type
= VIDEO_TYPE_CAMERA
;
3630 strcpy(uvd
->vchan
.name
, "Camera");
3636 * This procedure queries device descriptor and accepts the interface
3637 * if it looks like IBM C-it camera.
3640 * 22-Jan-2000 Moved camera init code to ibmcam_open()
3641 * 27=Jan-2000 Changed to use static structures, added locking.
3642 * 24-May-2000 Corrected to prevent race condition (MOD_xxx_USE_COUNT).
3643 * 03-Jul-2000 Fixed endianness bug.
3644 * 12-Nov-2000 Reworked to comply with new probe() signature.
3645 * 23-Jan-2001 Added compatibility with 2.2.x kernels.
3647 static int ibmcam_probe(struct usb_interface
*intf
, const struct usb_device_id
*devid
)
3649 struct usb_device
*dev
= interface_to_usbdev(intf
);
3650 struct uvd
*uvd
= NULL
;
3651 int ix
, i
, nas
, model
=0, canvasX
=0, canvasY
=0;
3652 int actInterface
=-1, inactInterface
=-1, maxPS
=0;
3653 __u8 ifnum
= intf
->altsetting
->desc
.bInterfaceNumber
;
3654 unsigned char video_ep
= 0;
3657 info("ibmcam_probe(%p,%u.)", intf
, ifnum
);
3659 /* We don't handle multi-config cameras */
3660 if (dev
->descriptor
.bNumConfigurations
!= 1)
3663 /* Check the version/revision */
3664 switch (le16_to_cpu(dev
->descriptor
.bcdDevice
)) {
3668 model
= IBMCAM_MODEL_1
;
3673 if ((le16_to_cpu(dev
->descriptor
.idProduct
) == NETCAM_PRODUCT_ID
) ||
3674 (le16_to_cpu(dev
->descriptor
.idProduct
) == VEO_800D_PRODUCT_ID
))
3675 model
= IBMCAM_MODEL_4
;
3677 model
= IBMCAM_MODEL_2
;
3682 model
= IBMCAM_MODEL_3
;
3685 err("IBM camera with revision 0x%04x is not supported.",
3686 le16_to_cpu(dev
->descriptor
.bcdDevice
));
3690 /* Print detailed info on what we found so far */
3693 switch (le16_to_cpu(dev
->descriptor
.idProduct
)) {
3694 case NETCAM_PRODUCT_ID
:
3695 brand
= "IBM NetCamera";
3697 case VEO_800C_PRODUCT_ID
:
3698 brand
= "Veo Stingray [800C]";
3700 case VEO_800D_PRODUCT_ID
:
3701 brand
= "Veo Stingray [800D]";
3703 case IBMCAM_PRODUCT_ID
:
3705 brand
= "IBM PC Camera"; /* a.k.a. Xirlink C-It */
3708 info("%s USB camera found (model %d, rev. 0x%04x)",
3709 brand
, model
, le16_to_cpu(dev
->descriptor
.bcdDevice
));
3712 /* Validate found interface: must have one ISO endpoint */
3713 nas
= intf
->num_altsetting
;
3715 info("Number of alternate settings=%d.", nas
);
3717 err("Too few alternate settings for this camera!");
3720 /* Validate all alternate settings */
3721 for (ix
=0; ix
< nas
; ix
++) {
3722 const struct usb_host_interface
*interface
;
3723 const struct usb_endpoint_descriptor
*endpoint
;
3725 interface
= &intf
->altsetting
[ix
];
3726 i
= interface
->desc
.bAlternateSetting
;
3727 if (interface
->desc
.bNumEndpoints
!= 1) {
3728 err("Interface %d. has %u. endpoints!",
3729 ifnum
, (unsigned)(interface
->desc
.bNumEndpoints
));
3732 endpoint
= &interface
->endpoint
[0].desc
;
3734 video_ep
= endpoint
->bEndpointAddress
;
3735 else if (video_ep
!= endpoint
->bEndpointAddress
) {
3736 err("Alternate settings have different endpoint addresses!");
3739 if ((endpoint
->bmAttributes
& 0x03) != 0x01) {
3740 err("Interface %d. has non-ISO endpoint!", ifnum
);
3743 if ((endpoint
->bEndpointAddress
& 0x80) == 0) {
3744 err("Interface %d. has ISO OUT endpoint!", ifnum
);
3747 if (le16_to_cpu(endpoint
->wMaxPacketSize
) == 0) {
3748 if (inactInterface
< 0)
3751 err("More than one inactive alt. setting!");
3755 if (actInterface
< 0) {
3757 maxPS
= le16_to_cpu(endpoint
->wMaxPacketSize
);
3759 info("Active setting=%d. maxPS=%d.", i
, maxPS
);
3761 err("More than one active alt. setting! Ignoring #%d.", i
);
3764 if ((maxPS
<= 0) || (actInterface
< 0) || (inactInterface
< 0)) {
3765 err("Failed to recognize the camera!");
3769 /* Validate options */
3771 case IBMCAM_MODEL_1
:
3772 RESTRICT_TO_RANGE(lighting
, 0, 2);
3773 RESTRICT_TO_RANGE(size
, SIZE_128x96
, SIZE_352x288
);
3779 case IBMCAM_MODEL_2
:
3780 RESTRICT_TO_RANGE(lighting
, 0, 15);
3781 RESTRICT_TO_RANGE(size
, SIZE_176x144
, SIZE_352x240
);
3787 case IBMCAM_MODEL_3
:
3788 RESTRICT_TO_RANGE(lighting
, 0, 15); /* FIXME */
3795 RESTRICT_TO_RANGE(framerate
, 0, 5);
3798 info("IBM camera: using 320x240");
3799 size
= SIZE_320x240
;
3806 RESTRICT_TO_RANGE(framerate
, 0, 5);
3811 framerate
= 0; /* Slowest, and maybe even that is too fast */
3815 case IBMCAM_MODEL_4
:
3816 RESTRICT_TO_RANGE(lighting
, 0, 2);
3827 info("IBM NetCamera: using 176x144");
3828 size
= SIZE_176x144
;
3845 err("IBM camera: Model %d. not supported!", model
);
3849 uvd
= usbvideo_AllocateDevice(cams
);
3851 /* Here uvd is a fully allocated uvd object */
3856 uvd
->ifaceAltInactive
= inactInterface
;
3857 uvd
->ifaceAltActive
= actInterface
;
3858 uvd
->video_endp
= video_ep
;
3859 uvd
->iso_packet_len
= maxPS
;
3860 uvd
->paletteBits
= 1L << VIDEO_PALETTE_RGB24
;
3861 uvd
->defaultPalette
= VIDEO_PALETTE_RGB24
;
3862 uvd
->canvas
= VIDEOSIZE(canvasX
, canvasY
);
3863 uvd
->videosize
= ibmcam_size_to_videosize(size
);
3865 /* Initialize ibmcam-specific data */
3866 assert(IBMCAM_T(uvd
) != NULL
);
3867 IBMCAM_T(uvd
)->camera_model
= model
;
3868 IBMCAM_T(uvd
)->initialized
= 0;
3870 ibmcam_configure_video(uvd
);
3872 i
= usbvideo_RegisterVideoDevice(uvd
);
3874 err("usbvideo_RegisterVideoDevice() failed.");
3878 usb_set_intfdata (intf
, uvd
);
3883 static struct usb_device_id id_table
[] = {
3884 { USB_DEVICE_VER(IBMCAM_VENDOR_ID
, IBMCAM_PRODUCT_ID
, 0x0002, 0x0002) }, /* Model 1 */
3885 { USB_DEVICE_VER(IBMCAM_VENDOR_ID
, IBMCAM_PRODUCT_ID
, 0x030a, 0x030a) }, /* Model 2 */
3886 { USB_DEVICE_VER(IBMCAM_VENDOR_ID
, IBMCAM_PRODUCT_ID
, 0x0301, 0x0301) }, /* Model 3 */
3887 { USB_DEVICE_VER(IBMCAM_VENDOR_ID
, NETCAM_PRODUCT_ID
, 0x030a, 0x030a) }, /* Model 4 */
3888 { USB_DEVICE_VER(IBMCAM_VENDOR_ID
, VEO_800C_PRODUCT_ID
, 0x030a, 0x030a) }, /* Model 2 */
3889 { USB_DEVICE_VER(IBMCAM_VENDOR_ID
, VEO_800D_PRODUCT_ID
, 0x030a, 0x030a) }, /* Model 4 */
3890 { } /* Terminating entry */
3896 * This code is run to initialize the driver.
3899 * 1/27/00 Reworked to use statically allocated ibmcam structures.
3900 * 21/10/00 Completely redesigned to use usbvideo services.
3902 static int __init
ibmcam_init(void)
3904 struct usbvideo_cb cbTbl
;
3905 memset(&cbTbl
, 0, sizeof(cbTbl
));
3906 cbTbl
.probe
= ibmcam_probe
;
3907 cbTbl
.setupOnOpen
= ibmcam_setup_on_open
;
3908 cbTbl
.videoStart
= ibmcam_video_start
;
3909 cbTbl
.videoStop
= ibmcam_video_stop
;
3910 cbTbl
.processData
= ibmcam_ProcessIsocData
;
3911 cbTbl
.postProcess
= usbvideo_DeinterlaceFrame
;
3912 cbTbl
.adjustPicture
= ibmcam_adjust_picture
;
3913 cbTbl
.getFPS
= ibmcam_calculate_fps
;
3914 return usbvideo_register(
3924 static void __exit
ibmcam_cleanup(void)
3926 usbvideo_Deregister(&cams
);
3929 MODULE_DEVICE_TABLE(usb
, id_table
);
3931 module_init(ibmcam_init
);
3932 module_exit(ibmcam_cleanup
);