S32 mpp_video_set_attr(TP_STRM_ID_E strm_id, const TP_STREAM_ATTR_S* pAttr)
{
FLOW_MUTEX_LOCK();
#ifdef HDR_MODE_SUPPORT
int ret = OK;
/* 切换hdr需要关闭所有proc和cap重新配置参数 */
#ifdef AIISP_ENABLED
// if (strm_id == STRM_ID_MAIN && (get_hdr_cfg() != pAttr->hdr || pAttr->strm_res.res_w != pre_res_w || is_need_reload_for_rotate == 1))
// {
// if(pAttr->strm_res.res_w != pre_res_w)
// {
// pre_res_w = pAttr->strm_res.res_w;
// }
// is_need_reload_for_rotate = 0;
// #else
if (strm_id == STRM_ID_MAIN && get_hdr_cfg() != pAttr->hdr)
{
#endif
ret = get_sensor_direction();
if(ret != HD_OK){
MPP_ERROR("vendor_isp_get_common ISPT_ITEM_SENSOR_DIRECTION, ret %d", ret);
goto RET;
}
int isp_stream_is_inited = 0;
int dla_stream_is_inited = 0;
int isp_stream_is_started = 0;
int dla_stream_is_started = 0;
if(g_strm_param[0][STRM_ID_ISP].video_stream_inited == TRUE)
{
isp_stream_is_inited = 1;
}
if(g_strm_param[0][STRM_ID_DLA].video_stream_inited == TRUE)
{
dla_stream_is_inited = 1;
}
if(g_strm_param[0][STRM_ID_ISP].video_stream_started == TRUE)
{
isp_stream_is_started = 1;
}
if(g_strm_param[0][STRM_ID_DLA].video_stream_started == TRUE)
{
dla_stream_is_started = 1;
}
if(dla_stream_is_started)
{
__video_stream_stop(STRM_ID_DLA);
}
if(isp_stream_is_started)
{
__video_stream_stop(STRM_ID_ISP);
}
#ifdef MINOR_STREAM_THD_ENABLE
__video_stream_stop(STRM_ID_MINOR_THD);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_stop(STRM_ID_MAIN_THD);
}
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
__video_stream_stop(STRM_ID_MINOR_SEC);
#endif
#ifdef MAIN_STREAM_SEC_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_stop(STRM_ID_MAIN_SEC);
}
#endif
__video_stream_stop(STRM_ID_JPEG);
__video_stream_stop(STRM_ID_MINOR);
__video_stream_stop(STRM_ID_MAIN);
if(dla_stream_is_inited)
{
__video_stream_exit(STRM_ID_DLA);
}
if(isp_stream_is_inited)
{
__video_stream_exit(STRM_ID_ISP);
}
#ifdef MINOR_STREAM_THD_ENABLE
__video_stream_exit(STRM_ID_MINOR_THD);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_exit(STRM_ID_MAIN_THD);
}
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
__video_stream_exit(STRM_ID_MINOR_SEC);
#endif
#ifdef MAIN_STREAM_SEC_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_exit(STRM_ID_MAIN_SEC);
}
#endif
__video_stream_exit(STRM_ID_JPEG);
__video_stream_exit(STRM_ID_MINOR);
__video_stream_exit(STRM_ID_MAIN);
if(g_rotate_type != ROTATE_OFF && g_rotate_type != ROTATE_ANTICLOCKWISE_180)
{
TP_STREAM_ATTR_S attr_main = {0};
memcpy(&attr_main, pAttr, sizeof(TP_STREAM_ATTR_S));
attr_main.strm_res.res_w = ALIGN_FLOOR_16(attr_main.strm_res.res_w);
attr_main.strm_res.res_h = ALIGN_FLOOR_16(attr_main.strm_res.res_h);
__video_stream_init(STRM_ID_MAIN, &attr_main);
}
else
{
__video_stream_init(STRM_ID_MAIN, pAttr);
}
__video_stream_init(STRM_ID_MINOR, &g_video_attr[STRM_ID_MINOR]);
__video_stream_init(STRM_ID_JPEG, &g_video_attr[STRM_ID_JPEG]);
#ifdef MAIN_STREAM_SEC_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_init(STRM_ID_MAIN_SEC, &g_video_attr[STRM_ID_MAIN_SEC]);
}
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
__video_stream_init(STRM_ID_MINOR_SEC, &g_video_attr[STRM_ID_MINOR_SEC]);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_init(STRM_ID_MAIN_THD, &g_video_attr[STRM_ID_MAIN_THD]);
}
#endif
#ifdef MINOR_STREAM_THD_ENABLE
__video_stream_init(STRM_ID_MINOR_THD, &g_video_attr[STRM_ID_MINOR_THD]);
#endif
if(isp_stream_is_inited)
{
__video_stream_init(STRM_ID_ISP, &g_video_attr[STRM_ID_ISP]);
}
if(dla_stream_is_inited)
{
__video_stream_init(STRM_ID_DLA, &g_video_attr[STRM_ID_DLA]);
}
__video_stream_start(STRM_ID_MAIN);
__video_stream_start(STRM_ID_MINOR);
__video_stream_start(STRM_ID_JPEG);
#ifdef MAIN_STREAM_SEC_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_start(STRM_ID_MAIN_SEC);
}
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
__video_stream_start(STRM_ID_MINOR_SEC);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_start(STRM_ID_MAIN_THD);
}
#endif
#ifdef MINOR_STREAM_THD_ENABLE
__video_stream_start(STRM_ID_MINOR_THD);
#endif
if(isp_stream_is_started)
{
__video_stream_start(STRM_ID_ISP);
}
if(dla_stream_is_started)
{
__video_stream_start(STRM_ID_DLA);
}
memcpy(&g_video_attr[strm_id], pAttr, sizeof(TP_STREAM_ATTR_S));
ret = set_sensor_direction();
if(ret != HD_OK){
MPP_ERROR("vendor_isp_set_common ISPT_ITEM_SENSOR_DIRECTION, ret %d", ret);
goto RET;
}
}
else
#endif
{
__video_stream_stop(strm_id);
__video_stream_exit(strm_id);
if(g_rotate_type != ROTATE_OFF && g_rotate_type != ROTATE_ANTICLOCKWISE_180
&& (strm_id == STRM_ID_MAIN || strm_id == STRM_ID_MINOR))
{
TP_STREAM_ATTR_S attr = {0};
memcpy(&attr, pAttr, sizeof(TP_STREAM_ATTR_S));
attr.strm_res.res_w = ALIGN_FLOOR_16(attr.strm_res.res_w);
attr.strm_res.res_h = ALIGN_FLOOR_16(attr.strm_res.res_h);
__video_stream_init(strm_id, &attr);
}
else
{
__video_stream_init(strm_id, pAttr);
}
__video_stream_start(strm_id);
memcpy(&g_video_attr[strm_id], pAttr, sizeof(TP_STREAM_ATTR_S));
if (STRM_ID_DLA == strm_id)
{
memcpy(&g_video_attr[STRM_ID_DLA_REC], pAttr + DLA_REC, sizeof(TP_STREAM_ATTR_S));
}
goto RET;
}
RET:
FLOW_MUTEX_UNLOCK();
return OK;
}
S32 sync_awb_cut_sensor(int cur_sen_id)
{
AWBT_STATUS cur_status = {0};
AWBT_STATUS to_status = {0};
ISPT_C_GAIN c_gain = {0};
IQT_NIGHT_MODE night_mode = {0};
night_mode.id = cur_sen_id;
cur_status.id = cur_sen_id;
to_status.id = cur_sen_id == 0 ? 1:0;
vendor_isp_get_awb(AWBT_ITEM_STATUS, &cur_status);
vendor_isp_get_awb(AWBT_ITEM_STATUS, &to_status);
vendor_isp_get_iq(IQT_ITEM_NIGHT_MODE,&night_mode);
if (night_mode.mode == 0)
{
if (abs(g_status_saved.status.cur_r_gain - cur_status.status.cur_r_gain)
+ abs(g_status_saved.status.cur_g_gain - cur_status.status.cur_g_gain)
+ abs(g_status_saved.status.cur_b_gain - cur_status.status.cur_b_gain)
> THRE_AWB_SYNC)
{
c_gain.gain[0] = cur_status.status.cur_r_gain * g_sensor_awb_ratio_r_1_to_0 / SENSOR_AWB_RATIO_BASE;
c_gain.gain[1] = cur_status.status.cur_g_gain;
c_gain.gain[2] = cur_status.status.cur_b_gain * g_sensor_awb_ratio_b_1_to_0 / SENSOR_AWB_RATIO_BASE;
}
else /* use to_status itself */
{
c_gain.gain[0] = to_status.status.cur_r_gain;
c_gain.gain[1] = to_status.status.cur_g_gain;
c_gain.gain[2] = to_status.status.cur_b_gain;
}
c_gain.id = cur_sen_id == 0 ? 1:0;
vendor_isp_set_common(ISPT_ITEM_C_GAIN, &c_gain);
}
return 0;
}
S32 mpp_video_stream_restart(int sensor_id)
{
int ret = 0;
if(sensor_id == 0)
{
ret = hd_videocap_stop(g_video_avdc_stream[1][0].cap_path);
if (ret != HD_OK) {
MPP_ERROR("hd_videocap_stop fail=%d\n", ret);
return -1;
}
sync_awb_cut_sensor(1);
g_cur_sensor_id = sensor_id;
g_wait_i_frame_flag[STRM_ID_MAIN] = 1;
g_wait_i_frame_flag[STRM_ID_MINOR] = 1;
ret = hd_videocap_start(g_video_avdc_stream[0][0].cap_path);
if (ret != HD_OK) {
MPP_ERROR("hd_videocap_start fail=%d\n", ret);
return -1;
}
}
else if(sensor_id == 1)
{
ret = hd_videocap_stop(g_video_avdc_stream[0][0].cap_path);
if (ret != HD_OK) {
MPP_ERROR("hd_videocap_stop fail=%d\n", ret);
return -1;
}
sync_awb_cut_sensor(0);
g_cur_sensor_id = sensor_id;
g_wait_i_frame_flag[STRM_ID_MAIN] = 1;
g_wait_i_frame_flag[STRM_ID_MINOR] = 1;
ret = hd_videocap_start(g_video_avdc_stream[1][0].cap_path);
if (ret != HD_OK) {
MPP_ERROR("hd_videocap_start fail=%d\n", ret);
return -1;
}
}
// HD_VIDEOCAP_OUT video_out_param = {0};
// //without setting dim for no scaling, using original sensor out size
// video_out_param.pxlfmt = HD_VIDEO_PXLFMT_RAW10;
// video_out_param.dir = HD_VIDEO_DIR_NONE;
// video_out_param.frc = HD_VIDEO_FRC_RATIO(15,20);
// ret = hd_videocap_set(g_video_avdc_stream[0][0].cap_path, HD_VIDEOCAP_PARAM_OUT, &video_out_param);
// if (ret != HD_OK) {
// MPP_ERROR("hd_videocap_set fail=%d\n", ret);
// return -1;
// }
// hd_videocap_start(g_video_avdc_stream[0][0].cap_path);
// video_out_param.pxlfmt = HD_VIDEO_PXLFMT_RAW10;
// video_out_param.dir = HD_VIDEO_DIR_NONE;
// video_out_param.frc = HD_VIDEO_FRC_RATIO(18,20);
// ret = hd_videocap_set(g_video_avdc_stream[1][0].cap_path, HD_VIDEOCAP_PARAM_OUT, &video_out_param);
// hd_videocap_start(g_video_avdc_stream[1][0].cap_path);
return OK;
}
S32 mpp_video_restart(ROTATE_TYPE rotate_type, int mirror_type)
{
FLOW_MUTEX_LOCK();
g_rotate_type = rotate_type;
g_mirror_type = mirror_type;
U8 stream_type;
if (g_strm_param[0][STRM_ID_ISP].video_stream_started == TRUE)
{
__video_stream_stop(STRM_ID_ISP);
__video_stream_exit(STRM_ID_ISP);
__video_stream_init(STRM_ID_ISP, &g_video_attr[STRM_ID_ISP]);
__video_stream_start(STRM_ID_ISP);
}
else if (g_strm_param[0][STRM_ID_ISP].video_stream_inited == TRUE)
{
__video_stream_exit(STRM_ID_ISP);
__video_stream_init(STRM_ID_ISP, &g_video_attr[STRM_ID_ISP]);
}
if (g_strm_param[0][STRM_ID_DLA].video_stream_started == TRUE)
{
__video_stream_stop(STRM_ID_DLA);
__video_stream_exit(STRM_ID_DLA);
__video_stream_init(STRM_ID_DLA, &g_video_attr[STRM_ID_DLA]);
__video_stream_start(STRM_ID_DLA);
}
else if (g_strm_param[0][STRM_ID_DLA].video_stream_inited == TRUE)
{
__video_stream_exit(STRM_ID_DLA);
__video_stream_init(STRM_ID_DLA, &g_video_attr[STRM_ID_DLA]);
}
if(rotate_type != ROTATE_OFF && rotate_type != ROTATE_ANTICLOCKWISE_180)
{
TP_STREAM_ATTR_S attr_main = {0};
TP_STREAM_ATTR_S attr_minor = {0};
#ifdef MAIN_STREAM_SEC_ENABLE
TP_STREAM_ATTR_S attr_main_sec = {0};
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
TP_STREAM_ATTR_S attr_minor_sec = {0};
#endif
#ifdef MAIN_STREAM_THD_ENABLE
TP_STREAM_ATTR_S attr_main_thd = {0};
#endif
#ifdef MINOR_STREAM_THD_ENABLE
TP_STREAM_ATTR_S attr_minor_thd = {0};
#endif
memcpy(&attr_main, &g_video_attr[STRM_ID_MAIN], sizeof(TP_STREAM_ATTR_S));
memcpy(&attr_minor, &g_video_attr[STRM_ID_MINOR], sizeof(TP_STREAM_ATTR_S));
#ifdef MAIN_STREAM_SEC_ENABLE
memcpy(&attr_main_sec, &g_video_attr[STRM_ID_MAIN_SEC], sizeof(TP_STREAM_ATTR_S));
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
memcpy(&attr_minor_sec, &g_video_attr[STRM_ID_MINOR_SEC], sizeof(TP_STREAM_ATTR_S));
#endif
#ifdef MAIN_STREAM_THD_ENABLE
memcpy(&attr_main_thd, &g_video_attr[STRM_ID_MAIN_THD], sizeof(TP_STREAM_ATTR_S));
#endif
#ifdef MINOR_STREAM_THD_ENABLE
memcpy(&attr_minor_thd, &g_video_attr[STRM_ID_MINOR_THD], sizeof(TP_STREAM_ATTR_S));
#endif
attr_main.strm_res.res_w = ALIGN_FLOOR_16(attr_main.strm_res.res_w);
attr_main.strm_res.res_h = ALIGN_FLOOR_16(attr_main.strm_res.res_h);
attr_minor.strm_res.res_w = ALIGN_FLOOR_16(attr_minor.strm_res.res_w);
attr_minor.strm_res.res_h = ALIGN_FLOOR_16(attr_minor.strm_res.res_h);
#ifdef MAIN_STREAM_SEC_ENABLE
attr_main_sec.strm_res.res_w = ALIGN_FLOOR_16(attr_main_sec.strm_res.res_w);
attr_main_sec.strm_res.res_h = ALIGN_FLOOR_16(attr_main_sec.strm_res.res_h);
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
attr_minor_sec.strm_res.res_w = ALIGN_FLOOR_16(attr_minor_sec.strm_res.res_w);
attr_minor_sec.strm_res.res_h = ALIGN_FLOOR_16(attr_minor_sec.strm_res.res_h);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
attr_main_thd.strm_res.res_w = ALIGN_FLOOR_16(attr_main_thd.strm_res.res_w);
attr_main_thd.strm_res.res_h = ALIGN_FLOOR_16(attr_main_thd.strm_res.res_h);
#endif
#ifdef MINOR_STREAM_THD_ENABLE
attr_minor_thd.strm_res.res_w = ALIGN_FLOOR_16(attr_minor_thd.strm_res.res_w);
attr_minor_thd.strm_res.res_h = ALIGN_FLOOR_16(attr_minor_thd.strm_res.res_h);
#endif
__video_stream_stop(STRM_ID_MAIN);
__video_stream_exit(STRM_ID_MAIN);
__video_stream_init(STRM_ID_MAIN, &attr_main);
__video_stream_start(STRM_ID_MAIN);
__video_stream_stop(STRM_ID_MINOR);
__video_stream_exit(STRM_ID_MINOR);
__video_stream_init(STRM_ID_MINOR, &attr_minor);
__video_stream_start(STRM_ID_MINOR);
#ifdef MAIN_STREAM_SEC_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_stop(STRM_ID_MAIN_SEC);
__video_stream_exit(STRM_ID_MAIN_SEC);
__video_stream_init(STRM_ID_MAIN_SEC, &attr_main_sec);
__video_stream_start(STRM_ID_MAIN_SEC);
}
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
__video_stream_stop(STRM_ID_MINOR_SEC);
__video_stream_exit(STRM_ID_MINOR_SEC);
__video_stream_init(STRM_ID_MINOR_SEC, &attr_minor_sec);
__video_stream_start(STRM_ID_MINOR_SEC);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_stop(STRM_ID_MAIN_THD);
__video_stream_exit(STRM_ID_MAIN_THD);
__video_stream_init(STRM_ID_MAIN_THD, &attr_main_thd);
__video_stream_start(STRM_ID_MAIN_THD);
}
#endif
#ifdef MINOR_STREAM_THD_ENABLE
__video_stream_stop(STRM_ID_MINOR_THD);
__video_stream_exit(STRM_ID_MINOR_THD);
__video_stream_init(STRM_ID_MINOR_THD, &attr_minor_thd);
__video_stream_start(STRM_ID_MINOR_THD);
#endif
}
else
{
__video_stream_stop(STRM_ID_MAIN);
__video_stream_exit(STRM_ID_MAIN);
__video_stream_init(STRM_ID_MAIN, &g_video_attr[STRM_ID_MAIN]);
__video_stream_start(STRM_ID_MAIN);
__video_stream_stop(STRM_ID_MINOR);
__video_stream_exit(STRM_ID_MINOR);
__video_stream_init(STRM_ID_MINOR, &g_video_attr[STRM_ID_MINOR]);
__video_stream_start(STRM_ID_MINOR);
#ifdef MAIN_STREAM_SEC_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_stop(STRM_ID_MAIN_SEC);
__video_stream_exit(STRM_ID_MAIN_SEC);
__video_stream_init(STRM_ID_MAIN_SEC, &g_video_attr[STRM_ID_MAIN_SEC]);
__video_stream_start(STRM_ID_MAIN_SEC);
}
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
__video_stream_stop(STRM_ID_MINOR_SEC);
__video_stream_exit(STRM_ID_MINOR_SEC);
__video_stream_init(STRM_ID_MINOR_SEC, &g_video_attr[STRM_ID_MINOR_SEC]);
__video_stream_start(STRM_ID_MINOR_SEC);
#endif
#ifdef MAIN_STREAM_THD_ENABLE
#ifdef BINOCULOR_AVS
if(get_factory_mode())
#endif
{
__video_stream_stop(STRM_ID_MAIN_THD);
__video_stream_exit(STRM_ID_MAIN_THD);
__video_stream_init(STRM_ID_MAIN_THD, &g_video_attr[STRM_ID_MAIN_THD]);
__video_stream_start(STRM_ID_MAIN_THD);
}
#endif
#ifdef MINOR_STREAM_THD_ENABLE
__video_stream_stop(STRM_ID_MINOR_THD);
__video_stream_exit(STRM_ID_MINOR_THD);
__video_stream_init(STRM_ID_MINOR_THD, &g_video_attr[STRM_ID_MINOR_THD]);
__video_stream_start(STRM_ID_MINOR_THD);
#endif
}
stream_type = (U8)STRM_ID_MAIN;
msg_send(AVTS_STREAM_RELOAD, &stream_type, sizeof(U8));
stream_type = (U8)STRM_ID_MINOR;
msg_send(AVTS_STREAM_RELOAD, &stream_type, sizeof(U8));
#ifdef MAIN_STREAM_SEC_ENABLE
// 预留:OSD 同步配置更新,当前除main、minor外暂不做处理(callback内部处理)
stream_type = (U8)STRM_ID_MAIN_SEC;
msg_send(AVTS_STREAM_RELOAD, &stream_type, sizeof(U8));
#endif
#ifdef MINOR_STREAM_SEC_ENABLE
// 预留:OSD 同步配置更新,当前除main、minor外暂不做处理(callback内部处理)
stream_type = (U8)STRM_ID_MINOR_SEC;
msg_send(AVTS_STREAM_RELOAD, &stream_type, sizeof(U8));
#endif
#ifdef MAIN_STREAM_THD_ENABLE
// 预留:OSD 同步配置更新,当前除main、minor外暂不做处理(callback内部处理)
stream_type = (U8)STRM_ID_MAIN_THD;
msg_send(AVTS_STREAM_RELOAD, &stream_type, sizeof(U8));
#endif
#ifdef MINOR_STREAM_THD_ENABLE
// 预留:OSD 同步配置更新,当前除main、minor外暂不做处理(callback内部处理)
stream_type = (U8)STRM_ID_MINOR_THD;
msg_send(AVTS_STREAM_RELOAD, &stream_type, sizeof(U8));
#endif
__video_stream_stop(STRM_ID_JPEG);
__video_stream_exit(STRM_ID_JPEG);
__video_stream_init(STRM_ID_JPEG, &g_video_attr[STRM_ID_JPEG]);
__video_stream_start(STRM_ID_JPEG);
FLOW_MUTEX_UNLOCK();
return OK;
}
这个函数里怎么把aiisp的东西去掉