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 * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com>
9 * This driver is based on earlier work of:
11 * (C) Copyright 1999 Johannes Erdfelt
12 * (C) Copyright 1999 Randy Dunlap
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #define MODULE_NAME "xirlink-cit"
32 #include <linux/input.h>
35 MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
36 MODULE_DESCRIPTION("Xirlink C-IT");
37 MODULE_LICENSE("GPL");
39 /* FIXME we should autodetect this */
40 static int ibm_netcam_pro
;
41 module_param(ibm_netcam_pro
, int, 0);
42 MODULE_PARM_DESC(ibm_netcam_pro
,
43 "Use IBM Netcamera Pro init sequences for Model 3 cams");
45 /* FIXME this should be handled through the V4L2 input selection API */
47 module_param(rca_input
, int, 0644);
48 MODULE_PARM_DESC(rca_input
,
49 "Use rca input instead of ccd sensor on Model 3 cams");
51 /* specific webcam descriptor */
53 struct gspca_dev gspca_dev
; /* !! must be the first item */
55 #define CIT_MODEL0 0 /* bcd version 0.01 cams ie the xvp-500 */
56 #define CIT_MODEL1 1 /* The model 1 - 4 nomenclature comes from the old */
57 #define CIT_MODEL2 2 /* ibmcam driver */
60 #define CIT_IBM_NETCAM_PRO 5
63 u8 stop_on_control_change
;
74 /* V4L2 controls supported by the driver */
75 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
);
76 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
);
77 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
);
78 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
);
79 static int sd_sethue(struct gspca_dev
*gspca_dev
, __s32 val
);
80 static int sd_gethue(struct gspca_dev
*gspca_dev
, __s32
*val
);
81 static int sd_setsharpness(struct gspca_dev
*gspca_dev
, __s32 val
);
82 static int sd_getsharpness(struct gspca_dev
*gspca_dev
, __s32
*val
);
83 static int sd_setlighting(struct gspca_dev
*gspca_dev
, __s32 val
);
84 static int sd_getlighting(struct gspca_dev
*gspca_dev
, __s32
*val
);
85 static int sd_sethflip(struct gspca_dev
*gspca_dev
, __s32 val
);
86 static int sd_gethflip(struct gspca_dev
*gspca_dev
, __s32
*val
);
87 static void sd_stop0(struct gspca_dev
*gspca_dev
);
89 static const struct ctrl sd_ctrls
[] = {
90 #define SD_BRIGHTNESS 0
93 .id
= V4L2_CID_BRIGHTNESS
,
94 .type
= V4L2_CTRL_TYPE_INTEGER
,
99 #define BRIGHTNESS_DEFAULT 32
100 .default_value
= BRIGHTNESS_DEFAULT
,
103 .set
= sd_setbrightness
,
104 .get
= sd_getbrightness
,
106 #define SD_CONTRAST 1
109 .id
= V4L2_CID_CONTRAST
,
110 .type
= V4L2_CTRL_TYPE_INTEGER
,
115 #define CONTRAST_DEFAULT 10
116 .default_value
= CONTRAST_DEFAULT
,
119 .set
= sd_setcontrast
,
120 .get
= sd_getcontrast
,
126 .type
= V4L2_CTRL_TYPE_INTEGER
,
131 #define HUE_DEFAULT 63
132 .default_value
= HUE_DEFAULT
,
138 #define SD_SHARPNESS 3
141 .id
= V4L2_CID_SHARPNESS
,
142 .type
= V4L2_CTRL_TYPE_INTEGER
,
147 #define SHARPNESS_DEFAULT 3
148 .default_value
= SHARPNESS_DEFAULT
,
151 .set
= sd_setsharpness
,
152 .get
= sd_getsharpness
,
154 #define SD_LIGHTING 4
157 .id
= V4L2_CID_BACKLIGHT_COMPENSATION
,
158 .type
= V4L2_CTRL_TYPE_INTEGER
,
163 #define LIGHTING_DEFAULT 1
164 .default_value
= LIGHTING_DEFAULT
,
167 .set
= sd_setlighting
,
168 .get
= sd_getlighting
,
173 .id
= V4L2_CID_HFLIP
,
174 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
179 #define HFLIP_DEFAULT 0
180 .default_value
= HFLIP_DEFAULT
,
187 static const struct v4l2_pix_format cif_yuv_mode
[] = {
188 {176, 144, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
190 .sizeimage
= 176 * 144 * 3 / 2 + 4,
191 .colorspace
= V4L2_COLORSPACE_SRGB
},
192 {352, 288, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
194 .sizeimage
= 352 * 288 * 3 / 2 + 4,
195 .colorspace
= V4L2_COLORSPACE_SRGB
},
198 static const struct v4l2_pix_format vga_yuv_mode
[] = {
199 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
201 .sizeimage
= 160 * 120 * 3 / 2 + 4,
202 .colorspace
= V4L2_COLORSPACE_SRGB
},
203 {320, 240, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
205 .sizeimage
= 320 * 240 * 3 / 2 + 4,
206 .colorspace
= V4L2_COLORSPACE_SRGB
},
207 {640, 480, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
209 .sizeimage
= 640 * 480 * 3 / 2 + 4,
210 .colorspace
= V4L2_COLORSPACE_SRGB
},
213 static const struct v4l2_pix_format model0_mode
[] = {
214 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
216 .sizeimage
= 160 * 120 * 3 / 2 + 4,
217 .colorspace
= V4L2_COLORSPACE_SRGB
},
218 {176, 144, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
220 .sizeimage
= 176 * 144 * 3 / 2 + 4,
221 .colorspace
= V4L2_COLORSPACE_SRGB
},
222 {320, 240, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
224 .sizeimage
= 320 * 240 * 3 / 2 + 4,
225 .colorspace
= V4L2_COLORSPACE_SRGB
},
228 static const struct v4l2_pix_format model2_mode
[] = {
229 {160, 120, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
231 .sizeimage
= 160 * 120 * 3 / 2 + 4,
232 .colorspace
= V4L2_COLORSPACE_SRGB
},
233 {176, 144, V4L2_PIX_FMT_CIT_YYVYUY
, V4L2_FIELD_NONE
,
235 .sizeimage
= 176 * 144 * 3 / 2 + 4,
236 .colorspace
= V4L2_COLORSPACE_SRGB
},
237 {320, 240, V4L2_PIX_FMT_SGRBG8
, V4L2_FIELD_NONE
,
239 .sizeimage
= 320 * 240 + 4,
240 .colorspace
= V4L2_COLORSPACE_SRGB
},
241 {352, 288, V4L2_PIX_FMT_SGRBG8
, V4L2_FIELD_NONE
,
243 .sizeimage
= 352 * 288 + 4,
244 .colorspace
= V4L2_COLORSPACE_SRGB
},
248 * 01.01.08 - Added for RCA video in support -LO
249 * This struct is used to init the Model3 cam to use the RCA video in port
250 * instead of the CCD sensor.
252 static const u16 rca_initdata
[][3] = {
789 /* TESTME the old ibmcam driver repeats certain commands to Model1 cameras, we
790 do the same for now (testing needed to see if this is really necessary) */
791 static const int cit_model1_ntries
= 5;
792 static const int cit_model1_ntries2
= 2;
794 static int cit_write_reg(struct gspca_dev
*gspca_dev
, u16 value
, u16 index
)
796 struct usb_device
*udev
= gspca_dev
->dev
;
799 err
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0), 0x00,
800 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_ENDPOINT
,
801 value
, index
, NULL
, 0, 1000);
803 err("Failed to write a register (index 0x%04X,"
804 " value 0x%02X, error %d)", index
, value
, err
);
809 static int cit_read_reg(struct gspca_dev
*gspca_dev
, u16 index
, int verbose
)
811 struct usb_device
*udev
= gspca_dev
->dev
;
812 __u8
*buf
= gspca_dev
->usb_buf
;
815 res
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0), 0x01,
816 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_ENDPOINT
,
817 0x00, index
, buf
, 8, 1000);
819 err("Failed to read a register (index 0x%04X, error %d)",
825 PDEBUG(D_PROBE
, "Register %04x value: %02x", index
, buf
[0]);
831 * cit_send_FF_04_02()
833 * This procedure sends magic 3-command prefix to the camera.
834 * The purpose of this prefix is not known.
839 static void cit_send_FF_04_02(struct gspca_dev
*gspca_dev
)
841 cit_write_reg(gspca_dev
, 0x00FF, 0x0127);
842 cit_write_reg(gspca_dev
, 0x0004, 0x0124);
843 cit_write_reg(gspca_dev
, 0x0002, 0x0124);
846 static void cit_send_00_04_06(struct gspca_dev
*gspca_dev
)
848 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
849 cit_write_reg(gspca_dev
, 0x0004, 0x0124);
850 cit_write_reg(gspca_dev
, 0x0006, 0x0124);
853 static void cit_send_x_00(struct gspca_dev
*gspca_dev
, unsigned short x
)
855 cit_write_reg(gspca_dev
, x
, 0x0127);
856 cit_write_reg(gspca_dev
, 0x0000, 0x0124);
859 static void cit_send_x_00_05(struct gspca_dev
*gspca_dev
, unsigned short x
)
861 cit_send_x_00(gspca_dev
, x
);
862 cit_write_reg(gspca_dev
, 0x0005, 0x0124);
865 static void cit_send_x_00_05_02(struct gspca_dev
*gspca_dev
, unsigned short x
)
867 cit_write_reg(gspca_dev
, x
, 0x0127);
868 cit_write_reg(gspca_dev
, 0x0000, 0x0124);
869 cit_write_reg(gspca_dev
, 0x0005, 0x0124);
870 cit_write_reg(gspca_dev
, 0x0002, 0x0124);
873 static void cit_send_x_01_00_05(struct gspca_dev
*gspca_dev
, u16 x
)
875 cit_write_reg(gspca_dev
, x
, 0x0127);
876 cit_write_reg(gspca_dev
, 0x0001, 0x0124);
877 cit_write_reg(gspca_dev
, 0x0000, 0x0124);
878 cit_write_reg(gspca_dev
, 0x0005, 0x0124);
881 static void cit_send_x_00_05_02_01(struct gspca_dev
*gspca_dev
, u16 x
)
883 cit_write_reg(gspca_dev
, x
, 0x0127);
884 cit_write_reg(gspca_dev
, 0x0000, 0x0124);
885 cit_write_reg(gspca_dev
, 0x0005, 0x0124);
886 cit_write_reg(gspca_dev
, 0x0002, 0x0124);
887 cit_write_reg(gspca_dev
, 0x0001, 0x0124);
890 static void cit_send_x_00_05_02_08_01(struct gspca_dev
*gspca_dev
, u16 x
)
892 cit_write_reg(gspca_dev
, x
, 0x0127);
893 cit_write_reg(gspca_dev
, 0x0000, 0x0124);
894 cit_write_reg(gspca_dev
, 0x0005, 0x0124);
895 cit_write_reg(gspca_dev
, 0x0002, 0x0124);
896 cit_write_reg(gspca_dev
, 0x0008, 0x0124);
897 cit_write_reg(gspca_dev
, 0x0001, 0x0124);
900 static void cit_Packet_Format1(struct gspca_dev
*gspca_dev
, u16 fkey
, u16 val
)
902 cit_send_x_01_00_05(gspca_dev
, 0x0088);
903 cit_send_x_00_05(gspca_dev
, fkey
);
904 cit_send_x_00_05_02_08_01(gspca_dev
, val
);
905 cit_send_x_00_05(gspca_dev
, 0x0088);
906 cit_send_x_00_05_02_01(gspca_dev
, fkey
);
907 cit_send_x_00_05(gspca_dev
, 0x0089);
908 cit_send_x_00(gspca_dev
, fkey
);
909 cit_send_00_04_06(gspca_dev
);
910 cit_read_reg(gspca_dev
, 0x0126, 0);
911 cit_send_FF_04_02(gspca_dev
);
914 static void cit_PacketFormat2(struct gspca_dev
*gspca_dev
, u16 fkey
, u16 val
)
916 cit_send_x_01_00_05(gspca_dev
, 0x0088);
917 cit_send_x_00_05(gspca_dev
, fkey
);
918 cit_send_x_00_05_02(gspca_dev
, val
);
921 static void cit_model2_Packet2(struct gspca_dev
*gspca_dev
)
923 cit_write_reg(gspca_dev
, 0x00ff, 0x012d);
924 cit_write_reg(gspca_dev
, 0xfea3, 0x0124);
927 static void cit_model2_Packet1(struct gspca_dev
*gspca_dev
, u16 v1
, u16 v2
)
929 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
930 cit_write_reg(gspca_dev
, 0x00ff, 0x012e);
931 cit_write_reg(gspca_dev
, v1
, 0x012f);
932 cit_write_reg(gspca_dev
, 0x00ff, 0x0130);
933 cit_write_reg(gspca_dev
, 0xc719, 0x0124);
934 cit_write_reg(gspca_dev
, v2
, 0x0127);
936 cit_model2_Packet2(gspca_dev
);
940 * cit_model3_Packet1()
948 static void cit_model3_Packet1(struct gspca_dev
*gspca_dev
, u16 v1
, u16 v2
)
950 cit_write_reg(gspca_dev
, 0x0078, 0x012d);
951 cit_write_reg(gspca_dev
, v1
, 0x012f);
952 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
953 cit_write_reg(gspca_dev
, v2
, 0x0127);
954 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
957 static void cit_model4_Packet1(struct gspca_dev
*gspca_dev
, u16 v1
, u16 v2
)
959 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
960 cit_write_reg(gspca_dev
, v1
, 0x012f);
961 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
962 cit_write_reg(gspca_dev
, v2
, 0x0127);
963 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
966 static void cit_model4_BrightnessPacket(struct gspca_dev
*gspca_dev
, u16 val
)
968 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
969 cit_write_reg(gspca_dev
, 0x0026, 0x012f);
970 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
971 cit_write_reg(gspca_dev
, val
, 0x0127);
972 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
973 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
974 cit_write_reg(gspca_dev
, 0x0038, 0x012d);
975 cit_write_reg(gspca_dev
, 0x0004, 0x012f);
976 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
977 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
980 /* this function is called at probe time */
981 static int sd_config(struct gspca_dev
*gspca_dev
,
982 const struct usb_device_id
*id
)
984 struct sd
*sd
= (struct sd
*) gspca_dev
;
987 sd
->model
= id
->driver_info
;
988 if (sd
->model
== CIT_MODEL3
&& ibm_netcam_pro
)
989 sd
->model
= CIT_IBM_NETCAM_PRO
;
991 cam
= &gspca_dev
->cam
;
994 cam
->cam_mode
= model0_mode
;
995 cam
->nmodes
= ARRAY_SIZE(model0_mode
);
996 cam
->reverse_alts
= 1;
997 gspca_dev
->ctrl_dis
= ~((1 << SD_CONTRAST
) | (1 << SD_HFLIP
));
1001 cam
->cam_mode
= cif_yuv_mode
;
1002 cam
->nmodes
= ARRAY_SIZE(cif_yuv_mode
);
1003 cam
->reverse_alts
= 1;
1004 gspca_dev
->ctrl_dis
= (1 << SD_HUE
) | (1 << SD_HFLIP
);
1008 cam
->cam_mode
= model2_mode
+ 1; /* no 160x120 */
1010 gspca_dev
->ctrl_dis
= (1 << SD_CONTRAST
) |
1011 (1 << SD_SHARPNESS
) |
1015 cam
->cam_mode
= vga_yuv_mode
;
1016 cam
->nmodes
= ARRAY_SIZE(vga_yuv_mode
);
1017 gspca_dev
->ctrl_dis
= (1 << SD_HUE
) |
1018 (1 << SD_LIGHTING
) |
1020 sd
->stop_on_control_change
= 1;
1024 cam
->cam_mode
= model2_mode
;
1025 cam
->nmodes
= ARRAY_SIZE(model2_mode
);
1026 gspca_dev
->ctrl_dis
= (1 << SD_CONTRAST
) |
1027 (1 << SD_SHARPNESS
) |
1028 (1 << SD_LIGHTING
) |
1031 case CIT_IBM_NETCAM_PRO
:
1032 cam
->cam_mode
= vga_yuv_mode
;
1033 cam
->nmodes
= 2; /* no 640 x 480 */
1034 cam
->input_flags
= V4L2_IN_ST_VFLIP
;
1035 gspca_dev
->ctrl_dis
= ~(1 << SD_CONTRAST
);
1036 sd
->stop_on_control_change
= 1;
1041 sd
->brightness
= BRIGHTNESS_DEFAULT
;
1042 sd
->contrast
= CONTRAST_DEFAULT
;
1043 sd
->hue
= HUE_DEFAULT
;
1044 sd
->sharpness
= SHARPNESS_DEFAULT
;
1045 sd
->lighting
= LIGHTING_DEFAULT
;
1046 sd
->hflip
= HFLIP_DEFAULT
;
1051 static int cit_init_model0(struct gspca_dev
*gspca_dev
)
1053 cit_write_reg(gspca_dev
, 0x0000, 0x0100); /* turn on led */
1054 cit_write_reg(gspca_dev
, 0x0001, 0x0112); /* turn on autogain ? */
1055 cit_write_reg(gspca_dev
, 0x0000, 0x0400);
1056 cit_write_reg(gspca_dev
, 0x0001, 0x0400);
1057 cit_write_reg(gspca_dev
, 0x0000, 0x0420);
1058 cit_write_reg(gspca_dev
, 0x0001, 0x0420);
1059 cit_write_reg(gspca_dev
, 0x000d, 0x0409);
1060 cit_write_reg(gspca_dev
, 0x0002, 0x040a);
1061 cit_write_reg(gspca_dev
, 0x0018, 0x0405);
1062 cit_write_reg(gspca_dev
, 0x0008, 0x0435);
1063 cit_write_reg(gspca_dev
, 0x0026, 0x040b);
1064 cit_write_reg(gspca_dev
, 0x0007, 0x0437);
1065 cit_write_reg(gspca_dev
, 0x0015, 0x042f);
1066 cit_write_reg(gspca_dev
, 0x002b, 0x0439);
1067 cit_write_reg(gspca_dev
, 0x0026, 0x043a);
1068 cit_write_reg(gspca_dev
, 0x0008, 0x0438);
1069 cit_write_reg(gspca_dev
, 0x001e, 0x042b);
1070 cit_write_reg(gspca_dev
, 0x0041, 0x042c);
1075 static int cit_init_ibm_netcam_pro(struct gspca_dev
*gspca_dev
)
1077 cit_read_reg(gspca_dev
, 0x128, 1);
1078 cit_write_reg(gspca_dev
, 0x0003, 0x0133);
1079 cit_write_reg(gspca_dev
, 0x0000, 0x0117);
1080 cit_write_reg(gspca_dev
, 0x0008, 0x0123);
1081 cit_write_reg(gspca_dev
, 0x0000, 0x0100);
1082 cit_read_reg(gspca_dev
, 0x0116, 0);
1083 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
1084 cit_write_reg(gspca_dev
, 0x0002, 0x0112);
1085 cit_write_reg(gspca_dev
, 0x0000, 0x0133);
1086 cit_write_reg(gspca_dev
, 0x0000, 0x0123);
1087 cit_write_reg(gspca_dev
, 0x0001, 0x0117);
1088 cit_write_reg(gspca_dev
, 0x0040, 0x0108);
1089 cit_write_reg(gspca_dev
, 0x0019, 0x012c);
1090 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
1091 cit_write_reg(gspca_dev
, 0x0002, 0x0115);
1092 cit_write_reg(gspca_dev
, 0x000b, 0x0115);
1094 cit_write_reg(gspca_dev
, 0x0078, 0x012d);
1095 cit_write_reg(gspca_dev
, 0x0001, 0x012f);
1096 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
1097 cit_write_reg(gspca_dev
, 0x0079, 0x012d);
1098 cit_write_reg(gspca_dev
, 0x00ff, 0x0130);
1099 cit_write_reg(gspca_dev
, 0xcd41, 0x0124);
1100 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
1101 cit_read_reg(gspca_dev
, 0x0126, 1);
1103 cit_model3_Packet1(gspca_dev
, 0x0000, 0x0000);
1104 cit_model3_Packet1(gspca_dev
, 0x0000, 0x0001);
1105 cit_model3_Packet1(gspca_dev
, 0x000b, 0x0000);
1106 cit_model3_Packet1(gspca_dev
, 0x000c, 0x0008);
1107 cit_model3_Packet1(gspca_dev
, 0x000d, 0x003a);
1108 cit_model3_Packet1(gspca_dev
, 0x000e, 0x0060);
1109 cit_model3_Packet1(gspca_dev
, 0x000f, 0x0060);
1110 cit_model3_Packet1(gspca_dev
, 0x0010, 0x0008);
1111 cit_model3_Packet1(gspca_dev
, 0x0011, 0x0004);
1112 cit_model3_Packet1(gspca_dev
, 0x0012, 0x0028);
1113 cit_model3_Packet1(gspca_dev
, 0x0013, 0x0002);
1114 cit_model3_Packet1(gspca_dev
, 0x0014, 0x0000);
1115 cit_model3_Packet1(gspca_dev
, 0x0015, 0x00fb);
1116 cit_model3_Packet1(gspca_dev
, 0x0016, 0x0002);
1117 cit_model3_Packet1(gspca_dev
, 0x0017, 0x0037);
1118 cit_model3_Packet1(gspca_dev
, 0x0018, 0x0036);
1119 cit_model3_Packet1(gspca_dev
, 0x001e, 0x0000);
1120 cit_model3_Packet1(gspca_dev
, 0x001f, 0x0008);
1121 cit_model3_Packet1(gspca_dev
, 0x0020, 0x00c1);
1122 cit_model3_Packet1(gspca_dev
, 0x0021, 0x0034);
1123 cit_model3_Packet1(gspca_dev
, 0x0022, 0x0034);
1124 cit_model3_Packet1(gspca_dev
, 0x0025, 0x0002);
1125 cit_model3_Packet1(gspca_dev
, 0x0028, 0x0022);
1126 cit_model3_Packet1(gspca_dev
, 0x0029, 0x000a);
1127 cit_model3_Packet1(gspca_dev
, 0x002b, 0x0000);
1128 cit_model3_Packet1(gspca_dev
, 0x002c, 0x0000);
1129 cit_model3_Packet1(gspca_dev
, 0x002d, 0x00ff);
1130 cit_model3_Packet1(gspca_dev
, 0x002e, 0x00ff);
1131 cit_model3_Packet1(gspca_dev
, 0x002f, 0x00ff);
1132 cit_model3_Packet1(gspca_dev
, 0x0030, 0x00ff);
1133 cit_model3_Packet1(gspca_dev
, 0x0031, 0x00ff);
1134 cit_model3_Packet1(gspca_dev
, 0x0032, 0x0007);
1135 cit_model3_Packet1(gspca_dev
, 0x0033, 0x0005);
1136 cit_model3_Packet1(gspca_dev
, 0x0037, 0x0040);
1137 cit_model3_Packet1(gspca_dev
, 0x0039, 0x0000);
1138 cit_model3_Packet1(gspca_dev
, 0x003a, 0x0000);
1139 cit_model3_Packet1(gspca_dev
, 0x003b, 0x0001);
1140 cit_model3_Packet1(gspca_dev
, 0x003c, 0x0000);
1141 cit_model3_Packet1(gspca_dev
, 0x0040, 0x000c);
1142 cit_model3_Packet1(gspca_dev
, 0x0041, 0x00fb);
1143 cit_model3_Packet1(gspca_dev
, 0x0042, 0x0002);
1144 cit_model3_Packet1(gspca_dev
, 0x0043, 0x0000);
1145 cit_model3_Packet1(gspca_dev
, 0x0045, 0x0000);
1146 cit_model3_Packet1(gspca_dev
, 0x0046, 0x0000);
1147 cit_model3_Packet1(gspca_dev
, 0x0047, 0x0000);
1148 cit_model3_Packet1(gspca_dev
, 0x0048, 0x0000);
1149 cit_model3_Packet1(gspca_dev
, 0x0049, 0x0000);
1150 cit_model3_Packet1(gspca_dev
, 0x004a, 0x00ff);
1151 cit_model3_Packet1(gspca_dev
, 0x004b, 0x00ff);
1152 cit_model3_Packet1(gspca_dev
, 0x004c, 0x00ff);
1153 cit_model3_Packet1(gspca_dev
, 0x004f, 0x0000);
1154 cit_model3_Packet1(gspca_dev
, 0x0050, 0x0000);
1155 cit_model3_Packet1(gspca_dev
, 0x0051, 0x0002);
1156 cit_model3_Packet1(gspca_dev
, 0x0055, 0x0000);
1157 cit_model3_Packet1(gspca_dev
, 0x0056, 0x0000);
1158 cit_model3_Packet1(gspca_dev
, 0x0057, 0x0000);
1159 cit_model3_Packet1(gspca_dev
, 0x0058, 0x0002);
1160 cit_model3_Packet1(gspca_dev
, 0x0059, 0x0000);
1161 cit_model3_Packet1(gspca_dev
, 0x005c, 0x0016);
1162 cit_model3_Packet1(gspca_dev
, 0x005d, 0x0022);
1163 cit_model3_Packet1(gspca_dev
, 0x005e, 0x003c);
1164 cit_model3_Packet1(gspca_dev
, 0x005f, 0x0050);
1165 cit_model3_Packet1(gspca_dev
, 0x0060, 0x0044);
1166 cit_model3_Packet1(gspca_dev
, 0x0061, 0x0005);
1167 cit_model3_Packet1(gspca_dev
, 0x006a, 0x007e);
1168 cit_model3_Packet1(gspca_dev
, 0x006f, 0x0000);
1169 cit_model3_Packet1(gspca_dev
, 0x0072, 0x001b);
1170 cit_model3_Packet1(gspca_dev
, 0x0073, 0x0005);
1171 cit_model3_Packet1(gspca_dev
, 0x0074, 0x000a);
1172 cit_model3_Packet1(gspca_dev
, 0x0075, 0x001b);
1173 cit_model3_Packet1(gspca_dev
, 0x0076, 0x002a);
1174 cit_model3_Packet1(gspca_dev
, 0x0077, 0x003c);
1175 cit_model3_Packet1(gspca_dev
, 0x0078, 0x0050);
1176 cit_model3_Packet1(gspca_dev
, 0x007b, 0x0000);
1177 cit_model3_Packet1(gspca_dev
, 0x007c, 0x0011);
1178 cit_model3_Packet1(gspca_dev
, 0x007d, 0x0024);
1179 cit_model3_Packet1(gspca_dev
, 0x007e, 0x0043);
1180 cit_model3_Packet1(gspca_dev
, 0x007f, 0x005a);
1181 cit_model3_Packet1(gspca_dev
, 0x0084, 0x0020);
1182 cit_model3_Packet1(gspca_dev
, 0x0085, 0x0033);
1183 cit_model3_Packet1(gspca_dev
, 0x0086, 0x000a);
1184 cit_model3_Packet1(gspca_dev
, 0x0087, 0x0030);
1185 cit_model3_Packet1(gspca_dev
, 0x0088, 0x0070);
1186 cit_model3_Packet1(gspca_dev
, 0x008b, 0x0008);
1187 cit_model3_Packet1(gspca_dev
, 0x008f, 0x0000);
1188 cit_model3_Packet1(gspca_dev
, 0x0090, 0x0006);
1189 cit_model3_Packet1(gspca_dev
, 0x0091, 0x0028);
1190 cit_model3_Packet1(gspca_dev
, 0x0092, 0x005a);
1191 cit_model3_Packet1(gspca_dev
, 0x0093, 0x0082);
1192 cit_model3_Packet1(gspca_dev
, 0x0096, 0x0014);
1193 cit_model3_Packet1(gspca_dev
, 0x0097, 0x0020);
1194 cit_model3_Packet1(gspca_dev
, 0x0098, 0x0000);
1195 cit_model3_Packet1(gspca_dev
, 0x00b0, 0x0046);
1196 cit_model3_Packet1(gspca_dev
, 0x00b1, 0x0000);
1197 cit_model3_Packet1(gspca_dev
, 0x00b2, 0x0000);
1198 cit_model3_Packet1(gspca_dev
, 0x00b3, 0x0004);
1199 cit_model3_Packet1(gspca_dev
, 0x00b4, 0x0007);
1200 cit_model3_Packet1(gspca_dev
, 0x00b6, 0x0002);
1201 cit_model3_Packet1(gspca_dev
, 0x00b7, 0x0004);
1202 cit_model3_Packet1(gspca_dev
, 0x00bb, 0x0000);
1203 cit_model3_Packet1(gspca_dev
, 0x00bc, 0x0001);
1204 cit_model3_Packet1(gspca_dev
, 0x00bd, 0x0000);
1205 cit_model3_Packet1(gspca_dev
, 0x00bf, 0x0000);
1206 cit_model3_Packet1(gspca_dev
, 0x00c0, 0x00c8);
1207 cit_model3_Packet1(gspca_dev
, 0x00c1, 0x0014);
1208 cit_model3_Packet1(gspca_dev
, 0x00c2, 0x0001);
1209 cit_model3_Packet1(gspca_dev
, 0x00c3, 0x0000);
1210 cit_model3_Packet1(gspca_dev
, 0x00c4, 0x0004);
1211 cit_model3_Packet1(gspca_dev
, 0x00cb, 0x00bf);
1212 cit_model3_Packet1(gspca_dev
, 0x00cc, 0x00bf);
1213 cit_model3_Packet1(gspca_dev
, 0x00cd, 0x00bf);
1214 cit_model3_Packet1(gspca_dev
, 0x00ce, 0x0000);
1215 cit_model3_Packet1(gspca_dev
, 0x00cf, 0x0020);
1216 cit_model3_Packet1(gspca_dev
, 0x00d0, 0x0040);
1217 cit_model3_Packet1(gspca_dev
, 0x00d1, 0x00bf);
1218 cit_model3_Packet1(gspca_dev
, 0x00d1, 0x00bf);
1219 cit_model3_Packet1(gspca_dev
, 0x00d2, 0x00bf);
1220 cit_model3_Packet1(gspca_dev
, 0x00d3, 0x00bf);
1221 cit_model3_Packet1(gspca_dev
, 0x00ea, 0x0008);
1222 cit_model3_Packet1(gspca_dev
, 0x00eb, 0x0000);
1223 cit_model3_Packet1(gspca_dev
, 0x00ec, 0x00e8);
1224 cit_model3_Packet1(gspca_dev
, 0x00ed, 0x0001);
1225 cit_model3_Packet1(gspca_dev
, 0x00ef, 0x0022);
1226 cit_model3_Packet1(gspca_dev
, 0x00f0, 0x0000);
1227 cit_model3_Packet1(gspca_dev
, 0x00f2, 0x0028);
1228 cit_model3_Packet1(gspca_dev
, 0x00f4, 0x0002);
1229 cit_model3_Packet1(gspca_dev
, 0x00f5, 0x0000);
1230 cit_model3_Packet1(gspca_dev
, 0x00fa, 0x0000);
1231 cit_model3_Packet1(gspca_dev
, 0x00fb, 0x0001);
1232 cit_model3_Packet1(gspca_dev
, 0x00fc, 0x0000);
1233 cit_model3_Packet1(gspca_dev
, 0x00fd, 0x0000);
1234 cit_model3_Packet1(gspca_dev
, 0x00fe, 0x0000);
1235 cit_model3_Packet1(gspca_dev
, 0x00ff, 0x0000);
1237 cit_model3_Packet1(gspca_dev
, 0x00be, 0x0003);
1238 cit_model3_Packet1(gspca_dev
, 0x00c8, 0x0000);
1239 cit_model3_Packet1(gspca_dev
, 0x00c9, 0x0020);
1240 cit_model3_Packet1(gspca_dev
, 0x00ca, 0x0040);
1241 cit_model3_Packet1(gspca_dev
, 0x0053, 0x0001);
1242 cit_model3_Packet1(gspca_dev
, 0x0082, 0x000e);
1243 cit_model3_Packet1(gspca_dev
, 0x0083, 0x0020);
1244 cit_model3_Packet1(gspca_dev
, 0x0034, 0x003c);
1245 cit_model3_Packet1(gspca_dev
, 0x006e, 0x0055);
1246 cit_model3_Packet1(gspca_dev
, 0x0062, 0x0005);
1247 cit_model3_Packet1(gspca_dev
, 0x0063, 0x0008);
1248 cit_model3_Packet1(gspca_dev
, 0x0066, 0x000a);
1249 cit_model3_Packet1(gspca_dev
, 0x0067, 0x0006);
1250 cit_model3_Packet1(gspca_dev
, 0x006b, 0x0010);
1251 cit_model3_Packet1(gspca_dev
, 0x005a, 0x0001);
1252 cit_model3_Packet1(gspca_dev
, 0x005b, 0x000a);
1253 cit_model3_Packet1(gspca_dev
, 0x0023, 0x0006);
1254 cit_model3_Packet1(gspca_dev
, 0x0026, 0x0004);
1255 cit_model3_Packet1(gspca_dev
, 0x0036, 0x0069);
1256 cit_model3_Packet1(gspca_dev
, 0x0038, 0x0064);
1257 cit_model3_Packet1(gspca_dev
, 0x003d, 0x0003);
1258 cit_model3_Packet1(gspca_dev
, 0x003e, 0x0001);
1259 cit_model3_Packet1(gspca_dev
, 0x00b8, 0x0014);
1260 cit_model3_Packet1(gspca_dev
, 0x00b9, 0x0014);
1261 cit_model3_Packet1(gspca_dev
, 0x00e6, 0x0004);
1262 cit_model3_Packet1(gspca_dev
, 0x00e8, 0x0001);
1267 /* this function is called at probe and resume time */
1268 static int sd_init(struct gspca_dev
*gspca_dev
)
1270 struct sd
*sd
= (struct sd
*) gspca_dev
;
1272 switch (sd
->model
) {
1274 cit_init_model0(gspca_dev
);
1275 sd_stop0(gspca_dev
);
1281 break; /* All is done in sd_start */
1282 case CIT_IBM_NETCAM_PRO
:
1283 cit_init_ibm_netcam_pro(gspca_dev
);
1284 sd_stop0(gspca_dev
);
1290 static int cit_set_brightness(struct gspca_dev
*gspca_dev
)
1292 struct sd
*sd
= (struct sd
*) gspca_dev
;
1295 switch (sd
->model
) {
1297 case CIT_IBM_NETCAM_PRO
:
1298 /* No (known) brightness control for these */
1301 /* Model 1: Brightness range 0 - 63 */
1302 cit_Packet_Format1(gspca_dev
, 0x0031, sd
->brightness
);
1303 cit_Packet_Format1(gspca_dev
, 0x0032, sd
->brightness
);
1304 cit_Packet_Format1(gspca_dev
, 0x0033, sd
->brightness
);
1307 /* Model 2: Brightness range 0x60 - 0xee */
1308 /* Scale 0 - 63 to 0x60 - 0xee */
1309 i
= 0x60 + sd
->brightness
* 2254 / 1000;
1310 cit_model2_Packet1(gspca_dev
, 0x001a, i
);
1313 /* Model 3: Brightness range 'i' in [0x0C..0x3F] */
1317 cit_model3_Packet1(gspca_dev
, 0x0036, i
);
1320 /* Model 4: Brightness range 'i' in [0x04..0xb4] */
1321 /* Scale 0 - 63 to 0x04 - 0xb4 */
1322 i
= 0x04 + sd
->brightness
* 2794 / 1000;
1323 cit_model4_BrightnessPacket(gspca_dev
, i
);
1330 static int cit_set_contrast(struct gspca_dev
*gspca_dev
)
1332 struct sd
*sd
= (struct sd
*) gspca_dev
;
1334 switch (sd
->model
) {
1337 /* gain 0-15, 0-20 -> 0-15 */
1338 i
= sd
->contrast
* 1000 / 1333;
1339 cit_write_reg(gspca_dev
, i
, 0x0422);
1340 /* gain 0-31, may not be lower then 0x0422, 0-20 -> 0-31 */
1341 i
= sd
->contrast
* 2000 / 1333;
1342 cit_write_reg(gspca_dev
, i
, 0x0423);
1343 /* gain 0-127, may not be lower then 0x0423, 0-20 -> 0-63 */
1344 i
= sd
->contrast
* 4000 / 1333;
1345 cit_write_reg(gspca_dev
, i
, 0x0424);
1346 /* gain 0-127, may not be lower then 0x0424, , 0-20 -> 0-127 */
1347 i
= sd
->contrast
* 8000 / 1333;
1348 cit_write_reg(gspca_dev
, i
, 0x0425);
1353 /* These models do not have this control. */
1357 /* Scale 0 - 20 to 15 - 0 */
1358 int i
, new_contrast
= (20 - sd
->contrast
) * 1000 / 1333;
1359 for (i
= 0; i
< cit_model1_ntries
; i
++) {
1360 cit_Packet_Format1(gspca_dev
, 0x0014, new_contrast
);
1361 cit_send_FF_04_02(gspca_dev
);
1366 { /* Preset hardware values */
1367 static const struct {
1372 { 0x05, 0x05, 0x0f }, /* Minimum */
1373 { 0x04, 0x04, 0x16 },
1374 { 0x02, 0x03, 0x16 },
1375 { 0x02, 0x08, 0x16 },
1376 { 0x01, 0x0c, 0x16 },
1377 { 0x01, 0x0e, 0x16 },
1378 { 0x01, 0x10, 0x16 } /* Maximum */
1380 int i
= sd
->contrast
/ 3;
1381 cit_model3_Packet1(gspca_dev
, 0x0067, cv
[i
].cv1
);
1382 cit_model3_Packet1(gspca_dev
, 0x005b, cv
[i
].cv2
);
1383 cit_model3_Packet1(gspca_dev
, 0x005c, cv
[i
].cv3
);
1386 case CIT_IBM_NETCAM_PRO
:
1387 cit_model3_Packet1(gspca_dev
, 0x005b, sd
->contrast
+ 1);
1393 static int cit_set_hue(struct gspca_dev
*gspca_dev
)
1395 struct sd
*sd
= (struct sd
*) gspca_dev
;
1397 switch (sd
->model
) {
1400 case CIT_IBM_NETCAM_PRO
:
1401 /* No hue control for these models */
1404 cit_model2_Packet1(gspca_dev
, 0x0024, sd
->hue
);
1405 /* cit_model2_Packet1(gspca_dev, 0x0020, sat); */
1408 /* Model 3: Brightness range 'i' in [0x05..0x37] */
1409 /* TESTME according to the ibmcam driver this does not work */
1411 /* Scale 0 - 127 to 0x05 - 0x37 */
1412 int i
= 0x05 + sd
->hue
* 1000 / 2540;
1413 cit_model3_Packet1(gspca_dev
, 0x007e, i
);
1418 /* HDG: taken from ibmcam, setting the color gains does not
1419 * really belong here.
1421 * I am not sure r/g/b_gain variables exactly control gain
1422 * of those channels. Most likely they subtly change some
1423 * very internal image processing settings in the camera.
1424 * In any case, here is what they do, and feel free to tweak:
1426 * r_gain: seriously affects red gain
1427 * g_gain: seriously affects green gain
1428 * b_gain: seriously affects blue gain
1429 * hue: changes average color from violet (0) to red (0xFF)
1431 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
1432 cit_write_reg(gspca_dev
, 0x001e, 0x012f);
1433 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
1434 cit_write_reg(gspca_dev
, 160, 0x0127); /* Green gain */
1435 cit_write_reg(gspca_dev
, 160, 0x012e); /* Red gain */
1436 cit_write_reg(gspca_dev
, 160, 0x0130); /* Blue gain */
1437 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
1438 cit_write_reg(gspca_dev
, sd
->hue
, 0x012d); /* Hue */
1439 cit_write_reg(gspca_dev
, 0xf545, 0x0124);
1445 static int cit_set_sharpness(struct gspca_dev
*gspca_dev
)
1447 struct sd
*sd
= (struct sd
*) gspca_dev
;
1449 switch (sd
->model
) {
1453 case CIT_IBM_NETCAM_PRO
:
1454 /* These models do not have this control */
1458 const unsigned short sa
[] = {
1459 0x11, 0x13, 0x16, 0x18, 0x1a, 0x8, 0x0a };
1461 for (i
= 0; i
< cit_model1_ntries
; i
++)
1462 cit_PacketFormat2(gspca_dev
, 0x0013, sa
[sd
->sharpness
]);
1467 * "Use a table of magic numbers.
1468 * This setting doesn't really change much.
1469 * But that's how Windows does it."
1471 static const struct {
1477 { 0x00, 0x00, 0x05, 0x14 }, /* Smoothest */
1478 { 0x01, 0x04, 0x05, 0x14 },
1479 { 0x02, 0x04, 0x05, 0x14 },
1480 { 0x03, 0x04, 0x05, 0x14 },
1481 { 0x03, 0x05, 0x05, 0x14 },
1482 { 0x03, 0x06, 0x05, 0x14 },
1483 { 0x03, 0x07, 0x05, 0x14 } /* Sharpest */
1485 cit_model3_Packet1(gspca_dev
, 0x0060, sv
[sd
->sharpness
].sv1
);
1486 cit_model3_Packet1(gspca_dev
, 0x0061, sv
[sd
->sharpness
].sv2
);
1487 cit_model3_Packet1(gspca_dev
, 0x0062, sv
[sd
->sharpness
].sv3
);
1488 cit_model3_Packet1(gspca_dev
, 0x0063, sv
[sd
->sharpness
].sv4
);
1496 * cit_set_lighting()
1499 * We have 3 levels of lighting conditions: 0=Bright, 1=Medium, 2=Low.
1502 * We have 16 levels of lighting, 0 for bright light and up to 15 for
1503 * low light. But values above 5 or so are useless because camera is
1504 * not really capable to produce anything worth viewing at such light.
1505 * This setting may be altered only in certain camera state.
1507 * Low lighting forces slower FPS.
1511 * 2/20/00 Added support for Model 2 cameras.
1513 static void cit_set_lighting(struct gspca_dev
*gspca_dev
)
1515 struct sd
*sd
= (struct sd
*) gspca_dev
;
1517 switch (sd
->model
) {
1522 case CIT_IBM_NETCAM_PRO
:
1526 for (i
= 0; i
< cit_model1_ntries
; i
++)
1527 cit_Packet_Format1(gspca_dev
, 0x0027, sd
->lighting
);
1533 static void cit_set_hflip(struct gspca_dev
*gspca_dev
)
1535 struct sd
*sd
= (struct sd
*) gspca_dev
;
1537 switch (sd
->model
) {
1540 cit_write_reg(gspca_dev
, 0x0020, 0x0115);
1542 cit_write_reg(gspca_dev
, 0x0040, 0x0115);
1548 case CIT_IBM_NETCAM_PRO
:
1553 static int cit_restart_stream(struct gspca_dev
*gspca_dev
)
1555 struct sd
*sd
= (struct sd
*) gspca_dev
;
1557 switch (sd
->model
) {
1560 cit_write_reg(gspca_dev
, 0x0001, 0x0114);
1564 cit_write_reg(gspca_dev
, 0x00c0, 0x010c); /* Go! */
1565 usb_clear_halt(gspca_dev
->dev
, gspca_dev
->urb
[0]->pipe
);
1568 case CIT_IBM_NETCAM_PRO
:
1569 cit_write_reg(gspca_dev
, 0x0001, 0x0114);
1570 cit_write_reg(gspca_dev
, 0x00c0, 0x010c); /* Go! */
1571 usb_clear_halt(gspca_dev
->dev
, gspca_dev
->urb
[0]->pipe
);
1572 /* Clear button events from while we were not streaming */
1573 cit_write_reg(gspca_dev
, 0x0001, 0x0113);
1582 static int cit_get_packet_size(struct gspca_dev
*gspca_dev
)
1584 struct usb_host_interface
*alt
;
1585 struct usb_interface
*intf
;
1587 intf
= usb_ifnum_to_if(gspca_dev
->dev
, gspca_dev
->iface
);
1588 alt
= usb_altnum_to_altsetting(intf
, gspca_dev
->alt
);
1590 err("Couldn't get altsetting");
1594 return le16_to_cpu(alt
->endpoint
[0].desc
.wMaxPacketSize
);
1597 /* Calculate the clockdiv giving us max fps given the available bandwidth */
1598 static int cit_get_clock_div(struct gspca_dev
*gspca_dev
)
1600 int clock_div
= 7; /* 0=30 1=25 2=20 3=15 4=12 5=7.5 6=6 7=3fps ?? */
1601 int fps
[8] = { 30, 25, 20, 15, 12, 8, 6, 3 };
1604 packet_size
= cit_get_packet_size(gspca_dev
);
1605 if (packet_size
< 0)
1608 while (clock_div
> 3 &&
1609 1000 * packet_size
>
1610 gspca_dev
->width
* gspca_dev
->height
*
1611 fps
[clock_div
- 1] * 3 / 2)
1615 "PacketSize: %d, res: %dx%d -> using clockdiv: %d (%d fps)",
1616 packet_size
, gspca_dev
->width
, gspca_dev
->height
, clock_div
,
1622 static int cit_start_model0(struct gspca_dev
*gspca_dev
)
1624 const unsigned short compression
= 0; /* 0=none, 7=best frame rate */
1627 clock_div
= cit_get_clock_div(gspca_dev
);
1631 cit_write_reg(gspca_dev
, 0x0000, 0x0100); /* turn on led */
1632 cit_write_reg(gspca_dev
, 0x0003, 0x0438);
1633 cit_write_reg(gspca_dev
, 0x001e, 0x042b);
1634 cit_write_reg(gspca_dev
, 0x0041, 0x042c);
1635 cit_write_reg(gspca_dev
, 0x0008, 0x0436);
1636 cit_write_reg(gspca_dev
, 0x0024, 0x0403);
1637 cit_write_reg(gspca_dev
, 0x002c, 0x0404);
1638 cit_write_reg(gspca_dev
, 0x0002, 0x0426);
1639 cit_write_reg(gspca_dev
, 0x0014, 0x0427);
1641 switch (gspca_dev
->width
) {
1642 case 160: /* 160x120 */
1643 cit_write_reg(gspca_dev
, 0x0004, 0x010b);
1644 cit_write_reg(gspca_dev
, 0x0001, 0x010a);
1645 cit_write_reg(gspca_dev
, 0x0010, 0x0102);
1646 cit_write_reg(gspca_dev
, 0x00a0, 0x0103);
1647 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
1648 cit_write_reg(gspca_dev
, 0x0078, 0x0105);
1651 case 176: /* 176x144 */
1652 cit_write_reg(gspca_dev
, 0x0006, 0x010b);
1653 cit_write_reg(gspca_dev
, 0x0000, 0x010a);
1654 cit_write_reg(gspca_dev
, 0x0005, 0x0102);
1655 cit_write_reg(gspca_dev
, 0x00b0, 0x0103);
1656 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
1657 cit_write_reg(gspca_dev
, 0x0090, 0x0105);
1660 case 320: /* 320x240 */
1661 cit_write_reg(gspca_dev
, 0x0008, 0x010b);
1662 cit_write_reg(gspca_dev
, 0x0004, 0x010a);
1663 cit_write_reg(gspca_dev
, 0x0005, 0x0102);
1664 cit_write_reg(gspca_dev
, 0x00a0, 0x0103);
1665 cit_write_reg(gspca_dev
, 0x0010, 0x0104);
1666 cit_write_reg(gspca_dev
, 0x0078, 0x0105);
1670 cit_write_reg(gspca_dev
, compression
, 0x0109);
1671 cit_write_reg(gspca_dev
, clock_div
, 0x0111);
1676 static int cit_start_model1(struct gspca_dev
*gspca_dev
)
1678 struct sd
*sd
= (struct sd
*) gspca_dev
;
1681 clock_div
= cit_get_clock_div(gspca_dev
);
1685 cit_read_reg(gspca_dev
, 0x0128, 1);
1686 cit_read_reg(gspca_dev
, 0x0100, 0);
1687 cit_write_reg(gspca_dev
, 0x01, 0x0100); /* LED On */
1688 cit_read_reg(gspca_dev
, 0x0100, 0);
1689 cit_write_reg(gspca_dev
, 0x81, 0x0100); /* LED Off */
1690 cit_read_reg(gspca_dev
, 0x0100, 0);
1691 cit_write_reg(gspca_dev
, 0x01, 0x0100); /* LED On */
1692 cit_write_reg(gspca_dev
, 0x01, 0x0108);
1694 cit_write_reg(gspca_dev
, 0x03, 0x0112);
1695 cit_read_reg(gspca_dev
, 0x0115, 0);
1696 cit_write_reg(gspca_dev
, 0x06, 0x0115);
1697 cit_read_reg(gspca_dev
, 0x0116, 0);
1698 cit_write_reg(gspca_dev
, 0x44, 0x0116);
1699 cit_read_reg(gspca_dev
, 0x0116, 0);
1700 cit_write_reg(gspca_dev
, 0x40, 0x0116);
1701 cit_read_reg(gspca_dev
, 0x0115, 0);
1702 cit_write_reg(gspca_dev
, 0x0e, 0x0115);
1703 cit_write_reg(gspca_dev
, 0x19, 0x012c);
1705 cit_Packet_Format1(gspca_dev
, 0x00, 0x1e);
1706 cit_Packet_Format1(gspca_dev
, 0x39, 0x0d);
1707 cit_Packet_Format1(gspca_dev
, 0x39, 0x09);
1708 cit_Packet_Format1(gspca_dev
, 0x3b, 0x00);
1709 cit_Packet_Format1(gspca_dev
, 0x28, 0x22);
1710 cit_Packet_Format1(gspca_dev
, 0x27, 0x00);
1711 cit_Packet_Format1(gspca_dev
, 0x2b, 0x1f);
1712 cit_Packet_Format1(gspca_dev
, 0x39, 0x08);
1714 for (i
= 0; i
< cit_model1_ntries
; i
++)
1715 cit_Packet_Format1(gspca_dev
, 0x2c, 0x00);
1717 for (i
= 0; i
< cit_model1_ntries
; i
++)
1718 cit_Packet_Format1(gspca_dev
, 0x30, 0x14);
1720 cit_PacketFormat2(gspca_dev
, 0x39, 0x02);
1721 cit_PacketFormat2(gspca_dev
, 0x01, 0xe1);
1722 cit_PacketFormat2(gspca_dev
, 0x02, 0xcd);
1723 cit_PacketFormat2(gspca_dev
, 0x03, 0xcd);
1724 cit_PacketFormat2(gspca_dev
, 0x04, 0xfa);
1725 cit_PacketFormat2(gspca_dev
, 0x3f, 0xff);
1726 cit_PacketFormat2(gspca_dev
, 0x39, 0x00);
1728 cit_PacketFormat2(gspca_dev
, 0x39, 0x02);
1729 cit_PacketFormat2(gspca_dev
, 0x0a, 0x37);
1730 cit_PacketFormat2(gspca_dev
, 0x0b, 0xb8);
1731 cit_PacketFormat2(gspca_dev
, 0x0c, 0xf3);
1732 cit_PacketFormat2(gspca_dev
, 0x0d, 0xe3);
1733 cit_PacketFormat2(gspca_dev
, 0x0e, 0x0d);
1734 cit_PacketFormat2(gspca_dev
, 0x0f, 0xf2);
1735 cit_PacketFormat2(gspca_dev
, 0x10, 0xd5);
1736 cit_PacketFormat2(gspca_dev
, 0x11, 0xba);
1737 cit_PacketFormat2(gspca_dev
, 0x12, 0x53);
1738 cit_PacketFormat2(gspca_dev
, 0x3f, 0xff);
1739 cit_PacketFormat2(gspca_dev
, 0x39, 0x00);
1741 cit_PacketFormat2(gspca_dev
, 0x39, 0x02);
1742 cit_PacketFormat2(gspca_dev
, 0x16, 0x00);
1743 cit_PacketFormat2(gspca_dev
, 0x17, 0x28);
1744 cit_PacketFormat2(gspca_dev
, 0x18, 0x7d);
1745 cit_PacketFormat2(gspca_dev
, 0x19, 0xbe);
1746 cit_PacketFormat2(gspca_dev
, 0x3f, 0xff);
1747 cit_PacketFormat2(gspca_dev
, 0x39, 0x00);
1749 for (i
= 0; i
< cit_model1_ntries
; i
++)
1750 cit_Packet_Format1(gspca_dev
, 0x00, 0x18);
1751 for (i
= 0; i
< cit_model1_ntries
; i
++)
1752 cit_Packet_Format1(gspca_dev
, 0x13, 0x18);
1753 for (i
= 0; i
< cit_model1_ntries
; i
++)
1754 cit_Packet_Format1(gspca_dev
, 0x14, 0x06);
1756 /* TESTME These are handled through controls
1757 KEEP until someone can test leaving this out is ok */
1759 /* This is default brightness */
1760 for (i
= 0; i
< cit_model1_ntries
; i
++)
1761 cit_Packet_Format1(gspca_dev
, 0x31, 0x37);
1762 for (i
= 0; i
< cit_model1_ntries
; i
++)
1763 cit_Packet_Format1(gspca_dev
, 0x32, 0x46);
1764 for (i
= 0; i
< cit_model1_ntries
; i
++)
1765 cit_Packet_Format1(gspca_dev
, 0x33, 0x55);
1768 cit_Packet_Format1(gspca_dev
, 0x2e, 0x04);
1769 for (i
= 0; i
< cit_model1_ntries
; i
++)
1770 cit_Packet_Format1(gspca_dev
, 0x2d, 0x04);
1771 for (i
= 0; i
< cit_model1_ntries
; i
++)
1772 cit_Packet_Format1(gspca_dev
, 0x29, 0x80);
1773 cit_Packet_Format1(gspca_dev
, 0x2c, 0x01);
1774 cit_Packet_Format1(gspca_dev
, 0x30, 0x17);
1775 cit_Packet_Format1(gspca_dev
, 0x39, 0x08);
1776 for (i
= 0; i
< cit_model1_ntries
; i
++)
1777 cit_Packet_Format1(gspca_dev
, 0x34, 0x00);
1779 cit_write_reg(gspca_dev
, 0x00, 0x0101);
1780 cit_write_reg(gspca_dev
, 0x00, 0x010a);
1782 switch (gspca_dev
->width
) {
1783 case 128: /* 128x96 */
1784 cit_write_reg(gspca_dev
, 0x80, 0x0103);
1785 cit_write_reg(gspca_dev
, 0x60, 0x0105);
1786 cit_write_reg(gspca_dev
, 0x0c, 0x010b);
1787 cit_write_reg(gspca_dev
, 0x04, 0x011b); /* Same everywhere */
1788 cit_write_reg(gspca_dev
, 0x0b, 0x011d);
1789 cit_write_reg(gspca_dev
, 0x00, 0x011e); /* Same everywhere */
1790 cit_write_reg(gspca_dev
, 0x00, 0x0129);
1792 case 176: /* 176x144 */
1793 cit_write_reg(gspca_dev
, 0xb0, 0x0103);
1794 cit_write_reg(gspca_dev
, 0x8f, 0x0105);
1795 cit_write_reg(gspca_dev
, 0x06, 0x010b);
1796 cit_write_reg(gspca_dev
, 0x04, 0x011b); /* Same everywhere */
1797 cit_write_reg(gspca_dev
, 0x0d, 0x011d);
1798 cit_write_reg(gspca_dev
, 0x00, 0x011e); /* Same everywhere */
1799 cit_write_reg(gspca_dev
, 0x03, 0x0129);
1801 case 352: /* 352x288 */
1802 cit_write_reg(gspca_dev
, 0xb0, 0x0103);
1803 cit_write_reg(gspca_dev
, 0x90, 0x0105);
1804 cit_write_reg(gspca_dev
, 0x02, 0x010b);
1805 cit_write_reg(gspca_dev
, 0x04, 0x011b); /* Same everywhere */
1806 cit_write_reg(gspca_dev
, 0x05, 0x011d);
1807 cit_write_reg(gspca_dev
, 0x00, 0x011e); /* Same everywhere */
1808 cit_write_reg(gspca_dev
, 0x00, 0x0129);
1812 cit_write_reg(gspca_dev
, 0xff, 0x012b);
1814 /* TESTME These are handled through controls
1815 KEEP until someone can test leaving this out is ok */
1817 /* This is another brightness - don't know why */
1818 for (i
= 0; i
< cit_model1_ntries
; i
++)
1819 cit_Packet_Format1(gspca_dev
, 0x31, 0xc3);
1820 for (i
= 0; i
< cit_model1_ntries
; i
++)
1821 cit_Packet_Format1(gspca_dev
, 0x32, 0xd2);
1822 for (i
= 0; i
< cit_model1_ntries
; i
++)
1823 cit_Packet_Format1(gspca_dev
, 0x33, 0xe1);
1825 /* Default contrast */
1826 for (i
= 0; i
< cit_model1_ntries
; i
++)
1827 cit_Packet_Format1(gspca_dev
, 0x14, 0x0a);
1829 /* Default sharpness */
1830 for (i
= 0; i
< cit_model1_ntries2
; i
++)
1831 cit_PacketFormat2(gspca_dev
, 0x13, 0x1a);
1833 /* Default lighting conditions */
1834 cit_Packet_Format1(gspca_dev
, 0x0027, sd
->lighting
);
1838 switch (gspca_dev
->width
) {
1839 case 128: /* 128x96 */
1840 cit_Packet_Format1(gspca_dev
, 0x2b, 0x1e);
1841 cit_write_reg(gspca_dev
, 0xc9, 0x0119); /* Same everywhere */
1842 cit_write_reg(gspca_dev
, 0x80, 0x0109); /* Same everywhere */
1843 cit_write_reg(gspca_dev
, 0x36, 0x0102);
1844 cit_write_reg(gspca_dev
, 0x1a, 0x0104);
1845 cit_write_reg(gspca_dev
, 0x04, 0x011a); /* Same everywhere */
1846 cit_write_reg(gspca_dev
, 0x2b, 0x011c);
1847 cit_write_reg(gspca_dev
, 0x23, 0x012a); /* Same everywhere */
1849 case 176: /* 176x144 */
1850 cit_Packet_Format1(gspca_dev
, 0x2b, 0x1e);
1851 cit_write_reg(gspca_dev
, 0xc9, 0x0119); /* Same everywhere */
1852 cit_write_reg(gspca_dev
, 0x80, 0x0109); /* Same everywhere */
1853 cit_write_reg(gspca_dev
, 0x04, 0x0102);
1854 cit_write_reg(gspca_dev
, 0x02, 0x0104);
1855 cit_write_reg(gspca_dev
, 0x04, 0x011a); /* Same everywhere */
1856 cit_write_reg(gspca_dev
, 0x2b, 0x011c);
1857 cit_write_reg(gspca_dev
, 0x23, 0x012a); /* Same everywhere */
1859 case 352: /* 352x288 */
1860 cit_Packet_Format1(gspca_dev
, 0x2b, 0x1f);
1861 cit_write_reg(gspca_dev
, 0xc9, 0x0119); /* Same everywhere */
1862 cit_write_reg(gspca_dev
, 0x80, 0x0109); /* Same everywhere */
1863 cit_write_reg(gspca_dev
, 0x08, 0x0102);
1864 cit_write_reg(gspca_dev
, 0x01, 0x0104);
1865 cit_write_reg(gspca_dev
, 0x04, 0x011a); /* Same everywhere */
1866 cit_write_reg(gspca_dev
, 0x2f, 0x011c);
1867 cit_write_reg(gspca_dev
, 0x23, 0x012a); /* Same everywhere */
1871 cit_write_reg(gspca_dev
, 0x01, 0x0100); /* LED On */
1872 cit_write_reg(gspca_dev
, clock_div
, 0x0111);
1877 static int cit_start_model2(struct gspca_dev
*gspca_dev
)
1879 struct sd
*sd
= (struct sd
*) gspca_dev
;
1882 cit_write_reg(gspca_dev
, 0x0000, 0x0100); /* LED on */
1883 cit_read_reg(gspca_dev
, 0x0116, 0);
1884 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
1885 cit_write_reg(gspca_dev
, 0x0002, 0x0112);
1886 cit_write_reg(gspca_dev
, 0x00bc, 0x012c);
1887 cit_write_reg(gspca_dev
, 0x0008, 0x012b);
1888 cit_write_reg(gspca_dev
, 0x0000, 0x0108);
1889 cit_write_reg(gspca_dev
, 0x0001, 0x0133);
1890 cit_write_reg(gspca_dev
, 0x0001, 0x0102);
1891 switch (gspca_dev
->width
) {
1892 case 176: /* 176x144 */
1893 cit_write_reg(gspca_dev
, 0x002c, 0x0103); /* All except 320x240 */
1894 cit_write_reg(gspca_dev
, 0x0000, 0x0104); /* Same */
1895 cit_write_reg(gspca_dev
, 0x0024, 0x0105); /* 176x144, 352x288 */
1896 cit_write_reg(gspca_dev
, 0x00b9, 0x010a); /* Unique to this mode */
1897 cit_write_reg(gspca_dev
, 0x0038, 0x0119); /* Unique to this mode */
1898 /* TESTME HDG: this does not seem right
1899 (it is 2 for all other resolutions) */
1902 case 320: /* 320x240 */
1903 cit_write_reg(gspca_dev
, 0x0028, 0x0103); /* Unique to this mode */
1904 cit_write_reg(gspca_dev
, 0x0000, 0x0104); /* Same */
1905 cit_write_reg(gspca_dev
, 0x001e, 0x0105); /* 320x240, 352x240 */
1906 cit_write_reg(gspca_dev
, 0x0039, 0x010a); /* All except 176x144 */
1907 cit_write_reg(gspca_dev
, 0x0070, 0x0119); /* All except 176x144 */
1910 /* case VIDEOSIZE_352x240: */
1911 cit_write_reg(gspca_dev
, 0x002c, 0x0103); /* All except 320x240 */
1912 cit_write_reg(gspca_dev
, 0x0000, 0x0104); /* Same */
1913 cit_write_reg(gspca_dev
, 0x001e, 0x0105); /* 320x240, 352x240 */
1914 cit_write_reg(gspca_dev
, 0x0039, 0x010a); /* All except 176x144 */
1915 cit_write_reg(gspca_dev
, 0x0070, 0x0119); /* All except 176x144 */
1918 case 352: /* 352x288 */
1919 cit_write_reg(gspca_dev
, 0x002c, 0x0103); /* All except 320x240 */
1920 cit_write_reg(gspca_dev
, 0x0000, 0x0104); /* Same */
1921 cit_write_reg(gspca_dev
, 0x0024, 0x0105); /* 176x144, 352x288 */
1922 cit_write_reg(gspca_dev
, 0x0039, 0x010a); /* All except 176x144 */
1923 cit_write_reg(gspca_dev
, 0x0070, 0x0119); /* All except 176x144 */
1928 cit_write_reg(gspca_dev
, 0x0000, 0x0100); /* LED on */
1930 switch (gspca_dev
->width
) {
1931 case 176: /* 176x144 */
1932 cit_write_reg(gspca_dev
, 0x0050, 0x0111);
1933 cit_write_reg(gspca_dev
, 0x00d0, 0x0111);
1935 case 320: /* 320x240 */
1936 case 352: /* 352x288 */
1937 cit_write_reg(gspca_dev
, 0x0040, 0x0111);
1938 cit_write_reg(gspca_dev
, 0x00c0, 0x0111);
1941 cit_write_reg(gspca_dev
, 0x009b, 0x010f);
1942 cit_write_reg(gspca_dev
, 0x00bb, 0x010f);
1945 * Hardware settings, may affect CMOS sensor; not user controls!
1946 * -------------------------------------------------------------
1948 * 0x0006: hardware effect
1950 * 0x000a: stops video stream, probably important h/w setting
1951 * 0x000c: changes color in hardware manner (not user setting)
1952 * 0x0012: changes number of colors (does not affect speed)
1954 * 0x002c: hardware setting (related to scan lines)
1955 * 0x002e: stops video stream, probably important h/w setting
1957 cit_model2_Packet1(gspca_dev
, 0x000a, 0x005c);
1958 cit_model2_Packet1(gspca_dev
, 0x0004, 0x0000);
1959 cit_model2_Packet1(gspca_dev
, 0x0006, 0x00fb);
1960 cit_model2_Packet1(gspca_dev
, 0x0008, 0x0000);
1961 cit_model2_Packet1(gspca_dev
, 0x000c, 0x0009);
1962 cit_model2_Packet1(gspca_dev
, 0x0012, 0x000a);
1963 cit_model2_Packet1(gspca_dev
, 0x002a, 0x0000);
1964 cit_model2_Packet1(gspca_dev
, 0x002c, 0x0000);
1965 cit_model2_Packet1(gspca_dev
, 0x002e, 0x0008);
1968 * Function 0x0030 pops up all over the place. Apparently
1969 * it is a hardware control register, with every bit assigned to
1972 cit_model2_Packet1(gspca_dev
, 0x0030, 0x0000);
1975 * Magic control of CMOS sensor. Only lower values like
1976 * 0-3 work, and picture shifts left or right. Don't change.
1978 switch (gspca_dev
->width
) {
1979 case 176: /* 176x144 */
1980 cit_model2_Packet1(gspca_dev
, 0x0014, 0x0002);
1981 cit_model2_Packet1(gspca_dev
, 0x0016, 0x0002); /* Horizontal shift */
1982 cit_model2_Packet1(gspca_dev
, 0x0018, 0x004a); /* Another hardware setting */
1985 case 320: /* 320x240 */
1986 cit_model2_Packet1(gspca_dev
, 0x0014, 0x0009);
1987 cit_model2_Packet1(gspca_dev
, 0x0016, 0x0005); /* Horizontal shift */
1988 cit_model2_Packet1(gspca_dev
, 0x0018, 0x0044); /* Another hardware setting */
1991 /* case VIDEOSIZE_352x240: */
1992 /* This mode doesn't work as Windows programs it; changed to work */
1993 cit_model2_Packet1(gspca_dev
, 0x0014, 0x0009); /* Windows sets this to 8 */
1994 cit_model2_Packet1(gspca_dev
, 0x0016, 0x0003); /* Horizontal shift */
1995 cit_model2_Packet1(gspca_dev
, 0x0018, 0x0044); /* Windows sets this to 0x0045 */
1998 case 352: /* 352x288 */
1999 cit_model2_Packet1(gspca_dev
, 0x0014, 0x0003);
2000 cit_model2_Packet1(gspca_dev
, 0x0016, 0x0002); /* Horizontal shift */
2001 cit_model2_Packet1(gspca_dev
, 0x0018, 0x004a); /* Another hardware setting */
2006 /* TESTME These are handled through controls
2007 KEEP until someone can test leaving this out is ok */
2009 cit_model2_Packet1(gspca_dev
, 0x001a, 0x005a);
2012 * We have our own frame rate setting varying from 0 (slowest) to 6
2013 * (fastest). The camera model 2 allows frame rate in range [0..0x1F]
2014 # where 0 is also the slowest setting. However for all practical
2015 # reasons high settings make no sense because USB is not fast enough
2016 # to support high FPS. Be aware that the picture datastream will be
2017 # severely disrupted if you ask for frame rate faster than allowed
2018 # for the video size - see below:
2020 * Allowable ranges (obtained experimentally on OHCI, K6-3, 450 MHz):
2021 * -----------------------------------------------------------------
2025 * 352x288: [16..31] I have to raise lower threshold for stability...
2027 * As usual, slower FPS provides better sensitivity.
2029 cit_model2_Packet1(gspca_dev
, 0x001c, clock_div
);
2032 * This setting does not visibly affect pictures; left it here
2033 * because it was present in Windows USB data stream. This function
2034 * does not allow arbitrary values and apparently is a bit mask, to
2035 * be activated only at appropriate time. Don't change it randomly!
2037 switch (gspca_dev
->width
) {
2038 case 176: /* 176x144 */
2039 cit_model2_Packet1(gspca_dev
, 0x0026, 0x00c2);
2041 case 320: /* 320x240 */
2042 cit_model2_Packet1(gspca_dev
, 0x0026, 0x0044);
2044 /* case VIDEOSIZE_352x240: */
2045 cit_model2_Packet1(gspca_dev
, 0x0026, 0x0046);
2047 case 352: /* 352x288 */
2048 cit_model2_Packet1(gspca_dev
, 0x0026, 0x0048);
2052 /* FIXME this cannot be changed while streaming, so we
2053 should report a grabbed flag for this control. */
2054 cit_model2_Packet1(gspca_dev
, 0x0028, sd
->lighting
);
2055 /* color balance rg2 */
2056 cit_model2_Packet1(gspca_dev
, 0x001e, 0x002f);
2058 cit_model2_Packet1(gspca_dev
, 0x0020, 0x0034);
2059 /* color balance yb */
2060 cit_model2_Packet1(gspca_dev
, 0x0022, 0x00a0);
2062 /* Hardware control command */
2063 cit_model2_Packet1(gspca_dev
, 0x0030, 0x0004);
2068 static int cit_start_model3(struct gspca_dev
*gspca_dev
)
2070 const unsigned short compression
= 0; /* 0=none, 7=best frame rate */
2071 int i
, clock_div
= 0;
2073 /* HDG not in ibmcam driver, added to see if it helps with
2074 auto-detecting between model3 and ibm netcamera pro */
2075 cit_read_reg(gspca_dev
, 0x128, 1);
2077 cit_write_reg(gspca_dev
, 0x0000, 0x0100);
2078 cit_read_reg(gspca_dev
, 0x0116, 0);
2079 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
2080 cit_write_reg(gspca_dev
, 0x0002, 0x0112);
2081 cit_write_reg(gspca_dev
, 0x0000, 0x0123);
2082 cit_write_reg(gspca_dev
, 0x0001, 0x0117);
2083 cit_write_reg(gspca_dev
, 0x0040, 0x0108);
2084 cit_write_reg(gspca_dev
, 0x0019, 0x012c);
2085 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
2086 cit_write_reg(gspca_dev
, 0x0002, 0x0115);
2087 cit_write_reg(gspca_dev
, 0x0003, 0x0115);
2088 cit_read_reg(gspca_dev
, 0x0115, 0);
2089 cit_write_reg(gspca_dev
, 0x000b, 0x0115);
2091 /* TESTME HDG not in ibmcam driver, added to see if it helps with
2092 auto-detecting between model3 and ibm netcamera pro */
2094 cit_write_reg(gspca_dev
, 0x0078, 0x012d);
2095 cit_write_reg(gspca_dev
, 0x0001, 0x012f);
2096 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2097 cit_write_reg(gspca_dev
, 0x0079, 0x012d);
2098 cit_write_reg(gspca_dev
, 0x00ff, 0x0130);
2099 cit_write_reg(gspca_dev
, 0xcd41, 0x0124);
2100 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2101 cit_read_reg(gspca_dev
, 0x0126, 1);
2104 cit_model3_Packet1(gspca_dev
, 0x000a, 0x0040);
2105 cit_model3_Packet1(gspca_dev
, 0x000b, 0x00f6);
2106 cit_model3_Packet1(gspca_dev
, 0x000c, 0x0002);
2107 cit_model3_Packet1(gspca_dev
, 0x000d, 0x0020);
2108 cit_model3_Packet1(gspca_dev
, 0x000e, 0x0033);
2109 cit_model3_Packet1(gspca_dev
, 0x000f, 0x0007);
2110 cit_model3_Packet1(gspca_dev
, 0x0010, 0x0000);
2111 cit_model3_Packet1(gspca_dev
, 0x0011, 0x0070);
2112 cit_model3_Packet1(gspca_dev
, 0x0012, 0x0030);
2113 cit_model3_Packet1(gspca_dev
, 0x0013, 0x0000);
2114 cit_model3_Packet1(gspca_dev
, 0x0014, 0x0001);
2115 cit_model3_Packet1(gspca_dev
, 0x0015, 0x0001);
2116 cit_model3_Packet1(gspca_dev
, 0x0016, 0x0001);
2117 cit_model3_Packet1(gspca_dev
, 0x0017, 0x0001);
2118 cit_model3_Packet1(gspca_dev
, 0x0018, 0x0000);
2119 cit_model3_Packet1(gspca_dev
, 0x001e, 0x00c3);
2120 cit_model3_Packet1(gspca_dev
, 0x0020, 0x0000);
2121 cit_model3_Packet1(gspca_dev
, 0x0028, 0x0010);
2122 cit_model3_Packet1(gspca_dev
, 0x0029, 0x0054);
2123 cit_model3_Packet1(gspca_dev
, 0x002a, 0x0013);
2124 cit_model3_Packet1(gspca_dev
, 0x002b, 0x0007);
2125 cit_model3_Packet1(gspca_dev
, 0x002d, 0x0028);
2126 cit_model3_Packet1(gspca_dev
, 0x002e, 0x0000);
2127 cit_model3_Packet1(gspca_dev
, 0x0031, 0x0000);
2128 cit_model3_Packet1(gspca_dev
, 0x0032, 0x0000);
2129 cit_model3_Packet1(gspca_dev
, 0x0033, 0x0000);
2130 cit_model3_Packet1(gspca_dev
, 0x0034, 0x0000);
2131 cit_model3_Packet1(gspca_dev
, 0x0035, 0x0038);
2132 cit_model3_Packet1(gspca_dev
, 0x003a, 0x0001);
2133 cit_model3_Packet1(gspca_dev
, 0x003c, 0x001e);
2134 cit_model3_Packet1(gspca_dev
, 0x003f, 0x000a);
2135 cit_model3_Packet1(gspca_dev
, 0x0041, 0x0000);
2136 cit_model3_Packet1(gspca_dev
, 0x0046, 0x003f);
2137 cit_model3_Packet1(gspca_dev
, 0x0047, 0x0000);
2138 cit_model3_Packet1(gspca_dev
, 0x0050, 0x0005);
2139 cit_model3_Packet1(gspca_dev
, 0x0052, 0x001a);
2140 cit_model3_Packet1(gspca_dev
, 0x0053, 0x0003);
2141 cit_model3_Packet1(gspca_dev
, 0x005a, 0x006b);
2142 cit_model3_Packet1(gspca_dev
, 0x005d, 0x001e);
2143 cit_model3_Packet1(gspca_dev
, 0x005e, 0x0030);
2144 cit_model3_Packet1(gspca_dev
, 0x005f, 0x0041);
2145 cit_model3_Packet1(gspca_dev
, 0x0064, 0x0008);
2146 cit_model3_Packet1(gspca_dev
, 0x0065, 0x0015);
2147 cit_model3_Packet1(gspca_dev
, 0x0068, 0x000f);
2148 cit_model3_Packet1(gspca_dev
, 0x0079, 0x0000);
2149 cit_model3_Packet1(gspca_dev
, 0x007a, 0x0000);
2150 cit_model3_Packet1(gspca_dev
, 0x007c, 0x003f);
2151 cit_model3_Packet1(gspca_dev
, 0x0082, 0x000f);
2152 cit_model3_Packet1(gspca_dev
, 0x0085, 0x0000);
2153 cit_model3_Packet1(gspca_dev
, 0x0099, 0x0000);
2154 cit_model3_Packet1(gspca_dev
, 0x009b, 0x0023);
2155 cit_model3_Packet1(gspca_dev
, 0x009c, 0x0022);
2156 cit_model3_Packet1(gspca_dev
, 0x009d, 0x0096);
2157 cit_model3_Packet1(gspca_dev
, 0x009e, 0x0096);
2158 cit_model3_Packet1(gspca_dev
, 0x009f, 0x000a);
2160 switch (gspca_dev
->width
) {
2162 cit_write_reg(gspca_dev
, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2163 cit_write_reg(gspca_dev
, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
2164 cit_write_reg(gspca_dev
, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
2165 cit_write_reg(gspca_dev
, 0x0000, 0x010a); /* Same */
2166 cit_write_reg(gspca_dev
, 0x0024, 0x010b); /* Differs everywhere */
2167 cit_write_reg(gspca_dev
, 0x00a9, 0x0119);
2168 cit_write_reg(gspca_dev
, 0x0016, 0x011b);
2169 cit_write_reg(gspca_dev
, 0x0002, 0x011d); /* Same on 160x120, 320x240 */
2170 cit_write_reg(gspca_dev
, 0x0003, 0x011e); /* Same on 160x120, 640x480 */
2171 cit_write_reg(gspca_dev
, 0x0000, 0x0129); /* Same */
2172 cit_write_reg(gspca_dev
, 0x00fc, 0x012b); /* Same */
2173 cit_write_reg(gspca_dev
, 0x0018, 0x0102);
2174 cit_write_reg(gspca_dev
, 0x0004, 0x0104);
2175 cit_write_reg(gspca_dev
, 0x0004, 0x011a);
2176 cit_write_reg(gspca_dev
, 0x0028, 0x011c);
2177 cit_write_reg(gspca_dev
, 0x0022, 0x012a); /* Same */
2178 cit_write_reg(gspca_dev
, 0x0000, 0x0118);
2179 cit_write_reg(gspca_dev
, 0x0000, 0x0132);
2180 cit_model3_Packet1(gspca_dev
, 0x0021, 0x0001); /* Same */
2181 cit_write_reg(gspca_dev
, compression
, 0x0109);
2185 cit_write_reg(gspca_dev
, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2186 cit_write_reg(gspca_dev
, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
2187 cit_write_reg(gspca_dev
, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
2188 cit_write_reg(gspca_dev
, 0x0000, 0x010a); /* Same */
2189 cit_write_reg(gspca_dev
, 0x0028, 0x010b); /* Differs everywhere */
2190 cit_write_reg(gspca_dev
, 0x0002, 0x011d); /* Same */
2191 cit_write_reg(gspca_dev
, 0x0000, 0x011e);
2192 cit_write_reg(gspca_dev
, 0x0000, 0x0129); /* Same */
2193 cit_write_reg(gspca_dev
, 0x00fc, 0x012b); /* Same */
2194 /* 4 commands from 160x120 skipped */
2195 cit_write_reg(gspca_dev
, 0x0022, 0x012a); /* Same */
2196 cit_model3_Packet1(gspca_dev
, 0x0021, 0x0001); /* Same */
2197 cit_write_reg(gspca_dev
, compression
, 0x0109);
2198 cit_write_reg(gspca_dev
, 0x00d9, 0x0119);
2199 cit_write_reg(gspca_dev
, 0x0006, 0x011b);
2200 cit_write_reg(gspca_dev
, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
2201 cit_write_reg(gspca_dev
, 0x0010, 0x0104);
2202 cit_write_reg(gspca_dev
, 0x0004, 0x011a);
2203 cit_write_reg(gspca_dev
, 0x003f, 0x011c);
2204 cit_write_reg(gspca_dev
, 0x001c, 0x0118);
2205 cit_write_reg(gspca_dev
, 0x0000, 0x0132);
2209 cit_write_reg(gspca_dev
, 0x00f0, 0x0105);
2210 cit_write_reg(gspca_dev
, 0x0000, 0x010a); /* Same */
2211 cit_write_reg(gspca_dev
, 0x0038, 0x010b); /* Differs everywhere */
2212 cit_write_reg(gspca_dev
, 0x00d9, 0x0119); /* Same on 320x240, 640x480 */
2213 cit_write_reg(gspca_dev
, 0x0006, 0x011b); /* Same on 320x240, 640x480 */
2214 cit_write_reg(gspca_dev
, 0x0004, 0x011d); /* NC */
2215 cit_write_reg(gspca_dev
, 0x0003, 0x011e); /* Same on 160x120, 640x480 */
2216 cit_write_reg(gspca_dev
, 0x0000, 0x0129); /* Same */
2217 cit_write_reg(gspca_dev
, 0x00fc, 0x012b); /* Same */
2218 cit_write_reg(gspca_dev
, 0x0021, 0x0102); /* Same on 320x240, 640x480 */
2219 cit_write_reg(gspca_dev
, 0x0016, 0x0104); /* NC */
2220 cit_write_reg(gspca_dev
, 0x0004, 0x011a); /* Same on 320x240, 640x480 */
2221 cit_write_reg(gspca_dev
, 0x003f, 0x011c); /* Same on 320x240, 640x480 */
2222 cit_write_reg(gspca_dev
, 0x0022, 0x012a); /* Same */
2223 cit_write_reg(gspca_dev
, 0x001c, 0x0118); /* Same on 320x240, 640x480 */
2224 cit_model3_Packet1(gspca_dev
, 0x0021, 0x0001); /* Same */
2225 cit_write_reg(gspca_dev
, compression
, 0x0109);
2226 cit_write_reg(gspca_dev
, 0x0040, 0x0101);
2227 cit_write_reg(gspca_dev
, 0x0040, 0x0103);
2228 cit_write_reg(gspca_dev
, 0x0000, 0x0132); /* Same on 320x240, 640x480 */
2233 cit_model3_Packet1(gspca_dev
, 0x007e, 0x000e); /* Hue */
2234 cit_model3_Packet1(gspca_dev
, 0x0036, 0x0011); /* Brightness */
2235 cit_model3_Packet1(gspca_dev
, 0x0060, 0x0002); /* Sharpness */
2236 cit_model3_Packet1(gspca_dev
, 0x0061, 0x0004); /* Sharpness */
2237 cit_model3_Packet1(gspca_dev
, 0x0062, 0x0005); /* Sharpness */
2238 cit_model3_Packet1(gspca_dev
, 0x0063, 0x0014); /* Sharpness */
2239 cit_model3_Packet1(gspca_dev
, 0x0096, 0x00a0); /* Red sharpness */
2240 cit_model3_Packet1(gspca_dev
, 0x0097, 0x0096); /* Blue sharpness */
2241 cit_model3_Packet1(gspca_dev
, 0x0067, 0x0001); /* Contrast */
2242 cit_model3_Packet1(gspca_dev
, 0x005b, 0x000c); /* Contrast */
2243 cit_model3_Packet1(gspca_dev
, 0x005c, 0x0016); /* Contrast */
2244 cit_model3_Packet1(gspca_dev
, 0x0098, 0x000b);
2245 cit_model3_Packet1(gspca_dev
, 0x002c, 0x0003); /* Was 1, broke 640x480 */
2246 cit_model3_Packet1(gspca_dev
, 0x002f, 0x002a);
2247 cit_model3_Packet1(gspca_dev
, 0x0030, 0x0029);
2248 cit_model3_Packet1(gspca_dev
, 0x0037, 0x0002);
2249 cit_model3_Packet1(gspca_dev
, 0x0038, 0x0059);
2250 cit_model3_Packet1(gspca_dev
, 0x003d, 0x002e);
2251 cit_model3_Packet1(gspca_dev
, 0x003e, 0x0028);
2252 cit_model3_Packet1(gspca_dev
, 0x0078, 0x0005);
2253 cit_model3_Packet1(gspca_dev
, 0x007b, 0x0011);
2254 cit_model3_Packet1(gspca_dev
, 0x007d, 0x004b);
2255 cit_model3_Packet1(gspca_dev
, 0x007f, 0x0022);
2256 cit_model3_Packet1(gspca_dev
, 0x0080, 0x000c);
2257 cit_model3_Packet1(gspca_dev
, 0x0081, 0x000b);
2258 cit_model3_Packet1(gspca_dev
, 0x0083, 0x00fd);
2259 cit_model3_Packet1(gspca_dev
, 0x0086, 0x000b);
2260 cit_model3_Packet1(gspca_dev
, 0x0087, 0x000b);
2261 cit_model3_Packet1(gspca_dev
, 0x007e, 0x000e);
2262 cit_model3_Packet1(gspca_dev
, 0x0096, 0x00a0); /* Red sharpness */
2263 cit_model3_Packet1(gspca_dev
, 0x0097, 0x0096); /* Blue sharpness */
2264 cit_model3_Packet1(gspca_dev
, 0x0098, 0x000b);
2266 /* FIXME we should probably use cit_get_clock_div() here (in
2267 combination with isoc negotiation using the programmable isoc size)
2268 like with the IBM netcam pro). */
2269 cit_write_reg(gspca_dev
, clock_div
, 0x0111); /* Clock Divider */
2271 switch (gspca_dev
->width
) {
2273 cit_model3_Packet1(gspca_dev
, 0x001f, 0x0000); /* Same */
2274 cit_model3_Packet1(gspca_dev
, 0x0039, 0x001f); /* Same */
2275 cit_model3_Packet1(gspca_dev
, 0x003b, 0x003c); /* Same */
2276 cit_model3_Packet1(gspca_dev
, 0x0040, 0x000a);
2277 cit_model3_Packet1(gspca_dev
, 0x0051, 0x000a);
2280 cit_model3_Packet1(gspca_dev
, 0x001f, 0x0000); /* Same */
2281 cit_model3_Packet1(gspca_dev
, 0x0039, 0x001f); /* Same */
2282 cit_model3_Packet1(gspca_dev
, 0x003b, 0x003c); /* Same */
2283 cit_model3_Packet1(gspca_dev
, 0x0040, 0x0008);
2284 cit_model3_Packet1(gspca_dev
, 0x0051, 0x000b);
2287 cit_model3_Packet1(gspca_dev
, 0x001f, 0x0002); /* !Same */
2288 cit_model3_Packet1(gspca_dev
, 0x0039, 0x003e); /* !Same */
2289 cit_model3_Packet1(gspca_dev
, 0x0040, 0x0008);
2290 cit_model3_Packet1(gspca_dev
, 0x0051, 0x000a);
2294 /* if (sd->input_index) { */
2296 for (i
= 0; i
< ARRAY_SIZE(rca_initdata
); i
++) {
2297 if (rca_initdata
[i
][0])
2298 cit_read_reg(gspca_dev
, rca_initdata
[i
][2], 0);
2300 cit_write_reg(gspca_dev
, rca_initdata
[i
][1],
2301 rca_initdata
[i
][2]);
2308 static int cit_start_model4(struct gspca_dev
*gspca_dev
)
2310 struct sd
*sd
= (struct sd
*) gspca_dev
;
2312 cit_write_reg(gspca_dev
, 0x0000, 0x0100);
2313 cit_write_reg(gspca_dev
, 0x00c0, 0x0111);
2314 cit_write_reg(gspca_dev
, 0x00bc, 0x012c);
2315 cit_write_reg(gspca_dev
, 0x0080, 0x012b);
2316 cit_write_reg(gspca_dev
, 0x0000, 0x0108);
2317 cit_write_reg(gspca_dev
, 0x0001, 0x0133);
2318 cit_write_reg(gspca_dev
, 0x009b, 0x010f);
2319 cit_write_reg(gspca_dev
, 0x00bb, 0x010f);
2320 cit_model4_Packet1(gspca_dev
, 0x0038, 0x0000);
2321 cit_model4_Packet1(gspca_dev
, 0x000a, 0x005c);
2323 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2324 cit_write_reg(gspca_dev
, 0x0004, 0x012f);
2325 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2326 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2327 cit_write_reg(gspca_dev
, 0x00fb, 0x012e);
2328 cit_write_reg(gspca_dev
, 0x0000, 0x0130);
2329 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2330 cit_write_reg(gspca_dev
, 0x00aa, 0x012f);
2331 cit_write_reg(gspca_dev
, 0xd055, 0x0124);
2332 cit_write_reg(gspca_dev
, 0x000c, 0x0127);
2333 cit_write_reg(gspca_dev
, 0x0009, 0x012e);
2334 cit_write_reg(gspca_dev
, 0xaa28, 0x0124);
2336 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2337 cit_write_reg(gspca_dev
, 0x0012, 0x012f);
2338 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2339 cit_write_reg(gspca_dev
, 0x0008, 0x0127);
2340 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2341 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2342 cit_write_reg(gspca_dev
, 0x002a, 0x012d);
2343 cit_write_reg(gspca_dev
, 0x0000, 0x012f);
2344 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2345 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2346 cit_model4_Packet1(gspca_dev
, 0x0034, 0x0000);
2348 switch (gspca_dev
->width
) {
2349 case 128: /* 128x96 */
2350 cit_write_reg(gspca_dev
, 0x0070, 0x0119);
2351 cit_write_reg(gspca_dev
, 0x00d0, 0x0111);
2352 cit_write_reg(gspca_dev
, 0x0039, 0x010a);
2353 cit_write_reg(gspca_dev
, 0x0001, 0x0102);
2354 cit_write_reg(gspca_dev
, 0x0028, 0x0103);
2355 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
2356 cit_write_reg(gspca_dev
, 0x001e, 0x0105);
2357 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2358 cit_write_reg(gspca_dev
, 0x0016, 0x012f);
2359 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2360 cit_write_reg(gspca_dev
, 0x000a, 0x0127);
2361 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2362 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2363 cit_write_reg(gspca_dev
, 0x0014, 0x012d);
2364 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2365 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2366 cit_write_reg(gspca_dev
, 0x00aa, 0x012e);
2367 cit_write_reg(gspca_dev
, 0x001a, 0x0130);
2368 cit_write_reg(gspca_dev
, 0x8a0a, 0x0124);
2369 cit_write_reg(gspca_dev
, 0x005a, 0x012d);
2370 cit_write_reg(gspca_dev
, 0x9545, 0x0124);
2371 cit_write_reg(gspca_dev
, 0x00aa, 0x0127);
2372 cit_write_reg(gspca_dev
, 0x0018, 0x012e);
2373 cit_write_reg(gspca_dev
, 0x0043, 0x0130);
2374 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2375 cit_write_reg(gspca_dev
, 0x00aa, 0x012f);
2376 cit_write_reg(gspca_dev
, 0xd055, 0x0124);
2377 cit_write_reg(gspca_dev
, 0x001c, 0x0127);
2378 cit_write_reg(gspca_dev
, 0x00eb, 0x012e);
2379 cit_write_reg(gspca_dev
, 0xaa28, 0x0124);
2380 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2381 cit_write_reg(gspca_dev
, 0x0032, 0x012f);
2382 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2383 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2384 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2385 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2386 cit_write_reg(gspca_dev
, 0x0036, 0x012d);
2387 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2388 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2389 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2390 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2391 cit_write_reg(gspca_dev
, 0x001e, 0x012f);
2392 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2393 cit_write_reg(gspca_dev
, 0x0017, 0x0127);
2394 cit_write_reg(gspca_dev
, 0x0013, 0x012e);
2395 cit_write_reg(gspca_dev
, 0x0031, 0x0130);
2396 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2397 cit_write_reg(gspca_dev
, 0x0017, 0x012d);
2398 cit_write_reg(gspca_dev
, 0x0078, 0x012f);
2399 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2400 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2401 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
2404 case 160: /* 160x120 */
2405 cit_write_reg(gspca_dev
, 0x0038, 0x0119);
2406 cit_write_reg(gspca_dev
, 0x00d0, 0x0111);
2407 cit_write_reg(gspca_dev
, 0x00b9, 0x010a);
2408 cit_write_reg(gspca_dev
, 0x0001, 0x0102);
2409 cit_write_reg(gspca_dev
, 0x0028, 0x0103);
2410 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
2411 cit_write_reg(gspca_dev
, 0x001e, 0x0105);
2412 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2413 cit_write_reg(gspca_dev
, 0x0016, 0x012f);
2414 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2415 cit_write_reg(gspca_dev
, 0x000b, 0x0127);
2416 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2417 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2418 cit_write_reg(gspca_dev
, 0x0014, 0x012d);
2419 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2420 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2421 cit_write_reg(gspca_dev
, 0x00aa, 0x012e);
2422 cit_write_reg(gspca_dev
, 0x001a, 0x0130);
2423 cit_write_reg(gspca_dev
, 0x8a0a, 0x0124);
2424 cit_write_reg(gspca_dev
, 0x005a, 0x012d);
2425 cit_write_reg(gspca_dev
, 0x9545, 0x0124);
2426 cit_write_reg(gspca_dev
, 0x00aa, 0x0127);
2427 cit_write_reg(gspca_dev
, 0x0018, 0x012e);
2428 cit_write_reg(gspca_dev
, 0x0043, 0x0130);
2429 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2430 cit_write_reg(gspca_dev
, 0x00aa, 0x012f);
2431 cit_write_reg(gspca_dev
, 0xd055, 0x0124);
2432 cit_write_reg(gspca_dev
, 0x001c, 0x0127);
2433 cit_write_reg(gspca_dev
, 0x00c7, 0x012e);
2434 cit_write_reg(gspca_dev
, 0xaa28, 0x0124);
2435 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2436 cit_write_reg(gspca_dev
, 0x0032, 0x012f);
2437 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2438 cit_write_reg(gspca_dev
, 0x0025, 0x0127);
2439 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2440 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2441 cit_write_reg(gspca_dev
, 0x0036, 0x012d);
2442 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2443 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2444 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2445 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2446 cit_write_reg(gspca_dev
, 0x001e, 0x012f);
2447 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2448 cit_write_reg(gspca_dev
, 0x0048, 0x0127);
2449 cit_write_reg(gspca_dev
, 0x0035, 0x012e);
2450 cit_write_reg(gspca_dev
, 0x00d0, 0x0130);
2451 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2452 cit_write_reg(gspca_dev
, 0x0048, 0x012d);
2453 cit_write_reg(gspca_dev
, 0x0090, 0x012f);
2454 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2455 cit_write_reg(gspca_dev
, 0x0001, 0x0127);
2456 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
2459 case 176: /* 176x144 */
2460 cit_write_reg(gspca_dev
, 0x0038, 0x0119);
2461 cit_write_reg(gspca_dev
, 0x00d0, 0x0111);
2462 cit_write_reg(gspca_dev
, 0x00b9, 0x010a);
2463 cit_write_reg(gspca_dev
, 0x0001, 0x0102);
2464 cit_write_reg(gspca_dev
, 0x002c, 0x0103);
2465 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
2466 cit_write_reg(gspca_dev
, 0x0024, 0x0105);
2467 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2468 cit_write_reg(gspca_dev
, 0x0016, 0x012f);
2469 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2470 cit_write_reg(gspca_dev
, 0x0007, 0x0127);
2471 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2472 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2473 cit_write_reg(gspca_dev
, 0x0014, 0x012d);
2474 cit_write_reg(gspca_dev
, 0x0001, 0x012f);
2475 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2476 cit_write_reg(gspca_dev
, 0x00aa, 0x012e);
2477 cit_write_reg(gspca_dev
, 0x001a, 0x0130);
2478 cit_write_reg(gspca_dev
, 0x8a0a, 0x0124);
2479 cit_write_reg(gspca_dev
, 0x005e, 0x012d);
2480 cit_write_reg(gspca_dev
, 0x9545, 0x0124);
2481 cit_write_reg(gspca_dev
, 0x00aa, 0x0127);
2482 cit_write_reg(gspca_dev
, 0x0018, 0x012e);
2483 cit_write_reg(gspca_dev
, 0x0049, 0x0130);
2484 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2485 cit_write_reg(gspca_dev
, 0x00aa, 0x012f);
2486 cit_write_reg(gspca_dev
, 0xd055, 0x0124);
2487 cit_write_reg(gspca_dev
, 0x001c, 0x0127);
2488 cit_write_reg(gspca_dev
, 0x00c7, 0x012e);
2489 cit_write_reg(gspca_dev
, 0xaa28, 0x0124);
2490 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2491 cit_write_reg(gspca_dev
, 0x0032, 0x012f);
2492 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2493 cit_write_reg(gspca_dev
, 0x0028, 0x0127);
2494 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2495 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2496 cit_write_reg(gspca_dev
, 0x0036, 0x012d);
2497 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2498 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2499 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2500 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2501 cit_write_reg(gspca_dev
, 0x001e, 0x012f);
2502 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2503 cit_write_reg(gspca_dev
, 0x0010, 0x0127);
2504 cit_write_reg(gspca_dev
, 0x0013, 0x012e);
2505 cit_write_reg(gspca_dev
, 0x002a, 0x0130);
2506 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2507 cit_write_reg(gspca_dev
, 0x0010, 0x012d);
2508 cit_write_reg(gspca_dev
, 0x006d, 0x012f);
2509 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2510 cit_write_reg(gspca_dev
, 0x0001, 0x0127);
2511 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
2512 /* TESTME HDG: this does not seem right
2513 (it is 2 for all other resolutions) */
2516 case 320: /* 320x240 */
2517 cit_write_reg(gspca_dev
, 0x0070, 0x0119);
2518 cit_write_reg(gspca_dev
, 0x00d0, 0x0111);
2519 cit_write_reg(gspca_dev
, 0x0039, 0x010a);
2520 cit_write_reg(gspca_dev
, 0x0001, 0x0102);
2521 cit_write_reg(gspca_dev
, 0x0028, 0x0103);
2522 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
2523 cit_write_reg(gspca_dev
, 0x001e, 0x0105);
2524 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2525 cit_write_reg(gspca_dev
, 0x0016, 0x012f);
2526 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2527 cit_write_reg(gspca_dev
, 0x000a, 0x0127);
2528 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2529 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2530 cit_write_reg(gspca_dev
, 0x0014, 0x012d);
2531 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2532 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2533 cit_write_reg(gspca_dev
, 0x00aa, 0x012e);
2534 cit_write_reg(gspca_dev
, 0x001a, 0x0130);
2535 cit_write_reg(gspca_dev
, 0x8a0a, 0x0124);
2536 cit_write_reg(gspca_dev
, 0x005a, 0x012d);
2537 cit_write_reg(gspca_dev
, 0x9545, 0x0124);
2538 cit_write_reg(gspca_dev
, 0x00aa, 0x0127);
2539 cit_write_reg(gspca_dev
, 0x0018, 0x012e);
2540 cit_write_reg(gspca_dev
, 0x0043, 0x0130);
2541 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2542 cit_write_reg(gspca_dev
, 0x00aa, 0x012f);
2543 cit_write_reg(gspca_dev
, 0xd055, 0x0124);
2544 cit_write_reg(gspca_dev
, 0x001c, 0x0127);
2545 cit_write_reg(gspca_dev
, 0x00eb, 0x012e);
2546 cit_write_reg(gspca_dev
, 0xaa28, 0x0124);
2547 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2548 cit_write_reg(gspca_dev
, 0x0032, 0x012f);
2549 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2550 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2551 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2552 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2553 cit_write_reg(gspca_dev
, 0x0036, 0x012d);
2554 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2555 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2556 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2557 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2558 cit_write_reg(gspca_dev
, 0x001e, 0x012f);
2559 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2560 cit_write_reg(gspca_dev
, 0x0017, 0x0127);
2561 cit_write_reg(gspca_dev
, 0x0013, 0x012e);
2562 cit_write_reg(gspca_dev
, 0x0031, 0x0130);
2563 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2564 cit_write_reg(gspca_dev
, 0x0017, 0x012d);
2565 cit_write_reg(gspca_dev
, 0x0078, 0x012f);
2566 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2567 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2568 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
2571 case 352: /* 352x288 */
2572 cit_write_reg(gspca_dev
, 0x0070, 0x0119);
2573 cit_write_reg(gspca_dev
, 0x00c0, 0x0111);
2574 cit_write_reg(gspca_dev
, 0x0039, 0x010a);
2575 cit_write_reg(gspca_dev
, 0x0001, 0x0102);
2576 cit_write_reg(gspca_dev
, 0x002c, 0x0103);
2577 cit_write_reg(gspca_dev
, 0x0000, 0x0104);
2578 cit_write_reg(gspca_dev
, 0x0024, 0x0105);
2579 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2580 cit_write_reg(gspca_dev
, 0x0016, 0x012f);
2581 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2582 cit_write_reg(gspca_dev
, 0x0006, 0x0127);
2583 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2584 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2585 cit_write_reg(gspca_dev
, 0x0014, 0x012d);
2586 cit_write_reg(gspca_dev
, 0x0002, 0x012f);
2587 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2588 cit_write_reg(gspca_dev
, 0x00aa, 0x012e);
2589 cit_write_reg(gspca_dev
, 0x001a, 0x0130);
2590 cit_write_reg(gspca_dev
, 0x8a0a, 0x0124);
2591 cit_write_reg(gspca_dev
, 0x005e, 0x012d);
2592 cit_write_reg(gspca_dev
, 0x9545, 0x0124);
2593 cit_write_reg(gspca_dev
, 0x00aa, 0x0127);
2594 cit_write_reg(gspca_dev
, 0x0018, 0x012e);
2595 cit_write_reg(gspca_dev
, 0x0049, 0x0130);
2596 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2597 cit_write_reg(gspca_dev
, 0x00aa, 0x012f);
2598 cit_write_reg(gspca_dev
, 0xd055, 0x0124);
2599 cit_write_reg(gspca_dev
, 0x001c, 0x0127);
2600 cit_write_reg(gspca_dev
, 0x00cf, 0x012e);
2601 cit_write_reg(gspca_dev
, 0xaa28, 0x0124);
2602 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2603 cit_write_reg(gspca_dev
, 0x0032, 0x012f);
2604 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2605 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2606 cit_write_reg(gspca_dev
, 0x00aa, 0x0130);
2607 cit_write_reg(gspca_dev
, 0x82a8, 0x0124);
2608 cit_write_reg(gspca_dev
, 0x0036, 0x012d);
2609 cit_write_reg(gspca_dev
, 0x0008, 0x012f);
2610 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2611 cit_write_reg(gspca_dev
, 0xfffa, 0x0124);
2612 cit_write_reg(gspca_dev
, 0x00aa, 0x012d);
2613 cit_write_reg(gspca_dev
, 0x001e, 0x012f);
2614 cit_write_reg(gspca_dev
, 0xd141, 0x0124);
2615 cit_write_reg(gspca_dev
, 0x0010, 0x0127);
2616 cit_write_reg(gspca_dev
, 0x0013, 0x012e);
2617 cit_write_reg(gspca_dev
, 0x0025, 0x0130);
2618 cit_write_reg(gspca_dev
, 0x8a28, 0x0124);
2619 cit_write_reg(gspca_dev
, 0x0010, 0x012d);
2620 cit_write_reg(gspca_dev
, 0x0048, 0x012f);
2621 cit_write_reg(gspca_dev
, 0xd145, 0x0124);
2622 cit_write_reg(gspca_dev
, 0x0000, 0x0127);
2623 cit_write_reg(gspca_dev
, 0xfea8, 0x0124);
2628 cit_model4_Packet1(gspca_dev
, 0x0038, 0x0004);
2633 static int cit_start_ibm_netcam_pro(struct gspca_dev
*gspca_dev
)
2635 const unsigned short compression
= 0; /* 0=none, 7=best frame rate */
2638 clock_div
= cit_get_clock_div(gspca_dev
);
2642 cit_write_reg(gspca_dev
, 0x0003, 0x0133);
2643 cit_write_reg(gspca_dev
, 0x0000, 0x0117);
2644 cit_write_reg(gspca_dev
, 0x0008, 0x0123);
2645 cit_write_reg(gspca_dev
, 0x0000, 0x0100);
2646 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
2647 /* cit_write_reg(gspca_dev, 0x0002, 0x0112); see sd_stop0 */
2648 cit_write_reg(gspca_dev
, 0x0000, 0x0133);
2649 cit_write_reg(gspca_dev
, 0x0000, 0x0123);
2650 cit_write_reg(gspca_dev
, 0x0001, 0x0117);
2651 cit_write_reg(gspca_dev
, 0x0040, 0x0108);
2652 cit_write_reg(gspca_dev
, 0x0019, 0x012c);
2653 cit_write_reg(gspca_dev
, 0x0060, 0x0116);
2654 /* cit_write_reg(gspca_dev, 0x000b, 0x0115); see sd_stop0 */
2656 cit_model3_Packet1(gspca_dev
, 0x0049, 0x0000);
2658 cit_write_reg(gspca_dev
, 0x0000, 0x0101); /* Same on 160x120, 320x240 */
2659 cit_write_reg(gspca_dev
, 0x003a, 0x0102); /* Hstart */
2660 cit_write_reg(gspca_dev
, 0x00a0, 0x0103); /* Same on 160x120, 320x240 */
2661 cit_write_reg(gspca_dev
, 0x0078, 0x0105); /* Same on 160x120, 320x240 */
2662 cit_write_reg(gspca_dev
, 0x0000, 0x010a); /* Same */
2663 cit_write_reg(gspca_dev
, 0x0002, 0x011d); /* Same on 160x120, 320x240 */
2664 cit_write_reg(gspca_dev
, 0x0000, 0x0129); /* Same */
2665 cit_write_reg(gspca_dev
, 0x00fc, 0x012b); /* Same */
2666 cit_write_reg(gspca_dev
, 0x0022, 0x012a); /* Same */
2668 switch (gspca_dev
->width
) {
2669 case 160: /* 160x120 */
2670 cit_write_reg(gspca_dev
, 0x0024, 0x010b);
2671 cit_write_reg(gspca_dev
, 0x0089, 0x0119);
2672 cit_write_reg(gspca_dev
, 0x000a, 0x011b);
2673 cit_write_reg(gspca_dev
, 0x0003, 0x011e);
2674 cit_write_reg(gspca_dev
, 0x0007, 0x0104);
2675 cit_write_reg(gspca_dev
, 0x0009, 0x011a);
2676 cit_write_reg(gspca_dev
, 0x008b, 0x011c);
2677 cit_write_reg(gspca_dev
, 0x0008, 0x0118);
2678 cit_write_reg(gspca_dev
, 0x0000, 0x0132);
2680 case 320: /* 320x240 */
2681 cit_write_reg(gspca_dev
, 0x0028, 0x010b);
2682 cit_write_reg(gspca_dev
, 0x00d9, 0x0119);
2683 cit_write_reg(gspca_dev
, 0x0006, 0x011b);
2684 cit_write_reg(gspca_dev
, 0x0000, 0x011e);
2685 cit_write_reg(gspca_dev
, 0x000e, 0x0104);
2686 cit_write_reg(gspca_dev
, 0x0004, 0x011a);
2687 cit_write_reg(gspca_dev
, 0x003f, 0x011c);
2688 cit_write_reg(gspca_dev
, 0x000c, 0x0118);
2689 cit_write_reg(gspca_dev
, 0x0000, 0x0132);
2693 cit_model3_Packet1(gspca_dev
, 0x0019, 0x0031);
2694 cit_model3_Packet1(gspca_dev
, 0x001a, 0x0003);
2695 cit_model3_Packet1(gspca_dev
, 0x001b, 0x0038);
2696 cit_model3_Packet1(gspca_dev
, 0x001c, 0x0000);
2697 cit_model3_Packet1(gspca_dev
, 0x0024, 0x0001);
2698 cit_model3_Packet1(gspca_dev
, 0x0027, 0x0001);
2699 cit_model3_Packet1(gspca_dev
, 0x002a, 0x0004);
2700 cit_model3_Packet1(gspca_dev
, 0x0035, 0x000b);
2701 cit_model3_Packet1(gspca_dev
, 0x003f, 0x0001);
2702 cit_model3_Packet1(gspca_dev
, 0x0044, 0x0000);
2703 cit_model3_Packet1(gspca_dev
, 0x0054, 0x0000);
2704 cit_model3_Packet1(gspca_dev
, 0x00c4, 0x0000);
2705 cit_model3_Packet1(gspca_dev
, 0x00e7, 0x0001);
2706 cit_model3_Packet1(gspca_dev
, 0x00e9, 0x0001);
2707 cit_model3_Packet1(gspca_dev
, 0x00ee, 0x0000);
2708 cit_model3_Packet1(gspca_dev
, 0x00f3, 0x00c0);
2710 cit_write_reg(gspca_dev
, compression
, 0x0109);
2711 cit_write_reg(gspca_dev
, clock_div
, 0x0111);
2713 /* if (sd->input_index) { */
2715 for (i
= 0; i
< ARRAY_SIZE(rca_initdata
); i
++) {
2716 if (rca_initdata
[i
][0])
2717 cit_read_reg(gspca_dev
, rca_initdata
[i
][2], 0);
2719 cit_write_reg(gspca_dev
, rca_initdata
[i
][1],
2720 rca_initdata
[i
][2]);
2727 /* -- start the camera -- */
2728 static int sd_start(struct gspca_dev
*gspca_dev
)
2730 struct sd
*sd
= (struct sd
*) gspca_dev
;
2733 packet_size
= cit_get_packet_size(gspca_dev
);
2734 if (packet_size
< 0)
2737 switch (sd
->model
) {
2739 cit_start_model0(gspca_dev
);
2742 cit_start_model1(gspca_dev
);
2745 cit_start_model2(gspca_dev
);
2748 cit_start_model3(gspca_dev
);
2751 cit_start_model4(gspca_dev
);
2753 case CIT_IBM_NETCAM_PRO
:
2754 cit_start_ibm_netcam_pro(gspca_dev
);
2758 cit_set_brightness(gspca_dev
);
2759 cit_set_contrast(gspca_dev
);
2760 cit_set_hue(gspca_dev
);
2761 cit_set_sharpness(gspca_dev
);
2762 cit_set_lighting(gspca_dev
);
2763 cit_set_hflip(gspca_dev
);
2765 /* Program max isoc packet size */
2766 cit_write_reg(gspca_dev
, packet_size
>> 8, 0x0106);
2767 cit_write_reg(gspca_dev
, packet_size
& 0xff, 0x0107);
2769 cit_restart_stream(gspca_dev
);
2774 static int sd_isoc_init(struct gspca_dev
*gspca_dev
)
2776 struct usb_host_interface
*alt
;
2777 int max_packet_size
;
2779 switch (gspca_dev
->width
) {
2781 max_packet_size
= 450;
2784 max_packet_size
= 600;
2787 max_packet_size
= 1022;
2791 /* Start isoc bandwidth "negotiation" at max isoc bandwidth */
2792 alt
= &gspca_dev
->dev
->config
->intf_cache
[0]->altsetting
[1];
2793 alt
->endpoint
[0].desc
.wMaxPacketSize
= cpu_to_le16(max_packet_size
);
2798 static int sd_isoc_nego(struct gspca_dev
*gspca_dev
)
2800 int ret
, packet_size
, min_packet_size
;
2801 struct usb_host_interface
*alt
;
2803 switch (gspca_dev
->width
) {
2805 min_packet_size
= 200;
2808 min_packet_size
= 266;
2811 min_packet_size
= 400;
2815 alt
= &gspca_dev
->dev
->config
->intf_cache
[0]->altsetting
[1];
2816 packet_size
= le16_to_cpu(alt
->endpoint
[0].desc
.wMaxPacketSize
);
2817 if (packet_size
<= min_packet_size
)
2821 if (packet_size
< min_packet_size
)
2822 packet_size
= min_packet_size
;
2823 alt
->endpoint
[0].desc
.wMaxPacketSize
= cpu_to_le16(packet_size
);
2825 ret
= usb_set_interface(gspca_dev
->dev
, gspca_dev
->iface
, 1);
2827 err("set alt 1 err %d", ret
);
2832 static void sd_stopN(struct gspca_dev
*gspca_dev
)
2834 cit_write_reg(gspca_dev
, 0x0000, 0x010c);
2837 static void sd_stop0(struct gspca_dev
*gspca_dev
)
2839 struct sd
*sd
= (struct sd
*) gspca_dev
;
2841 /* We cannot use gspca_dev->present here as that is not set when
2842 sd_init gets called and we get called from sd_init */
2843 if (!gspca_dev
->dev
)
2846 switch (sd
->model
) {
2848 /* HDG windows does this, but it causes the cams autogain to
2849 restart from a gain of 0, which does not look good when
2850 changing resolutions. */
2851 /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */
2852 cit_write_reg(gspca_dev
, 0x00c0, 0x0100); /* LED Off */
2855 cit_send_FF_04_02(gspca_dev
);
2856 cit_read_reg(gspca_dev
, 0x0100, 0);
2857 cit_write_reg(gspca_dev
, 0x81, 0x0100); /* LED Off */
2861 cit_model2_Packet1(gspca_dev
, 0x0030, 0x0004);
2863 cit_write_reg(gspca_dev
, 0x0080, 0x0100); /* LED Off */
2864 cit_write_reg(gspca_dev
, 0x0020, 0x0111);
2865 cit_write_reg(gspca_dev
, 0x00a0, 0x0111);
2867 cit_model2_Packet1(gspca_dev
, 0x0030, 0x0002);
2869 cit_write_reg(gspca_dev
, 0x0020, 0x0111);
2870 cit_write_reg(gspca_dev
, 0x0000, 0x0112);
2873 cit_write_reg(gspca_dev
, 0x0006, 0x012c);
2874 cit_model3_Packet1(gspca_dev
, 0x0046, 0x0000);
2875 cit_read_reg(gspca_dev
, 0x0116, 0);
2876 cit_write_reg(gspca_dev
, 0x0064, 0x0116);
2877 cit_read_reg(gspca_dev
, 0x0115, 0);
2878 cit_write_reg(gspca_dev
, 0x0003, 0x0115);
2879 cit_write_reg(gspca_dev
, 0x0008, 0x0123);
2880 cit_write_reg(gspca_dev
, 0x0000, 0x0117);
2881 cit_write_reg(gspca_dev
, 0x0000, 0x0112);
2882 cit_write_reg(gspca_dev
, 0x0080, 0x0100);
2884 case CIT_IBM_NETCAM_PRO
:
2885 cit_model3_Packet1(gspca_dev
, 0x0049, 0x00ff);
2886 cit_write_reg(gspca_dev
, 0x0006, 0x012c);
2887 cit_write_reg(gspca_dev
, 0x0000, 0x0116);
2888 /* HDG windows does this, but I cannot get the camera
2889 to restart with this without redoing the entire init
2890 sequence which makes switching modes really slow */
2891 /* cit_write_reg(gspca_dev, 0x0006, 0x0115); */
2892 cit_write_reg(gspca_dev
, 0x0008, 0x0123);
2893 cit_write_reg(gspca_dev
, 0x0000, 0x0117);
2894 cit_write_reg(gspca_dev
, 0x0003, 0x0133);
2895 cit_write_reg(gspca_dev
, 0x0000, 0x0111);
2896 /* HDG windows does this, but I get a green picture when
2897 restarting the stream after this */
2898 /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */
2899 cit_write_reg(gspca_dev
, 0x00c0, 0x0100);
2903 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2904 /* If the last button state is pressed, release it now! */
2905 if (sd
->button_state
) {
2906 input_report_key(gspca_dev
->input_dev
, KEY_CAMERA
, 0);
2907 input_sync(gspca_dev
->input_dev
);
2908 sd
->button_state
= 0;
2913 static u8
*cit_find_sof(struct gspca_dev
*gspca_dev
, u8
*data
, int len
)
2915 struct sd
*sd
= (struct sd
*) gspca_dev
;
2916 u8 byte3
= 0, byte4
= 0;
2919 switch (sd
->model
) {
2923 case CIT_IBM_NETCAM_PRO
:
2924 switch (gspca_dev
->width
) {
2925 case 160: /* 160x120 */
2929 case 176: /* 176x144 */
2933 case 320: /* 320x240 */
2937 case 352: /* 352x288 */
2947 /* These have a different byte3 */
2948 if (sd
->model
<= CIT_MODEL1
)
2951 for (i
= 0; i
< len
; i
++) {
2952 /* For this model the SOF always starts at offset 0
2953 so no need to search the entire frame */
2954 if (sd
->model
== CIT_MODEL0
&& sd
->sof_read
!= i
)
2957 switch (sd
->sof_read
) {
2959 if (data
[i
] == 0x00)
2963 if (data
[i
] == 0xff)
2965 else if (data
[i
] == 0x00)
2971 if (data
[i
] == byte3
)
2973 else if (data
[i
] == 0x00)
2979 if (data
[i
] == byte4
) {
2981 return data
+ i
+ (sd
->sof_len
- 3);
2983 if (byte3
== 0x00 && data
[i
] == 0xff)
2985 else if (data
[i
] == 0x00)
2995 /* TESTME we need to find a longer sof signature to avoid
2997 for (i
= 0; i
< len
; i
++) {
2998 switch (sd
->sof_read
) {
3000 if (data
[i
] == 0x00)
3005 if (data
[i
] == 0xff) {
3008 "header found at offset: %d: %02x %02x 00 %02x %02x %02x\n",
3017 "header found at offset: %d: 00 %02x %02x %02x\n",
3022 return data
+ i
+ (sd
->sof_len
- 1);
3032 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
3035 struct sd
*sd
= (struct sd
*) gspca_dev
;
3038 sof
= cit_find_sof(gspca_dev
, data
, len
);
3042 /* finish decoding current frame */
3044 if (n
> sd
->sof_len
)
3048 gspca_frame_add(gspca_dev
, LAST_PACKET
,
3050 gspca_frame_add(gspca_dev
, FIRST_PACKET
, NULL
, 0);
3055 gspca_frame_add(gspca_dev
, INTER_PACKET
, data
, len
);
3058 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
)
3060 struct sd
*sd
= (struct sd
*) gspca_dev
;
3062 sd
->brightness
= val
;
3063 if (gspca_dev
->streaming
) {
3064 if (sd
->stop_on_control_change
)
3065 sd_stopN(gspca_dev
);
3066 cit_set_brightness(gspca_dev
);
3067 if (sd
->stop_on_control_change
)
3068 cit_restart_stream(gspca_dev
);
3074 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
)
3076 struct sd
*sd
= (struct sd
*) gspca_dev
;
3078 *val
= sd
->brightness
;
3083 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
)
3085 struct sd
*sd
= (struct sd
*) gspca_dev
;
3088 if (gspca_dev
->streaming
) {
3089 if (sd
->stop_on_control_change
)
3090 sd_stopN(gspca_dev
);
3091 cit_set_contrast(gspca_dev
);
3092 if (sd
->stop_on_control_change
)
3093 cit_restart_stream(gspca_dev
);
3099 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
)
3101 struct sd
*sd
= (struct sd
*) gspca_dev
;
3103 *val
= sd
->contrast
;
3108 static int sd_sethue(struct gspca_dev
*gspca_dev
, __s32 val
)
3110 struct sd
*sd
= (struct sd
*) gspca_dev
;
3113 if (gspca_dev
->streaming
) {
3114 if (sd
->stop_on_control_change
)
3115 sd_stopN(gspca_dev
);
3116 cit_set_hue(gspca_dev
);
3117 if (sd
->stop_on_control_change
)
3118 cit_restart_stream(gspca_dev
);
3123 static int sd_gethue(struct gspca_dev
*gspca_dev
, __s32
*val
)
3125 struct sd
*sd
= (struct sd
*) gspca_dev
;
3132 static int sd_setsharpness(struct gspca_dev
*gspca_dev
, __s32 val
)
3134 struct sd
*sd
= (struct sd
*) gspca_dev
;
3136 sd
->sharpness
= val
;
3137 if (gspca_dev
->streaming
) {
3138 if (sd
->stop_on_control_change
)
3139 sd_stopN(gspca_dev
);
3140 cit_set_sharpness(gspca_dev
);
3141 if (sd
->stop_on_control_change
)
3142 cit_restart_stream(gspca_dev
);
3147 static int sd_getsharpness(struct gspca_dev
*gspca_dev
, __s32
*val
)
3149 struct sd
*sd
= (struct sd
*) gspca_dev
;
3151 *val
= sd
->sharpness
;
3156 static int sd_setlighting(struct gspca_dev
*gspca_dev
, __s32 val
)
3158 struct sd
*sd
= (struct sd
*) gspca_dev
;
3161 if (gspca_dev
->streaming
) {
3162 if (sd
->stop_on_control_change
)
3163 sd_stopN(gspca_dev
);
3164 cit_set_lighting(gspca_dev
);
3165 if (sd
->stop_on_control_change
)
3166 cit_restart_stream(gspca_dev
);
3171 static int sd_getlighting(struct gspca_dev
*gspca_dev
, __s32
*val
)
3173 struct sd
*sd
= (struct sd
*) gspca_dev
;
3175 *val
= sd
->lighting
;
3180 static int sd_sethflip(struct gspca_dev
*gspca_dev
, __s32 val
)
3182 struct sd
*sd
= (struct sd
*) gspca_dev
;
3185 if (gspca_dev
->streaming
) {
3186 if (sd
->stop_on_control_change
)
3187 sd_stopN(gspca_dev
);
3188 cit_set_hflip(gspca_dev
);
3189 if (sd
->stop_on_control_change
)
3190 cit_restart_stream(gspca_dev
);
3195 static int sd_gethflip(struct gspca_dev
*gspca_dev
, __s32
*val
)
3197 struct sd
*sd
= (struct sd
*) gspca_dev
;
3204 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3205 static void cit_check_button(struct gspca_dev
*gspca_dev
)
3207 int new_button_state
;
3208 struct sd
*sd
= (struct sd
*)gspca_dev
;
3210 switch (sd
->model
) {
3212 case CIT_IBM_NETCAM_PRO
:
3214 default: /* TEST ME unknown if this works on other models too */
3218 /* Read the button state */
3219 cit_read_reg(gspca_dev
, 0x0113, 0);
3220 new_button_state
= !gspca_dev
->usb_buf
[0];
3222 /* Tell the cam we've seen the button press, notice that this
3223 is a nop (iow the cam keeps reporting pressed) until the
3224 button is actually released. */
3225 if (new_button_state
)
3226 cit_write_reg(gspca_dev
, 0x01, 0x0113);
3228 if (sd
->button_state
!= new_button_state
) {
3229 input_report_key(gspca_dev
->input_dev
, KEY_CAMERA
,
3231 input_sync(gspca_dev
->input_dev
);
3232 sd
->button_state
= new_button_state
;
3237 /* sub-driver description */
3238 static const struct sd_desc sd_desc
= {
3239 .name
= MODULE_NAME
,
3241 .nctrls
= ARRAY_SIZE(sd_ctrls
),
3242 .config
= sd_config
,
3247 .pkt_scan
= sd_pkt_scan
,
3248 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3249 .dq_callback
= cit_check_button
,
3254 static const struct sd_desc sd_desc_isoc_nego
= {
3255 .name
= MODULE_NAME
,
3257 .nctrls
= ARRAY_SIZE(sd_ctrls
),
3258 .config
= sd_config
,
3261 .isoc_init
= sd_isoc_init
,
3262 .isoc_nego
= sd_isoc_nego
,
3265 .pkt_scan
= sd_pkt_scan
,
3266 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3267 .dq_callback
= cit_check_button
,
3272 /* -- module initialisation -- */
3273 static const struct usb_device_id device_table
[] = {
3274 { USB_DEVICE_VER(0x0545, 0x8080, 0x0001, 0x0001), .driver_info
= CIT_MODEL0
},
3275 { USB_DEVICE_VER(0x0545, 0x8080, 0x0002, 0x0002), .driver_info
= CIT_MODEL1
},
3276 { USB_DEVICE_VER(0x0545, 0x8080, 0x030a, 0x030a), .driver_info
= CIT_MODEL2
},
3277 { USB_DEVICE_VER(0x0545, 0x8080, 0x0301, 0x0301), .driver_info
= CIT_MODEL3
},
3278 { USB_DEVICE_VER(0x0545, 0x8002, 0x030a, 0x030a), .driver_info
= CIT_MODEL4
},
3279 { USB_DEVICE_VER(0x0545, 0x800c, 0x030a, 0x030a), .driver_info
= CIT_MODEL2
},
3280 { USB_DEVICE_VER(0x0545, 0x800d, 0x030a, 0x030a), .driver_info
= CIT_MODEL4
},
3283 MODULE_DEVICE_TABLE(usb
, device_table
);
3285 /* -- device connect -- */
3286 static int sd_probe(struct usb_interface
*intf
,
3287 const struct usb_device_id
*id
)
3289 const struct sd_desc
*desc
= &sd_desc
;
3291 switch (id
->driver_info
) {
3294 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
!= 2)
3299 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
!= 0)
3303 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
!= 0)
3305 /* FIXME this likely applies to all model3 cams and probably
3306 to other models too. */
3308 desc
= &sd_desc_isoc_nego
;
3312 return gspca_dev_probe2(intf
, id
, desc
, sizeof(struct sd
), THIS_MODULE
);
3315 static struct usb_driver sd_driver
= {
3316 .name
= MODULE_NAME
,
3317 .id_table
= device_table
,
3319 .disconnect
= gspca_disconnect
,
3321 .suspend
= gspca_suspend
,
3322 .resume
= gspca_resume
,
3326 /* -- module insert / remove -- */
3327 static int __init
sd_mod_init(void)
3329 return usb_register(&sd_driver
);
3331 static void __exit
sd_mod_exit(void)
3333 usb_deregister(&sd_driver
);
3336 module_init(sd_mod_init
);
3337 module_exit(sd_mod_exit
);