update:更新双目sensor驱动
This commit is contained in:
@@ -19,52 +19,38 @@
|
||||
#include "../../utility/media-bus-format.h"
|
||||
#include "../../utility/vin_supply.h"
|
||||
|
||||
#define MCLK (24*1000*1000)
|
||||
#define V4L2_IDENT_SENSOR 0xeb52
|
||||
#define MCLK (24*1000*1000)
|
||||
#define V4L2_IDENT_SENSOR 0xeb52
|
||||
|
||||
/*
|
||||
* Our nominal (default) frame rate.
|
||||
*/
|
||||
#define ID_REG_HIGH 0xf0
|
||||
#define ID_REG_LOW 0xf1
|
||||
#define ID_VAL_HIGH ((V4L2_IDENT_SENSOR) >> 8)
|
||||
#define ID_VAL_LOW ((V4L2_IDENT_SENSOR) & 0xff)
|
||||
#define SENSOR_FRAME_RATE 30
|
||||
|
||||
#define VTS 1250
|
||||
|
||||
#define EXPOSURE_MIN 6
|
||||
#define EXPOSURE_MAX (VTS - 6)
|
||||
#define EXPOSURE_STEP 1
|
||||
#define EXPOSURE_DEFAULT 0x0148
|
||||
|
||||
#define GAIN_MIN 0x00
|
||||
#define GAIN_MAX 0xF8
|
||||
#define GAIN_STEP 1
|
||||
#define GAIN_DEFAULT 20
|
||||
#define GAIN_STEP_BASE 128 //mean gain min step is 1/64gain
|
||||
//define the registers
|
||||
#define EXP_HIGH 0x3e00
|
||||
#define EXP_MID 0x3e01
|
||||
#define EXP_LOW 0x3e02
|
||||
#define DIG_GAIN 0x3e06
|
||||
#define DIG_FINE_GAIN 0x3e07
|
||||
#define ANA_GAIN 0x3e09
|
||||
#define GAIN_STEP_BASE 128
|
||||
|
||||
/*
|
||||
* The sc202cs i2c address
|
||||
*/
|
||||
#define I2C_ADDR 0x7c//0xdc
|
||||
#define ID_REG_HIGH 0x3107
|
||||
#define ID_REG_LOW 0x3108
|
||||
#define ID_VAL_HIGH 0xeb
|
||||
#define ID_VAL_LOW 0x52
|
||||
#define SENSOR_FRAME_RATE 30
|
||||
|
||||
#define GAIN_STEP_BASE 64 //mean gain min step is 1/64gain
|
||||
|
||||
#define I2C_ADDR 0x60
|
||||
//#define I2C_ADDR_2 0x32
|
||||
|
||||
#define SENSOR_NUM 0x2
|
||||
#define SENSOR_NAME "sc202cs_mipi"
|
||||
#define SENSOR_NAME_2 "sc202cs_mipi_2"
|
||||
#define SENSOR_NAME "sc202csr_mipi"
|
||||
#define SENSOR_NAME_2 "sc202csi_mipi"
|
||||
|
||||
#define SC202CS_1600X1200_30FPS
|
||||
|
||||
static int sensor_power_count[2];
|
||||
static int sensor_stream_count[2];
|
||||
static struct sensor_format_struct *current_win[2];
|
||||
static struct sensor_format_struct *current_switch_win[2];
|
||||
|
||||
#define SENSOR_30FPS 1
|
||||
#define SENSOR_25FPS 0
|
||||
#define SENSOR_20FPS 0
|
||||
#define SENSOR_15FPS 0
|
||||
|
||||
/*
|
||||
* The default register settings
|
||||
@@ -72,14 +58,9 @@ static struct sensor_format_struct *current_switch_win[2];
|
||||
|
||||
static struct regval_list sensor_default_regs[] = {
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#if defined CONFIG_ISP_READ_THRESHOLD || defined CONFIG_ISP_ONLY_HARD_LIGHTADC//FULL_SIZE
|
||||
#if SENSOR_30FPS
|
||||
|
||||
static struct regval_list sensor_1600x1200_30_regs[] = {
|
||||
static struct regval_list sensor_normal_regs[] = {
|
||||
{0x0103, 0x01},
|
||||
{0x0100, 0x00},
|
||||
{0x36e9, 0x80},
|
||||
@@ -190,19 +171,7 @@ static struct regval_list sensor_1600x1200_30_regs[] = {
|
||||
{0x450d, 0x61},
|
||||
{0x0100, 0x01},
|
||||
};
|
||||
#endif
|
||||
|
||||
#else //CONFIG_ISP_FAST_CONVERGENCE || CONFIG_ISP_HARD_LIGHTADC
|
||||
static struct regval_list sensor_480p120_regs[] = {
|
||||
|
||||
};
|
||||
#if SENSOR_30FPS
|
||||
static struct regval_list sensor_480p120fps_to_1600x1200_30fps[] = {
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Here we'll try to encapsulate the changes for just the output
|
||||
* video format.
|
||||
@@ -213,53 +182,29 @@ static struct regval_list sensor_fmt_raw[] = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Code for dealing with controls.
|
||||
* fill with different sensor module
|
||||
* different sensor module has different settings here
|
||||
* if not support the follow function , retrun -EINVAL
|
||||
*/
|
||||
#if 0
|
||||
static int sensor_g_exp(struct v4l2_subdev *sd, __s32 *value)
|
||||
{
|
||||
struct sensor_info *info = to_state(sd);
|
||||
*value = info->exp;
|
||||
sensor_dbg("sensor_get_exposure = %d\n", info->exp);
|
||||
return 0;
|
||||
}
|
||||
static int sensor_g_gain(struct v4l2_subdev *sd, __s32 *value)
|
||||
{
|
||||
struct sensor_info *info = to_state(sd);
|
||||
*value = info->gain;
|
||||
sensor_dbg("sensor_get_gain = %d\n", info->gain);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
static int sc202cs_sensor_vts;
|
||||
|
||||
static int sensor_s_exp(int id, unsigned int exp_val)
|
||||
{
|
||||
unsigned int tmp_exp_val = exp_val;
|
||||
data_type explow, expmid, exphigh;
|
||||
|
||||
int explow, expmid, exphigh;
|
||||
//struct sensor_info *info = to_state(sd);
|
||||
/*struct vin_md *vind = dev_get_drvdata(sd->v4l2_dev->dev);*/
|
||||
/*struct vin_core *vinc = vind->vinc[0];*/
|
||||
|
||||
if (exp_val > EXPOSURE_MAX << 4)
|
||||
exp_val = EXPOSURE_MAX << 4;
|
||||
sensor_print("exp_val:%d.\n", exp_val);
|
||||
if (exp_val > sc202cs_sensor_vts << 4)
|
||||
exp_val = sc202cs_sensor_vts << 4;
|
||||
|
||||
if (exp_val < 16)
|
||||
exp_val = 16;
|
||||
|
||||
exphigh = (unsigned char) (0x0f & (exp_val>>16));
|
||||
expmid = (unsigned char) (0xff & (exp_val>>8));
|
||||
explow = (unsigned char) (0xf0 & (exp_val<<0));
|
||||
sensor_write(id, 0x3e02, explow);
|
||||
sensor_write(id, 0x3e01, expmid);
|
||||
sensor_write(id, 0x3e00, exphigh);
|
||||
sensor_dbg("%s():%d, exp_val = %d\n", __func__, __LINE__, exp_val);
|
||||
//info->exp = exp_val;
|
||||
sensor_print("exp_val:%d.\n", exp_val);
|
||||
|
||||
exphigh = (unsigned char)(0xf & (exp_val >> 12)); // upper 4 bits
|
||||
expmid = (unsigned char)(0xff & (exp_val >> 4)); // middle 7 bits
|
||||
explow = (unsigned char)(0xf0 & (exp_val << 4)); // lower 4 bits
|
||||
|
||||
sensor_write(id, 0x3e02, explow); //[7:4]
|
||||
sensor_write(id, 0x3e01, expmid); //[7:0]
|
||||
sensor_write(id, 0x3e00, exphigh); //[3:0]
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -272,7 +217,11 @@ static int setSensorGain(int id, int gain)
|
||||
int dig_Gain;
|
||||
int gain_flag = 1;
|
||||
|
||||
if (ana_gain >= 16) {
|
||||
if (ana_gain >= 32 * 2) {
|
||||
gain_flag = 5;
|
||||
} else if (ana_gain >= 32) {
|
||||
gain_flag = 5;
|
||||
} else if (ana_gain >= 16) {
|
||||
gain_flag = 4;
|
||||
} else if (ana_gain >= 8) {
|
||||
gain_flag = 3;
|
||||
@@ -289,16 +238,21 @@ static int setSensorGain(int id, int gain)
|
||||
if (dig_Gain < 2 * GAIN_STEP_BASE) {
|
||||
//step1/128
|
||||
sensor_write(id, DIG_GAIN, 0x00);
|
||||
sensor_write(id, DIG_FINE_GAIN, dig_Gain - GAIN_STEP_BASE + 0x80);
|
||||
sensor_write(id, DIG_FINE_GAIN, dig_Gain - 128 + 0x80);
|
||||
//sensor_print("sensor set analog_gain:0x%02x, dig_gain:0x%02x, dig_fine_gain:0x%02x", analog_Gain_Reg[gain_flag], 0x00, dig_Gain - 128 + 0x80);
|
||||
} else if (dig_Gain < 4 * GAIN_STEP_BASE) {
|
||||
//step1/64
|
||||
sensor_write(id, DIG_GAIN, 0x01);
|
||||
sensor_write(id, DIG_FINE_GAIN, (dig_Gain - GAIN_STEP_BASE * 2) / 2 + 0x80);
|
||||
sensor_write(id, DIG_FINE_GAIN, (dig_Gain - 128 * 2) / 2 + 0x80);
|
||||
//sensor_print("sensor set analog_gain:0x%02x, dig_gain:0x%02x, dig_fine_gain:0x%02x", analog_Gain_Reg[gain_flag], 0x01, (dig_Gain - 128 * 2) / 2 + 0x80);
|
||||
} else if (dig_Gain < 8 * GAIN_STEP_BASE) {
|
||||
//step1/32
|
||||
sensor_write(id, DIG_GAIN, 0x03);
|
||||
sensor_write(id, DIG_FINE_GAIN, (dig_Gain - 128 * 4) / 4 + 0x80);
|
||||
//sensor_print("sensor set analog_gain:0x%02x, dig_gain:0x%02x, dig_fine_gain:0x%02x", analog_Gain_Reg[gain_flag], 0x03, (dig_Gain - 128 * 4) / 4 + 0x80);
|
||||
} else {
|
||||
sensor_write(id, DIG_GAIN, 0x01);
|
||||
sensor_write(id, DIG_FINE_GAIN, 0xfc);
|
||||
sensor_write(id, DIG_GAIN, 0x03);
|
||||
sensor_write(id, DIG_FINE_GAIN, 0xfe);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -306,8 +260,10 @@ static int setSensorGain(int id, int gain)
|
||||
|
||||
static int sensor_s_gain(int id, int gain_val)
|
||||
{
|
||||
#if 0
|
||||
int tem_gain_val;
|
||||
|
||||
|
||||
sensor_print("gain_val:%d.\n", gain_val);
|
||||
//gain min step is 1/128gain
|
||||
tem_gain_val = gain_val * GAIN_STEP_BASE;
|
||||
if ((tem_gain_val - tem_gain_val / 16 * 16) > 0) {
|
||||
@@ -316,156 +272,94 @@ static int sensor_s_gain(int id, int gain_val)
|
||||
tem_gain_val = tem_gain_val / 16;
|
||||
}
|
||||
|
||||
sensor_dbg("%s(), L:%d, gain_val:%d, tem_gain_val:%d, info->gain:%d\n",
|
||||
__func__, __LINE__, gain_val, tem_gain_val, info->gain);
|
||||
|
||||
sensor_print("%s(), L:%d, gain_val:%d, tem_gain_val:%d\n",
|
||||
__func__, __LINE__, gain_val, tem_gain_val);
|
||||
|
||||
setSensorGain(id, tem_gain_val);
|
||||
#else
|
||||
if (gain_val > 16 * 16 - 1)
|
||||
gain_val = 16 * 16 - 1;
|
||||
|
||||
if (gain_val < 32) {
|
||||
sensor_write(id, 0x3314, 0x1e);
|
||||
sensor_write(id, 0x3317, 0x10);
|
||||
} else {
|
||||
sensor_write(id, 0x3314, 0x4f);
|
||||
sensor_write(id, 0x3317, 0x0f);
|
||||
}
|
||||
|
||||
if (gain_val < 32) {
|
||||
sensor_write(id, 0x3e08, 0x03);
|
||||
sensor_write(id, 0x3e09, gain_val);
|
||||
} else if (gain_val >= 32 && gain_val < 64) {
|
||||
sensor_write(id, 0x3e08, 0x07);
|
||||
sensor_write(id, 0x3e09, gain_val >> 1);
|
||||
} else if (gain_val >= 64 && gain_val < 128) {
|
||||
sensor_write(id, 0x3e08, 0x0f);
|
||||
sensor_write(id, 0x3e09, gain_val >> 2);
|
||||
} else if (gain_val >= 128) {
|
||||
sensor_write(id, 0x3e08, 0x1f);
|
||||
sensor_write(id, 0x3e09, gain_val >> 3);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int sc202cs_sensor_vts;
|
||||
static int sensor_s_exp_gain(int id, struct sensor_exp_gain *exp_gain)
|
||||
{
|
||||
int exp_val, gain_val;
|
||||
int exp_val,gain_val;
|
||||
int shutter = 0, frame_length = 0;
|
||||
|
||||
exp_val = exp_gain->exp_val;
|
||||
gain_val = exp_gain->gain_val;
|
||||
sensor_s_exp(id, exp_gain->exp_val);
|
||||
sensor_s_gain(id, exp_gain->gain_val);
|
||||
sensor_s_exp(id, exp_val);
|
||||
sensor_s_gain(id, gain_val);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int sensor_flip_status;
|
||||
static int sensor_s_vflip(int id, int enable)
|
||||
{
|
||||
data_type get_value;
|
||||
data_type set_value;
|
||||
|
||||
if (!(enable == 0 || enable == 1))
|
||||
return -1;
|
||||
|
||||
sensor_read(id, 0x00, &get_value);
|
||||
sensor_dbg("ready to vflip, regs_data = 0x%x\n", get_value);
|
||||
|
||||
if (enable) {
|
||||
set_value = get_value | 0x04;
|
||||
sensor_flip_status |= 0x04;
|
||||
} else {
|
||||
set_value = get_value & 0xFB;
|
||||
sensor_flip_status &= 0xFB;
|
||||
}
|
||||
sensor_write(id, 0x00, set_value);
|
||||
usleep_range(80000, 100000);
|
||||
sensor_read(id, 0x00, &get_value);
|
||||
sensor_dbg("after vflip, regs_data = 0x%x, sensor_flip_status = %d\n",
|
||||
get_value, sensor_flip_status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sensor_s_hflip(int id, int enable)
|
||||
{
|
||||
data_type get_value;
|
||||
data_type set_value;
|
||||
|
||||
if (!(enable == 0 || enable == 1))
|
||||
return -1;
|
||||
|
||||
sensor_read(id, 0x00, &get_value);
|
||||
sensor_dbg("ready to hflip, regs_data = 0x%x\n", get_value);
|
||||
|
||||
if (enable) {
|
||||
set_value = get_value | 0x08;
|
||||
sensor_flip_status |= 0x08;
|
||||
} else {
|
||||
set_value = get_value & 0xF7;
|
||||
sensor_flip_status &= 0xF7;
|
||||
}
|
||||
sensor_write(id, 0x00, set_value);
|
||||
usleep_range(80000, 100000);
|
||||
sensor_read(id, 0x00, &get_value);
|
||||
sensor_dbg("after hflip, regs_data = 0x%x, sensor_flip_status = %d\n",
|
||||
get_value, sensor_flip_status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sensor_get_fmt_mbus_core(struct v4l2_subdev *sd, int *code)
|
||||
{
|
||||
// struct sensor_info *info = to_state(sd);
|
||||
// data_type get_value = 0, check_value = 0;
|
||||
|
||||
// sensor_read(sd, 0x17, &get_value);
|
||||
// check_value = get_value & 0x03;
|
||||
// check_value = sensor_flip_status & 0x3;
|
||||
// sensor_dbg("0x17 = 0x%x, check_value = 0x%x\n", get_value, check_value);
|
||||
|
||||
// switch (check_value) {
|
||||
// case 0x00:
|
||||
// sensor_dbg("RGGB\n");
|
||||
// *code = MEDIA_BUS_FMT_SRGGB10_1X10;
|
||||
// break;
|
||||
// case 0x01:
|
||||
// sensor_dbg("GRBG\n");
|
||||
// *code = MEDIA_BUS_FMT_SGRBG10_1X10;
|
||||
// break;
|
||||
// case 0x02:
|
||||
// sensor_dbg("GBRG\n");
|
||||
// *code = MEDIA_BUS_FMT_SGBRG10_1X10;
|
||||
// break;
|
||||
// case 0x03:
|
||||
// sensor_dbg("BGGR\n");
|
||||
// *code = MEDIA_BUS_FMT_SBGGR10_1X10;
|
||||
// break;
|
||||
// default:
|
||||
// *code = info->fmt->mbus_code;
|
||||
// }
|
||||
*code = MEDIA_BUS_FMT_SRGGB10_1X10; // sc202cs support change the rgb format by itself
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Stuff that knows about the sensor.
|
||||
*/
|
||||
static int sensor_power(int id, int on)
|
||||
{
|
||||
if (on && (sensor_power_count[id])++ > 0)
|
||||
int ret;
|
||||
if (on && (sensor_power_count[id])++ > 0) {
|
||||
return 0;
|
||||
else if (!on && (sensor_power_count[id] == 0 || --(sensor_power_count[id]) > 0))
|
||||
} else if (!on && (sensor_power_count[id] == 0 || --(sensor_power_count[id]) > 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (on) {
|
||||
switch(on){
|
||||
case PWR_ON:
|
||||
sensor_print("PWR_ON!\n");
|
||||
vin_set_mclk(id, 0);
|
||||
hal_usleep(1000);
|
||||
vin_set_mclk_freq(id, MCLK);
|
||||
vin_set_mclk(id, 1);
|
||||
hal_usleep(1000);
|
||||
//vin_gpio_set_status(id, PWDN, 1);
|
||||
ret = vin_gpio_get_status(id, IR_CUT0);
|
||||
if(ret != 1){ //if not output, set output
|
||||
vin_gpio_set_status(id, IR_CUT0, 1); /* power en*/
|
||||
vin_gpio_write(id, IR_CUT0, CSI_GPIO_HIGH); /* power en*/
|
||||
}
|
||||
//vin_gpio_get_status(id, IR_CUT0);
|
||||
vin_gpio_read(id, IR_CUT0);
|
||||
vin_gpio_set_status(id, PWDN, 1);
|
||||
vin_gpio_set_status(id, RESET, 1);
|
||||
//vin_gpio_set_status(sd, POWER_EN, 1);
|
||||
//vin_gpio_write(id, PWDN, CSI_GPIO_LOW);
|
||||
//vin_gpio_set_status(id, IR_CUT0, 1); /* power en*/
|
||||
|
||||
//vin_gpio_write(id, IR_CUT0, CSI_GPIO_HIGH); /* power en*/
|
||||
vin_gpio_write(id, PWDN, CSI_GPIO_LOW);
|
||||
vin_gpio_write(id, RESET, CSI_GPIO_LOW);
|
||||
hal_usleep(1000);
|
||||
//vin_gpio_write(id, PWDN, CSI_GPIO_HIGH);
|
||||
hal_usleep(1000);
|
||||
vin_gpio_write(id, PWDN, CSI_GPIO_HIGH);
|
||||
vin_gpio_write(id, RESET, CSI_GPIO_HIGH);
|
||||
hal_usleep(1000);
|
||||
break;
|
||||
|
||||
break;
|
||||
case PWR_OFF:
|
||||
sensor_print("PWR_OFF!\n");
|
||||
vin_set_mclk(id, 0);
|
||||
hal_usleep(1000);
|
||||
// vin_gpio_set_status(id, PWDN, 1);
|
||||
vin_gpio_set_status(id, PWDN, 1);
|
||||
vin_gpio_set_status(id, RESET, 1);
|
||||
// vin_gpio_write(id, PWDN, CSI_GPIO_LOW);
|
||||
vin_gpio_write(id, PWDN, CSI_GPIO_LOW);
|
||||
vin_gpio_write(id, RESET, CSI_GPIO_LOW);
|
||||
break;
|
||||
default:
|
||||
@@ -495,55 +389,25 @@ static int sensor_set_ir(int id, int status)
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int sensor_reset(int id, u32 val)
|
||||
{
|
||||
|
||||
sensor_dbg("%s: val=%d\n", __func__);
|
||||
switch (val) {
|
||||
case 0:
|
||||
vin_gpio_write(id, RESET, CSI_GPIO_HIGH);
|
||||
hal_usleep(1000);
|
||||
break;
|
||||
case 1:
|
||||
vin_gpio_write(id, RESET, CSI_GPIO_LOW);
|
||||
hal_usleep(1000);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int sensor_detect(int id)
|
||||
{
|
||||
static int sensor_detect(int id){
|
||||
data_type rdval;
|
||||
int eRet;
|
||||
int times_out = 3;
|
||||
do {
|
||||
eRet = sensor_read(id, ID_REG_HIGH, &rdval);
|
||||
sensor_dbg("eRet:%d, ID_VAL_HIGH:0x%x, times_out:%d\n", eRet, rdval, times_out);
|
||||
hal_usleep(200);
|
||||
times_out--;
|
||||
} while (eRet < 0 && times_out > 0);
|
||||
|
||||
sensor_read(id, ID_REG_HIGH, &rdval);
|
||||
sensor_dbg("ID_VAL_HIGH = %2x, Done!\n", rdval);
|
||||
if (rdval != ID_VAL_HIGH)
|
||||
sensor_print("ID_VAL_HIGH = %2x, Done!\n", rdval);
|
||||
|
||||
if(rdval != ID_VAL_HIGH)
|
||||
return -ENODEV;
|
||||
|
||||
sensor_read(id, ID_REG_LOW, &rdval);
|
||||
sensor_dbg("ID_VAL_LOW = %2x, Done!\n", rdval);
|
||||
if (rdval != ID_VAL_LOW)
|
||||
sensor_print("ID_VAL_LOW = %2x, Done!\n", rdval);
|
||||
if(rdval != ID_VAL_LOW)
|
||||
return -ENODEV;
|
||||
|
||||
sensor_dbg("Done!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -552,10 +416,8 @@ static int sensor_init(int id)
|
||||
int ret;
|
||||
|
||||
sensor_dbg("sensor_init\n");
|
||||
|
||||
/*Make sure it is a target sensor */
|
||||
ret = sensor_detect(id);
|
||||
if (ret) {
|
||||
if(ret) {
|
||||
sensor_err("chip found is not an target chip.\n");
|
||||
return ret;
|
||||
}
|
||||
@@ -567,53 +429,29 @@ static int sensor_init(int id)
|
||||
* Store information about the video data format.
|
||||
*/
|
||||
static struct sensor_format_struct sensor_formats[] = {
|
||||
#if defined CONFIG_ISP_READ_THRESHOLD || defined CONFIG_ISP_ONLY_HARD_LIGHTADC // FULL_SIZE
|
||||
#if SENSOR_30FPS
|
||||
|
||||
{
|
||||
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,//MEDIA_BUS_FMT_SRGGB10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
|
||||
.width = 1600,
|
||||
.height = 1200,
|
||||
.hoffset = 0,
|
||||
.voffset = 0,
|
||||
.hts = 1920,
|
||||
.vts = 1250,
|
||||
.pclk = 72000000,
|
||||
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
|
||||
.width = 1600,
|
||||
.height = 1200,//1080,
|
||||
.hoffset = 0,
|
||||
.voffset = 0,
|
||||
.hts = 2200,
|
||||
.vts = 1250,
|
||||
.pclk = 74250000,
|
||||
.mipi_bps = 371250000,
|
||||
.fps_fixed = 30,
|
||||
.bin_factor = 1,
|
||||
.intg_min = 1 << 4,
|
||||
.intg_max = (1250 - 8) << 4,
|
||||
.intg_max = 1250 << 4,
|
||||
.gain_min = 1 << 4,
|
||||
.gain_max = 64 << 4,
|
||||
.gain_max = 128 << 4,
|
||||
.offs_h = 0,
|
||||
.offs_v = 0,
|
||||
.regs = sensor_1600x1200_30_regs,
|
||||
.regs_size = ARRAY_SIZE(sensor_1600x1200_30_regs),
|
||||
}
|
||||
#endif
|
||||
#else //CONFIG_ISP_FAST_CONVERGENCE || CONFIG_ISP_HARD_LIGHTADC
|
||||
{
|
||||
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,
|
||||
.width = 640,
|
||||
.height = 480,
|
||||
.hoffset = 0,
|
||||
.voffset = 0,
|
||||
.hts = 1696,
|
||||
.vts = 525,
|
||||
.pclk = 106848000,
|
||||
.mipi_bps = 648 * 1000 * 1000,
|
||||
.fps_fixed = 120,
|
||||
.bin_factor = 1,
|
||||
.intg_min = 1 << 4,
|
||||
.intg_max = (525 - 16) << 4,
|
||||
.gain_min = 1 << 4,
|
||||
.gain_max = 110 << 4,
|
||||
.offs_h = 0,
|
||||
.offs_v = 0,
|
||||
.regs = sensor_480p120_regs,
|
||||
.regs_size = ARRAY_SIZE(sensor_480p120_regs),
|
||||
}
|
||||
#endif
|
||||
.regs = sensor_normal_regs,
|
||||
.regs_size = ARRAY_SIZE(sensor_normal_regs),
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
static struct sensor_format_struct *sensor_get_format(int id, int isp_id)
|
||||
@@ -679,18 +517,18 @@ static struct sensor_format_struct switch_sensor_formats[] = {
|
||||
.height = 1200,//1080,
|
||||
.hoffset = 0,
|
||||
.voffset = 0,
|
||||
.hts = 1920,
|
||||
.vts = 1250,
|
||||
.pclk = 72000000,
|
||||
.mipi_bps = 672 * 1000 * 1000,
|
||||
.hts = 2200,
|
||||
.vts = 1250,
|
||||
.pclk = 74250000,
|
||||
.mipi_bps = 371250000,
|
||||
.fps_fixed = 30,
|
||||
.bin_factor = 1,
|
||||
.intg_min = 1 << 4,
|
||||
.intg_max = (1250 - 16) << 4,
|
||||
.intg_max = 1250 << 4,
|
||||
.gain_min = 1 << 4,
|
||||
.gain_max = 110 << 4,
|
||||
.switch_regs = sensor_480p120fps_to_1600x1200_30fps,
|
||||
.switch_regs_size = ARRAY_SIZE(sensor_480p120fps_to_1600x1200_30fps),
|
||||
.gain_max = 128 << 4,
|
||||
.switch_regs = sensor_normal_regs,
|
||||
.switch_regs_size = ARRAY_SIZE(sensor_normal_regs),
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -746,12 +584,9 @@ done:
|
||||
|
||||
static int sensor_g_mbus_config(int id, struct v4l2_mbus_config *cfg, struct mbus_framefmt_res *res)
|
||||
{
|
||||
//struct sensor_info *info = to_state(sd);
|
||||
|
||||
cfg->type = V4L2_MBUS_CSI2;
|
||||
cfg->flags = 0 | V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_CHANNEL_0;
|
||||
// res->res_time_hs = 0x11;
|
||||
res->deskew = 2;
|
||||
res->res_time_hs = 0x28;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -775,7 +610,6 @@ static int sensor_reg_init(int id, int isp_id)
|
||||
return ret;
|
||||
|
||||
sc202cs_sensor_vts = current_win[id]->vts;
|
||||
#if 0
|
||||
//#if defined CONFIG_ISP_READ_THRESHOLD || defined CONFIG_ISP_FAST_CONVERGENCE
|
||||
if (ispid == 0) {
|
||||
exp_gain.exp_val = clamp(*((unsigned int *)ISP0_NORFLASH_SAVE + 2), 16, 1125 << 4);
|
||||
@@ -784,19 +618,10 @@ static int sensor_reg_init(int id, int isp_id)
|
||||
exp_gain.exp_val = clamp(*((unsigned int *)ISP1_NORFLASH_SAVE + 2), 16, 1125 << 4);
|
||||
exp_gain.gain_val = clamp(*((unsigned int *)ISP1_NORFLASH_SAVE + 1), 16, 110 << 4);
|
||||
}
|
||||
#if defined CONFIG_ISP_FAST_CONVERGENCE || defined CONFIG_ISP_HARD_LIGHTADC
|
||||
temperature_ctrl = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
exp_gain.exp_val = 0xff0302;
|
||||
exp_gain.gain_val = 0xff24;
|
||||
sensor_s_exp_gain(id, &exp_gain);
|
||||
// sensor_write(id, 0x3e, 0x91);
|
||||
//#else //CONFIG_ISP_HARD_LIGHTADC
|
||||
|
||||
//#endif
|
||||
//sensor_flip_status = 0x0;
|
||||
sc202cs_sensor_vts = current_win[id]->vts;
|
||||
//sensor_dbg("sc202cs_sensor_vts = %d\n", sc202cs_sensor_vts);
|
||||
|
||||
return 0;
|
||||
@@ -804,12 +629,13 @@ exp_gain.gain_val = 0xff24;
|
||||
|
||||
static int sensor_s_stream(int id, int isp_id, int enable)
|
||||
{
|
||||
sensor_dbg("step sensor_s_stream\n");
|
||||
if (enable && sensor_stream_count[id]++ > 0)
|
||||
return 0;
|
||||
else if (!enable && (sensor_stream_count[id] == 0 || --sensor_stream_count[id] > 0))
|
||||
return 0;
|
||||
|
||||
sensor_dbg("%s on = %d, 2560*1440 fps: 15\n", __func__, enable);
|
||||
sensor_dbg("%s on = %d, 1600*1200 fps: 15\n", __func__, enable);
|
||||
|
||||
if (!enable)
|
||||
return 0;
|
||||
@@ -823,7 +649,7 @@ static int sensor_s_switch(int id)
|
||||
struct sensor_exp_gain exp_gain;
|
||||
int ret = -1;
|
||||
temperature_ctrl = 1;
|
||||
sc202cs_sensor_vts = current_switch_win[id]->vts;
|
||||
bf2257cs_sensor_vts = current_switch_win[id]->vts;
|
||||
if (current_switch_win[id]->switch_regs)
|
||||
ret = sensor_write_array(id, current_switch_win[id]->switch_regs, current_switch_win[id]->switch_regs_size);
|
||||
else
|
||||
|
||||
@@ -69,7 +69,8 @@ struct sensor_cfg_array sensor_array[] = {
|
||||
{"gc2083_mipi", &gc2083_core},
|
||||
#endif
|
||||
#ifdef CONFIG_SENSOR_SC202CS_MIPI
|
||||
{"sc202cs_mipi", &sc202cs_core},
|
||||
{"sc202csr_mipi", &sc202cs_core},
|
||||
{"sc202csi_mipi", &sc202cs_core},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user