Path: blob/master/drivers/media/video/gspca/m5602/m5602_ov9650.h
17984 views
/*1* Driver for the ov9650 sensor2*3* Copyright (C) 2008 Erik Andrén4* Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.5* Copyright (C) 2005 m5603x Linux Driver Project <[email protected]>6*7* Portions of code to USB interface and ALi driver software,8* Copyright (c) 2006 Willem Duinker9* v4l2 interface modeled after the V4L2 driver10* for SN9C10x PC Camera Controllers11*12* This program is free software; you can redistribute it and/or13* modify it under the terms of the GNU General Public License as14* published by the Free Software Foundation, version 2.15*16*/1718#ifndef M5602_OV9650_H_19#define M5602_OV9650_H_2021#include <linux/dmi.h>22#include "m5602_sensor.h"2324/*****************************************************************************/2526#define OV9650_GAIN 0x0027#define OV9650_BLUE 0x0128#define OV9650_RED 0x0229#define OV9650_VREF 0x0330#define OV9650_COM1 0x0431#define OV9650_BAVE 0x0532#define OV9650_GEAVE 0x0633#define OV9650_RSVD7 0x0734#define OV9650_COM2 0x0935#define OV9650_PID 0x0a36#define OV9650_VER 0x0b37#define OV9650_COM3 0x0c38#define OV9650_COM4 0x0d39#define OV9650_COM5 0x0e40#define OV9650_COM6 0x0f41#define OV9650_AECH 0x1042#define OV9650_CLKRC 0x1143#define OV9650_COM7 0x1244#define OV9650_COM8 0x1345#define OV9650_COM9 0x1446#define OV9650_COM10 0x1547#define OV9650_RSVD16 0x1648#define OV9650_HSTART 0x1749#define OV9650_HSTOP 0x1850#define OV9650_VSTRT 0x1951#define OV9650_VSTOP 0x1a52#define OV9650_PSHFT 0x1b53#define OV9650_MVFP 0x1e54#define OV9650_AEW 0x2455#define OV9650_AEB 0x2556#define OV9650_VPT 0x2657#define OV9650_BBIAS 0x2758#define OV9650_GbBIAS 0x2859#define OV9650_Gr_COM 0x2960#define OV9650_RBIAS 0x2c61#define OV9650_HREF 0x3262#define OV9650_CHLF 0x3363#define OV9650_ARBLM 0x3464#define OV9650_RSVD35 0x3565#define OV9650_RSVD36 0x3666#define OV9650_ADC 0x3767#define OV9650_ACOM38 0x3868#define OV9650_OFON 0x3969#define OV9650_TSLB 0x3a70#define OV9650_COM12 0x3c71#define OV9650_COM13 0x3d72#define OV9650_COM15 0x4073#define OV9650_COM16 0x4174#define OV9650_LCC1 0x6275#define OV9650_LCC2 0x6376#define OV9650_LCC3 0x6477#define OV9650_LCC4 0x6578#define OV9650_LCC5 0x6679#define OV9650_HV 0x6980#define OV9650_DBLV 0x6b81#define OV9650_COM21 0x8b82#define OV9650_COM22 0x8c83#define OV9650_COM24 0x8e84#define OV9650_DBLC1 0x8f85#define OV9650_RSVD94 0x9486#define OV9650_RSVD95 0x9587#define OV9650_RSVD96 0x9688#define OV9650_LCCFB 0x9d89#define OV9650_LCCFR 0x9e90#define OV9650_AECHM 0xa191#define OV9650_COM26 0xa592#define OV9650_ACOMA8 0xa893#define OV9650_ACOMA9 0xa99495#define OV9650_REGISTER_RESET (1 << 7)96#define OV9650_VGA_SELECT (1 << 6)97#define OV9650_CIF_SELECT (1 << 5)98#define OV9650_QVGA_SELECT (1 << 4)99#define OV9650_QCIF_SELECT (1 << 3)100#define OV9650_RGB_SELECT (1 << 2)101#define OV9650_RAW_RGB_SELECT (1 << 0)102103#define OV9650_FAST_AGC_AEC (1 << 7)104#define OV9650_AEC_UNLIM_STEP_SIZE (1 << 6)105#define OV9650_BANDING (1 << 5)106#define OV9650_AGC_EN (1 << 2)107#define OV9650_AWB_EN (1 << 1)108#define OV9650_AEC_EN (1 << 0)109110#define OV9650_VARIOPIXEL (1 << 2)111#define OV9650_SYSTEM_CLK_SEL (1 << 7)112#define OV9650_SLAM_MODE (1 << 4)113114#define OV9650_QVGA_VARIOPIXEL (1 << 7)115116#define OV9650_VFLIP (1 << 4)117#define OV9650_HFLIP (1 << 5)118119#define OV9650_SOFT_SLEEP (1 << 4)120#define OV9650_OUTPUT_DRIVE_2X (1 << 0)121122#define OV9650_DENOISE_ENABLE (1 << 5)123#define OV9650_WHITE_PIXEL_ENABLE (1 << 1)124#define OV9650_WHITE_PIXEL_OPTION (1 << 0)125126#define OV9650_LEFT_OFFSET 0x62127128#define GAIN_DEFAULT 0x14129#define RED_GAIN_DEFAULT 0x70130#define BLUE_GAIN_DEFAULT 0x20131#define EXPOSURE_DEFAULT 0x1ff132133/*****************************************************************************/134135/* Kernel module parameters */136extern int force_sensor;137extern int dump_sensor;138139int ov9650_probe(struct sd *sd);140int ov9650_init(struct sd *sd);141int ov9650_start(struct sd *sd);142int ov9650_stop(struct sd *sd);143void ov9650_disconnect(struct sd *sd);144145static const struct m5602_sensor ov9650 = {146.name = "OV9650",147.i2c_slave_id = 0x60,148.i2c_regW = 1,149.probe = ov9650_probe,150.init = ov9650_init,151.start = ov9650_start,152.stop = ov9650_stop,153.disconnect = ov9650_disconnect,154};155156static const unsigned char preinit_ov9650[][3] = {157/* [INITCAM] */158{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},159{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},160{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},161{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},162{BRIDGE, M5602_XB_ADC_CTRL, 0xc0},163{BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},164165{BRIDGE, M5602_XB_SENSOR_TYPE, 0x08},166{BRIDGE, M5602_XB_GPIO_DIR, 0x05},167{BRIDGE, M5602_XB_GPIO_DAT, 0x04},168{BRIDGE, M5602_XB_GPIO_EN_H, 0x06},169{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},170{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},171{BRIDGE, M5602_XB_GPIO_DAT, 0x00},172{BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a},173/* Reset chip */174{SENSOR, OV9650_COM7, OV9650_REGISTER_RESET},175/* Enable double clock */176{SENSOR, OV9650_CLKRC, 0x80},177/* Do something out of spec with the power */178{SENSOR, OV9650_OFON, 0x40}179};180181static const unsigned char init_ov9650[][3] = {182/* [INITCAM] */183{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},184{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},185{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},186{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},187{BRIDGE, M5602_XB_ADC_CTRL, 0xc0},188{BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},189190{BRIDGE, M5602_XB_SENSOR_TYPE, 0x08},191{BRIDGE, M5602_XB_GPIO_DIR, 0x05},192{BRIDGE, M5602_XB_GPIO_DAT, 0x04},193{BRIDGE, M5602_XB_GPIO_EN_H, 0x06},194{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},195{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},196{BRIDGE, M5602_XB_GPIO_DAT, 0x00},197{BRIDGE, M5602_XB_I2C_CLK_DIV, 0x0a},198199/* Reset chip */200{SENSOR, OV9650_COM7, OV9650_REGISTER_RESET},201/* One extra reset is needed in order to make the sensor behave202properly when resuming from ram, could be a timing issue */203{SENSOR, OV9650_COM7, OV9650_REGISTER_RESET},204205/* Enable double clock */206{SENSOR, OV9650_CLKRC, 0x80},207/* Do something out of spec with the power */208{SENSOR, OV9650_OFON, 0x40},209210/* Set fast AGC/AEC algorithm with unlimited step size */211{SENSOR, OV9650_COM8, OV9650_FAST_AGC_AEC |212OV9650_AEC_UNLIM_STEP_SIZE},213214{SENSOR, OV9650_CHLF, 0x10},215{SENSOR, OV9650_ARBLM, 0xbf},216{SENSOR, OV9650_ACOM38, 0x81},217/* Turn off color matrix coefficient double option */218{SENSOR, OV9650_COM16, 0x00},219/* Enable color matrix for RGB/YUV, Delay Y channel,220set output Y/UV delay to 1 */221{SENSOR, OV9650_COM13, 0x19},222/* Enable digital BLC, Set output mode to U Y V Y */223{SENSOR, OV9650_TSLB, 0x0c},224/* Limit the AGC/AEC stable upper region */225{SENSOR, OV9650_COM24, 0x00},226/* Enable HREF and some out of spec things */227{SENSOR, OV9650_COM12, 0x73},228/* Set all DBLC offset signs to positive and229do some out of spec stuff */230{SENSOR, OV9650_DBLC1, 0xdf},231{SENSOR, OV9650_COM21, 0x06},232{SENSOR, OV9650_RSVD35, 0x91},233/* Necessary, no camera stream without it */234{SENSOR, OV9650_RSVD16, 0x06},235{SENSOR, OV9650_RSVD94, 0x99},236{SENSOR, OV9650_RSVD95, 0x99},237{SENSOR, OV9650_RSVD96, 0x04},238/* Enable full range output */239{SENSOR, OV9650_COM15, 0x0},240/* Enable HREF at optical black, enable ADBLC bias,241enable ADBLC, reset timings at format change */242{SENSOR, OV9650_COM6, 0x4b},243/* Subtract 32 from the B channel bias */244{SENSOR, OV9650_BBIAS, 0xa0},245/* Subtract 32 from the Gb channel bias */246{SENSOR, OV9650_GbBIAS, 0xa0},247/* Do not bypass the analog BLC and to some out of spec stuff */248{SENSOR, OV9650_Gr_COM, 0x00},249/* Subtract 32 from the R channel bias */250{SENSOR, OV9650_RBIAS, 0xa0},251/* Subtract 32 from the R channel bias */252{SENSOR, OV9650_RBIAS, 0x0},253{SENSOR, OV9650_COM26, 0x80},254{SENSOR, OV9650_ACOMA9, 0x98},255/* Set the AGC/AEC stable region upper limit */256{SENSOR, OV9650_AEW, 0x68},257/* Set the AGC/AEC stable region lower limit */258{SENSOR, OV9650_AEB, 0x5c},259/* Set the high and low limit nibbles to 3 */260{SENSOR, OV9650_VPT, 0xc3},261/* Set the Automatic Gain Ceiling (AGC) to 128x,262drop VSYNC at frame drop,263limit exposure timing,264drop frame when the AEC step is larger than the exposure gap */265{SENSOR, OV9650_COM9, 0x6e},266/* Set VSYNC negative, Set RESET to SLHS (slave mode horizontal sync)267and set PWDN to SLVS (slave mode vertical sync) */268{SENSOR, OV9650_COM10, 0x42},269/* Set horizontal column start high to default value */270{SENSOR, OV9650_HSTART, 0x1a}, /* 210 */271/* Set horizontal column end */272{SENSOR, OV9650_HSTOP, 0xbf}, /* 1534 */273/* Complementing register to the two writes above */274{SENSOR, OV9650_HREF, 0xb2},275/* Set vertical row start high bits */276{SENSOR, OV9650_VSTRT, 0x02},277/* Set vertical row end low bits */278{SENSOR, OV9650_VSTOP, 0x7e},279/* Set complementing vertical frame control */280{SENSOR, OV9650_VREF, 0x10},281{SENSOR, OV9650_ADC, 0x04},282{SENSOR, OV9650_HV, 0x40},283284/* Enable denoise, and white-pixel erase */285{SENSOR, OV9650_COM22, OV9650_DENOISE_ENABLE |286OV9650_WHITE_PIXEL_ENABLE |287OV9650_WHITE_PIXEL_OPTION},288289/* Enable VARIOPIXEL */290{SENSOR, OV9650_COM3, OV9650_VARIOPIXEL},291{SENSOR, OV9650_COM4, OV9650_QVGA_VARIOPIXEL},292293/* Put the sensor in soft sleep mode */294{SENSOR, OV9650_COM2, OV9650_SOFT_SLEEP | OV9650_OUTPUT_DRIVE_2X},295};296297static const unsigned char res_init_ov9650[][3] = {298{SENSOR, OV9650_COM2, OV9650_OUTPUT_DRIVE_2X},299300{BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x82},301{BRIDGE, M5602_XB_LINE_OF_FRAME_L, 0x00},302{BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},303{BRIDGE, M5602_XB_PIX_OF_LINE_L, 0x00},304{BRIDGE, M5602_XB_SIG_INI, 0x01}305};306#endif307308309