Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 1 | /* |
| 2 | * SPCA506 chip based cameras function |
| 3 | * M Xhaard 15/04/2004 based on different work Mark Taylor and others |
| 4 | * and my own snoopy file on a pv-321c donate by a german compagny |
| 5 | * "Firma Frank Gmbh" from Saarbruecken |
| 6 | * |
| 7 | * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #define MODULE_NAME "spca506" |
| 25 | |
| 26 | #include "gspca.h" |
| 27 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 28 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
| 29 | MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver"); |
| 30 | MODULE_LICENSE("GPL"); |
| 31 | |
| 32 | /* specific webcam descriptor */ |
| 33 | struct sd { |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 34 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 35 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 36 | unsigned char brightness; |
| 37 | unsigned char contrast; |
| 38 | unsigned char colors; |
| 39 | unsigned char hue; |
| 40 | char norme; |
| 41 | char channel; |
| 42 | }; |
| 43 | |
| 44 | /* V4L2 controls supported by the driver */ |
| 45 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); |
| 46 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); |
| 47 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); |
| 48 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); |
| 49 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); |
| 50 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); |
| 51 | static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val); |
| 52 | static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val); |
| 53 | |
| 54 | static struct ctrl sd_ctrls[] = { |
| 55 | #define SD_BRIGHTNESS 0 |
| 56 | { |
| 57 | { |
| 58 | .id = V4L2_CID_BRIGHTNESS, |
| 59 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 60 | .name = "Brightness", |
| 61 | .minimum = 0, |
| 62 | .maximum = 0xff, |
| 63 | .step = 1, |
| 64 | .default_value = 0x80, |
| 65 | }, |
| 66 | .set = sd_setbrightness, |
| 67 | .get = sd_getbrightness, |
| 68 | }, |
| 69 | #define SD_CONTRAST 1 |
| 70 | { |
| 71 | { |
| 72 | .id = V4L2_CID_CONTRAST, |
| 73 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 74 | .name = "Contrast", |
| 75 | .minimum = 0, |
| 76 | .maximum = 0xff, |
| 77 | .step = 1, |
| 78 | .default_value = 0x47, |
| 79 | }, |
| 80 | .set = sd_setcontrast, |
| 81 | .get = sd_getcontrast, |
| 82 | }, |
| 83 | #define SD_COLOR 2 |
| 84 | { |
| 85 | { |
| 86 | .id = V4L2_CID_SATURATION, |
| 87 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 88 | .name = "Saturation", |
| 89 | .minimum = 0, |
| 90 | .maximum = 0xff, |
| 91 | .step = 1, |
| 92 | .default_value = 0x40, |
| 93 | }, |
| 94 | .set = sd_setcolors, |
| 95 | .get = sd_getcolors, |
| 96 | }, |
| 97 | #define SD_HUE 3 |
| 98 | { |
| 99 | { |
| 100 | .id = V4L2_CID_HUE, |
| 101 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 102 | .name = "Hue", |
| 103 | .minimum = 0, |
| 104 | .maximum = 0xff, |
| 105 | .step = 1, |
| 106 | .default_value = 0, |
| 107 | }, |
| 108 | .set = sd_sethue, |
| 109 | .get = sd_gethue, |
| 110 | }, |
| 111 | }; |
| 112 | |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 113 | static struct v4l2_pix_format vga_mode[] = { |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 114 | {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame^] | 115 | .bytesperline = 160, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 116 | .sizeimage = 160 * 120 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 117 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 118 | .priv = 5}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 119 | {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame^] | 120 | .bytesperline = 176, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 121 | .sizeimage = 176 * 144 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 122 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 123 | .priv = 4}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 124 | {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame^] | 125 | .bytesperline = 320, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 126 | .sizeimage = 320 * 240 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 127 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 128 | .priv = 2}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 129 | {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame^] | 130 | .bytesperline = 352, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 131 | .sizeimage = 352 * 288 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 132 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 133 | .priv = 1}, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 134 | {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
Jean-Francois Moine | 00b27ce | 2008-07-30 05:47:54 -0300 | [diff] [blame^] | 135 | .bytesperline = 640, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 136 | .sizeimage = 640 * 480 * 3 / 2, |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 137 | .colorspace = V4L2_COLORSPACE_SRGB, |
| 138 | .priv = 0}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | #define SPCA50X_OFFSET_DATA 10 |
| 142 | |
| 143 | #define SAA7113_bright 0x0a /* defaults 0x80 */ |
| 144 | #define SAA7113_contrast 0x0b /* defaults 0x47 */ |
| 145 | #define SAA7113_saturation 0x0c /* defaults 0x40 */ |
| 146 | #define SAA7113_hue 0x0d /* defaults 0x00 */ |
| 147 | #define SAA7113_I2C_BASE_WRITE 0x4a |
| 148 | |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 149 | /* read 'len' bytes to gspca_dev->usb_buf */ |
| 150 | static void reg_r(struct gspca_dev *gspca_dev, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 151 | __u16 req, |
| 152 | __u16 index, |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 153 | __u16 length) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 154 | { |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 155 | usb_control_msg(gspca_dev->dev, |
| 156 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 157 | req, |
| 158 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 159 | 0, /* value */ |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 160 | index, gspca_dev->usb_buf, length, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 161 | 500); |
| 162 | } |
| 163 | |
| 164 | static void reg_w(struct usb_device *dev, |
| 165 | __u16 req, |
| 166 | __u16 value, |
| 167 | __u16 index) |
| 168 | { |
| 169 | usb_control_msg(dev, |
| 170 | usb_sndctrlpipe(dev, 0), |
| 171 | req, |
| 172 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 173 | value, index, |
| 174 | NULL, 0, 500); |
| 175 | } |
| 176 | |
| 177 | static void spca506_Initi2c(struct gspca_dev *gspca_dev) |
| 178 | { |
| 179 | reg_w(gspca_dev->dev, 0x07, SAA7113_I2C_BASE_WRITE, 0x0004); |
| 180 | } |
| 181 | |
| 182 | static void spca506_WriteI2c(struct gspca_dev *gspca_dev, __u16 valeur, |
| 183 | __u16 reg) |
| 184 | { |
| 185 | int retry = 60; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 186 | |
| 187 | reg_w(gspca_dev->dev, 0x07, reg, 0x0001); |
| 188 | reg_w(gspca_dev->dev, 0x07, valeur, 0x0000); |
| 189 | while (retry--) { |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 190 | reg_r(gspca_dev, 0x07, 0x0003, 2); |
| 191 | if ((gspca_dev->usb_buf[0] | gspca_dev->usb_buf[1]) == 0x00) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 192 | break; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | static int spca506_ReadI2c(struct gspca_dev *gspca_dev, __u16 reg) |
| 197 | { |
| 198 | int retry = 60; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 199 | |
| 200 | reg_w(gspca_dev->dev, 0x07, SAA7113_I2C_BASE_WRITE, 0x0004); |
| 201 | reg_w(gspca_dev->dev, 0x07, reg, 0x0001); |
| 202 | reg_w(gspca_dev->dev, 0x07, 0x01, 0x0002); |
| 203 | while (--retry) { |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 204 | reg_r(gspca_dev, 0x07, 0x0003, 2); |
| 205 | if ((gspca_dev->usb_buf[0] | gspca_dev->usb_buf[1]) == 0x00) |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 206 | break; |
| 207 | } |
| 208 | if (retry == 0) |
| 209 | return -1; |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 210 | reg_r(gspca_dev, 0x07, 0x0000, 1); |
| 211 | return gspca_dev->usb_buf[0]; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | static void spca506_SetNormeInput(struct gspca_dev *gspca_dev, |
| 215 | __u16 norme, |
| 216 | __u16 channel) |
| 217 | { |
| 218 | struct sd *sd = (struct sd *) gspca_dev; |
| 219 | /* fixme: check if channel == 0..3 and 6..9 (8 values) */ |
| 220 | __u8 setbit0 = 0x00; |
| 221 | __u8 setbit1 = 0x00; |
| 222 | __u8 videomask = 0x00; |
| 223 | |
| 224 | PDEBUG(D_STREAM, "** Open Set Norme **"); |
| 225 | spca506_Initi2c(gspca_dev); |
| 226 | /* NTSC bit0 -> 1(525 l) PAL SECAM bit0 -> 0 (625 l) */ |
| 227 | /* Composite channel bit1 -> 1 S-video bit 1 -> 0 */ |
| 228 | /* and exclude SAA7113 reserved channel set default 0 otherwise */ |
| 229 | if (norme & V4L2_STD_NTSC) |
| 230 | setbit0 = 0x01; |
| 231 | if (channel == 4 || channel == 5 || channel > 9) |
| 232 | channel = 0; |
| 233 | if (channel < 4) |
| 234 | setbit1 = 0x02; |
| 235 | videomask = (0x48 | setbit0 | setbit1); |
| 236 | reg_w(gspca_dev->dev, 0x08, videomask, 0x0000); |
| 237 | spca506_WriteI2c(gspca_dev, (0xc0 | (channel & 0x0F)), 0x02); |
| 238 | |
| 239 | if (norme & V4L2_STD_NTSC) |
| 240 | spca506_WriteI2c(gspca_dev, 0x33, 0x0e); |
| 241 | /* Chrominance Control NTSC N */ |
| 242 | else if (norme & V4L2_STD_SECAM) |
| 243 | spca506_WriteI2c(gspca_dev, 0x53, 0x0e); |
| 244 | /* Chrominance Control SECAM */ |
| 245 | else |
| 246 | spca506_WriteI2c(gspca_dev, 0x03, 0x0e); |
| 247 | /* Chrominance Control PAL BGHIV */ |
| 248 | |
| 249 | sd->norme = norme; |
| 250 | sd->channel = channel; |
| 251 | PDEBUG(D_STREAM, "Set Video Byte to 0x%2x", videomask); |
| 252 | PDEBUG(D_STREAM, "Set Norme: %08x Channel %d", norme, channel); |
| 253 | } |
| 254 | |
| 255 | static void spca506_GetNormeInput(struct gspca_dev *gspca_dev, |
| 256 | __u16 *norme, __u16 *channel) |
| 257 | { |
| 258 | struct sd *sd = (struct sd *) gspca_dev; |
| 259 | |
| 260 | /* Read the register is not so good value change so |
| 261 | we use your own copy in spca50x struct */ |
| 262 | *norme = sd->norme; |
| 263 | *channel = sd->channel; |
| 264 | PDEBUG(D_STREAM, "Get Norme: %d Channel %d", *norme, *channel); |
| 265 | } |
| 266 | |
| 267 | static void spca506_Setsize(struct gspca_dev *gspca_dev, __u16 code, |
| 268 | __u16 xmult, __u16 ymult) |
| 269 | { |
| 270 | struct usb_device *dev = gspca_dev->dev; |
| 271 | |
| 272 | PDEBUG(D_STREAM, "** SetSize **"); |
| 273 | reg_w(dev, 0x04, (0x18 | (code & 0x07)), 0x0000); |
| 274 | /* Soft snap 0x40 Hard 0x41 */ |
| 275 | reg_w(dev, 0x04, 0x41, 0x0001); |
| 276 | reg_w(dev, 0x04, 0x00, 0x0002); |
| 277 | /* reserved */ |
| 278 | reg_w(dev, 0x04, 0x00, 0x0003); |
| 279 | |
| 280 | /* reserved */ |
| 281 | reg_w(dev, 0x04, 0x00, 0x0004); |
| 282 | /* reserved */ |
| 283 | reg_w(dev, 0x04, 0x01, 0x0005); |
| 284 | /* reserced */ |
| 285 | reg_w(dev, 0x04, xmult, 0x0006); |
| 286 | /* reserved */ |
| 287 | reg_w(dev, 0x04, ymult, 0x0007); |
| 288 | /* compression 1 */ |
| 289 | reg_w(dev, 0x04, 0x00, 0x0008); |
| 290 | /* T=64 -> 2 */ |
| 291 | reg_w(dev, 0x04, 0x00, 0x0009); |
| 292 | /* threshold2D */ |
| 293 | reg_w(dev, 0x04, 0x21, 0x000a); |
| 294 | /* quantization */ |
| 295 | reg_w(dev, 0x04, 0x00, 0x000b); |
| 296 | } |
| 297 | |
| 298 | /* this function is called at probe time */ |
| 299 | static int sd_config(struct gspca_dev *gspca_dev, |
| 300 | const struct usb_device_id *id) |
| 301 | { |
| 302 | struct sd *sd = (struct sd *) gspca_dev; |
| 303 | struct cam *cam; |
| 304 | |
| 305 | cam = &gspca_dev->cam; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 306 | cam->epaddr = 0x01; |
| 307 | cam->cam_mode = vga_mode; |
| 308 | cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; |
| 309 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; |
| 310 | sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; |
| 311 | sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; |
| 312 | sd->hue = sd_ctrls[SD_HUE].qctrl.default_value; |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | /* this function is called at open time */ |
| 317 | static int sd_open(struct gspca_dev *gspca_dev) |
| 318 | { |
| 319 | struct usb_device *dev = gspca_dev->dev; |
| 320 | |
| 321 | reg_w(dev, 0x03, 0x00, 0x0004); |
| 322 | reg_w(dev, 0x03, 0xFF, 0x0003); |
| 323 | reg_w(dev, 0x03, 0x00, 0x0000); |
| 324 | reg_w(dev, 0x03, 0x1c, 0x0001); |
| 325 | reg_w(dev, 0x03, 0x18, 0x0001); |
| 326 | /* Init on PAL and composite input0 */ |
| 327 | spca506_SetNormeInput(gspca_dev, 0, 0); |
| 328 | reg_w(dev, 0x03, 0x1c, 0x0001); |
| 329 | reg_w(dev, 0x03, 0x18, 0x0001); |
| 330 | reg_w(dev, 0x05, 0x00, 0x0000); |
| 331 | reg_w(dev, 0x05, 0xef, 0x0001); |
| 332 | reg_w(dev, 0x05, 0x00, 0x00c1); |
| 333 | reg_w(dev, 0x05, 0x00, 0x00c2); |
| 334 | reg_w(dev, 0x06, 0x18, 0x0002); |
| 335 | reg_w(dev, 0x06, 0xf5, 0x0011); |
| 336 | reg_w(dev, 0x06, 0x02, 0x0012); |
| 337 | reg_w(dev, 0x06, 0xfb, 0x0013); |
| 338 | reg_w(dev, 0x06, 0x00, 0x0014); |
| 339 | reg_w(dev, 0x06, 0xa4, 0x0051); |
| 340 | reg_w(dev, 0x06, 0x40, 0x0052); |
| 341 | reg_w(dev, 0x06, 0x71, 0x0053); |
| 342 | reg_w(dev, 0x06, 0x40, 0x0054); |
| 343 | /************************************************/ |
| 344 | reg_w(dev, 0x03, 0x00, 0x0004); |
| 345 | reg_w(dev, 0x03, 0x00, 0x0003); |
| 346 | reg_w(dev, 0x03, 0x00, 0x0004); |
| 347 | reg_w(dev, 0x03, 0xFF, 0x0003); |
| 348 | reg_w(dev, 0x02, 0x00, 0x0000); |
| 349 | reg_w(dev, 0x03, 0x60, 0x0000); |
| 350 | reg_w(dev, 0x03, 0x18, 0x0001); |
| 351 | /* for a better reading mx :) */ |
| 352 | /*sdca506_WriteI2c(value,register) */ |
| 353 | spca506_Initi2c(gspca_dev); |
| 354 | spca506_WriteI2c(gspca_dev, 0x08, 0x01); |
| 355 | spca506_WriteI2c(gspca_dev, 0xc0, 0x02); |
| 356 | /* input composite video */ |
| 357 | spca506_WriteI2c(gspca_dev, 0x33, 0x03); |
| 358 | spca506_WriteI2c(gspca_dev, 0x00, 0x04); |
| 359 | spca506_WriteI2c(gspca_dev, 0x00, 0x05); |
| 360 | spca506_WriteI2c(gspca_dev, 0x0d, 0x06); |
| 361 | spca506_WriteI2c(gspca_dev, 0xf0, 0x07); |
| 362 | spca506_WriteI2c(gspca_dev, 0x98, 0x08); |
| 363 | spca506_WriteI2c(gspca_dev, 0x03, 0x09); |
| 364 | spca506_WriteI2c(gspca_dev, 0x80, 0x0a); |
| 365 | spca506_WriteI2c(gspca_dev, 0x47, 0x0b); |
| 366 | spca506_WriteI2c(gspca_dev, 0x48, 0x0c); |
| 367 | spca506_WriteI2c(gspca_dev, 0x00, 0x0d); |
| 368 | spca506_WriteI2c(gspca_dev, 0x03, 0x0e); /* Chroma Pal adjust */ |
| 369 | spca506_WriteI2c(gspca_dev, 0x2a, 0x0f); |
| 370 | spca506_WriteI2c(gspca_dev, 0x00, 0x10); |
| 371 | spca506_WriteI2c(gspca_dev, 0x0c, 0x11); |
| 372 | spca506_WriteI2c(gspca_dev, 0xb8, 0x12); |
| 373 | spca506_WriteI2c(gspca_dev, 0x01, 0x13); |
| 374 | spca506_WriteI2c(gspca_dev, 0x00, 0x14); |
| 375 | spca506_WriteI2c(gspca_dev, 0x00, 0x15); |
| 376 | spca506_WriteI2c(gspca_dev, 0x00, 0x16); |
| 377 | spca506_WriteI2c(gspca_dev, 0x00, 0x17); |
| 378 | spca506_WriteI2c(gspca_dev, 0x00, 0x18); |
| 379 | spca506_WriteI2c(gspca_dev, 0x00, 0x19); |
| 380 | spca506_WriteI2c(gspca_dev, 0x00, 0x1a); |
| 381 | spca506_WriteI2c(gspca_dev, 0x00, 0x1b); |
| 382 | spca506_WriteI2c(gspca_dev, 0x00, 0x1c); |
| 383 | spca506_WriteI2c(gspca_dev, 0x00, 0x1d); |
| 384 | spca506_WriteI2c(gspca_dev, 0x00, 0x1e); |
| 385 | spca506_WriteI2c(gspca_dev, 0xa1, 0x1f); |
| 386 | spca506_WriteI2c(gspca_dev, 0x02, 0x40); |
| 387 | spca506_WriteI2c(gspca_dev, 0xff, 0x41); |
| 388 | spca506_WriteI2c(gspca_dev, 0xff, 0x42); |
| 389 | spca506_WriteI2c(gspca_dev, 0xff, 0x43); |
| 390 | spca506_WriteI2c(gspca_dev, 0xff, 0x44); |
| 391 | spca506_WriteI2c(gspca_dev, 0xff, 0x45); |
| 392 | spca506_WriteI2c(gspca_dev, 0xff, 0x46); |
| 393 | spca506_WriteI2c(gspca_dev, 0xff, 0x47); |
| 394 | spca506_WriteI2c(gspca_dev, 0xff, 0x48); |
| 395 | spca506_WriteI2c(gspca_dev, 0xff, 0x49); |
| 396 | spca506_WriteI2c(gspca_dev, 0xff, 0x4a); |
| 397 | spca506_WriteI2c(gspca_dev, 0xff, 0x4b); |
| 398 | spca506_WriteI2c(gspca_dev, 0xff, 0x4c); |
| 399 | spca506_WriteI2c(gspca_dev, 0xff, 0x4d); |
| 400 | spca506_WriteI2c(gspca_dev, 0xff, 0x4e); |
| 401 | spca506_WriteI2c(gspca_dev, 0xff, 0x4f); |
| 402 | spca506_WriteI2c(gspca_dev, 0xff, 0x50); |
| 403 | spca506_WriteI2c(gspca_dev, 0xff, 0x51); |
| 404 | spca506_WriteI2c(gspca_dev, 0xff, 0x52); |
| 405 | spca506_WriteI2c(gspca_dev, 0xff, 0x53); |
| 406 | spca506_WriteI2c(gspca_dev, 0xff, 0x54); |
| 407 | spca506_WriteI2c(gspca_dev, 0xff, 0x55); |
| 408 | spca506_WriteI2c(gspca_dev, 0xff, 0x56); |
| 409 | spca506_WriteI2c(gspca_dev, 0xff, 0x57); |
| 410 | spca506_WriteI2c(gspca_dev, 0x00, 0x58); |
| 411 | spca506_WriteI2c(gspca_dev, 0x54, 0x59); |
| 412 | spca506_WriteI2c(gspca_dev, 0x07, 0x5a); |
| 413 | spca506_WriteI2c(gspca_dev, 0x83, 0x5b); |
| 414 | spca506_WriteI2c(gspca_dev, 0x00, 0x5c); |
| 415 | spca506_WriteI2c(gspca_dev, 0x00, 0x5d); |
| 416 | spca506_WriteI2c(gspca_dev, 0x00, 0x5e); |
| 417 | spca506_WriteI2c(gspca_dev, 0x00, 0x5f); |
| 418 | spca506_WriteI2c(gspca_dev, 0x00, 0x60); |
| 419 | spca506_WriteI2c(gspca_dev, 0x05, 0x61); |
| 420 | spca506_WriteI2c(gspca_dev, 0x9f, 0x62); |
| 421 | PDEBUG(D_STREAM, "** Close Init *"); |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | static void sd_start(struct gspca_dev *gspca_dev) |
| 426 | { |
| 427 | struct usb_device *dev = gspca_dev->dev; |
| 428 | __u16 norme; |
| 429 | __u16 channel; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 430 | |
| 431 | /**************************************/ |
| 432 | reg_w(dev, 0x03, 0x00, 0x0004); |
| 433 | reg_w(dev, 0x03, 0x00, 0x0003); |
| 434 | reg_w(dev, 0x03, 0x00, 0x0004); |
| 435 | reg_w(dev, 0x03, 0xFF, 0x0003); |
| 436 | reg_w(dev, 0x02, 0x00, 0x0000); |
| 437 | reg_w(dev, 0x03, 0x60, 0x0000); |
| 438 | reg_w(dev, 0x03, 0x18, 0x0001); |
| 439 | |
| 440 | /*sdca506_WriteI2c(value,register) */ |
| 441 | spca506_Initi2c(gspca_dev); |
| 442 | spca506_WriteI2c(gspca_dev, 0x08, 0x01); /* Increment Delay */ |
| 443 | /* spca506_WriteI2c(gspca_dev, 0xc0, 0x02); * Analog Input Control 1 */ |
| 444 | spca506_WriteI2c(gspca_dev, 0x33, 0x03); |
| 445 | /* Analog Input Control 2 */ |
| 446 | spca506_WriteI2c(gspca_dev, 0x00, 0x04); |
| 447 | /* Analog Input Control 3 */ |
| 448 | spca506_WriteI2c(gspca_dev, 0x00, 0x05); |
| 449 | /* Analog Input Control 4 */ |
| 450 | spca506_WriteI2c(gspca_dev, 0x0d, 0x06); |
| 451 | /* Horizontal Sync Start 0xe9-0x0d */ |
| 452 | spca506_WriteI2c(gspca_dev, 0xf0, 0x07); |
| 453 | /* Horizontal Sync Stop 0x0d-0xf0 */ |
| 454 | |
| 455 | spca506_WriteI2c(gspca_dev, 0x98, 0x08); /* Sync Control */ |
| 456 | /* Defaults value */ |
| 457 | spca506_WriteI2c(gspca_dev, 0x03, 0x09); /* Luminance Control */ |
| 458 | spca506_WriteI2c(gspca_dev, 0x80, 0x0a); |
| 459 | /* Luminance Brightness */ |
| 460 | spca506_WriteI2c(gspca_dev, 0x47, 0x0b); /* Luminance Contrast */ |
| 461 | spca506_WriteI2c(gspca_dev, 0x48, 0x0c); |
| 462 | /* Chrominance Saturation */ |
| 463 | spca506_WriteI2c(gspca_dev, 0x00, 0x0d); |
| 464 | /* Chrominance Hue Control */ |
| 465 | spca506_WriteI2c(gspca_dev, 0x2a, 0x0f); |
| 466 | /* Chrominance Gain Control */ |
| 467 | /**************************************/ |
| 468 | spca506_WriteI2c(gspca_dev, 0x00, 0x10); |
| 469 | /* Format/Delay Control */ |
| 470 | spca506_WriteI2c(gspca_dev, 0x0c, 0x11); /* Output Control 1 */ |
| 471 | spca506_WriteI2c(gspca_dev, 0xb8, 0x12); /* Output Control 2 */ |
| 472 | spca506_WriteI2c(gspca_dev, 0x01, 0x13); /* Output Control 3 */ |
| 473 | spca506_WriteI2c(gspca_dev, 0x00, 0x14); /* reserved */ |
| 474 | spca506_WriteI2c(gspca_dev, 0x00, 0x15); /* VGATE START */ |
| 475 | spca506_WriteI2c(gspca_dev, 0x00, 0x16); /* VGATE STOP */ |
| 476 | spca506_WriteI2c(gspca_dev, 0x00, 0x17); /* VGATE Control (MSB) */ |
| 477 | spca506_WriteI2c(gspca_dev, 0x00, 0x18); |
| 478 | spca506_WriteI2c(gspca_dev, 0x00, 0x19); |
| 479 | spca506_WriteI2c(gspca_dev, 0x00, 0x1a); |
| 480 | spca506_WriteI2c(gspca_dev, 0x00, 0x1b); |
| 481 | spca506_WriteI2c(gspca_dev, 0x00, 0x1c); |
| 482 | spca506_WriteI2c(gspca_dev, 0x00, 0x1d); |
| 483 | spca506_WriteI2c(gspca_dev, 0x00, 0x1e); |
| 484 | spca506_WriteI2c(gspca_dev, 0xa1, 0x1f); |
| 485 | spca506_WriteI2c(gspca_dev, 0x02, 0x40); |
| 486 | spca506_WriteI2c(gspca_dev, 0xff, 0x41); |
| 487 | spca506_WriteI2c(gspca_dev, 0xff, 0x42); |
| 488 | spca506_WriteI2c(gspca_dev, 0xff, 0x43); |
| 489 | spca506_WriteI2c(gspca_dev, 0xff, 0x44); |
| 490 | spca506_WriteI2c(gspca_dev, 0xff, 0x45); |
| 491 | spca506_WriteI2c(gspca_dev, 0xff, 0x46); |
| 492 | spca506_WriteI2c(gspca_dev, 0xff, 0x47); |
| 493 | spca506_WriteI2c(gspca_dev, 0xff, 0x48); |
| 494 | spca506_WriteI2c(gspca_dev, 0xff, 0x49); |
| 495 | spca506_WriteI2c(gspca_dev, 0xff, 0x4a); |
| 496 | spca506_WriteI2c(gspca_dev, 0xff, 0x4b); |
| 497 | spca506_WriteI2c(gspca_dev, 0xff, 0x4c); |
| 498 | spca506_WriteI2c(gspca_dev, 0xff, 0x4d); |
| 499 | spca506_WriteI2c(gspca_dev, 0xff, 0x4e); |
| 500 | spca506_WriteI2c(gspca_dev, 0xff, 0x4f); |
| 501 | spca506_WriteI2c(gspca_dev, 0xff, 0x50); |
| 502 | spca506_WriteI2c(gspca_dev, 0xff, 0x51); |
| 503 | spca506_WriteI2c(gspca_dev, 0xff, 0x52); |
| 504 | spca506_WriteI2c(gspca_dev, 0xff, 0x53); |
| 505 | spca506_WriteI2c(gspca_dev, 0xff, 0x54); |
| 506 | spca506_WriteI2c(gspca_dev, 0xff, 0x55); |
| 507 | spca506_WriteI2c(gspca_dev, 0xff, 0x56); |
| 508 | spca506_WriteI2c(gspca_dev, 0xff, 0x57); |
| 509 | spca506_WriteI2c(gspca_dev, 0x00, 0x58); |
| 510 | spca506_WriteI2c(gspca_dev, 0x54, 0x59); |
| 511 | spca506_WriteI2c(gspca_dev, 0x07, 0x5a); |
| 512 | spca506_WriteI2c(gspca_dev, 0x83, 0x5b); |
| 513 | spca506_WriteI2c(gspca_dev, 0x00, 0x5c); |
| 514 | spca506_WriteI2c(gspca_dev, 0x00, 0x5d); |
| 515 | spca506_WriteI2c(gspca_dev, 0x00, 0x5e); |
| 516 | spca506_WriteI2c(gspca_dev, 0x00, 0x5f); |
| 517 | spca506_WriteI2c(gspca_dev, 0x00, 0x60); |
| 518 | spca506_WriteI2c(gspca_dev, 0x05, 0x61); |
| 519 | spca506_WriteI2c(gspca_dev, 0x9f, 0x62); |
| 520 | /**************************************/ |
| 521 | reg_w(dev, 0x05, 0x00, 0x0003); |
| 522 | reg_w(dev, 0x05, 0x00, 0x0004); |
| 523 | reg_w(dev, 0x03, 0x10, 0x0001); |
| 524 | reg_w(dev, 0x03, 0x78, 0x0000); |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 525 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 526 | case 0: |
| 527 | spca506_Setsize(gspca_dev, 0, 0x10, 0x10); |
| 528 | break; |
| 529 | case 1: |
| 530 | spca506_Setsize(gspca_dev, 1, 0x1a, 0x1a); |
| 531 | break; |
| 532 | case 2: |
| 533 | spca506_Setsize(gspca_dev, 2, 0x1c, 0x1c); |
| 534 | break; |
| 535 | case 4: |
| 536 | spca506_Setsize(gspca_dev, 4, 0x34, 0x34); |
| 537 | break; |
| 538 | default: |
| 539 | /* case 5: */ |
| 540 | spca506_Setsize(gspca_dev, 5, 0x40, 0x40); |
| 541 | break; |
| 542 | } |
| 543 | |
| 544 | /* compress setting and size */ |
| 545 | /* set i2c luma */ |
| 546 | reg_w(dev, 0x02, 0x01, 0x0000); |
Jean-Francois Moine | 739570b | 2008-07-14 09:38:29 -0300 | [diff] [blame] | 547 | reg_w(dev, 0x03, 0x12, 0x0000); |
| 548 | reg_r(gspca_dev, 0x04, 0x0001, 2); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 549 | PDEBUG(D_STREAM, "webcam started"); |
| 550 | spca506_GetNormeInput(gspca_dev, &norme, &channel); |
| 551 | spca506_SetNormeInput(gspca_dev, norme, channel); |
| 552 | } |
| 553 | |
| 554 | static void sd_stopN(struct gspca_dev *gspca_dev) |
| 555 | { |
| 556 | struct usb_device *dev = gspca_dev->dev; |
| 557 | |
| 558 | reg_w(dev, 0x02, 0x00, 0x0000); |
| 559 | reg_w(dev, 0x03, 0x00, 0x0004); |
| 560 | reg_w(dev, 0x03, 0x00, 0x0003); |
| 561 | } |
| 562 | |
| 563 | static void sd_stop0(struct gspca_dev *gspca_dev) |
| 564 | { |
| 565 | } |
| 566 | |
| 567 | static void sd_close(struct gspca_dev *gspca_dev) |
| 568 | { |
| 569 | } |
| 570 | |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 571 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
| 572 | struct gspca_frame *frame, /* target */ |
Jean-Francois Moine | c2446b3 | 2008-07-05 11:49:20 -0300 | [diff] [blame] | 573 | __u8 *data, /* isoc packet */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 574 | int len) /* iso packet length */ |
| 575 | { |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 576 | switch (data[0]) { |
| 577 | case 0: /* start of frame */ |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 578 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, |
| 579 | data, 0); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 580 | data += SPCA50X_OFFSET_DATA; |
| 581 | len -= SPCA50X_OFFSET_DATA; |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 582 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, |
| 583 | data, len); |
| 584 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 585 | case 0xff: /* drop */ |
| 586 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 587 | break; |
| 588 | default: |
| 589 | data += 1; |
| 590 | len -= 1; |
Jean-Francois Moine | 01b988b | 2008-07-30 05:33:11 -0300 | [diff] [blame] | 591 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, |
Jean-Francois Moine | 1250ac6 | 2008-07-26 08:02:47 -0300 | [diff] [blame] | 592 | data, len); |
| 593 | break; |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 594 | } |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | static void setbrightness(struct gspca_dev *gspca_dev) |
| 598 | { |
| 599 | struct sd *sd = (struct sd *) gspca_dev; |
| 600 | |
| 601 | spca506_Initi2c(gspca_dev); |
| 602 | spca506_WriteI2c(gspca_dev, sd->brightness, SAA7113_bright); |
| 603 | spca506_WriteI2c(gspca_dev, 0x01, 0x09); |
| 604 | } |
| 605 | |
| 606 | static void getbrightness(struct gspca_dev *gspca_dev) |
| 607 | { |
| 608 | struct sd *sd = (struct sd *) gspca_dev; |
| 609 | |
| 610 | sd->brightness = spca506_ReadI2c(gspca_dev, SAA7113_bright); |
| 611 | } |
| 612 | |
| 613 | static void setcontrast(struct gspca_dev *gspca_dev) |
| 614 | { |
| 615 | struct sd *sd = (struct sd *) gspca_dev; |
| 616 | |
| 617 | spca506_Initi2c(gspca_dev); |
| 618 | spca506_WriteI2c(gspca_dev, sd->contrast, SAA7113_contrast); |
| 619 | spca506_WriteI2c(gspca_dev, 0x01, 0x09); |
| 620 | } |
| 621 | |
| 622 | static void getcontrast(struct gspca_dev *gspca_dev) |
| 623 | { |
| 624 | struct sd *sd = (struct sd *) gspca_dev; |
| 625 | |
| 626 | sd->contrast = spca506_ReadI2c(gspca_dev, SAA7113_contrast); |
| 627 | } |
| 628 | |
| 629 | static void setcolors(struct gspca_dev *gspca_dev) |
| 630 | { |
| 631 | struct sd *sd = (struct sd *) gspca_dev; |
| 632 | |
| 633 | spca506_Initi2c(gspca_dev); |
| 634 | spca506_WriteI2c(gspca_dev, sd->colors, SAA7113_saturation); |
| 635 | spca506_WriteI2c(gspca_dev, 0x01, 0x09); |
| 636 | } |
| 637 | |
| 638 | static void getcolors(struct gspca_dev *gspca_dev) |
| 639 | { |
| 640 | struct sd *sd = (struct sd *) gspca_dev; |
| 641 | |
| 642 | sd->colors = spca506_ReadI2c(gspca_dev, SAA7113_saturation); |
| 643 | } |
| 644 | |
| 645 | static void sethue(struct gspca_dev *gspca_dev) |
| 646 | { |
| 647 | struct sd *sd = (struct sd *) gspca_dev; |
| 648 | |
| 649 | spca506_Initi2c(gspca_dev); |
| 650 | spca506_WriteI2c(gspca_dev, sd->hue, SAA7113_hue); |
| 651 | spca506_WriteI2c(gspca_dev, 0x01, 0x09); |
| 652 | } |
| 653 | |
| 654 | static void gethue(struct gspca_dev *gspca_dev) |
| 655 | { |
| 656 | struct sd *sd = (struct sd *) gspca_dev; |
| 657 | |
| 658 | sd->hue = spca506_ReadI2c(gspca_dev, SAA7113_hue); |
| 659 | } |
| 660 | |
| 661 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
| 662 | { |
| 663 | struct sd *sd = (struct sd *) gspca_dev; |
| 664 | |
| 665 | sd->brightness = val; |
| 666 | if (gspca_dev->streaming) |
| 667 | setbrightness(gspca_dev); |
| 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) |
| 672 | { |
| 673 | struct sd *sd = (struct sd *) gspca_dev; |
| 674 | |
| 675 | getbrightness(gspca_dev); |
| 676 | *val = sd->brightness; |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) |
| 681 | { |
| 682 | struct sd *sd = (struct sd *) gspca_dev; |
| 683 | |
| 684 | sd->contrast = val; |
| 685 | if (gspca_dev->streaming) |
| 686 | setcontrast(gspca_dev); |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) |
| 691 | { |
| 692 | struct sd *sd = (struct sd *) gspca_dev; |
| 693 | |
| 694 | getcontrast(gspca_dev); |
| 695 | *val = sd->contrast; |
| 696 | return 0; |
| 697 | } |
| 698 | |
| 699 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) |
| 700 | { |
| 701 | struct sd *sd = (struct sd *) gspca_dev; |
| 702 | |
| 703 | sd->colors = val; |
| 704 | if (gspca_dev->streaming) |
| 705 | setcolors(gspca_dev); |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) |
| 710 | { |
| 711 | struct sd *sd = (struct sd *) gspca_dev; |
| 712 | |
| 713 | getcolors(gspca_dev); |
| 714 | *val = sd->colors; |
| 715 | return 0; |
| 716 | } |
| 717 | |
| 718 | static int sd_sethue(struct gspca_dev *gspca_dev, __s32 val) |
| 719 | { |
| 720 | struct sd *sd = (struct sd *) gspca_dev; |
| 721 | |
| 722 | sd->hue = val; |
| 723 | if (gspca_dev->streaming) |
| 724 | sethue(gspca_dev); |
| 725 | return 0; |
| 726 | } |
| 727 | |
| 728 | static int sd_gethue(struct gspca_dev *gspca_dev, __s32 *val) |
| 729 | { |
| 730 | struct sd *sd = (struct sd *) gspca_dev; |
| 731 | |
| 732 | gethue(gspca_dev); |
| 733 | *val = sd->hue; |
| 734 | return 0; |
| 735 | } |
| 736 | |
| 737 | /* sub-driver description */ |
| 738 | static struct sd_desc sd_desc = { |
| 739 | .name = MODULE_NAME, |
| 740 | .ctrls = sd_ctrls, |
| 741 | .nctrls = ARRAY_SIZE(sd_ctrls), |
| 742 | .config = sd_config, |
| 743 | .open = sd_open, |
| 744 | .start = sd_start, |
| 745 | .stopN = sd_stopN, |
| 746 | .stop0 = sd_stop0, |
| 747 | .close = sd_close, |
| 748 | .pkt_scan = sd_pkt_scan, |
| 749 | }; |
| 750 | |
| 751 | /* -- module initialisation -- */ |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 752 | static __devinitdata struct usb_device_id device_table[] = { |
Jean-Francois Moine | 9d64fdb | 2008-07-25 08:53:03 -0300 | [diff] [blame] | 753 | {USB_DEVICE(0x06e1, 0xa190)}, |
| 754 | /*fixme: may be IntelPCCameraPro BRIDGE_SPCA505 |
| 755 | {USB_DEVICE(0x0733, 0x0430)}, */ |
| 756 | {USB_DEVICE(0x0734, 0x043b)}, |
| 757 | {USB_DEVICE(0x99fa, 0x8988)}, |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 758 | {} |
| 759 | }; |
| 760 | MODULE_DEVICE_TABLE(usb, device_table); |
| 761 | |
| 762 | /* -- device connect -- */ |
| 763 | static int sd_probe(struct usb_interface *intf, |
| 764 | const struct usb_device_id *id) |
| 765 | { |
| 766 | return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), |
| 767 | THIS_MODULE); |
| 768 | } |
| 769 | |
| 770 | static struct usb_driver sd_driver = { |
| 771 | .name = MODULE_NAME, |
| 772 | .id_table = device_table, |
| 773 | .probe = sd_probe, |
| 774 | .disconnect = gspca_disconnect, |
| 775 | }; |
| 776 | |
| 777 | /* -- module insert / remove -- */ |
| 778 | static int __init sd_mod_init(void) |
| 779 | { |
| 780 | if (usb_register(&sd_driver) < 0) |
| 781 | return -1; |
Jean-Francois Moine | 10b0e96 | 2008-07-22 05:35:10 -0300 | [diff] [blame] | 782 | PDEBUG(D_PROBE, "registered"); |
Jean-Francois Moine | 6a7eba2 | 2008-06-30 15:50:11 -0300 | [diff] [blame] | 783 | return 0; |
| 784 | } |
| 785 | static void __exit sd_mod_exit(void) |
| 786 | { |
| 787 | usb_deregister(&sd_driver); |
| 788 | PDEBUG(D_PROBE, "deregistered"); |
| 789 | } |
| 790 | |
| 791 | module_init(sd_mod_init); |
| 792 | module_exit(sd_mod_exit); |