1289 lines
36 KiB
C
1289 lines
36 KiB
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <signal.h>
|
|
#include <hdal.h>
|
|
#include <kwrap/perf.h>
|
|
#include <kwrap/debug.h>
|
|
#include <kwrap/util.h>
|
|
#include <kwrap/flag.h>
|
|
#include <FreeRTOS_POSIX.h>
|
|
#include <FreeRTOS_POSIX/pthread.h>
|
|
#include "PrjCfg.h"
|
|
#include "sys_fastboot.h"
|
|
#include "flow_preview.h"
|
|
#include "vendor_videocapture.h"
|
|
#include "vendor_common.h"
|
|
#include "vendor_isp.h"
|
|
#include "PhotoFast.h"
|
|
#include "UIAppPhoto.h"
|
|
#include "UIAppPhoto_Param.h"
|
|
#include "UIWnd/UIFlow.h"
|
|
#include "ImageApp/ImageApp_Photo.h"
|
|
#include "SysSensor.h"
|
|
#include "PhotoFastSliceEncode.h"
|
|
#include <kwrap/cmdsys.h>
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
#include <sf_mcu.h>
|
|
#endif
|
|
#include "flow_boot_logo.h"
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//header
|
|
#define DBGINFO_BUFSIZE() (0x200)
|
|
|
|
//RAW
|
|
#define VDO_RAW_BUFSIZE(w, h, pxlfmt) (ALIGN_CEIL_4((w) * HD_VIDEO_PXLFMT_BPP(pxlfmt) / 8) * (h))
|
|
//NRX: RAW compress: Only support 12bit mode
|
|
#define RAW_COMPRESS_RATIO 59
|
|
#define VDO_NRX_BUFSIZE(w, h) (ALIGN_CEIL_4(ALIGN_CEIL_64(w) * 12 / 8 * RAW_COMPRESS_RATIO / 100 * (h)))
|
|
//CA for AWB
|
|
#define VDO_CA_BUF_SIZE(win_num_w, win_num_h) ALIGN_CEIL_4((win_num_w * win_num_h << 3) << 1)
|
|
//LA for AE
|
|
#define VDO_LA_BUF_SIZE(win_num_w, win_num_h) ALIGN_CEIL_4((win_num_w * win_num_h << 1) << 1)
|
|
|
|
//YUV
|
|
#define VDO_YUV_BUFSIZE(w, h, pxlfmt) (ALIGN_CEIL_4((w) * HD_VIDEO_PXLFMT_BPP(pxlfmt) / 8) * (h))
|
|
//NVX: YUV compress
|
|
#define YUV_COMPRESS_RATIO 75
|
|
#define VDO_NVX_BUFSIZE(w, h, pxlfmt) (VDO_YUV_BUFSIZE(w, h, pxlfmt) * YUV_COMPRESS_RATIO / 100)
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define SEN_OUT_FMT HD_VIDEO_PXLFMT_RAW12
|
|
#define CAP_OUT_FMT HD_VIDEO_PXLFMT_RAW12
|
|
#define SHDR_CAP_OUT_FMT HD_VIDEO_PXLFMT_RAW12_SHDR2
|
|
#define CA_WIN_NUM_W 32
|
|
#define CA_WIN_NUM_H 32
|
|
#define LA_WIN_NUM_W 32
|
|
#define LA_WIN_NUM_H 32
|
|
#define VA_WIN_NUM_W 16
|
|
#define VA_WIN_NUM_H 16
|
|
#define YOUT_WIN_NUM_W 128
|
|
#define YOUT_WIN_NUM_H 128
|
|
#define ETH_8BIT_SEL 0 //0: 2bit out, 1:8 bit out
|
|
#define ETH_OUT_SEL 1 //0: full, 1: subsample 1/2
|
|
|
|
#define LCD_SIZE_W 960
|
|
#define LCD_SIZE_H 240
|
|
|
|
#define DEFAULT_TASK_STACK_SIZE 4096
|
|
#define FLOW_PREVIEW_TASK_STACK_SIZE 8192
|
|
#define FLAG_SENSOR_TASK_EXIT 0x00000001
|
|
#define FLAG_CAP_PROC_TASK_EXIT 0x00000002
|
|
#define FLAG_VOUT_TASK_EXIT 0x00000004
|
|
#define FLAG_FLOW_PREVIEW_TASK_EXIT 0x00000008
|
|
|
|
#define AE_PRESET_FUNC DISABLE
|
|
#if (AE_PRESET_FUNC == ENABLE)
|
|
#include "adc.h"
|
|
#define ADC_CH_PHOTORESISTOR ADC_CHANNEL_0
|
|
#define ADC_READY_RETRY_CNT (1000000/10) //1 sec
|
|
#endif
|
|
|
|
static ID flag_task = 0;
|
|
|
|
#if defined(_sen_sc4238_)
|
|
static UINT32 g_shdr_mode = 1;
|
|
#else
|
|
static UINT32 g_shdr_mode = 0;
|
|
#endif
|
|
extern UINT16 IRSHTTER;
|
|
extern void get_preset_param(void);
|
|
static ISP_SENSOR_INIT_INFO preset_param;
|
|
static BOOL g_stop_flag = FALSE;
|
|
|
|
void flow_preview_set_stop_flag(BOOL flag)
|
|
{
|
|
g_stop_flag = flag;
|
|
}
|
|
|
|
extern BOOL flow_preview_get_stop_flag(void)
|
|
{
|
|
return g_stop_flag;
|
|
}
|
|
|
|
ISP_SENSOR_INIT_INFO *sen_preset_param(void)
|
|
{
|
|
return &preset_param;
|
|
}
|
|
|
|
HD_RESULT fastflow_common_init(void)
|
|
{
|
|
static BOOL need_init = TRUE;
|
|
HD_RESULT ret = HD_OK;
|
|
HD_COMMON_MEM_INIT_CONFIG mem_cfg = {0};
|
|
|
|
// init hdal
|
|
if (need_init) {
|
|
ret = hd_common_init(0);
|
|
if (ret != HD_OK) {
|
|
printf("common fail=%d\n", ret);
|
|
return -1;
|
|
}
|
|
|
|
// init memory
|
|
// default
|
|
mem_cfg.pool_info[0].type = HD_COMMON_MEM_COMMON_POOL;
|
|
mem_cfg.pool_info[0].blk_size = DBGINFO_BUFSIZE() + 160*120*3/2;
|
|
mem_cfg.pool_info[0].blk_cnt = 1;
|
|
mem_cfg.pool_info[0].ddr_id = DDR_ID0;
|
|
|
|
ret = hd_common_mem_init(&mem_cfg);
|
|
if (ret != HD_OK) {
|
|
printf("mem_init fail=%d\n", ret);
|
|
return -1;
|
|
}
|
|
need_init = FALSE;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static HD_RESULT flowpreview_mem_relayout(void)
|
|
{
|
|
HD_RESULT ret;
|
|
HD_COMMON_MEM_INIT_CONFIG mem_cfg = {0};
|
|
UIAPP_PHOTO_SENSOR_INFO *pSensorInfo = UIAppPhoto_get_SensorInfo(0);
|
|
UINT8 idx = 0;
|
|
|
|
// config common pool (cap)
|
|
mem_cfg.pool_info[idx].type = HD_COMMON_MEM_COMMON_POOL;
|
|
mem_cfg.pool_info[idx].blk_size = DBGINFO_BUFSIZE()+VDO_RAW_BUFSIZE(pSensorInfo->sSize.w, pSensorInfo->sSize.h, CAP_OUT_FMT)
|
|
+VDO_CA_BUF_SIZE(CA_WIN_NUM_W, CA_WIN_NUM_H)
|
|
+VDO_LA_BUF_SIZE(LA_WIN_NUM_W, LA_WIN_NUM_H);
|
|
|
|
mem_cfg.pool_info[idx].blk_cnt = 6;
|
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
|
// config common pool (main)
|
|
// mem_cfg.pool_info[1].type = HD_COMMON_MEM_COMMON_POOL;
|
|
// mem_cfg.pool_info[1].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(pSensorInfo->sSize.w, pSensorInfo->sSize.h, HD_VIDEO_PXLFMT_YUV420);
|
|
// mem_cfg.pool_info[1].blk_cnt = 2;
|
|
// mem_cfg.pool_info[1].ddr_id = DDR_ID0;
|
|
|
|
|
|
#if POWERON_FAST_SLICE_ENC == ENABLE
|
|
idx++;
|
|
mem_cfg.pool_info[idx].type = HD_COMMON_MEM_COMMON_POOL;
|
|
mem_cfg.pool_info[idx].blk_size = PhotoFast_SliceEncode_Get_Max_Dst_Slice_Buffer_Size(HD_VIDEO_PXLFMT_YUV420);
|
|
mem_cfg.pool_info[idx].blk_cnt = 1;
|
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
|
|
|
DBG_DUMP("************ blk_size = %lx ************\n", mem_cfg.pool_info[idx].blk_size);
|
|
#else
|
|
|
|
// config common pool (primary image)
|
|
{
|
|
UINT32 u32W, u32H;
|
|
u32W = GetPhotoSizeWidth(SysGetFlag(FL_PHOTO_SIZE));
|
|
u32H = GetPhotoSizeHeight(SysGetFlag(FL_PHOTO_SIZE));
|
|
mem_cfg.pool_info[2].type = HD_COMMON_MEM_COMMON_POOL;
|
|
u32W = ALIGN_CEIL_16(u32W);
|
|
u32H = ALIGN_CEIL_16(u32H);
|
|
mem_cfg.pool_info[2].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(u32W, u32H, HD_VIDEO_PXLFMT_YUV420);
|
|
mem_cfg.pool_info[2].blk_cnt = 1;
|
|
mem_cfg.pool_info[2].ddr_id = DDR_ID0;
|
|
}
|
|
|
|
#endif
|
|
|
|
// config common pool (screennail image)
|
|
idx++;
|
|
mem_cfg.pool_info[idx].type = HD_COMMON_MEM_COMMON_POOL;
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
|
mem_cfg.pool_info[idx].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(sf_get_screen_nail_width(puiPara->SendPicSize), sf_get_screen_nail_height(puiPara->SendPicSize), HD_VIDEO_PXLFMT_YUV420);
|
|
|
|
#else
|
|
mem_cfg.pool_info[idx].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(CFG_SCREENNAIL_W, CFG_SCREENNAIL_H, HD_VIDEO_PXLFMT_YUV420);
|
|
#endif
|
|
mem_cfg.pool_info[idx].blk_cnt = 1;
|
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
|
// config common pool (thumbnail image)
|
|
idx++;
|
|
mem_cfg.pool_info[idx].type = HD_COMMON_MEM_COMMON_POOL;
|
|
mem_cfg.pool_info[idx].blk_size = DBGINFO_BUFSIZE()+VDO_YUV_BUFSIZE(CFG_THUMBNAIL_W, CFG_THUMBNAIL_H, HD_VIDEO_PXLFMT_YUV420);
|
|
mem_cfg.pool_info[idx].blk_cnt = 1;
|
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
|
// config common pool (EXIF)
|
|
idx++;
|
|
mem_cfg.pool_info[idx].type = HD_COMMON_MEM_COMMON_POOL;
|
|
mem_cfg.pool_info[idx].blk_size = DBGINFO_BUFSIZE()+CFG_JPG_HEADER_SIZE;
|
|
mem_cfg.pool_info[idx].blk_cnt = 1;
|
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
|
|
|
#if (_PACKAGE_BOOTLOGO_)
|
|
idx++;
|
|
mem_cfg.pool_info[idx].type = HD_COMMON_MEM_COMMON_POOL;
|
|
mem_cfg.pool_info[idx].blk_size = DBGINFO_BUFSIZE() + ((BOOT_LOGO_LCD_WIDTH * BOOT_LOGO_LCD_HEIGHT * 3) / 2);
|
|
mem_cfg.pool_info[idx].blk_cnt = 2;
|
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
|
#endif
|
|
|
|
ret = vendor_common_mem_relayout(&mem_cfg);
|
|
return ret;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static HD_RESULT set_cap_cfg(HD_PATH_ID *p_video_cap_ctrl)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
HD_VIDEOCAP_DRV_CONFIG cap_cfg = {0};
|
|
HD_PATH_ID video_cap_ctrl = 0;
|
|
HD_VIDEOCAP_CTRL iq_ctl = {0};
|
|
|
|
System_GetSensorInfo(0, SENSOR_DRV_CFG, &cap_cfg);
|
|
#if (SENSOR_SIEPATGEN == ENABLE)
|
|
snprintf(cap_cfg.sen_cfg.sen_dev.driver_name, HD_VIDEOCAP_SEN_NAME_LEN-1, "PATTERN_GEN");
|
|
#endif
|
|
|
|
printf("Using %s\n", cap_cfg.sen_cfg.sen_dev.driver_name);
|
|
|
|
if (g_shdr_mode == 1) {
|
|
printf("Using g_shdr_mode\n");
|
|
}
|
|
|
|
ret = hd_videocap_open(0, HD_VIDEOCAP_0_CTRL, &video_cap_ctrl); //open this for device control
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
|
|
if (g_shdr_mode == 1) {
|
|
cap_cfg.sen_cfg.shdr_map = HD_VIDEOCAP_SHDR_MAP(HD_VIDEOCAP_HDR_SENSOR1, (HD_VIDEOCAP_0|HD_VIDEOCAP_1));
|
|
}
|
|
ret |= hd_videocap_set(video_cap_ctrl, HD_VIDEOCAP_PARAM_DRV_CONFIG, &cap_cfg);
|
|
|
|
if (g_shdr_mode == 1) {
|
|
iq_ctl.func = HD_VIDEOCAP_FUNC_AE | HD_VIDEOCAP_FUNC_AWB | HD_VIDEOCAP_FUNC_SHDR;
|
|
} else {
|
|
iq_ctl.func = HD_VIDEOCAP_FUNC_AE | HD_VIDEOCAP_FUNC_AWB;
|
|
}
|
|
ret |= hd_videocap_set(video_cap_ctrl, HD_VIDEOCAP_PARAM_CTRL, &iq_ctl);
|
|
|
|
*p_video_cap_ctrl = video_cap_ctrl;
|
|
return ret;
|
|
}
|
|
|
|
static HD_RESULT set_cap_param(HD_PATH_ID video_cap_path, HD_DIM *p_dim)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
{//select sensor mode, manually or automatically
|
|
HD_VIDEOCAP_IN video_in_param = {0};
|
|
|
|
#if (SENSOR_SIEPATGEN == DISABLE)
|
|
video_in_param.sen_mode = HD_VIDEOCAP_SEN_MODE_AUTO; //auto select sensor mode by the parameter of HD_VIDEOCAP_PARAM_OUT
|
|
#else
|
|
UIAPP_PHOTO_SENSOR_INFO *pSensorInfo = UIAppPhoto_get_SensorInfo(0);
|
|
video_in_param.sen_mode = HD_VIDEOCAP_PATGEN_MODE(1, ALIGN_CEIL((pSensorInfo->sSize.w *10/65), 2));
|
|
#endif
|
|
|
|
#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE
|
|
video_in_param.frc = HD_VIDEO_FRC_RATIO(60,1);
|
|
#else
|
|
video_in_param.frc = HD_VIDEO_FRC_RATIO(30,1);
|
|
#endif
|
|
|
|
video_in_param.dim.w = p_dim->w;
|
|
video_in_param.dim.h = p_dim->h;
|
|
video_in_param.pxlfmt = SEN_OUT_FMT;
|
|
if (g_shdr_mode == 1) {
|
|
video_in_param.out_frame_num = HD_VIDEOCAP_SEN_FRAME_NUM_2;
|
|
} else {
|
|
video_in_param.out_frame_num = HD_VIDEOCAP_SEN_FRAME_NUM_1;
|
|
}
|
|
|
|
ret = hd_videocap_set(video_cap_path, HD_VIDEOCAP_PARAM_IN, &video_in_param);
|
|
//printf("set_cap_param MODE=%d\r\n", ret);
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
}
|
|
#if 0 //no crop, full frame
|
|
{
|
|
HD_VIDEOCAP_CROP video_crop_param = {0};
|
|
|
|
video_crop_param.mode = HD_CROP_OFF;
|
|
ret = hd_videocap_set(video_cap_path, HD_VIDEOCAP_PARAM_IN_CROP, &video_crop_param);
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
//printf("set_cap_param CROP NONE=%d\r\n", ret);
|
|
}
|
|
#else //HD_CROP_ON
|
|
{
|
|
HD_VIDEOCAP_CROP video_crop_param = {0};
|
|
|
|
video_crop_param.mode = HD_CROP_ON;
|
|
video_crop_param.win.rect.x = -1;
|
|
video_crop_param.win.rect.y = -1;
|
|
video_crop_param.win.rect.w = p_dim->w;
|
|
video_crop_param.win.rect.h = p_dim->h;
|
|
video_crop_param.align.w = 4;
|
|
video_crop_param.align.h = 4;
|
|
ret = hd_videocap_set(video_cap_path, HD_VIDEOCAP_PARAM_IN_CROP, &video_crop_param);
|
|
//printf("set_cap_param CROP ON=%d\r\n", ret);
|
|
}
|
|
#endif
|
|
|
|
{
|
|
HD_VIDEOCAP_OUT video_out_param = {0};
|
|
|
|
//without setting dim for no scaling, using original sensor out size
|
|
if (g_shdr_mode == 1) {
|
|
video_out_param.pxlfmt = SHDR_CAP_OUT_FMT;
|
|
} else {
|
|
video_out_param.pxlfmt = CAP_OUT_FMT;
|
|
}
|
|
video_out_param.dir = HD_VIDEO_DIR_NONE;
|
|
video_out_param.frc = 0;
|
|
|
|
#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE
|
|
video_out_param.depth = 1;
|
|
#else
|
|
video_out_param.depth = 0;
|
|
#endif
|
|
|
|
ret = hd_videocap_set(video_cap_path, HD_VIDEOCAP_PARAM_OUT, &video_out_param);
|
|
//printf("set_cap_param OUT=%d\r\n", ret);
|
|
}
|
|
|
|
{
|
|
UINT32 data_lane = 0;
|
|
System_GetSensorInfo(0, SENSOR_DATA_LANE, &data_lane);
|
|
if (data_lane) {
|
|
if ((ret = vendor_videocap_set(video_cap_path, VENDOR_VIDEOCAP_PARAM_DATA_LANE, &data_lane)) != HD_OK) {
|
|
DBG_ERR("set VENDOR_VIDEOCAP_PARAM_DATA_LANE fail(%d)\r\n", ret);
|
|
}
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
static HD_RESULT set_proc_cfg(HD_PATH_ID *p_video_proc_ctrl, HD_DIM* p_max_dim)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
HD_VIDEOPROC_DEV_CONFIG video_cfg_param = {0};
|
|
HD_PATH_ID video_proc_ctrl = 0;
|
|
HD_VIDEOPROC_CTRL video_ctrl_param = {0};
|
|
|
|
ret = hd_videoproc_open(0, HD_VIDEOPROC_0_CTRL, &video_proc_ctrl); //open this for device control
|
|
if (ret != HD_OK)
|
|
return ret;
|
|
|
|
if (p_max_dim != NULL ) {
|
|
video_cfg_param.pipe = HD_VIDEOPROC_PIPE_RAWALL;
|
|
video_cfg_param.isp_id = 0;
|
|
video_cfg_param.ctrl_max.func |=(HD_VIDEOPROC_FUNC_3DNR|HD_VIDEOPROC_FUNC_WDR|HD_VIDEOPROC_FUNC_COLORNR);
|
|
video_cfg_param.ctrl_max.func |=(HD_VIDEOPROC_FUNC_WDR|HD_VIDEOPROC_FUNC_COLORNR);
|
|
if (g_shdr_mode == 1) {
|
|
video_cfg_param.ctrl_max.func |= HD_VIDEOPROC_FUNC_SHDR;
|
|
}
|
|
video_cfg_param.in_max.func = 0;
|
|
video_cfg_param.in_max.dim.w = p_max_dim->w;
|
|
video_cfg_param.in_max.dim.h = p_max_dim->h;
|
|
if (g_shdr_mode == 1) {
|
|
video_cfg_param.in_max.pxlfmt = SHDR_CAP_OUT_FMT;
|
|
} else {
|
|
video_cfg_param.in_max.pxlfmt = CAP_OUT_FMT;
|
|
}
|
|
video_cfg_param.in_max.frc = HD_VIDEO_FRC_RATIO(1,1);
|
|
ret = hd_videoproc_set(video_proc_ctrl, HD_VIDEOPROC_PARAM_DEV_CONFIG, &video_cfg_param);
|
|
if (ret != HD_OK) {
|
|
return HD_ERR_NG;
|
|
}
|
|
}
|
|
|
|
#if 1
|
|
video_ctrl_param.func = HD_VIDEOPROC_FUNC_3DNR;
|
|
video_ctrl_param.ref_path_3dnr = HD_VIDEOPROC_OUT(0, 0);
|
|
ret = hd_videoproc_set(video_proc_ctrl, HD_VIDEOPROC_PARAM_CTRL, &video_ctrl_param);
|
|
#endif
|
|
video_ctrl_param.func |= (HD_VIDEOPROC_FUNC_WDR|HD_VIDEOPROC_FUNC_COLORNR);
|
|
ret = hd_videoproc_set(video_proc_ctrl, HD_VIDEOPROC_PARAM_CTRL, &video_ctrl_param);
|
|
|
|
if (g_shdr_mode == 1) {
|
|
video_ctrl_param.func |= HD_VIDEOPROC_FUNC_SHDR;
|
|
ret = hd_videoproc_set(video_proc_ctrl, HD_VIDEOPROC_PARAM_CTRL, &video_ctrl_param);
|
|
if (ret != HD_OK) {
|
|
return HD_ERR_NG;
|
|
}
|
|
}
|
|
|
|
*p_video_proc_ctrl = video_proc_ctrl;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static HD_RESULT set_proc_param(HD_PATH_ID video_proc_path, HD_DIM* p_dim)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
|
|
if (p_dim != NULL) { //if videoproc is already binding to dest module, not require to setting this!
|
|
HD_VIDEOPROC_OUT video_out_param = {0};
|
|
video_out_param.func = 0;
|
|
video_out_param.dim.w = p_dim->w;
|
|
video_out_param.dim.h = p_dim->h;
|
|
video_out_param.pxlfmt = HD_VIDEO_PXLFMT_YUV420;
|
|
video_out_param.dir = HD_VIDEO_DIR_NONE;
|
|
video_out_param.frc = HD_VIDEO_FRC_RATIO(1,1);
|
|
video_out_param.depth = 1; //set 1 to allow pull
|
|
ret = hd_videoproc_set(video_proc_path, HD_VIDEOPROC_PARAM_OUT, &video_out_param);
|
|
}
|
|
|
|
#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE
|
|
{
|
|
HD_VIDEOPROC_IN video_in_param = {0};
|
|
video_in_param.func = 0;
|
|
video_in_param.dim.w = p_dim->w;
|
|
video_in_param.dim.h = p_dim->h;
|
|
video_in_param.pxlfmt = HD_VIDEO_PXLFMT_RAW12;
|
|
video_in_param.dir = HD_VIDEO_DIR_NONE;
|
|
video_in_param.frc = HD_VIDEO_FRC_RATIO(1, 1);
|
|
ret = hd_videoproc_set(video_proc_path, HD_VIDEOPROC_PARAM_IN, &video_in_param);
|
|
}
|
|
#endif
|
|
|
|
return ret;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
#if (_PACKAGE_DISPLAY_)
|
|
static HD_RESULT set_out_cfg(HD_PATH_ID *p_video_out_ctrl, UINT32 out_type,HD_VIDEOOUT_HDMI_ID hdmi_id)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
HD_VIDEOOUT_MODE videoout_mode = {0};
|
|
HD_PATH_ID video_out_ctrl = 0;
|
|
|
|
ret = hd_videoout_open(0, HD_VIDEOOUT_0_CTRL, &video_out_ctrl); //open this for device control
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
|
|
printf("out_type=%d\r\n", (int)out_type);
|
|
|
|
#if 1
|
|
videoout_mode.output_type = HD_COMMON_VIDEO_OUT_LCD;
|
|
videoout_mode.input_dim = HD_VIDEOOUT_IN_AUTO;
|
|
videoout_mode.output_mode.lcd = HD_VIDEOOUT_LCD_0;
|
|
if (out_type != 1) {
|
|
printf("520 only support LCD\r\n");
|
|
}
|
|
#else
|
|
switch(out_type){
|
|
case 0:
|
|
videoout_mode.output_type = HD_COMMON_VIDEO_OUT_CVBS;
|
|
videoout_mode.input_dim = HD_VIDEOOUT_IN_AUTO;
|
|
videoout_mode.output_mode.cvbs= HD_VIDEOOUT_CVBS_NTSC;
|
|
break;
|
|
case 1:
|
|
videoout_mode.output_type = HD_COMMON_VIDEO_OUT_LCD;
|
|
videoout_mode.input_dim = HD_VIDEOOUT_IN_AUTO;
|
|
videoout_mode.output_mode.lcd = HD_VIDEOOUT_LCD_0;
|
|
break;
|
|
case 2:
|
|
videoout_mode.output_type = HD_COMMON_VIDEO_OUT_HDMI;
|
|
videoout_mode.input_dim = HD_VIDEOOUT_IN_AUTO;
|
|
videoout_mode.output_mode.hdmi= hdmi_id;
|
|
break;
|
|
default:
|
|
printf("not support out_type\r\n");
|
|
break;
|
|
}
|
|
#endif
|
|
ret = hd_videoout_set(video_out_ctrl, HD_VIDEOOUT_PARAM_MODE, &videoout_mode);
|
|
|
|
*p_video_out_ctrl=video_out_ctrl ;
|
|
return ret;
|
|
}
|
|
|
|
static HD_RESULT get_out_caps(HD_PATH_ID video_out_ctrl,HD_VIDEOOUT_SYSCAPS *p_video_out_syscaps)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
HD_DEVCOUNT video_out_dev = {0};
|
|
|
|
ret = hd_videoout_get(video_out_ctrl, HD_VIDEOOUT_PARAM_DEVCOUNT, &video_out_dev);
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
printf("##devcount %d\r\n", (int)video_out_dev.max_dev_count);
|
|
|
|
ret = hd_videoout_get(video_out_ctrl, HD_VIDEOOUT_PARAM_SYSCAPS, p_video_out_syscaps);
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
static HD_RESULT set_out_param(HD_PATH_ID video_out_path, HD_DIM *p_dim)
|
|
{
|
|
HD_RESULT ret = HD_OK;
|
|
HD_VIDEOOUT_IN video_out_param={0};
|
|
|
|
video_out_param.dim.w = p_dim->w;
|
|
video_out_param.dim.h = p_dim->h;
|
|
video_out_param.pxlfmt = HD_VIDEO_PXLFMT_YUV420;
|
|
video_out_param.dir = HD_VIDEO_DIR_NONE;
|
|
ret = hd_videoout_set(video_out_path, HD_VIDEOOUT_PARAM_IN, &video_out_param);
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
memset((void *)&video_out_param,0,sizeof(HD_VIDEOOUT_IN));
|
|
ret = hd_videoout_get(video_out_path, HD_VIDEOOUT_PARAM_IN, &video_out_param);
|
|
if (ret != HD_OK) {
|
|
return ret;
|
|
}
|
|
printf("##video_out_param w:%d,h:%d %x %x\r\n", (int)video_out_param.dim.w, (int)video_out_param.dim.h, (int)video_out_param.pxlfmt, (int)video_out_param.dir);
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
typedef struct _VIDEO_LIVEVIEW {
|
|
|
|
// (1)
|
|
HD_VIDEOCAP_SYSCAPS cap_syscaps;
|
|
HD_PATH_ID cap_ctrl;
|
|
HD_PATH_ID cap_path;
|
|
|
|
HD_DIM cap_dim;
|
|
HD_DIM proc_max_dim;
|
|
HD_DIM proc_dim;
|
|
|
|
// (2)
|
|
HD_VIDEOPROC_SYSCAPS proc_syscaps;
|
|
HD_PATH_ID proc_ctrl;
|
|
HD_PATH_ID proc_path;
|
|
|
|
HD_DIM out_max_dim;
|
|
HD_DIM out_dim;
|
|
|
|
// (3)
|
|
HD_VIDEOOUT_SYSCAPS out_syscaps;
|
|
HD_PATH_ID out_ctrl;
|
|
HD_PATH_ID out_path;
|
|
|
|
HD_VIDEOOUT_HDMI_ID hdmi_id;
|
|
} VIDEO_LIVEVIEW;
|
|
|
|
static VIDEO_LIVEVIEW stream[1] = {0}; //0: main stream
|
|
static UINT32 out_type = 1;
|
|
|
|
static void fast_open_sensor(void)
|
|
{
|
|
#if 0
|
|
VENDOR_VIDEOCAP_FAST_OPEN_SENSOR cap_cfg = {0};
|
|
|
|
snprintf(cap_cfg.sen_cfg.sen_dev.driver_name, HD_VIDEOCAP_SEN_NAME_LEN-1, SEN_DRVIVER_NAME);
|
|
cap_cfg.sen_cfg.sen_dev.if_type = SEN_IF_TYPE;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.pinmux.sensor_pinmux = SEN_PINMUX;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.pinmux.serial_if_pinmux = SERIAL_IF_PINMUX;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.pinmux.cmd_if_pinmux = CMD_IF_PINMUX;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.clk_lane_sel = CLK_LANE_SEL;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[0] = PIN_MAP_0;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[1] = PIN_MAP_1;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[2] = PIN_MAP_2;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[3] = PIN_MAP_3;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[4] = PIN_MAP_4;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[5] = PIN_MAP_5;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[6] = PIN_MAP_6;
|
|
cap_cfg.sen_cfg.sen_dev.pin_cfg.sen_2_serial_pin_map[7] = PIN_MAP_7;
|
|
cap_cfg.sen_mode = 0;
|
|
cap_cfg.frc = HD_VIDEO_FRC_RATIO(30,1);
|
|
#if (AE_PRESET_FUNC == ENABLE)
|
|
cap_cfg.ae_preset.enable = TRUE;
|
|
get_ae_preset(&cap_cfg.ae_preset.exp_time, &cap_cfg.ae_preset.gain_ratio);
|
|
#endif
|
|
vendor_videocap_set(0, VENDOR_VIDEOCAP_PARAM_FAST_OPEN_SENSOR, &cap_cfg);
|
|
#endif
|
|
}
|
|
|
|
static HD_RESULT init_module_cap_proc(void)
|
|
{
|
|
HD_RESULT ret;
|
|
if ((ret = hd_videocap_init()) != HD_OK)
|
|
return ret;
|
|
if ((ret = hd_videoproc_init()) != HD_OK)
|
|
return ret;
|
|
return HD_OK;
|
|
}
|
|
|
|
#if (_PACKAGE_DISPLAY_)
|
|
static HD_RESULT init_module_videoout(void)
|
|
{
|
|
HD_RESULT ret;
|
|
if ((ret = hd_videoout_init()) != HD_OK) {
|
|
printf("failed to hd_videoout_init:%d\n", ret);
|
|
return ret;
|
|
}
|
|
return HD_OK;
|
|
}
|
|
#endif
|
|
|
|
static HD_RESULT open_module_cap_proc(VIDEO_LIVEVIEW *p_stream, HD_DIM* p_proc_max_dim, UINT32 out_type)
|
|
{
|
|
HD_RESULT ret;
|
|
// set videocap config
|
|
ret = set_cap_cfg(&p_stream->cap_ctrl);
|
|
if (ret != HD_OK) {
|
|
printf("set cap-cfg fail=%d\n", ret);
|
|
return HD_ERR_NG;
|
|
}
|
|
// set videoproc config
|
|
ret = set_proc_cfg(&p_stream->proc_ctrl, p_proc_max_dim);
|
|
if (ret != HD_OK) {
|
|
printf("set proc-cfg fail=%d\n", ret);
|
|
return HD_ERR_NG;
|
|
}
|
|
if ((ret = hd_videocap_open(HD_VIDEOCAP_0_IN_0, HD_VIDEOCAP_0_OUT_0, &p_stream->cap_path)) != HD_OK)
|
|
return ret;
|
|
|
|
if ((ret = hd_videoproc_open(HD_VIDEOPROC_0_IN_0, HD_VIDEOPROC_0_OUT_0, &p_stream->proc_path)) != HD_OK)
|
|
return ret;
|
|
|
|
return HD_OK;
|
|
}
|
|
|
|
#if (_PACKAGE_DISPLAY_)
|
|
static HD_RESULT open_module_videoout(VIDEO_LIVEVIEW *p_stream, HD_DIM* p_proc_max_dim, UINT32 out_type)
|
|
{
|
|
HD_RESULT ret;
|
|
// set videoout config
|
|
ret = set_out_cfg(&p_stream->out_ctrl, out_type,p_stream->hdmi_id);
|
|
if (ret != HD_OK) {
|
|
printf("set out-cfg fail=%d\n", ret);
|
|
return HD_ERR_NG;
|
|
}
|
|
|
|
if ((ret = hd_videoout_open(HD_VIDEOOUT_0_IN_0, HD_VIDEOOUT_0_OUT_0, &p_stream->out_path)) != HD_OK)
|
|
return ret;
|
|
|
|
return HD_OK;
|
|
}
|
|
#endif
|
|
|
|
static THREAD_RETTYPE thread_sensor(void *ptr)
|
|
{
|
|
fastboot_wait_done(BOOT_INIT_SENSOR);
|
|
// vos_perf_list_mark("ss", __LINE__, 0);
|
|
//quick sensor setup flow
|
|
fast_open_sensor();
|
|
// vos_perf_list_mark("ss", __LINE__, 1);
|
|
|
|
vos_flag_set(flag_task, FLAG_SENSOR_TASK_EXIT);
|
|
THREAD_RETURN(0);
|
|
}
|
|
|
|
static THREAD_RETTYPE thread_cap_proc(void *ptr)
|
|
{
|
|
HD_RESULT ret;
|
|
UIAPP_PHOTO_SENSOR_INFO *pSensorInfo = UIAppPhoto_get_SensorInfo(0);
|
|
ISPT_TOTAL_GAIN total_gain = {0};
|
|
|
|
// wait sensor setup ready
|
|
#if 0
|
|
int join_ret;
|
|
pthread_t *p_handle_sensor = (pthread_t *)ptr;
|
|
int pthread_ret = pthread_join(*p_handle_sensor, (void *)&join_ret);
|
|
if (0 != pthread_ret) {
|
|
printf("thread_sensor pthread_join failed, ret %d\r\n", pthread_ret);
|
|
pthread_exit((void *)-1);
|
|
return NULL;
|
|
}
|
|
#endif
|
|
|
|
// wait driver init ready
|
|
fastboot_wait_done(BOOT_INIT_CAPTURE);
|
|
vos_perf_list_mark("capproc", __LINE__, 0);
|
|
|
|
stream[0].hdmi_id=HD_VIDEOOUT_HDMI_1920X1080I60;//default
|
|
|
|
// init capture, proc
|
|
ret = init_module_cap_proc();
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("init fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
// open capture, proc
|
|
stream[0].proc_max_dim.w = pSensorInfo->sSize.w; //assign by user
|
|
stream[0].proc_max_dim.h = pSensorInfo->sSize.h; //assign by user
|
|
ret = open_module_cap_proc(&stream[0], &stream[0].proc_max_dim, out_type);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("open fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
// set videocap parameter
|
|
stream[0].cap_dim.w = pSensorInfo->sSize.w; //assign by user
|
|
stream[0].cap_dim.h = pSensorInfo->sSize.h; //assign by user
|
|
ret = set_cap_param(stream[0].cap_path, &stream[0].cap_dim);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("set cap fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
// set videoproc parameter (main)
|
|
#if 0
|
|
stream[0].proc_dim.w = LCD_SIZE_W;
|
|
stream[0].proc_dim.h = LCD_SIZE_H;
|
|
#else
|
|
stream[0].proc_dim.w = pSensorInfo->sSize.w;
|
|
stream[0].proc_dim.h = pSensorInfo->sSize.h;
|
|
#endif
|
|
ret = set_proc_param(stream[0].proc_path, &stream[0].proc_dim);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("set proc fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
// bind video_liveview modules (main)
|
|
#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE
|
|
#else
|
|
hd_videocap_bind(HD_VIDEOCAP_0_OUT_0, HD_VIDEOPROC_0_IN_0);
|
|
#endif
|
|
|
|
// start video_liveview modules (main)
|
|
hd_videocap_start(stream[0].cap_path);
|
|
vos_perf_list_mark("capproc", __LINE__, 1);
|
|
|
|
hd_videoproc_start(stream[0].proc_path);
|
|
|
|
total_gain.id = 0;
|
|
total_gain.gain = preset_param.gain/10;
|
|
vendor_isp_set_common(ISPT_ITEM_TOTAL_GAIN, &total_gain);
|
|
|
|
#if 0
|
|
// get first frame
|
|
HD_VIDEO_FRAME video_frame = {0};
|
|
hd_videoproc_pull_out_buf(stream[0].proc_path, &video_frame, -1);
|
|
hd_videoproc_release_out_buf(stream[0].proc_path, &video_frame);
|
|
#endif
|
|
|
|
vos_perf_list_mark("capproc", __LINE__, 2);
|
|
exit:
|
|
vos_flag_set(flag_task, FLAG_CAP_PROC_TASK_EXIT);
|
|
THREAD_RETURN(0);
|
|
}
|
|
|
|
#if (_PACKAGE_DISPLAY_)
|
|
static THREAD_RETTYPE thread_videoout(void *ptr)
|
|
{
|
|
HD_RESULT ret;
|
|
UIAPP_PHOTO_SENSOR_INFO *pSensorInfo = UIAppPhoto_get_SensorInfo(0);
|
|
|
|
fastboot_wait_done(BOOT_INIT_DISPLAY);
|
|
vos_perf_list_mark("disp", __LINE__, 0);
|
|
|
|
// init videoout
|
|
ret = init_module_videoout();
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("init fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
// open capture, proc modules (main)
|
|
stream[0].proc_max_dim.w = pSensorInfo->sSize.w; //assign by user
|
|
stream[0].proc_max_dim.h = pSensorInfo->sSize.h; //assign by user
|
|
ret = open_module_videoout(&stream[0], &stream[0].proc_max_dim, out_type);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("open fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
// get videoout capability
|
|
ret = get_out_caps(stream[0].out_ctrl, &stream[0].out_syscaps);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("get out-caps fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
stream[0].out_max_dim = stream[0].out_syscaps.output_dim;
|
|
|
|
// set videoout parameter (main)
|
|
stream[0].out_dim.w = stream[0].out_max_dim.w; //using device max dim.w
|
|
stream[0].out_dim.h = stream[0].out_max_dim.h; //using device max dim.h
|
|
ret = set_out_param(stream[0].out_path, &stream[0].out_dim);
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("set out fail=%d\n", ret);
|
|
goto exit;
|
|
}
|
|
|
|
if (hd_videoout_start(stream[0].out_path) != HD_OK) {
|
|
DBG_ERR("hd_videoout_start fail\n");
|
|
goto exit;
|
|
}
|
|
|
|
vos_perf_list_mark("disp", __LINE__, 1);
|
|
|
|
exit:
|
|
vos_flag_set(flag_task, FLAG_VOUT_TASK_EXIT);
|
|
THREAD_RETURN(0);
|
|
}
|
|
#endif
|
|
|
|
void flow_preview_get_path(HD_PATH_ID *pPath, FLOW_PREIVEW_PATH PathType, UINT32 id)
|
|
{
|
|
switch (PathType) {
|
|
case FLOW_PREIVEW_VCAP_PATH:
|
|
*pPath = stream[0].cap_path;
|
|
break;
|
|
|
|
case FLOW_PREIVEW_VPRC_PATH:
|
|
*pPath = stream[0].proc_path;
|
|
break;
|
|
|
|
case FLOW_PREIVEW_VOUT_PATH:
|
|
*pPath = stream[0].out_path;
|
|
break;
|
|
|
|
case FLOW_PREIVEW_VENC_PATH:
|
|
break;
|
|
|
|
default:
|
|
DBG_ERR("No path type is selected\r\n");
|
|
break;
|
|
}
|
|
}
|
|
|
|
extern void Set_NIGHTMODE(UINT32 id, UINT8 isSnapVideo);
|
|
extern void DrvGOIO_Turn_Onoff_IRCUT(UINT8 onoff);
|
|
int flow_preview(void)
|
|
{
|
|
int ret;
|
|
// int join_ret;
|
|
VK_TASK_HANDLE handle_sensor = 0;
|
|
VK_TASK_HANDLE handle_cap_proc = 0;
|
|
VK_TASK_HANDLE handle_preview = 0;
|
|
// int policy;
|
|
PHOTO_SENSOR_INFO sen_cfg = {0};
|
|
PHOTO_SENSOR_INFO *pSenCfg = &sen_cfg;
|
|
HD_RESULT hd_ret;
|
|
// struct sched_param schedparam = {0};
|
|
T_CFLG cflg = {0};
|
|
FLGPTN flag_ptn;
|
|
|
|
#if (_PACKAGE_DISPLAY_)
|
|
VK_TASK_HANDLE handle_videoout = 0;
|
|
#endif
|
|
|
|
if(!flag_task){
|
|
if ((ret = vos_flag_create(&flag_task, &cflg, "flow_preview")) != E_OK) {
|
|
DBG_ERR("create flag failed!(%d)\n", ret);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
// quick sensor setup
|
|
vos_flag_clr(flag_task, FLAG_SENSOR_TASK_EXIT);
|
|
handle_sensor = vos_task_create(thread_sensor, NULL, "init_sensor", 10, DEFAULT_TASK_STACK_SIZE);
|
|
if(!handle_sensor){
|
|
DBG_ERR("create thread_sensor failed\r\n");
|
|
return -1;
|
|
}
|
|
else
|
|
vos_task_resume(handle_sensor);
|
|
|
|
//hd_common_init(including vds), must wait until insmod_capture()
|
|
fastboot_wait_done(BOOT_INIT_CAPTURE);
|
|
|
|
// init hdal
|
|
ret = fastflow_common_init();
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("init fail\r\n");
|
|
}
|
|
ret = flowpreview_mem_relayout();
|
|
if (ret != HD_OK) {
|
|
DBG_ERR("relayout fail\r\n");
|
|
}
|
|
|
|
//load ae/awb/iq
|
|
System_GetSensorInfo(0, SENSOR_AE_PATH, &(sen_cfg.ae_path));
|
|
System_GetSensorInfo(0, SENSOR_AWB_PATH, &(sen_cfg.awb_path));
|
|
System_GetSensorInfo(0, SENSOR_IQ_PATH, &(sen_cfg.iq_path));
|
|
System_GetSensorInfo(0, SENSOR_IQ_SHADING_PATH, &(sen_cfg.iq_shading_path));
|
|
System_GetSensorInfo(0, SENSOR_IQ_DPC_PATH, &(sen_cfg.iq_dpc_path));
|
|
System_GetSensorInfo(0, SENSOR_IQ_LDC_PATH, &(sen_cfg.iq_ldc_path));
|
|
|
|
if ((hd_ret = vendor_isp_init()) != HD_OK) {
|
|
DBG_ERR("vendor_isp_init fail(%d)\n", hd_ret);
|
|
}
|
|
|
|
if (strlen(pSenCfg->ae_path.path) != 0) {
|
|
AET_DTSI_INFO ae_dtsi_info;
|
|
ae_dtsi_info.id = pSenCfg->ae_path.id;
|
|
strncpy(ae_dtsi_info.node_path, pSenCfg->ae_path.path, 31);
|
|
strncpy(ae_dtsi_info.file_path, "null", DTSI_NAME_LENGTH);
|
|
ae_dtsi_info.buf_addr = (UINT8 *)pSenCfg->ae_path.addr;
|
|
if ((hd_ret = vendor_isp_set_ae(AET_ITEM_RLD_DTSI, &ae_dtsi_info)) != HD_OK) {
|
|
DBG_ERR("vendor_isp_set_ae fail(%d)\r\n", hd_ret);
|
|
}
|
|
}
|
|
if (strlen(pSenCfg->awb_path.path) != 0) {
|
|
AWBT_DTSI_INFO awb_dtsi_info;
|
|
awb_dtsi_info.id = pSenCfg->awb_path.id;
|
|
strncpy(awb_dtsi_info.node_path, pSenCfg->awb_path.path, 31);
|
|
strncpy(awb_dtsi_info.file_path, "null", DTSI_NAME_LENGTH);
|
|
awb_dtsi_info.buf_addr = (UINT8 *)pSenCfg->awb_path.addr;
|
|
if ((hd_ret = vendor_isp_set_awb(AWBT_ITEM_RLD_DTSI, &awb_dtsi_info)) != HD_OK) {
|
|
DBG_ERR("vendor_isp_set_awb fail(%d)\r\n", hd_ret);
|
|
}
|
|
}
|
|
if (strlen(pSenCfg->iq_path.path) != 0) {
|
|
IQT_DTSI_INFO iq_dtsi_info;
|
|
iq_dtsi_info.id = pSenCfg->iq_path.id;
|
|
strncpy(iq_dtsi_info.node_path, pSenCfg->iq_path.path, 31);
|
|
strncpy(iq_dtsi_info.file_path, "null", DTSI_NAME_LENGTH);
|
|
iq_dtsi_info.buf_addr = (UINT8 *)pSenCfg->iq_path.addr;
|
|
if ((hd_ret = vendor_isp_set_iq(IQT_ITEM_RLD_DTSI, &iq_dtsi_info)) != HD_OK) {
|
|
DBG_ERR("vendor_isp_set_iq fail(%d)\r\n", hd_ret);
|
|
}
|
|
}
|
|
if (strlen(pSenCfg->iq_shading_path.path) != 0) {
|
|
IQT_DTSI_INFO iq_dtsi_info;
|
|
iq_dtsi_info.id = pSenCfg->iq_shading_path.id;
|
|
strncpy(iq_dtsi_info.node_path, pSenCfg->iq_shading_path.path, 31);
|
|
strncpy(iq_dtsi_info.file_path, "null", DTSI_NAME_LENGTH);
|
|
iq_dtsi_info.buf_addr = (UINT8 *)pSenCfg->iq_shading_path.addr;
|
|
if ((hd_ret = vendor_isp_set_iq(IQT_ITEM_RLD_DTSI, &iq_dtsi_info)) != HD_OK) {
|
|
DBG_ERR("vendor_isp_set_iq fail(%d)\r\n", hd_ret);
|
|
ret = E_SYS;
|
|
}
|
|
}
|
|
if (strlen(pSenCfg->iq_dpc_path.path) != 0) {
|
|
IQT_DTSI_INFO iq_dtsi_info;
|
|
iq_dtsi_info.id = pSenCfg->iq_dpc_path.id;
|
|
strncpy(iq_dtsi_info.node_path, pSenCfg->iq_dpc_path.path, 31);
|
|
strncpy(iq_dtsi_info.file_path, "null", DTSI_NAME_LENGTH);
|
|
iq_dtsi_info.buf_addr = (UINT8 *)pSenCfg->iq_dpc_path.addr;
|
|
if ((hd_ret = vendor_isp_set_iq(IQT_ITEM_RLD_DTSI, &iq_dtsi_info)) != HD_OK) {
|
|
DBG_ERR("vendor_isp_set_iq fail(%d)\r\n", hd_ret);
|
|
ret = E_SYS;
|
|
}
|
|
}
|
|
if (strlen(pSenCfg->iq_ldc_path.path) != 0) {
|
|
IQT_DTSI_INFO iq_dtsi_info;
|
|
iq_dtsi_info.id = pSenCfg->iq_ldc_path.id;
|
|
strncpy(iq_dtsi_info.node_path, pSenCfg->iq_ldc_path.path, 31);
|
|
strncpy(iq_dtsi_info.file_path, "null", DTSI_NAME_LENGTH);
|
|
iq_dtsi_info.buf_addr = (UINT8 *)pSenCfg->iq_ldc_path.addr;
|
|
if ((hd_ret = vendor_isp_set_iq(IQT_ITEM_RLD_DTSI, &iq_dtsi_info)) != HD_OK) {
|
|
DBG_ERR("vendor_isp_set_iq fail(%d)\r\n", hd_ret);
|
|
ret = E_SYS;
|
|
}
|
|
}
|
|
|
|
if ((hd_ret = vendor_isp_uninit()) != HD_OK) {
|
|
DBG_ERR("vendor_isp_uninit fail(%d)\n", hd_ret);
|
|
}
|
|
|
|
|
|
vos_flag_clr(flag_task, FLAG_CAP_PROC_TASK_EXIT);
|
|
handle_cap_proc = vos_task_create(thread_cap_proc, NULL, "cap_proc", 10, DEFAULT_TASK_STACK_SIZE);
|
|
if(!handle_cap_proc){
|
|
DBG_ERR("create thread_cap_proc failed\r\n");
|
|
return -1;
|
|
}
|
|
else
|
|
vos_task_resume(handle_cap_proc);
|
|
Set_NIGHTMODE(0, 0);
|
|
|
|
#if (_PACKAGE_DISPLAY_)
|
|
vos_flag_clr(flag_task, FLAG_VOUT_TASK_EXIT);
|
|
handle_videoout = vos_task_create(thread_videoout, NULL, "vout", 9, DEFAULT_TASK_STACK_SIZE);
|
|
if(!handle_videoout){
|
|
DBG_ERR("create thread_videoout failed\r\n");
|
|
return -1;
|
|
}
|
|
else
|
|
vos_task_resume(handle_videoout);
|
|
#endif
|
|
vos_flag_wait(&flag_ptn, flag_task, FLAG_CAP_PROC_TASK_EXIT, (TWF_ORW | TWF_CLR));
|
|
vos_task_destroy(handle_cap_proc);
|
|
#if (_PACKAGE_DISPLAY_)
|
|
vos_flag_wait(&flag_ptn, flag_task, FLAG_VOUT_TASK_EXIT, (TWF_ORW | TWF_CLR));
|
|
vos_task_destroy(handle_videoout);
|
|
#endif
|
|
// DrvGOIO_Turn_Onoff_IRCUT(0);
|
|
// start video_preview
|
|
|
|
// nvt_cmdsys_runcmd("nvtmpp info");
|
|
|
|
vos_flag_clr(flag_task, FLAG_FLOW_PREVIEW_TASK_EXIT);
|
|
handle_preview = vos_task_create(PhotoFast_FlowPreviewThread, NULL, "flow_preview", 10, FLOW_PREVIEW_TASK_STACK_SIZE);
|
|
if(!handle_preview){
|
|
DBG_ERR("create thread_preview failed\r\n");
|
|
return -1;
|
|
}
|
|
else
|
|
vos_task_resume(handle_preview);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void flow_preview_close_module(void)
|
|
{
|
|
HD_RESULT hd_ret;
|
|
|
|
if(stream[0].cap_path){
|
|
hd_ret = hd_videocap_stop(stream[0].cap_path);
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vcap stop failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
}
|
|
|
|
if(stream[0].proc_path){
|
|
hd_ret = hd_videoproc_stop(stream[0].proc_path);
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vprc stop failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
}
|
|
|
|
if(stream[0].cap_path){
|
|
hd_ret = hd_videocap_close(stream[0].cap_path);
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vcap close failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
}
|
|
|
|
if(stream[0].proc_path){
|
|
hd_ret = hd_videoproc_close(stream[0].proc_path);
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vprc close failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
}
|
|
|
|
#if HUNTING_PHOTO_FAST_AE_60_FPS == ENABLE
|
|
|
|
#else
|
|
if(stream[0].cap_path){
|
|
hd_ret = hd_videocap_unbind(HD_VIDEOCAP_0_OUT_0);
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vcap unbind failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
}
|
|
|
|
void flow_preview_uninit_module(void)
|
|
{
|
|
HD_RESULT hd_ret;
|
|
|
|
hd_ret = hd_videocap_uninit();
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vcap uninit failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
|
|
hd_ret = hd_videoproc_uninit();
|
|
if (hd_ret != HD_OK) {
|
|
DBG_ERR("vprc uninit failed, hd_ret = %d\r\n", hd_ret);
|
|
}
|
|
}
|
|
|
|
#if 1 //for pre set ae
|
|
static UINT32 ae_adc_tbl[57][3] = {
|
|
#if 1 //for S530 200K RSS photodie
|
|
{980, 44, 1000},
|
|
{970, 73, 1000},
|
|
{960, 88, 1000},
|
|
{945, 99, 1130},
|
|
{930, 103, 1000},
|
|
{910, 126, 1070},
|
|
{900, 135, 1020},
|
|
{885, 153, 1040},
|
|
{870, 160, 1090},
|
|
{859, 177, 1010},
|
|
{854, 258, 1000},
|
|
{849, 500, 1000},
|
|
{845, 768, 1000},
|
|
{842, 984, 1000},
|
|
{839, 1372, 1000},
|
|
{830, 2236, 1000},
|
|
{828, 3459, 1000},
|
|
{824, 5213, 1000},
|
|
{822, 7232, 1000},
|
|
{813, 8333, 1280},
|
|
{809, 8333, 2380},
|
|
{799, 16666, 4300},
|
|
{787, 16666, 6390},
|
|
{735, 16666, 7990},
|
|
{686, 16666, 8460},
|
|
{652, 16666, 9530},
|
|
{613, 16666, 10690},
|
|
{576, 16666, 2310},//night
|
|
{541, 16666, 2310},
|
|
{509, 16666, 2310},
|
|
{480, 16666, 2310},
|
|
{458, 16666, 2310},
|
|
{421, 16666, 2310},
|
|
{399, 16666, 2310},
|
|
{363, 16666, 2310},
|
|
{322, 16666, 2310},// 12190},
|
|
{288, 16666, 2310},// 26600},
|
|
{246, 16666, 2310}, //45770},
|
|
{216, 16666, 2310},
|
|
{188, 16666, 1000},
|
|
{162, 16666, 1000},
|
|
{151, 16666, 1000},
|
|
{138, 16666, 1000},
|
|
{118, 16666, 1000},
|
|
{96, 16666, 1280},
|
|
{80, 16666, 2000},
|
|
{62, 16666, 2000},
|
|
{48, 20000, 2000},
|
|
{35, 20000, 2000},
|
|
{26, 33333, 1100},
|
|
{19, 33333, 1100},
|
|
{13, 33333, 1100},
|
|
{10, 33333, 1100},
|
|
{8, 33333, 2100},
|
|
{4, 33333, 3100},
|
|
{2, 33333, 3400},
|
|
//{1, 33333, 3500},
|
|
{0, 33333, 4000},
|
|
|
|
#else // 1K RSS
|
|
{980, 120, 1000},
|
|
{970, 120, 1000},
|
|
{960, 120, 1000},
|
|
{945, 120, 1000},
|
|
{930, 120, 1000},
|
|
{910, 120, 1000},
|
|
{900, 120, 1000},
|
|
{885, 120, 1000},
|
|
{870, 200, 1000},
|
|
{850, 200, 1000},
|
|
{840, 200, 1000},
|
|
{832, 200, 1000},
|
|
{820, 200, 1000},
|
|
{816, 200, 1000},
|
|
{810, 200, 1000},
|
|
{805, 200, 1000},
|
|
{800, 200, 1000},
|
|
{787, 200, 1000},
|
|
{750, 200, 1000},
|
|
{723, 200, 1000},
|
|
{671, 200, 1000},
|
|
{641, 200, 1000},
|
|
{600, 200, 1000},
|
|
{538, 300, 1000},
|
|
{503, 300, 1000},
|
|
{484, 300, 1000},
|
|
{466, 300, 1000},
|
|
{414, 400, 1000},
|
|
{347, 400, 1000},
|
|
{353, 400, 1000},
|
|
{330, 500, 1000},
|
|
{324, 500, 1000},
|
|
{314, 500, 1000},
|
|
{306, 600, 1000},
|
|
{277, 600, 1000},
|
|
{257, 800, 1000},
|
|
{109, 900, 1000},
|
|
{84, 1000, 1000},
|
|
{76, 1200, 1000},// night
|
|
{60, 2700, 1000},
|
|
{49, 4201, 1000},
|
|
{36, 5801, 1000},
|
|
{31, 7332, 1000},
|
|
{26, 7332, 1000},
|
|
{19, 8333, 1000},
|
|
{17, 8333, 1000},
|
|
{15, 8333, 1000},
|
|
{13, 8333, 1000},
|
|
{12, 8333, 1000},
|
|
{11, 8333, 1000},
|
|
{10, 8333, 1000},
|
|
{9, 8333, 1000},
|
|
{8, 8333, 1000},
|
|
{6, 8333, 1000},
|
|
{5, 8333, 1000},
|
|
{1, 16666, 1000},
|
|
{0, 33333, 4000},
|
|
#endif
|
|
};
|
|
|
|
|
|
void ae_adc_get_exp_photo(UINT16 adc_value, UINT32 *exptime, UINT32 *isogain)
|
|
{
|
|
UINT32 idx0=0, idx1=0;
|
|
UINT32 exptime0, exptime1, isogain0, isogain1;
|
|
UINT32 adc_ev, ev0, ev1;
|
|
|
|
for(idx1=1; idx1<56; idx1++) {
|
|
//if(adc_value > ae_adc_tbl[idx1][0])
|
|
if(adc_value>=ae_adc_tbl[idx1][0])
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
if(adc_value>ae_adc_tbl[0][0]) {
|
|
*exptime = ae_adc_tbl[0][1];
|
|
*isogain = ae_adc_tbl[0][2];
|
|
}
|
|
else {
|
|
idx0 = idx1-1;
|
|
|
|
exptime0 = ae_adc_tbl[idx0][1];
|
|
isogain0 = (ae_adc_tbl[idx0][2]);
|
|
exptime1 = ae_adc_tbl[idx1][1];
|
|
isogain1 = (ae_adc_tbl[idx1][2]);
|
|
ev0 = (exptime0 * isogain0);
|
|
ev1 = (exptime1 * isogain1);
|
|
|
|
//adc_ev = ((ev1 - ev0) * (ae_adc_tbl[idx1][0]-adc_value))/(ae_adc_tbl[idx1][0]-ae_adc_tbl[idx0][0]) + ev0;
|
|
adc_ev = ((ev1 - ev0) * (adc_value - ae_adc_tbl[idx1][0]))/(ae_adc_tbl[idx0][0] - ae_adc_tbl[idx1][0]) + ev0;
|
|
|
|
if(adc_value>200)
|
|
{
|
|
*exptime = exptime0;
|
|
*isogain = (adc_ev / exptime0);
|
|
}else{
|
|
*exptime = 16666;
|
|
*isogain = 7000;
|
|
}
|
|
}
|
|
DBG_WRN("idx = %d, %d, adc = %d, fast open preset exp = %d, %d\r\n", idx0, idx1, adc_value, *exptime, *isogain);
|
|
}
|
|
|
|
|
|
UINT32 ae_preset_exp,ae_preset_iso;
|
|
|
|
void get_preset_param(void)
|
|
{
|
|
static BOOL get_preset_flag=FALSE;
|
|
UINT32 adc_expt, adc_gain;
|
|
|
|
if(get_preset_flag==FALSE)
|
|
{
|
|
ae_adc_get_exp_photo(IRSHTTER, &adc_expt, &adc_gain);
|
|
preset_param.expt= ae_preset_exp = adc_expt;
|
|
preset_param.gain= ae_preset_iso = adc_gain;
|
|
DBG_WRN("adc_value = %d, adc_exp =========== %d, %d\r\n", IRSHTTER, (unsigned int)adc_expt, (unsigned int)adc_gain);
|
|
|
|
get_preset_flag=TRUE;
|
|
}
|
|
}
|
|
|
|
void setet_preset_param(void)
|
|
{
|
|
AET_STATUS_INFO ae_status_info = {0};
|
|
ISPT_TOTAL_GAIN total_gain = {0};
|
|
|
|
ae_status_info.id = 0;
|
|
vendor_isp_get_ae(AET_ITEM_STATUS, &ae_status_info);
|
|
DBG_WRN(">> aet status exp %d iso %d\r\n",ae_status_info.status_info.expotime[0],ae_status_info.status_info.iso_gain[0]);
|
|
preset_param.expt= ae_status_info.status_info.expotime[0];
|
|
preset_param.gain= ae_status_info.status_info.iso_gain[0];
|
|
total_gain.id = 0;
|
|
total_gain.gain = preset_param.gain;
|
|
vendor_isp_set_common(ISPT_ITEM_TOTAL_GAIN, &total_gain);
|
|
}
|
|
|
|
|
|
#endif
|