diff options
Diffstat (limited to 'drivers/media/video/gspca/xirlink_cit.c')
-rw-r--r-- | drivers/media/video/gspca/xirlink_cit.c | 194 |
1 files changed, 139 insertions, 55 deletions
diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c index 8715577bc2d8..5b5039a02031 100644 --- a/drivers/media/video/gspca/xirlink_cit.c +++ b/drivers/media/video/gspca/xirlink_cit.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #define MODULE_NAME "xirlink-cit" | 30 | #define MODULE_NAME "xirlink-cit" |
31 | 31 | ||
32 | #include <linux/input.h> | ||
32 | #include "gspca.h" | 33 | #include "gspca.h" |
33 | 34 | ||
34 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); | 35 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
@@ -58,6 +59,7 @@ struct sd { | |||
58 | #define CIT_MODEL4 4 | 59 | #define CIT_MODEL4 4 |
59 | #define CIT_IBM_NETCAM_PRO 5 | 60 | #define CIT_IBM_NETCAM_PRO 5 |
60 | u8 input_index; | 61 | u8 input_index; |
62 | u8 button_state; | ||
61 | u8 stop_on_control_change; | 63 | u8 stop_on_control_change; |
62 | u8 sof_read; | 64 | u8 sof_read; |
63 | u8 sof_len; | 65 | u8 sof_len; |
@@ -185,60 +187,60 @@ static const struct ctrl sd_ctrls[] = { | |||
185 | static const struct v4l2_pix_format cif_yuv_mode[] = { | 187 | static const struct v4l2_pix_format cif_yuv_mode[] = { |
186 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 188 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
187 | .bytesperline = 176, | 189 | .bytesperline = 176, |
188 | .sizeimage = 176 * 144 * 3 / 2, | 190 | .sizeimage = 176 * 144 * 3 / 2 + 4, |
189 | .colorspace = V4L2_COLORSPACE_SRGB}, | 191 | .colorspace = V4L2_COLORSPACE_SRGB}, |
190 | {352, 288, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 192 | {352, 288, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
191 | .bytesperline = 352, | 193 | .bytesperline = 352, |
192 | .sizeimage = 352 * 288 * 3 / 2, | 194 | .sizeimage = 352 * 288 * 3 / 2 + 4, |
193 | .colorspace = V4L2_COLORSPACE_SRGB}, | 195 | .colorspace = V4L2_COLORSPACE_SRGB}, |
194 | }; | 196 | }; |
195 | 197 | ||
196 | static const struct v4l2_pix_format vga_yuv_mode[] = { | 198 | static const struct v4l2_pix_format vga_yuv_mode[] = { |
197 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 199 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
198 | .bytesperline = 160, | 200 | .bytesperline = 160, |
199 | .sizeimage = 160 * 120 * 3 / 2, | 201 | .sizeimage = 160 * 120 * 3 / 2 + 4, |
200 | .colorspace = V4L2_COLORSPACE_SRGB}, | 202 | .colorspace = V4L2_COLORSPACE_SRGB}, |
201 | {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 203 | {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
202 | .bytesperline = 320, | 204 | .bytesperline = 320, |
203 | .sizeimage = 320 * 240 * 3 / 2, | 205 | .sizeimage = 320 * 240 * 3 / 2 + 4, |
204 | .colorspace = V4L2_COLORSPACE_SRGB}, | 206 | .colorspace = V4L2_COLORSPACE_SRGB}, |
205 | {640, 480, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 207 | {640, 480, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
206 | .bytesperline = 640, | 208 | .bytesperline = 640, |
207 | .sizeimage = 640 * 480 * 3 / 2, | 209 | .sizeimage = 640 * 480 * 3 / 2 + 4, |
208 | .colorspace = V4L2_COLORSPACE_SRGB}, | 210 | .colorspace = V4L2_COLORSPACE_SRGB}, |
209 | }; | 211 | }; |
210 | 212 | ||
211 | static const struct v4l2_pix_format model0_mode[] = { | 213 | static const struct v4l2_pix_format model0_mode[] = { |
212 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 214 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
213 | .bytesperline = 160, | 215 | .bytesperline = 160, |
214 | .sizeimage = 160 * 120 * 3 / 2, | 216 | .sizeimage = 160 * 120 * 3 / 2 + 4, |
215 | .colorspace = V4L2_COLORSPACE_SRGB}, | 217 | .colorspace = V4L2_COLORSPACE_SRGB}, |
216 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 218 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
217 | .bytesperline = 176, | 219 | .bytesperline = 176, |
218 | .sizeimage = 176 * 144 * 3 / 2, | 220 | .sizeimage = 176 * 144 * 3 / 2 + 4, |
219 | .colorspace = V4L2_COLORSPACE_SRGB}, | 221 | .colorspace = V4L2_COLORSPACE_SRGB}, |
220 | {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 222 | {320, 240, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
221 | .bytesperline = 320, | 223 | .bytesperline = 320, |
222 | .sizeimage = 320 * 240 * 3 / 2, | 224 | .sizeimage = 320 * 240 * 3 / 2 + 4, |
223 | .colorspace = V4L2_COLORSPACE_SRGB}, | 225 | .colorspace = V4L2_COLORSPACE_SRGB}, |
224 | }; | 226 | }; |
225 | 227 | ||
226 | static const struct v4l2_pix_format model2_mode[] = { | 228 | static const struct v4l2_pix_format model2_mode[] = { |
227 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 229 | {160, 120, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
228 | .bytesperline = 160, | 230 | .bytesperline = 160, |
229 | .sizeimage = 160 * 120 * 3 / 2, | 231 | .sizeimage = 160 * 120 * 3 / 2 + 4, |
230 | .colorspace = V4L2_COLORSPACE_SRGB}, | 232 | .colorspace = V4L2_COLORSPACE_SRGB}, |
231 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, | 233 | {176, 144, V4L2_PIX_FMT_CIT_YYVYUY, V4L2_FIELD_NONE, |
232 | .bytesperline = 176, | 234 | .bytesperline = 176, |
233 | .sizeimage = 176 * 144 * 3 / 2, | 235 | .sizeimage = 176 * 144 * 3 / 2 + 4, |
234 | .colorspace = V4L2_COLORSPACE_SRGB}, | 236 | .colorspace = V4L2_COLORSPACE_SRGB}, |
235 | {320, 240, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | 237 | {320, 240, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, |
236 | .bytesperline = 320, | 238 | .bytesperline = 320, |
237 | .sizeimage = 320 * 240, | 239 | .sizeimage = 320 * 240 + 4, |
238 | .colorspace = V4L2_COLORSPACE_SRGB}, | 240 | .colorspace = V4L2_COLORSPACE_SRGB}, |
239 | {352, 288, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, | 241 | {352, 288, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, |
240 | .bytesperline = 352, | 242 | .bytesperline = 352, |
241 | .sizeimage = 352 * 288, | 243 | .sizeimage = 352 * 288 + 4, |
242 | .colorspace = V4L2_COLORSPACE_SRGB}, | 244 | .colorspace = V4L2_COLORSPACE_SRGB}, |
243 | }; | 245 | }; |
244 | 246 | ||
@@ -804,7 +806,7 @@ static int cit_write_reg(struct gspca_dev *gspca_dev, u16 value, u16 index) | |||
804 | return 0; | 806 | return 0; |
805 | } | 807 | } |
806 | 808 | ||
807 | static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index) | 809 | static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index, int verbose) |
808 | { | 810 | { |
809 | struct usb_device *udev = gspca_dev->dev; | 811 | struct usb_device *udev = gspca_dev->dev; |
810 | __u8 *buf = gspca_dev->usb_buf; | 812 | __u8 *buf = gspca_dev->usb_buf; |
@@ -819,10 +821,8 @@ static int cit_read_reg(struct gspca_dev *gspca_dev, u16 index) | |||
819 | return res; | 821 | return res; |
820 | } | 822 | } |
821 | 823 | ||
822 | PDEBUG(D_PROBE, | 824 | if (verbose) |
823 | "Register %04x value: %02x %02x %02x %02x %02x %02x %02x %02x", | 825 | PDEBUG(D_PROBE, "Register %04x value: %02x", index, buf[0]); |
824 | index, | ||
825 | buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); | ||
826 | 826 | ||
827 | return 0; | 827 | return 0; |
828 | } | 828 | } |
@@ -907,7 +907,7 @@ static void cit_Packet_Format1(struct gspca_dev *gspca_dev, u16 fkey, u16 val) | |||
907 | cit_send_x_00_05(gspca_dev, 0x0089); | 907 | cit_send_x_00_05(gspca_dev, 0x0089); |
908 | cit_send_x_00(gspca_dev, fkey); | 908 | cit_send_x_00(gspca_dev, fkey); |
909 | cit_send_00_04_06(gspca_dev); | 909 | cit_send_00_04_06(gspca_dev); |
910 | cit_read_reg(gspca_dev, 0x0126); | 910 | cit_read_reg(gspca_dev, 0x0126, 0); |
911 | cit_send_FF_04_02(gspca_dev); | 911 | cit_send_FF_04_02(gspca_dev); |
912 | } | 912 | } |
913 | 913 | ||
@@ -1074,12 +1074,12 @@ static int cit_init_model0(struct gspca_dev *gspca_dev) | |||
1074 | 1074 | ||
1075 | static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev) | 1075 | static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev) |
1076 | { | 1076 | { |
1077 | cit_read_reg(gspca_dev, 0x128); | 1077 | cit_read_reg(gspca_dev, 0x128, 1); |
1078 | cit_write_reg(gspca_dev, 0x0003, 0x0133); | 1078 | cit_write_reg(gspca_dev, 0x0003, 0x0133); |
1079 | cit_write_reg(gspca_dev, 0x0000, 0x0117); | 1079 | cit_write_reg(gspca_dev, 0x0000, 0x0117); |
1080 | cit_write_reg(gspca_dev, 0x0008, 0x0123); | 1080 | cit_write_reg(gspca_dev, 0x0008, 0x0123); |
1081 | cit_write_reg(gspca_dev, 0x0000, 0x0100); | 1081 | cit_write_reg(gspca_dev, 0x0000, 0x0100); |
1082 | cit_read_reg(gspca_dev, 0x0116); | 1082 | cit_read_reg(gspca_dev, 0x0116, 0); |
1083 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | 1083 | cit_write_reg(gspca_dev, 0x0060, 0x0116); |
1084 | cit_write_reg(gspca_dev, 0x0002, 0x0112); | 1084 | cit_write_reg(gspca_dev, 0x0002, 0x0112); |
1085 | cit_write_reg(gspca_dev, 0x0000, 0x0133); | 1085 | cit_write_reg(gspca_dev, 0x0000, 0x0133); |
@@ -1098,7 +1098,7 @@ static int cit_init_ibm_netcam_pro(struct gspca_dev *gspca_dev) | |||
1098 | cit_write_reg(gspca_dev, 0x00ff, 0x0130); | 1098 | cit_write_reg(gspca_dev, 0x00ff, 0x0130); |
1099 | cit_write_reg(gspca_dev, 0xcd41, 0x0124); | 1099 | cit_write_reg(gspca_dev, 0xcd41, 0x0124); |
1100 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | 1100 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); |
1101 | cit_read_reg(gspca_dev, 0x0126); | 1101 | cit_read_reg(gspca_dev, 0x0126, 1); |
1102 | 1102 | ||
1103 | cit_model3_Packet1(gspca_dev, 0x0000, 0x0000); | 1103 | cit_model3_Packet1(gspca_dev, 0x0000, 0x0000); |
1104 | cit_model3_Packet1(gspca_dev, 0x0000, 0x0001); | 1104 | cit_model3_Packet1(gspca_dev, 0x0000, 0x0001); |
@@ -1557,18 +1557,20 @@ static int cit_restart_stream(struct gspca_dev *gspca_dev) | |||
1557 | switch (sd->model) { | 1557 | switch (sd->model) { |
1558 | case CIT_MODEL0: | 1558 | case CIT_MODEL0: |
1559 | case CIT_MODEL1: | 1559 | case CIT_MODEL1: |
1560 | case CIT_MODEL3: | ||
1561 | case CIT_IBM_NETCAM_PRO: | ||
1562 | cit_write_reg(gspca_dev, 0x0001, 0x0114); | 1560 | cit_write_reg(gspca_dev, 0x0001, 0x0114); |
1563 | /* Fall through */ | 1561 | /* Fall through */ |
1564 | case CIT_MODEL2: | 1562 | case CIT_MODEL2: |
1565 | case CIT_MODEL4: | 1563 | case CIT_MODEL4: |
1566 | cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */ | 1564 | cit_write_reg(gspca_dev, 0x00c0, 0x010c); /* Go! */ |
1567 | usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe); | 1565 | usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe); |
1568 | /* This happens repeatedly while streaming with the ibm netcam | 1566 | break; |
1569 | pro and the ibmcam driver did it for model3 after changing | 1567 | case CIT_MODEL3: |
1570 | settings, but it does not seem to have any effect. */ | 1568 | case CIT_IBM_NETCAM_PRO: |
1571 | /* cit_write_reg(gspca_dev, 0x0001, 0x0113); */ | 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); | ||
1572 | break; | 1574 | break; |
1573 | } | 1575 | } |
1574 | 1576 | ||
@@ -1680,23 +1682,23 @@ static int cit_start_model1(struct gspca_dev *gspca_dev) | |||
1680 | if (clock_div < 0) | 1682 | if (clock_div < 0) |
1681 | return clock_div; | 1683 | return clock_div; |
1682 | 1684 | ||
1683 | cit_read_reg(gspca_dev, 0x0128); | 1685 | cit_read_reg(gspca_dev, 0x0128, 1); |
1684 | cit_read_reg(gspca_dev, 0x0100); | 1686 | cit_read_reg(gspca_dev, 0x0100, 0); |
1685 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ | 1687 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ |
1686 | cit_read_reg(gspca_dev, 0x0100); | 1688 | cit_read_reg(gspca_dev, 0x0100, 0); |
1687 | cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ | 1689 | cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ |
1688 | cit_read_reg(gspca_dev, 0x0100); | 1690 | cit_read_reg(gspca_dev, 0x0100, 0); |
1689 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ | 1691 | cit_write_reg(gspca_dev, 0x01, 0x0100); /* LED On */ |
1690 | cit_write_reg(gspca_dev, 0x01, 0x0108); | 1692 | cit_write_reg(gspca_dev, 0x01, 0x0108); |
1691 | 1693 | ||
1692 | cit_write_reg(gspca_dev, 0x03, 0x0112); | 1694 | cit_write_reg(gspca_dev, 0x03, 0x0112); |
1693 | cit_read_reg(gspca_dev, 0x0115); | 1695 | cit_read_reg(gspca_dev, 0x0115, 0); |
1694 | cit_write_reg(gspca_dev, 0x06, 0x0115); | 1696 | cit_write_reg(gspca_dev, 0x06, 0x0115); |
1695 | cit_read_reg(gspca_dev, 0x0116); | 1697 | cit_read_reg(gspca_dev, 0x0116, 0); |
1696 | cit_write_reg(gspca_dev, 0x44, 0x0116); | 1698 | cit_write_reg(gspca_dev, 0x44, 0x0116); |
1697 | cit_read_reg(gspca_dev, 0x0116); | 1699 | cit_read_reg(gspca_dev, 0x0116, 0); |
1698 | cit_write_reg(gspca_dev, 0x40, 0x0116); | 1700 | cit_write_reg(gspca_dev, 0x40, 0x0116); |
1699 | cit_read_reg(gspca_dev, 0x0115); | 1701 | cit_read_reg(gspca_dev, 0x0115, 0); |
1700 | cit_write_reg(gspca_dev, 0x0e, 0x0115); | 1702 | cit_write_reg(gspca_dev, 0x0e, 0x0115); |
1701 | cit_write_reg(gspca_dev, 0x19, 0x012c); | 1703 | cit_write_reg(gspca_dev, 0x19, 0x012c); |
1702 | 1704 | ||
@@ -1878,7 +1880,7 @@ static int cit_start_model2(struct gspca_dev *gspca_dev) | |||
1878 | int clock_div = 0; | 1880 | int clock_div = 0; |
1879 | 1881 | ||
1880 | cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */ | 1882 | cit_write_reg(gspca_dev, 0x0000, 0x0100); /* LED on */ |
1881 | cit_read_reg(gspca_dev, 0x0116); | 1883 | cit_read_reg(gspca_dev, 0x0116, 0); |
1882 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | 1884 | cit_write_reg(gspca_dev, 0x0060, 0x0116); |
1883 | cit_write_reg(gspca_dev, 0x0002, 0x0112); | 1885 | cit_write_reg(gspca_dev, 0x0002, 0x0112); |
1884 | cit_write_reg(gspca_dev, 0x00bc, 0x012c); | 1886 | cit_write_reg(gspca_dev, 0x00bc, 0x012c); |
@@ -2070,10 +2072,10 @@ static int cit_start_model3(struct gspca_dev *gspca_dev) | |||
2070 | 2072 | ||
2071 | /* HDG not in ibmcam driver, added to see if it helps with | 2073 | /* HDG not in ibmcam driver, added to see if it helps with |
2072 | auto-detecting between model3 and ibm netcamera pro */ | 2074 | auto-detecting between model3 and ibm netcamera pro */ |
2073 | cit_read_reg(gspca_dev, 0x128); | 2075 | cit_read_reg(gspca_dev, 0x128, 1); |
2074 | 2076 | ||
2075 | cit_write_reg(gspca_dev, 0x0000, 0x0100); | 2077 | cit_write_reg(gspca_dev, 0x0000, 0x0100); |
2076 | cit_read_reg(gspca_dev, 0x0116); | 2078 | cit_read_reg(gspca_dev, 0x0116, 0); |
2077 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | 2079 | cit_write_reg(gspca_dev, 0x0060, 0x0116); |
2078 | cit_write_reg(gspca_dev, 0x0002, 0x0112); | 2080 | cit_write_reg(gspca_dev, 0x0002, 0x0112); |
2079 | cit_write_reg(gspca_dev, 0x0000, 0x0123); | 2081 | cit_write_reg(gspca_dev, 0x0000, 0x0123); |
@@ -2083,7 +2085,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev) | |||
2083 | cit_write_reg(gspca_dev, 0x0060, 0x0116); | 2085 | cit_write_reg(gspca_dev, 0x0060, 0x0116); |
2084 | cit_write_reg(gspca_dev, 0x0002, 0x0115); | 2086 | cit_write_reg(gspca_dev, 0x0002, 0x0115); |
2085 | cit_write_reg(gspca_dev, 0x0003, 0x0115); | 2087 | cit_write_reg(gspca_dev, 0x0003, 0x0115); |
2086 | cit_read_reg(gspca_dev, 0x0115); | 2088 | cit_read_reg(gspca_dev, 0x0115, 0); |
2087 | cit_write_reg(gspca_dev, 0x000b, 0x0115); | 2089 | cit_write_reg(gspca_dev, 0x000b, 0x0115); |
2088 | 2090 | ||
2089 | /* TESTME HDG not in ibmcam driver, added to see if it helps with | 2091 | /* TESTME HDG not in ibmcam driver, added to see if it helps with |
@@ -2096,7 +2098,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev) | |||
2096 | cit_write_reg(gspca_dev, 0x00ff, 0x0130); | 2098 | cit_write_reg(gspca_dev, 0x00ff, 0x0130); |
2097 | cit_write_reg(gspca_dev, 0xcd41, 0x0124); | 2099 | cit_write_reg(gspca_dev, 0xcd41, 0x0124); |
2098 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); | 2100 | cit_write_reg(gspca_dev, 0xfffa, 0x0124); |
2099 | cit_read_reg(gspca_dev, 0x0126); | 2101 | cit_read_reg(gspca_dev, 0x0126, 1); |
2100 | } | 2102 | } |
2101 | 2103 | ||
2102 | cit_model3_Packet1(gspca_dev, 0x000a, 0x0040); | 2104 | cit_model3_Packet1(gspca_dev, 0x000a, 0x0040); |
@@ -2293,7 +2295,7 @@ static int cit_start_model3(struct gspca_dev *gspca_dev) | |||
2293 | if (rca_input) { | 2295 | if (rca_input) { |
2294 | for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { | 2296 | for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { |
2295 | if (rca_initdata[i][0]) | 2297 | if (rca_initdata[i][0]) |
2296 | cit_read_reg(gspca_dev, rca_initdata[i][2]); | 2298 | cit_read_reg(gspca_dev, rca_initdata[i][2], 0); |
2297 | else | 2299 | else |
2298 | cit_write_reg(gspca_dev, rca_initdata[i][1], | 2300 | cit_write_reg(gspca_dev, rca_initdata[i][1], |
2299 | rca_initdata[i][2]); | 2301 | rca_initdata[i][2]); |
@@ -2712,7 +2714,7 @@ static int cit_start_ibm_netcam_pro(struct gspca_dev *gspca_dev) | |||
2712 | if (rca_input) { | 2714 | if (rca_input) { |
2713 | for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { | 2715 | for (i = 0; i < ARRAY_SIZE(rca_initdata); i++) { |
2714 | if (rca_initdata[i][0]) | 2716 | if (rca_initdata[i][0]) |
2715 | cit_read_reg(gspca_dev, rca_initdata[i][2]); | 2717 | cit_read_reg(gspca_dev, rca_initdata[i][2], 0); |
2716 | else | 2718 | else |
2717 | cit_write_reg(gspca_dev, rca_initdata[i][1], | 2719 | cit_write_reg(gspca_dev, rca_initdata[i][1], |
2718 | rca_initdata[i][2]); | 2720 | rca_initdata[i][2]); |
@@ -2769,16 +2771,55 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2769 | return 0; | 2771 | return 0; |
2770 | } | 2772 | } |
2771 | 2773 | ||
2774 | static int sd_isoc_init(struct gspca_dev *gspca_dev) | ||
2775 | { | ||
2776 | struct usb_host_interface *alt; | ||
2777 | int max_packet_size; | ||
2778 | |||
2779 | switch (gspca_dev->width) { | ||
2780 | case 160: | ||
2781 | max_packet_size = 450; | ||
2782 | break; | ||
2783 | case 176: | ||
2784 | max_packet_size = 600; | ||
2785 | break; | ||
2786 | default: | ||
2787 | max_packet_size = 1022; | ||
2788 | break; | ||
2789 | } | ||
2790 | |||
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); | ||
2794 | |||
2795 | return 0; | ||
2796 | } | ||
2797 | |||
2772 | static int sd_isoc_nego(struct gspca_dev *gspca_dev) | 2798 | static int sd_isoc_nego(struct gspca_dev *gspca_dev) |
2773 | { | 2799 | { |
2774 | int ret, packet_size; | 2800 | int ret, packet_size, min_packet_size; |
2775 | struct usb_host_interface *alt; | 2801 | struct usb_host_interface *alt; |
2776 | 2802 | ||
2803 | switch (gspca_dev->width) { | ||
2804 | case 160: | ||
2805 | min_packet_size = 200; | ||
2806 | break; | ||
2807 | case 176: | ||
2808 | min_packet_size = 266; | ||
2809 | break; | ||
2810 | default: | ||
2811 | min_packet_size = 400; | ||
2812 | break; | ||
2813 | } | ||
2814 | |||
2777 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; | 2815 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; |
2778 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | 2816 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); |
2779 | packet_size -= 100; | 2817 | if (packet_size <= min_packet_size) |
2780 | if (packet_size < 300) | ||
2781 | return -EIO; | 2818 | return -EIO; |
2819 | |||
2820 | packet_size -= 100; | ||
2821 | if (packet_size < min_packet_size) | ||
2822 | packet_size = min_packet_size; | ||
2782 | alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size); | 2823 | alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(packet_size); |
2783 | 2824 | ||
2784 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); | 2825 | ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); |
@@ -2796,15 +2837,12 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
2796 | static void sd_stop0(struct gspca_dev *gspca_dev) | 2837 | static void sd_stop0(struct gspca_dev *gspca_dev) |
2797 | { | 2838 | { |
2798 | struct sd *sd = (struct sd *) gspca_dev; | 2839 | struct sd *sd = (struct sd *) gspca_dev; |
2799 | struct usb_host_interface *alt; | ||
2800 | 2840 | ||
2801 | /* We cannot use gspca_dev->present here as that is not set when | 2841 | /* We cannot use gspca_dev->present here as that is not set when |
2802 | sd_init gets called and we get called from sd_init */ | 2842 | sd_init gets called and we get called from sd_init */ |
2803 | if (!gspca_dev->dev) | 2843 | if (!gspca_dev->dev) |
2804 | return; | 2844 | return; |
2805 | 2845 | ||
2806 | alt = &gspca_dev->dev->config->intf_cache[0]->altsetting[1]; | ||
2807 | |||
2808 | switch (sd->model) { | 2846 | switch (sd->model) { |
2809 | case CIT_MODEL0: | 2847 | case CIT_MODEL0: |
2810 | /* HDG windows does this, but it causes the cams autogain to | 2848 | /* HDG windows does this, but it causes the cams autogain to |
@@ -2815,7 +2853,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
2815 | break; | 2853 | break; |
2816 | case CIT_MODEL1: | 2854 | case CIT_MODEL1: |
2817 | cit_send_FF_04_02(gspca_dev); | 2855 | cit_send_FF_04_02(gspca_dev); |
2818 | cit_read_reg(gspca_dev, 0x0100); | 2856 | cit_read_reg(gspca_dev, 0x0100, 0); |
2819 | cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ | 2857 | cit_write_reg(gspca_dev, 0x81, 0x0100); /* LED Off */ |
2820 | break; | 2858 | break; |
2821 | case CIT_MODEL2: | 2859 | case CIT_MODEL2: |
@@ -2834,9 +2872,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
2834 | case CIT_MODEL3: | 2872 | case CIT_MODEL3: |
2835 | cit_write_reg(gspca_dev, 0x0006, 0x012c); | 2873 | cit_write_reg(gspca_dev, 0x0006, 0x012c); |
2836 | cit_model3_Packet1(gspca_dev, 0x0046, 0x0000); | 2874 | cit_model3_Packet1(gspca_dev, 0x0046, 0x0000); |
2837 | cit_read_reg(gspca_dev, 0x0116); | 2875 | cit_read_reg(gspca_dev, 0x0116, 0); |
2838 | cit_write_reg(gspca_dev, 0x0064, 0x0116); | 2876 | cit_write_reg(gspca_dev, 0x0064, 0x0116); |
2839 | cit_read_reg(gspca_dev, 0x0115); | 2877 | cit_read_reg(gspca_dev, 0x0115, 0); |
2840 | cit_write_reg(gspca_dev, 0x0003, 0x0115); | 2878 | cit_write_reg(gspca_dev, 0x0003, 0x0115); |
2841 | cit_write_reg(gspca_dev, 0x0008, 0x0123); | 2879 | cit_write_reg(gspca_dev, 0x0008, 0x0123); |
2842 | cit_write_reg(gspca_dev, 0x0000, 0x0117); | 2880 | cit_write_reg(gspca_dev, 0x0000, 0x0117); |
@@ -2859,12 +2897,17 @@ static void sd_stop0(struct gspca_dev *gspca_dev) | |||
2859 | restarting the stream after this */ | 2897 | restarting the stream after this */ |
2860 | /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */ | 2898 | /* cit_write_reg(gspca_dev, 0x0000, 0x0112); */ |
2861 | cit_write_reg(gspca_dev, 0x00c0, 0x0100); | 2899 | cit_write_reg(gspca_dev, 0x00c0, 0x0100); |
2862 | |||
2863 | /* Start isoc bandwidth "negotiation" at max isoc bandwith | ||
2864 | next stream start */ | ||
2865 | alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(1022); | ||
2866 | break; | 2900 | break; |
2867 | } | 2901 | } |
2902 | |||
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; | ||
2909 | } | ||
2910 | #endif | ||
2868 | } | 2911 | } |
2869 | 2912 | ||
2870 | static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len) | 2913 | static u8 *cit_find_sof(struct gspca_dev *gspca_dev, u8 *data, int len) |
@@ -3158,6 +3201,38 @@ static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
3158 | return 0; | 3201 | return 0; |
3159 | } | 3202 | } |
3160 | 3203 | ||
3204 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
3205 | static void cit_check_button(struct gspca_dev *gspca_dev) | ||
3206 | { | ||
3207 | int new_button_state; | ||
3208 | struct sd *sd = (struct sd *)gspca_dev; | ||
3209 | |||
3210 | switch (sd->model) { | ||
3211 | case CIT_MODEL3: | ||
3212 | case CIT_IBM_NETCAM_PRO: | ||
3213 | break; | ||
3214 | default: /* TEST ME unknown if this works on other models too */ | ||
3215 | return; | ||
3216 | } | ||
3217 | |||
3218 | /* Read the button state */ | ||
3219 | cit_read_reg(gspca_dev, 0x0113, 0); | ||
3220 | new_button_state = !gspca_dev->usb_buf[0]; | ||
3221 | |||
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); | ||
3227 | |||
3228 | if (sd->button_state != new_button_state) { | ||
3229 | input_report_key(gspca_dev->input_dev, KEY_CAMERA, | ||
3230 | new_button_state); | ||
3231 | input_sync(gspca_dev->input_dev); | ||
3232 | sd->button_state = new_button_state; | ||
3233 | } | ||
3234 | } | ||
3235 | #endif | ||
3161 | 3236 | ||
3162 | /* sub-driver description */ | 3237 | /* sub-driver description */ |
3163 | static const struct sd_desc sd_desc = { | 3238 | static const struct sd_desc sd_desc = { |
@@ -3170,6 +3245,10 @@ static const struct sd_desc sd_desc = { | |||
3170 | .stopN = sd_stopN, | 3245 | .stopN = sd_stopN, |
3171 | .stop0 = sd_stop0, | 3246 | .stop0 = sd_stop0, |
3172 | .pkt_scan = sd_pkt_scan, | 3247 | .pkt_scan = sd_pkt_scan, |
3248 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
3249 | .dq_callback = cit_check_button, | ||
3250 | .other_input = 1, | ||
3251 | #endif | ||
3173 | }; | 3252 | }; |
3174 | 3253 | ||
3175 | static const struct sd_desc sd_desc_isoc_nego = { | 3254 | static const struct sd_desc sd_desc_isoc_nego = { |
@@ -3179,10 +3258,15 @@ static const struct sd_desc sd_desc_isoc_nego = { | |||
3179 | .config = sd_config, | 3258 | .config = sd_config, |
3180 | .init = sd_init, | 3259 | .init = sd_init, |
3181 | .start = sd_start, | 3260 | .start = sd_start, |
3261 | .isoc_init = sd_isoc_init, | ||
3182 | .isoc_nego = sd_isoc_nego, | 3262 | .isoc_nego = sd_isoc_nego, |
3183 | .stopN = sd_stopN, | 3263 | .stopN = sd_stopN, |
3184 | .stop0 = sd_stop0, | 3264 | .stop0 = sd_stop0, |
3185 | .pkt_scan = sd_pkt_scan, | 3265 | .pkt_scan = sd_pkt_scan, |
3266 | #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) | ||
3267 | .dq_callback = cit_check_button, | ||
3268 | .other_input = 1, | ||
3269 | #endif | ||
3186 | }; | 3270 | }; |
3187 | 3271 | ||
3188 | /* -- module initialisation -- */ | 3272 | /* -- module initialisation -- */ |