mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
camera: add ov5642 5M/3M/2M/1M capture parpmter and fix auto focus
This commit is contained in:
654
drivers/media/video/ov5642.c
Normal file → Executable file
654
drivers/media/video/ov5642.c
Normal file → Executable file
@@ -37,9 +37,9 @@
|
||||
#define SENSOR_MIN_HEIGHT 144
|
||||
#define SENSOR_MAX_WIDTH 2592
|
||||
#define SENSOR_MAX_HEIGHT 1944
|
||||
#define SENSOR_INIT_WIDTH 640 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 480
|
||||
#define SENSOR_INIT_WINSEQADR sensor_vga
|
||||
#define SENSOR_INIT_WIDTH 800 /* Sensor pixel size for sensor_init_data array */
|
||||
#define SENSOR_INIT_HEIGHT 600
|
||||
#define SENSOR_INIT_WINSEQADR sensor_svga
|
||||
#define SENSOR_INIT_PIXFMT V4L2_PIX_FMT_UYVY
|
||||
|
||||
#define CONFIG_SENSOR_WhiteBalance 1
|
||||
@@ -60,7 +60,7 @@
|
||||
#define CONFIG_SENSOR_Focus 0
|
||||
#endif
|
||||
|
||||
#define CONFIG_SENSOR_I2C_SPEED 300000 /* Hz */
|
||||
#define CONFIG_SENSOR_I2C_SPEED 100000 /* Hz */
|
||||
|
||||
#define CONFIG_SENSOR_TR 1
|
||||
#define CONFIG_SENSOR_DEBUG 1
|
||||
@@ -803,35 +803,7 @@ static struct reginfo sensor_init_data[] =
|
||||
{0x568d,0xef},
|
||||
{0x568e,0xaa},
|
||||
{0x568f,0xaa},
|
||||
{0x0000,0x00}
|
||||
|
||||
};
|
||||
/* 2592X1944 QSXGA */
|
||||
static struct reginfo sensor_qsxga[] =
|
||||
{
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
/* 2048*1536 QXGA */
|
||||
static struct reginfo sensor_qxga[] =
|
||||
{
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
|
||||
/* 1600X1200 UXGA */
|
||||
static struct reginfo sensor_uxga[] =
|
||||
{
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
|
||||
/* 1280X1024 SXGA */
|
||||
static struct reginfo sensor_sxga[] =
|
||||
{
|
||||
{0x0000,0x00}
|
||||
};
|
||||
|
||||
/* 800X600 SVGA*/
|
||||
static struct reginfo sensor_svga[] =
|
||||
{
|
||||
{0x3800 ,0x1 },
|
||||
{0x3801 ,0x50},
|
||||
{0x3802 ,0x0 },
|
||||
@@ -859,9 +831,450 @@ static struct reginfo sensor_svga[] =
|
||||
{0x5687 ,0xc0},
|
||||
{0x5687 ,0xc0},
|
||||
{0x3815 ,0x02},
|
||||
{0x3503 ,0x00},
|
||||
{0x0000,0x00}
|
||||
|
||||
};
|
||||
/* 2592X1944 QSXGA */
|
||||
static struct reginfo sensor_qsxga[] =
|
||||
{
|
||||
{0x3503 , 0x7 },
|
||||
{0x3000 , 0x0 },
|
||||
{0x3001 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3003 , 0x0 },
|
||||
{0x3005 , 0xff},
|
||||
{0x3006 , 0xff},
|
||||
{0x3007 , 0x3f},
|
||||
{0x350c , 0x7 },
|
||||
{0x350d , 0xd0},
|
||||
{0x3602 , 0xe4},
|
||||
{0x3612 , 0xac},
|
||||
{0x3613 , 0x44},
|
||||
{0x3621 , 0x27},
|
||||
{0x3622 , 0x8 },
|
||||
{0x3623 , 0x22},
|
||||
{0x3604 , 0x60},
|
||||
{0x3705 , 0xda},
|
||||
{0x370a , 0x80},
|
||||
{0x3801 , 0x8a},
|
||||
{0x3803 , 0xa },
|
||||
{0x3804 , 0xa },
|
||||
{0x3805 , 0x20},
|
||||
{0x3806 , 0x7 },
|
||||
{0x3807 , 0x98},
|
||||
{0x3808 , 0xa },
|
||||
{0x3809 , 0x20},
|
||||
{0x380a , 0x7 },
|
||||
{0x380b , 0x98},
|
||||
{0x380c , 0xc },
|
||||
{0x380d , 0x80},
|
||||
{0x380e , 0x7 },
|
||||
{0x380f , 0xd0},
|
||||
{0x3810 , 0xc2},
|
||||
{0x3815 , 0x1 },
|
||||
{0x3818 , 0xc0},
|
||||
{0x3824 , 0x1 },
|
||||
{0x3827 , 0xa },
|
||||
{0x3a00 , 0x78},
|
||||
{0x3a0d , 0x10},
|
||||
{0x3a0e , 0xd },
|
||||
{0x3a10 , 0x32},
|
||||
{0x3a1b , 0x40},
|
||||
{0x3a1e , 0x2e},
|
||||
{0x3a11 , 0xd0},
|
||||
{0x3a1f , 0x40},
|
||||
{0x3a00 , 0x78},
|
||||
{0x460b , 0x37},
|
||||
{0x471d , 0x5 },
|
||||
{0x4713 , 0x2 },
|
||||
{0x471c , 0xd0},
|
||||
{0x5682 , 0xa },
|
||||
{0x5683 , 0x20},
|
||||
{0x5686 , 0x7 },
|
||||
{0x5687 , 0x98},
|
||||
{0x5001 , 0x1 },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x4407 , 0xc },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x3002 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3503 , 0x0 },
|
||||
{0x3010 , 0x10},
|
||||
{0x3009 , 0x1 },
|
||||
{0x300a , 0x56},
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
/* 2048*1536 QXGA */
|
||||
static struct reginfo sensor_qxga[] =
|
||||
{
|
||||
{0x3503 , 0x7 },
|
||||
{0x3000 , 0x0 },
|
||||
{0x3001 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3003 , 0x0 },
|
||||
{0x3005 , 0xff},
|
||||
{0x3006 , 0xff},
|
||||
{0x3007 , 0x3f},
|
||||
{0x350c , 0x7 },
|
||||
{0x350d , 0xd0},
|
||||
{0x3602 , 0xe4},
|
||||
{0x3612 , 0xac},
|
||||
{0x3613 , 0x44},
|
||||
{0x3621 , 0x27},
|
||||
{0x3622 , 0x8 },
|
||||
{0x3623 , 0x22},
|
||||
{0x3604 , 0x60},
|
||||
{0x3705 , 0xda},
|
||||
{0x370a , 0x80},
|
||||
{0x3801 , 0x8a},
|
||||
{0x3803 , 0xa },
|
||||
{0x3804 , 0xa },
|
||||
{0x3805 , 0x20},
|
||||
{0x3806 , 0x7 },
|
||||
{0x3807 , 0x98},
|
||||
{0x3808 , 0xa },
|
||||
{0x3809 , 0x20},
|
||||
{0x380a , 0x7 },
|
||||
{0x380b , 0x98},
|
||||
{0x380c , 0xc },
|
||||
{0x380d , 0x80},
|
||||
{0x380e , 0x7 },
|
||||
{0x380f , 0xd0},
|
||||
{0x3810 , 0xc2},
|
||||
{0x3815 , 0x1 },
|
||||
{0x3818 , 0xc0},
|
||||
{0x3824 , 0x1 },
|
||||
{0x3827 , 0xa },
|
||||
{0x3a00 , 0x78},
|
||||
{0x3a0d , 0x10},
|
||||
{0x3a0e , 0xd },
|
||||
{0x3a10 , 0x32},
|
||||
{0x3a1b , 0x40},
|
||||
{0x3a1e , 0x2e},
|
||||
{0x3a11 , 0xd0},
|
||||
{0x3a1f , 0x40},
|
||||
{0x3a00 , 0x78},
|
||||
{0x460b , 0x37},
|
||||
{0x471d , 0x5 },
|
||||
{0x4713 , 0x2 },
|
||||
{0x471c , 0xd0},
|
||||
{0x5682 , 0xa },
|
||||
{0x5683 , 0x20},
|
||||
{0x5686 , 0x7 },
|
||||
{0x5687 , 0x98},
|
||||
{0x5001 , 0x1 },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x4407 , 0xc },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x3002 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3503 , 0x0 },
|
||||
{0x3010 , 0x10},
|
||||
{0x3009 , 0x1 },
|
||||
{0x300a , 0x56},
|
||||
|
||||
{0x3800 ,0x1 },
|
||||
{0x3801 ,0x8A},
|
||||
{0x3802 ,0x0 },
|
||||
{0x3803 ,0xA },
|
||||
{0x3804 ,0xA },
|
||||
{0x3805 ,0x20},
|
||||
{0x3806 ,0x7 },
|
||||
{0x3807 ,0x98},
|
||||
{0x3808 ,0x8 },
|
||||
{0x3809 ,0x0 },
|
||||
{0x380a ,0x6 },
|
||||
{0x380b ,0x0 },
|
||||
{0x380c ,0xc },
|
||||
{0x380d ,0x80},
|
||||
{0x380e ,0x7 },
|
||||
{0x380f ,0xd0},
|
||||
{0x5001 ,0x7f},
|
||||
{0x5680 ,0x0 },
|
||||
{0x5681 ,0x0 },
|
||||
{0x5682 ,0xA },
|
||||
{0x5683 ,0x20},
|
||||
{0x5684 ,0x0 },
|
||||
{0x5685 ,0x0 },
|
||||
{0x5686 ,0x7 },
|
||||
{0x5687 ,0x98},
|
||||
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
|
||||
/* 1600X1200 UXGA */
|
||||
static struct reginfo sensor_uxga[] =
|
||||
{
|
||||
{0x3503 , 0x7 },
|
||||
{0x3000 , 0x0 },
|
||||
{0x3001 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3003 , 0x0 },
|
||||
{0x3005 , 0xff},
|
||||
{0x3006 , 0xff},
|
||||
{0x3007 , 0x3f},
|
||||
{0x350c , 0x7 },
|
||||
{0x350d , 0xd0},
|
||||
{0x3602 , 0xe4},
|
||||
{0x3612 , 0xac},
|
||||
{0x3613 , 0x44},
|
||||
{0x3621 , 0x27},
|
||||
{0x3622 , 0x8 },
|
||||
{0x3623 , 0x22},
|
||||
{0x3604 , 0x60},
|
||||
{0x3705 , 0xda},
|
||||
{0x370a , 0x80},
|
||||
{0x3801 , 0x8a},
|
||||
{0x3803 , 0xa },
|
||||
{0x3804 , 0xa },
|
||||
{0x3805 , 0x20},
|
||||
{0x3806 , 0x7 },
|
||||
{0x3807 , 0x98},
|
||||
{0x3808 , 0xa },
|
||||
{0x3809 , 0x20},
|
||||
{0x380a , 0x7 },
|
||||
{0x380b , 0x98},
|
||||
{0x380c , 0xc },
|
||||
{0x380d , 0x80},
|
||||
{0x380e , 0x7 },
|
||||
{0x380f , 0xd0},
|
||||
{0x3810 , 0xc2},
|
||||
{0x3815 , 0x1 },
|
||||
{0x3818 , 0xc0},
|
||||
{0x3824 , 0x1 },
|
||||
{0x3827 , 0xa },
|
||||
{0x3a00 , 0x78},
|
||||
{0x3a0d , 0x10},
|
||||
{0x3a0e , 0xd },
|
||||
{0x3a10 , 0x32},
|
||||
{0x3a1b , 0x40},
|
||||
{0x3a1e , 0x2e},
|
||||
{0x3a11 , 0xd0},
|
||||
{0x3a1f , 0x40},
|
||||
{0x3a00 , 0x78},
|
||||
{0x460b , 0x37},
|
||||
{0x471d , 0x5 },
|
||||
{0x4713 , 0x2 },
|
||||
{0x471c , 0xd0},
|
||||
{0x5682 , 0xa },
|
||||
{0x5683 , 0x20},
|
||||
{0x5686 , 0x7 },
|
||||
{0x5687 , 0x98},
|
||||
{0x5001 , 0x1 },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x4407 , 0xc },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x3002 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3503 , 0x0 },
|
||||
{0x3010 , 0x10},
|
||||
{0x3009 , 0x1 },
|
||||
{0x300a , 0x56},
|
||||
|
||||
{0x3800 ,0x1 },
|
||||
{0x3801 ,0x8A},
|
||||
{0x3802 ,0x0 },
|
||||
{0x3803 ,0xA },
|
||||
{0x3804 ,0xA },
|
||||
{0x3805 ,0x20},
|
||||
{0x3806 ,0x7 },
|
||||
{0x3807 ,0x98},
|
||||
{0x3808 ,0x6 },
|
||||
{0x3809 ,0x40},
|
||||
{0x380a ,0x4 },
|
||||
{0x380b ,0xb0},
|
||||
{0x380c ,0xc },
|
||||
{0x380d ,0x80},
|
||||
{0x380e ,0x7 },
|
||||
{0x380f ,0xd0},
|
||||
{0x5001 ,0x7f},
|
||||
{0x5680 ,0x0 },
|
||||
{0x5681 ,0x0 },
|
||||
{0x5682 ,0xA },
|
||||
{0x5683 ,0x20},
|
||||
{0x5684 ,0x0 },
|
||||
{0x5685 ,0x0 },
|
||||
{0x5686 ,0x7 },
|
||||
{0x5687 ,0x98},
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
|
||||
/* 1280X1024 SXGA */
|
||||
static struct reginfo sensor_sxga[] =
|
||||
{
|
||||
{0x3503 , 0x7 },
|
||||
{0x3000 , 0x0 },
|
||||
{0x3001 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3003 , 0x0 },
|
||||
{0x3005 , 0xff},
|
||||
{0x3006 , 0xff},
|
||||
{0x3007 , 0x3f},
|
||||
{0x350c , 0x7 },
|
||||
{0x350d , 0xd0},
|
||||
{0x3602 , 0xe4},
|
||||
{0x3612 , 0xac},
|
||||
{0x3613 , 0x44},
|
||||
{0x3621 , 0x27},
|
||||
{0x3622 , 0x8 },
|
||||
{0x3623 , 0x22},
|
||||
{0x3604 , 0x60},
|
||||
{0x3705 , 0xda},
|
||||
{0x370a , 0x80},
|
||||
{0x3801 , 0x8a},
|
||||
{0x3803 , 0xa },
|
||||
{0x3804 , 0xa },
|
||||
{0x3805 , 0x20},
|
||||
{0x3806 , 0x7 },
|
||||
{0x3807 , 0x98},
|
||||
{0x3808 , 0xa },
|
||||
{0x3809 , 0x20},
|
||||
{0x380a , 0x7 },
|
||||
{0x380b , 0x98},
|
||||
{0x380c , 0xc },
|
||||
{0x380d , 0x80},
|
||||
{0x380e , 0x7 },
|
||||
{0x380f , 0xd0},
|
||||
{0x3810 , 0xc2},
|
||||
{0x3815 , 0x1 },
|
||||
{0x3818 , 0xc0},
|
||||
{0x3824 , 0x1 },
|
||||
{0x3827 , 0xa },
|
||||
{0x3a00 , 0x78},
|
||||
{0x3a0d , 0x10},
|
||||
{0x3a0e , 0xd },
|
||||
{0x3a10 , 0x32},
|
||||
{0x3a1b , 0x40},
|
||||
{0x3a1e , 0x2e},
|
||||
{0x3a11 , 0xd0},
|
||||
{0x3a1f , 0x40},
|
||||
{0x3a00 , 0x78},
|
||||
{0x460b , 0x37},
|
||||
{0x471d , 0x5 },
|
||||
{0x4713 , 0x2 },
|
||||
{0x471c , 0xd0},
|
||||
{0x5682 , 0xa },
|
||||
{0x5683 , 0x20},
|
||||
{0x5686 , 0x7 },
|
||||
{0x5687 , 0x98},
|
||||
{0x5001 , 0x1 },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x4407 , 0xc },
|
||||
{0x589b , 0x0 },
|
||||
{0x589a , 0xc0},
|
||||
{0x3002 , 0x0 },
|
||||
{0x3002 , 0x0 },
|
||||
{0x3503 , 0x0 },
|
||||
{0x3010 , 0x10},
|
||||
{0x3009 , 0x1 },
|
||||
{0x300a , 0x56},
|
||||
|
||||
{0x3800 ,0x1 },
|
||||
{0x3801 ,0x8A},
|
||||
{0x3802 ,0x0 },
|
||||
{0x3803 ,0xA },
|
||||
{0x3804 ,0xA },
|
||||
{0x3805 ,0x20},
|
||||
{0x3806 ,0x7 },
|
||||
{0x3807 ,0x98},
|
||||
{0x3808 ,0x5 },
|
||||
{0x3809 ,0x0 },
|
||||
{0x380a ,0x4 },
|
||||
{0x380b ,0x0 },
|
||||
{0x380c ,0xc },
|
||||
{0x380d ,0x80},
|
||||
{0x380e ,0x7 },
|
||||
{0x380f ,0xd0},
|
||||
{0x5001 ,0x7f},
|
||||
{0x5680 ,0x0 },
|
||||
{0x5681 ,0x0 },
|
||||
{0x5682 ,0xA },
|
||||
{0x5683 ,0x20},
|
||||
{0x5684 ,0x0 },
|
||||
{0x5685 ,0x0 },
|
||||
{0x5686 ,0x7 },
|
||||
{0x5687 ,0x98},
|
||||
|
||||
{0x0000,0x00}
|
||||
};
|
||||
|
||||
/* 800X600 SVGA*/
|
||||
static struct reginfo sensor_svga[] =
|
||||
{
|
||||
{0x3000,0xf8},
|
||||
{0x3001,0x48},
|
||||
{0x3002,0x5c},
|
||||
{0x3003,0x2},
|
||||
{0x3005,0xb7},
|
||||
{0x3006,0x43},
|
||||
{0x3007,0x37},
|
||||
{0x350c,0x07},
|
||||
{0x350d,0xd0},
|
||||
{0x3602,0xfc},
|
||||
{0x3612,0xff},
|
||||
{0x3613,0x0},
|
||||
{0x3621,0xc7},
|
||||
{0x3622,0x00},
|
||||
{0x3623,0x22},
|
||||
{0x3604,0x40},
|
||||
{0x3705,0xdb},
|
||||
{0x370a,0x81},
|
||||
{0x3801,0x50},
|
||||
{0x3803,0x08},
|
||||
{0x3804,0x05},
|
||||
{0x3805,0x0},
|
||||
{0x3806,0x03},
|
||||
{0x3807,0xc0},
|
||||
{0x3808,0x3},
|
||||
{0x3809,0x20},
|
||||
{0x380a,0x2},
|
||||
{0x380b,0x58},
|
||||
{0x380c,0x0c},
|
||||
{0x380d,0x80},
|
||||
{0x380e,0x03},
|
||||
{0x380f,0xe8},
|
||||
{0x3810,0xc0},
|
||||
{0x3815,0x02},
|
||||
{0x3818,0xc1},
|
||||
{0x3824,0x11},
|
||||
{0x3827,0x08},
|
||||
{0x3a00,0x78},
|
||||
{0x3a0d,0x8},
|
||||
{0x3a0e,0x06},
|
||||
{0x3a10,0x72},
|
||||
{0x3a1b,0x80},
|
||||
{0x3a1e,0x70},
|
||||
{0x3a11,0xd0},
|
||||
{0x3a1f,0x10},
|
||||
{0x460b,0x37},
|
||||
{0x471d,0x5},
|
||||
{0x4713,0x02},
|
||||
{0x471c,0xd0},
|
||||
{0x501f,0x00},
|
||||
{0x4300,0x32},
|
||||
{0x3002,0x5c},
|
||||
{0x5682,0x5},
|
||||
{0x5683,0x0},
|
||||
{0x5686,0x3},
|
||||
{0x5687,0xc0},
|
||||
{0x5001,0x7f},
|
||||
{0x589b,0x4},
|
||||
{0x589a,0xc5},
|
||||
{0x4407,0x04},
|
||||
{0x3002,0x5c},
|
||||
{0x3503,0x00},
|
||||
{0x3000,0x00},
|
||||
{0x0000 ,0x00}
|
||||
};
|
||||
|
||||
/* 640X480 VGA */
|
||||
static struct reginfo sensor_vga[] =
|
||||
{
|
||||
@@ -1524,7 +1937,7 @@ static const struct v4l2_queryctrl sensor_controls[] =
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSOR_Focus
|
||||
#if CONFIG_SENSOR_Focus
|
||||
{
|
||||
.id = V4L2_CID_FOCUS_RELATIVE,
|
||||
.type = V4L2_CTRL_TYPE_INTEGER,
|
||||
@@ -1629,11 +2042,25 @@ typedef struct sensor_info_priv_s
|
||||
unsigned int funmodule_state;
|
||||
} sensor_info_priv_t;
|
||||
|
||||
|
||||
|
||||
struct sensor_parameter
|
||||
{
|
||||
unsigned short int preview_maxlines;
|
||||
unsigned short int preview_exposure;
|
||||
unsigned short int preview_line_width;
|
||||
unsigned short int preview_gain;
|
||||
|
||||
unsigned short int capture_framerate;
|
||||
unsigned short int preview_framerate;
|
||||
};
|
||||
|
||||
struct sensor
|
||||
{
|
||||
struct v4l2_subdev subdev;
|
||||
struct i2c_client *client;
|
||||
sensor_info_priv_t info_priv;
|
||||
struct sensor_parameter parameter;
|
||||
int model; /* V4L2_IDENT_OV* codes from v4l2-chip-ident.h */
|
||||
};
|
||||
|
||||
@@ -1967,16 +2394,155 @@ static int sensor_af_init(struct i2c_client *client)
|
||||
goto sensor_af_init_end;
|
||||
}
|
||||
|
||||
if (sensor_af_single(client)) {
|
||||
ret = -1;
|
||||
goto sensor_af_init_end;
|
||||
}
|
||||
//if (sensor_af_single(client)) {
|
||||
//ret = -1;
|
||||
//goto sensor_af_init_end;
|
||||
//}
|
||||
|
||||
sensor_af_init_end:
|
||||
SENSOR_DG("%s %s ret:0x%x \n",SENSOR_NAME_STRING(),__FUNCTION__,ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
int sensor_parameter_record(struct i2c_client *client)
|
||||
{
|
||||
u8 ret_l,ret_m,ret_h;
|
||||
u8 tp_l,tp_m,tp_h;
|
||||
u16 reg_index = 0;
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
|
||||
sensor_read(client,0x3500,&ret_h);
|
||||
sensor_read(client,0x3501, &ret_m);
|
||||
sensor_read(client,0x3502, &ret_l);
|
||||
tp_l = ret_l;
|
||||
tp_m = ret_m;
|
||||
tp_h = ret_h;
|
||||
SENSOR_DG(" %s Read 0x3500 = 0x%02x 0x3501 = 0x%02x 0x3502=0x%02x \n",SENSOR_NAME_STRING(), ret_h, ret_m, ret_l);
|
||||
sensor->parameter.preview_exposure = (tp_h<<12)+(tp_m<<4)+(tp_l>>4);
|
||||
sensor_read(client,0x350c, &ret_h);
|
||||
sensor_read(client,0x350d, &ret_l);
|
||||
sensor->parameter.preview_line_width = ret_h & 0xff;
|
||||
sensor->parameter.preview_line_width = (sensor->parameter.preview_line_width << 8) +ret_l;
|
||||
//Read back AGC Gain for preview
|
||||
sensor_read(client,0x350b, &sensor->parameter.preview_gain);
|
||||
|
||||
sensor->parameter.capture_framerate = 900;
|
||||
sensor->parameter.preview_framerate = 1500;
|
||||
|
||||
SENSOR_DG(" %s Read 0x350c = 0x%02x 0x350d = 0x%02x 0x350b=0x%02x \n",SENSOR_NAME_STRING(), ret_h, ret_l, sensor->parameter.preview_gain);
|
||||
return 0;
|
||||
}
|
||||
int sensor_ae_transfer(struct i2c_client *client)
|
||||
{
|
||||
u8 ExposureLow;
|
||||
u8 ExposureMid;
|
||||
u8 ExposureHigh;
|
||||
u16 ulCapture_Exposure;
|
||||
u32 ulCapture_Exposure_Gain;
|
||||
u16 iCapture_Gain;
|
||||
u8 Lines_10ms;
|
||||
bool m_60Hz = 0;
|
||||
u8 m_60_50Hz = 1;
|
||||
u8 reg_l = 0,reg_h =0;
|
||||
u16 Preview_Maxlines;
|
||||
u8 Gain;
|
||||
u32 Capture_MaxLines;
|
||||
u8 i = 0;
|
||||
struct sensor *sensor = to_sensor(client);
|
||||
|
||||
Preview_Maxlines = sensor->parameter.preview_line_width;
|
||||
Gain = sensor->parameter.preview_gain;
|
||||
sensor_read(client,0x350c, ®_h);
|
||||
sensor_read(client,0x350d, ®_l);
|
||||
Capture_MaxLines = reg_h & 0xff;
|
||||
Capture_MaxLines = (Capture_MaxLines << 8) + reg_l;
|
||||
|
||||
if(m_60Hz== 1) {
|
||||
Lines_10ms = sensor->parameter.capture_framerate * Capture_MaxLines/12000;
|
||||
} else {
|
||||
Lines_10ms = sensor->parameter.capture_framerate * Capture_MaxLines/10000;
|
||||
}
|
||||
|
||||
if(Preview_Maxlines == 0)
|
||||
Preview_Maxlines = 1;
|
||||
|
||||
ulCapture_Exposure =
|
||||
(sensor->parameter.preview_exposure*(sensor->parameter.capture_framerate)*(Capture_MaxLines))/(((Preview_Maxlines)*(sensor->parameter.preview_framerate)));
|
||||
iCapture_Gain = (Gain & 0x0f) + 16;
|
||||
if (Gain & 0x10) {
|
||||
iCapture_Gain = iCapture_Gain << 1;
|
||||
}
|
||||
if (Gain & 0x20) {
|
||||
iCapture_Gain = iCapture_Gain << 1;
|
||||
}
|
||||
if (Gain & 0x40) {
|
||||
iCapture_Gain = iCapture_Gain << 1;
|
||||
}
|
||||
if (Gain & 0x80) {
|
||||
iCapture_Gain = iCapture_Gain << 1;
|
||||
}
|
||||
ulCapture_Exposure_Gain =(u32) (11 * ulCapture_Exposure * iCapture_Gain/5); //0ld value 2.5, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(ulCapture_Exposure_Gain < Capture_MaxLines*16) {
|
||||
ulCapture_Exposure = ulCapture_Exposure_Gain/16;
|
||||
if (ulCapture_Exposure > Lines_10ms)
|
||||
{
|
||||
//ulCapture_Exposure *= 1.7;
|
||||
ulCapture_Exposure /= Lines_10ms;
|
||||
ulCapture_Exposure *= Lines_10ms;
|
||||
}
|
||||
} else {
|
||||
ulCapture_Exposure = Capture_MaxLines;
|
||||
//ulCapture_Exposure_Gain *= 1.5;
|
||||
}
|
||||
if(ulCapture_Exposure == 0)
|
||||
ulCapture_Exposure = 1;
|
||||
iCapture_Gain = (ulCapture_Exposure_Gain*2/ulCapture_Exposure + 1)/2;
|
||||
ExposureLow = ((unsigned char)ulCapture_Exposure)<<4;
|
||||
ExposureMid = (unsigned char)(ulCapture_Exposure >> 4) & 0xff;
|
||||
ExposureHigh = (unsigned char)(ulCapture_Exposure >> 12);
|
||||
|
||||
Gain = 0;
|
||||
if (iCapture_Gain > 31) {
|
||||
Gain |= 0x10;
|
||||
iCapture_Gain = iCapture_Gain >> 1;
|
||||
}
|
||||
if (iCapture_Gain > 31) {
|
||||
Gain |= 0x20;
|
||||
iCapture_Gain = iCapture_Gain >> 1;
|
||||
}
|
||||
if (iCapture_Gain > 31) {
|
||||
Gain |= 0x40;
|
||||
iCapture_Gain = iCapture_Gain >> 1;
|
||||
}
|
||||
if (iCapture_Gain > 31) {
|
||||
Gain |= 0x80;
|
||||
iCapture_Gain = iCapture_Gain >> 1;
|
||||
}
|
||||
if (iCapture_Gain > 16)
|
||||
Gain |= ((iCapture_Gain -16) & 0x0f);
|
||||
if(Gain == 0x10)
|
||||
Gain = 0x11;
|
||||
// write the gain and exposure to 0x350* registers
|
||||
//m_iWrite0x350b=Gain;
|
||||
sensor_write(client,0x350b, Gain);
|
||||
//m_iWrite0x3502=ExposureLow;
|
||||
sensor_write(client,0x3502, ExposureLow);
|
||||
//m_iWrite0x3501=ExposureMid;
|
||||
sensor_write(client,0x3501, ExposureMid);
|
||||
//m_iWrite0x3500=ExposureHigh;
|
||||
sensor_write(client,0x3500, ExposureHigh);
|
||||
// SendToFile("Gain = 0x%x\r\n", Gain);
|
||||
// SendToFile("ExposureLow = 0x%x\r\n", ExposureLow);
|
||||
// SendToFile("ExposureMid = 0x%x\r\n", ExposureMid);
|
||||
// SendToFile("ExposureHigh = 0x%x\r\n", ExposureHigh);
|
||||
//<2F>ӳ<EFBFBD><D3B3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ⰵ<EFBFBD><E2B0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//camera_timed_wait(200);
|
||||
//linzhk camera_timed_wait(500);
|
||||
SENSOR_DG(" %s Write 0x350b = 0x%02x 0x3502 = 0x%02x 0x3501=0x%02x 0x3500 = 0x%02x\n",SENSOR_NAME_STRING(), Gain, ExposureLow, ExposureMid, ExposureHigh);
|
||||
mdelay(100);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sensor_init(struct v4l2_subdev *sd, u32 val)
|
||||
{
|
||||
struct i2c_client *client = sd->priv;
|
||||
@@ -2299,6 +2865,15 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
|
||||
|
||||
if ((int)winseqe_set_addr != sensor->info_priv.winseqe_cur_addr)
|
||||
{
|
||||
if (set_w >= 1280) { /* ddl@rock-chips.com : Capture */
|
||||
sensor_parameter_record(client);
|
||||
#if CONFIG_SENSOR_Focus
|
||||
sensor_af_idlechk(client);
|
||||
if (sensor->info_priv.auto_focus == SENSOR_AF_MODE_CONTINUOUS)
|
||||
sensor_af_cmdset(client, PauseFocus_Cmd, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
ret |= sensor_write_array(client, winseqe_set_addr);
|
||||
if (ret != 0) {
|
||||
SENSOR_TR("%s set format capability failed\n", SENSOR_NAME_STRING());
|
||||
@@ -2306,10 +2881,9 @@ static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
|
||||
}
|
||||
|
||||
sensor->info_priv.winseqe_cur_addr = (int)winseqe_set_addr;
|
||||
//#if CONFIG_SENSOR_Focus
|
||||
//sensor_af_zoneupdate(client);
|
||||
//#endif
|
||||
|
||||
if (set_w >= 1280)
|
||||
sensor_ae_transfer(client);
|
||||
|
||||
SENSOR_DG("\n%s..%s.. icd->width = %d.. icd->height %d\n",SENSOR_NAME_STRING(),__FUNCTION__,set_w,set_h);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user