Path: blob/master/drivers/media/video/gspca/m5602/m5602_s5k83a.h
17984 views
/*1* Driver for the s5k83a 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_S5K83A_H_19#define M5602_S5K83A_H_2021#include "m5602_sensor.h"2223#define S5K83A_FLIP 0x0124#define S5K83A_HFLIP_TUNE 0x0325#define S5K83A_VFLIP_TUNE 0x0526#define S5K83A_BRIGHTNESS 0x0a27#define S5K83A_EXPOSURE 0x1828#define S5K83A_GAIN 0x1b29#define S5K83A_PAGE_MAP 0xec3031#define S5K83A_DEFAULT_GAIN 0x7132#define S5K83A_DEFAULT_BRIGHTNESS 0x7e33#define S5K83A_DEFAULT_EXPOSURE 0x0034#define S5K83A_MAXIMUM_EXPOSURE 0x3c35#define S5K83A_FLIP_MASK 0x1036#define S5K83A_GPIO_LED_MASK 0x1037#define S5K83A_GPIO_ROTATION_MASK 0x403839/*****************************************************************************/4041/* Kernel module parameters */42extern int force_sensor;43extern int dump_sensor;4445int s5k83a_probe(struct sd *sd);46int s5k83a_init(struct sd *sd);47int s5k83a_start(struct sd *sd);48int s5k83a_stop(struct sd *sd);49void s5k83a_disconnect(struct sd *sd);5051static const struct m5602_sensor s5k83a = {52.name = "S5K83A",53.probe = s5k83a_probe,54.init = s5k83a_init,55.start = s5k83a_start,56.stop = s5k83a_stop,57.disconnect = s5k83a_disconnect,58.i2c_slave_id = 0x5a,59.i2c_regW = 2,60};6162struct s5k83a_priv {63/* We use another thread periodically64probing the orientation of the camera */65struct task_struct *rotation_thread;66s32 *settings;67};6869static const unsigned char preinit_s5k83a[][4] = {70{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},71{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},72{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},73{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},74{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},75{BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d, 0x00},76{BRIDGE, M5602_XB_SENSOR_CTRL, 0x00, 0x00},7778{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},79{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},80{BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},81{BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},82{BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},83{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},84{BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},85{BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},86{BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},87{BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},88{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},89{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},90{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},91{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},92{BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},93{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},94{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},95{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},96{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},97{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},98{BRIDGE, M5602_XB_GPIO_DAT, 0x1c, 0x00},99{BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},100{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},101{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},102{BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},103{BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},104};105106/* This could probably be considerably shortened.107I don't have the hardware to experiment with it, patches welcome108*/109static const unsigned char init_s5k83a[][4] = {110/* The following sequence is useless after a clean boot111but is necessary after resume from suspend */112{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},113{BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},114{BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},115{BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},116{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},117{BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},118{BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},119{BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},120{BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},121{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},122{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},123{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},124{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},125{BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},126{BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},127{BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},128{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},129{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},130{BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},131{BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},132{BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},133{BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},134{BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},135{BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},136{BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},137138{SENSOR, S5K83A_PAGE_MAP, 0x04, 0x00},139{SENSOR, 0xaf, 0x01, 0x00},140{SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},141{SENSOR, 0x7b, 0xff, 0x00},142{SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},143{SENSOR, 0x01, 0x50, 0x00},144{SENSOR, 0x12, 0x20, 0x00},145{SENSOR, 0x17, 0x40, 0x00},146{SENSOR, 0x1c, 0x00, 0x00},147{SENSOR, 0x02, 0x70, 0x00},148{SENSOR, 0x03, 0x0b, 0x00},149{SENSOR, 0x04, 0xf0, 0x00},150{SENSOR, 0x05, 0x0b, 0x00},151{SENSOR, 0x06, 0x71, 0x00},152{SENSOR, 0x07, 0xe8, 0x00}, /* 488 */153{SENSOR, 0x08, 0x02, 0x00},154{SENSOR, 0x09, 0x88, 0x00}, /* 648 */155{SENSOR, 0x14, 0x00, 0x00},156{SENSOR, 0x15, 0x20, 0x00}, /* 32 */157{SENSOR, 0x19, 0x00, 0x00},158{SENSOR, 0x1a, 0x98, 0x00}, /* 152 */159{SENSOR, 0x0f, 0x02, 0x00},160{SENSOR, 0x10, 0xe5, 0x00}, /* 741 */161/* normal colors162(this is value after boot, but after tries can be different) */163{SENSOR, 0x00, 0x06, 0x00},164};165166static const unsigned char start_s5k83a[][4] = {167{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},168{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},169{BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},170{BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},171{BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},172{BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},173{BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},174{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},175{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},176{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},177{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},178{BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},179{BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00}, /* 484 */180{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},181{BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},182{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},183{BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},184{BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},185{BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},186{BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},187{BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00}, /* 639 */188{BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},189{BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},190{BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},191};192#endif193194195