1*fd9871f7SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 20c0d06caSMauro Carvalho Chehab /* 30c0d06caSMauro Carvalho Chehab * Sunplus spca561 subdriver 40c0d06caSMauro Carvalho Chehab * 50c0d06caSMauro Carvalho Chehab * Copyright (C) 2004 Michel Xhaard mxhaard@magic.fr 60c0d06caSMauro Carvalho Chehab * 70c0d06caSMauro Carvalho Chehab * V4L2 by Jean-Francois Moine <http://moinejf.free.fr> 80c0d06caSMauro Carvalho Chehab */ 90c0d06caSMauro Carvalho Chehab 100c0d06caSMauro Carvalho Chehab #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 110c0d06caSMauro Carvalho Chehab 120c0d06caSMauro Carvalho Chehab #define MODULE_NAME "spca561" 130c0d06caSMauro Carvalho Chehab 140c0d06caSMauro Carvalho Chehab #include <linux/input.h> 150c0d06caSMauro Carvalho Chehab #include "gspca.h" 160c0d06caSMauro Carvalho Chehab 170c0d06caSMauro Carvalho Chehab MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 180c0d06caSMauro Carvalho Chehab MODULE_DESCRIPTION("GSPCA/SPCA561 USB Camera Driver"); 190c0d06caSMauro Carvalho Chehab MODULE_LICENSE("GPL"); 200c0d06caSMauro Carvalho Chehab 210c0d06caSMauro Carvalho Chehab #define EXPOSURE_MAX (2047 + 325) 220c0d06caSMauro Carvalho Chehab 230c0d06caSMauro Carvalho Chehab /* specific webcam descriptor */ 240c0d06caSMauro Carvalho Chehab struct sd { 250c0d06caSMauro Carvalho Chehab struct gspca_dev gspca_dev; /* !! must be the first item */ 260c0d06caSMauro Carvalho Chehab 270c0d06caSMauro Carvalho Chehab struct { /* hue/contrast control cluster */ 280c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *contrast; 290c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *hue; 300c0d06caSMauro Carvalho Chehab }; 310c0d06caSMauro Carvalho Chehab struct v4l2_ctrl *autogain; 320c0d06caSMauro Carvalho Chehab 330c0d06caSMauro Carvalho Chehab #define EXPO12A_DEF 3 340c0d06caSMauro Carvalho Chehab __u8 expo12a; /* expo/gain? for rev 12a */ 350c0d06caSMauro Carvalho Chehab 360c0d06caSMauro Carvalho Chehab __u8 chip_revision; 370c0d06caSMauro Carvalho Chehab #define Rev012A 0 380c0d06caSMauro Carvalho Chehab #define Rev072A 1 390c0d06caSMauro Carvalho Chehab 400c0d06caSMauro Carvalho Chehab signed char ag_cnt; 410c0d06caSMauro Carvalho Chehab #define AG_CNT_START 13 420c0d06caSMauro Carvalho Chehab }; 430c0d06caSMauro Carvalho Chehab 440c0d06caSMauro Carvalho Chehab static const struct v4l2_pix_format sif_012a_mode[] = { 450c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, 460c0d06caSMauro Carvalho Chehab .bytesperline = 160, 470c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120, 480c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 490c0d06caSMauro Carvalho Chehab .priv = 3}, 500c0d06caSMauro Carvalho Chehab {176, 144, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, 510c0d06caSMauro Carvalho Chehab .bytesperline = 176, 520c0d06caSMauro Carvalho Chehab .sizeimage = 176 * 144, 530c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 540c0d06caSMauro Carvalho Chehab .priv = 2}, 550c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_SPCA561, V4L2_FIELD_NONE, 560c0d06caSMauro Carvalho Chehab .bytesperline = 320, 570c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240 * 4 / 8, 580c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 590c0d06caSMauro Carvalho Chehab .priv = 1}, 600c0d06caSMauro Carvalho Chehab {352, 288, V4L2_PIX_FMT_SPCA561, V4L2_FIELD_NONE, 610c0d06caSMauro Carvalho Chehab .bytesperline = 352, 620c0d06caSMauro Carvalho Chehab .sizeimage = 352 * 288 * 4 / 8, 630c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 640c0d06caSMauro Carvalho Chehab .priv = 0}, 650c0d06caSMauro Carvalho Chehab }; 660c0d06caSMauro Carvalho Chehab 670c0d06caSMauro Carvalho Chehab static const struct v4l2_pix_format sif_072a_mode[] = { 680c0d06caSMauro Carvalho Chehab {160, 120, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, 690c0d06caSMauro Carvalho Chehab .bytesperline = 160, 700c0d06caSMauro Carvalho Chehab .sizeimage = 160 * 120, 710c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 720c0d06caSMauro Carvalho Chehab .priv = 3}, 730c0d06caSMauro Carvalho Chehab {176, 144, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, 740c0d06caSMauro Carvalho Chehab .bytesperline = 176, 750c0d06caSMauro Carvalho Chehab .sizeimage = 176 * 144, 760c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 770c0d06caSMauro Carvalho Chehab .priv = 2}, 780c0d06caSMauro Carvalho Chehab {320, 240, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, 790c0d06caSMauro Carvalho Chehab .bytesperline = 320, 800c0d06caSMauro Carvalho Chehab .sizeimage = 320 * 240, 810c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 820c0d06caSMauro Carvalho Chehab .priv = 1}, 830c0d06caSMauro Carvalho Chehab {352, 288, V4L2_PIX_FMT_SGBRG8, V4L2_FIELD_NONE, 840c0d06caSMauro Carvalho Chehab .bytesperline = 352, 850c0d06caSMauro Carvalho Chehab .sizeimage = 352 * 288, 860c0d06caSMauro Carvalho Chehab .colorspace = V4L2_COLORSPACE_SRGB, 870c0d06caSMauro Carvalho Chehab .priv = 0}, 880c0d06caSMauro Carvalho Chehab }; 890c0d06caSMauro Carvalho Chehab 900c0d06caSMauro Carvalho Chehab /* 910c0d06caSMauro Carvalho Chehab * Initialization data 920c0d06caSMauro Carvalho Chehab * I'm not very sure how to split initialization from open data 930c0d06caSMauro Carvalho Chehab * chunks. For now, we'll consider everything as initialization 940c0d06caSMauro Carvalho Chehab */ 950c0d06caSMauro Carvalho Chehab /* Frame packet header offsets for the spca561 */ 960c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_SNAP 1 970c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_TYPE 2 980c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_COMPRESS 3 990c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_FRAMSEQ 4 1000c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_GPIO 5 1010c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_USBBUFF 6 1020c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN2GRAVE 7 1030c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN2RAVE 8 1040c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN2BAVE 9 1050c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN2GBAVE 10 1060c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN1GRAVE 11 1070c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN1RAVE 12 1080c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN1BAVE 13 1090c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_WIN1GBAVE 14 1100c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_FREQ 15 1110c0d06caSMauro Carvalho Chehab #define SPCA561_OFFSET_VSYNC 16 1120c0d06caSMauro Carvalho Chehab #define SPCA561_INDEX_I2C_BASE 0x8800 1130c0d06caSMauro Carvalho Chehab #define SPCA561_SNAPBIT 0x20 1140c0d06caSMauro Carvalho Chehab #define SPCA561_SNAPCTRL 0x40 1150c0d06caSMauro Carvalho Chehab 1160c0d06caSMauro Carvalho Chehab static const u16 rev72a_reset[][2] = { 1170c0d06caSMauro Carvalho Chehab {0x0000, 0x8114}, /* Software GPIO output data */ 1180c0d06caSMauro Carvalho Chehab {0x0001, 0x8114}, /* Software GPIO output data */ 1190c0d06caSMauro Carvalho Chehab {0x0000, 0x8112}, /* Some kind of reset */ 1200c0d06caSMauro Carvalho Chehab {} 1210c0d06caSMauro Carvalho Chehab }; 1220c0d06caSMauro Carvalho Chehab static const __u16 rev72a_init_data1[][2] = { 1230c0d06caSMauro Carvalho Chehab {0x0003, 0x8701}, /* PCLK clock delay adjustment */ 1240c0d06caSMauro Carvalho Chehab {0x0001, 0x8703}, /* HSYNC from cmos inverted */ 1250c0d06caSMauro Carvalho Chehab {0x0011, 0x8118}, /* Enable and conf sensor */ 1260c0d06caSMauro Carvalho Chehab {0x0001, 0x8118}, /* Conf sensor */ 1270c0d06caSMauro Carvalho Chehab {0x0092, 0x8804}, /* I know nothing about these */ 1280c0d06caSMauro Carvalho Chehab {0x0010, 0x8802}, /* 0x88xx registers, so I won't */ 1290c0d06caSMauro Carvalho Chehab {} 1300c0d06caSMauro Carvalho Chehab }; 1310c0d06caSMauro Carvalho Chehab static const u16 rev72a_init_sensor1[][2] = { 1320c0d06caSMauro Carvalho Chehab {0x0001, 0x000d}, 1330c0d06caSMauro Carvalho Chehab {0x0002, 0x0018}, 1340c0d06caSMauro Carvalho Chehab {0x0004, 0x0165}, 1350c0d06caSMauro Carvalho Chehab {0x0005, 0x0021}, 1360c0d06caSMauro Carvalho Chehab {0x0007, 0x00aa}, 1370c0d06caSMauro Carvalho Chehab {0x0020, 0x1504}, 1380c0d06caSMauro Carvalho Chehab {0x0039, 0x0002}, 1390c0d06caSMauro Carvalho Chehab {0x0035, 0x0010}, 1400c0d06caSMauro Carvalho Chehab {0x0009, 0x1049}, 1410c0d06caSMauro Carvalho Chehab {0x0028, 0x000b}, 1420c0d06caSMauro Carvalho Chehab {0x003b, 0x000f}, 1430c0d06caSMauro Carvalho Chehab {0x003c, 0x0000}, 1440c0d06caSMauro Carvalho Chehab {} 1450c0d06caSMauro Carvalho Chehab }; 1460c0d06caSMauro Carvalho Chehab static const __u16 rev72a_init_data2[][2] = { 1470c0d06caSMauro Carvalho Chehab {0x0018, 0x8601}, /* Pixel/line selection for color separation */ 1480c0d06caSMauro Carvalho Chehab {0x0000, 0x8602}, /* Optical black level for user setting */ 1490c0d06caSMauro Carvalho Chehab {0x0060, 0x8604}, /* Optical black horizontal offset */ 1500c0d06caSMauro Carvalho Chehab {0x0002, 0x8605}, /* Optical black vertical offset */ 1510c0d06caSMauro Carvalho Chehab {0x0000, 0x8603}, /* Non-automatic optical black level */ 1520c0d06caSMauro Carvalho Chehab {0x0002, 0x865b}, /* Horizontal offset for valid pixels */ 1530c0d06caSMauro Carvalho Chehab {0x0000, 0x865f}, /* Vertical valid pixels window (x2) */ 1540c0d06caSMauro Carvalho Chehab {0x00b0, 0x865d}, /* Horizontal valid pixels window (x2) */ 1550c0d06caSMauro Carvalho Chehab {0x0090, 0x865e}, /* Vertical valid lines window (x2) */ 1560c0d06caSMauro Carvalho Chehab {0x00e0, 0x8406}, /* Memory buffer threshold */ 1570c0d06caSMauro Carvalho Chehab {0x0000, 0x8660}, /* Compensation memory stuff */ 1580c0d06caSMauro Carvalho Chehab {0x0002, 0x8201}, /* Output address for r/w serial EEPROM */ 1590c0d06caSMauro Carvalho Chehab {0x0008, 0x8200}, /* Clear valid bit for serial EEPROM */ 1600c0d06caSMauro Carvalho Chehab {0x0001, 0x8200}, /* OprMode to be executed by hardware */ 1610c0d06caSMauro Carvalho Chehab /* from ms-win */ 1620c0d06caSMauro Carvalho Chehab {0x0000, 0x8611}, /* R offset for white balance */ 1630c0d06caSMauro Carvalho Chehab {0x00fd, 0x8612}, /* Gr offset for white balance */ 1640c0d06caSMauro Carvalho Chehab {0x0003, 0x8613}, /* B offset for white balance */ 1650c0d06caSMauro Carvalho Chehab {0x0000, 0x8614}, /* Gb offset for white balance */ 1660c0d06caSMauro Carvalho Chehab /* from ms-win */ 1670c0d06caSMauro Carvalho Chehab {0x0035, 0x8651}, /* R gain for white balance */ 1680c0d06caSMauro Carvalho Chehab {0x0040, 0x8652}, /* Gr gain for white balance */ 1690c0d06caSMauro Carvalho Chehab {0x005f, 0x8653}, /* B gain for white balance */ 1700c0d06caSMauro Carvalho Chehab {0x0040, 0x8654}, /* Gb gain for white balance */ 1710c0d06caSMauro Carvalho Chehab {0x0002, 0x8502}, /* Maximum average bit rate stuff */ 1720c0d06caSMauro Carvalho Chehab {0x0011, 0x8802}, 1730c0d06caSMauro Carvalho Chehab 1740c0d06caSMauro Carvalho Chehab {0x0087, 0x8700}, /* Set master clock (96Mhz????) */ 1750c0d06caSMauro Carvalho Chehab {0x0081, 0x8702}, /* Master clock output enable */ 1760c0d06caSMauro Carvalho Chehab 1770c0d06caSMauro Carvalho Chehab {0x0000, 0x8500}, /* Set image type (352x288 no compression) */ 1780c0d06caSMauro Carvalho Chehab /* Originally was 0x0010 (352x288 compression) */ 1790c0d06caSMauro Carvalho Chehab 1800c0d06caSMauro Carvalho Chehab {0x0002, 0x865b}, /* Horizontal offset for valid pixels */ 1810c0d06caSMauro Carvalho Chehab {0x0003, 0x865c}, /* Vertical offset for valid lines */ 1820c0d06caSMauro Carvalho Chehab {} 1830c0d06caSMauro Carvalho Chehab }; 1840c0d06caSMauro Carvalho Chehab static const u16 rev72a_init_sensor2[][2] = { 1850c0d06caSMauro Carvalho Chehab {0x0003, 0x0121}, 1860c0d06caSMauro Carvalho Chehab {0x0004, 0x0165}, 1870c0d06caSMauro Carvalho Chehab {0x0005, 0x002f}, /* blanking control column */ 1880c0d06caSMauro Carvalho Chehab {0x0006, 0x0000}, /* blanking mode row*/ 1890c0d06caSMauro Carvalho Chehab {0x000a, 0x0002}, 1900c0d06caSMauro Carvalho Chehab {0x0009, 0x1061}, /* setexposure times && pixel clock 1910c0d06caSMauro Carvalho Chehab * 0001 0 | 000 0110 0001 */ 1920c0d06caSMauro Carvalho Chehab {0x0035, 0x0014}, 1930c0d06caSMauro Carvalho Chehab {} 1940c0d06caSMauro Carvalho Chehab }; 1950c0d06caSMauro Carvalho Chehab 1960c0d06caSMauro Carvalho Chehab /******************** QC Express etch2 stuff ********************/ 1970c0d06caSMauro Carvalho Chehab static const __u16 Pb100_1map8300[][2] = { 1980c0d06caSMauro Carvalho Chehab /* reg, value */ 1990c0d06caSMauro Carvalho Chehab {0x8320, 0x3304}, 2000c0d06caSMauro Carvalho Chehab 2010c0d06caSMauro Carvalho Chehab {0x8303, 0x0125}, /* image area */ 2020c0d06caSMauro Carvalho Chehab {0x8304, 0x0169}, 2030c0d06caSMauro Carvalho Chehab {0x8328, 0x000b}, 2040c0d06caSMauro Carvalho Chehab {0x833c, 0x0001}, /*fixme: win:07*/ 2050c0d06caSMauro Carvalho Chehab 2060c0d06caSMauro Carvalho Chehab {0x832f, 0x1904}, /*fixme: was 0419*/ 2070c0d06caSMauro Carvalho Chehab {0x8307, 0x00aa}, 2080c0d06caSMauro Carvalho Chehab {0x8301, 0x0003}, 2090c0d06caSMauro Carvalho Chehab {0x8302, 0x000e}, 2100c0d06caSMauro Carvalho Chehab {} 2110c0d06caSMauro Carvalho Chehab }; 2120c0d06caSMauro Carvalho Chehab static const __u16 Pb100_2map8300[][2] = { 2130c0d06caSMauro Carvalho Chehab /* reg, value */ 2140c0d06caSMauro Carvalho Chehab {0x8339, 0x0000}, 2150c0d06caSMauro Carvalho Chehab {0x8307, 0x00aa}, 2160c0d06caSMauro Carvalho Chehab {} 2170c0d06caSMauro Carvalho Chehab }; 2180c0d06caSMauro Carvalho Chehab 2190c0d06caSMauro Carvalho Chehab static const __u16 spca561_161rev12A_data1[][2] = { 2200c0d06caSMauro Carvalho Chehab {0x29, 0x8118}, /* Control register (various enable bits) */ 2210c0d06caSMauro Carvalho Chehab {0x08, 0x8114}, /* GPIO: Led off */ 2220c0d06caSMauro Carvalho Chehab {0x0e, 0x8112}, /* 0x0e stream off 0x3e stream on */ 2230c0d06caSMauro Carvalho Chehab {0x00, 0x8102}, /* white balance - new */ 2240c0d06caSMauro Carvalho Chehab {0x92, 0x8804}, 2250c0d06caSMauro Carvalho Chehab {0x04, 0x8802}, /* windows uses 08 */ 2260c0d06caSMauro Carvalho Chehab {} 2270c0d06caSMauro Carvalho Chehab }; 2280c0d06caSMauro Carvalho Chehab static const __u16 spca561_161rev12A_data2[][2] = { 2290c0d06caSMauro Carvalho Chehab {0x21, 0x8118}, 2300c0d06caSMauro Carvalho Chehab {0x10, 0x8500}, 2310c0d06caSMauro Carvalho Chehab {0x07, 0x8601}, 2320c0d06caSMauro Carvalho Chehab {0x07, 0x8602}, 2330c0d06caSMauro Carvalho Chehab {0x04, 0x8501}, 2340c0d06caSMauro Carvalho Chehab 2350c0d06caSMauro Carvalho Chehab {0x07, 0x8201}, /* windows uses 02 */ 2360c0d06caSMauro Carvalho Chehab {0x08, 0x8200}, 2370c0d06caSMauro Carvalho Chehab {0x01, 0x8200}, 2380c0d06caSMauro Carvalho Chehab 2390c0d06caSMauro Carvalho Chehab {0x90, 0x8604}, 2400c0d06caSMauro Carvalho Chehab {0x00, 0x8605}, 2410c0d06caSMauro Carvalho Chehab {0xb0, 0x8603}, 2420c0d06caSMauro Carvalho Chehab 2430c0d06caSMauro Carvalho Chehab /* sensor gains */ 2440c0d06caSMauro Carvalho Chehab {0x07, 0x8601}, /* white balance - new */ 2450c0d06caSMauro Carvalho Chehab {0x07, 0x8602}, /* white balance - new */ 2460c0d06caSMauro Carvalho Chehab {0x00, 0x8610}, /* *red */ 2470c0d06caSMauro Carvalho Chehab {0x00, 0x8611}, /* 3f *green */ 2480c0d06caSMauro Carvalho Chehab {0x00, 0x8612}, /* green *blue */ 2490c0d06caSMauro Carvalho Chehab {0x00, 0x8613}, /* blue *green */ 2500c0d06caSMauro Carvalho Chehab {0x43, 0x8614}, /* green *red - white balance - was 0x35 */ 2510c0d06caSMauro Carvalho Chehab {0x40, 0x8615}, /* 40 *green - white balance - was 0x35 */ 2520c0d06caSMauro Carvalho Chehab {0x71, 0x8616}, /* 7a *blue - white balance - was 0x35 */ 2530c0d06caSMauro Carvalho Chehab {0x40, 0x8617}, /* 40 *green - white balance - was 0x35 */ 2540c0d06caSMauro Carvalho Chehab 2550c0d06caSMauro Carvalho Chehab {0x0c, 0x8620}, /* 0c */ 2560c0d06caSMauro Carvalho Chehab {0xc8, 0x8631}, /* c8 */ 2570c0d06caSMauro Carvalho Chehab {0xc8, 0x8634}, /* c8 */ 2580c0d06caSMauro Carvalho Chehab {0x23, 0x8635}, /* 23 */ 2590c0d06caSMauro Carvalho Chehab {0x1f, 0x8636}, /* 1f */ 2600c0d06caSMauro Carvalho Chehab {0xdd, 0x8637}, /* dd */ 2610c0d06caSMauro Carvalho Chehab {0xe1, 0x8638}, /* e1 */ 2620c0d06caSMauro Carvalho Chehab {0x1d, 0x8639}, /* 1d */ 2630c0d06caSMauro Carvalho Chehab {0x21, 0x863a}, /* 21 */ 2640c0d06caSMauro Carvalho Chehab {0xe3, 0x863b}, /* e3 */ 2650c0d06caSMauro Carvalho Chehab {0xdf, 0x863c}, /* df */ 2660c0d06caSMauro Carvalho Chehab {0xf0, 0x8505}, 2670c0d06caSMauro Carvalho Chehab {0x32, 0x850a}, 2680c0d06caSMauro Carvalho Chehab /* {0x99, 0x8700}, * - white balance - new (removed) */ 2690c0d06caSMauro Carvalho Chehab /* HDG we used to do this in stop0, making the init state and the state 2700c0d06caSMauro Carvalho Chehab after a start / stop different, so do this here instead. */ 2710c0d06caSMauro Carvalho Chehab {0x29, 0x8118}, 2720c0d06caSMauro Carvalho Chehab {} 2730c0d06caSMauro Carvalho Chehab }; 2740c0d06caSMauro Carvalho Chehab 275c93396e1STheodore Kilgore static void reg_w_val(struct gspca_dev *gspca_dev, __u16 index, __u8 value) 2760c0d06caSMauro Carvalho Chehab { 2770c0d06caSMauro Carvalho Chehab int ret; 278c93396e1STheodore Kilgore struct usb_device *dev = gspca_dev->dev; 2790c0d06caSMauro Carvalho Chehab 2800c0d06caSMauro Carvalho Chehab ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2810c0d06caSMauro Carvalho Chehab 0, /* request */ 2820c0d06caSMauro Carvalho Chehab USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 2830c0d06caSMauro Carvalho Chehab value, index, NULL, 0, 500); 28437d5efb0SJoe Perches gspca_dbg(gspca_dev, D_USBO, "reg write: 0x%02x:0x%02x\n", 28537d5efb0SJoe Perches index, value); 2860c0d06caSMauro Carvalho Chehab if (ret < 0) 2870c0d06caSMauro Carvalho Chehab pr_err("reg write: error %d\n", ret); 2880c0d06caSMauro Carvalho Chehab } 2890c0d06caSMauro Carvalho Chehab 2900c0d06caSMauro Carvalho Chehab static void write_vector(struct gspca_dev *gspca_dev, 2910c0d06caSMauro Carvalho Chehab const __u16 data[][2]) 2920c0d06caSMauro Carvalho Chehab { 2930c0d06caSMauro Carvalho Chehab int i; 2940c0d06caSMauro Carvalho Chehab 2950c0d06caSMauro Carvalho Chehab i = 0; 2960c0d06caSMauro Carvalho Chehab while (data[i][1] != 0) { 297c93396e1STheodore Kilgore reg_w_val(gspca_dev, data[i][1], data[i][0]); 2980c0d06caSMauro Carvalho Chehab i++; 2990c0d06caSMauro Carvalho Chehab } 3000c0d06caSMauro Carvalho Chehab } 3010c0d06caSMauro Carvalho Chehab 3020c0d06caSMauro Carvalho Chehab /* read 'len' bytes to gspca_dev->usb_buf */ 3030c0d06caSMauro Carvalho Chehab static void reg_r(struct gspca_dev *gspca_dev, 3040c0d06caSMauro Carvalho Chehab __u16 index, __u16 length) 3050c0d06caSMauro Carvalho Chehab { 3060c0d06caSMauro Carvalho Chehab usb_control_msg(gspca_dev->dev, 3070c0d06caSMauro Carvalho Chehab usb_rcvctrlpipe(gspca_dev->dev, 0), 3080c0d06caSMauro Carvalho Chehab 0, /* request */ 3090c0d06caSMauro Carvalho Chehab USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 3100c0d06caSMauro Carvalho Chehab 0, /* value */ 3110c0d06caSMauro Carvalho Chehab index, gspca_dev->usb_buf, length, 500); 3120c0d06caSMauro Carvalho Chehab } 3130c0d06caSMauro Carvalho Chehab 3140c0d06caSMauro Carvalho Chehab /* write 'len' bytes from gspca_dev->usb_buf */ 3150c0d06caSMauro Carvalho Chehab static void reg_w_buf(struct gspca_dev *gspca_dev, 3160c0d06caSMauro Carvalho Chehab __u16 index, __u16 len) 3170c0d06caSMauro Carvalho Chehab { 3180c0d06caSMauro Carvalho Chehab usb_control_msg(gspca_dev->dev, 3190c0d06caSMauro Carvalho Chehab usb_sndctrlpipe(gspca_dev->dev, 0), 3200c0d06caSMauro Carvalho Chehab 0, /* request */ 3210c0d06caSMauro Carvalho Chehab USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 3220c0d06caSMauro Carvalho Chehab 0, /* value */ 3230c0d06caSMauro Carvalho Chehab index, gspca_dev->usb_buf, len, 500); 3240c0d06caSMauro Carvalho Chehab } 3250c0d06caSMauro Carvalho Chehab 3260c0d06caSMauro Carvalho Chehab static void i2c_write(struct gspca_dev *gspca_dev, __u16 value, __u16 reg) 3270c0d06caSMauro Carvalho Chehab { 3280c0d06caSMauro Carvalho Chehab int retry = 60; 3290c0d06caSMauro Carvalho Chehab 330c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8801, reg); 331c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8805, value); 332c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8800, value >> 8); 3330c0d06caSMauro Carvalho Chehab do { 3340c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8803, 1); 3350c0d06caSMauro Carvalho Chehab if (!gspca_dev->usb_buf[0]) 3360c0d06caSMauro Carvalho Chehab return; 3370c0d06caSMauro Carvalho Chehab msleep(10); 3380c0d06caSMauro Carvalho Chehab } while (--retry); 3390c0d06caSMauro Carvalho Chehab } 3400c0d06caSMauro Carvalho Chehab 3410c0d06caSMauro Carvalho Chehab static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode) 3420c0d06caSMauro Carvalho Chehab { 3430c0d06caSMauro Carvalho Chehab int retry = 60; 3440c0d06caSMauro Carvalho Chehab __u8 value; 3450c0d06caSMauro Carvalho Chehab 346c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8804, 0x92); 347c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8801, reg); 348c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8802, mode | 0x01); 3490c0d06caSMauro Carvalho Chehab do { 3500c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8803, 1); 3510c0d06caSMauro Carvalho Chehab if (!gspca_dev->usb_buf[0]) { 3520c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8800, 1); 3530c0d06caSMauro Carvalho Chehab value = gspca_dev->usb_buf[0]; 3540c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8805, 1); 3550c0d06caSMauro Carvalho Chehab return ((int) value << 8) | gspca_dev->usb_buf[0]; 3560c0d06caSMauro Carvalho Chehab } 3570c0d06caSMauro Carvalho Chehab msleep(10); 3580c0d06caSMauro Carvalho Chehab } while (--retry); 3590c0d06caSMauro Carvalho Chehab return -1; 3600c0d06caSMauro Carvalho Chehab } 3610c0d06caSMauro Carvalho Chehab 3620c0d06caSMauro Carvalho Chehab static void sensor_mapwrite(struct gspca_dev *gspca_dev, 3630c0d06caSMauro Carvalho Chehab const __u16 (*sensormap)[2]) 3640c0d06caSMauro Carvalho Chehab { 3650c0d06caSMauro Carvalho Chehab while ((*sensormap)[0]) { 3660c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[0] = (*sensormap)[1]; 3670c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[1] = (*sensormap)[1] >> 8; 3680c0d06caSMauro Carvalho Chehab reg_w_buf(gspca_dev, (*sensormap)[0], 2); 3690c0d06caSMauro Carvalho Chehab sensormap++; 3700c0d06caSMauro Carvalho Chehab } 3710c0d06caSMauro Carvalho Chehab } 3720c0d06caSMauro Carvalho Chehab 3730c0d06caSMauro Carvalho Chehab static void write_sensor_72a(struct gspca_dev *gspca_dev, 3740c0d06caSMauro Carvalho Chehab const __u16 (*sensor)[2]) 3750c0d06caSMauro Carvalho Chehab { 3760c0d06caSMauro Carvalho Chehab while ((*sensor)[0]) { 3770c0d06caSMauro Carvalho Chehab i2c_write(gspca_dev, (*sensor)[1], (*sensor)[0]); 3780c0d06caSMauro Carvalho Chehab sensor++; 3790c0d06caSMauro Carvalho Chehab } 3800c0d06caSMauro Carvalho Chehab } 3810c0d06caSMauro Carvalho Chehab 3820c0d06caSMauro Carvalho Chehab static void init_161rev12A(struct gspca_dev *gspca_dev) 3830c0d06caSMauro Carvalho Chehab { 3840c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, spca561_161rev12A_data1); 3850c0d06caSMauro Carvalho Chehab sensor_mapwrite(gspca_dev, Pb100_1map8300); 3860c0d06caSMauro Carvalho Chehab /*fixme: should be in sd_start*/ 3870c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, spca561_161rev12A_data2); 3880c0d06caSMauro Carvalho Chehab sensor_mapwrite(gspca_dev, Pb100_2map8300); 3890c0d06caSMauro Carvalho Chehab } 3900c0d06caSMauro Carvalho Chehab 3910c0d06caSMauro Carvalho Chehab /* this function is called at probe time */ 3920c0d06caSMauro Carvalho Chehab static int sd_config(struct gspca_dev *gspca_dev, 3930c0d06caSMauro Carvalho Chehab const struct usb_device_id *id) 3940c0d06caSMauro Carvalho Chehab { 3950c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 3960c0d06caSMauro Carvalho Chehab struct cam *cam; 3970c0d06caSMauro Carvalho Chehab __u16 vendor, product; 3980c0d06caSMauro Carvalho Chehab __u8 data1, data2; 3990c0d06caSMauro Carvalho Chehab 4000c0d06caSMauro Carvalho Chehab /* Read frm global register the USB product and vendor IDs, just to 4010c0d06caSMauro Carvalho Chehab * prove that we can communicate with the device. This works, which 4020c0d06caSMauro Carvalho Chehab * confirms at we are communicating properly and that the device 4030c0d06caSMauro Carvalho Chehab * is a 561. */ 4040c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8104, 1); 4050c0d06caSMauro Carvalho Chehab data1 = gspca_dev->usb_buf[0]; 4060c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8105, 1); 4070c0d06caSMauro Carvalho Chehab data2 = gspca_dev->usb_buf[0]; 4080c0d06caSMauro Carvalho Chehab vendor = (data2 << 8) | data1; 4090c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8106, 1); 4100c0d06caSMauro Carvalho Chehab data1 = gspca_dev->usb_buf[0]; 4110c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8107, 1); 4120c0d06caSMauro Carvalho Chehab data2 = gspca_dev->usb_buf[0]; 4130c0d06caSMauro Carvalho Chehab product = (data2 << 8) | data1; 4140c0d06caSMauro Carvalho Chehab if (vendor != id->idVendor || product != id->idProduct) { 41537d5efb0SJoe Perches gspca_dbg(gspca_dev, D_PROBE, "Bad vendor / product from device\n"); 4160c0d06caSMauro Carvalho Chehab return -EINVAL; 4170c0d06caSMauro Carvalho Chehab } 4180c0d06caSMauro Carvalho Chehab 4190c0d06caSMauro Carvalho Chehab cam = &gspca_dev->cam; 4200c0d06caSMauro Carvalho Chehab cam->needs_full_bandwidth = 1; 4210c0d06caSMauro Carvalho Chehab 4220c0d06caSMauro Carvalho Chehab sd->chip_revision = id->driver_info; 4230c0d06caSMauro Carvalho Chehab if (sd->chip_revision == Rev012A) { 4240c0d06caSMauro Carvalho Chehab cam->cam_mode = sif_012a_mode; 4250c0d06caSMauro Carvalho Chehab cam->nmodes = ARRAY_SIZE(sif_012a_mode); 4260c0d06caSMauro Carvalho Chehab } else { 4270c0d06caSMauro Carvalho Chehab cam->cam_mode = sif_072a_mode; 4280c0d06caSMauro Carvalho Chehab cam->nmodes = ARRAY_SIZE(sif_072a_mode); 4290c0d06caSMauro Carvalho Chehab } 4300c0d06caSMauro Carvalho Chehab sd->expo12a = EXPO12A_DEF; 4310c0d06caSMauro Carvalho Chehab return 0; 4320c0d06caSMauro Carvalho Chehab } 4330c0d06caSMauro Carvalho Chehab 4340c0d06caSMauro Carvalho Chehab /* this function is called at probe and resume time */ 4350c0d06caSMauro Carvalho Chehab static int sd_init_12a(struct gspca_dev *gspca_dev) 4360c0d06caSMauro Carvalho Chehab { 43737d5efb0SJoe Perches gspca_dbg(gspca_dev, D_STREAM, "Chip revision: 012a\n"); 4380c0d06caSMauro Carvalho Chehab init_161rev12A(gspca_dev); 4390c0d06caSMauro Carvalho Chehab return 0; 4400c0d06caSMauro Carvalho Chehab } 4410c0d06caSMauro Carvalho Chehab static int sd_init_72a(struct gspca_dev *gspca_dev) 4420c0d06caSMauro Carvalho Chehab { 44337d5efb0SJoe Perches gspca_dbg(gspca_dev, D_STREAM, "Chip revision: 072a\n"); 4440c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, rev72a_reset); 4450c0d06caSMauro Carvalho Chehab msleep(200); 4460c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, rev72a_init_data1); 4470c0d06caSMauro Carvalho Chehab write_sensor_72a(gspca_dev, rev72a_init_sensor1); 4480c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, rev72a_init_data2); 4490c0d06caSMauro Carvalho Chehab write_sensor_72a(gspca_dev, rev72a_init_sensor2); 450c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8112, 0x30); 4510c0d06caSMauro Carvalho Chehab return 0; 4520c0d06caSMauro Carvalho Chehab } 4530c0d06caSMauro Carvalho Chehab 4540c0d06caSMauro Carvalho Chehab static void setbrightness(struct gspca_dev *gspca_dev, s32 val) 4550c0d06caSMauro Carvalho Chehab { 4560c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 4570c0d06caSMauro Carvalho Chehab __u16 reg; 4580c0d06caSMauro Carvalho Chehab 4590c0d06caSMauro Carvalho Chehab if (sd->chip_revision == Rev012A) 4600c0d06caSMauro Carvalho Chehab reg = 0x8610; 4610c0d06caSMauro Carvalho Chehab else 4620c0d06caSMauro Carvalho Chehab reg = 0x8611; 4630c0d06caSMauro Carvalho Chehab 464c93396e1STheodore Kilgore reg_w_val(gspca_dev, reg + 0, val); /* R */ 465c93396e1STheodore Kilgore reg_w_val(gspca_dev, reg + 1, val); /* Gr */ 466c93396e1STheodore Kilgore reg_w_val(gspca_dev, reg + 2, val); /* B */ 467c93396e1STheodore Kilgore reg_w_val(gspca_dev, reg + 3, val); /* Gb */ 4680c0d06caSMauro Carvalho Chehab } 4690c0d06caSMauro Carvalho Chehab 4700c0d06caSMauro Carvalho Chehab static void setwhite(struct gspca_dev *gspca_dev, s32 white, s32 contrast) 4710c0d06caSMauro Carvalho Chehab { 4720c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 4730c0d06caSMauro Carvalho Chehab __u8 blue, red; 4740c0d06caSMauro Carvalho Chehab __u16 reg; 4750c0d06caSMauro Carvalho Chehab 4760c0d06caSMauro Carvalho Chehab /* try to emulate MS-win as possible */ 4770c0d06caSMauro Carvalho Chehab red = 0x20 + white * 3 / 8; 4780c0d06caSMauro Carvalho Chehab blue = 0x90 - white * 5 / 8; 4790c0d06caSMauro Carvalho Chehab if (sd->chip_revision == Rev012A) { 4800c0d06caSMauro Carvalho Chehab reg = 0x8614; 4810c0d06caSMauro Carvalho Chehab } else { 4820c0d06caSMauro Carvalho Chehab reg = 0x8651; 4830c0d06caSMauro Carvalho Chehab red += contrast - 0x20; 4840c0d06caSMauro Carvalho Chehab blue += contrast - 0x20; 485c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8652, contrast + 0x20); /* Gr */ 486c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8654, contrast + 0x20); /* Gb */ 4870c0d06caSMauro Carvalho Chehab } 488c93396e1STheodore Kilgore reg_w_val(gspca_dev, reg, red); 489c93396e1STheodore Kilgore reg_w_val(gspca_dev, reg + 2, blue); 4900c0d06caSMauro Carvalho Chehab } 4910c0d06caSMauro Carvalho Chehab 4920c0d06caSMauro Carvalho Chehab /* rev 12a only */ 4930c0d06caSMauro Carvalho Chehab static void setexposure(struct gspca_dev *gspca_dev, s32 val) 4940c0d06caSMauro Carvalho Chehab { 4950c0d06caSMauro Carvalho Chehab int i, expo = 0; 4960c0d06caSMauro Carvalho Chehab 4970c0d06caSMauro Carvalho Chehab /* Register 0x8309 controls exposure for the spca561, 4980c0d06caSMauro Carvalho Chehab the basic exposure setting goes from 1-2047, where 1 is completely 4990c0d06caSMauro Carvalho Chehab dark and 2047 is very bright. It not only influences exposure but 5000c0d06caSMauro Carvalho Chehab also the framerate (to allow for longer exposure) from 1 - 300 it 5010c0d06caSMauro Carvalho Chehab only raises the exposure time then from 300 - 600 it halves the 5020c0d06caSMauro Carvalho Chehab framerate to be able to further raise the exposure time and for every 5030c0d06caSMauro Carvalho Chehab 300 more it halves the framerate again. This allows for a maximum 5040c0d06caSMauro Carvalho Chehab exposure time of circa 0.2 - 0.25 seconds (30 / (2000/3000) fps). 5050c0d06caSMauro Carvalho Chehab Sometimes this is not enough, the 1-2047 uses bits 0-10, bits 11-12 5060c0d06caSMauro Carvalho Chehab configure a divider for the base framerate which us used at the 5070c0d06caSMauro Carvalho Chehab exposure setting of 1-300. These bits configure the base framerate 5080c0d06caSMauro Carvalho Chehab according to the following formula: fps = 60 / (value + 2) */ 5090c0d06caSMauro Carvalho Chehab 5100c0d06caSMauro Carvalho Chehab /* We choose to use the high bits setting the fixed framerate divisor 5110c0d06caSMauro Carvalho Chehab asap, as setting high basic exposure setting without the fixed 5120c0d06caSMauro Carvalho Chehab divider in combination with high gains makes the cam stop */ 5130c0d06caSMauro Carvalho Chehab int table[] = { 0, 450, 550, 625, EXPOSURE_MAX }; 5140c0d06caSMauro Carvalho Chehab 5150c0d06caSMauro Carvalho Chehab for (i = 0; i < ARRAY_SIZE(table) - 1; i++) { 5160c0d06caSMauro Carvalho Chehab if (val <= table[i + 1]) { 5170c0d06caSMauro Carvalho Chehab expo = val - table[i]; 5180c0d06caSMauro Carvalho Chehab if (i) 5190c0d06caSMauro Carvalho Chehab expo += 300; 5200c0d06caSMauro Carvalho Chehab expo |= i << 11; 5210c0d06caSMauro Carvalho Chehab break; 5220c0d06caSMauro Carvalho Chehab } 5230c0d06caSMauro Carvalho Chehab } 5240c0d06caSMauro Carvalho Chehab 5250c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[0] = expo; 5260c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[1] = expo >> 8; 5270c0d06caSMauro Carvalho Chehab reg_w_buf(gspca_dev, 0x8309, 2); 5280c0d06caSMauro Carvalho Chehab } 5290c0d06caSMauro Carvalho Chehab 5300c0d06caSMauro Carvalho Chehab /* rev 12a only */ 5310c0d06caSMauro Carvalho Chehab static void setgain(struct gspca_dev *gspca_dev, s32 val) 5320c0d06caSMauro Carvalho Chehab { 5330c0d06caSMauro Carvalho Chehab /* gain reg low 6 bits 0-63 gain, bit 6 and 7, both double the 5340c0d06caSMauro Carvalho Chehab sensitivity when set, so 31 + one of them set == 63, and 15 5350c0d06caSMauro Carvalho Chehab with both of them set == 63 */ 5360c0d06caSMauro Carvalho Chehab if (val < 64) 5370c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[0] = val; 5380c0d06caSMauro Carvalho Chehab else if (val < 128) 5390c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[0] = (val / 2) | 0x40; 5400c0d06caSMauro Carvalho Chehab else 5410c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[0] = (val / 4) | 0xc0; 5420c0d06caSMauro Carvalho Chehab 5430c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[1] = 0; 5440c0d06caSMauro Carvalho Chehab reg_w_buf(gspca_dev, 0x8335, 2); 5450c0d06caSMauro Carvalho Chehab } 5460c0d06caSMauro Carvalho Chehab 5470c0d06caSMauro Carvalho Chehab static void setautogain(struct gspca_dev *gspca_dev, s32 val) 5480c0d06caSMauro Carvalho Chehab { 5490c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 5500c0d06caSMauro Carvalho Chehab 5510c0d06caSMauro Carvalho Chehab if (val) 5520c0d06caSMauro Carvalho Chehab sd->ag_cnt = AG_CNT_START; 5530c0d06caSMauro Carvalho Chehab else 5540c0d06caSMauro Carvalho Chehab sd->ag_cnt = -1; 5550c0d06caSMauro Carvalho Chehab } 5560c0d06caSMauro Carvalho Chehab 5570c0d06caSMauro Carvalho Chehab static int sd_start_12a(struct gspca_dev *gspca_dev) 5580c0d06caSMauro Carvalho Chehab { 5590c0d06caSMauro Carvalho Chehab int mode; 5600c0d06caSMauro Carvalho Chehab static const __u8 Reg8391[8] = 5610c0d06caSMauro Carvalho Chehab {0x92, 0x30, 0x20, 0x00, 0x0c, 0x00, 0x00, 0x00}; 5620c0d06caSMauro Carvalho Chehab 5630c0d06caSMauro Carvalho Chehab mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 5640c0d06caSMauro Carvalho Chehab if (mode <= 1) { 5650c0d06caSMauro Carvalho Chehab /* Use compression on 320x240 and above */ 566c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8500, 0x10 | mode); 5670c0d06caSMauro Carvalho Chehab } else { 5680c0d06caSMauro Carvalho Chehab /* I couldn't get the compression to work below 320x240 5690c0d06caSMauro Carvalho Chehab * Fortunately at these resolutions the bandwidth 5700c0d06caSMauro Carvalho Chehab * is sufficient to push raw frames at ~20fps */ 571c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8500, mode); 5720c0d06caSMauro Carvalho Chehab } /* -- qq@kuku.eu.org */ 5730c0d06caSMauro Carvalho Chehab 5740c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[0] = 0xaa; 5750c0d06caSMauro Carvalho Chehab gspca_dev->usb_buf[1] = 0x00; 5760c0d06caSMauro Carvalho Chehab reg_w_buf(gspca_dev, 0x8307, 2); 5770c0d06caSMauro Carvalho Chehab /* clock - lower 0x8X values lead to fps > 30 */ 578c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8700, 0x8a); 5790c0d06caSMauro Carvalho Chehab /* 0x8f 0x85 0x27 clock */ 580c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8112, 0x1e | 0x20); 581c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x850b, 0x03); 5820c0d06caSMauro Carvalho Chehab memcpy(gspca_dev->usb_buf, Reg8391, 8); 5830c0d06caSMauro Carvalho Chehab reg_w_buf(gspca_dev, 0x8391, 8); 5840c0d06caSMauro Carvalho Chehab reg_w_buf(gspca_dev, 0x8390, 8); 5850c0d06caSMauro Carvalho Chehab 5860c0d06caSMauro Carvalho Chehab /* Led ON (bit 3 -> 0 */ 587c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8114, 0x00); 5880c0d06caSMauro Carvalho Chehab return 0; 5890c0d06caSMauro Carvalho Chehab } 5900c0d06caSMauro Carvalho Chehab static int sd_start_72a(struct gspca_dev *gspca_dev) 5910c0d06caSMauro Carvalho Chehab { 5920c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 5930c0d06caSMauro Carvalho Chehab int Clck; 5940c0d06caSMauro Carvalho Chehab int mode; 5950c0d06caSMauro Carvalho Chehab 5960c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, rev72a_reset); 5970c0d06caSMauro Carvalho Chehab msleep(200); 5980c0d06caSMauro Carvalho Chehab write_vector(gspca_dev, rev72a_init_data1); 5990c0d06caSMauro Carvalho Chehab write_sensor_72a(gspca_dev, rev72a_init_sensor1); 6000c0d06caSMauro Carvalho Chehab 6010c0d06caSMauro Carvalho Chehab mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 6020c0d06caSMauro Carvalho Chehab switch (mode) { 6030c0d06caSMauro Carvalho Chehab default: 6040c0d06caSMauro Carvalho Chehab case 0: 6050c0d06caSMauro Carvalho Chehab Clck = 0x27; /* ms-win 0x87 */ 6060c0d06caSMauro Carvalho Chehab break; 6070c0d06caSMauro Carvalho Chehab case 1: 6080c0d06caSMauro Carvalho Chehab Clck = 0x25; 6090c0d06caSMauro Carvalho Chehab break; 6100c0d06caSMauro Carvalho Chehab case 2: 6110c0d06caSMauro Carvalho Chehab Clck = 0x22; 6120c0d06caSMauro Carvalho Chehab break; 6130c0d06caSMauro Carvalho Chehab case 3: 6140c0d06caSMauro Carvalho Chehab Clck = 0x21; 6150c0d06caSMauro Carvalho Chehab break; 6160c0d06caSMauro Carvalho Chehab } 617c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8700, Clck); /* 0x27 clock */ 618c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8702, 0x81); 619c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8500, mode); /* mode */ 6200c0d06caSMauro Carvalho Chehab write_sensor_72a(gspca_dev, rev72a_init_sensor2); 6210c0d06caSMauro Carvalho Chehab setwhite(gspca_dev, v4l2_ctrl_g_ctrl(sd->hue), 6220c0d06caSMauro Carvalho Chehab v4l2_ctrl_g_ctrl(sd->contrast)); 6230c0d06caSMauro Carvalho Chehab /* setbrightness(gspca_dev); * fixme: bad values */ 6240c0d06caSMauro Carvalho Chehab setautogain(gspca_dev, v4l2_ctrl_g_ctrl(sd->autogain)); 625c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8112, 0x10 | 0x20); 6260c0d06caSMauro Carvalho Chehab return 0; 6270c0d06caSMauro Carvalho Chehab } 6280c0d06caSMauro Carvalho Chehab 6290c0d06caSMauro Carvalho Chehab static void sd_stopN(struct gspca_dev *gspca_dev) 6300c0d06caSMauro Carvalho Chehab { 6310c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 6320c0d06caSMauro Carvalho Chehab 6330c0d06caSMauro Carvalho Chehab if (sd->chip_revision == Rev012A) { 634c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8112, 0x0e); 6350c0d06caSMauro Carvalho Chehab /* Led Off (bit 3 -> 1 */ 636c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8114, 0x08); 6370c0d06caSMauro Carvalho Chehab } else { 638c93396e1STheodore Kilgore reg_w_val(gspca_dev, 0x8112, 0x20); 639c93396e1STheodore Kilgore /* reg_w_val(gspca_dev, 0x8102, 0x00); ?? */ 6400c0d06caSMauro Carvalho Chehab } 6410c0d06caSMauro Carvalho Chehab } 6420c0d06caSMauro Carvalho Chehab 6430c0d06caSMauro Carvalho Chehab static void do_autogain(struct gspca_dev *gspca_dev) 6440c0d06caSMauro Carvalho Chehab { 6450c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 6460c0d06caSMauro Carvalho Chehab int expotimes; 6470c0d06caSMauro Carvalho Chehab int pixelclk; 6480c0d06caSMauro Carvalho Chehab int gainG; 6490c0d06caSMauro Carvalho Chehab __u8 R, Gr, Gb, B; 6500c0d06caSMauro Carvalho Chehab int y; 6510c0d06caSMauro Carvalho Chehab __u8 luma_mean = 110; 6520c0d06caSMauro Carvalho Chehab __u8 luma_delta = 20; 6530c0d06caSMauro Carvalho Chehab __u8 spring = 4; 6540c0d06caSMauro Carvalho Chehab 6550c0d06caSMauro Carvalho Chehab if (sd->ag_cnt < 0) 6560c0d06caSMauro Carvalho Chehab return; 6570c0d06caSMauro Carvalho Chehab if (--sd->ag_cnt >= 0) 6580c0d06caSMauro Carvalho Chehab return; 6590c0d06caSMauro Carvalho Chehab sd->ag_cnt = AG_CNT_START; 6600c0d06caSMauro Carvalho Chehab 6610c0d06caSMauro Carvalho Chehab switch (sd->chip_revision) { 6620c0d06caSMauro Carvalho Chehab case Rev072A: 6630c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8621, 1); 6640c0d06caSMauro Carvalho Chehab Gr = gspca_dev->usb_buf[0]; 6650c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8622, 1); 6660c0d06caSMauro Carvalho Chehab R = gspca_dev->usb_buf[0]; 6670c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8623, 1); 6680c0d06caSMauro Carvalho Chehab B = gspca_dev->usb_buf[0]; 6690c0d06caSMauro Carvalho Chehab reg_r(gspca_dev, 0x8624, 1); 6700c0d06caSMauro Carvalho Chehab Gb = gspca_dev->usb_buf[0]; 6710c0d06caSMauro Carvalho Chehab y = (77 * R + 75 * (Gr + Gb) + 29 * B) >> 8; 6720c0d06caSMauro Carvalho Chehab /* u= (128*B-(43*(Gr+Gb+R))) >> 8; */ 6730c0d06caSMauro Carvalho Chehab /* v= (128*R-(53*(Gr+Gb))-21*B) >> 8; */ 6740c0d06caSMauro Carvalho Chehab 6750c0d06caSMauro Carvalho Chehab if (y < luma_mean - luma_delta || 6760c0d06caSMauro Carvalho Chehab y > luma_mean + luma_delta) { 6770c0d06caSMauro Carvalho Chehab expotimes = i2c_read(gspca_dev, 0x09, 0x10); 6780c0d06caSMauro Carvalho Chehab pixelclk = 0x0800; 6790c0d06caSMauro Carvalho Chehab expotimes = expotimes & 0x07ff; 6800c0d06caSMauro Carvalho Chehab gainG = i2c_read(gspca_dev, 0x35, 0x10); 6810c0d06caSMauro Carvalho Chehab 6820c0d06caSMauro Carvalho Chehab expotimes += (luma_mean - y) >> spring; 6830c0d06caSMauro Carvalho Chehab gainG += (luma_mean - y) / 50; 6840c0d06caSMauro Carvalho Chehab 6850c0d06caSMauro Carvalho Chehab if (gainG > 0x3f) 6860c0d06caSMauro Carvalho Chehab gainG = 0x3f; 6870c0d06caSMauro Carvalho Chehab else if (gainG < 3) 6880c0d06caSMauro Carvalho Chehab gainG = 3; 6890c0d06caSMauro Carvalho Chehab i2c_write(gspca_dev, gainG, 0x35); 6900c0d06caSMauro Carvalho Chehab 6910c0d06caSMauro Carvalho Chehab if (expotimes > 0x0256) 6920c0d06caSMauro Carvalho Chehab expotimes = 0x0256; 6930c0d06caSMauro Carvalho Chehab else if (expotimes < 3) 6940c0d06caSMauro Carvalho Chehab expotimes = 3; 6950c0d06caSMauro Carvalho Chehab i2c_write(gspca_dev, expotimes | pixelclk, 0x09); 6960c0d06caSMauro Carvalho Chehab } 6970c0d06caSMauro Carvalho Chehab break; 6980c0d06caSMauro Carvalho Chehab } 6990c0d06caSMauro Carvalho Chehab } 7000c0d06caSMauro Carvalho Chehab 7010c0d06caSMauro Carvalho Chehab static void sd_pkt_scan(struct gspca_dev *gspca_dev, 7020c0d06caSMauro Carvalho Chehab u8 *data, /* isoc packet */ 7030c0d06caSMauro Carvalho Chehab int len) /* iso packet length */ 7040c0d06caSMauro Carvalho Chehab { 7050c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *) gspca_dev; 7060c0d06caSMauro Carvalho Chehab 7070c0d06caSMauro Carvalho Chehab len--; 7080c0d06caSMauro Carvalho Chehab switch (*data++) { /* sequence number */ 7090c0d06caSMauro Carvalho Chehab case 0: /* start of frame */ 7100c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); 7110c0d06caSMauro Carvalho Chehab 7120c0d06caSMauro Carvalho Chehab /* This should never happen */ 7130c0d06caSMauro Carvalho Chehab if (len < 2) { 71437d5efb0SJoe Perches gspca_err(gspca_dev, "Short SOF packet, ignoring\n\n\n\n\n"); 7150c0d06caSMauro Carvalho Chehab gspca_dev->last_packet_type = DISCARD_PACKET; 7160c0d06caSMauro Carvalho Chehab return; 7170c0d06caSMauro Carvalho Chehab } 7180c0d06caSMauro Carvalho Chehab 71960d21563SPeter Senna Tschudin #if IS_ENABLED(CONFIG_INPUT) 7200c0d06caSMauro Carvalho Chehab if (data[0] & 0x20) { 7210c0d06caSMauro Carvalho Chehab input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); 7220c0d06caSMauro Carvalho Chehab input_sync(gspca_dev->input_dev); 7230c0d06caSMauro Carvalho Chehab input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0); 7240c0d06caSMauro Carvalho Chehab input_sync(gspca_dev->input_dev); 7250c0d06caSMauro Carvalho Chehab } 7260c0d06caSMauro Carvalho Chehab #endif 7270c0d06caSMauro Carvalho Chehab 7280c0d06caSMauro Carvalho Chehab if (data[1] & 0x10) { 7290c0d06caSMauro Carvalho Chehab /* compressed bayer */ 7300c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, FIRST_PACKET, data, len); 7310c0d06caSMauro Carvalho Chehab } else { 7320c0d06caSMauro Carvalho Chehab /* raw bayer (with a header, which we skip) */ 7330c0d06caSMauro Carvalho Chehab if (sd->chip_revision == Rev012A) { 7340c0d06caSMauro Carvalho Chehab data += 20; 7350c0d06caSMauro Carvalho Chehab len -= 20; 7360c0d06caSMauro Carvalho Chehab } else { 7370c0d06caSMauro Carvalho Chehab data += 16; 7380c0d06caSMauro Carvalho Chehab len -= 16; 7390c0d06caSMauro Carvalho Chehab } 7400c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, FIRST_PACKET, data, len); 7410c0d06caSMauro Carvalho Chehab } 7420c0d06caSMauro Carvalho Chehab return; 7430c0d06caSMauro Carvalho Chehab case 0xff: /* drop (empty mpackets) */ 7440c0d06caSMauro Carvalho Chehab return; 7450c0d06caSMauro Carvalho Chehab } 7460c0d06caSMauro Carvalho Chehab gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 7470c0d06caSMauro Carvalho Chehab } 7480c0d06caSMauro Carvalho Chehab 7490c0d06caSMauro Carvalho Chehab static int sd_s_ctrl(struct v4l2_ctrl *ctrl) 7500c0d06caSMauro Carvalho Chehab { 7510c0d06caSMauro Carvalho Chehab struct gspca_dev *gspca_dev = 7520c0d06caSMauro Carvalho Chehab container_of(ctrl->handler, struct gspca_dev, ctrl_handler); 7530c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *)gspca_dev; 7540c0d06caSMauro Carvalho Chehab 7550c0d06caSMauro Carvalho Chehab gspca_dev->usb_err = 0; 7560c0d06caSMauro Carvalho Chehab 7570c0d06caSMauro Carvalho Chehab if (!gspca_dev->streaming) 7580c0d06caSMauro Carvalho Chehab return 0; 7590c0d06caSMauro Carvalho Chehab 7600c0d06caSMauro Carvalho Chehab switch (ctrl->id) { 7610c0d06caSMauro Carvalho Chehab case V4L2_CID_BRIGHTNESS: 7620c0d06caSMauro Carvalho Chehab setbrightness(gspca_dev, ctrl->val); 7630c0d06caSMauro Carvalho Chehab break; 7640c0d06caSMauro Carvalho Chehab case V4L2_CID_CONTRAST: 7650c0d06caSMauro Carvalho Chehab /* hue/contrast control cluster for 72a */ 7660c0d06caSMauro Carvalho Chehab setwhite(gspca_dev, sd->hue->val, ctrl->val); 7670c0d06caSMauro Carvalho Chehab break; 7680c0d06caSMauro Carvalho Chehab case V4L2_CID_HUE: 7690c0d06caSMauro Carvalho Chehab /* just plain hue control for 12a */ 7700c0d06caSMauro Carvalho Chehab setwhite(gspca_dev, ctrl->val, 0); 7710c0d06caSMauro Carvalho Chehab break; 7720c0d06caSMauro Carvalho Chehab case V4L2_CID_EXPOSURE: 7730c0d06caSMauro Carvalho Chehab setexposure(gspca_dev, ctrl->val); 7740c0d06caSMauro Carvalho Chehab break; 7750c0d06caSMauro Carvalho Chehab case V4L2_CID_GAIN: 7760c0d06caSMauro Carvalho Chehab setgain(gspca_dev, ctrl->val); 7770c0d06caSMauro Carvalho Chehab break; 7780c0d06caSMauro Carvalho Chehab case V4L2_CID_AUTOGAIN: 7790c0d06caSMauro Carvalho Chehab setautogain(gspca_dev, ctrl->val); 7800c0d06caSMauro Carvalho Chehab break; 7810c0d06caSMauro Carvalho Chehab } 7820c0d06caSMauro Carvalho Chehab return gspca_dev->usb_err; 7830c0d06caSMauro Carvalho Chehab } 7840c0d06caSMauro Carvalho Chehab 7850c0d06caSMauro Carvalho Chehab static const struct v4l2_ctrl_ops sd_ctrl_ops = { 7860c0d06caSMauro Carvalho Chehab .s_ctrl = sd_s_ctrl, 7870c0d06caSMauro Carvalho Chehab }; 7880c0d06caSMauro Carvalho Chehab 7890c0d06caSMauro Carvalho Chehab static int sd_init_controls_12a(struct gspca_dev *gspca_dev) 7900c0d06caSMauro Carvalho Chehab { 7910c0d06caSMauro Carvalho Chehab struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; 7920c0d06caSMauro Carvalho Chehab 7930c0d06caSMauro Carvalho Chehab gspca_dev->vdev.ctrl_handler = hdl; 7940c0d06caSMauro Carvalho Chehab v4l2_ctrl_handler_init(hdl, 3); 7950c0d06caSMauro Carvalho Chehab v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 7960c0d06caSMauro Carvalho Chehab V4L2_CID_HUE, 1, 0x7f, 1, 0x40); 7970c0d06caSMauro Carvalho Chehab v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 7980c0d06caSMauro Carvalho Chehab V4L2_CID_BRIGHTNESS, -128, 127, 1, 0); 7990c0d06caSMauro Carvalho Chehab v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 8000c0d06caSMauro Carvalho Chehab V4L2_CID_EXPOSURE, 1, EXPOSURE_MAX, 1, 700); 8010c0d06caSMauro Carvalho Chehab v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 8020c0d06caSMauro Carvalho Chehab V4L2_CID_GAIN, 0, 255, 1, 63); 8030c0d06caSMauro Carvalho Chehab 8040c0d06caSMauro Carvalho Chehab if (hdl->error) { 8050c0d06caSMauro Carvalho Chehab pr_err("Could not initialize controls\n"); 8060c0d06caSMauro Carvalho Chehab return hdl->error; 8070c0d06caSMauro Carvalho Chehab } 8080c0d06caSMauro Carvalho Chehab return 0; 8090c0d06caSMauro Carvalho Chehab } 8100c0d06caSMauro Carvalho Chehab 8110c0d06caSMauro Carvalho Chehab static int sd_init_controls_72a(struct gspca_dev *gspca_dev) 8120c0d06caSMauro Carvalho Chehab { 8130c0d06caSMauro Carvalho Chehab struct sd *sd = (struct sd *)gspca_dev; 8140c0d06caSMauro Carvalho Chehab struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; 8150c0d06caSMauro Carvalho Chehab 8160c0d06caSMauro Carvalho Chehab gspca_dev->vdev.ctrl_handler = hdl; 8170c0d06caSMauro Carvalho Chehab v4l2_ctrl_handler_init(hdl, 4); 8180c0d06caSMauro Carvalho Chehab sd->contrast = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 8190c0d06caSMauro Carvalho Chehab V4L2_CID_CONTRAST, 0, 0x3f, 1, 0x20); 8200c0d06caSMauro Carvalho Chehab sd->hue = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 8210c0d06caSMauro Carvalho Chehab V4L2_CID_HUE, 1, 0x7f, 1, 0x40); 8220c0d06caSMauro Carvalho Chehab v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 8230c0d06caSMauro Carvalho Chehab V4L2_CID_BRIGHTNESS, 0, 0x3f, 1, 0x20); 8240c0d06caSMauro Carvalho Chehab sd->autogain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, 8250c0d06caSMauro Carvalho Chehab V4L2_CID_AUTOGAIN, 0, 1, 1, 1); 8260c0d06caSMauro Carvalho Chehab 8270c0d06caSMauro Carvalho Chehab if (hdl->error) { 8280c0d06caSMauro Carvalho Chehab pr_err("Could not initialize controls\n"); 8290c0d06caSMauro Carvalho Chehab return hdl->error; 8300c0d06caSMauro Carvalho Chehab } 8310c0d06caSMauro Carvalho Chehab v4l2_ctrl_cluster(2, &sd->contrast); 8320c0d06caSMauro Carvalho Chehab return 0; 8330c0d06caSMauro Carvalho Chehab } 8340c0d06caSMauro Carvalho Chehab 8350c0d06caSMauro Carvalho Chehab /* sub-driver description */ 8360c0d06caSMauro Carvalho Chehab static const struct sd_desc sd_desc_12a = { 8370c0d06caSMauro Carvalho Chehab .name = MODULE_NAME, 8380c0d06caSMauro Carvalho Chehab .init_controls = sd_init_controls_12a, 8390c0d06caSMauro Carvalho Chehab .config = sd_config, 8400c0d06caSMauro Carvalho Chehab .init = sd_init_12a, 8410c0d06caSMauro Carvalho Chehab .start = sd_start_12a, 8420c0d06caSMauro Carvalho Chehab .stopN = sd_stopN, 8430c0d06caSMauro Carvalho Chehab .pkt_scan = sd_pkt_scan, 84460d21563SPeter Senna Tschudin #if IS_ENABLED(CONFIG_INPUT) 8450c0d06caSMauro Carvalho Chehab .other_input = 1, 8460c0d06caSMauro Carvalho Chehab #endif 8470c0d06caSMauro Carvalho Chehab }; 8480c0d06caSMauro Carvalho Chehab static const struct sd_desc sd_desc_72a = { 8490c0d06caSMauro Carvalho Chehab .name = MODULE_NAME, 8500c0d06caSMauro Carvalho Chehab .init_controls = sd_init_controls_72a, 8510c0d06caSMauro Carvalho Chehab .config = sd_config, 8520c0d06caSMauro Carvalho Chehab .init = sd_init_72a, 8530c0d06caSMauro Carvalho Chehab .start = sd_start_72a, 8540c0d06caSMauro Carvalho Chehab .stopN = sd_stopN, 8550c0d06caSMauro Carvalho Chehab .pkt_scan = sd_pkt_scan, 8560c0d06caSMauro Carvalho Chehab .dq_callback = do_autogain, 85760d21563SPeter Senna Tschudin #if IS_ENABLED(CONFIG_INPUT) 8580c0d06caSMauro Carvalho Chehab .other_input = 1, 8590c0d06caSMauro Carvalho Chehab #endif 8600c0d06caSMauro Carvalho Chehab }; 8610c0d06caSMauro Carvalho Chehab static const struct sd_desc *sd_desc[2] = { 8620c0d06caSMauro Carvalho Chehab &sd_desc_12a, 8630c0d06caSMauro Carvalho Chehab &sd_desc_72a 8640c0d06caSMauro Carvalho Chehab }; 8650c0d06caSMauro Carvalho Chehab 8660c0d06caSMauro Carvalho Chehab /* -- module initialisation -- */ 8670c0d06caSMauro Carvalho Chehab static const struct usb_device_id device_table[] = { 8680c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A}, 8690c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A}, 8700c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A}, 8710c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x0461, 0x0815), .driver_info = Rev072A}, 8720c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x0928), .driver_info = Rev012A}, 8730c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x0929), .driver_info = Rev012A}, 8740c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x092a), .driver_info = Rev012A}, 8750c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x092b), .driver_info = Rev012A}, 8760c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x092c), .driver_info = Rev012A}, 8770c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x092d), .driver_info = Rev012A}, 8780c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x092e), .driver_info = Rev012A}, 8790c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x046d, 0x092f), .driver_info = Rev012A}, 8800c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x04fc, 0x0561), .driver_info = Rev072A}, 8810c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x060b, 0xa001), .driver_info = Rev072A}, 8820c0d06caSMauro Carvalho Chehab {USB_DEVICE(0x10fd, 0x7e50), .driver_info = Rev072A}, 8830c0d06caSMauro Carvalho Chehab {USB_DEVICE(0xabcd, 0xcdee), .driver_info = Rev072A}, 8840c0d06caSMauro Carvalho Chehab {} 8850c0d06caSMauro Carvalho Chehab }; 8860c0d06caSMauro Carvalho Chehab 8870c0d06caSMauro Carvalho Chehab MODULE_DEVICE_TABLE(usb, device_table); 8880c0d06caSMauro Carvalho Chehab 8890c0d06caSMauro Carvalho Chehab /* -- device connect -- */ 8900c0d06caSMauro Carvalho Chehab static int sd_probe(struct usb_interface *intf, 8910c0d06caSMauro Carvalho Chehab const struct usb_device_id *id) 8920c0d06caSMauro Carvalho Chehab { 8930c0d06caSMauro Carvalho Chehab return gspca_dev_probe(intf, id, 8940c0d06caSMauro Carvalho Chehab sd_desc[id->driver_info], 8950c0d06caSMauro Carvalho Chehab sizeof(struct sd), 8960c0d06caSMauro Carvalho Chehab THIS_MODULE); 8970c0d06caSMauro Carvalho Chehab } 8980c0d06caSMauro Carvalho Chehab 8990c0d06caSMauro Carvalho Chehab static struct usb_driver sd_driver = { 9000c0d06caSMauro Carvalho Chehab .name = MODULE_NAME, 9010c0d06caSMauro Carvalho Chehab .id_table = device_table, 9020c0d06caSMauro Carvalho Chehab .probe = sd_probe, 9030c0d06caSMauro Carvalho Chehab .disconnect = gspca_disconnect, 9040c0d06caSMauro Carvalho Chehab #ifdef CONFIG_PM 9050c0d06caSMauro Carvalho Chehab .suspend = gspca_suspend, 9060c0d06caSMauro Carvalho Chehab .resume = gspca_resume, 9070c0d06caSMauro Carvalho Chehab .reset_resume = gspca_resume, 9080c0d06caSMauro Carvalho Chehab #endif 9090c0d06caSMauro Carvalho Chehab }; 9100c0d06caSMauro Carvalho Chehab 9110c0d06caSMauro Carvalho Chehab module_usb_driver(sd_driver); 912