/* * Copyright (c) Technologies Co., Ltd. 2013-2019. All rights reserved. * Description: vi test * Author: sdk * Create: 2020-11-02 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "soc_errno.h" #include "securec.h" #include "vi_st_common.h" static const st_vi_setting g_vi_default_setting = { .picture_mode = UAPI_VI_PICTURE_MODE_VIDEO, .display_field = UAPI_VI_DISPLAY_FIELD_ALL, .quantify_range = UAPI_VI_QUANTIZATION_RANGE_AUTO, .nonstd_info.is_non_std = TD_FALSE, .crop_rect = {0x0}, }; static const st_vi_timing g_vi_default_hdmi_timing = { .hdr_type = UAPI_HDR_TYPE_SDR, .video_3d_type = UAPI_FRAME_PACKING_TYPE_2D, .pixel_format = UAPI_FORMAT_YUV_SEMIPLANAR_444_VU, .color_description = { .color_primary = UAPI_COLOR_PRIMARY_BT709, .color_space = UAPI_COLOR_CS_YUV, .quantify_range = UAPI_COLOR_LIMITED_RANGE, .transfer_type = UAPI_COLOR_TRANSFER_TYPE_GAMMA_SDR, .matrix_coef = UAPI_COLOR_MATRIX_COEFFS_BT709, }, .color_sys = UAPI_COLOR_SYS_AUTO, .bit_depth = UAPI_PIXEL_BIT_DEPTH_8BIT, .over_sample = UAPI_OVERSAMPLE_1X, .width = 1920, .height = 1080, .interlace = TD_FALSE, .frame_rate = 60000, .vblank = 0, }; static const st_vi_frontend_param g_vi_default_hdmi_frontend_param = { .source_type = UAPI_VIDEO_SOURCE_HDMI, .port = VI_FRONTEND_PORT, .frontend_bypass = TD_TRUE, }; static const st_vi_backend_param g_vi_default_backend_param = { .x = 0x0, .y = 0x0, .width = VI_BACKEND_WIDTH, .height = VI_BACKEND_HEIGHT, .abs_zorder = 0x0, .low_latency = TD_FALSE, .pq_bypass = TD_FALSE, .vo_bypass = TD_FALSE, }; td_s32 sample_vi_get_hdmirx_port(td_char *str, td_u32 hdmirx_port_num_max, td_u32 *hdmirx_port) { td_char tmp_str[0x10]; td_u32 count; td_s32 ret; for (count = 0x0; count < hdmirx_port_num_max; count++) { ret = snprintf_s(tmp_str, sizeof(tmp_str), sizeof(tmp_str) - 1, "hdmirx%u", count); if (ret <= 0) { printf("snprintf_s return err 0x%x\n", ret); return TD_FAILURE; } if (strcasecmp(str, tmp_str) == 0) { *hdmirx_port = count; break; } } if (count >= hdmirx_port_num_max) { printf("not support %s\n", str); return TD_FAILURE; } return TD_SUCCESS; } td_void st_vi_manual_case_hdmirx_001(td_u32 *hdmirx_prot, td_u32 vi_path_num) { st_vi_test_info test_info[0x2]; td_u32 count; td_bool is_forward_destroy; td_bool vo_bypass; vo_bypass = st_vi_comm_wait_input_select("Do you want to bypass vo and acquire/release frame from vi directly?"); for (count = 0x0; count < vi_path_num; count++) { test_info[count].vi_setting = g_vi_default_setting; test_info[count].vi_timing = g_vi_default_hdmi_timing; test_info[count].frontend_param = g_vi_default_hdmi_frontend_param; test_info[count].backend_param = g_vi_default_backend_param; test_info[count].frontend_param.frontend_bypass = TD_FALSE; test_info[count].frontend_param.port = hdmirx_prot[count]; test_info[count].backend_param.abs_zorder = count; if (count == 0x0) { test_info[count].backend_param.width = g_vi_default_backend_param.width; test_info[count].backend_param.height = g_vi_default_backend_param.height; test_info[count].backend_param.x += 0; test_info[count].backend_param.y += 0; } else { test_info[count].backend_param.width = g_vi_default_backend_param.width / vi_path_num; test_info[count].backend_param.height = g_vi_default_backend_param.height / vi_path_num; test_info[count].backend_param.x += test_info[count].backend_param.width * count; test_info[count].backend_param.y += test_info[count].backend_param.height * count; } test_info[count].backend_param.vo_bypass = vo_bypass; st_vi_comm_create_monitor(&test_info[count]); sleep(0x3); st_vi_comm_wait_quit_test(); } if (vi_path_num > 0x1) { is_forward_destroy = st_vi_comm_wait_input_select("select forward destroy"); } else { is_forward_destroy = TD_TRUE; } for (count = 0x0; count < vi_path_num; count++) { if (is_forward_destroy == TD_TRUE) { vi_st_green_print("destroy hdmirx %u path!\n", test_info[count].frontend_param.port); st_vi_comm_destroy_monitor(&test_info[count]); } else { vi_st_green_print("destroy hdmirx %u path!\n", test_info[vi_path_num - count - 0x1].frontend_param.port); st_vi_comm_destroy_monitor(&test_info[vi_path_num - count - 0x1]); } if (count < (vi_path_num - 0x1)) { st_vi_comm_wait_quit_test(); } } } td_s32 main(td_s32 argc, td_char *argv[]) { td_u32 hdmirx_port_num_max; td_u32 vi_num_max; td_u32 vi_path_num; td_u32 hdmirx_port[0x2]; st_vi_comm_init_monitor(); if (argc == 0x1) { st_vi_self_running(); return TD_SUCCESS; } hdmirx_port_num_max = st_vi_comm_get_hdmirx_port_num(); vi_num_max = st_vi_comm_get_vi_num(); if (vi_num_max <= 0x1) { if (argc < 0x2 || argv == TD_NULL) { st_vi_comm_deinit_monitor(); printf("Usage: sample_vi [hdmirx0~%d]\n", hdmirx_port_num_max - 0x1); return TD_SUCCESS; } } else { if (argc < 0x2 || argv == TD_NULL) { st_vi_comm_deinit_monitor(); printf("Usage: sample_vi [hdmirx0~%d]\n", hdmirx_port_num_max - 0x1); printf("Usage: sample_vi [hdmirx0~%d] [hdmirx%d]\n", hdmirx_port_num_max - 0x2, hdmirx_port_num_max - 0x1); printf("Usage: sample_vi [hdmirx%d] [hdmirx0~%d]\n", hdmirx_port_num_max - 0x1, hdmirx_port_num_max - 0x2); return TD_SUCCESS; } } if (argc == 0x2) { vi_path_num = 0x1; if (sample_vi_get_hdmirx_port(argv[1], hdmirx_port_num_max, &hdmirx_port[0x0]) != TD_SUCCESS) { return TD_SUCCESS; } vi_st_green_print("hmirx vi path num is 1, hdmirx%u!\n", hdmirx_port[0x0]); } else { vi_path_num = 0x2; if (sample_vi_get_hdmirx_port(argv[1], hdmirx_port_num_max, &hdmirx_port[0x0]) != TD_SUCCESS) { st_vi_comm_deinit_monitor(); return TD_SUCCESS; } if (sample_vi_get_hdmirx_port(argv[2], hdmirx_port_num_max, &hdmirx_port[0x1]) != TD_SUCCESS) { st_vi_comm_deinit_monitor(); return TD_SUCCESS; } vi_st_green_print("hmirx vi path num is 2, hdmirx%u, hdmirx%u!\n", hdmirx_port[0x0], hdmirx_port[0x1]); } st_vi_manual_case_hdmirx_001(hdmirx_port, vi_path_num); st_vi_comm_deinit_monitor(); return TD_SUCCESS; }