/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved. * Description : iapi tvd * Author : sdk * Create : 2019/11/21 */ #include "td_type.h" #include "uapi_tvd.h" #include "mpi_tvd_ext.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif /* __cplusplus */ static ext_tvd_video_format_convert g_tvd_vid_format[] = { { UAPI_FORMAT_YUV_SEMIPLANAR_422_VU, EXT_DRV_PIXEL_FMT_NV61_2X1 }, { UAPI_FORMAT_YUV_SEMIPLANAR_420_VU, EXT_DRV_PIXEL_FMT_NV21 }, { UAPI_FORMAT_YUV_SEMIPLANAR_420_UV, EXT_DRV_PIXEL_FMT_NV12 }, { UAPI_FORMAT_YUV_SEMIPLANAR_400, EXT_DRV_PIXEL_FMT_NV80 }, { UAPI_FORMAT_YUV_SEMIPLANAR_411_VU, EXT_DRV_PIXEL_FMT_NV12_411 }, { UAPI_FORMAT_YUV_SEMIPLANAR_422_UV, EXT_DRV_PIXEL_FMT_NV61 }, { UAPI_FORMAT_YUV_SEMIPLANAR_444_VU, EXT_DRV_PIXEL_FMT_NV42 }, { UAPI_FORMAT_YUV_PACKAGE_UYVY, EXT_DRV_PIXEL_FMT_UYVY }, { UAPI_FORMAT_YUV_PACKAGE_YUYV, EXT_DRV_PIXEL_FMT_YUYV }, { UAPI_FORMAT_YUV_PACKAGE_YVYU, EXT_DRV_PIXEL_FMT_YVYU }, { UAPI_FORMAT_YUV_PLANAR_400, EXT_DRV_PIXEL_FMT_YUV400 }, { UAPI_FORMAT_YUV_PLANAR_411_VU, EXT_DRV_PIXEL_FMT_YUV411 }, { UAPI_FORMAT_YUV_PLANAR_420_VU, EXT_DRV_PIXEL_FMT_YUV420P }, { UAPI_FORMAT_YUV_PLANAR_422_UV, EXT_DRV_PIXEL_FMT_YUV422_1X2 }, { UAPI_FORMAT_YUV_PLANAR_422_VU, EXT_DRV_PIXEL_FMT_YUV422_2X1 }, { UAPI_FORMAT_YUV_PLANAR_444_UV, EXT_DRV_PIXEL_FMT_YUV_444 }, { UAPI_FORMAT_YUV_PLANAR_410_VU, EXT_DRV_PIXEL_FMT_YUV410P }, { UAPI_FORMAT_RGB_SEMIPLANAR_444, EXT_DRV_PIXEL_FMT_NV42_RGB }, { UAPI_FORMAT_RGB888, EXT_DRV_PIXEL_FMT_RGB24 }, { UAPI_FORMAT_ARGB8888, EXT_DRV_PIXEL_FMT_ARGB8888 }, }; td_s32 uapi_tvd_init(td_void) { return ext_mpi_tvd_init(); } td_s32 uapi_tvd_deinit(td_void) { return ext_mpi_tvd_de_init(); } td_s32 uapi_tvd_connect(const uapi_tvd_src_attr *src_attr) { ext_drv_tvd_src_attr_in drv_src_attr; if (src_attr == TD_NULL) { return TD_FAILURE; } drv_src_attr.type = (ext_drv_source)src_attr->type; drv_src_attr.index = src_attr->index; return ext_mpi_tvd_connect(&drv_src_attr); } td_s32 uapi_tvd_disconnect(td_void) { return ext_mpi_tvd_dis_connect(); } td_s32 uapi_tvd_get_signal_status(uapi_sig_status *signal_status) { td_s32 ret; if (signal_status == TD_NULL) { return TD_FAILURE; } ext_drv_sig_status sig_status; ret = ext_mpi_tvd_get_signal_status(&sig_status); *signal_status = (uapi_sig_status)sig_status; return ret; } td_s32 uapi_tvd_get_timing_info(uapi_tvd_timing_info *timing_info) { td_s32 ret; td_u32 max_index; td_u32 index; ext_drv_tvd_timing_info drv_timing_info; if (timing_info == TD_NULL) { return TD_FAILURE; } ret = ext_mpi_tvd_get_std_timing_info(&drv_timing_info); timing_info->interlace = drv_timing_info.interlace; timing_info->width = drv_timing_info.width; timing_info->height = drv_timing_info.height; timing_info->frame_rate = drv_timing_info.frame_rate; timing_info->oversample = (uapi_oversample)(drv_timing_info.oversample); timing_info->bit_depth = (uapi_pixel_bit_depth)(drv_timing_info.bit_width); max_index = sizeof(g_tvd_vid_format) / sizeof(g_tvd_vid_format[0]); for (index = 0; index < max_index; index++) { if (drv_timing_info.pixel_fmt == g_tvd_vid_format[index].drv_video_format) { timing_info->pixel_fmt = g_tvd_vid_format[index].iapi_video_format; break; } } return ret; } td_s32 uapi_tvd_set_color_system(uapi_color_sys color_sys) { ext_drv_color_sys drv_color_sys = (ext_drv_color_sys)color_sys; return ext_mpi_tvd_set_color_system(drv_color_sys); } td_s32 uapi_tvd_get_color_system(uapi_color_sys *color_sys) { td_s32 ret; ext_drv_color_sys color_system; if (color_sys == TD_NULL) { return TD_FAILURE; } ret = ext_mpi_tvd_get_color_system(&color_system); *color_sys = (uapi_color_sys)color_system; return ret; } td_s32 uapi_tvd_get_signal_lock(td_bool *lock) { if (lock == TD_NULL) { return TD_FAILURE; } return ext_mpi_tvd_get_signal_lock(lock); } td_s32 uapi_tvd_get_noise_value(td_u32 *noise_value) { if (noise_value == TD_NULL) { return TD_FAILURE; } return ext_mpi_tvd_get_noise_value(noise_value); } td_s32 uapi_tvd_get_macrovision_status(td_bool *status) { if (status == TD_NULL) { return TD_FAILURE; } return ext_mpi_tvd_get_macrovision_status(status); } td_s32 uapi_tvd_get_nonstd_info(uapi_video_nonstd_info *nstd_info) { td_s32 ret; ext_drv_video_nonstd_info non_std_info; if (nstd_info == TD_NULL) { return TD_FAILURE; } ret = ext_mpi_tvd_get_nstd_info(&non_std_info); nstd_info->is_non_std = non_std_info.non_std; nstd_info->height = non_std_info.height; nstd_info->v_freq = non_std_info.v_freq; return ret; } td_s32 uapi_tvd_get_range(uapi_tvd_position type, uapi_sys_range *range) { td_s32 ret; ext_drv_tvd_pos_type drv_type = (ext_drv_tvd_pos_type)type; ext_range drv_range; if (range == TD_NULL) { return TD_FAILURE; } ret = ext_mpi_tvd_get_range(drv_type, &drv_range); if (ret != TD_SUCCESS) { return TD_FAILURE; } range->max = drv_range.max; range->min = drv_range.min; return TD_SUCCESS; } td_s32 uapi_tvd_get_position(uapi_tvd_position type, td_u32 *position) { ext_drv_tvd_pos_type pos_type; if (position == TD_NULL) { return TD_FAILURE; } pos_type = (ext_drv_tvd_pos_type)type; return ext_mpi_tvd_get_position(pos_type, position); } td_s32 uapi_tvd_set_position(uapi_tvd_position type, td_u32 position) { ext_drv_tvd_pos_type pos_type = (ext_drv_tvd_pos_type)type; return ext_mpi_tvd_set_position(pos_type, position); } td_s32 uapi_tvd_get_offline_status(const uapi_tvd_src_attr *src_attr, td_bool *status) { td_s32 ret; ext_drv_tvd_src_attr_in drv_attr; if ((src_attr == TD_NULL) || (status == TD_NULL)) { return TD_FAILURE; } drv_attr.type = (ext_drv_source)src_attr->type; drv_attr.index = src_attr->index; ret = ext_mpi_tvd_get_offline_status(&drv_attr, status); return ret; } td_s32 uapi_tvd_set_pedestal(td_bool enable) { return ext_mpi_tvd_set_pedestal(enable); } td_s32 uapi_tvd_set_color_system_filter(const uapi_tvd_sys_filter *sys_filter) { ext_drv_tvd_sys_filter drv_sys_filter; if (sys_filter == TD_NULL) { return TD_FAILURE; } drv_sys_filter.dis_ntsc443 = sys_filter->dis_ntsc443; drv_sys_filter.dis_pal_m = sys_filter->dis_palm; drv_sys_filter.dis_pal_n = sys_filter->dis_paln; drv_sys_filter.dis_secam = sys_filter->dis_secam; drv_sys_filter.dis_pal60 = sys_filter->dis_pal60; return ext_mpi_tvd_set_color_system_filter(&drv_sys_filter); } td_s32 uapi_tvd_get_color_system_filter(uapi_tvd_sys_filter *sys_filter) { td_s32 ret; ext_drv_tvd_sys_filter drv_sys_filter; if (sys_filter == TD_NULL) { return TD_FAILURE; } ret = ext_mpi_tvd_get_color_system_filter(&drv_sys_filter); sys_filter->dis_ntsc443 = drv_sys_filter.dis_ntsc443; sys_filter->dis_palm = drv_sys_filter.dis_pal_m; sys_filter->dis_paln = drv_sys_filter.dis_pal_n; sys_filter->dis_secam = drv_sys_filter.dis_secam; sys_filter->dis_pal60 = drv_sys_filter.dis_pal60; return ret; } td_s32 uapi_tvd_set_comb_filter_mode(uapi_tvd_comb_mode mode) { ext_drv_tvd_comb_mode comb_mode = (ext_drv_tvd_comb_mode)mode; return ext_mpi_tvd_set_comb_filter_mode(comb_mode); } td_s32 uapi_tvd_get_line_status(td_bool *is_625mode) { if (is_625mode == TD_NULL) { return TD_FAILURE; } return ext_mpi_tvd_get_line_status(is_625mode); } td_s32 uapi_tvd_set_work_mode(uapi_tvd_work_mode work_mode) { ext_drv_tvd_work_mode tvd_work_mode = (ext_drv_tvd_work_mode)work_mode; return ext_mpi_tvd_set_work_mode(tvd_work_mode); } td_s32 uapi_tvd_get_capability(uapi_tvd_capability *capability) { td_s32 ret; ext_drv_tvd_capability drv_capability; if (capability == TD_NULL) { return TD_FAILURE; } ret = ext_mpi_tvd_get_capability(&drv_capability); capability->atv_max = drv_capability.atv_max; capability->cvbs_max = drv_capability.cvbs_max; capability->scart_max = drv_capability.scart_max; return ret; } #ifdef __cplusplus #if __cplusplus } #endif #endif /* __cplusplus */