Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
244
sdk/lib/video/isp/isp_dev.c
Normal file
244
sdk/lib/video/isp/isp_dev.c
Normal file
@@ -0,0 +1,244 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "lib/video/dvp/cmos_sensor/csi.h"
|
||||
#include "lib/video/dvp/cmos_sensor/csi_V2.h"
|
||||
#include "devid.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/isp.h"
|
||||
#include "hal/i2c.h"
|
||||
#include "osal/irq.h"
|
||||
#include "osal/string.h"
|
||||
#include "dev/vpp/hgvpp.h"
|
||||
#include "dev/csi/hgdvp.h"
|
||||
#include "lib/lcd/lcd.h"
|
||||
#include "hal/jpeg.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "app/app_iic/app_iic.h"
|
||||
#include "lib/video/isp/isp_dev.h"
|
||||
#include "lib/video/isp/isp_ircut.h"
|
||||
#include "osal/event.h"
|
||||
#include "osal/msgqueue.h"
|
||||
#include "lib/heap/av_heap.h"
|
||||
|
||||
#ifndef ISP_HARDWARE_CLK
|
||||
#define ISP_HARDWARE_CLK ISP_MODULE_CLK_320M
|
||||
#endif
|
||||
|
||||
extern _Sensor_YGAMMA y_gamma_tbl[];
|
||||
// extern uint32 gamma2p4_tbl[];
|
||||
extern uint32 gamma_table_addr[3] ;
|
||||
extern uint32 luma_ca_addr[];
|
||||
extern IRCUT_INFO ircut_info;
|
||||
#if ISP_DMA_EN
|
||||
#define ISP_IRQ_HANDLE_TYPE ISP_IRQ_FLAG_DMA_DONE
|
||||
#else
|
||||
#define ISP_IRQ_HANDLE_TYPE ISP_IRQ_FLAG_FRM_END
|
||||
#endif
|
||||
|
||||
volatile struct list_head sensor_info_head;
|
||||
const float ev_offset_lut[] = {0.015625, 0.03125, 0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 64};
|
||||
const struct isp_awb_mode_param isp_awb_mode_map[] =
|
||||
{
|
||||
// awb_mode awb_gain_r awb_gain_gr awb_gain_gb awb_gain_b
|
||||
{ 0, 0, 256, 256, 0},
|
||||
{ 1, 480, 256, 256, 430},
|
||||
{ 2, 530, 256, 256, 380},
|
||||
{ 3, 551, 256, 256, 360},
|
||||
};
|
||||
|
||||
void sensor_info_init()
|
||||
{
|
||||
INIT_LIST_HEAD((struct list_head *)&sensor_info_head);
|
||||
}
|
||||
|
||||
void sensor_info_add(enum sensor_type type, enum isp_input_dat_src sensor_src, uint32 sensor_config, uint32 iic_id, uint32 opt_cmd)
|
||||
{
|
||||
SENSOR_BASIC_INFO *info = os_malloc(sizeof(SENSOR_BASIC_INFO));
|
||||
if (info)
|
||||
{
|
||||
os_memset(info, 0, sizeof(sizeof(SENSOR_BASIC_INFO)));
|
||||
info->sensor_src = sensor_src;
|
||||
info->sensor_type = type;
|
||||
info->sensor_dev_id = iic_id;
|
||||
info->sensor_opt_cmd = opt_cmd;
|
||||
info->sensor_config = sensor_config;
|
||||
INIT_LIST_HEAD(&info->list);
|
||||
list_add_tail(&info->list,(struct list_head*)&sensor_info_head);
|
||||
}
|
||||
}
|
||||
|
||||
void sensor_info_destory()
|
||||
{
|
||||
SENSOR_BASIC_INFO *info = NULL;
|
||||
struct list_head *nhead = NULL;
|
||||
|
||||
while(1)
|
||||
{
|
||||
if (list_empty((void *)&sensor_info_head)) break;
|
||||
nhead = sensor_info_head.next;
|
||||
info = list_entry(nhead, SENSOR_BASIC_INFO, list);
|
||||
list_del(nhead);
|
||||
os_free(info);
|
||||
}
|
||||
}
|
||||
|
||||
void hgisp_frame_start_handle(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2) {
|
||||
// _os_printf("d");
|
||||
// os_printf("%s %d\r\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
void hgisp_frame_done_handle(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2){
|
||||
os_printf("%s %d\r\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
void hgisp_frame_slow_handle(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2){
|
||||
os_printf("%s %d\r\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
void hgisp_frame_fast_handle(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2){
|
||||
os_printf("%s %d\r\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
void hgisp_motion_detect_handle(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2){
|
||||
os_printf("%s %d\r\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
void hgisp_data_overflow_handle(uint32 irq, uint32 irq_data, uint32 param1, uint32 param2){
|
||||
os_printf("%s %d\r\n",__func__,__LINE__);
|
||||
}
|
||||
|
||||
void *isp_task_hdl;
|
||||
volatile struct os_event isp_event;
|
||||
volatile struct os_msgqueue isp_msg;
|
||||
int32 isp_task(void *data)
|
||||
{
|
||||
uint32 flag = 0;
|
||||
int32 event_ret = 0;
|
||||
int32 msg_ret = 0;
|
||||
uint8 msg_cnt = 0;
|
||||
|
||||
struct isp_device *dev = (struct isp_device *)data;
|
||||
struct isp_exposure_opt *cfg = NULL;
|
||||
struct isp_sensor_opt *opt = NULL;
|
||||
|
||||
while (1)
|
||||
{
|
||||
event_ret = os_event_wait((void *)&isp_event, EVENT_ISP_CALC | EVENT_ISP_FPS_OPT | EVENT_ISP_IMG_OPT, &flag, OS_EVENT_WMODE_OR | OS_EVENT_WMODE_CLEAR, 50);
|
||||
if (event_ret)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flag & EVENT_ISP_CALC)
|
||||
{
|
||||
if (cfg && iic_devid_finish(cfg->devid_id) == 1)
|
||||
{
|
||||
cfg->data.size = 0;
|
||||
cfg = NULL;
|
||||
}
|
||||
|
||||
isp_calculate(dev, (void *)&cfg);
|
||||
|
||||
if (cfg)
|
||||
{
|
||||
wake_up_iic_queue(cfg->devid_id, (void *)&cfg->data, cfg->cmd_len, 2, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((flag & EVENT_ISP_IMG_OPT) || (flag & EVENT_ISP_FPS_OPT))
|
||||
{
|
||||
msg_cnt = os_msgq_cnt((void *)&isp_msg);
|
||||
for (int i = 0; i < msg_cnt; i++)
|
||||
{
|
||||
opt = (struct isp_sensor_opt *)os_msgq_get2((void *)&isp_msg, 100, &msg_ret);
|
||||
if (msg_ret == 0)
|
||||
{
|
||||
while(iic_devid_finish(opt->devid_id) != 1)
|
||||
{
|
||||
os_sleep_ms(1);
|
||||
}
|
||||
wake_up_iic_queue(opt->devid_id, (uint8_t*)&opt->data, opt->cmd_len, 2, (uint8_t*)NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern const uint16_t isp_param[];
|
||||
|
||||
void isp_cfg_dev(){
|
||||
uint8_t ret;
|
||||
struct hgisp_sensor_init *sensor_init = NULL;
|
||||
struct isp_device *isp_dev;
|
||||
SENSOR_BASIC_INFO *info = NULL;
|
||||
isp_dev = (struct isp_device *)dev_get(HG_ISP_DEVID);
|
||||
if (isp_dev == NULL)
|
||||
{
|
||||
os_printf("get isp device err\r\n");
|
||||
return;
|
||||
}
|
||||
os_printf("isp cfg....\r\n");
|
||||
sensor_init = (struct hgisp_sensor_init *)isp_sensor_param_load((void *)isp_param);
|
||||
if (sensor_init && !list_empty((void *)&sensor_info_head))
|
||||
{
|
||||
os_event_init((void *)&isp_event);
|
||||
os_msgq_init((void *)&isp_msg, 2);
|
||||
ret = isp_open(isp_dev, ISP_HARDWARE_CLK, ISP_INPUT_FIFO_FULL);
|
||||
if (!ret)
|
||||
{
|
||||
isp_yuv_range(isp_dev, VIDEO_YUV_RANGE_TYPE);
|
||||
isp_sensor_param_config(isp_dev, (uint32)sensor_init);
|
||||
isp_y_gamma_init(isp_dev , (uint32)y_gamma_tbl);
|
||||
isp_rgb_gamma_init(isp_dev, (uint32)gamma_table_addr[1]);
|
||||
isp_awb_mannul_mode_map(isp_dev, (uint32)isp_awb_mode_map);
|
||||
isp_ae_ev_offset_lut(isp_dev, (uint32)ev_offset_lut);
|
||||
isp_awb_gain_type(isp_dev, AWB_GAIN_TYPE_AWB, SENSOR_TYPE_MASTER);
|
||||
isp_awb_gain_type(isp_dev, AWB_GAIN_TYPE_AWB, SENSOR_TYPE_SLAVE0);
|
||||
isp_awb_gain_type(isp_dev, AWB_GAIN_TYPE_AWB, SENSOR_TYPE_SLAVE1);
|
||||
list_for_each_entry(info, (struct list_head*)&sensor_info_head, list)
|
||||
{
|
||||
ret = isp_sensor_init(isp_dev, info->sensor_type, info->sensor_src, info->sensor_config);
|
||||
if (ret)
|
||||
{
|
||||
os_printf(KERN_ERR"config sensor param err!\r\n");
|
||||
isp_close(isp_dev);
|
||||
goto end;
|
||||
} else {
|
||||
isp_sensor_iic_devid_init(isp_dev, info->sensor_dev_id, info->sensor_type);
|
||||
isp_sensor_iic_cmd_init(isp_dev, info->sensor_opt_cmd, info->sensor_type);
|
||||
}
|
||||
}
|
||||
ircut_init();
|
||||
isp_request_irq(isp_dev, ISP_IRQ_FLAG_DMA_DONE , hgisp_frame_start_handle , 0);
|
||||
// isp_request_irq(isp_dev, ISP_IRQ_FLAG_FRM_END , hgisp_frame_done_handle , (uint32)isp_dev);
|
||||
isp_request_irq(isp_dev, ISP_IRQ_FLAG_DAT_OF , hgisp_data_overflow_handle , 0);
|
||||
isp_request_irq(isp_dev, ISP_IRQ_FLAG_INTF_SLOW, hgisp_frame_slow_handle , 0);
|
||||
isp_request_irq(isp_dev, ISP_IRQ_FLAG_FRM_FAST , hgisp_frame_fast_handle , 0);
|
||||
isp_request_irq(isp_dev, ISP_IRQ_FLAG_MD_DONE , hgisp_motion_detect_handle , 0);
|
||||
isp_task_hdl = os_task_create("isp", (void *)isp_task, isp_dev, OS_TASK_PRIORITY_HIGH+1, 0, NULL, 1024);
|
||||
} else {
|
||||
os_printf("isp open err");
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
os_printf("sensor param init err!\r\n");
|
||||
}
|
||||
end:
|
||||
sensor_info_destory();
|
||||
}
|
||||
|
||||
void isp_dev_close()
|
||||
{
|
||||
struct isp_device *isp_dev = (struct isp_device *)dev_get(HG_ISP_DEVID);
|
||||
if (isp_dev == NULL)
|
||||
{
|
||||
os_printf("get isp device err\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
isp_close(isp_dev);
|
||||
os_task_destroy(isp_task_hdl);
|
||||
os_event_del((void *)&isp_event);
|
||||
os_msgq_del((void *)&isp_msg);
|
||||
}
|
||||
|
||||
113
sdk/lib/video/isp/isp_gamma.c
Normal file
113
sdk/lib/video/isp/isp_gamma.c
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
const uint32 gamma2p4_tbl[] = {
|
||||
0x08715C00,0x0C62A887,0x0F537CC6,0x11C424F5,0x13D4B51C,0x15A5313D,0x1755A15A,0x18E60575,
|
||||
0x1A46658E,0x1BA6BDA4,0x1CE711BA,0x1E1761CE,0x1F37A9E1,0x2057F1F3,0x21583605,0x22587615,
|
||||
0x2358B625,0x2448F235,0x25292E44,0x26096652,0x26E99E60,0x27B9D66E,0x288A0A7B,0x295A3E88,
|
||||
0x2A1A6E95,0x2ADA9EA1,0x2B9ACEAD,0x2C5AFEB9,0x2D0B2AC5,0x2DBB56D0,0x2E6B82DB,0x2F0BAEE6,
|
||||
0x2FBBDAF0,0x305C02FB,0x30FC2B05,0x319C530F,0x323C7B19,0x32CCA323,0x336CC72C,0x33FCEB36,
|
||||
0x348D133F,0x351D3748,0x35AD5B51,0x363D7F5A,0x36CD9F63,0x374DC36C,0x37DDE774,0x385E077D,
|
||||
0x38DE2785,0x396E478D,0x39EE6B96,0x3A6E8B9E,0x3ADEABA6,0x3B5EC7AD,0x3BDEE7B5,0x3C5F07BD,
|
||||
0x3CCF23C5,0x3D4F43CC,0x3DBF5FD4,0x3E2F7FDB,0x3EAF9BE2,0x3F1FB7EA,0x3F8FD3F1,0x3FFFEFF8
|
||||
};
|
||||
|
||||
#if 0
|
||||
const uint32 gamma2p2_tbl[] = {
|
||||
0x09A1C400,0x0D42E89A,0x0FF3A8D4,0x122444FF,0x1414C922,0x15D53D41,0x1765A95D,0x18E60976,
|
||||
0x1A36658E,0x1B86B9A3,0x1CB709B8,0x1DE755CB,0x1F079DDE,0x2017E1F0,0x21182601,0x22186611,
|
||||
0x2308A221,0x23F8DE30,0x24D91A3F,0x25B9524D,0x26898A5B,0x2769BE68,0x2829F276,0x28FA2682,
|
||||
0x29BA568F,0x2A7A869B,0x2B3AB6A7,0x2BFAE6B3,0x2CAB12BF,0x2D5B3ECA,0x2E0B6AD5,0x2EBB96E0,
|
||||
0x2F5BC2EB,0x2FFBEAF5,0x30AC12FF,0x314C3F0A,0x31DC6714,0x327C8B1D,0x331CB327,0x33ACDB31,
|
||||
0x344CFF3A,0x34DD2344,0x356D474D,0x35FD6B56,0x368D8F5F,0x370DB368,0x379DD770,0x382DF779,
|
||||
0x38AE1B82,0x392E3B8A,0x39BE5F92,0x3A3E7F9B,0x3ABE9FA3,0x3B3EBFAB,0x3BBEDFB3,0x3C3EFFBB,
|
||||
0x3CBF1FC3,0x3D2F3BCB,0x3DAF5BD2,0x3E1F7BDA,0x3E9F97E1,0x3F0FB7E9,0x3F8FD3F0,0x3FFFEFF8
|
||||
};
|
||||
#else
|
||||
// BT 709 gamma 20/9=2.222...
|
||||
const uint32 gamma2p2_tbl[] = {
|
||||
0x04809000,0x0871A848,0x0B628087,0x0DD32CB6,0x1003BCDD,0x11E43D00,0x13A4B11E,0x15451D3A,
|
||||
0x16C58154,0x1825DD6C,0x19863582,0x1AC68998,0x1BF6D9AC,0x1D2725BF,0x1E476DD2,0x1F57B5E4,
|
||||
0x2067F9F5,0x21683A06,0x22687A16,0x2358B626,0x2448F235,0x25292E44,0x26096652,0x26E99E60,
|
||||
0x27B9D26E,0x288A0A7B,0x295A3E88,0x2A2A6E95,0x2AEAA2A2,0x2BAAD2AE,0x2C6B02BA,0x2D2B32C6,
|
||||
0x2DDB5ED2,0x2E8B8EDD,0x2F4BBAE8,0x2FFBE6F4,0x309C12FF,0x314C3F09,0x31EC6714,0x329C931E,
|
||||
0x333CBB29,0x33DCE333,0x347D0B3D,0x351D3347,0x35AD5751,0x364D7F5A,0x36DDA364,0x376DCB6D,
|
||||
0x380DEF76,0x389E1380,0x392E3789,0x39BE5B92,0x3A4E7F9B,0x3ACEA3A4,0x3B5EC7AC,0x3BDEE7B5,
|
||||
0x3C6F0BBD,0x3CEF2BC6,0x3D7F4BCE,0x3DFF6FD7,0x3E7F8FDF,0x3EFFAFE7,0x3F7FCFEF,0x3FFFEFF7
|
||||
};
|
||||
#endif
|
||||
|
||||
const uint32 gamma1p8_tbl[] = {
|
||||
0x06511400,0x0951FC65,0x0BB2A495,0x0DB330BB,0x0F83A8DB,0x113418F8,0x12B47D13,0x1424DD2B,
|
||||
0x15853542,0x16D58D58,0x1815DD6D,0x19462981,0x1A667594,0x1B86BDA6,0x1C9701B8,0x1DA745C9,
|
||||
0x1EA789DA,0x1FA7C9EA,0x209805FA,0x21884609,0x22787E18,0x2358BA27,0x2438F235,0x25192A43,
|
||||
0x25F96251,0x26C99A5F,0x2799CE6C,0x286A0279,0x293A3686,0x2A0A6693,0x2ACA9AA0,0x2B8ACAAC,
|
||||
0x2C4AFAB8,0x2D0B2AC4,0x2DCB5AD0,0x2E7B86DC,0x2F3BB6E7,0x2FEBE2F3,0x309C0EFE,0x314C3B09,
|
||||
0x31FC6714,0x32AC931F,0x334CBF2A,0x33FCE734,0x349D133F,0x354D3B49,0x35ED6754,0x368D8F5E,
|
||||
0x372DB768,0x37CDDF72,0x386E077C,0x390E2F86,0x399E5390,0x3A3E7B99,0x3ACEA3A3,0x3B6EC7AC,
|
||||
0x3BFEEFB6,0x3C9F13BF,0x3D2F37C9,0x3DBF5BD2,0x3E4F83DB,0x3EDFA7E4,0x3F6FCBED,0x3FFFEFF6
|
||||
};
|
||||
|
||||
|
||||
// 预设的Gamma曲线和对应的BV值
|
||||
const _Sensor_YGAMMA y_gamma_tbl[NUM_CURVES] = {
|
||||
{
|
||||
.bv = 3.4028235e+38,
|
||||
.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,}}
|
||||
};
|
||||
|
||||
|
||||
uint32 gamma_table_addr[3] = {(uint32)gamma1p8_tbl, (uint32)gamma2p2_tbl, (uint32)gamma2p4_tbl};
|
||||
75
sdk/lib/video/isp/isp_infra.c
Normal file
75
sdk/lib/video/isp/isp_infra.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
|
||||
//luma_ca mode0
|
||||
const uint32 luma_ca_lut_mode0[] = {0x0000,0x0000,0x0000,0x0000,0x0100,0x0200,0x0300,0x0500,0x0600,0x0900,0x0B00,0x0E00,0x1100,0x1400,0x1700,0x1A00,
|
||||
0x1E00,0x2200,0x2600,0x2A00,0x2E00,0x3300,0x3700,0x3B00,0x4000,0x4500,0x4900,0x4E00,0x5200,0x5700,0x5B00,0x5F00,
|
||||
0x6300,0x6700,0x6B00,0x6F00,0x7200,0x7500,0x7800,0x7B00,0x7D00,0x7F00,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,
|
||||
0x8000,0x8000,0x8000,0x8000,0x7E00,0x7B00,0x7700,0x7200,0x6D00,0x6700,0x6100,0x5B00,0x5400,0x4E00,0x4700,0x4000,
|
||||
0x3900,0x3300,0x2C00,0x2600,0x2000,0x1A00,0x1500,0x1100,0x0C00,0x0900,0x0500,0x0300,0x0100,0x0000,0x0000,0x0000};
|
||||
|
||||
//luma_ca_mode1
|
||||
//color_pattern == 0, Iron
|
||||
const uint32 luma_ca_lut_iron[] = {0x11867F,0x138D7E,0x14927D,0x15957D,0x15987C,0x169B7C,0x179E7B,0x17A17B,0x18A47A,0x19A67A,0x19A77A,0x1AA97B,0x1BAA7B,0x1BAC7B,0x1CAD7C,0x1DAF7C,
|
||||
0x1EB07C,0x1EB17D,0x1FB27D,0x20B27E,0x20B27F,0x22B380,0x22B482,0x23B483,0x25B584,0x25B685,0x27B587,0x28B688,0x29B689,0x2AB68B,0x2BB78C,0x2CB68E,
|
||||
0x2CB78E,0x2DB790,0x2EB791,0x2FB892,0x30B893,0x30B894,0x31B795,0x32B796,0x33B797,0x33B698,0x34B69A,0x35B69B,0x36B69D,0x37B69D,0x37B69F,0x39B5A0,
|
||||
0x39B5A1,0x3AB5A3,0x3BB5A4,0x3CB4A5,0x3CB4A6,0x3DB4A7,0x3EB3A9,0x3EB3AA,0x3FB3AB,0x40B2AD,0x41B2AE,0x41B1AF,0x42B1B0,0x43B1B1,0x43B0B2,0x44AFB4,
|
||||
0x45AFB5,0x46AEB6,0x46AEB8,0x47ADB9,0x47ADB9,0x48ADBB,0x49ACBC,0x49ACBD,0x4AABBE,0x4AABBF,0x4AAABF,0x4BAAC0,0x4CA9C1,0x4DA8C2,0x4DA8C2,0x4DA8C3,
|
||||
0x4EA7C4,0x4EA6C4,0x4FA5C5,0x50A5C5,0x50A5C6,0x51A3C6,0x51A3C7,0x52A2C7,0x52A2C7,0x53A1C7,0x54A0C7,0x559FC7,0x569EC7,0x569DC8,0x579CC8,0x589AC8,
|
||||
0x5999C8,0x5A98C9,0x5B97C9,0x5C95C9,0x5D94C8,0x5D92C9,0x5E90C9,0x5F8EC9,0x5F8DC9,0x608BC9,0x6189C9,0x6288C9,0x6385C9,0x6483C9,0x6481C9,0x657FC9,
|
||||
0x677CC9,0x687BC9,0x6878C9,0x6975CA,0x6A72CA,0x6A6FCA,0x6A6CCA,0x6B69CA,0x6B66CA,0x6C63CA,0x6C60CA,0x6D5DCB,0x6D5ACB,0x6F57CA,0x6F56CA,0x7055C9,
|
||||
0x7152CA,0x7251C9,0x734FC9,0x734EC9,0x744DC9,0x754CC9,0x764BC9,0x774AC8,0x7749C8,0x7948C7,0x7A47C7,0x7A46C7,0x7B45C6,0x7C44C6,0x7C44C6,0x7E43C6,
|
||||
0x7F42C5,0x8041C5,0x8041C4,0x8240C4,0x8240C4,0x833FC3,0x843EC3,0x843EC2,0x853DC2,0x863DC2,0x873CC1,0x883BC1,0x893AC1,0x8A3AC0,0x8B39BF,0x8C39BF,
|
||||
0x8D38BE,0x8E37BE,0x8F37BD,0x9036BD,0x9135BC,0x9235BC,0x9334BB,0x9434BB,0x9533BB,0x9533BA,0x9633B9,0x9732BA,0x9832B9,0x9931B8,0x9A31B8,0x9A30B7,
|
||||
0x9B30B7,0x9D2FB7,0x9E2EB6,0x9F2DB5,0xA12CB4,0xA22CB3,0xA32BB4,0xA42BB3,0xA52AB2,0xA629B1,0xA729B0,0xA828AF,0xA928AF,0xAA27AF,0xAB27AE,0xAB26AE,
|
||||
0xAC26AD,0xAE25AC,0xAE25AC,0xAF24AB,0xB024AA,0xB123AA,0xB222A9,0xB322A8,0xB421A7,0xB521A7,0xB620A6,0xB720A6,0xB720A5,0xB820A5,0xB920A4,0xB920A4,
|
||||
0xBA20A3,0xBB20A2,0xBD21A1,0xBE21A1,0xBF21A0,0xC0219F,0xC1219F,0xC1229E,0xC2239E,0xC3249D,0xC4259C,0xC6279B,0xC6289B,0xC7299A,0xC92A99,0xCA2D98,
|
||||
0xCB2F98,0xCC3197,0xCD3396,0xCE3595,0xCF3894,0xD13A93,0xD23C92,0xD33F92,0xD44191,0xD54490,0xD6478F,0xD74A8F,0xD84D8E,0xD9518D,0xDB538C,0xDB568B,
|
||||
0xDD598B,0xDD5C8A,0xDE5F89,0xE06188,0xE16488,0xE16687,0xE26987,0xE36A86,0xE46D85,0xE56F84,0xE67284,0xE77483,0xE87682,0xE97882,0xE97A81,0xEA7C81};
|
||||
//color_pattern == 1, Glowbow
|
||||
const uint32 luma_ca_lut_glowbow[] = {0x118081,0x127F82,0x137F84,0x147F84,0x157F86,0x167E87,0x177E89,0x187E89,0x197D8B,0x1B7D8C,0x1B7D8D,0x1C7C8E,0x1E7C8F,0x1F7C91,0x1F7C92,0x207B93,
|
||||
0x227B95,0x237A96,0x247A97,0x257A98,0x267A99,0x27799A,0x28799C,0x29799D,0x2A789E,0x2B78A0,0x2C78A1,0x2E77A3,0x3076A5,0x3176A7,0x3376A8,0x3476AA,
|
||||
0x3575AB,0x3675AB,0x3775AD,0x3874AE,0x3974AF,0x3B73B1,0x3B73B2,0x3C73B4,0x3D73B4,0x3E72B6,0x3F72B7,0x4072B8,0x4272B9,0x4271BA,0x4471BB,0x4570BD,
|
||||
0x4570BE,0x4670BF,0x4870C1,0x4970C2,0x4A6FC4,0x4B6FC4,0x4C6EC5,0x4D6EC7,0x4E6EC8,0x4F6EC9,0x506DCA,0x516DCB,0x526DCD,0x546CCE,0x546CCF,0x556BCF,
|
||||
0x566ACF,0x566ACF,0x5769CE,0x5868CF,0x5868CF,0x5967CF,0x5A66CF,0x5A66CF,0x5B65CF,0x5C64CE,0x5D63CF,0x5D63CF,0x5E62CF,0x5E62CF,0x5F61CE,0x5F60CF,
|
||||
0x615FCE,0x615ECF,0x625ECF,0x635DCF,0x635DCF,0x645CCF,0x655BCF,0x655ACE,0x665ACE,0x6659CF,0x6759CF,0x6858CF,0x6857CE,0x6956CE,0x6A56CE,0x6B55CE,
|
||||
0x6C54CF,0x6C54CE,0x6D53CE,0x6E52CE,0x6E52CE,0x6F51CE,0x6F50CE,0x714FCE,0x714FCF,0x714ECE,0x724DCE,0x734DCE,0x734CCF,0x744BCE,0x754BCE,0x764ACE,
|
||||
0x7649CE,0x7649CE,0x7749CE,0x7847CF,0x7946CE,0x7A46CE,0x7A45CE,0x7B44CE,0x7B44CE,0x7C44CE,0x7D43CE,0x7D42CE,0x7E41CE,0x7F40CE,0x7F40CF,0x803FCE,
|
||||
0x813FCD,0x823ECC,0x833DCC,0x843DCB,0x853CCA,0x863CC9,0x873BC9,0x883AC8,0x893AC8,0x8A39C6,0x8B39C6,0x8C38C5,0x8D38C5,0x8E37C4,0x8F37C3,0x9036C2,
|
||||
0x9235C1,0x9335C1,0x9334C0,0x9434BF,0x9533BF,0x9633BE,0x9732BD,0x9831BD,0x9931BC,0x9A31BB,0x9B30BA,0x9C2FBA,0x9D2FB9,0x9E2EB8,0x9F2DB7,0xA02DB7,
|
||||
0xA12DB6,0xA22CB6,0xA32BB5,0xA42BB4,0xA52AB3,0xA62AB3,0xA729B2,0xA828B1,0xA928B0,0xAA27B0,0xAB27AF,0xAC26AE,0xAC26AE,0xAD25AD,0xAF24AC,0xB024AB,
|
||||
0xB123AA,0xB223AA,0xB222A9,0xB322A9,0xB521A8,0xB521A7,0xB620A6,0xB71FA6,0xB81FA5,0xB91EA4,0xBA1EA4,0xBC1DA2,0xBC1DA2,0xBD1CA1,0xBE1BA1,0xBF1BA0,
|
||||
0xC01CA0,0xC11E9F,0xC11F9F,0xC2219E,0xC3229D,0xC4249D,0xC4259C,0xC5279C,0xC5299B,0xC62A9B,0xC72C9B,0xC82D9A,0xC82F9A,0xC93199,0xCA3298,0xCB3498,
|
||||
0xCB3597,0xCB3797,0xCC3896,0xCD3A96,0xCD3B96,0xCE3D95,0xCF3F95,0xD04094,0xD14193,0xD14393,0xD14593,0xD24792,0xD34892,0xD44A91,0xD44B90,0xD54D90,
|
||||
0xD64E90,0xD7508F,0xD7518F,0xD8538E,0xD8548E,0xD9568D,0xDA588D,0xDA598D,0xDB5B8C,0xDC5C8B,0xDD5E8B,0xDD5F8A,0xDE618A,0xDE6389,0xDF6489,0xDF6688,
|
||||
0xE06788,0xE16988,0xE26A87,0xE36C86,0xE36E85,0xE46F85,0xE47185,0xE57284,0xE67484,0xE67683,0xE77783,0xE87982,0xE97A82,0xE97B81,0xEA7E81,0xEB7F80};
|
||||
//color_pattern == 2, Rainbow
|
||||
const uint32 luma_ca_lut_rainbow[] = {0x1C9D78,0x1B9E78,0x1B9E78,0x1B9E78,0x1B9E78,0x1B9F78,0x1CA077,0x1DA177,0x1DA377,0x1EA476,0x20A474,0x22A473,0x24A471,0x26A470,0x28A56E,0x2AA66D,
|
||||
0x2BA76C,0x2EA76A,0x30A869,0x32A967,0x34AA66,0x34AB65,0x36AC65,0x36AC64,0x37AD64,0x38AE63,0x39AE62,0x3AAE62,0x3AAF61,0x3BAF61,0x3CB060,0x3EB15F,
|
||||
0x3FB25E,0x40B25D,0x42B35C,0x42B45B,0x43B65B,0x44B75A,0x46B859,0x47B858,0x48B957,0x49BA56,0x4ABB56,0x4BBB55,0x4CBC54,0x4EBB53,0x4EBC53,0x50BC51,
|
||||
0x51BC50,0x52BE50,0x53BE4F,0x54BE4E,0x54C04E,0x55C04E,0x56C04E,0x57C04D,0x58C04C,0x59C04B,0x59C04B,0x5AC04A,0x5BBF49,0x5CBF48,0x5DBF48,0x5EBE47,
|
||||
0x5FBE47,0x5FBD47,0x60BC46,0x61BA46,0x62B944,0x62B844,0x64B643,0x64B543,0x65B242,0x66AF41,0x67AC41,0x67AA41,0x67A740,0x68A541,0x68A241,0x689F42,
|
||||
0x699A42,0x699743,0x699444,0x6B9145,0x6B8E45,0x6B8B46,0x6C8748,0x6D8249,0x6F7C4B,0x70784D,0x727450,0x736F52,0x756A54,0x776557,0x796059,0x7C5C5C,
|
||||
0x7E585E,0x815560,0x825261,0x854D63,0x864A65,0x884768,0x8A4469,0x8C416B,0x8D406C,0x8E3E6D,0x903D6E,0x923B70,0x953872,0x963674,0x983575,0x9A3377,
|
||||
0x9B3179,0x9D2F7A,0x9F2E7C,0x9F2D7D,0xA12C7F,0xA22C80,0xA42B81,0xA62A83,0xA72985,0xA82886,0xAA2787,0xAB2788,0xAD2689,0xAE258A,0xAF248B,0xB0248C,
|
||||
0xB1248E,0xB22390,0xB22391,0xB32293,0xB42294,0xB42195,0xB52196,0xB52197,0xB52298,0xB52298,0xB52298,0xB52298,0xB5239A,0xB5239A,0xB5249B,0xB4249C,
|
||||
0xB4259E,0xB2269F,0xB327A0,0xB226A0,0xB227A0,0xB127A1,0xB028A2,0xB028A4,0xB029A4,0xAF29A5,0xAF29A7,0xAD2BA8,0xAB2DA9,0xAB2EAA,0xA92FAB,0xA831AC,
|
||||
0xA632AD,0xA432AE,0xA332AF,0xA234B0,0xA234B1,0xA135B2,0x9F36B3,0x9E38B4,0x9C39B5,0x9B3AB6,0x983CB7,0x963FB9,0x9441BA,0x9244BD,0x8F46BF,0x8D46C0,
|
||||
0x8948C3,0x864AC5,0x844CC5,0x824EC7,0x8051CA,0x7E54CC,0x7B57CE,0x7859CF,0x755CD1,0x725ED2,0x7060D5,0x6E62D7,0x6B64D9,0x6966DA,0x6868DB,0x6768DB,
|
||||
0x6868DB,0x6768DB,0x6769DB,0x6869DA,0x696ADB,0x696BDB,0x696CDA,0x6A6DDB,0x6A6DDB,0x696EDA,0x696FD9,0x696FD9,0x6871D7,0x6872D7,0x6873D6,0x6974D6,
|
||||
0x6975D6,0x6976D5,0x6A77D6,0x6C76D5,0x6E76D5,0x7275D4,0x7474D2,0x7873CF,0x7C72CD,0x7F71CA,0x8270C8,0x846FC6,0x876EC4,0x8A6DC2,0x8B6DC1,0x8D6DC0,
|
||||
0x8F6DBE,0x926EBD,0x946EBC,0x966DB9,0x996DB7,0x9B6EB5,0x9E6EB3,0xA16EB1,0xA46DAF,0xA66DAD,0xAA6CAB,0xAD6BA9,0xB06CA6,0xB36CA4,0xB56BA2,0xB86BA0,
|
||||
0xBB6B9E,0xBC6C9D,0xBF6D9B,0xC16C9A,0xC36C98,0xC66C97,0xC86C95,0xCB6D93,0xCD6F91,0xCF7190,0xD0728F,0xD3738E,0xD4738D,0xD6728B,0xD7738A,0xD9728A};
|
||||
|
||||
uint32 luma_ca_addr[] = {(uint32)luma_ca_lut_mode0, (uint32)luma_ca_lut_iron, (uint32)luma_ca_lut_glowbow, (uint32)luma_ca_lut_rainbow};
|
||||
295
sdk/lib/video/isp/isp_ircut.c
Normal file
295
sdk/lib/video/isp/isp_ircut.c
Normal file
@@ -0,0 +1,295 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "lib/video/dvp/cmos_sensor/csi.h"
|
||||
#include "lib/video/dvp/cmos_sensor/csi_V2.h"
|
||||
#include "devid.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/isp.h"
|
||||
#include "hal/i2c.h"
|
||||
#include "osal/irq.h"
|
||||
#include "osal/string.h"
|
||||
#include "dev/vpp/hgvpp.h"
|
||||
#include "dev/csi/hgdvp.h"
|
||||
#include "lib/lcd/lcd.h"
|
||||
#include "hal/jpeg.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "lib/video/isp/isp_ircut.h"
|
||||
|
||||
#ifdef PIN_FROM_PARAM
|
||||
#include "pin_param.h"
|
||||
#endif
|
||||
#include "syscfg.h"
|
||||
|
||||
IRCUT_INFO ircut_info;
|
||||
|
||||
|
||||
void irled_control(uint8 led_state)
|
||||
{
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_LED), led_state);
|
||||
}
|
||||
|
||||
void whiteled_control(uint8 led_state)
|
||||
{
|
||||
gpio_set_val(MACRO_PIN(PIN_WHITE_LED), led_state);
|
||||
}
|
||||
|
||||
void ircut_control(IRCUT_INFO *info)
|
||||
{
|
||||
switch (info->ircut_opt_status)
|
||||
{
|
||||
case IRCUT_OPT_STATE_ON:
|
||||
if (info->ircut_status == IRCUT_OFF)
|
||||
{
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 1);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 0);
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_SW_OFF;
|
||||
}
|
||||
break;
|
||||
|
||||
case IRCUT_OPT_STATE_OFF:
|
||||
if (info->ircut_status == IRCUT_ON)
|
||||
{
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 0);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 1);
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_SW_ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case IRCUT_OPT_STATE_IDLE:
|
||||
if (info->ircut_status == IRCUT_ON)
|
||||
{
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 0);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 1);
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_SW_ON;
|
||||
} else if (info->ircut_status == IRCUT_OFF) {
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 1);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 0);
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_SW_ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case IRCUT_OPT_STATE_SW_ON:
|
||||
if (++info->frame_cnt >= info->frame_to_switch)
|
||||
{
|
||||
info->frame_cnt = 0;
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 0);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 0);
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_ON;
|
||||
info->action_status = IRCUT_ACTION_STOP;
|
||||
}
|
||||
break;
|
||||
|
||||
case IRCUT_OPT_STATE_SW_OFF:
|
||||
if (++info->frame_cnt >= info->frame_to_switch)
|
||||
{
|
||||
info->frame_cnt = 0;
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 0);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 0);
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_OFF;
|
||||
info->action_status = IRCUT_ACTION_STOP;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
info->ircut_opt_status = IRCUT_OPT_STATE_OFF;
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 0);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ircut_action(struct os_work *work)
|
||||
{
|
||||
switch (ircut_info.irled_detect_mode)
|
||||
{
|
||||
case IRCUT_DET_MODE_HW:
|
||||
if (ircut_info.irdet_gpio_en)
|
||||
{
|
||||
ircut_info.irdet_status = gpio_get_val(MACRO_PIN(PIN_IRCUT_DETECT));
|
||||
if (ircut_info.irdet_status && (ircut_info.irled_status == IRLED_OFF)) {
|
||||
if (++ircut_info.switch_cnt >= ircut_info.switch_max)
|
||||
{
|
||||
ircut_info.switch_cnt = 0;
|
||||
ircut_info.whiteled_status = WHITELED_ON;
|
||||
ircut_info.irled_status = IRLED_ON;
|
||||
ircut_info.ircut_status = IRCUT_OFF;
|
||||
ircut_info.action_status = IRCUT_ACTION_START;
|
||||
isp_black_white_enable(ircut_info.dev, ircut_info.irled_status, SENSOR_TYPE_MASTER);
|
||||
}
|
||||
} else if (!ircut_info.irdet_status && (ircut_info.irled_status == IRLED_ON)) {
|
||||
if (++ircut_info.switch_cnt >= ircut_info.switch_max)
|
||||
{
|
||||
ircut_info.switch_cnt = 0;
|
||||
ircut_info.whiteled_status = WHITELED_OFF;
|
||||
ircut_info.irled_status = IRLED_OFF;
|
||||
ircut_info.ircut_status = IRCUT_ON;
|
||||
ircut_info.action_status = IRCUT_ACTION_START;
|
||||
isp_black_white_enable(ircut_info.dev, ircut_info.irled_status, SENSOR_TYPE_MASTER);
|
||||
}
|
||||
} else {
|
||||
ircut_info.switch_cnt = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IRCUT_DET_MODE_SW:
|
||||
{
|
||||
ISP_IRCUT_STAT isp_stat;
|
||||
isp_get_isp_ircut_statistics(ircut_info.dev,&isp_stat,SENSOR_TYPE_MASTER);
|
||||
|
||||
// os_printf("r_mean=%d g_mean=%d b_mean=%d \r\n",isp_stat.r_mean,isp_stat.g_mean,isp_stat.b_mean);
|
||||
//
|
||||
// os_printf("sat=%d bv=%f \r\n",isp_stat.saturation,isp_stat.curr_bv);
|
||||
|
||||
switch (ircut_info.sw_state)
|
||||
{
|
||||
//Status 1: from day to night
|
||||
case IRCUT_STAT_DAY_TO_NIGHT:
|
||||
{
|
||||
if (isp_stat.curr_bv < ircut_info.to_night_bv){
|
||||
ircut_info.switch_cnt++;
|
||||
if (ircut_info.switch_cnt >= ircut_info.switch_max ){
|
||||
ircut_info.switch_cnt = 0;
|
||||
ircut_info.whiteled_status = WHITELED_ON;
|
||||
ircut_info.irled_status = IRLED_ON;
|
||||
ircut_info.ircut_status = IRCUT_OFF;
|
||||
ircut_info.action_status = IRCUT_ACTION_START;
|
||||
isp_black_white_enable(ircut_info.dev, ircut_info.irled_status, SENSOR_TYPE_MASTER);
|
||||
isp_awb_measure_mode_config(ircut_info.dev, AWB_MEAS_MODE_RGB, SENSOR_TYPE_MASTER);
|
||||
ircut_info.sw_state = IRCUT_STAT_WB_REC;
|
||||
}
|
||||
}else{
|
||||
ircut_info.switch_cnt = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// State 2: Save stable white balance statistics
|
||||
case IRCUT_STAT_WB_REC:
|
||||
{
|
||||
ircut_info.switch_cnt++;
|
||||
if (ircut_info.switch_cnt >= 20){//after one second
|
||||
ircut_info.switch_cnt = 0;
|
||||
//os_printf("REC r_gain=%d b_gain=%d \r\n",isp_stat.r_gain,isp_stat.b_gain);
|
||||
ircut_info.last_r_gain = isp_stat.r_gain;
|
||||
ircut_info.last_b_gain = isp_stat.b_gain;
|
||||
ircut_info.sw_state = IRCUT_STAT_NIGHT_TO_DAY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//Status 3: from night to day
|
||||
case IRCUT_STAT_NIGHT_TO_DAY:
|
||||
{
|
||||
uint16 diff_r_gain = IR_ABS(isp_stat.r_gain - ircut_info.last_r_gain);
|
||||
uint16 diff_b_gain = IR_ABS(isp_stat.b_gain - ircut_info.last_b_gain);
|
||||
//os_printf("diff_r_gain=%d diff_b_gain=%d \r\n",diff_r_gain,diff_b_gain);
|
||||
if (((isp_stat.curr_bv > ircut_info.to_day_bv) &&(isp_stat.saturation > ircut_info.to_day_sat)
|
||||
&& ((diff_r_gain + diff_b_gain) > ircut_info.to_day_diff_rb_gain || diff_b_gain > ircut_info.to_day_diff_b_gain))
|
||||
|| ((isp_stat.saturation > ircut_info.to_day_sat) && (isp_stat.curr_bv > ircut_info.to_day_bv_max))){
|
||||
ircut_info.switch_cnt++;
|
||||
if (ircut_info.switch_cnt >= ircut_info.switch_max)
|
||||
{
|
||||
ircut_info.switch_cnt = 0;
|
||||
ircut_info.whiteled_status = WHITELED_OFF;
|
||||
ircut_info.irled_status = IRLED_OFF;
|
||||
ircut_info.ircut_status = IRCUT_ON;
|
||||
ircut_info.action_status = IRCUT_ACTION_START;
|
||||
isp_black_white_enable(ircut_info.dev, ircut_info.irled_status, SENSOR_TYPE_MASTER);
|
||||
isp_awb_measure_mode_config(ircut_info.dev, AWB_MEAS_MODE_YUV_NEW, SENSOR_TYPE_MASTER);
|
||||
ircut_info.sw_state = IRCUT_STAT_DAY_TO_NIGHT;
|
||||
}
|
||||
}else{
|
||||
ircut_info.switch_cnt = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRCUT_DET_MODE_MANUAL:
|
||||
ircut_info.action_status = IRCUT_ACTION_STOP;
|
||||
break;
|
||||
|
||||
default :
|
||||
os_printf(KERN_ERR"ircut detect mode : %d err", ircut_info.irled_detect_mode);
|
||||
}
|
||||
|
||||
if (ircut_info.action_status)
|
||||
{
|
||||
if (ircut_info.ircut_gpio_en) ircut_control(&ircut_info);
|
||||
if (ircut_info.irled_gpio_en) irled_control(ircut_info.irled_status);
|
||||
//if (ircut_info.whiteled_gpio_en) whiteled_control(ircut_info.whiteled_status);
|
||||
}
|
||||
|
||||
os_run_work_delay(&ircut_info.ircut_action_work, 50);
|
||||
}
|
||||
|
||||
void ircut_init()
|
||||
{
|
||||
os_memset(&ircut_info, 0, sizeof(IRCUT_INFO));
|
||||
ircut_info.dev = (struct isp_device *)dev_get(HG_ISP_DEVID);
|
||||
if (ircut_info.dev == NULL)
|
||||
{
|
||||
os_printf(KERN_ERR"ircut get isp device err!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ircut_info.frame_cnt = 0;
|
||||
ircut_info.frame_to_switch = 3;
|
||||
ircut_info.switch_cnt = 0;
|
||||
ircut_info.switch_max = 30;
|
||||
ircut_info.to_day_bv = 8000;
|
||||
ircut_info.to_night_bv = 3500;
|
||||
ircut_info.to_day_sat = 30;
|
||||
ircut_info.to_day_bv_max = 10000;
|
||||
ircut_info.to_day_diff_rb_gain = 45;
|
||||
ircut_info.to_day_diff_b_gain = 30;
|
||||
ircut_info.ircut_opt_status = IRCUT_OPT_STATE_IDLE;
|
||||
ircut_info.ircut_status = IRCUT_ON;
|
||||
ircut_info.irled_status = IRLED_OFF;
|
||||
ircut_info.irdet_status = IRDET_OFF;
|
||||
ircut_info.whiteled_status = WHITELED_OFF;
|
||||
ircut_info.action_status = IRCUT_ACTION_START;
|
||||
ircut_info.irled_detect_mode = IRCUT_DET_MODE_MANUAL;
|
||||
|
||||
if (MACRO_PIN(PIN_IRCUT_DETECT) != 255)
|
||||
{
|
||||
gpio_set_dir(MACRO_PIN(PIN_IRCUT_DETECT), GPIO_DIR_INPUT);
|
||||
ircut_info.irled_detect_mode = IRCUT_DET_MODE_HW;
|
||||
ircut_info.irdet_gpio_en = 1;
|
||||
} else {
|
||||
ircut_info.irdet_gpio_en = 0;
|
||||
}
|
||||
|
||||
if (MACRO_PIN(PIN_IRCUT_LED) != 255)
|
||||
{
|
||||
gpio_iomap_output(MACRO_PIN(PIN_IRCUT_LED), GPIO_IOMAP_OUTPUT);
|
||||
irled_control(ircut_info.irled_status);
|
||||
ircut_info.irled_gpio_en = 1;
|
||||
}
|
||||
|
||||
if (MACRO_PIN(PIN_WHITE_LED) != 255)
|
||||
{
|
||||
gpio_iomap_output(MACRO_PIN(PIN_WHITE_LED), GPIO_IOMAP_OUTPUT);
|
||||
whiteled_control(ircut_info.whiteled_status);
|
||||
ircut_info.whiteled_gpio_en = 1;
|
||||
}
|
||||
|
||||
if ((MACRO_PIN(PIN_IRCUT_IN1) != 255) && (MACRO_PIN(PIN_IRCUT_IN2) != 255))
|
||||
{
|
||||
gpio_iomap_output(MACRO_PIN(PIN_IRCUT_IN1), GPIO_IOMAP_OUTPUT);
|
||||
gpio_iomap_output(MACRO_PIN(PIN_IRCUT_IN2), GPIO_IOMAP_OUTPUT);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN1), 1);
|
||||
gpio_set_val(MACRO_PIN(PIN_IRCUT_IN2), 0);
|
||||
ircut_info.ircut_en = 1;
|
||||
ircut_info.ircut_gpio_en = 1;
|
||||
} else {
|
||||
ircut_info.ircut_en = 0;
|
||||
ircut_info.ircut_gpio_en = 0;
|
||||
}
|
||||
|
||||
if (ircut_info.ircut_en)
|
||||
{
|
||||
OS_WORK_INIT(&ircut_info.ircut_action_work, (void *)ircut_action, 0);
|
||||
os_run_work_delay(&ircut_info.ircut_action_work, 50);
|
||||
}
|
||||
}
|
||||
524
sdk/lib/video/isp/isp_param.c
Normal file
524
sdk/lib/video/isp/isp_param.c
Normal file
@@ -0,0 +1,524 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
#define ISP_DMA_ENABLE 1
|
||||
|
||||
const struct hgisp_param_info isp_master_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 1,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 2,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 32,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 0,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.exposure_alpha = 16,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 180,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 1,
|
||||
.abl_expo_line_low_ratio = 0,
|
||||
.abl_expo_line_high_ratio = 0,
|
||||
.abl_expo_gain_low_thr = 0,
|
||||
.abl_expo_gain_high_thr = 0,
|
||||
.aoe_expo_gain_thr[0] = 65535,
|
||||
.aoe_expo_gain_thr[1] = 65535,
|
||||
.abl_bv_thr[0] = 1e20,
|
||||
.abl_bv_thr[1] = 1e20,
|
||||
.aoe_bv_thr[0] = 0,
|
||||
.aoe_bv_thr[1] = 0,
|
||||
.abl_hist_thr[0] = 50, // hist
|
||||
.abl_hist_thr[1] = 236,
|
||||
.dark_pixel_low_ratio = 0.60,
|
||||
.dark_pixel_high_ratio = 0.90,
|
||||
.bright_pixel_high_ratio = 0.15,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50, // position
|
||||
.bright_pos_adjust_ratio = 0.90,
|
||||
.abl_dark_pos_low_wthr = 0.40 * 61,
|
||||
.abl_dark_pos_add_wthr = 0.10 * 61,
|
||||
.aoe_dark_pos_wthr = 0.60 * 61,
|
||||
.aoe_bright_pos_wthr = 0.20 * 61,
|
||||
.abl_luma_target_max = 100, // stable
|
||||
.abl_diff_ratio = 0.05,
|
||||
.abl_dark_pos_diff_thr = 0.15 * 61,
|
||||
.abl_bright_pos_diff_thr = 0.10 * 61,
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 20,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.dynamic_gamma_en = 0,
|
||||
.y_gamma_opt = 0,
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
const struct hgisp_param_info isp_slave0_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 0,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.exposure_alpha = 16,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 180,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 1,
|
||||
.abl_expo_line_low_ratio = 0,
|
||||
.abl_expo_line_high_ratio = 0,
|
||||
.abl_expo_gain_low_thr = 0,
|
||||
.abl_expo_gain_high_thr = 0,
|
||||
.aoe_expo_gain_thr[0] = 65535,
|
||||
.aoe_expo_gain_thr[1] = 65535,
|
||||
.abl_bv_thr[0] = 1e20,
|
||||
.abl_bv_thr[1] = 1e20,
|
||||
.aoe_bv_thr[0] = 0,
|
||||
.aoe_bv_thr[1] = 0,
|
||||
.abl_hist_thr[0] = 50, // hist
|
||||
.abl_hist_thr[1] = 236,
|
||||
.dark_pixel_low_ratio = 0.60,
|
||||
.dark_pixel_high_ratio = 0.90,
|
||||
.bright_pixel_high_ratio = 0.15,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50, // position
|
||||
.bright_pos_adjust_ratio = 0.90,
|
||||
.abl_dark_pos_low_wthr = 0.40 * 61,
|
||||
.abl_dark_pos_add_wthr = 0.10 * 61,
|
||||
.aoe_dark_pos_wthr = 0.60 * 61,
|
||||
.aoe_bright_pos_wthr = 0.20 * 61,
|
||||
.abl_luma_target_max = 100, // stable
|
||||
.abl_diff_ratio = 0.05,
|
||||
.abl_dark_pos_diff_thr = 0.15 * 61,
|
||||
.abl_bright_pos_diff_thr = 0.10 * 61,
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 20,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.dynamic_gamma_en = 0,
|
||||
.y_gamma_opt = 0,
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
const struct hgisp_param_info isp_slave1_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 32,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 1,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.exposure_alpha = 16,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 180,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 1,
|
||||
.abl_expo_line_low_ratio = 0,
|
||||
.abl_expo_line_high_ratio = 0,
|
||||
.abl_expo_gain_low_thr = 0,
|
||||
.abl_expo_gain_high_thr = 0,
|
||||
.aoe_expo_gain_thr[0] = 65535,
|
||||
.aoe_expo_gain_thr[1] = 65535,
|
||||
.abl_bv_thr[0] = 1e20,
|
||||
.abl_bv_thr[1] = 1e20,
|
||||
.aoe_bv_thr[0] = 0,
|
||||
.aoe_bv_thr[1] = 0,
|
||||
.abl_hist_thr[0] = 50, // hist
|
||||
.abl_hist_thr[1] = 236,
|
||||
.dark_pixel_low_ratio = 0.60,
|
||||
.dark_pixel_high_ratio = 0.90,
|
||||
.bright_pixel_high_ratio = 0.15,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50, // position
|
||||
.bright_pos_adjust_ratio = 0.90,
|
||||
.abl_dark_pos_low_wthr = 0.40 * 61,
|
||||
.abl_dark_pos_add_wthr = 0.10 * 61,
|
||||
.aoe_dark_pos_wthr = 0.60 * 61,
|
||||
.aoe_bright_pos_wthr = 0.20 * 61,
|
||||
.abl_luma_target_max = 100, // stable
|
||||
.abl_diff_ratio = 0.05,
|
||||
.abl_dark_pos_diff_thr = 0.15 * 61,
|
||||
.abl_bright_pos_diff_thr = 0.10 * 61,
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 20,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.dynamic_gamma_en = 0,
|
||||
.y_gamma_opt = 0,
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
void *isp_sensor_param_load(uint16 *buff)
|
||||
{
|
||||
struct hgisp_sensor_init *init = NULL;
|
||||
uint8 sensor_index = 0;
|
||||
uint32 data_offset = 0;
|
||||
uint32 param_size = buff[2] << 16 | buff[1];
|
||||
uint32 gamma_size = 256;
|
||||
uint32 lsc_size = 153*4*4;
|
||||
uint32 info_szie = sizeof(struct hgisp_sensor_info);
|
||||
uint32 sensor_param_size = (gamma_size << 1) + lsc_size + info_szie;
|
||||
init = (struct hgisp_sensor_init *)os_malloc(sizeof(struct hgisp_sensor_init));
|
||||
if (init)
|
||||
{
|
||||
os_memset(init, 0, sizeof(struct hgisp_sensor_init));
|
||||
sensor_index = buff[3];
|
||||
if (sensor_index && (param_size >= sensor_index * sensor_param_size))
|
||||
{
|
||||
data_offset = 4;
|
||||
for (int i = 0; i < sensor_index; i++)
|
||||
{
|
||||
if (buff[data_offset+2] == ISPCFG_MAGIC)
|
||||
{
|
||||
os_memcpy((void *)&init->sensor_info[i], (void *)&buff[data_offset], info_szie);
|
||||
init->sensor_info[i].info_src = ISP_INFO_SRC_TYPE_CODE_PARAM;
|
||||
data_offset += (info_szie >> 1);
|
||||
// init->sensor_info[i].sensor_param.y_gamma.local_ygamma_map = (_Sensor_YGAMMA *)&buff[data_offset];
|
||||
// data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.rgb_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.lsc_tbl = (uint32 *)&buff[data_offset];
|
||||
data_offset += (lsc_size >> 1);
|
||||
} else {
|
||||
os_printf("param_data flash : %04x target : %04x err!\r\n", buff[data_offset], ISPCFG_MAGIC);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
os_printf("sensor param use flash_param!\r\n");
|
||||
goto _end;
|
||||
} else {
|
||||
os_printf("param_size : %d calc_size : %d\r\n", param_size, sensor_index * sensor_param_size);
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
os_printf("%s malloc sram size : %d err!\r\n", sizeof(struct hgisp_sensor_init));
|
||||
}
|
||||
return (void *)NULL;
|
||||
|
||||
|
||||
_err:
|
||||
os_printf("sensor param use default param!\r\n");
|
||||
init->sensor_info[0].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[1].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[2].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
os_memcpy((void *)&init->sensor_info[0].sensor_param, (void *)&isp_master_param, sizeof(struct hgisp_param_info));
|
||||
os_memcpy((void *)&init->sensor_info[1].sensor_param, (void *)&isp_slave0_param, sizeof(struct hgisp_param_info));
|
||||
os_memcpy((void *)&init->sensor_info[2].sensor_param, (void *)&isp_slave1_param, sizeof(struct hgisp_param_info));
|
||||
_end:
|
||||
return (void *)init;
|
||||
}
|
||||
|
||||
|
||||
221
sdk/lib/video/isp/isp_param_2053_f2p2_dri.c
Normal file
221
sdk/lib/video/isp/isp_param_2053_f2p2_dri.c
Normal file
@@ -0,0 +1,221 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
#define ISP_DMA_ENABLE 1
|
||||
|
||||
const struct hgisp_param_info isp_master_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 0,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 0,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 6 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 2,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 8,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 1,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 610,
|
||||
.luma_weight = { 20, 20, 20, 20, 20,//100
|
||||
20, 30, 30, 30, 20,//130
|
||||
20, 30, 50, 30, 20,//150
|
||||
20, 30, 30, 30, 20,//130
|
||||
20, 20, 20, 20, 20},//100
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 1,
|
||||
.lowlight_lsb_gain_4hi_fps = 64, // lowlight_lsb_gain_en==0 ? 16 : 64
|
||||
.lowlight_lsb_gain_4lo_fps = 64, // lowlight_lsb_gain_en==0 ? 16 : 64
|
||||
.hist_hs_bin_thr = 224,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_gain_low_thr = 260,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 6645, // 80lx
|
||||
.abl_bv_thr[1] = 13216, // 160lx
|
||||
.aoe_bv_thr[0] = 3531, // 40lx
|
||||
.aoe_bv_thr[1] = 6645, // 80lx
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_luma_target_max = 100,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 0,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.dynamic_gamma_en = 0,
|
||||
.y_gamma_opt = 0,
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
#define SENSOR_PARAM_SIZE (64*4*2+153*4*4)
|
||||
|
||||
void *isp_sensor_param_load(uint16 *buff)
|
||||
{
|
||||
struct hgisp_sensor_init *init = NULL;
|
||||
uint8 sensor_index = 0;
|
||||
uint32 data_offset = 0;
|
||||
uint32 param_size = buff[2] << 16 | buff[1];
|
||||
uint32 gamma_size = 256;
|
||||
uint32 lsc_size = 153*4*4;
|
||||
uint32 info_szie = sizeof(struct hgisp_sensor_info);
|
||||
uint32 sensor_param_size = (gamma_size << 1) + lsc_size + info_szie;
|
||||
init = (struct hgisp_sensor_init *)os_malloc(sizeof(struct hgisp_sensor_init));
|
||||
if (init)
|
||||
{
|
||||
os_memset(init, 0, sizeof(struct hgisp_sensor_init));
|
||||
sensor_index = buff[3];
|
||||
if (sensor_index && (param_size >= sensor_index * sensor_param_size))
|
||||
{
|
||||
data_offset = 4;
|
||||
for (int i = 0; i < sensor_index; i++)
|
||||
{
|
||||
if (buff[data_offset+2] == ISPCFG_MAGIC)
|
||||
{
|
||||
os_memcpy((void *)&init->sensor_info[i], (void *)&buff[data_offset], info_szie);
|
||||
init->sensor_info[i].info_src = ISP_INFO_SRC_TYPE_CODE_PARAM;
|
||||
data_offset += (info_szie >> 1);
|
||||
init->sensor_info[i].sensor_param.y_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.rgb_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.lsc_tbl = (uint32 *)&buff[data_offset];
|
||||
data_offset += (lsc_size >> 1);
|
||||
} else {
|
||||
os_printf("param_data flash : %04x target : %04x err!\r\n", buff[data_offset], ISPCFG_MAGIC);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
os_printf("sensor param use flash_param!\r\n");
|
||||
goto _end;
|
||||
} else {
|
||||
os_printf("param_size : %d calc_size : %d\r\n", param_size, sensor_index * sensor_param_size);
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
os_printf("%s malloc sram size : %d err!\r\n", sizeof(struct hgisp_sensor_init));
|
||||
}
|
||||
return (void *)NULL;
|
||||
|
||||
|
||||
_err:
|
||||
os_printf("sensor param use default param!\r\n");
|
||||
init->sensor_info[0].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[1].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[2].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
os_memcpy((void *)&init->sensor_info[0].sensor_param, (void *)&isp_master_param, sizeof(struct hgisp_param_info));
|
||||
// os_memcpy((void *)&init->sensor_info[1].sensor_param, (void *)&isp_slave0_param, sizeof(struct hgisp_param_info));
|
||||
// os_memcpy((void *)&init->sensor_info[2].sensor_param, (void *)&isp_slave1_param, sizeof(struct hgisp_param_info));
|
||||
_end:
|
||||
return (void *)init;
|
||||
}
|
||||
|
||||
513
sdk/lib/video/isp/isp_param_2083_f2p0_dri.c
Normal file
513
sdk/lib/video/isp/isp_param_2083_f2p0_dri.c
Normal file
@@ -0,0 +1,513 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
#define ISP_DMA_ENABLE 1
|
||||
|
||||
const struct hgisp_param_info isp_master_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 1,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 255,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 6 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 2,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 1,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 360,
|
||||
.awb_crop_pixel_end_h = 1919,
|
||||
.awb_crop_pixel_end_v = 1079,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 380,
|
||||
.luma_weight = { 5, 5, 5, 5, 5, //25
|
||||
10, 20, 30, 20, 10, //90
|
||||
20, 30, 50, 30, 20, //150
|
||||
10, 20, 30, 20, 10, //90
|
||||
5, 5, 5, 5, 5},//25
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 270,
|
||||
.ae_crop_size_h = 1920,
|
||||
.ae_crop_size_v = 810,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 271,
|
||||
.hist_crop_end_h = 1920,
|
||||
.hist_crop_end_v = 1080,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 1,
|
||||
.lowlight_lsb_gain_4hi_fps = 64, // lowlight_lsb_gain_en==0 ? 16 : 64
|
||||
.lowlight_lsb_gain_4lo_fps = 64, // lowlight_lsb_gain_en==0 ? 16 : 64
|
||||
.hist_hs_bin_thr = 180,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 1,
|
||||
.abl_expo_line_low_ratio = 0,
|
||||
.abl_expo_gain_low_thr = 0,
|
||||
.abl_expo_line_high_ratio = 0,
|
||||
.abl_expo_gain_high_thr = 0,
|
||||
.aoe_expo_gain_thr[0] = 65535,
|
||||
.aoe_expo_gain_thr[1] = 65535,
|
||||
.abl_bv_thr[0] = 1e20,
|
||||
.abl_bv_thr[1] = 1e20,
|
||||
.aoe_bv_thr[0] = 0,
|
||||
.aoe_bv_thr[1] = 0,
|
||||
.abl_hist_thr[0] = 50, // hist
|
||||
.abl_hist_thr[1] = 236,
|
||||
.dark_pixel_low_ratio = 0.60,
|
||||
.dark_pixel_high_ratio = 0.90,
|
||||
.bright_pixel_high_ratio = 0.15,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50, // position
|
||||
.bright_pos_adjust_ratio = 0.90,
|
||||
.abl_dark_pos_low_wthr = 0.40 * 61,
|
||||
.abl_dark_pos_add_wthr = 0.10 * 61,
|
||||
.aoe_dark_pos_wthr = 0.60 * 61,
|
||||
.aoe_bright_pos_wthr = 0.20 * 61,
|
||||
.abl_luma_target_max = 100, // stable
|
||||
.abl_diff_ratio = 0.05,
|
||||
.abl_dark_pos_diff_thr = 0.15 * 61,
|
||||
.abl_bright_pos_diff_thr = 0.10 * 61,
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 0,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.wdr_en = 1,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 80,
|
||||
.noise_floor_out = 0,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
const struct hgisp_param_info isp_slave0_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 232,
|
||||
.abl_luma_target_max = 100,
|
||||
.dark_pos_thr_max = 50,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 5000,
|
||||
.abl_bv_thr[1] = 8000,
|
||||
.aoe_bv_thr[0] = 4000,
|
||||
.aoe_bv_thr[1] = 6000,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_upper_hs_pixel_ratio = 0.92,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
const struct hgisp_param_info isp_slave1_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 360,
|
||||
.awb_crop_pixel_end_h = 1919,
|
||||
.awb_crop_pixel_end_v = 1079,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 480,
|
||||
.luma_weight = { 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10,
|
||||
20, 30, 50, 30, 20,
|
||||
20, 30, 30, 30, 20,
|
||||
20, 20, 20, 20, 20},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 1,
|
||||
.lowlight_lsb_gain_4hi_fps = 64, // lowlight_lsb_gain_en==0 ? 16 : 64
|
||||
.lowlight_lsb_gain_4lo_fps = 64, // lowlight_lsb_gain_en==0 ? 16 : 64
|
||||
.hist_hs_bin_thr = 180,
|
||||
.abl_luma_target_max = 100,
|
||||
.dark_pos_thr_max = 50,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9,
|
||||
.abl_bright_pos_diff_thr = 6,
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 6645, // 80lx
|
||||
.abl_bv_thr[1] = 13216, // 160lx
|
||||
.aoe_bv_thr[0] = 3531, // 40lx
|
||||
.aoe_bv_thr[1] = 6645, // 80lx
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
.stg_mode = 0, // 自动曝光策略 0:高光优先; 1:低光优先
|
||||
.stg_ratio_slope = 0.3*256, // fix(0,16,8), 值越大,roi对权重的影响越大。
|
||||
.stg_max_offset = 20, // fix(0,8,0), roi对权重影响的最大程度
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.dynamic_gamma_en = 0,
|
||||
.y_gamma_opt = 0,
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
#define SENSOR_PARAM_SIZE (64*4*4+153*4*4)
|
||||
|
||||
|
||||
void *isp_sensor_param_load(uint16 *buff)
|
||||
{
|
||||
struct hgisp_sensor_init *init = NULL;
|
||||
uint8 sensor_index = 0;
|
||||
uint32 data_offset = 0;
|
||||
uint32 param_size = buff[2] << 16 | buff[1];
|
||||
uint32 gamma_size = 256;
|
||||
uint32 lsc_size = 153*4*4;
|
||||
uint32 info_szie = sizeof(struct hgisp_sensor_info);
|
||||
uint32 sensor_param_size = (gamma_size << 1) + lsc_size + info_szie;
|
||||
init = (struct hgisp_sensor_init *)os_malloc(sizeof(struct hgisp_sensor_init));
|
||||
if (init)
|
||||
{
|
||||
os_memset(init, 0, sizeof(struct hgisp_sensor_init));
|
||||
sensor_index = buff[3];
|
||||
if (sensor_index && (param_size >= sensor_index * sensor_param_size))
|
||||
{
|
||||
data_offset = 4;
|
||||
for (int i = 0; i < sensor_index; i++)
|
||||
{
|
||||
if (buff[data_offset+2] == ISPCFG_MAGIC)
|
||||
{
|
||||
os_memcpy((void *)&init->sensor_info[i], (void *)&buff[data_offset], info_szie);
|
||||
init->sensor_info[i].info_src = ISP_INFO_SRC_TYPE_CODE_PARAM;
|
||||
data_offset += (info_szie >> 1);
|
||||
init->sensor_info[i].sensor_param.y_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.rgb_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.lsc_tbl = (uint32 *)&buff[data_offset];
|
||||
data_offset += (lsc_size >> 1);
|
||||
} else {
|
||||
os_printf("param_data flash : %04x target : %04x err!\r\n", buff[data_offset], ISPCFG_MAGIC);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
os_printf("sensor param use flash_param!\r\n");
|
||||
goto _end;
|
||||
} else {
|
||||
os_printf("param_size : %d calc_size : %d\r\n", param_size, sensor_index * sensor_param_size);
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
os_printf("%s malloc sram size : %d err!\r\n", sizeof(struct hgisp_sensor_init));
|
||||
}
|
||||
return (void *)NULL;
|
||||
|
||||
|
||||
_err:
|
||||
os_printf("sensor param use default param!\r\n");
|
||||
init->sensor_info[0].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[1].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[2].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
os_memcpy((void *)&init->sensor_info[0].sensor_param, (void *)&isp_master_param, sizeof(struct hgisp_param_info));
|
||||
os_memcpy((void *)&init->sensor_info[1].sensor_param, (void *)&isp_slave0_param, sizeof(struct hgisp_param_info));
|
||||
os_memcpy((void *)&init->sensor_info[2].sensor_param, (void *)&isp_slave1_param, sizeof(struct hgisp_param_info));
|
||||
_end:
|
||||
return (void *)init;
|
||||
}
|
||||
|
||||
|
||||
489
sdk/lib/video/isp/isp_param_gc1084_mipi_f1p6_devboard.c
Normal file
489
sdk/lib/video/isp/isp_param_gc1084_mipi_f1p6_devboard.c
Normal file
@@ -0,0 +1,489 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
#define ISP_DMA_ENABLE 1
|
||||
|
||||
const struct hgisp_param_info isp_master_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 1,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 6 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 2,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 32,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 1,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 1,
|
||||
.lowlight_lsb_gain_4hi_fps = 64,
|
||||
.lowlight_lsb_gain_4lo_fps = 64,
|
||||
.hist_hs_bin_thr = 224,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 6645, // 80lx
|
||||
.abl_bv_thr[1] = 13216, // 160lx
|
||||
.aoe_bv_thr[0] = 3531, // 40lx
|
||||
.aoe_bv_thr[1] = 6645, // 80lx
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_luma_target_max = 100,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 0,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.wdr_en = 1,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 80,
|
||||
.noise_floor_out = 0,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
const struct hgisp_param_info isp_slave0_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 232,
|
||||
.abl_luma_target_max = 100,
|
||||
.dark_pos_thr_max = 50,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 5000,
|
||||
.abl_bv_thr[1] = 8000,
|
||||
.aoe_bv_thr[0] = 4000,
|
||||
.aoe_bv_thr[1] = 6000,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_upper_hs_pixel_ratio = 0.92,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
},
|
||||
};
|
||||
|
||||
const struct hgisp_param_info isp_slave1_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 1,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 3 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 232,
|
||||
.abl_luma_target_max = 100,
|
||||
.dark_pos_thr_max = 50,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 6645, // 80lx
|
||||
.abl_bv_thr[1] = 13216, // 160lx
|
||||
.aoe_bv_thr[0] = 3531, // 40lx
|
||||
.aoe_bv_thr[1] = 6645, // 80lx
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
.stg_mode = 0, // <20>Զ<EFBFBD><D4B6>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD> 0<><30><EFBFBD>߹<EFBFBD><DFB9><EFBFBD><EFBFBD>ȣ<EFBFBD> 1<><31><EFBFBD><EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD>
|
||||
.stg_ratio_slope = 0.3*256, // fix(0,16,8), ֵԽ<D6B5><D4BD><EFBFBD><EFBFBD>roi<6F><69>Ȩ<EFBFBD>ص<EFBFBD>Ӱ<EFBFBD><D3B0>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD>
|
||||
.stg_max_offset = 20, // fix(0,8,0)<29><> roi<6F><69>Ȩ<EFBFBD><C8A8>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̶<EFBFBD>
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
},
|
||||
};
|
||||
|
||||
void *isp_sensor_param_load(uint16 *buff)
|
||||
{
|
||||
struct hgisp_sensor_init *init = NULL;
|
||||
uint8 sensor_index = 0;
|
||||
uint32 data_offset = 0;
|
||||
uint32 param_size = buff[2] << 16 | buff[1];
|
||||
uint32 gamma_size = 256;
|
||||
uint32 lsc_size = 153*4*4;
|
||||
uint32 info_szie = sizeof(struct hgisp_sensor_info);
|
||||
uint32 sensor_param_size = (gamma_size << 1) + lsc_size + info_szie;
|
||||
init = (struct hgisp_sensor_init *)os_malloc(sizeof(struct hgisp_sensor_init));
|
||||
if (init)
|
||||
{
|
||||
os_memset(init, 0, sizeof(struct hgisp_sensor_init));
|
||||
sensor_index = buff[3];
|
||||
if (sensor_index && (param_size >= sensor_index * sensor_param_size))
|
||||
{
|
||||
data_offset = 4;
|
||||
for (int i = 0; i < sensor_index; i++)
|
||||
{
|
||||
if (buff[data_offset+2] == ISPCFG_MAGIC)
|
||||
{
|
||||
os_memcpy((void *)&init->sensor_info[i], (void *)&buff[data_offset], info_szie);
|
||||
init->sensor_info[i].info_src = ISP_INFO_SRC_TYPE_CODE_PARAM;
|
||||
data_offset += (info_szie >> 1);
|
||||
init->sensor_info[i].sensor_param.y_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.rgb_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.lsc_tbl = (uint32 *)&buff[data_offset];
|
||||
data_offset += (lsc_size >> 1);
|
||||
} else {
|
||||
os_printf("param_data flash : %04x target : %04x err!\r\n", buff[data_offset], ISPCFG_MAGIC);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
os_printf("sensor param use flash_param!\r\n");
|
||||
goto _end;
|
||||
} else {
|
||||
os_printf("param_size : %d calc_size : %d\r\n", param_size, sensor_index * sensor_param_size);
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
os_printf("%s malloc sram size : %d err!\r\n", sizeof(struct hgisp_sensor_init));
|
||||
}
|
||||
return (void *)NULL;
|
||||
|
||||
|
||||
_err:
|
||||
os_printf("sensor param use default param!\r\n");
|
||||
init->sensor_info[0].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[1].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[2].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
os_memcpy((void *)&init->sensor_info[0].sensor_param, (void *)&isp_master_param, sizeof(struct hgisp_param_info));
|
||||
os_memcpy((void *)&init->sensor_info[1].sensor_param, (void *)&isp_slave0_param, sizeof(struct hgisp_param_info));
|
||||
os_memcpy((void *)&init->sensor_info[2].sensor_param, (void *)&isp_slave1_param, sizeof(struct hgisp_param_info));
|
||||
_end:
|
||||
return (void *)init;
|
||||
}
|
||||
|
||||
219
sdk/lib/video/isp/isp_param_gc20C3.c
Normal file
219
sdk/lib/video/isp/isp_param_gc20C3.c
Normal file
@@ -0,0 +1,219 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
#define ISP_DMA_ENABLE 1
|
||||
|
||||
const struct hgisp_param_info isp_master_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 0,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 0,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 6 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 0,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.back_cr_max = 30,
|
||||
.back_cb_max = 30,
|
||||
.back_uv_max = 10,
|
||||
.back_cr_min = 5,
|
||||
.back_cb_min = 5,
|
||||
.back_uv_min = 5,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 0x08,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 1,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.awb_back_cons_en = 1,
|
||||
.awb_back_wp_min_ratio = 0.2,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
.awb_crop_pixel_start_h = 0,
|
||||
.awb_crop_pixel_start_v = 0,
|
||||
.awb_crop_pixel_end_h = 0,
|
||||
.awb_crop_pixel_end_v = 0,
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 61,
|
||||
.luma_weight = { 2, 2, 2, 2, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 3, 5, 3, 2,
|
||||
2, 3, 3, 3, 2,
|
||||
2, 2, 2, 2, 2},
|
||||
.ae_crop_start_h = 0,
|
||||
.ae_crop_start_v = 0,
|
||||
.ae_crop_size_h = 0,
|
||||
.ae_crop_size_v = 0,
|
||||
.hist_crop_start_h = 1,
|
||||
.hist_crop_start_v = 1,
|
||||
.hist_crop_end_h = 0,
|
||||
.hist_crop_end_v = 0,
|
||||
.ae_lock_cnt = 10,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 0,
|
||||
.lowlight_lsb_gain_4hi_fps = 16,
|
||||
.lowlight_lsb_gain_4lo_fps = 16,
|
||||
.hist_hs_bin_thr = 180,
|
||||
.hist_upper_hs_pixel_ratio = 0.94,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
.abl_bv_thr[0] = 6645, // 80lx
|
||||
.abl_bv_thr[1] = 13216, // 160lx
|
||||
.aoe_bv_thr[0] = 3531, // 40lx
|
||||
.aoe_bv_thr[1] = 6645, // 80lx
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pos_thr_max = 50,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
.abl_luma_target_max = 100,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 20,
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.dynamic_gamma_en = 0,
|
||||
.y_gamma_opt = 0,
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
.auto_noise_floor_out = 1,
|
||||
.min_ns_percentile = 0.01,
|
||||
.max_ns_percentile = 0.07,
|
||||
},
|
||||
};
|
||||
|
||||
void *isp_sensor_param_load(uint16 *buff)
|
||||
{
|
||||
struct hgisp_sensor_init *init = NULL;
|
||||
uint8 sensor_index = 0;
|
||||
uint32 data_offset = 0;
|
||||
uint32 param_size = buff[2] << 16 | buff[1];
|
||||
uint32 gamma_size = 256;
|
||||
uint32 lsc_size = 153*4*4;
|
||||
uint32 info_szie = sizeof(struct hgisp_sensor_info);
|
||||
uint32 sensor_param_size = (gamma_size << 1) + lsc_size + info_szie;
|
||||
init = (struct hgisp_sensor_init *)os_malloc(sizeof(struct hgisp_sensor_init));
|
||||
if (init)
|
||||
{
|
||||
os_memset(init, 0, sizeof(struct hgisp_sensor_init));
|
||||
sensor_index = buff[3];
|
||||
if (sensor_index && (param_size >= sensor_index * sensor_param_size))
|
||||
{
|
||||
data_offset = 4;
|
||||
for (int i = 0; i < sensor_index; i++)
|
||||
{
|
||||
if (buff[data_offset+2] == ISPCFG_MAGIC)
|
||||
{
|
||||
os_memcpy((void *)&init->sensor_info[i], (void *)&buff[data_offset], info_szie);
|
||||
init->sensor_info[i].info_src = ISP_INFO_SRC_TYPE_CODE_PARAM;
|
||||
data_offset += (info_szie >> 1);
|
||||
init->sensor_info[i].sensor_param.y_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.rgb_gamma = (uint32 *)&buff[data_offset];
|
||||
data_offset += (gamma_size >> 1);
|
||||
init->sensor_info[i].sensor_param.lsc_tbl = (uint32 *)&buff[data_offset];
|
||||
data_offset += (lsc_size >> 1);
|
||||
} else {
|
||||
os_printf("param_data flash : %04x target : %04x err!\r\n", buff[data_offset], ISPCFG_MAGIC);
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
os_printf("sensor param use flash_param!\r\n");
|
||||
goto _end;
|
||||
} else {
|
||||
os_printf("param_size : %d calc_size : %d\r\n", param_size, sensor_index * sensor_param_size);
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
os_printf("%s malloc sram size : %d err!\r\n", sizeof(struct hgisp_sensor_init));
|
||||
}
|
||||
return (void *)NULL;
|
||||
|
||||
|
||||
_err:
|
||||
os_printf("sensor param use default param!\r\n");
|
||||
init->sensor_info[0].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[1].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
init->sensor_info[2].info_src = ISP_INFO_SRC_TYPE_CODE_DOC;
|
||||
os_memcpy((void *)&init->sensor_info[0].sensor_param, (void *)&isp_master_param, sizeof(struct hgisp_param_info));
|
||||
// os_memcpy((void *)&init->sensor_info[1].sensor_param, (void *)&isp_slave0_param, sizeof(struct hgisp_param_info));
|
||||
// os_memcpy((void *)&init->sensor_info[2].sensor_param, (void *)&isp_slave1_param, sizeof(struct hgisp_param_info));
|
||||
_end:
|
||||
return (void *)init;
|
||||
}
|
||||
|
||||
|
||||
174
sdk/lib/video/isp/isp_param_ov9734.c
Normal file
174
sdk/lib/video/isp/isp_param_ov9734.c
Normal file
@@ -0,0 +1,174 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "hal/isp_param.h"
|
||||
|
||||
#define ISP_DMA_ENABLE 1
|
||||
|
||||
const struct hgisp_param_info isp_master_param =
|
||||
{
|
||||
.enable_param = {
|
||||
.test_pattern_en = 0,
|
||||
.dma_flush_en = ISP_DMA_ENABLE,
|
||||
.blc_en = 1,
|
||||
.awb_en = 1,
|
||||
.ae_en = 1,
|
||||
.hist_en = 1,
|
||||
.ccm_en = 1,
|
||||
.y_gamma_en = 0,
|
||||
.rgb_gamma_en = 1,
|
||||
.ce_en = 1,
|
||||
.sharpen_en = 1,
|
||||
.bnr_en = 1,
|
||||
.ynr_en = 1,
|
||||
.cnr_en = 1,
|
||||
.csupp_en = 1,
|
||||
.adj_hue_en = 1,
|
||||
.lsc_en = 1,
|
||||
.dpc_en = 0,
|
||||
.af_en = 0,
|
||||
.dehaze_en = 0,
|
||||
.gic_en = 0,
|
||||
.md_en = 0,
|
||||
.luma_ca_en = 0,
|
||||
},
|
||||
|
||||
.awb_param = {
|
||||
.coarse_scale = 128,
|
||||
.coarse_thr = 3 << 2,
|
||||
.fine_step = 1 << 2,
|
||||
.lock_hi_thr = 4,
|
||||
.lock_lo_thr = 0,
|
||||
.stable_thr = 16,
|
||||
.cbcr_thr = 6 << 2,
|
||||
.awb_auto_en = 1,
|
||||
.awb_meas_mode = 2,
|
||||
.cr_target = 2048,
|
||||
.cb_target = 2048,
|
||||
.front_cr_val = 30,
|
||||
.front_cb_val = 30,
|
||||
.front_uv_sum = 15,
|
||||
.back_cr_val = 30,
|
||||
.back_cb_val = 30,
|
||||
.back_uv_sum = 10,
|
||||
.cons_cr_max = 40,
|
||||
.cons_cb_max = 40,
|
||||
.cons_uv_max = 30,
|
||||
.cons_cr_min = 10,
|
||||
.cons_cb_min = 10,
|
||||
.cons_uv_min = 2,
|
||||
.awb_wp_max = 0xc0,
|
||||
.awb_wp_min = 32,
|
||||
.awb_r_max = 0xc0,
|
||||
.awb_g_max = 0xc0,
|
||||
.awb_b_max = 0xc0,
|
||||
.awb_precision = 1,
|
||||
.awb_fine_cons_en = 0,
|
||||
.awb_coarse_cons_en = 0,
|
||||
.manual_gain = {256, 256, 256, 256},
|
||||
},
|
||||
|
||||
.cfg_ae = {
|
||||
.ae_manual_en = 0,
|
||||
.luma_target = 55,
|
||||
.luma_weight_sum = 450,
|
||||
.luma_weight = { 10, 10, 10, 10, 10,//50
|
||||
10, 30, 30, 30, 10,//110
|
||||
10, 30, 50, 30, 10,//130
|
||||
10, 30, 30, 30, 10,//110
|
||||
10, 10, 10, 10, 10},//50
|
||||
.ae_lock_cnt = 5,
|
||||
.ae_lock_tolerance = 12,
|
||||
.reduce_fps_en = 0,
|
||||
.lowlight_lsb_gain_en = 1,//低光<<2
|
||||
.lowlight_lsb_gain_4hi_fps = 64,
|
||||
.lowlight_lsb_gain_4lo_fps = 64,
|
||||
.hist_hs_bin_thr = 250,
|
||||
.hist_upper_hs_pixel_ratio = 0.74,
|
||||
.hist_upper_pixel_ratio = 0.88,
|
||||
.hist_lower_pixel_ratio = 0.00,
|
||||
|
||||
.abl_luma_target_max = 100,
|
||||
.dark_pos_thr_max = 50,
|
||||
.abl_diff_ratio = 0.03,
|
||||
.abl_dark_pos_diff_thr = 9, // 0.15 * 61
|
||||
.abl_bright_pos_diff_thr = 6, // 0.10 * 61
|
||||
.bright_pixel_high_ratio = 0.10,
|
||||
.bright_pixel_sub_ratio = 0.05,
|
||||
.dark_pixel_low_ratio = 0.55,
|
||||
.dark_pixel_high_ratio = 0.85,
|
||||
.abl_dark_pos_low_wthr = 18, // 0.30 * 61,
|
||||
.abl_dark_pos_add_wthr = 12, // 0.20 * 61,
|
||||
.bright_pos_adjust_ratio = 0.80,
|
||||
.aoe_dark_pos_wthr = 30, // 0.50 * 61,
|
||||
.aoe_bright_pos_wthr = 9, // 0.15 * 61,
|
||||
// .abl_bv_gain_sel = 0,
|
||||
.abl_expo_line_low_ratio = 0.80,
|
||||
.abl_expo_line_high_ratio = 1.00,
|
||||
.abl_expo_gain_low_thr = 256,
|
||||
.abl_expo_gain_high_thr = 324,
|
||||
.abl_hist_thr[0] = 50,
|
||||
.abl_hist_thr[1] = 230,
|
||||
.aoe_expo_gain_thr[0] = 384-50,
|
||||
.aoe_expo_gain_thr[1] = 384,
|
||||
// .abl_bv_thr[0] = 6645, // 80lx
|
||||
// .abl_bv_thr[1] = 13216, // 160lx
|
||||
// .aoe_bv_thr[0] = 3531, // 40lx
|
||||
// .aoe_bv_thr[1] = 6645, // 80lx
|
||||
|
||||
.stg_mode = 0,
|
||||
.stg_ratio_slope = 0.3*256,
|
||||
.stg_max_offset = 0,
|
||||
|
||||
.abl_bv_gain_sel = 1,
|
||||
.abl_bv_thr[0] = 1e20,
|
||||
.abl_bv_thr[1] = 1e20,
|
||||
.aoe_bv_thr[0] = 1,
|
||||
.aoe_bv_thr[1] = 1,
|
||||
|
||||
|
||||
},
|
||||
|
||||
.config_wdr = {
|
||||
.wdr_en = 0,
|
||||
.temporal_smooth_alpha = 0.1,
|
||||
.noise_floor = 128,
|
||||
.noise_floor_out = 128,
|
||||
.shadow_boost_target = 512,
|
||||
.highlight_compress_target = 870,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
#define SENSOR_PARAM_SIZE (64*4*4+153*4*4)
|
||||
|
||||
void *isp_sensor_param_load(uint16 *buff)
|
||||
{
|
||||
struct hgisp_sensor_init *init = NULL;
|
||||
init = (struct hgisp_sensor_init *)os_malloc(sizeof(struct hgisp_sensor_init));
|
||||
if (init)
|
||||
{
|
||||
os_memset(init, 0, sizeof(struct hgisp_sensor_init));
|
||||
if (buff[0] && (buff[1]) && (buff[2] == ISPCFG_MAGIC))
|
||||
{
|
||||
os_printf("sensor param use flash param!\r\n");
|
||||
os_memcpy(init, (void *)&buff[2], sizeof(struct hgisp_sensor_init));
|
||||
goto _end;
|
||||
} else {
|
||||
goto _err;
|
||||
}
|
||||
} else {
|
||||
os_printf("%s malloc sram size : %d err!\r\n", sizeof(struct hgisp_sensor_init));
|
||||
}
|
||||
return (void *)NULL;
|
||||
|
||||
_err:
|
||||
os_printf("sensor param use default param!\r\n");
|
||||
os_memcpy((void *)&init->sensor_info[0].sensor_param, (void *)&isp_master_param, sizeof(struct hgisp_param_info));
|
||||
// os_memcpy((void *)&init->sensor_info[1].sensor_param, (void *)&isp_slave0_param, sizeof(struct hgisp_param_info));
|
||||
// os_memcpy((void *)&init->sensor_info[2].sensor_param, (void *)&isp_slave1_param, sizeof(struct hgisp_param_info));
|
||||
_end:
|
||||
return (void *)init;
|
||||
}
|
||||
|
||||
|
||||
691
sdk/lib/video/isp/isp_tunning.c
Normal file
691
sdk/lib/video/isp/isp_tunning.c
Normal file
@@ -0,0 +1,691 @@
|
||||
#include "basic_include.h"
|
||||
#include "hal/isp_tunning.h"
|
||||
#include "hal/isp.h"
|
||||
#include "hal/dual_org.h"
|
||||
#include "lib/multimedia/framebuff.h"
|
||||
#include "lib/multimedia/msi.h"
|
||||
#include "lib/video/dvp/jpeg/jpg.h"
|
||||
|
||||
#if ISP_TUNNING_EN
|
||||
struct isp_tunnning_dev *isp_tunning = NULL;
|
||||
void isp_tunning_response(struct isp_tunnning_dev *p_dev, uint16 ret_val)
|
||||
{
|
||||
uint16 crc_val = 0;
|
||||
os_memset(p_dev->response, 0, 8);
|
||||
p_dev->response[0] = p_dev->tunning_head;
|
||||
p_dev->response[1] = p_dev->cmd_num;
|
||||
p_dev->response[2] = ret_val;
|
||||
crc_val = hw_crc(CRC_TYPE_CRC16_MODBUS, (void *)p_dev->response, 6);
|
||||
p_dev->response[3] = crc_val;
|
||||
p_dev->response[5] = 0x0a;
|
||||
p_dev->write_handle(p_dev->device, 0, (void *)p_dev->response, sizeof(p_dev->response));
|
||||
}
|
||||
|
||||
void isp_tunning_message_head(struct isp_tunnning_dev *p_dev, uint32 data_addr, uint32 data_len)
|
||||
{
|
||||
p_dev->message_head[0] = p_dev->tunning_head;
|
||||
p_dev->message_head[1] = p_dev->cmd_num;
|
||||
p_dev->message_head[2] = (data_len >> 0) & 0xffff;
|
||||
p_dev->message_head[3] = (data_len >> 16) & 0xffff;
|
||||
p_dev->message_head[4] = hw_crc(CRC_TYPE_CRC16_MODBUS, (void *)data_addr, data_len);
|
||||
p_dev->message_head[5] = hw_crc(CRC_TYPE_CRC16_MODBUS, (void *)p_dev->message_head, TUNNING_PACKAGE_INFO_SIZE - 2 - 4);
|
||||
p_dev->message_head[6] = 0x00;
|
||||
p_dev->message_head[7] = 0x0a;
|
||||
p_dev->write_handle(p_dev->device, 0, (void *)p_dev->message_head, TUNNING_PACKAGE_INFO_SIZE);
|
||||
}
|
||||
|
||||
uint32 isp_tunning_get_img(struct isp_tunnning_dev *p_dev)
|
||||
{
|
||||
uint32 ret_val = TUNNING_ERR_CODE_RIGHT;
|
||||
uint32 flen = 0;
|
||||
uint32 offset = 0;
|
||||
uint8 *img_addr = NULL;
|
||||
struct framebuff *get_f = NULL;
|
||||
uint8 get_max = 10;
|
||||
uint8 get_idx = 0;
|
||||
uint8 first_packet = 0;
|
||||
while((++get_idx) <= get_max)
|
||||
{
|
||||
__retry:
|
||||
get_f = msi_get_fb(p_dev->v_msi, 100);
|
||||
if (get_f)
|
||||
{
|
||||
if (abs(get_f->time - os_jiffies()) > 100)
|
||||
{
|
||||
msi_delete_fb(NULL, get_f);
|
||||
get_f = NULL;
|
||||
goto __retry;
|
||||
}
|
||||
|
||||
flen = get_f->len;
|
||||
img_addr = get_f->data;
|
||||
p_dev->write_data.addr = os_zalloc(TUNNING_PACKET_SIZE+4);
|
||||
if (p_dev->write_data.addr)
|
||||
{
|
||||
// os_printf("%s %d addr : %08x\r\n", __func__, __LINE__, (uint32)p_dev->write_data.addr);
|
||||
|
||||
isp_tunning_message_head(p_dev, (uint32)img_addr, flen);
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+0] = 0x00;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+1] = 0x00;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+2] = 0x0d;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+3] = 0x0a;
|
||||
while (flen)
|
||||
{
|
||||
offset = (flen > TUNNING_PACKET_SIZE) ? (TUNNING_PACKET_SIZE) : (flen);
|
||||
hw_memcpy((void *)p_dev->write_data.addr, img_addr, offset);
|
||||
img_addr += offset;
|
||||
flen -= offset;
|
||||
if (offset < TUNNING_PACKET_SIZE)
|
||||
{
|
||||
p_dev->write_data.addr[offset+0] = 0x00;
|
||||
p_dev->write_data.addr[offset+1] = 0x00;
|
||||
p_dev->write_data.addr[offset+2] = 0x0d;
|
||||
p_dev->write_data.addr[offset+3] = 0x0a;
|
||||
}
|
||||
p_dev->write_handle(p_dev->device, 0, (void *)p_dev->write_data.addr, offset+4);
|
||||
if (first_packet == 0) {
|
||||
os_sleep_ms(10);
|
||||
first_packet = 1;
|
||||
}else {
|
||||
os_sleep_ms(1);
|
||||
}
|
||||
}
|
||||
os_free(p_dev->write_data.addr);
|
||||
} else {
|
||||
ret_val = TUNNING_ERR_CODE_MALLOC_ERR;
|
||||
os_printf("%s %d malloc size : %d err\r\n", __func__, __LINE__, TUNNING_PACKET_SIZE);
|
||||
goto __err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((get_idx > get_max) && (get_f == NULL))
|
||||
{
|
||||
ret_val = TUNNING_ERR_CODE_GET_PARAM_ERR;
|
||||
os_printf("%s %d get frame err\r\n", __func__, __LINE__);
|
||||
goto __err;
|
||||
}
|
||||
goto __end;
|
||||
__err:
|
||||
isp_tunning_response(p_dev, ret_val);
|
||||
__end:
|
||||
if(get_f)
|
||||
{
|
||||
msi_delete_fb(NULL, get_f);
|
||||
p_dev->v_msi->enable = 0;
|
||||
while(1)
|
||||
{
|
||||
get_f = msi_get_fb(p_dev->v_msi, 0);
|
||||
if (get_f)
|
||||
{
|
||||
msi_delete_fb(NULL, get_f);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
get_f = NULL;
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void isp_tunning_get_raw(struct isp_tunnning_dev *p_dev)
|
||||
{
|
||||
uint32 ret_val = TUNNING_ERR_CODE_RIGHT;
|
||||
uint32 flen = 0;
|
||||
uint32 offset = 0;
|
||||
uint8 first_packet = 0;
|
||||
|
||||
p_dev->backup_addr = dual_save_cfg(p_dev->p_dual, p_dev->cmd_channel, (uint32)&flen);
|
||||
p_dev->write_data.size = TUNNING_PACKET_SIZE;
|
||||
p_dev->write_data.addr = os_zalloc(TUNNING_PACKET_SIZE+4);
|
||||
if (p_dev->write_data.addr)
|
||||
{
|
||||
// os_printf("%s %d addr : %08x src : %08x flen : %d\r\n", __func__, __LINE__, (uint32)p_dev->write_data.addr, p_dev->backup_addr, flen);
|
||||
while(!dual_save_status(p_dev->p_dual));
|
||||
sys_dcache_invalid_range((void *)p_dev->backup_addr, flen);
|
||||
isp_tunning_message_head(p_dev, p_dev->backup_addr, flen);
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+0] = 0x00;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+1] = 0x00;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+2] = 0x0d;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+3] = 0x0a;
|
||||
while (flen)
|
||||
{
|
||||
// os_printf("%s %d flen : %d\r\n", __func__, __LINE__, flen);
|
||||
offset = (flen > TUNNING_PACKET_SIZE) ? (TUNNING_PACKET_SIZE) : (flen);
|
||||
hw_memcpy((void *)p_dev->write_data.addr, (void *)p_dev->backup_addr, offset);
|
||||
p_dev->backup_addr += offset;
|
||||
flen -= offset;
|
||||
if (offset < TUNNING_PACKET_SIZE)
|
||||
{
|
||||
p_dev->write_data.addr[offset+0] = 0x00;
|
||||
p_dev->write_data.addr[offset+1] = 0x00;
|
||||
p_dev->write_data.addr[offset+2] = 0x0d;
|
||||
p_dev->write_data.addr[offset+3] = 0x0a;
|
||||
}
|
||||
p_dev->write_handle(p_dev->device, 0, (void *)p_dev->write_data.addr, offset+4);
|
||||
if (first_packet == 0) {
|
||||
os_sleep_ms(10);
|
||||
first_packet = 1;
|
||||
}else {
|
||||
os_sleep_ms(1);
|
||||
}
|
||||
}
|
||||
dual_recover_cfg(p_dev->p_dual);
|
||||
os_free(p_dev->write_data.addr);
|
||||
} else {
|
||||
os_printf("%s %d get package_size : %d err\r\n", __func__, __LINE__, TUNNING_PACKET_SIZE);
|
||||
ret_val = TUNNING_ERR_CODE_MALLOC_ERR;
|
||||
goto __err;
|
||||
}
|
||||
return;
|
||||
|
||||
__err:
|
||||
isp_tunning_response(p_dev, ret_val);
|
||||
return;
|
||||
}
|
||||
|
||||
void isp_tunning_dump_data(struct isp_tunnning_dev *p_dev, uint32 data_addr, uint32 data_size)
|
||||
{
|
||||
uint32 ret_val = 0;
|
||||
uint32 flen = data_size;
|
||||
uint32 first_packet = 0;
|
||||
uint32 offset = 0;
|
||||
uint32 faddr = data_addr;
|
||||
|
||||
p_dev->write_data.addr = os_malloc(TUNNING_PACKET_SIZE + 4);
|
||||
if (p_dev->write_data.addr)
|
||||
{
|
||||
isp_tunning_message_head(p_dev, faddr, flen);
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+0] = 0x00;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+1] = 0x00;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+2] = 0x0d;
|
||||
p_dev->write_data.addr[TUNNING_PACKET_SIZE+3] = 0x0a;
|
||||
while (flen)
|
||||
{
|
||||
offset = (flen > TUNNING_PACKET_SIZE) ? (TUNNING_PACKET_SIZE) : (flen);
|
||||
hw_memcpy((void *)p_dev->write_data.addr, (void *)faddr, offset);
|
||||
faddr += offset;
|
||||
flen -= offset;
|
||||
if (offset < TUNNING_PACKET_SIZE)
|
||||
{
|
||||
p_dev->write_data.addr[offset+0] = 0x00;
|
||||
p_dev->write_data.addr[offset+1] = 0x00;
|
||||
p_dev->write_data.addr[offset+2] = 0x0d;
|
||||
p_dev->write_data.addr[offset+3] = 0x0a;
|
||||
}
|
||||
p_dev->write_handle(p_dev->device, 0, (void *)p_dev->write_data.addr, offset+4);
|
||||
if (first_packet == 0) {
|
||||
os_sleep_ms(10);
|
||||
first_packet = 1;
|
||||
}else {
|
||||
os_sleep_ms(1);
|
||||
}
|
||||
}
|
||||
os_free(p_dev->write_data.addr);
|
||||
} else {
|
||||
os_printf("%s %d malloc write_data err\r\n", __func__, __LINE__);
|
||||
goto __err;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
__err:
|
||||
isp_tunning_response(p_dev, ret_val);
|
||||
return;
|
||||
}
|
||||
|
||||
void isp_tunning_thread(void *dev)
|
||||
{
|
||||
uint32 ret_val = 0;
|
||||
uint8 response_flag = 1;
|
||||
scatter_data dump_data;
|
||||
struct isp_tunnning_dev *p_dev = (struct isp_tunnning_dev *)dev;
|
||||
|
||||
os_memset(&dump_data, 0, sizeof(scatter_data));
|
||||
while(1)
|
||||
{
|
||||
response_flag = 1;
|
||||
os_sema_down((void *)&p_dev->usb_cmd_sema, -1);
|
||||
|
||||
switch (p_dev->cmd_num)
|
||||
{
|
||||
case ISP_IOCTL_CMD_3DNR_ENABLE:
|
||||
isp_3dnr_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_IMG_MIRROR:
|
||||
isp_mirror_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_IMG_REVERSE:
|
||||
isp_reverse_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_GET_IMG:
|
||||
p_dev->v_msi->enable = 1;
|
||||
ret_val = isp_tunning_get_img(p_dev);
|
||||
response_flag = 0;
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_MANNUL_MODE_TYPE:
|
||||
isp_awb_mannul_mode_type(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_CONTROL_STEP:
|
||||
isp_awb_control_step_config(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_CONTROL_THR:
|
||||
isp_awb_control_thr_config(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->p_data[3], p_dev->p_data[4], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_AUTO_CTRL:
|
||||
isp_awb_auto_config(p_dev->p_isp, p_dev->p_data[0], (void *)&p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_FINE_CONSTRAINT_CTRL:
|
||||
isp_awb_fine_constraint_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_COARSE_CONSTRAINT_CTRL:
|
||||
isp_awb_coarse_constraint_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_MEAS_MODE:
|
||||
isp_awb_measure_mode_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_WP_EXPECT:
|
||||
isp_awb_wp_expect_val(p_dev->p_isp, p_dev->p_data[1], p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_WP_RANGE_CONSTRAINT:
|
||||
isp_awb_cbcr_constraint(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_WP_RANGE_CONSTRAINTF:
|
||||
isp_awb_cbcr_constraintf(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_WP_RANGE_CONSTRAINT_RESTRAIN:
|
||||
isp_awb_cbcr_constraint_restrain(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_RGB_CONSTRAINT:
|
||||
isp_awb_rgb_constraint(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_WP_NUM_RESTRAIN:
|
||||
isp_awb_wp_constraint(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_GAIN_TYPE:
|
||||
isp_awb_gain_type(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_GAIN_CONSTRAINT:
|
||||
isp_awb_gain_constraint(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_GAIN_COARSE_CONSTRAINT:
|
||||
isp_awb_gain_coarse_constraint(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_GAIN_FINE_CONSTRAINT:
|
||||
isp_awb_gain_fine_constraint(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AWB_CROP_RANGE:
|
||||
ret_val = isp_awb_crop_range(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->p_data[3], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_MANUAL_PARAM:
|
||||
isp_ae_manul_config(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ROW_TIME_US:
|
||||
isp_ae_row_time(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ANALOG_GAIN:
|
||||
isp_ae_analog_gain(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_EXPOSURE_LINE:
|
||||
isp_ae_exposure_line(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_CONFIG_INTERVAL:
|
||||
isp_ae_interval_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_DAY_NIGHT_BV:
|
||||
isp_ae_day_night_bv(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_SCENE_LUT:
|
||||
isp_ae_scene_lut(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_LOWLIGHT_PARAM:
|
||||
isp_ae_lowlight_param(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_FRAME_MAX:
|
||||
isp_ae_frame_max(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_LOCK_PARAM:
|
||||
isp_ae_lock_param(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_REDUCE_FPS:
|
||||
isp_ae_reduce_fps(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_LOWLIGHT_LSB_GAIN_EN:
|
||||
isp_ae_lowlight_gain_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_LOWLIGHT_LSB_GAIN_4HI_FPS:
|
||||
isp_ae_lowlight_gain_high_gain(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_LOWLIGHT_LSB_GAIN_4LO_FPS:
|
||||
isp_ae_lowlight_gain_low_gain(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_HIST_HS_BIN_THR:
|
||||
isp_ae_hist_hs_bin_thr(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_LUMA_TARGET:
|
||||
isp_ae_luma_target_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_LUMA_WEIGHT:
|
||||
isp_ae_luma_weight_config(p_dev->p_isp, p_dev->p_data[0], (void *)&p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_LUMA_MAX:
|
||||
isp_ae_abl_luma_max(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_POS_THR:
|
||||
isp_ae_pos_thr(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_HIST_THR:
|
||||
isp_ae_hist_thr(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_AOE_EXPO_GAIN:
|
||||
isp_ae_aoe_gain(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_LOCK_THR:
|
||||
isp_ae_abl_lock(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_BRIGHT_DARK_PIXEL_RATIO:
|
||||
isp_ae_brihgt_dark_pixel_ratio(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->p_data[3], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_DARK_BRIGHT_POS_THR:
|
||||
isp_ae_abl_dark_bright_pos_ratio(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_AOE_DARK_BRIGHT_POS_THR:
|
||||
isp_ae_aoe_dark_bright_pos_ratio(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_GAIN_MODE:
|
||||
isp_ae_abl_gain_type(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_EXPO_LINE_RATIO:
|
||||
isp_ae_abl_expo_line_ratio(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_EXPO_GAIN_THR:
|
||||
isp_ae_abl_expo_gain_set(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_ABL_BV_THR:
|
||||
isp_ae_abl_bv_thr(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_AOE_BV_THR:
|
||||
isp_ae_aoe_bv_thr(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_HIST_PIXEL_THR:
|
||||
isp_ae_hist_pixel_thr(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_STG_PARAM:
|
||||
ret_val = isp_ae_stg_param(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_EV_OFFSET_TYPE:
|
||||
isp_ae_ev_offset_type(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_AE_CROP_RANGE:
|
||||
isp_ae_crop_range(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_HIST_CROP_RANGE:
|
||||
isp_hist_crop_range(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CCM_ARRAY:
|
||||
isp_ccm_config(p_dev->p_isp, (void *)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_BLC_PARAM:
|
||||
isp_blc_config(p_dev->p_isp, (void *)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_MD_WINDOW_PARAM:
|
||||
isp_md_window_config(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->p_data[3], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_MD_DETECT_PARAM:
|
||||
isp_md_param_config(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CSC_PARAM:
|
||||
isp_csc_config(p_dev->p_isp, (void *)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_DPC_PARAM:
|
||||
isp_dpc_config(p_dev->p_isp, (void *)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_YUV_RANGE:
|
||||
isp_ce_yuv_range(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_LUMA:
|
||||
isp_ce_luma_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_SATURATION:
|
||||
isp_ce_saturation_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_CONTRAST:
|
||||
isp_ce_contrast_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_HUE:
|
||||
isp_ce_hue_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_OFFSET_PARAM:
|
||||
isp_ce_offset_config(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CE_ADJ_BY_BV_PARAM:
|
||||
isp_ce_adj_by_bv_param(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_SHARP_PARAM:
|
||||
isp_sharp_param(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_RAWNR_MAP:
|
||||
isp_rawnr_map(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], (uint32)&p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_YUVNR_MAP:
|
||||
isp_yuvnr_map(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], (uint32)&p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CSUPP_MAP:
|
||||
isp_csupp_map(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], (uint32)&p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_Y_GAMMA_TUNNING:
|
||||
isp_y_gamma_tunning(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_RGB_GAMMA_TUNNING:
|
||||
isp_rgb_gamma_tunning(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_LSC_TUNNING:
|
||||
isp_lsc_tunning(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_GIC_PARAM:
|
||||
isp_gic_init(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_LHS_MAP:
|
||||
isp_lhs_map(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], (uint32)&p_dev->p_data[2], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_GET_SENSOR_RAW:
|
||||
isp_tunning_get_raw(p_dev);
|
||||
response_flag = 0;
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_GET_Y_GAMMA:
|
||||
case ISP_IOCTL_CMD_GET_SENSOR_YGAMMA:
|
||||
case ISP_IOCTL_CMD_GET_RGB_GAMMA:
|
||||
case ISP_IOCTL_CMD_GET_LSC:
|
||||
case ISP_IOCTL_CMD_DUMP_SRAM_PARAM:
|
||||
case ISP_IOCTL_CMD_DUMP_REG_PARAM:
|
||||
ret_val = isp_ioctl(p_dev->p_isp, p_dev->cmd_num, p_dev->cmd_channel, (uint32)&dump_data);
|
||||
//os_printf("%s %d dump addr :%08x dump_data : %08x\r\n", __func__, __LINE__, (uint32)dump_data.addr, dump_data.size);
|
||||
if (!ret_val) isp_tunning_dump_data(p_dev, (uint32)dump_data.addr, dump_data.size);
|
||||
response_flag = 0;
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_CONFIG_SRAM_PARAM:
|
||||
isp_sensor_sram_param_config(p_dev->p_isp, p_dev->cmd_channel, (uint32)p_dev->p_data);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_FUNC_ENABLE:
|
||||
ret_val = isp_sensor_func_enable(p_dev->p_isp, p_dev->cmd_channel, (uint32)p_dev->p_data[0]);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_WDR_EN:
|
||||
isp_wdr_en_config(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_WDR_NOISE_FLOOR:
|
||||
isp_wdr_noise_floor_config(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_WDR_TUNNING:
|
||||
isp_wdr_tunning(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_GAMMA_BY_BV_PARAM:
|
||||
isp_gamma_by_bv_param(p_dev->p_isp, (uint32)p_dev->p_data, p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_GAMMA_BY_BV_ENABLE:
|
||||
isp_gamma_by_bv_enable(p_dev->p_isp, p_dev->p_data[0], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
|
||||
case ISP_IOCTL_CMD_FPS_OPT:
|
||||
{
|
||||
float value = *(float *)p_dev->p_data;
|
||||
isp_sensor_fps_opt(p_dev->p_isp, value, p_dev->cmd_channel);
|
||||
}
|
||||
break;
|
||||
|
||||
case ISP_IOCTL_CMD_DYN_YGAMMA_OPT:
|
||||
isp_dyn_gamma_param(p_dev->p_isp, p_dev->p_data[0], p_dev->p_data[1], p_dev->cmd_channel);
|
||||
break;
|
||||
|
||||
default:
|
||||
os_printf("tunning get cmd type : %d err type : %d!\r\n", p_dev->cmd_num, ret_val);
|
||||
break;
|
||||
}
|
||||
if (p_dev->p_data) os_free(p_dev->p_data);
|
||||
if (response_flag) isp_tunning_response(p_dev, ret_val);
|
||||
}
|
||||
}
|
||||
|
||||
void isp_tunning_get_img_msi_create(struct isp_tunnning_dev *p_dev, enum tunning_img_type type, uint32 img_w, uint32 img_h, uint32 src)
|
||||
{
|
||||
if (type)
|
||||
{
|
||||
struct msi *h264_msi_init_with_mode(uint32_t drv1_from, uint32_t drv1_w, uint32_t drv1_h, uint32_t drv2_from, uint32_t drv2_w, uint32_t drv2_h);
|
||||
p_dev->video_msi = msi_find("auto-h264", 1);//h264_msi_init_with_mode(src, img_w, img_h, 0, 0, 0);
|
||||
} else {
|
||||
struct msi *jpg_concat_msi_init_start(uint32_t jpgid,uint16_t w, uint16_t h, uint16_t *filter_type,uint8_t src_from,uint8_t run);
|
||||
p_dev->video_msi = msi_find("auto-jpg", 1);//jpg_concat_msi_init_start(JPGID0, img_w, img_h, NULL, src,1);
|
||||
}
|
||||
|
||||
if (p_dev->video_msi)
|
||||
{
|
||||
p_dev->v_msi = msi_new(TUNNING_IMG_MSI,1,NULL);
|
||||
if (p_dev->v_msi)
|
||||
{
|
||||
// p_dev->v_msi->enable = 1;
|
||||
msi_add_output(p_dev->video_msi, NULL, TUNNING_IMG_MSI);
|
||||
} else {
|
||||
p_dev->video_msi = NULL;
|
||||
p_dev->v_msi = NULL;
|
||||
}
|
||||
} else {
|
||||
p_dev->video_msi = NULL;
|
||||
p_dev->v_msi = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void isp_tunning_init(uint32 img_w, uint32 img_h)
|
||||
{
|
||||
rt_ssize_t cdc_usb_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
|
||||
isp_tunning = os_zalloc(sizeof(struct isp_tunnning_dev));
|
||||
if (isp_tunning == NULL)
|
||||
{
|
||||
os_printf("%s %d isp_tunning_dev malloc err");
|
||||
return;
|
||||
}
|
||||
os_sema_init(&isp_tunning->usb_write_sema, 0);
|
||||
os_sema_init(&isp_tunning->usb_cmd_sema , 0);
|
||||
isp_tunning->tunning_head = 0xb103;
|
||||
isp_tunning->tunning_succ = 0x55aa;
|
||||
isp_tunning->tunning_err = 0x5a5a;
|
||||
isp_tunning->p_isp = (struct isp_device *)dev_get(HG_ISP_DEVID);
|
||||
isp_tunning->p_dual = (struct dual_device *)dev_get(HG_DUALORG_DEVID);
|
||||
isp_tunning->write_handle = cdc_usb_write;
|
||||
isp_tunning_get_img_msi_create(isp_tunning, TUNNING_IMG_JPEG, img_w, img_h, 0);
|
||||
if ((isp_tunning->p_isp == NULL) || (isp_tunning->p_dual == NULL) || (isp_tunning->video_msi == NULL))
|
||||
{
|
||||
os_printf("%s %d get device isp:%d dual:%d msi : %d err", __func__, __LINE__, (isp_tunning->p_isp == NULL), (isp_tunning->p_dual == NULL), (isp_tunning->video_msi == NULL));
|
||||
os_free(isp_tunning);
|
||||
return;
|
||||
}
|
||||
os_printf("%s %d create succ\r\n", __func__, __LINE__);
|
||||
os_task_create("isp_tunning_demo", isp_tunning_thread, (void *)isp_tunning, OS_TASK_PRIORITY_NORMAL, 0, NULL, 1024);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user