Path: blob/master/drivers/media/video/gspca/stv06xx/stv06xx_vv6410.h
17994 views
/*1* Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher2* Mark Cave-Ayland, Carlo E Prelz, Dick Streefland3* Copyright (c) 2002, 2003 Tuukka Toivonen4* Copyright (c) 2008 Erik Andrén5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19*20* P/N 861037: Sensor HDCS1000 ASIC STV060021* P/N 861050-0010: Sensor HDCS1000 ASIC STV060022* P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express23* P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam24* P/N 861075-0040: Sensor HDCS1000 ASIC25* P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB26* P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web27*/2829#ifndef STV06XX_VV6410_H_30#define STV06XX_VV6410_H_3132#include "stv06xx_sensor.h"3334#define VV6410_COLS 41635#define VV6410_ROWS 3203637/* Status registers */38/* Chip identification number including revision indicator */39#define VV6410_DEVICEH 0x0040#define VV6410_DEVICEL 0x014142/* User can determine whether timed I2C data43has been consumed by interrogating flag states */44#define VV6410_STATUS0 0x024546/* Current line counter value */47#define VV6410_LINECOUNTH 0x0348#define VV6410_LINECOUNTL 0x044950/* End x coordinate of image size */51#define VV6410_XENDH 0x0552#define VV6410_XENDL 0x065354/* End y coordinate of image size */55#define VV6410_YENDH 0x0756#define VV6410_YENDL 0x085758/* This is the average pixel value returned from the59dark line offset cancellation algorithm */60#define VV6410_DARKAVGH 0x0961#define VV6410_DARKAVGL 0x0a6263/* This is the average pixel value returned from the64black line offset cancellation algorithm */65#define VV6410_BLACKAVGH 0x0b66#define VV6410_BLACKAVGL 0x0c6768/* Flags to indicate whether the x or y image coordinates have been clipped */69#define VV6410_STATUS1 0x0d7071/* Setup registers */7273/* Low-power/sleep modes & video timing */74#define VV6410_SETUP0 0x107576/* Various parameters */77#define VV6410_SETUP1 0x117879/* Contains pixel counter reset value used by external sync */80#define VV6410_SYNCVALUE 0x128182/* Frame grabbing modes (FST, LST and QCK) */83#define VV6410_FGMODES 0x148485/* FST and QCK mapping modes. */86#define VV6410_PINMAPPING 0x158788/* Data resolution */89#define VV6410_DATAFORMAT 0x169091/* Output coding formats */92#define VV6410_OPFORMAT 0x179394/* Various mode select bits */95#define VV6410_MODESELECT 0x189697/* Exposure registers */98/* Fine exposure. */99#define VV6410_FINEH 0x20100#define VV6410_FINEL 0x21101102/* Coarse exposure */103#define VV6410_COARSEH 0x22104#define VV6410_COARSEL 0x23105106/* Analog gain setting */107#define VV6410_ANALOGGAIN 0x24108109/* Clock division */110#define VV6410_CLKDIV 0x25111112/* Dark line offset cancellation value */113#define VV6410_DARKOFFSETH 0x2c114#define VV6410_DARKOFFSETL 0x2d115116/* Dark line offset cancellation enable */117#define VV6410_DARKOFFSETSETUP 0x2e118119/* Video timing registers */120/* Line Length (Pixel Clocks) */121#define VV6410_LINELENGTHH 0x52122#define VV6410_LINELENGTHL 0x53123124/* X-co-ordinate of top left corner of region of interest (x-offset) */125#define VV6410_XOFFSETH 0x57126#define VV6410_XOFFSETL 0x58127128/* Y-coordinate of top left corner of region of interest (y-offset) */129#define VV6410_YOFFSETH 0x59130#define VV6410_YOFFSETL 0x5a131132/* Field length (Lines) */133#define VV6410_FIELDLENGTHH 0x61134#define VV6410_FIELDLENGTHL 0x62135136/* System registers */137/* Black offset cancellation default value */138#define VV6410_BLACKOFFSETH 0x70139#define VV6410_BLACKOFFSETL 0x71140141/* Black offset cancellation setup */142#define VV6410_BLACKOFFSETSETUP 0x72143144/* Analog Control Register 0 */145#define VV6410_CR0 0x75146147/* Analog Control Register 1 */148#define VV6410_CR1 0x76149150/* ADC Setup Register */151#define VV6410_AS0 0x77152153/* Analog Test Register */154#define VV6410_AT0 0x78155156/* Audio Amplifier Setup Register */157#define VV6410_AT1 0x79158159#define VV6410_HFLIP (1 << 3)160#define VV6410_VFLIP (1 << 4)161162#define VV6410_LOW_POWER_MODE (1 << 0)163#define VV6410_SOFT_RESET (1 << 2)164#define VV6410_PAL_25_FPS (0 << 3)165166#define VV6410_CLK_DIV_2 (1 << 1)167168#define VV6410_FINE_EXPOSURE 320169#define VV6410_COARSE_EXPOSURE 192170#define VV6410_DEFAULT_GAIN 5171172#define VV6410_SUBSAMPLE 0x01173#define VV6410_CROP_TO_QVGA 0x02174175#define VV6410_CIF_LINELENGTH 415176177static int vv6410_probe(struct sd *sd);178static int vv6410_start(struct sd *sd);179static int vv6410_init(struct sd *sd);180static int vv6410_stop(struct sd *sd);181static int vv6410_dump(struct sd *sd);182static void vv6410_disconnect(struct sd *sd);183184/* V4L2 controls supported by the driver */185static int vv6410_get_hflip(struct gspca_dev *gspca_dev, __s32 *val);186static int vv6410_set_hflip(struct gspca_dev *gspca_dev, __s32 val);187static int vv6410_get_vflip(struct gspca_dev *gspca_dev, __s32 *val);188static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val);189static int vv6410_get_analog_gain(struct gspca_dev *gspca_dev, __s32 *val);190static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val);191static int vv6410_get_exposure(struct gspca_dev *gspca_dev, __s32 *val);192static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val);193194const struct stv06xx_sensor stv06xx_sensor_vv6410 = {195.name = "ST VV6410",196.i2c_flush = 5,197.i2c_addr = 0x20,198.i2c_len = 1,199/* FIXME (see if we can lower packet_size-s, needs testing, and also200adjusting framerate when the bandwidth gets lower) */201.min_packet_size = { 1023 },202.max_packet_size = { 1023 },203.init = vv6410_init,204.probe = vv6410_probe,205.start = vv6410_start,206.stop = vv6410_stop,207.dump = vv6410_dump,208.disconnect = vv6410_disconnect,209};210211/* If NULL, only single value to write, stored in len */212struct stv_init {213const u8 *data;214u16 start;215u8 len;216};217218static const u8 x1500[] = { /* 0x1500 - 0x150f */2190x0b, 0xa7, 0xb7, 0x00, 0x00220};221222static const u8 x1536[] = { /* 0x1536 - 0x153b */2230x02, 0x00, 0x60, 0x01, 0x20, 0x01224};225226static const struct stv_init stv_bridge_init[] = {227/* This reg is written twice. Some kind of reset? */228{NULL, 0x1620, 0x80},229{NULL, 0x1620, 0x00},230{NULL, 0x1443, 0x00},231{NULL, 0x1423, 0x04},232{x1500, 0x1500, ARRAY_SIZE(x1500)},233{x1536, 0x1536, ARRAY_SIZE(x1536)},234};235236static const u8 vv6410_sensor_init[][2] = {237/* Setup registers */238{VV6410_SETUP0, VV6410_SOFT_RESET},239{VV6410_SETUP0, VV6410_LOW_POWER_MODE},240/* Use shuffled read-out mode */241{VV6410_SETUP1, BIT(6)},242/* All modes to 1 */243{VV6410_FGMODES, BIT(6) | BIT(4) | BIT(2) | BIT(0)},244{VV6410_PINMAPPING, 0x00},245/* Pre-clock generator divide off */246{VV6410_DATAFORMAT, BIT(7) | BIT(0)},247248{VV6410_CLKDIV, VV6410_CLK_DIV_2},249250/* System registers */251/* Enable voltage doubler */252{VV6410_AS0, BIT(6) | BIT(4) | BIT(3) | BIT(2) | BIT(1)},253{VV6410_AT0, 0x00},254/* Power up audio, differential */255{VV6410_AT1, BIT(4)|BIT(0)},256};257258#endif259260261