Linux_SDK_V1.0.3

This commit is contained in:
thead_admin
2023-01-04 13:00:45 +08:00
parent c9c8f34f4e
commit aa56337b1f
7 changed files with 114 additions and 33 deletions

View File

@@ -173,6 +173,12 @@ typedef struct dsp_ctx{
char* algo_name;
}dsp_ctx_t;
typedef enum {
DUAL_DSP_ALGO_TYPE_DSP0_COPY =0,
DUAL_DSP_ALGO_TYPE_DSP1_COPY,
DUAL_DSP_ALGO_TYPE_DSP01_COPY,
}dual_dsp_algo_type_e;
typedef struct dual_dsp_handle{
dsp_ctx_t dsp_ctx[MAX_DSP_DEVICE];
msg_queue_ctx_t dsp_prcoess_queue;
@@ -180,6 +186,7 @@ typedef struct dual_dsp_handle{
void *mem_allocor;
pthread_t thread_dsp_process;
frame_mode_t frame_mode;
dual_dsp_algo_type_e dsp_run_type;
}dual_dsp_handle_t;
@@ -211,11 +218,11 @@ void printUsage(char *name)
" -h height (default: 1280))\n"
" -n runing Camera frame num :0 not stop ,else frame num to stop )\n"
" -M DSP frame mode :0 none ,1 dump enable,2 display)\n"
" -a DSP algo mode :0 catch master frame ,1 catch slave frame, 2 catch each half frame)\n"
"\n", name);
}
static int parseParams(int argc, char **argv, camera_param_t *params,frame_mode_t *mode)
static int parseParams(int argc, char **argv, camera_param_t *params,frame_mode_t *mode,dual_dsp_algo_type_e *dsp_type)
{
int index =0;
int i = 1;
@@ -241,6 +248,7 @@ static int parseParams(int argc, char **argv, camera_param_t *params,frame_mode
params[index].frames_to_stop = 30;
index++;
*mode = FRAME_NONE;
*dsp_type = DUAL_DSP_ALGO_TYPE_DSP01_COPY;
while (i < argc)
{
if (argv[i][0] != '-' || strlen(argv[i]) < 2)
@@ -282,6 +290,11 @@ static int parseParams(int argc, char **argv, camera_param_t *params,frame_mode
if (++i < argc)
*mode = atoi(argv[i++]);
}
else if (argv[i][1] == 'a')
{
if (++i < argc)
*dsp_type = atoi(argv[i++]);
}
else if (strcmp(argv[i], "--help") == 0)
{
printUsage(argv[0]);
@@ -293,7 +306,7 @@ static int parseParams(int argc, char **argv, camera_param_t *params,frame_mode
printf("[DUAL IR] Resolution : %dx%d\n", params[0].out_pic[0].width,params[0].out_pic[0].height);
printf("[DUAL IR] run frame : %d\n", params[0].frames_to_stop);
printf("[DUAL IR] frame mode : %d\n", *mode);
printf("[DUAL IR] dsp run type : %d\n", *dsp_type);
return index;
}
@@ -490,7 +503,7 @@ static int dsp_send_info_to_cam(msg_queue_ctx_t* cam_msg_queue,int master_fd,int
return 0;
}
static dual_dsp_handle_t* dsp_process_create(frame_mode_t mode)
static dual_dsp_handle_t* dsp_process_create(frame_mode_t mode,dual_dsp_algo_type_e type)
{
dual_dsp_handle_t *dsp_hdl=NULL;
dsp_hdl = malloc(sizeof(dual_dsp_handle_t));
@@ -506,6 +519,7 @@ static dual_dsp_handle_t* dsp_process_create(frame_mode_t mode)
dsp_hdl->dsp_prcoess_queue.tail=NULL;
dsp_hdl->dsp_prcoess_queue.exit = 0;
dsp_hdl->frame_mode = mode;
dsp_hdl->dsp_run_type = type;
pthread_mutex_init(&dsp_hdl->dsp_prcoess_queue.mutex,NULL);
if(dsp_construct_task(&dsp_hdl->dsp_ctx[0]))
@@ -739,10 +753,21 @@ static void* dsp_dual_ir_porcess(void *arg)
continue;
}
dsp1_result = (algo_result_t *)buf4.planes[0].buf_vir;
setting.mode = ALGO_PIC_MODE_FULL_COPY_WITH_PARAM;
setting.buf_id=0;
setting.h_offset = dual_ir_frame->height/2;
setting.height =dual_ir_frame->height/2;
if(dsp_hdl->dsp_run_type == DUAL_DSP_ALGO_TYPE_DSP01_COPY )
{
setting.mode = ALGO_PIC_MODE_FULL_COPY_WITH_PARAM;
setting.buf_id=0;
setting.h_offset = dual_ir_frame->height/2;
setting.height =dual_ir_frame->height/2;
}else if(dsp_hdl->dsp_run_type == DUAL_DSP_ALGO_TYPE_DSP0_COPY)
{
setting.mode = ALGO_PIC_MODE_FULL_COPY;
}
else
{
setting.mode = ALGO_PIC_MODE_FULL_COPY_NONE;
}
setting.timestap = dual_ir_frame->timestap;
if(csi_dsp_request_set_property(req1,&setting,sizeof(setting)))
{
@@ -753,10 +778,21 @@ static void* dsp_dual_ir_porcess(void *arg)
continue;
}
setting.mode = ALGO_PIC_MODE_FULL_COPY_WITH_PARAM;
setting.buf_id=0;
setting.h_offset = 0;
setting.height =dual_ir_frame->height/2;
if(dsp_hdl->dsp_run_type == DUAL_DSP_ALGO_TYPE_DSP01_COPY )
{
setting.mode = ALGO_PIC_MODE_FULL_COPY_WITH_PARAM;
setting.buf_id=0;
setting.h_offset = 0;
setting.height =dual_ir_frame->height/2;
}else if(dsp_hdl->dsp_run_type == DUAL_DSP_ALGO_TYPE_DSP1_COPY)
{
setting.mode = ALGO_PIC_MODE_FULL_COPY;
}
else
{
setting.mode = ALGO_PIC_MODE_FULL_COPY_NONE;
}
setting.timestap = dual_ir_frame->timestap;
if(csi_dsp_request_set_property(req2,&setting,sizeof(setting)))
{
@@ -1023,7 +1059,7 @@ static int send_paired_frame_to_dsp(msg_queue_ctx_t *queue,csi_frame_s *master_f
dsp_msg_payload->master_stride = master_frame->img.strides[0];
dsp_msg_payload->master_fd = master_frame->img.fds[0];
dsp_msg_payload->slave_fd = slave_frame->img.fds[0];
dsp_msg_payload->slave_stride = slave_frame->img.strides[0];
dsp_msg_payload->slave_stride = slave_frame->img.strides[0];
dsp_msg_payload->timestap = timestap.time_value.tv_sec*1000000+timestap.time_value.tv_usec;
enqueue_msg(queue,dsp_msg);
main_item = malloc(sizeof(frame_item_t));
@@ -1393,14 +1429,15 @@ static camera_ctx_t * camera_open(camera_param_t *params)
LOG_O("%s open successfully\n",dev_name);
// if(params->type == CAM_TYEP_MASTER)
// {
if(params->type == CAM_TYEP_SLAVE)
{
// csi_camera_floodlight_led_set_flash_bright(cam_ctx->cam_handle, 500); //500ma
// csi_camera_projection_led_set_flash_bright(cam_ctx->cam_handle, 500); //500ma
// csi_camera_projection_led_set_mode(cam_ctx->cam_handle, LED_IR_ENABLE);
csi_camera_projection_led_set_flash_bright(cam_ctx->cam_handle, 500); //500ma
csi_camera_projection_led_set_mode(cam_ctx->cam_handle, LED_IR_ENABLE);
// csi_camera_floodlight_led_set_mode(cam_ctx->cam_handle, LED_IR_ENABLE);
// csi_camera_led_enable(cam_ctx->cam_handle, LED_FLOODLIGHT_PROJECTION);
// }
csi_camera_led_enable(cam_ctx->cam_handle, LED_PROJECTION);
// csi_camera_led_set_switch_mode(cam_ctx->cam_handle, SWITCH_MODE_PROJECTION_ALWAYS_ON);
}
get_system_time(__func__, __LINE__);
@@ -1453,16 +1490,18 @@ int main(int argc, char *argv[])
camera_param_t params[MAX_CAM_NUM];
camera_ctx_t * ctx[MAX_CAM_NUM]={NULL};
frame_mode_t frame_mode ;
dual_dsp_algo_type_e dsp_type;
int cam_num=0;
bool running = false;
cam_num =parseParams(argc,argv,params,&frame_mode);
cam_num =parseParams(argc,argv,params,&frame_mode,&dsp_type);
if(cam_num <=0 || cam_num>MAX_CAM_NUM)
{
LOG_E("not camera is active\n");
exit(0);
}
dsp_hdl =dsp_process_create(frame_mode);
dsp_hdl =dsp_process_create(frame_mode,dsp_type);
if(dsp_hdl==NULL)
{
LOG_E("dsp create faile\n");

View File

@@ -12,10 +12,10 @@
#include <time.h>
#include <csi_common.h>
#include <csi_camera_property.h>
#include <csi_camera_frame.h>
#include <csi_frame_ex.h>
#include "csi_common.h"
#include "csi_camera_property.h"
#include "csi_camera_frame.h"
#include "csi_frame_ex.h"
#ifdef __cplusplus
extern "C" {
@@ -223,6 +223,22 @@ typedef struct csi_camera_event {
};
} csi_camera_event_s;
typedef enum csi_camera_error{
CSI_CAMERA_RET_ERR_INVALID_DEV = -1001,/* device is not valid */
CSI_CAMERA_RET_ERR_INVALID_PARA, /* input params is not valid */
CSI_CAMERA_RET_ERR_NULL_PTR,
CSI_CAMERA_RET_ERR_DEV_BUSY, /* device is budy */
CSI_CAMERA_RET_ERR_NOMEM, /* malloc fail */
CSI_CAMERA_RET_ERR_TIMEOUT, /* evet or frame wait timeout */
CSI_CAMERA_RET_ERR_NOT_SUPPORT, /* setting or config is not supported */
CSI_CAMERA_CHANNEL_RET_ERR_INVALID_CHN = -501,/*channel is not valid */
CSI_CAMERA_CHANNEL_RET_ERR_NOTOPEN,
CSI_CAMERA_RET_ERR = -1, /*common sw error */
CSI_CAMERA_RET_OK =0,
}csi_camera_erro_e;
int csi_camera_get_version(csi_api_version_u *version);
int csi_camera_query_list(csi_camera_infos_s *infos);

View File

@@ -14,7 +14,11 @@
#include <stdbool.h>
#include <sys/time.h>
#include <csi_frame.h>
#include "csi_frame.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CSI_CAMERA_META_MAX_LEN 1024
@@ -57,6 +61,9 @@ int csi_camera_frame_get_meta_unit(csi_camrea_meta_unit_s *meta_unit,
csi_camera_meta_s *meta_data,
csi_camera_meta_id_e meta_field);
#ifdef __cplusplus
}
#endif
#endif /* __CSI_CAMERA_FRAME_H__ */

View File

@@ -10,6 +10,9 @@
#ifndef __CSI_CAMERA_PROPERTY_H__
#define __CSI_CAMERA_PROPERTY_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Camera Property ID */
#define CSI_CAMERA_PID_BASE (0x009a0000 | 0x900)
@@ -89,5 +92,8 @@ enum CSI_CAMERA_AUTO_PRESET_WHITE_BALANCE_MODE {
#define CSI_CAMERA_PID_BAND_STOP_FILTER (CSI_CAMERA_PID_BASE + 0x62)
#define CSI_CAMERA_PID_IMAGE_STABILIZATION (CSI_CAMERA_PID_BASE + 0x63)
#ifdef __cplusplus
}
#endif
#endif /* __CSI_CAMERA_PROPERTY_H__ */

View File

@@ -15,6 +15,9 @@
#include <unistd.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* CSI frame defination is below, including
*
@@ -153,4 +156,8 @@ int csi_frame_release(csi_frame_s *frame);
void *csi_frame_mmap(csi_frame_s *frame);
int csi_frame_munmap(csi_frame_s *frame);
#ifdef __cplusplus
}
#endif
#endif /* __CSI_FRAME_H__ */

View File

@@ -4,8 +4,10 @@
#ifndef _CSI_FRAME_EX_H
#define _CSI_FRAME_EX_H
#include <csi_common.h>
#include "csi_common.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_PLANE_COUNT 3
typedef enum {
@@ -173,4 +175,8 @@ typedef struct csi_bitstream {
} csi_bitstream_s;
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -14,11 +14,11 @@
#include <stdint.h>
#include <stdbool.h>
#include <csi_common.h>
#include <csi_vcodec_common.h>
#include <csi_allocator.h>
#include <csi_frame.h>
#include <csi_frame_ex.h>
#include "csi_common.h"
#include "csi_vcodec_common.h"
#include "csi_allocator.h"
#include "csi_frame.h"
#include "csi_frame_ex.h"
#ifdef __cplusplus
extern "C" {