#include "sys_config.h" #include "typesdef.h" #include "lib/video/dvp/cmos_sensor/csi.h" #include "tx_platform.h" #include "list.h" #include "dev.h" #include "hal/isp.h" #if DEV_SENSOR_SC1346 /* lens & sensor config information: - sensor : gc1346 - fstop : TBD - mclk : 24MHz - max FPS : 25fps - frame length: 1500 - usage : TDB - interface : DVP */ SENSOR_INIT_SECTION const unsigned char sc1346InitTable[CMOS_INIT_LEN]= { #if 0 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0x36, 0xe9, 0x80, 0x37, 0xf9, 0x80, 0x30, 0x01, 0xff, 0x30, 0x02, 0xf0, 0x30, 0x0a, 0x24, 0x30, 0x18, 0x0f, 0x30, 0x1a, 0xf8, 0x30, 0x1c, 0x94, 0x30, 0x1f, 0x1f, 0x30, 0x30, 0x01, 0x30, 0x3f, 0x81, 0x31, 0x06, 0x05, 0x32, 0x00, 0x00, 0x32, 0x01, 0x00, 0x32, 0x02, 0x00, 0x32, 0x03, 0x00, 0x32, 0x04, 0x05, 0x32, 0x05, 0x07, 0x32, 0x06, 0x02, 0x32, 0x07, 0xdb, 0x32, 0x08, 0x05, 0x32, 0x09, 0x00, 0x32, 0x0a, 0x02, 0x32, 0x0b, 0xd0, 0x32, 0x0c, 0x07, 0x32, 0x0d, 0x80, 0x32, 0x0e, 0x02, 0x32, 0x0f, 0xee, 0x32, 0x10, 0x00, 0x32, 0x11, 0x04, 0x32, 0x12, 0x00, 0x32, 0x13, 0x04, 0x32, 0x50, 0x40, 0x33, 0x01, 0x06, 0x33, 0x06, 0x50, 0x33, 0x08, 0x0a, 0x33, 0x0a, 0x00, 0x33, 0x0b, 0xda, 0x33, 0x0e, 0x0a, 0x33, 0x1e, 0x61, 0x33, 0x1f, 0xa1, 0x33, 0x64, 0x1f, 0x33, 0x90, 0x09, 0x33, 0x91, 0x0f, 0x33, 0x92, 0x1f, 0x33, 0x93, 0x30, 0x33, 0x94, 0x30, 0x33, 0x95, 0x30, 0x33, 0xad, 0x10, 0x33, 0xb3, 0x40, 0x33, 0xf9, 0x50, 0x33, 0xfb, 0x80, 0x33, 0xfc, 0x09, 0x33, 0xfd, 0x0f, 0x34, 0x9f, 0x03, 0x34, 0xa6, 0x09, 0x34, 0xa7, 0x0f, 0x34, 0xa8, 0x40, 0x34, 0xa9, 0x30, 0x34, 0xaa, 0x00, 0x34, 0xab, 0xe8, 0x34, 0xac, 0x01, 0x34, 0xad, 0x0c, 0x36, 0x30, 0xe2, 0x36, 0x32, 0x76, 0x36, 0x33, 0x33, 0x36, 0x39, 0xf4, 0x36, 0x41, 0x01, 0x36, 0x70, 0x09, 0x36, 0x74, 0xe2, 0x36, 0x75, 0xea, 0x36, 0x76, 0xea, 0x36, 0x7c, 0x09, 0x36, 0x7d, 0x0f, 0x36, 0x90, 0x22, 0x36, 0x91, 0x22, 0x36, 0x92, 0x22, 0x36, 0x98, 0x88, 0x36, 0x99, 0x90, 0x36, 0x9a, 0xa1, 0x36, 0x9b, 0xc3, 0x36, 0x9c, 0x09, 0x36, 0x9d, 0x0f, 0x36, 0xa2, 0x09, 0x36, 0xa3, 0x0b, 0x36, 0xa4, 0x0f, 0x36, 0xd0, 0x01, 0x36, 0xea, 0x1b, 0x36, 0xeb, 0x0d, 0x36, 0xec, 0x15, 0x36, 0xed, 0x28, 0x37, 0x0f, 0x01, 0x37, 0x22, 0x41, 0x37, 0x24, 0x41, 0x37, 0x25, 0xc1, 0x37, 0x28, 0x00, 0x37, 0xb0, 0x41, 0x37, 0xb1, 0x41, 0x37, 0xb2, 0x47, 0x37, 0xb3, 0x09, 0x30, 0x00, 0xff, 0x37, 0xb4, 0x0f, 0x37, 0xfa, 0x06, 0x37, 0xfb, 0x33, 0x37, 0xfc, 0x11, 0x37, 0xfd, 0x17, 0x39, 0x03, 0x40, 0x39, 0x04, 0x04, 0x39, 0x05, 0x8d, 0x39, 0x07, 0x00, 0x39, 0x08, 0x41, 0x39, 0x1f, 0x41, 0x39, 0x33, 0x80, 0x39, 0x34, 0x02, 0x39, 0x37, 0x74, 0x39, 0x39, 0x0f, 0x39, 0x3a, 0xd4, 0x3e, 0x01, 0x2e, 0x3e, 0x02, 0x80, 0x44, 0x0e, 0x02, 0x45, 0x09, 0x20, 0x45, 0x0d, 0x28, 0x46, 0x03, 0x01, 0x48, 0x00, 0x44, 0x48, 0x19, 0x06, 0x48, 0x1b, 0x03, 0x48, 0x1d, 0x0b, 0x48, 0x1f, 0x03, 0x48, 0x21, 0x08, 0x48, 0x23, 0x03, 0x48, 0x25, 0x03, 0x48, 0x27, 0x03, 0x48, 0x29, 0x05, 0x57, 0x80, 0x66, 0x57, 0x8d, 0x40, 0x32, 0x0e, 0x05, 0x32, 0x0f, 0xdc, 0x3e, 0x01, 0x05, 0x3e, 0x02, 0xd6, //master 0x30, 0x0a, 0x24, 0x30, 0x32, 0xa0, 0x36, 0xe9, 0x28, 0x37, 0xf9, 0x04, 0x01, 0x00, 0x01, 0xff, 0xff, 0xff, #elif 0 0x01,0x03,0x01, 0x01,0x00,0x00, 0x36,0xe9,0x80, 0x37,0xf9,0x80, 0x30,0x01,0xff, 0x30,0x02,0xf0, 0x30,0x0a,0x24, 0x30,0x18,0x0f, 0x30,0x1a,0xf8, 0x30,0x1c,0x94, 0x30,0x1f,0x1f, 0x30,0x30,0x01, 0x30,0x3f,0x81, 0x31,0x06,0x05, 0x32,0x00,0x00, 0x32,0x01,0x00, 0x32,0x02,0x00, 0x32,0x03,0x00, 0x32,0x04,0x05, 0x32,0x05,0x07, 0x32,0x06,0x02, 0x32,0x07,0xdb, 0x32,0x08,0x05, 0x32,0x09,0x00, 0x32,0x0a,0x02, 0x32,0x0b,0xd0, 0x32,0x0c,0x09, 0x32,0x0d,0x80, 0x32,0x0e,0x02, 0x32,0x0f,0xee, 0x32,0x10,0x00, 0x32,0x11,0x04, 0x32,0x12,0x00, 0x32,0x13,0x04, 0x32,0x50,0x40, 0x33,0x01,0x06, 0x33,0x06,0x50, 0x33,0x08,0x0a, 0x33,0x0a,0x00, 0x33,0x0b,0xda, 0x33,0x0e,0x0a, 0x33,0x1e,0x61, 0x33,0x1f,0xa1, 0x33,0x64,0x1f, 0x33,0x90,0x09, 0x33,0x91,0x0f, 0x33,0x92,0x1f, 0x33,0x93,0x30, 0x33,0x94,0x30, 0x33,0x95,0x30, 0x33,0xad,0x10, 0x33,0xb3,0x40, 0x33,0xf9,0x50, 0x33,0xfb,0x80, 0x33,0xfc,0x09, 0x33,0xfd,0x0f, 0x34,0x9f,0x03, 0x34,0xa6,0x09, 0x34,0xa7,0x0f, 0x34,0xa8,0x40, 0x34,0xa9,0x30, 0x34,0xaa,0x00, 0x34,0xab,0xe8, 0x34,0xac,0x01, 0x34,0xad,0x0c, 0x36,0x30,0xe2, 0x36,0x32,0x76, 0x36,0x33,0x33, 0x36,0x39,0xf4, 0x36,0x41,0x03, 0x36,0x70,0x09, 0x36,0x74,0xe2, 0x36,0x75,0xea, 0x36,0x76,0xea, 0x36,0x7c,0x09, 0x36,0x7d,0x0f, 0x36,0x90,0x22, 0x36,0x91,0x22, 0x36,0x92,0x22, 0x36,0x98,0x88, 0x36,0x99,0x90, 0x36,0x9a,0xa1, 0x36,0x9b,0xc3, 0x36,0x9c,0x09, 0x36,0x9d,0x0f, 0x36,0xa2,0x09, 0x36,0xa3,0x0b, 0x36,0xa4,0x0f, 0x36,0xd0,0x01, 0x36,0xea,0x1b, 0x36,0xeb,0x0d, 0x36,0xec,0x15, 0x36,0xed,0x28, 0x37,0x0f,0x01, 0x37,0x22,0x41, 0x37,0x24,0x41, 0x37,0x25,0xc1, 0x37,0x28,0x00, 0x37,0xb0,0x41, 0x37,0xb1,0x41, 0x37,0xb2,0x47, 0x37,0xb3,0x09, 0x30,0x00,0xff, 0x37,0xb4,0x0f, 0x37,0xfa,0x06, 0x37,0xfb,0x33, 0x37,0xfc,0x11, 0x37,0xfd,0x17, 0x39,0x03,0x40, 0x39,0x04,0x04, 0x39,0x05,0x8d, 0x39,0x07,0x00, 0x39,0x08,0x41, 0x39,0x1f,0x41, 0x39,0x33,0x80, 0x39,0x34,0x02, 0x39,0x37,0x74, 0x39,0x39,0x0f, 0x39,0x3a,0xd4, 0x3e,0x01,0x2e, 0x3e,0x02,0x80, 0x44,0x0e,0x02, 0x45,0x09,0x20, 0x45,0x0d,0x28, 0x46,0x03,0x01, 0x48,0x00,0x44, 0x48,0x19,0x06, 0x48,0x1b,0x03, 0x48,0x1d,0x0b, 0x48,0x1f,0x03, 0x48,0x21,0x08, 0x48,0x23,0x03, 0x48,0x25,0x03, 0x48,0x27,0x03, 0x48,0x29,0x05, 0x57,0x80,0x66, 0x57,0x8d,0x40, 0x32,0x0e,0x04, 0x32,0x0f,0x90, 0x3e,0x01,0x4d, 0x3e,0x02,0xc0, 0x32,0x0e,0x03, 0x32,0x0f,0x70, 0x3e,0x01,0x36, 0x3e,0x02,0x80, 0x32,0x0c,0x0c, 0x32,0x0d,0xb9, //0x32,0x0c,0x0c, //0x32,0x0d,0xc9, 0x32,0x2e,0x03, 0x32,0x2f,0x60, //ma,0xster 0x30,0x0a,0x24, 0x30,0x32,0xa0, 0x36,0xe9,0x28, 0x37,0xf9,0x04, 0x01,0x00,0x01, 0xff,0xff, 0xff, #endif //12.5 fps 0x01, 0x03, 0x01, 0x01, 0x00, 0x00, 0x36, 0xe9, 0x80, 0x37, 0xf9, 0x80, 0x30, 0x1f, 0x03, 0x31, 0x06, 0x05, // 0x32, 0x0e, 0x03,//800 // 0x32, 0x0f, 0x84, 0x32, 0x0e, 0x07,//1944 0x32, 0x0f, 0x98, 0x32, 0x21, 0x66, 0x32, 0x50, 0x40, 0x33, 0x01, 0x06, 0x33, 0x06, 0x50, 0x33, 0x08, 0x0a, 0x33, 0x0a, 0x00, 0x33, 0x0b, 0xda, 0x33, 0x0e, 0x0a, 0x33, 0x1e, 0x61, 0x33, 0x1f, 0xa1, 0x33, 0x64, 0x1f, 0x33, 0x90, 0x09, 0x33, 0x91, 0x0f, 0x33, 0x92, 0x1f, 0x33, 0x93, 0x30, 0x33, 0x94, 0x30, 0x33, 0x95, 0x30, 0x33, 0xad, 0x10, 0x33, 0xb3, 0x40, 0x33, 0xf9, 0x50, 0x33, 0xfb, 0x70, 0x33, 0xfc, 0x09, 0x33, 0xfd, 0x0f, 0x34, 0x9f, 0x03, 0x34, 0xa6, 0x09, 0x34, 0xa7, 0x0f, 0x34, 0xa8, 0x40, 0x34, 0xa9, 0x30, 0x34, 0xaa, 0x00, 0x34, 0xab, 0xe8, 0x34, 0xac, 0x00, 0x34, 0xad, 0xfc, 0x36, 0x30, 0xe2, 0x36, 0x32, 0x76, 0x36, 0x33, 0x33, 0x36, 0x39, 0xf4, 0x36, 0x70, 0x09, 0x36, 0x74, 0xe2, 0x36, 0x75, 0xea, 0x36, 0x76, 0xea, 0x36, 0x7c, 0x09, 0x36, 0x7d, 0x0f, 0x36, 0x90, 0x22, 0x36, 0x91, 0x22, 0x36, 0x92, 0x22, 0x36, 0x98, 0x88, 0x36, 0x99, 0x90, 0x36, 0x9a, 0xa1, 0x36, 0x9b, 0xc3, 0x36, 0x9c, 0x09, 0x36, 0x9d, 0x0f, 0x36, 0xa2, 0x09, 0x36, 0xa3, 0x0b, 0x36, 0xa4, 0x0f, 0x36, 0xd0, 0x01, 0x36, 0xea, 0x1b, 0x36, 0xeb, 0x0d, 0x36, 0xec, 0x15, 0x36, 0xed, 0x28, 0x37, 0x0f, 0x01, 0x37, 0x22, 0x41, 0x37, 0x24, 0x41, 0x37, 0x25, 0xc1, 0x37, 0x28, 0x00, 0x37, 0xb0, 0x41, 0x37, 0xb1, 0x41, 0x37, 0xb2, 0x47, 0x37, 0xb3, 0x09, 0x37, 0xb4, 0x0f, 0x37, 0xfa, 0x09, 0x37, 0xfb, 0x33, 0x37, 0xfc, 0x11, 0x37, 0xfd, 0x37, 0x39, 0x03, 0x40, 0x39, 0x04, 0x04, 0x39, 0x05, 0x8d, 0x39, 0x07, 0x00, 0x39, 0x08, 0x41, 0x39, 0x33, 0x80, 0x39, 0x34, 0x0a, 0x39, 0x37, 0x79, 0x39, 0x39, 0x00, 0x39, 0x3a, 0x00, 0x3e, 0x01, 0x2e, 0x3e, 0x02, 0xa0, 0x44, 0x0e, 0x02, 0x45, 0x09, 0x20, 0x45, 0x0d, 0x28, 0x48, 0x00, 0x44, 0x48, 0x19, 0x06, 0x48, 0x1b, 0x03, 0x48, 0x1d, 0x0b, 0x48, 0x1f, 0x03, 0x48, 0x21, 0x08, 0x48, 0x23, 0x03, 0x48, 0x25, 0x03, 0x48, 0x27, 0x03, 0x48, 0x29, 0x05, 0x36, 0xe9, 0x28, 0x37, 0xf9, 0x20, 0x01, 0x00, 0x01, 0xff, 0xff, 0xff, }; const _Sensor_CCM sc1346_ccm_init = { // 5500k, gamma2p2 0x18b, 0xf95, 0xff2, 0xf79, 0x183, 0xf61, 0xfe7, 0xfdf, 0x197, 0xfff, 0xffd, 0xffe, }; const _Sensor_BLC sc1346_blc_init = { 260, 260, 260, 260, }; const _Sensor_AWB sc1346_awb_init = { // r, gr, gb, b .default_gain = {482, 256, 256, 508}, .awb_min_gain = {328, 256, 256, 508}, .awb_max_gain = {500, 256, 256, 738}, .coarse_constraint = { .coarse_min_bg = 0, .coarse_lb_bg = 0, .coarse_rt_bg = 0, .coarse_max_bg = 0, .coarse_min_rg = 0, .coarse_lb_rg = 0, .coarse_rt_rg = 0, .coarse_max_rg = 0, }, .constraint = { .section_num = 5, .color_temp = { 7500, 6500, 5000, 4000, 2856, 0, 0, 0}, .sec_line_slope = {0.13043478,0.57894737,1.33333333,1.44897959,1.47058824, 0, 0, 0}, .sec_line_offset = {163.17391304,80.57894737,-59.33333333,-122.22448980,-233.47058824, 0, 0, 0}, .sec_line_sqrtk2add1 = {0.99160041,0.86542629,0.60000000,0.56800381,0.56231002, 0, 0, 0}, .center_line_slope = {-7.66666667,-0.78947368,-0.71428571,-0.68000000, 0, 0, 0}, .center_line_offset = {1169.00000000,261.21052632,249.85714286,243.96000000, 0, 0, 0}, .lower_line_slope = {14.39078405,-2.25188242,-0.71452001,-0.28621527, 0, 0, 0}, .lower_line_offset = {-1563.28659702,417.50036139,213.03116117,146.66110778, 0, 0, 0}, .upper_line_slope = {-2.76616134,-0.70016780,-0.71416035,-0.80835805, 0, 0, 0}, .upper_line_offset = {565.55747149,266.02684729,268.26565555,285.27022947, 0, 0, 0}, .corner_limit = {121.06719671,178.96528653,138.91600411,181.29339184,216.37689979,84.73073498,227.62310021,101.26926502}, }, }; const _Sensor_GAMMA_BV sc1346_gamma_map = { .adj_by_bv = 1, .bv = { 29491, 3534, 1599, 347, 222, 115, 57, 34, }, .y_alpha = { 255, 255, 192, 192, 128, 128, 64, 64, }, .rgb_alpha = { 255, 255, 192, 192, 128, 128, 64, 64, }, }; const _Sensor_CSC sc1346_csc_init = { .rgb2yuv_gamut = ISP_YUV_GAMUT_BT709, .rgb2yuv_range = ISP_YUV_RANGE_NARROW, .yuv2rgb_in_gamut = ISP_YUV_GAMUT_BT709, .yuv2rgb_in_range = ISP_YUV_RANGE_NARROW, .yuv2rgb_out_gamut = ISP_YUV_GAMUT_BT709, .yuv2rgb_out_range = ISP_YUV_RANGE_NARROW, .y_gamma_alpha = 0xff, .rgb_gamma_alpha = 0xff, .gamma_alpha_map = (void *)&sc1346_gamma_map, }; const _Sensor_AE sc1346_ae_init = { .curr_fps = (uint32)(12.5*256), .max_frame_length = 880, .min_frame_vb = 8, .max_analog_gain = 126<<8, .min_analog_gain = 1<<8, .default_exposure_line = 872, .max_exposure_line = 872, .min_exposure_line = 10, .row_time_us = 26, .expo_frame_interval = 2, .to_day_bv = 1528, .to_night_bv = 369, .dark_scene_target_lut = {50, 60}, .dark_scene_bv_lut = {47, 800}, .hs_scene_limit_lut = {60, 80}, .hs_scene_bv_lut = {800, 3022}, .lowlight_lsb_bv_lut = {47, 94, 195, 381, 781, 1636, 3225, 1e30}, .lowlight_lsb_gain_lut = {16, 16, 16, 16, 16, 16, 16, 16}, // u7.4 }; const _Sensor_CSUPP sc1346_csupp_init = { // u8 U_luma_thr_lo, U_luma_slop_lo, U_luma_shfb_lo, U_luma_gmin_lo, // u8 U_luma_thr_hi, U_luma_slop_hi, U_luma_shfb_hi, U_luma_gmin_hi, // u8 V_luma_thr_lo, V_luma_slop_lo, V_luma_shfb_lo, V_luma_gmin_lo, // u8 V_luma_thr_hi, V_luma_slop_hi, V_luma_shfb_hi, V_luma_gmin_hi, // u8 chroma_thr_lo, chroma_slop_lo, chroma_shfb_lo, chroma_gmin_lo, 31, 4, 0, 0, 209, 4, 0, 0, 31, 4, 0, 0, 209, 4, 0, 0, 31, 4, 0, 0, }; const _Sensor_SHARP sc1346_sharp_init = { .filt_alpha = 128, .shrink_thr = 0, .filt_clip_hi = 127, .filt_clip_lo = 127, .sp_thr2 = 10, .sp_thr1 = 5, .enha_clip_hi = 30, .enha_clip_lo = 127, .e1 = 5, .e2 = 10, .e3 = 15, .k0 = 0, .k1 = 128, .k2 = 128, .k3 = 128, .y1 = 0, // y1 = k0*e1 .y2 = 20, // y2 = k1*e2 + (y1 - k1*e1) = k1 * (e2 - e1) + y1 .y3 = 40, // y3 = k2*e3 + (y2 - k2*e2) = k2 * (e3 - e2) + y2 .filt_w11 = 7, .filt_w12 = 9, .filt_w13 = 10, .filt_w21 = 9, .filt_w22 = 12, .filt_w23 = 13, .filt_w31 = 10, .filt_w32 = 13, .filt_w33 = 16, .filt_type = 1, .filt_sbit = 8, .lpf_scale = 1, .strength_lut = { 64, 128}, .strength_bv_lut = {369,1528}, }; const _Sensor_YUVNR sc1346_yuvnr_init = { 20,20,20,20,20,20,20,20, 205,255,0, }; const _Sensor_COLENH_BV sc1346_ce_map[BV2COLENH_ARRAY_NUM] = { {.bv = 29491, .hue = 0, .luma = 58, .contrast = 60, .saturation = 70}, {.bv = 3534, .hue = 0, .luma = 58, .contrast = 60, .saturation = 70}, {.bv = 4531, .hue = 0, .luma = 50, .contrast = 60, .saturation = 65}, {.bv = 400, .hue = 0, .luma = 50, .contrast = 60, .saturation = 50}, {.bv = 222, .hue = 0, .luma = 50, .contrast = 60, .saturation = 50}, {.bv = 115, .hue = 0, .luma = 50, .contrast = 60, .saturation = 50}, {.bv = 57, .hue = 0, .luma = 50, .contrast = 60, .saturation = 50}, {.bv = 34, .hue = 0, .luma = 50, .contrast = 60, .saturation = 50}, }; const _Sensor_COLENH sc1346_colenh_init = { .yuv_range = 0, .luma = 58, // range: 0 ~ 100 .contrast = 53, // range: 0 ~ 100 .saturation = 90, // range: 0 ~ 100 .hue = 0, // range: -180 ~ 180 .ce_in_ofs_y = 128, .ce_in_ofs_cb = 128, .ce_in_ofs_cr = 128, // range: -128 ~ 128 .ce_out_ofs_y = 128, .ce_out_ofs_cb = 128, .ce_out_ofs_cr = 128, // range: -128 ~ 128 .adj_by_bv_en = 1, .bv2colenh_map = (void *)sc1346_ce_map, }; const _Sensor_BV2NR sc1346_bv2nr_init[BV2RAWNR_ARRAY_NUM] = { // bv, bnr_range_weight_index, bnr_invksigma, bnr_intensity_threshold, yuvnr_idx, csupp_idx. h264_3dnr_lev h264_3dnr_en { 10000, 8 , 511, 63, 1, 0, 1, 1}, // 646lux { 5993, 8 , 400, 63, 1, 0, 2, 1}, // 240lux { 3022, 16, 250, 63, 1, 1, 2, 1}, // 20lux { 1528, 16, 271, 63, 1, 1, 2, 1}, // 10lux { 754, 16, 165, 63, 2, 1, 2, 1}, // 5p03lux { 369, 16, 135, 63, 2, 1, 2, 1}, // 2p5lux { 184, 20, 101, 63, 3, 1, 2, 1}, // 1p25lux { 90, 24, 62, 63, 4, 2, 2, 1}, // 0p62lux { 46, 26, 50, 63, 4, 2, 2, 1}, // 0p31lux { 32, 28, 40, 63, 5, 2, 2, 1}, // 0p1lux { 24, 31, 25, 63, 5, 2, 2, 1}, // 0p01lux }; const uint32 sc1346_lsc_tbl[] = { //R channel 0x0009dad1,0x00071e13,0x0005a58f,0x00050553,0x0005113c,0x0005ad50,0x00074195,0x000a5621,0x0000030a,0x00097eb8,0x0006d1fc,0x00056d7e,0x0004d545,0x0004dd30,0x00056d43,0x0006f582, 0x0009e209,0x000002eb,0x0008fe94,0x000675e3,0x00052169,0x00049532,0x0004951f,0x00052131,0x0006916c,0x000961ec,0x000002c3,0x0008aa7c,0x000629cd,0x0004e558,0x00045d26,0x00046913, 0x0004e925,0x0006415c,0x0008fdd7,0x000002a8,0x00085e6c,0x0005f1be,0x0004bd4c,0x00043d1b,0x0004410a,0x0004c11c,0x00060950,0x0008b1c6,0x00000295,0x00082a5c,0x0005cdb3,0x0004a145, 0x00042515,0x00042504,0x0004a514,0x0005e149,0x000881bc,0x00000288,0x00081254,0x0005b9ab,0x00049141,0x00041511,0x00042101,0x00049d12,0x0005d947,0x000869b7,0x00000285,0x00081655, 0x0005b5ad,0x00048d42,0x00041511,0x00041d00,0x0004a513,0x0005e548,0x000875ba,0x0000028a,0x00082a5d,0x0005c1b1,0x00049544,0x00041d13,0x00042902,0x0004b116,0x0005f94c,0x0008a9c3, 0x00000297,0x0008526d,0x0005ddb8,0x0004ad4b,0x00043117,0x00044108,0x0004cd1b,0x00063157,0x0008edd3,0x000002ae,0x00089a80,0x00060dc7,0x0004d154,0x00045520,0x00046110,0x0004fd25, 0x00067165,0x00095de9,0x000002c7,0x0008fa9b,0x000655dd,0x00050164,0x0004812c,0x0004911b,0x00053d33,0x0006c976,0x0009e205,0x000002ee,0x00097ac0,0x0006adf8,0x00054977,0x0004bd3a, 0x0004d52b,0x00058d46,0x0007418e,0x000a8628,0x0000031e,0x000a0eec,0x0007261a,0x0005a190,0x00050d50,0x0005213f,0x0005f15c,0x0007d1ad,0x000b4e53,0x00000356,0x000abf1d,0x0007ba43, 0x00060db0,0x0005716a,0x00058d56,0x00066d76,0x000879d0,0x000c3688,0x0000039f,0x000baf5a,0x00086a79,0x0006a5da,0x0005ed8b,0x00060d76,0x0007059a,0x000945fc,0x000d46c1,0x000003e7, 0x000cbfa0,0x00093ab6,0x00075209,0x000681b1,0x0006a99c,0x0007c5c4,0x000a4232,0x000e6f02,0x000003ff, //GR channel 0x00093693,0x0006d1f5,0x0005697d,0x0004dd44,0x0004ed32,0x00059149,0x0007258d,0x0009f217,0x000002e0,0x0008fa86,0x000689e4,0x0005316c,0x0004a936,0x0004b927,0x0005513b,0x0006dd7c, 0x00099e03,0x000002cd,0x0008aa71,0x000639cf,0x0004f15a,0x00047528,0x00048119,0x00050d2c,0x00068168,0x00093dec,0x000002b4,0x00086663,0x0005f9bf,0x0004bd4c,0x0004491c,0x0004550e, 0x0004d921,0x00063959,0x0008edd9,0x000002a0,0x00083259,0x0005cdb3,0x00049d42,0x00042d15,0x00043507,0x0004b519,0x0006014f,0x0008b9ca,0x00000295,0x00081a51,0x0005b1aa,0x0004893d, 0x00041910,0x00042102,0x00049d14,0x0005e548,0x000891c0,0x0000028c,0x0008064e,0x0005a1a6,0x00047d3a,0x0004110e,0x00041900,0x00049511,0x0005d545,0x000875bb,0x00000284,0x00080a4f, 0x0005a1a6,0x00047d3a,0x0004150f,0x00041d01,0x00049511,0x0005d144,0x000875bb,0x00000285,0x00082256,0x0005adaa,0x0004853d,0x00041d11,0x00042503,0x00049d13,0x0005dd46,0x000889bf, 0x0000028a,0x00084663,0x0005c9b2,0x00049d44,0x00043116,0x00043908,0x0004b118,0x0005f94d,0x0008adc8,0x00000296,0x00088275,0x0005f1bf,0x0004bd4d,0x00044d1c,0x0004550f,0x0004d120, 0x00062557,0x0008edd6,0x000002a5,0x0008ce88,0x000631d0,0x0004ed5b,0x00047928,0x00047d19,0x0005092c,0x00066d66,0x000949ea,0x000002bb,0x000936a3,0x000689e9,0x00052d6d,0x0004b136, 0x0004b927,0x00054d3b,0x0006d17a,0x0009c207,0x000002d9,0x0009b6c5,0x0006f209,0x00058585,0x0004f94a,0x00050539,0x0005ad50,0x00074d95,0x000a5a2b,0x00000300,0x000a4aea,0x0007762e, 0x0005eda3,0x00055963,0x00056951,0x00061d6b,0x0007e9b7,0x000b0656,0x0000032d,0x000b0b1d,0x0008225a,0x000679ca,0x0005d583,0x0005e970,0x0006b58d,0x0008a5e1,0x000bde89,0x00000360, 0x000bdb4e,0x0008e290,0x000725f8,0x000671aa,0x00068997,0x000771b8,0x00098213,0x000cbebf,0x00000397, 0x00093694,0x0006cdf7,0x0005697e,0x0004e145,0x0004fd34,0x0005c951,0x000799a1,0x000a8e3a,0x00000303,0x0008f687,0x000689e6,0x0005316d,0x0004ad36,0x0004c928,0x00058141,0x00073d8c, 0x000a2a22,0x000002ea,0x0008aa72,0x000635d1,0x0004f15b,0x00047528,0x00048919,0x00053131,0x0006d175,0x0009b204,0x000002cc,0x00086664,0x0005f9c1,0x0004bd4d,0x0004491d,0x0004590e, 0x0004f524,0x00067963,0x000945eb,0x000002b0,0x0008325a,0x0005cdb4,0x00049943,0x00042d15,0x00043907,0x0004c91b,0x00063156,0x0008edd7,0x0000029c,0x00081652,0x0005b1ac,0x0004853e, 0x00041910,0x00042502,0x0004a914,0x0006014c,0x0008adc7,0x00000290,0x0008024f,0x0005a1a7,0x00047d3b,0x0004110e,0x00041d00,0x00049911,0x0005e146,0x000885bd,0x00000287,0x0008064f, 0x0005a1a8,0x00047d3b,0x0004150f,0x00041d00,0x00049511,0x0005d944,0x00087dbb,0x00000285,0x00081e57,0x0005adab,0x0004853e,0x00041d11,0x00042503,0x00049d13,0x0005dd46,0x00088dbe, 0x0000028a,0x00084263,0x0005c5b4,0x00049d44,0x00043116,0x00043508,0x0004ad17,0x0005f94b,0x0008adc6,0x00000295,0x00087e75,0x0005f1c0,0x0004bd4d,0x00044d1c,0x0004510e,0x0004cd1e, 0x00061d54,0x0008e9d3,0x000002a3,0x0008ca88,0x00062dd2,0x0004ed5c,0x00047927,0x00047918,0x0004f929,0x00065960,0x000935e2,0x000002b7,0x00092ea3,0x000685ea,0x0005296d,0x0004ad36, 0x0004b125,0x00053537,0x0006a570,0x000995f7,0x000002d0,0x0009b2c5,0x0006ee0a,0x00058186,0x0004f549,0x0004f137,0x00058549,0x00070586,0x000a0613,0x000002ee,0x000a46e9,0x0007722e, 0x0005e9a3,0x00054d61,0x0005514d,0x0005e961,0x000785a3,0x000a8e36,0x00000314,0x000b071d,0x00081a5b,0x000675ca,0x0005c981,0x0005c56a,0x00066d7f,0x000829c8,0x000b4260,0x00000340, 0x000bd34d,0x0008da90,0x000719f8,0x000659a6,0x0006558e,0x000711a5,0x0008e5f3,0x000c0a8e,0x00000372, //B channel 0x0007be24,0x0005edad,0x0004e551,0x00048929,0x0004c923,0x0005a547,0x00076599,0x000a2a2d,0x000002d9,0x00078618,0x0005b59c,0x0004b543,0x0004691f,0x0004a11c,0x0005693b,0x00071989, 0x0009ba12,0x000002bd,0x00074606,0x0005798f,0x00049539,0x00045119,0x00048114,0x00052d31,0x0006b575,0x000939f8,0x0000029a,0x000711f9,0x00054982,0x0004752f,0x00043112,0x0004590b, 0x0004f525,0x00064960,0x0008b1d9,0x00000275,0x0006d9ec,0x00052176,0x00045d27,0x00041d0c,0x00043906,0x0004c51b,0x0005f150,0x000841be,0x00000255,0x0006b9e1,0x0005096d,0x00044d22, 0x0004110a,0x00042503,0x00049d15,0x0005ad44,0x0007d1a6,0x0000023d,0x00069ddf,0x0004fd67,0x00044521,0x00040d09,0x00041900,0x00048110,0x00057939,0x00077994,0x00000226,0x0006a1dc, 0x0004f966,0x0004491f,0x00041109,0x00041901,0x00046d0d,0x00054931,0x00074187,0x00000217,0x0006a5e2,0x0004fd69,0x00044d22,0x0004190a,0x00041d03,0x00045d0c,0x0005312d,0x00071980, 0x0000020b,0x0006c1eb,0x0005116d,0x00045d27,0x0004290e,0x00042505,0x0004590d,0x00052d2b,0x00070d7e,0x00000209,0x0006e9f4,0x00053177,0x0004752e,0x00043912,0x0004350a,0x00046910, 0x00052d2e,0x00071580,0x0000020b,0x00072607,0x00055d84,0x00049538,0x0004591a,0x00045110,0x00048117,0x00054d33,0x00073987,0x00000211,0x00077619,0x00059d97,0x0004c545,0x00047d24, 0x0004751a,0x0004a51f,0x0005793f,0x00077d95,0x00000221,0x0007d637,0x0005f1b0,0x00050958,0x0004b134,0x0004a126,0x0004dd2d,0x0005c54f,0x0007cdaa,0x00000235,0x00084e55,0x000655cc, 0x0005596e,0x0004fd47,0x0004e938,0x0005293e,0x00061d62,0x00082dc3,0x00000255,0x0008e277,0x0006d5ef,0x0005c58d,0x00055960,0x0005414f,0x00058956,0x0006a17f,0x0008b9e5,0x00000276, 0x00098a9e,0x00077618,0x000655b2,0x0005d17f,0x0005b56c,0x00061174,0x00073da1,0x00095a08,0x0000029f, }; const _Sensor_LSC sc1346_lsc_init = { .p_lsc_tbl = (uint32 *)sc1346_lsc_tbl, }; const _Sensor_LHS sc1346_lhs_map[] = { // region defination: lower -> center -> upper(direction: anticlockwise) // region_lower, region_center, region_upper, hue adjust value, saturation adjust value // (9 bits) (9 bits) (9 bits) (9 bits) (8 bits) { 24, 52, 80, 0, 0}, // magenta, range: 28 { 80, 109, 138, 0, 0}, // red, range: 29 { 140, 171, 202, +0, +00}, // yellow, range: 31 { 204, 232, 260, + 0, 0}, // green, range: 28 { 261, 289, 317, 0, 0}, // cyan, range: 28 { 320, 351, 22, 0, 0}, // blue, range: 31 { 109, 132, 156, 0, 0}, // skin enhance, range: { 160, 203, 247, +00, 0}, // green enhance(plants), range: { 296, 318, 340, 0, 00} // blue enhance, range: }; const _Sensor_YGAMMA sc1346_ygamma_tbl[NUM_CURVES] = { { .bv = 200, .packed_lut = { 0x01002000, 0x02006010, 0x0300A020, 0x0400E030, 0x05012040, 0x06016050, 0x0701A060, 0x0801E070, 0x09022080, 0x0A026090, 0x0B02A0A0, 0x0C02E0B0, 0x0D0320C0, 0x0E0360D0, 0x0F03A0E0, 0x1003E0F0, 0x11042100, 0x12046110, 0x1304A120, 0x1404E130, 0x15052140, 0x16056150, 0x1705A160, 0x1805E170, 0x19062180, 0x1A066190, 0x1B06A1A0, 0x1C06E1B0, 0x1D0721C0, 0x1E0761D0, 0x1F07A1E0, 0x2007E1F0, 0x21082200, 0x22086210, 0x2308A220, 0x2408E230, 0x25092240, 0x26096250, 0x2709A260, 0x2809E270, 0x290A2280, 0x2A0A6290, 0x2B0AA2A0, 0x2C0AE2B0, 0x2D0B22C0, 0x2E0B62D0, 0x2F0BA2E0, 0x300BE2F0, 0x310C2300, 0x320C6310, 0x330CA320, 0x340CE330, 0x350D2340, 0x360D6350, 0x370DA360, 0x380DE370, 0x390E2380, 0x3A0E6390, 0x3B0EA3A0, 0x3C0EE3B0, 0x3D0F23C0, 0x3E0F63D0, 0x3F0FA3E0, 0x3FFFE3F0,}}, { .bv = 500, .packed_lut = { 0x01002000, 0x02006010, 0x0300A020, 0x0400E030, 0x05012040, 0x06016050, 0x0701A060, 0x0801E070, 0x09022080, 0x0A026090, 0x0B02A0A0, 0x0C02E0B0, 0x0D0320C0, 0x0E0360D0, 0x0F03A0E0, 0x1003E0F0, 0x11042100, 0x12046110, 0x1304A120, 0x1404E130, 0x15052140, 0x16056150, 0x1705A160, 0x1805E170, 0x19062180, 0x1A066190, 0x1B06A1A0, 0x1C06E1B0, 0x1D0721C0, 0x1E0761D0, 0x1F07A1E0, 0x2007E1F0, 0x21082200, 0x22086210, 0x2308A220, 0x2408E230, 0x25092240, 0x26096250, 0x2709A260, 0x2809E270, 0x290A2280, 0x2A0A6290, 0x2B0AA2A0, 0x2C0AE2B0, 0x2D0B22C0, 0x2E0B62D0, 0x2F0BA2E0, 0x300BE2F0, 0x310C2300, 0x320C6310, 0x330CA320, 0x340CE330, 0x350D2340, 0x360D6350, 0x370DA360, 0x380DE370, 0x390E2380, 0x3A0E6390, 0x3B0EA3A0, 0x3C0EE3B0, 0x3D0F23C0, 0x3E0F63D0, 0x3F0FA3E0, 0x3FFFE3F0,}}, { .bv = 1000, .packed_lut = { 0x01002000, 0x02006010, 0x0300A020, 0x0400E030, 0x05012040, 0x06016050, 0x0701A060, 0x0801E070, 0x09022080, 0x0A026090, 0x0B02A0A0, 0x0C02E0B0, 0x0D0320C0, 0x0E0360D0, 0x0F03A0E0, 0x1003E0F0, 0x11042100, 0x12046110, 0x1304A120, 0x1404E130, 0x15052140, 0x16056150, 0x1705A160, 0x1805E170, 0x19062180, 0x1A066190, 0x1B06A1A0, 0x1C06E1B0, 0x1D0721C0, 0x1E0761D0, 0x1F07A1E0, 0x2007E1F0, 0x21082200, 0x22086210, 0x2308A220, 0x2408E230, 0x25092240, 0x26096250, 0x2709A260, 0x2809E270, 0x290A2280, 0x2A0A6290, 0x2B0AA2A0, 0x2C0AE2B0, 0x2D0B22C0, 0x2E0B62D0, 0x2F0BA2E0, 0x300BE2F0, 0x310C2300, 0x320C6310, 0x330CA320, 0x340CE330, 0x350D2340, 0x360D6350, 0x370DA360, 0x380DE370, 0x390E2380, 0x3A0E6390, 0x3B0EA3A0, 0x3C0EE3B0, 0x3D0F23C0, 0x3E0F63D0, 0x3F0FA3E0, 0x3FFFE3F0,}}, { .bv = 1500, .packed_lut = { 0x01002000, 0x02006010, 0x0300A020, 0x0400E030, 0x05012040, 0x06016050, 0x0701A060, 0x0801E070, 0x09022080, 0x0A026090, 0x0B02A0A0, 0x0C02E0B0, 0x0D0320C0, 0x0E0360D0, 0x0F03A0E0, 0x1003E0F0, 0x11042100, 0x12046110, 0x1304A120, 0x1404E130, 0x15052140, 0x16056150, 0x1705A160, 0x1805E170, 0x19062180, 0x1A066190, 0x1B06A1A0, 0x1C06E1B0, 0x1D0721C0, 0x1E0761D0, 0x1F07A1E0, 0x2007E1F0, 0x21082200, 0x22086210, 0x2308A220, 0x2408E230, 0x25092240, 0x26096250, 0x2709A260, 0x2809E270, 0x290A2280, 0x2A0A6290, 0x2B0AA2A0, 0x2C0AE2B0, 0x2D0B22C0, 0x2E0B62D0, 0x2F0BA2E0, 0x300BE2F0, 0x310C2300, 0x320C6310, 0x330CA320, 0x340CE330, 0x350D2340, 0x360D6350, 0x370DA360, 0x380DE370, 0x390E2380, 0x3A0E6390, 0x3B0EA3A0, 0x3C0EE3B0, 0x3D0F23C0, 0x3E0F63D0, 0x3F0FA3E0, 0x3FFFE3F0, }}, {// ?????BV=500 .bv = 2000, .packed_lut = { 0x01002000, 0x02006010, 0x0300A020, 0x0400E030, 0x05012040, 0x06016050, 0x0701A060, 0x0801E070, 0x09022080, 0x0A026090, 0x0B02A0A0, 0x0C02E0B0, 0x0D0320C0, 0x0E0360D0, 0x0F03A0E0, 0x1003E0F0, 0x11042100, 0x12046110, 0x1304A120, 0x1404E130, 0x15052140, 0x16056150, 0x1705A160, 0x1805E170, 0x19062180, 0x1A066190, 0x1B06A1A0, 0x1C06E1B0, 0x1D0721C0, 0x1E0761D0, 0x1F07A1E0, 0x2007E1F0, 0x21082200, 0x22086210, 0x2308A220, 0x2408E230, 0x25092240, 0x26096250, 0x2709A260, 0x2809E270, 0x290A2280, 0x2A0A6290, 0x2B0AA2A0, 0x2C0AE2B0, 0x2D0B22C0, 0x2E0B62D0, 0x2F0BA2E0, 0x300BE2F0, 0x310C2300, 0x320C6310, 0x330CA320, 0x340CE330, 0x350D2340, 0x360D6350, 0x370DA360, 0x380DE370, 0x390E2380, 0x3A0E6390, 0x3B0EA3A0, 0x3C0EE3B0, 0x3D0F23C0, 0x3E0F63D0, 0x3F0FA3E0, 0x3FFFE3F0,}} }; const _Sensor_DPC sc1346_dpc_init = { .static_psram_addr = (uint32)0, .white_threshold = 115, .black_threshold = 115, .white_threshold_min = 30, .black_threshold_min = 30, .sensitivity_value = 128, .dynamic_white_strength = 4, .dynamic_black_strength = 4, }; void SC1346_ae_adjust(struct isp_exposure_opt *p_cfg) { uint8_t i; uint32_t total_gain_int = p_cfg->analog_gain; uint8_t gain_segment[] = { 1, 2, 4, 8, 16, 32}; uint8_t gain_value[] = {0x00, 0x08, 0x09, 0x0B, 0x0F, 0x1F}; uint8_t ana_idx = 5; uint16_t fine_val = 0; uint8_t dig_gain = 0; uint32_t exposure_line = p_cfg->exposure_line; uint8_t *addr = (uint8_t *)p_cfg->data.addr; for (i = 0; i < 6; i++) { if (total_gain_int >= (gain_segment[i]* 256)) { ana_idx = i; } else { break; } } (total_gain_int >= 16384)?(dig_gain=1):(dig_gain=0); fine_val = (((p_cfg->analog_gain >> (ana_idx + dig_gain)) - 256) >> 3) << 2; i = 0; addr[i++] = 0x3e; addr[i++] = 0x02; addr[i++] = (exposure_line << 4) & 0xf0; addr[i++] = 0x3e; addr[i++] = 0x01; addr[i++] = (exposure_line >> 4) & 0xff; addr[i++] = 0x3e; addr[i++] = 0x00; addr[i++] = (exposure_line >> 12) & 0x0f; addr[i++] = 0x3e; addr[i++] = 0x09; addr[i++] = gain_value[ana_idx]; addr[i++] = 0x3e; addr[i++] = 0x06; addr[i++] = dig_gain; addr[i++] = 0x3e; addr[i++] = 0x07; addr[i++] = 0x80 + fine_val; p_cfg->data.size = i; p_cfg->cmd_len = 3; } void sc1346_fps_opt(struct isp_sensor_opt *p_opt) { uint8 *addr = (uint8 *)p_opt->data.addr; uint8 index = 0; addr[index++] = 0x32; addr[index++] = 0x0e; addr[index++] = p_opt->curr_length >> 8; addr[index++] = 0x32; addr[index++] = 0x0f; addr[index++] = p_opt->curr_length & 0xff; p_opt->data.size = index; p_opt->cmd_len = 2+1; } void sc1346_img_opt(struct isp_sensor_opt *p_opt) { uint8 *addr = (uint8 *)p_opt->data.addr; uint8 index = 0; uint8 reg_value = 0x00; addr[index++] = 0x32; addr[index++] = 0x21; if (p_opt->reverse_en) { reg_value |= (0x03 << 5); //set bit[6:5] = 0b11 } if (p_opt->mirror_en) { // reg_value |= (0x03 << 1); // set bit[2:1] = 0b11 } addr[index++] = reg_value; p_opt->data.size = index; p_opt->cmd_len = 2 + 1; } const _Sensor_ISP_Init sc1346_isp_init = { .type = ISP_INPUT_DAT_SRC_MIPI0, .pixel_h = 720, .pixel_w = 1280, .bayer_patten = ISP_BAYER_FORMAT_BGGR, .input_format = ISP_INPUT_DAT_FORMAT_RAW10, .adjust_func = (isp_ae_func )SC1346_ae_adjust, .p_blc = (_Sensor_BLC *)&sc1346_blc_init, .p_ccm = (_Sensor_CCM *)&sc1346_ccm_init, .p_awb = (_Sensor_AWB *)&sc1346_awb_init, .p_ae = (_Sensor_AE *)&sc1346_ae_init, .p_dpc = (_Sensor_DPC *)&sc1346_dpc_init, .p_csc = (_Sensor_CSC *)&sc1346_csc_init, .p_csupp = (_Sensor_CSUPP *)&sc1346_csupp_init, .p_sharp = (_Sensor_SHARP *)&sc1346_sharp_init, .p_yuvnr = (_Sensor_YUVNR *)&sc1346_yuvnr_init, .p_colenh = (_Sensor_COLENH *)&sc1346_colenh_init, .p_bv2nr = (_Sensor_BV2NR *)sc1346_bv2nr_init, .p_lsc = (_Sensor_LSC *)&sc1346_lsc_init, .p_lhs = (_Sensor_LHS *)sc1346_lhs_map, .p_ygamma = (_Sensor_YGAMMA *)sc1346_ygamma_tbl, .fps_opt = (sensor_fps_opt )sc1346_fps_opt, .img_opt = (sensor_img_opt )sc1346_img_opt, }; SENSOR_OP_SECTION const _Sensor_Adpt_ sc1346_cmd= { .typ = 1, //YUV .pixelw = 1280, .pixelh= 720, .hsyn = 1, .vsyn = 1, .rduline = 0,// .rawwide = 1,//10bit .colrarray = 2,//0:_RGRG_ 1:_GRGR_,2:_BGBG_,3:_GBGB_ .init = (uint8 *)sc1346InitTable, .init_len = sizeof(sc1346InitTable), .rotate_adapt = {0}, .hvb_adapt = {0x80,0x0a,0x80,0x0a}, .mclk = 24000000, .p_fun_adapt = {NULL,NULL,NULL}, .sensor_isp = (_Sensor_ISP_Init *)&sc1346_isp_init, }; const _Sensor_Ident_ sc1346_init= { 0x4d,0x60,0x61,0x02,0x01,0x3108 }; #endif