150 lines
4.8 KiB
C
150 lines
4.8 KiB
C
/*
|
|
Copyright (c), 2001-2022, Shenshu Tech. Co., Ltd.
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/time.h>
|
|
|
|
#include "sample_comm.h"
|
|
|
|
#define SAMPLE_VPSS_DEFAULT_BORDER_THICK 2
|
|
#define SAMPLE_VPSS_DEFAULT_CHN_WIDTH 960
|
|
#define SAMPLE_VPSS_DEFAULT_CHN_HEIGHT 576
|
|
|
|
/* start vpss */
|
|
td_s32 sample_common_vpss_start(ot_vpss_grp grp, const td_bool *chn_enable,
|
|
const ot_vpss_grp_attr *grp_attr, const ot_vpss_chn_attr *chn_attr, td_u32 chn_array_size)
|
|
{
|
|
ot_vpss_chn vpss_chn;
|
|
td_s32 ret;
|
|
td_s32 i;
|
|
|
|
if (chn_array_size < OT_VPSS_MAX_PHYS_CHN_NUM) {
|
|
sample_print("array size(%u) of chn_enable and chn_attr need > %u!\n",
|
|
chn_array_size, OT_VPSS_MAX_PHYS_CHN_NUM);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ss_mpi_vpss_create_grp(grp, grp_attr);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("ss_mpi_vpss_create_grp(grp:%d) failed with %#x!\n", grp, ret);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ss_mpi_vpss_start_grp(grp);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("ss_mpi_vpss_start_grp failed with %#x\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
for (i = 0; i < OT_VPSS_MAX_PHYS_CHN_NUM; ++i) {
|
|
if (chn_enable[i] == TD_TRUE) {
|
|
vpss_chn = i;
|
|
ret = ss_mpi_vpss_set_chn_attr(grp, vpss_chn, &chn_attr[vpss_chn]);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("ss_mpi_vpss_set_chn_attr failed with %#x\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ss_mpi_vpss_enable_chn(grp, vpss_chn);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("ss_mpi_vpss_enable_chn failed with %#x\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
}
|
|
}
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
/* stop vpss */
|
|
td_s32 sample_common_vpss_stop(ot_vpss_grp grp, const td_bool *chn_enable, td_u32 chn_array_size)
|
|
{
|
|
td_s32 i;
|
|
td_s32 ret;
|
|
ot_vpss_chn vpss_chn;
|
|
|
|
if (chn_array_size < OT_VPSS_MAX_PHYS_CHN_NUM) {
|
|
sample_print("array size(%u) of chn_enable need > %u!\n", chn_array_size, OT_VPSS_MAX_PHYS_CHN_NUM);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
for (i = 0; i < OT_VPSS_MAX_PHYS_CHN_NUM; ++i) {
|
|
if (chn_enable[i] == TD_TRUE) {
|
|
vpss_chn = i;
|
|
ret = ss_mpi_vpss_disable_chn(grp, vpss_chn);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("failed with %#x!\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
}
|
|
}
|
|
|
|
ret = ss_mpi_vpss_stop_grp(grp);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("failed with %#x!\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
ret = ss_mpi_vpss_destroy_grp(grp);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("failed with %#x!\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
|
|
return TD_SUCCESS;
|
|
}
|
|
|
|
td_s32 sample_common_vpss_start_vpss_user(td_s32 grp_cnt, td_s32 chn_cnt, const ot_size *size)
|
|
{
|
|
td_s32 ret;
|
|
ot_vpss_grp vpss_grp;
|
|
ot_vpss_chn vpss_chn;
|
|
ot_vpss_grp_attr grp_attr = {0};
|
|
ot_vpss_chn_attr chn_attr[OT_VPSS_MAX_PHYS_CHN_NUM] = {0};
|
|
td_bool chn_enable[OT_VPSS_MAX_PHYS_CHN_NUM] = {0};
|
|
|
|
grp_attr.max_width = size->width;
|
|
grp_attr.max_height = size->height;
|
|
grp_attr.nr_en = TD_FALSE;
|
|
grp_attr.dei_mode = OT_VPSS_DEI_MODE_OFF;
|
|
grp_attr.pixel_format = SAMPLE_PIXEL_FORMAT;
|
|
grp_attr.frame_rate.src_frame_rate = -1;
|
|
grp_attr.frame_rate.dst_frame_rate = -1;
|
|
|
|
for (vpss_chn = 0; vpss_chn < chn_cnt; ++vpss_chn) {
|
|
chn_enable[vpss_chn] = TD_TRUE;
|
|
chn_attr[vpss_chn].border_en = TD_TRUE;
|
|
chn_attr[vpss_chn].chn_mode = OT_VPSS_CHN_MODE_USER;
|
|
chn_attr[vpss_chn].pixel_format = OT_PIXEL_FORMAT_YVU_SEMIPLANAR_420;
|
|
chn_attr[vpss_chn].width = SAMPLE_VPSS_DEFAULT_CHN_WIDTH;
|
|
chn_attr[vpss_chn].height = SAMPLE_VPSS_DEFAULT_CHN_HEIGHT;
|
|
chn_attr[vpss_chn].frame_rate.src_frame_rate = -1;
|
|
chn_attr[vpss_chn].frame_rate.dst_frame_rate = -1;
|
|
chn_attr[vpss_chn].compress_mode = OT_COMPRESS_MODE_NONE;
|
|
|
|
chn_attr[vpss_chn].border_attr.color = COLOR_RGB_WHITE;
|
|
chn_attr[vpss_chn].border_attr.top_width = SAMPLE_VPSS_DEFAULT_BORDER_THICK;
|
|
chn_attr[vpss_chn].border_attr.bottom_width = SAMPLE_VPSS_DEFAULT_BORDER_THICK;
|
|
chn_attr[vpss_chn].border_attr.left_width = SAMPLE_VPSS_DEFAULT_BORDER_THICK;
|
|
chn_attr[vpss_chn].border_attr.right_width = SAMPLE_VPSS_DEFAULT_BORDER_THICK;
|
|
}
|
|
|
|
for (vpss_grp = 0; vpss_grp < grp_cnt; ++vpss_grp) {
|
|
ret = sample_common_vpss_start(vpss_grp, chn_enable, &grp_attr, chn_attr, OT_VPSS_MAX_PHYS_CHN_NUM);
|
|
if (ret != TD_SUCCESS) {
|
|
sample_print("failed with %#x!\n", ret);
|
|
return TD_FAILURE;
|
|
}
|
|
}
|
|
|
|
return TD_SUCCESS;
|
|
}
|