Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
0004  *            Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
0005  * Copyright (c) 2002, 2003 Tuukka Toivonen
0006  * Copyright (c) 2008 Erik Andrén
0007  *
0008  * P/N 861037:      Sensor HDCS1000        ASIC STV0600
0009  * P/N 861050-0010: Sensor HDCS1000        ASIC STV0600
0010  * P/N 861050-0020: Sensor Photobit PB100  ASIC STV0600-1 - QuickCam Express
0011  * P/N 861055:      Sensor ST VV6410       ASIC STV0610   - LEGO cam
0012  * P/N 861075-0040: Sensor HDCS1000        ASIC
0013  * P/N 961179-0700: Sensor ST VV6410       ASIC STV0602   - Dexxa WebCam USB
0014  * P/N 861040-0000: Sensor ST VV6410       ASIC STV0610   - QuickCam Web
0015  */
0016 
0017 #ifndef STV06XX_VV6410_H_
0018 #define STV06XX_VV6410_H_
0019 
0020 #include "stv06xx_sensor.h"
0021 
0022 #define VV6410_COLS         416
0023 #define VV6410_ROWS         320
0024 
0025 /* Status registers */
0026 /* Chip identification number including revision indicator */
0027 #define VV6410_DEVICEH          0x00
0028 #define VV6410_DEVICEL          0x01
0029 
0030 /* User can determine whether timed I2C data
0031    has been consumed by interrogating flag states */
0032 #define VV6410_STATUS0          0x02
0033 
0034 /* Current line counter value */
0035 #define VV6410_LINECOUNTH       0x03
0036 #define VV6410_LINECOUNTL       0x04
0037 
0038 /* End x coordinate of image size */
0039 #define VV6410_XENDH            0x05
0040 #define VV6410_XENDL            0x06
0041 
0042 /* End y coordinate of image size */
0043 #define VV6410_YENDH            0x07
0044 #define VV6410_YENDL            0x08
0045 
0046 /* This is the average pixel value returned from the
0047    dark line offset cancellation algorithm */
0048 #define VV6410_DARKAVGH         0x09
0049 #define VV6410_DARKAVGL         0x0a
0050 
0051 /* This is the average pixel value returned from the
0052    black line offset cancellation algorithm  */
0053 #define VV6410_BLACKAVGH        0x0b
0054 #define VV6410_BLACKAVGL        0x0c
0055 
0056 /* Flags to indicate whether the x or y image coordinates have been clipped */
0057 #define VV6410_STATUS1          0x0d
0058 
0059 /* Setup registers */
0060 
0061 /* Low-power/sleep modes & video timing */
0062 #define VV6410_SETUP0           0x10
0063 
0064 /* Various parameters */
0065 #define VV6410_SETUP1           0x11
0066 
0067 /* Contains pixel counter reset value used by external sync */
0068 #define VV6410_SYNCVALUE        0x12
0069 
0070 /* Frame grabbing modes (FST, LST and QCK) */
0071 #define VV6410_FGMODES          0x14
0072 
0073 /* FST and QCK mapping modes. */
0074 #define VV6410_PINMAPPING       0x15
0075 
0076 /* Data resolution */
0077 #define VV6410_DATAFORMAT       0x16
0078 
0079 /* Output coding formats */
0080 #define VV6410_OPFORMAT         0x17
0081 
0082 /* Various mode select bits */
0083 #define VV6410_MODESELECT       0x18
0084 
0085 /* Exposure registers */
0086 /* Fine exposure. */
0087 #define VV6410_FINEH            0x20
0088 #define VV6410_FINEL            0x21
0089 
0090 /* Coarse exposure */
0091 #define VV6410_COARSEH          0x22
0092 #define VV6410_COARSEL          0x23
0093 
0094 /* Analog gain setting */
0095 #define VV6410_ANALOGGAIN       0x24
0096 
0097 /* Clock division */
0098 #define VV6410_CLKDIV           0x25
0099 
0100 /* Dark line offset cancellation value */
0101 #define VV6410_DARKOFFSETH      0x2c
0102 #define VV6410_DARKOFFSETL      0x2d
0103 
0104 /* Dark line offset cancellation enable */
0105 #define VV6410_DARKOFFSETSETUP      0x2e
0106 
0107 /* Video timing registers */
0108 /* Line Length (Pixel Clocks) */
0109 #define VV6410_LINELENGTHH      0x52
0110 #define VV6410_LINELENGTHL      0x53
0111 
0112 /* X-co-ordinate of top left corner of region of interest (x-offset) */
0113 #define VV6410_XOFFSETH         0x57
0114 #define VV6410_XOFFSETL         0x58
0115 
0116 /* Y-coordinate of top left corner of region of interest (y-offset) */
0117 #define VV6410_YOFFSETH         0x59
0118 #define VV6410_YOFFSETL         0x5a
0119 
0120 /* Field length (Lines) */
0121 #define VV6410_FIELDLENGTHH     0x61
0122 #define VV6410_FIELDLENGTHL     0x62
0123 
0124 /* System registers */
0125 /* Black offset cancellation default value */
0126 #define VV6410_BLACKOFFSETH     0x70
0127 #define VV6410_BLACKOFFSETL     0x71
0128 
0129 /* Black offset cancellation setup */
0130 #define VV6410_BLACKOFFSETSETUP     0x72
0131 
0132 /* Analog Control Register 0 */
0133 #define VV6410_CR0          0x75
0134 
0135 /* Analog Control Register 1 */
0136 #define VV6410_CR1          0x76
0137 
0138 /* ADC Setup Register */
0139 #define VV6410_AS0          0x77
0140 
0141 /* Analog Test Register */
0142 #define VV6410_AT0          0x78
0143 
0144 /* Audio Amplifier Setup Register */
0145 #define VV6410_AT1          0x79
0146 
0147 #define VV6410_HFLIP            (1 << 3)
0148 #define VV6410_VFLIP            (1 << 4)
0149 
0150 #define VV6410_LOW_POWER_MODE       (1 << 0)
0151 #define VV6410_SOFT_RESET       (1 << 2)
0152 #define VV6410_PAL_25_FPS       (0 << 3)
0153 
0154 #define VV6410_CLK_DIV_2        (1 << 1)
0155 
0156 #define VV6410_FINE_EXPOSURE        320
0157 #define VV6410_COARSE_EXPOSURE      192
0158 #define VV6410_DEFAULT_GAIN     5
0159 
0160 #define VV6410_SUBSAMPLE        0x01
0161 #define VV6410_CROP_TO_QVGA     0x02
0162 
0163 #define VV6410_CIF_LINELENGTH       415
0164 
0165 static int vv6410_probe(struct sd *sd);
0166 static int vv6410_start(struct sd *sd);
0167 static int vv6410_init(struct sd *sd);
0168 static int vv6410_init_controls(struct sd *sd);
0169 static int vv6410_stop(struct sd *sd);
0170 static int vv6410_dump(struct sd *sd);
0171 
0172 /* V4L2 controls supported by the driver */
0173 static int vv6410_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
0174 static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
0175 static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val);
0176 static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
0177 
0178 const struct stv06xx_sensor stv06xx_sensor_vv6410 = {
0179     .name = "ST VV6410",
0180     .i2c_flush = 5,
0181     .i2c_addr = 0x20,
0182     .i2c_len = 1,
0183     /* FIXME (see if we can lower packet_size-s, needs testing, and also
0184        adjusting framerate when the bandwidth gets lower) */
0185     .min_packet_size = { 1023 },
0186     .max_packet_size = { 1023 },
0187     .init = vv6410_init,
0188     .init_controls = vv6410_init_controls,
0189     .probe = vv6410_probe,
0190     .start = vv6410_start,
0191     .stop = vv6410_stop,
0192     .dump = vv6410_dump,
0193 };
0194 
0195 /* If NULL, only single value to write, stored in len */
0196 struct stv_init {
0197     u16 addr;
0198     u8 data;
0199 };
0200 
0201 static const struct stv_init stv_bridge_init[] = {
0202     /* This reg is written twice. Some kind of reset? */
0203     {STV_RESET, 0x80},
0204     {STV_RESET, 0x00},
0205     {STV_SCAN_RATE, 0x00},
0206     {STV_I2C_FLUSH, 0x04},
0207     {STV_REG00, 0x0b},
0208     {STV_REG01, 0xa7},
0209     {STV_REG02, 0xb7},
0210     {STV_REG03, 0x00},
0211     {STV_REG04, 0x00},
0212     {0x1536, 0x02},
0213     {0x1537, 0x00},
0214     {0x1538, 0x60},
0215     {0x1539, 0x01},
0216     {0x153a, 0x20},
0217     {0x153b, 0x01},
0218 };
0219 
0220 static const u8 vv6410_sensor_init[][2] = {
0221     /* Setup registers */
0222     {VV6410_SETUP0, VV6410_SOFT_RESET},
0223     {VV6410_SETUP0, VV6410_LOW_POWER_MODE},
0224     /* Use shuffled read-out mode */
0225     {VV6410_SETUP1, BIT(6)},
0226     /* All modes to 1, FST, Fast QCK, Free running QCK, Free running LST, FST will qualify visible pixels */
0227     {VV6410_FGMODES, BIT(6) | BIT(4) | BIT(2) | BIT(0)},
0228     {VV6410_PINMAPPING, 0x00},
0229     /* Pre-clock generator divide off */
0230     {VV6410_DATAFORMAT, BIT(7) | BIT(0)},
0231 
0232     {VV6410_CLKDIV, VV6410_CLK_DIV_2},
0233 
0234     /* System registers */
0235     /* Enable voltage doubler */
0236     {VV6410_AS0, BIT(6) | BIT(4) | BIT(3) | BIT(2) | BIT(1)},
0237     {VV6410_AT0, 0x00},
0238     /* Power up audio, differential */
0239     {VV6410_AT1, BIT(4) | BIT(0)},
0240 };
0241 
0242 #endif