update:1、更新双sensor驱动 2、关闭mpp调试信息,缩小rootfs尺寸
This commit is contained in:
@@ -30,16 +30,16 @@ MODULE_DESCRIPTION("A low-level driver for SC202CS sensors");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
//define the registers
|
||||
#define EXP_HIGH 0xff
|
||||
#define EXP_MID 0x03
|
||||
#define EXP_LOW 0x04
|
||||
#define GAIN_HIGH 0xff
|
||||
#define GAIN_LOW 0x24
|
||||
/*
|
||||
* Our nominal (default) frame rate.
|
||||
*/
|
||||
#define ID_REG_HIGH 0xf0
|
||||
#define ID_REG_LOW 0xf1
|
||||
#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 //mean gain min step is 1/128gain
|
||||
|
||||
#define ID_REG_HIGH 0x3e07
|
||||
#define ID_REG_LOW 0x3e08
|
||||
#define ID_VAL_HIGH ((V4L2_IDENT_SENSOR) >> 8)
|
||||
#define ID_VAL_LOW ((V4L2_IDENT_SENSOR) & 0xff)
|
||||
|
||||
@@ -66,7 +66,7 @@ MODULE_LICENSE("GPL");
|
||||
#endif
|
||||
|
||||
#define EXPOSURE_MIN 6
|
||||
#define EXPOSURE_MAX (VTS - 6)
|
||||
#define EXPOSURE_MAX (VTS)
|
||||
#define EXPOSURE_STEP 1
|
||||
#define EXPOSURE_DEFAULT 0x0148
|
||||
|
||||
@@ -373,8 +373,58 @@ static int sensor_g_gain(struct v4l2_subdev *sd, __s32 *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char analog_Gain_Reg[] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f};
|
||||
|
||||
static int setSensorGain(struct v4l2_subdev *sd, int gain)
|
||||
{
|
||||
int ana_gain = gain / GAIN_STEP_BASE;
|
||||
int dig_Gain;
|
||||
int gain_flag = 1;
|
||||
|
||||
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;
|
||||
} else if (ana_gain >= 4) {
|
||||
gain_flag = 2;
|
||||
} else if (ana_gain >= 2) {
|
||||
gain_flag = 1;
|
||||
} else {
|
||||
gain_flag = 0;
|
||||
}
|
||||
|
||||
sensor_write(sd, ANA_GAIN, analog_Gain_Reg[gain_flag]);
|
||||
dig_Gain = gain >> gain_flag; //dig_Gain min mean 1/128gain
|
||||
if (dig_Gain < 2 * GAIN_STEP_BASE) {
|
||||
//step1/128
|
||||
sensor_write(sd, DIG_GAIN, 0x00);
|
||||
sensor_write(sd, 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(sd, DIG_GAIN, 0x01);
|
||||
sensor_write(sd, 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(sd, DIG_GAIN, 0x03);
|
||||
sensor_write(sd, 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(sd, DIG_GAIN, 0x03);
|
||||
sensor_write(sd, DIG_FINE_GAIN, 0xfe);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sensor_s_gain(struct v4l2_subdev *sd, int gain_val)
|
||||
{
|
||||
#if 0
|
||||
struct sensor_info *info = to_state(sd);
|
||||
//sensor_dbg("%s():%d. info:%p, gain_val:%d\n", __func__, __LINE__, info, gain_val);
|
||||
// if (gain_val == info->gain) {
|
||||
@@ -414,6 +464,15 @@ static int sensor_s_gain(struct v4l2_subdev *sd, int gain_val)
|
||||
|
||||
//sensor_dbg("drv sensor_s_gain(%d)\n", gain_val);
|
||||
info->gain = gain_val;
|
||||
#endif
|
||||
struct sensor_info *info = to_state(sd);
|
||||
|
||||
//if (gain_val == info->gain)
|
||||
// return 0;
|
||||
|
||||
//sensor_print("gain_val:%d\n", gain_val);
|
||||
setSensorGain(sd, gain_val);
|
||||
info->gain = gain_val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -421,8 +480,30 @@ static int sensor_s_gain(struct v4l2_subdev *sd, int gain_val)
|
||||
static int sensor_s_exp_gain(struct v4l2_subdev *sd,
|
||||
struct sensor_exp_gain *exp_gain)
|
||||
{
|
||||
sensor_s_exp(sd, exp_gain->exp_val);
|
||||
sensor_s_gain(sd, exp_gain->gain_val);
|
||||
int exp_val, gain_val;
|
||||
//int shutter = 0, frame_length = 0;
|
||||
struct sensor_info *info = to_state(sd);
|
||||
struct i2c_client *client = v4l2_get_subdevdata(sd);
|
||||
if ((exp_gain->exp_val - exp_gain->exp_val / 16 * 16) > 0) {
|
||||
exp_val = exp_gain->exp_val / 16 + 1;
|
||||
} else {
|
||||
exp_val = exp_gain->exp_val / 16;
|
||||
}
|
||||
exp_val = exp_val & 0xffff;
|
||||
|
||||
if (exp_val > 1250){
|
||||
exp_val = 1250;
|
||||
}
|
||||
|
||||
//gain min step is 1/128gain
|
||||
gain_val = exp_gain->gain_val * GAIN_STEP_BASE;
|
||||
if ((gain_val - gain_val / 16 * 16) > 0) {
|
||||
gain_val = gain_val / 16 + 1;
|
||||
} else {
|
||||
gain_val = gain_val / 16;
|
||||
}
|
||||
sensor_s_exp(sd, exp_val);
|
||||
sensor_s_gain(sd, gain_val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -466,7 +547,7 @@ static int sensor_s_hflip(struct v4l2_subdev *sd, int enable)
|
||||
|
||||
static int sensor_get_fmt_mbus_core(struct v4l2_subdev *sd, int *code)
|
||||
{
|
||||
*code = MEDIA_BUS_FMT_SBGGR10_1X10;// MEDIA_BUS_FMT_SRGGB10_1X10; // gc2053 support change the rgb format by itself
|
||||
*code = MEDIA_BUS_FMT_SBGGR10_1X10;//;MEDIA_BUS_FMT_SBGGR10_1X10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -655,8 +736,8 @@ static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
|
||||
info->focus_status = 0;
|
||||
info->low_speed = 0;
|
||||
info->width = SENSOR_WIDTH;
|
||||
info->height = SENSOR_HEIGHT;
|
||||
info->width = 1600;
|
||||
info->height = 1200;
|
||||
info->hflip = 0;
|
||||
info->vflip = 0;
|
||||
info->gain = 0;
|
||||
@@ -695,13 +776,7 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
||||
case SET_FPS:
|
||||
break;
|
||||
case VIDIOC_VIN_SENSOR_EXP_GAIN:
|
||||
if (m_autoexp == V4L2_EXPOSURE_MANUAL) {
|
||||
sensor_print("SENSOR_EXP_GAIN continue\n");
|
||||
break;
|
||||
} else {
|
||||
//sensor_dbg("SENSOR_EXP_GAIN set\n");
|
||||
ret = sensor_s_exp_gain(sd, (struct sensor_exp_gain *)arg);
|
||||
}
|
||||
sensor_s_exp_gain(sd, (struct sensor_exp_gain *)arg);
|
||||
break;
|
||||
// case VIDIOC_VIN_SENSOR_SET_FPS:
|
||||
// ret = sensor_s_fps(sd, (struct sensor_fps *)arg);
|
||||
@@ -727,7 +802,7 @@ static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
|
||||
static struct sensor_format_struct sensor_formats[] = {
|
||||
{
|
||||
.desc = "Raw RGB Bayer",
|
||||
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,//MEDIA_BUS_FMT_SRGGB10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
|
||||
.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,//MEDIA_BUS_FMT_SBGGR10_1X10, /*.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, */
|
||||
.regs = sensor_fmt_raw,
|
||||
.regs_size = ARRAY_SIZE(sensor_fmt_raw),
|
||||
.bpp = 1
|
||||
@@ -746,16 +821,16 @@ static struct sensor_win_size sensor_win_sizes[] = {
|
||||
.height = 1200, //
|
||||
.hoffset = 0,
|
||||
.voffset = 0,
|
||||
.hts = 2200,
|
||||
.hts = 1920,
|
||||
.vts = 1250,
|
||||
.pclk = 74250000,
|
||||
.mipi_bps = 371250000,
|
||||
.pclk = 71250000,
|
||||
.mipi_bps = 297 * 1000 * 1000,
|
||||
.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 = 128 << 4,
|
||||
.gain_max = 16 << 4,
|
||||
.regs = sensor_normal_regs,
|
||||
.regs_size = ARRAY_SIZE(sensor_normal_regs),
|
||||
.set_size = NULL,
|
||||
@@ -973,23 +1048,18 @@ static int sensor_init_controls(struct v4l2_subdev *sd,
|
||||
|
||||
v4l2_ctrl_handler_init(handler, 5);
|
||||
|
||||
ctrl = v4l2_ctrl_new_std(handler, ops, V4L2_CID_GAIN,
|
||||
GAIN_MIN, GAIN_MAX,
|
||||
GAIN_STEP, GAIN_DEFAULT);
|
||||
ctrl = v4l2_ctrl_new_std(handler, ops, V4L2_CID_GAIN, 1 * 1600, 256 * 1600, 1, 1 * 1600);
|
||||
|
||||
if (ctrl != NULL)
|
||||
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
|
||||
|
||||
ctrl = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE,
|
||||
EXPOSURE_MIN, EXPOSURE_MAX,
|
||||
EXPOSURE_STEP, EXPOSURE_DEFAULT);
|
||||
if (ctrl != NULL)
|
||||
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
|
||||
ctrl = v4l2_ctrl_new_std(handler, ops, V4L2_CID_EXPOSURE, 1, 65536 * 16, 1, 1);
|
||||
|
||||
v4l2_ctrl_new_std(handler, ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
|
||||
v4l2_ctrl_new_std(handler, ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
|
||||
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_EXPOSURE_AUTO,
|
||||
V4L2_EXPOSURE_APERTURE_PRIORITY, 0,
|
||||
V4L2_EXPOSURE_AUTO);
|
||||
|
||||
if (ctrl != NULL)
|
||||
ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
|
||||
|
||||
if (handler->error) {
|
||||
ret = handler->error;
|
||||
@@ -1039,7 +1109,7 @@ static int sensor_probe(struct i2c_client *client,
|
||||
info->af_first_flag = 1;
|
||||
info->exp = 0;
|
||||
info->gain = 0;
|
||||
//info->time_hs = 0x11;
|
||||
info->time_hs = 0x11;
|
||||
info->deskew = 0x02;
|
||||
|
||||
#if defined CONFIG_VIN_INIT_MELIS
|
||||
|
||||
Reference in New Issue
Block a user