summaryrefslogtreecommitdiff
path: root/drivers/media/video/wmt_v4l2/sensors/gc0307
diff options
context:
space:
mode:
authorSrikant Patnaik2015-01-13 15:08:24 +0530
committerSrikant Patnaik2015-01-13 15:08:24 +0530
commit97327692361306d1e6259021bc425e32832fdb50 (patch)
treefe9088f3248ec61e24f404f21b9793cb644b7f01 /drivers/media/video/wmt_v4l2/sensors/gc0307
parent2d05a8f663478a44e088d122e0d62109bbc801d0 (diff)
parenta3a8b90b61e21be3dde9101c4e86c881e0f06210 (diff)
downloadFOSSEE-netbook-kernel-source-97327692361306d1e6259021bc425e32832fdb50.tar.gz
FOSSEE-netbook-kernel-source-97327692361306d1e6259021bc425e32832fdb50.tar.bz2
FOSSEE-netbook-kernel-source-97327692361306d1e6259021bc425e32832fdb50.zip
dirty fix to merging
Diffstat (limited to 'drivers/media/video/wmt_v4l2/sensors/gc0307')
-rwxr-xr-xdrivers/media/video/wmt_v4l2/sensors/gc0307/gc0307-twv82222z2-f10.h624
-rwxr-xr-xdrivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.c371
-rwxr-xr-xdrivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.h567
3 files changed, 1562 insertions, 0 deletions
diff --git a/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307-twv82222z2-f10.h b/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307-twv82222z2-f10.h
new file mode 100755
index 00000000..6e48cd00
--- /dev/null
+++ b/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307-twv82222z2-f10.h
@@ -0,0 +1,624 @@
+#ifndef GC0307_H
+#define GC0307_H
+
+
+// Scene Mode
+uint8_t gc0307_scene_mode_auto[] = {
+
+};
+
+uint8_t gc0307_scene_mode_night[] = {
+
+};
+
+
+// White Balance
+uint8_t gc0307_wb_auto [] = {
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x4c,
+ 0xc8,0x40,
+ 0xc9,0x4a,
+};
+
+uint8_t gc0307_wb_incandescent [] = {
+ //bai re guang
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x48,
+ 0xc8,0x40,
+ 0xc9,0x5c,
+};
+
+uint8_t gc0307_wb_fluorescent [] = {
+ //ri guang deng
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x40,
+ 0xc8,0x42,
+ 0xc9,0x50,
+};
+
+uint8_t gc0307_wb_daylight [] = {
+ //tai yang guang
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x50,
+ 0xc8,0x45,
+ 0xc9,0x40,
+};
+
+uint8_t gc0307_wb_cloudy [] = {
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x5a,
+ 0xc8,0x42,
+ 0xc9,0x40,
+};
+
+
+// Exposure
+uint8_t gc0307_exposure_neg6[] = {
+ 0xf0,0x00,
+ 0x7a,0xd0,
+ 0xd1,0x38,
+};
+
+uint8_t gc0307_exposure_neg3[] = {
+ 0xf0,0x00,
+ 0x7a,0xe0,
+ 0xd1,0x48,
+};
+
+uint8_t gc0307_exposure_zero[] = {
+ 0xf0,0x00,
+ 0x7a,0x00,
+ 0xd1,0x50,
+};
+
+uint8_t gc0307_exposure_pos3[] = {
+ 0xf0,0x00,
+ 0x7a,0x20,
+ 0xd1,0x58,
+};
+
+uint8_t gc0307_exposure_pos6[] = {
+ 0xf0,0x00,
+ 0x7a,0x40,
+ 0xd1,0x68,
+};
+
+
+// Resolution
+uint8_t gc0307_320x240[]= {
+ 0x05,0x00,
+ 0x06,0x78,
+ 0x07,0x00,
+ 0x08,0xa0,
+ 0x09,0x00,
+ 0x0a,0xf8,
+ 0x0b,0x01,
+ 0x0c,0x48,
+ 0x45,0x24, // bit[7:2]=001001
+ 0x48,0x04, // bit[7]= 0
+ 0xe0,0x02,
+ 0xe1,0x01,
+ 0xe2,0x13,
+ 0xe3,0x0f,
+ 0xe8,0x1c,
+ 0xe9,0x35,
+ 0xea,0x17,
+ 0xeb,0x29,
+ 0xec,0x39,
+};
+
+uint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+
+ 0x0f, 0xa2,
+ 0x45, 0x26,
+ 0x47, 0x28,
+
+
+ 0x0f, 0x92,
+ 0x45, 0x25,
+ 0x47, 0x24,
+
+
+ 0x0f, 0x82,
+ 0x45, 0x24,
+ 0x47, 0x20,
+#endif
+
+
+
+ 0x43 ,0x40,
+ 0x44 ,0xE2,
+
+ 0xff,0xff,
+
+
+
+ 0x01 ,0xfa ,
+ 0x02 ,0x70,
+ 0x10 ,0x01 ,
+ 0xd6 ,0x64,
+ 0x28 ,0x02,
+ 0x29 ,0x58,
+ 0x2a ,0x03,
+ 0x2b ,0x20,
+ 0x2c ,0x03,
+ 0x2d ,0xe8 ,
+ 0x2e ,0x09,
+ 0x2f ,0xc4,
+
+ 0x7e ,0x65,
+ 0x7f ,0x56,
+
+};
+#endif
diff --git a/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.c b/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.c
new file mode 100755
index 00000000..7d46e1de
--- /dev/null
+++ b/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.c
@@ -0,0 +1,371 @@
+
+#include "../cmos-subdev.h"
+#include "../../wmt-vid.h"
+#include "gc0307.h"
+
+#define sensor_write_array(sd, arr, sz) \
+ cmos_init_8bit_addr(arr, sz, (sd)->i2c_addr)
+
+#define sensor_read(sd, reg) \
+ wmt_vid_i2c_read(sd->i2c_addr, reg)
+
+#define sensor_write(sd, reg, val) \
+ wmt_vid_i2c_write(sd->i2c_addr, reg, val)
+
+struct cmos_win_size {
+ char *name;
+ int width;
+ int height;
+ uint8_t *regs;
+ size_t size;
+};
+
+struct sensor_flip{
+ int h_flip;
+ int v_flip;
+ int cnt;
+}gc0307_flip;
+
+#define CMOS_WIN_SIZE(n, w, h, r) \
+ {.name = n, .width = w , .height = h, .regs = r, .size = ARRAY_SIZE(r) }
+
+
+static const struct cmos_win_size cmos_supported_win_sizes[] = {
+// CMOS_WIN_SIZE("QVGA", 320, 240, gc0307_320x240),
+ CMOS_WIN_SIZE("VGA", 640, 480, gc0307_640x480),
+};
+
+static const struct cmos_win_size *cmos_select_win(u32 *width, u32 *height)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(cmos_supported_win_sizes); i++) {
+ if (cmos_supported_win_sizes[i].width == *width &&
+ cmos_supported_win_sizes[i].height == *height) {
+ *width = cmos_supported_win_sizes[i].width;
+ *height = cmos_supported_win_sizes[i].height;
+ return &cmos_supported_win_sizes[i];
+ }
+ }
+ return NULL;
+}
+
+static int sensor_s_wb(struct cmos_subdev *sd, enum v4l2_wb_mode value)
+{
+ uint8_t *regs,data;
+
+ size_t size;
+
+ switch (value) {
+ case WHITE_BALANCE_AUTO:
+ sensor_write(sd, 0xf0, 0x00);
+ data = sensor_read(sd, 0x41);
+ data |=0x04;
+ sensor_write(sd, 0x41, data);
+ regs = gc0307_wb_auto;
+ size = ARRAY_SIZE(gc0307_wb_auto);
+ break;
+ case WHITE_BALANCE_INCANDESCENCE:
+ sensor_write(sd, 0xf0, 0x00);
+ data = sensor_read(sd, 0x41);
+ data &=0xfb;
+ sensor_write(sd, 0x41, data);
+ regs = gc0307_wb_incandescent;
+ size = ARRAY_SIZE(gc0307_wb_incandescent);
+ break;
+ case WHITE_BALANCE_DAYLIGHT:
+ sensor_write(sd, 0xf0, 0x00);
+ data = sensor_read(sd, 0x41);
+ data &=0xfb;
+ sensor_write(sd, 0x41, data);
+ regs = gc0307_wb_daylight;
+ size = ARRAY_SIZE(gc0307_wb_daylight);
+ break;
+ case WHITE_BALANCE_CLOUDY:
+ sensor_write(sd, 0xf0, 0x00);
+ data = sensor_read(sd, 0x41);
+ data &=0xfb;
+ sensor_write(sd, 0x41, data);
+ regs = gc0307_wb_cloudy;
+ size = ARRAY_SIZE(gc0307_wb_cloudy);
+ break;
+ case WHITE_BALANCE_FLUORESCENT:
+ sensor_write(sd, 0xf0, 0x00);
+ data = sensor_read(sd, 0x41);
+ data &=0xfb;
+ sensor_write(sd, 0x41, data);
+ regs = gc0307_wb_fluorescent;
+ size = ARRAY_SIZE(gc0307_wb_fluorescent);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ sensor_write_array(sd, regs, size);
+ mdelay(80);
+ return 0;
+}
+
+static int sensor_s_scenemode(struct cmos_subdev *sd, enum v4l2_scene_mode value)
+{
+ uint8_t *regs;
+ size_t size;
+
+ switch (value) {
+ case SCENE_MODE_AUTO:
+ regs = gc0307_scene_mode_auto;
+ size = ARRAY_SIZE(gc0307_scene_mode_auto);
+ break;
+ case SCENE_MODE_NIGHTSHOT:
+ regs = gc0307_scene_mode_night;
+ size = ARRAY_SIZE(gc0307_scene_mode_night);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ sensor_write_array(sd, regs, size);
+ return 0;
+}
+
+static int sensor_s_exposure(struct cmos_subdev *sd, int value)
+{
+ uint8_t *regs;
+ size_t size;
+
+ switch (value) {
+ case -2:
+ regs = gc0307_exposure_neg6;
+ size = ARRAY_SIZE(gc0307_exposure_neg6);
+ break;
+ case -1:
+ regs = gc0307_exposure_neg3;
+ size = ARRAY_SIZE(gc0307_exposure_neg3);
+ break;
+ case 0:
+ regs = gc0307_exposure_zero;
+ size = ARRAY_SIZE(gc0307_exposure_zero);
+ break;
+ case 1:
+ regs = gc0307_exposure_pos3;
+ size = ARRAY_SIZE(gc0307_exposure_pos3);
+ break;
+ case 2:
+ regs = gc0307_exposure_pos6;
+ size = ARRAY_SIZE(gc0307_exposure_pos6);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ sensor_write_array(sd, regs, size);
+ return 0;
+}
+
+static int sensor_do_flip(struct cmos_subdev *sd)
+{
+ if ((gc0307_flip.h_flip == 0) &&(gc0307_flip.v_flip == 0)){
+ sensor_write( sd, 0x0f, 0xb2);
+ sensor_write( sd, 0x45, 0x27);
+ sensor_write( sd, 0x47, 0x2c);
+ }else if ((gc0307_flip.h_flip == 0) &&(gc0307_flip.v_flip == 1)){
+ sensor_write( sd, 0x0f, 0xa2);
+ sensor_write( sd, 0x45, 0x26);
+ sensor_write( sd, 0x47, 0x28);
+ }else if ((gc0307_flip.h_flip == 1) &&(gc0307_flip.v_flip == 0)){
+ sensor_write( sd, 0x0f, 0x92);
+ sensor_write( sd, 0x45, 0x25);
+ sensor_write( sd, 0x47, 0x24);
+ }else if ((gc0307_flip.h_flip == 1) &&(gc0307_flip.v_flip == 1)){
+ sensor_write( sd, 0x0f, 0x82);
+ sensor_write( sd, 0x45, 0x24);
+ sensor_write( sd, 0x47, 0x20);
+ }
+
+ msleep(100);
+ return 0;
+}
+
+
+static int sensor_s_hflip(struct cmos_subdev *sd, int value)
+{
+ gc0307_flip.cnt ++;
+
+ switch (value) {
+ case 0:
+ gc0307_flip.h_flip=0;
+ break;
+ case 1:
+ gc0307_flip.h_flip=1;
+ break;
+ default:
+ return -EINVAL;
+ }
+ if(gc0307_flip.cnt==2)
+ sensor_do_flip(sd);
+
+ return 0;
+}
+
+static int sensor_s_vflip(struct cmos_subdev *sd, int value)
+{
+ gc0307_flip.cnt ++;
+
+ switch (value) {
+ case 0:
+ gc0307_flip.v_flip=0;
+ break;
+ case 1:
+ gc0307_flip.v_flip=1;
+ break;
+ default:
+ return -EINVAL;
+ }
+ if(gc0307_flip.cnt==2)
+ sensor_do_flip(sd);
+
+ return 0;
+}
+
+static int sensor_queryctrl(struct cmos_subdev *sd, struct v4l2_queryctrl *qc)
+{
+ switch (qc->id) {
+ case V4L2_CID_VFLIP:
+ case V4L2_CID_HFLIP:
+ return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0);
+ case V4L2_CID_CAMERA_SCENE_MODE:
+ return v4l2_ctrl_query_fill(qc, 0, 1, 1, 0);
+ case V4L2_CID_DO_WHITE_BALANCE:
+ return v4l2_ctrl_query_fill(qc, 0, 3, 1, 0);
+ case V4L2_CID_EXPOSURE:
+ return v4l2_ctrl_query_fill(qc, -2, 2, 1, 0);
+ }
+ return -EINVAL;
+}
+
+static int sensor_s_ctrl(struct cmos_subdev *sd, struct v4l2_control *ctrl)
+{
+ switch (ctrl->id) {
+ case V4L2_CID_CAMERA_SCENE_MODE:
+ return sensor_s_scenemode(sd, ctrl->value);
+ case V4L2_CID_DO_WHITE_BALANCE:
+ return sensor_s_wb(sd, ctrl->value);
+ case V4L2_CID_EXPOSURE:
+ return sensor_s_exposure(sd, ctrl->value);
+ case V4L2_CID_HFLIP:
+ return sensor_s_hflip(sd, ctrl->value);
+ case V4L2_CID_VFLIP:
+ return sensor_s_vflip(sd, ctrl->value);
+ default:
+ case WMT_V4L2_CID_CAMERA_ANTIBANDING:
+ return -EINVAL;
+ }
+ return -EINVAL;
+}
+
+static int sensor_g_mbus_fmt(struct cmos_subdev *sd,
+ struct v4l2_mbus_framefmt *mf)
+{
+ return -EINVAL;
+}
+
+static int sensor_s_mbus_fmt(struct cmos_subdev *sd,
+ struct v4l2_mbus_framefmt *mf)
+{
+ const struct cmos_win_size *win;
+
+ win = cmos_select_win(&mf->width, &mf->height);
+ if (!win) {
+ pr_err("%s, s_mbus_fmt failed, width %d, height %d\n",
+ sd->name, mf->width, mf->height);
+ return -EINVAL;
+ }
+
+ sensor_write_array(sd, win->regs, win->size);
+ return 0;
+}
+
+static int sensor_try_mbus_fmt(struct cmos_subdev *sd,
+ struct v4l2_mbus_framefmt *mf)
+{
+ return 0;
+}
+
+static int sensor_enum_framesizes(struct cmos_subdev *sd,
+ struct v4l2_frmsizeenum *fsize)
+{
+ int i;
+ int num_valid = -1;
+ __u32 index = fsize->index;
+
+ for (i = 0; i < ARRAY_SIZE(cmos_supported_win_sizes); i++) {
+ const struct cmos_win_size *win = &cmos_supported_win_sizes[index];
+ if (index == ++num_valid) {
+ fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+ fsize->discrete.width = win->width;
+ fsize->discrete.height = win->height;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
+static int sensor_identify(struct cmos_subdev *sd)
+{
+ return (sensor_read(sd, 0) == sd->id) ? 0 : -EINVAL;
+}
+
+static int sensor_init(struct cmos_subdev *sd)
+{
+ if (sensor_identify(sd)) {
+ return -1;
+ }
+ gc0307_flip.cnt=0;
+ sensor_write_array(sd, gc0307_default_regs_init,
+ ARRAY_SIZE(gc0307_default_regs_init));
+ return 0;
+}
+
+static int sensor_exit(struct cmos_subdev *sd)
+{
+ return 0;
+}
+
+static struct cmos_subdev_ops gc0307_ops = {
+ .identify = sensor_identify,
+ .init = sensor_init,
+ .exit = sensor_exit,
+ .queryctrl = sensor_queryctrl,
+ .s_ctrl = sensor_s_ctrl,
+ .s_mbus_fmt = sensor_s_mbus_fmt,
+ .g_mbus_fmt = sensor_g_mbus_fmt,
+ .try_mbus_fmt = sensor_try_mbus_fmt,
+ .enum_framesizes = sensor_enum_framesizes,
+};
+
+struct cmos_subdev gc0307 = {
+ .name = "gc0307",
+ .i2c_addr = 0x21,
+ .id = 0x99,
+ .max_width = 640,
+ .max_height = 480,
+ .ops = &gc0307_ops,
+};
+
+#if 0
+static int __init gc0307_init(void)
+{
+ return cmos_register_sudbdev(&gc0307);
+}
+
+static void __exit gc0307_exit(void)
+{
+ return cmos_unregister_subdev(&gc0307);
+}
+
+module_init(gc0307_init);
+module_exit(gc0307_exit);
+
+MODULE_LICENSE("GPL");
+#endif
diff --git a/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.h b/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.h
new file mode 100755
index 00000000..9c58f202
--- /dev/null
+++ b/drivers/media/video/wmt_v4l2/sensors/gc0307/gc0307.h
@@ -0,0 +1,567 @@
+#ifndef GC0307_H
+#define GC0307_H
+
+
+// Scene Mode
+uint8_t gc0307_scene_mode_auto[] = {
+
+};
+
+uint8_t gc0307_scene_mode_night[] = {
+
+};
+
+
+// White Balance
+uint8_t gc0307_wb_auto [] = {
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x4c,
+ 0xc8,0x40,
+ 0xc9,0x4a,
+};
+
+uint8_t gc0307_wb_incandescent [] = {
+ //bai re guang
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x48,
+ 0xc8,0x40,
+ 0xc9,0x5c,
+};
+
+uint8_t gc0307_wb_fluorescent [] = {
+ //ri guang deng
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x40,
+ 0xc8,0x42,
+ 0xc9,0x50,
+};
+
+uint8_t gc0307_wb_daylight [] = {
+ //tai yang guang
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x50,
+ 0xc8,0x45,
+ 0xc9,0x40,
+};
+
+uint8_t gc0307_wb_cloudy [] = {
+ 0xf0,0x00,
+// 0x41,0x2b,
+ 0xc7,0x5a,
+ 0xc8,0x42,
+ 0xc9,0x40,
+};
+
+
+// Exposure
+uint8_t gc0307_exposure_neg6[] = {
+ 0xf0,0x00,
+ 0x7a,0xd0,
+ 0xd1,0x38,
+};
+
+uint8_t gc0307_exposure_neg3[] = {
+ 0xf0,0x00,
+ 0x7a,0xe0,
+ 0xd1,0x48,
+};
+
+uint8_t gc0307_exposure_zero[] = {
+ 0xf0,0x00,
+ 0x7a,0x00,
+ 0xd1,0x50,
+};
+
+uint8_t gc0307_exposure_pos3[] = {
+ 0xf0,0x00,
+ 0x7a,0x20,
+ 0xd1,0x58,
+};
+
+uint8_t gc0307_exposure_pos6[] = {
+ 0xf0,0x00,
+ 0x7a,0x40,
+ 0xd1,0x68,
+};
+
+
+// Resolution
+uint8_t gc0307_320x240[]= {
+ 0x05,0x00,
+ 0x06,0x78,
+ 0x07,0x00,
+ 0x08,0xa0,
+ 0x09,0x00,
+ 0x0a,0xf8,
+ 0x0b,0x01,
+ 0x0c,0x48,
+ 0x45,0x24, // bit[7:2]=001001
+ 0x48,0x04, // bit[7]= 0
+ 0xe0,0x02,
+ 0xe1,0x01,
+ 0xe2,0x13,
+ 0xe3,0x0f,
+ 0xe8,0x1c,
+ 0xe9,0x35,
+ 0xea,0x17,
+ 0xeb,0x29,
+ 0xec,0x39,
+};
+
+uint8_t gc0307_640x480[] = {
+#if 0
+ 0x05,0x00,
+ 0x06,0x00,
+ 0x07,0x00,
+ 0x08,0x00,
+ 0x09,0x01,
+ 0x0a,0xe8,
+ 0x0b,0x02,
+ 0x0c,0x80,
+ 0x45,0x26, // bit[7:2]=001001
+ 0x48,0x84, // bit[7]=1
+ 0xe0,0x03,
+ 0xe1,0x02,
+ 0xe2,0x27,
+ 0xe3,0x1e,
+ 0xe8,0x3b,
+ 0xe9,0x6e,
+ 0xea,0x2c,
+ 0xeb,0x50,
+ 0xec,0x73,
+#endif
+};
+
+uint8_t gc0307_default_regs_init[] = {
+
+ // Initail Sequence Write In.
+ //========= close output
+ 0x43,0x00,
+ 0x44,0xa2,
+
+ //========= close some functions
+ // open them after configure their parmameters
+ 0x40,0x10,
+ 0x41,0x00,
+ 0x42,0x10,
+ 0x47,0x00,//mode1,
+ 0x48,0xc1,//mode2,
+ 0x49,0x00,//dither_mode
+ 0x4a,0x00,//clock_gating_en
+ 0x4b,0x00,//mode_reg3
+ 0x4E,0x23,//sync mode
+ 0x4F,0x01,//AWB, AEC, every N frame
+
+ //========= frame timing
+ 0x01,0x6a,//HB
+ 0x02,0x70,//VB//0c
+ 0x1C,0x00,//Vs_st
+ 0x1D,0x00,//Vs_et
+ 0x10,0x00,//high 4 bits of VB, HB
+ 0x11,0x05,//row_tail, AD_pipe_number
+
+ 0x03,0x01,//row_start
+ 0x04,0x2c,
+
+ //========= windowing
+ 0x05,0x00,//row_start
+ 0x06,0x00,
+ 0x07,0x00,//col start
+ 0x08,0x00,
+ 0x09,0x01,//win height
+ 0x0A,0xE8,
+ 0x0B,0x02,//win width, pixel array only 640
+ 0x0C,0x80,
+
+ //========= analog
+ 0x0D,0x22,//rsh_width
+ 0x0E,0x02,//CISCTL mode2,
+ 0x0F,0xb2,//CISCTL mode1
+
+
+ 0x12,0x70,//7 hrst, 6_4 darsg,
+ 0x13,0x00,//7 CISCTL_restart, 0 apwd
+ 0x14,0x00,//NA
+ 0x15,0xba,//7_4 vref
+ 0x16,0x13,//5to4 _coln_r, __1to0__da18
+ 0x17,0x52,//opa_r, ref_r, sRef_r
+ //0x18,0xc0,//analog_mode, best case for left band.
+ 0x18,0x00,
+
+ 0x1E,0x0d,//tsp_width
+ 0x1F,0x32,//sh_delay
+
+ //========= offset
+ 0x47,0x00, //7__test_image, __6__fixed_pga, //__5__auto_DN,__4__CbCr_fix,
+ //__3to2__dark_sequence, __1__allow_pclk_vcync, __0__LSC_test_image
+ 0x19,0x06, //pga_o
+ 0x1a,0x06, //pga_e
+
+ 0x31,0x00, //4 //pga_oFFset , high 8bits of 11bits
+ 0x3B,0x00, //global_oFFset, low 8bits of 11bits
+
+ 0x59,0x0f, //offset_mode
+ 0x58,0x88, //DARK_VALUE_RATIO_G, DARK_VALUE_RATIO_RB
+ 0x57,0x08, //DARK_CURRENT_RATE
+ 0x56,0x77, //PGA_OFFSET_EVEN_RATIO, PGA_OFFSET_ODD_RATIO
+
+ //========= blk
+ 0x35,0xd8, //blk_mode
+
+ 0x36,0x40,
+
+ 0x3C,0x00,
+ 0x3D,0x00,
+ 0x3E,0x00,
+ 0x3F,0x00,
+
+ 0xb5,0x70,
+ 0xb6,0x40,
+ 0xb7,0x00,
+ 0xb8,0x38,
+ 0xb9,0xc3,
+ 0xba,0x0f,
+
+ 0x7e,0x45,
+ 0x7f,0x66,
+
+ 0x5c,0x48,//78
+ 0x5d,0x58,//88
+
+
+ //========= manual_gain
+ 0x61,0x80,//manual_gain_g1
+ 0x63,0x80,//manual_gain_r
+ 0x65,0x98,//manual_gai_b, 0xa0=1.25, 0x98=1.1875
+ 0x67,0x80,//manual_gain_g2
+ 0x68,0x18,//global_manual_gain 2.4bits
+
+ //=========CC _R
+ 0x69,0x58, //54//58
+ 0x6A,0xf6, //ff
+ 0x6B,0xfb, //fe
+ 0x6C,0xf4, //ff
+ 0x6D,0x5a, //5f
+ 0x6E,0xe6, //e1
+
+ 0x6f,0x00,
+
+ //=========lsc
+ 0x70,0x14,
+ 0x71,0x1c,
+ 0x72,0x20,
+
+ 0x73,0x10,
+ 0x74,0x3c,//480/8
+ 0x75,0x52,// 640/8
+
+ //=========dn
+ 0x7d,0x2f, //dn_mode
+ 0x80,0x0c,//when auto_dn, check 7e,7f
+ 0x81,0x0c,
+ 0x82,0x44,
+
+ //dd
+ 0x83,0x18, //DD_TH1
+ 0x84,0x18, //DD_TH2
+ 0x85,0x04, //DD_TH3
+ 0x87,0x34, //32 b DNDD_low_range X16, DNDD_low_range_C_weight_center
+
+
+ //=========intp-ee
+ 0x88,0x04,
+ 0x89,0x01,
+ 0x8a,0x50,//60
+ 0x8b,0x50,//60
+ 0x8c,0x07,
+
+ 0x50,0x0c,
+ 0x5f,0x3c,
+
+ 0x8e,0x02,
+ 0x86,0x02,
+
+ 0x51,0x20,
+ 0x52,0x08,
+ 0x53,0x00,
+
+
+ //========= YCP
+ //contrast_center
+ 0x77,0x80,//contrast_center
+ 0x78,0x00,//fixed_Cb
+ 0x79,0x00,//fixed_Cr
+ 0x7a,0x00,//luma_offset
+ 0x7b,0x40,//hue_cos
+ 0x7c,0x00,//hue_sin
+
+ //saturation
+ 0xa0,0x40,//global_saturation
+ 0xa1,0x40,//luma_contrast
+ 0xa2,0x34,//saturation_Cb//0x34
+ 0xa3,0x32,// 34 saturation_Cr//0x34
+
+ 0xa4,0xc8,
+ 0xa5,0x02,
+ 0xa6,0x28,
+ 0xa7,0x02,
+
+ //skin
+ 0xa8,0xee,
+ 0xa9,0x12,
+ 0xaa,0x01,
+ 0xab,0x20,
+ 0xac,0xf0,
+ 0xad,0x10,
+
+ //========= ABS
+ 0xae,0x18,// black_pixel_target_number
+ 0xaf,0x74,
+ 0xb0,0xe0,
+ 0xb1,0x20,
+ 0xb2,0x6c,
+ 0xb3,0x40,
+ 0xb4,0x04,
+
+ //========= AWB
+ 0xbb,0x42,
+ 0xbc,0x60,
+ 0xbd,0x50,
+ 0xbe,0x50,
+
+ 0xbf,0x0c,
+ 0xc0,0x06,
+ 0xc1,0x60,
+ 0xc2,0xf1, //f4
+ 0xc3,0x40,
+ 0xc4,0x1c,//18
+ 0xc5,0x56,
+ 0xc6,0x1d,
+
+ 0xca,0x70,//0x70
+ 0xcb,0x70,//0x70
+ 0xcc,0x78,//0x78
+
+ 0xcd,0x80,//R_ratio
+ 0xce,0x80,//G_ratio , cold_white white
+ 0xcf,0x80,//B_ratio
+
+ //========= aecT
+ 0x20,0x06,//02
+ 0x21,0xc0,
+ 0x22,0x40,
+ 0x23,0x88,
+ 0x24,0x96,
+ 0x25,0x30,
+ 0x26,0xd0,
+ 0x27,0x00,
+
+
+ /////23 M
+ 0x28,0x02,//AEC_exp_level_1bit11to8
+ 0x29,0x58,//AEC_exp_level_1bit7to0
+ 0x2a,0x02,//AEC_exp_level_2bit11to8
+ 0x2b,0x58,//AEC_exp_level_2bit7to0
+ 0x2c,0x02,//AEC_exp_level_3bit11to8 659 - 8FPS, 8ca - 6FPS //
+ 0x2d,0x58,//AEC_exp_level_3bit7to0
+ 0x2e,0x02,//AEC_exp_level_4bit11to8 4FPS
+ 0x2f,0xee,//AEC_exp_level_4bit7to0
+
+ 0x30,0x20,
+ 0x31,0x00,
+ 0x32,0x1c,
+ 0x33,0x90,
+ 0x34,0x10,
+
+ 0xd0,0x34,//[2] 1 before gamma, 0 after gamma
+
+ 0xd1,0x50,//AEC_target_Y//0x50
+ 0xd2,0x61,//f2
+ 0xd4,0x4b,//96
+ 0xd5,0x01,// 10
+ 0xd6,0x4b,//antiflicker_step //96
+ 0xd7,0x03,//AEC_exp_time_min //10
+ 0xd8,0x02,
+
+ 0xdd,0x12,
+
+ //========= measure window
+ 0xe0,0x03,
+ 0xe1,0x02,
+ 0xe2,0x27,
+ 0xe3,0x1e,
+ 0xe8,0x3b,
+ 0xe9,0x6e,
+ 0xea,0x2c,
+ 0xeb,0x50,
+ 0xec,0x73,
+
+ //========= close_frame
+ 0xed,0x00,//close_frame_num1 ,can be use to reduce FPS
+ 0xee,0x00,//close_frame_num2
+ 0xef,0x00,//close_frame_num
+
+ // page1
+ 0xf0,0x01,//select page1
+
+ 0x00,0x20,
+ 0x01,0x20,
+ 0x02,0x20,
+ 0x03,0x20,
+ 0x04,0x78,
+ 0x05,0x78,
+ 0x06,0x78,
+ 0x07,0x78,
+
+
+
+ 0x10,0x04,
+ 0x11,0x04,
+ 0x12,0x04,
+ 0x13,0x04,
+ 0x14,0x01,
+ 0x15,0x01,
+ 0x16,0x01,
+ 0x17,0x01,
+
+
+ 0x20,0x00,
+ 0x21,0x00,
+ 0x22,0x00,
+ 0x23,0x00,
+ 0x24,0x00,
+ 0x25,0x00,
+ 0x26,0x00,
+ 0x27,0x00,
+
+ 0x40,0x11,
+
+ //=============================lscP
+ 0x45,0x06,
+ 0x46,0x06,
+ 0x47,0x05,
+
+ 0x48,0x04,
+ 0x49,0x03,
+ 0x4a,0x03,
+
+
+ 0x62,0xd8,
+ 0x63,0x24,
+ 0x64,0x24,
+ 0x65,0x24,
+ 0x66,0xd8,
+ 0x67,0x24,
+
+ 0x5a,0x00,
+ 0x5b,0x00,
+ 0x5c,0x00,
+ 0x5d,0x00,
+ 0x5e,0x00,
+ 0x5f,0x00,
+
+
+ //============================= ccP
+
+ 0x69,0x03,//cc_mode
+
+ //CC_G
+ 0x70,0x5d,
+ 0x71,0xed,
+ 0x72,0xff,
+ 0x73,0xe5,
+ 0x74,0x5f,
+ 0x75,0xe6,
+
+ //CC_B
+ 0x76,0x41,
+ 0x77,0xef,
+ 0x78,0xff,
+ 0x79,0xff,
+ 0x7a,0x5f,
+ 0x7b,0xfa,
+
+
+ //============================= AGP
+
+ 0x7e,0x00,
+ 0x7f,0x30, // 00 select gamma
+ 0x80,0x48, // c8
+ 0x81,0x06,
+ 0x82,0x08,
+
+
+ 0x83,0x23,
+ 0x84,0x38,
+ 0x85,0x4F,
+ 0x86,0x61,
+ 0x87,0x72,
+ 0x88,0x80,
+ 0x89,0x8D,
+ 0x8a,0xA2,
+ 0x8b,0xB2,
+ 0x8c,0xC0,
+ 0x8d,0xCA,
+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