Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources

This commit is contained in:
2026-07-06 11:30:13 +08:00
commit e76462eeb7
3451 changed files with 1415300 additions and 0 deletions

View File

@@ -0,0 +1,612 @@
#ifndef _CSI_MODE_DEFINE_
#define _CSI_MODE_DEFINE_
#include "tx_platform.h"
#include "list.h"
#include "dev.h"
#include "hal/i2c.h"
#include "dev/csi/hgdvp.h"
#include "hal/isp.h"
typedef struct {
uint32 rotate;
} Rotate_Adapt;
typedef struct {
uint32 pclk;
uint32 v_len;
uint32 step_val;
uint32 step_max;
} Hvb_Adapt;
typedef struct {
void (*fp_rotate)(uint32 rotate);
uint32 (*fp_hvblank)(int8_t hb,int8_t vb);
void (*fp_exp_gain_wr)(uint32 exp,uint32 gain);
} P_Fun_Adapt;
typedef struct {
uint8 *bypass_on;
uint8 *bypass_off;
//_Sensor_Ident_ * sensor_init;
uint8 *sensor_init_table;
uint8 id,w_cmd,r_cmd,addr_num,data_num;
uint16 id_reg;
} P_XC7016_Fun;
typedef struct
{
uint16 pixel_w, pixel_h, bayer_patten, type, input_format;
uint8 mirror, reverse, curr_mirror, curr_reverse;
isp_ae_func adjust_func;
_Sensor_LSC *p_lsc;
_Sensor_BLC *p_blc;
_Sensor_CCM *p_ccm;
_Sensor_AWB *p_awb;
_Sensor_AE *p_ae;
_Sensor_DPC *p_dpc;
_Sensor_CSC *p_csc;
_Sensor_GIC *p_gic;
_Sensor_CSUPP *p_csupp;
_Sensor_SHARP *p_sharp;
_Sensor_YUVNR *p_yuvnr;
_Sensor_COLENH *p_colenh;
_Sensor_BV2NR *p_bv2nr;
_Sensor_LHS *p_lhs;
_Sensor_YGAMMA *p_ygamma;
_Sensor_WDR *p_wdr;
sensor_img_opt img_opt;
sensor_fps_opt fps_opt;
}_Sensor_ISP_Init;
typedef struct {
uint8 w_cmd,r_cmd,id,addr_num,data_num;
uint16 id_reg;//id ¼Ä´æÆ÷µØÖ·
uint8 *init;
uint32 init_len;
uint8 *preset;
uint16 typ; //0: raw 1:yuv 2:mipi
uint32 mclk;
uint32 pclk_fir_en;
uint16 pixelw;
uint16 pixelh;
uint8 mipi_lane_num;
uint8 colrarray;
bool hsyn;
bool vsyn;
bool rduline;
bool rawwide;
/*void (*fp_rotate)(uint8 rotate);
uint32 (*fp_hvblank)(int8_t dh,int8_t dv);
Exp_Adapt exp_adapt;
uint32 csi_awb_gain;*/
Rotate_Adapt rotate_adapt;
Hvb_Adapt hvb_adapt;
volatile uint32 isp_all_mod;
uint32 allow_miss_dots;
uint32 align[1]; // only for 16byte align
//sens_isp_adapt
//BLC blc_adapt;
//LC lc_adapt;
//DDC ddc_adapt;
//AWB awb_adapt;
//CCM ccm_adapt;
//YGAMA ygama_adapt;
//RGB_GAMA rgbgama_adapt;
//EE ee_adapt;
//CCF ccf_adapt;
//LSC lsc_adapt;
//CBHS cbhs_adapt;
//MD md_adapt;
//EXP exp_adapt;
P_Fun_Adapt p_fun_adapt;
P_XC7016_Fun p_xc7016_adapt;
_Sensor_ISP_Init *sensor_isp;
} _Sensor_Adpt_;
typedef struct
{
uint8 id,w_cmd,r_cmd,addr_num,data_num;
uint16 id_reg;
}_Sensor_Ident_;
typedef struct
{
uint8 online;
uint32 pclk;
uint32 iclk;
_Sensor_Ident_ * p_sensor_ident;
_Sensor_Adpt_ * p_sensor_cmd;
}SNSER;
typedef struct
{
uint16 in_w; //sensor pixel
uint16 in_h;
uint16 out0_w; //to jpg encode
uint16 out0_h;
uint16 out1_w; //to jpg encode
uint16 out1_h;
}Vpp_stream;
typedef struct
{
uint16 out_w;
uint16 out_h;
}Output_photo;
struct i2c_setting
{
uint8 u8DevWriteAddr;
uint8 u8DevReadAddr;
};
#define ALIGNED(x) __attribute__ ((aligned(x)))
#define SENSOR_INIT_SECTION ALIGNED(32)
#define SENSOR_OP_SECTION ALIGNED(32)
#define CMOS_INIT_LEN
#define DVP ((struct hgdvp_hw *) DVP_BASE)
extern uint8 u8SensorwriteID,u8SensorreadID;
extern uint8 u8Addrbytnum,u8Databytnum;
void Delay_nopCnt(uint32 cnt);
int sensorCheckId(uint8_t devid,const _Sensor_Ident_ *p_sensor_ident,const _Sensor_Adpt_ *p_sensor_adpt);
void get_single_dvp(uint16_t *w,uint16_t *h);
//void sensor_ClockInit(struct hgdvp_hw *p_dvp,uint32 mclk);
//uint32 Sensor_ReadRegister(SPI_I2C_TypeDef *p_iic,uint8 *pbdata ,uint8 u8AddrLength,uint8 u8DataLength);
//bool Sensor_WriteRegister(SPI_I2C_TypeDef *p_iic,uint8 *pbdata ,uint8 u8AddrLength,uint8 u8DataLength);
//void i2c_SendStop(SPI_I2C_TypeDef *p_iic);
//void iic_init_sensor(uint32 u32iicClk,SPI_I2C_TypeDef *p_iic);
//////////////////////////////////////////COMMON//////////////////////////////////////////////////////////////////////
#define IMAGE_W 1280
#define IMAGE_H 720
#define IMAGE_FORMAT 0 //0:YUV422
//1:RAW8
//2:RAW10
//3:RAW12
#define SCEN_EN 0
#define FRAME_RATE 0 //0: 100%
//1: 75%
//2: 50%
//3: 25%
#define ONCE_SAMPLE 0 //这个只处理整帧中断的情况,即RGB/Y ONLY
////////////////////////////////////////////////////////RGB//////////////////////////////////////////////////////////////////
#define RGB2YUV 0
////////////////////////////////////////////////////////YUV//////////////////////////////////////////////////////////////////
#define HSYS 0 //0:h->1 v->1
//1:h->1 v->0
//2:h->0 v->1
//3:h->0 v->0
#define YUV_MODE 0 //0YUYV
//1YVYU
//2UYVY
//3VYUY
#define ONLY_Y 0
////////////////////////////////////////////////////////JPEG//////////////////////////////////////////////////////////////////
#define JPEG_LEN 2*1024
#ifndef VPP_SCALE_WIDTH
#define VPP_SCALE_WIDTH 1920//1920//1280
#endif
#ifndef VPP_SCALE_HIGH
#define VPP_SCALE_HIGH 1080//1080//720
#endif
#ifndef IPF_EN
#define IPF_EN 0
#endif
#define DET_EN 1
#ifndef VPP_BUF1_EN
#define VPP_BUF1_EN 0
#endif
#ifndef PSRAM_FRAME_SAVE
#define PSRAM_FRAME_SAVE 0
#endif
///////////////////////////////////////////////////////sensor//////////////////////////////////////////////////////////////////////
#ifndef DEV_SENSOR_OV7725
#define DEV_SENSOR_OV7725 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_OV7670
#define DEV_SENSOR_OV7670 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC0308
#define DEV_SENSOR_GC0308 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC0309
#define DEV_SENSOR_GC0309 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC0328
#define DEV_SENSOR_GC0328 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_BF20A6
#define DEV_SENSOR_BF20A6 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_BF3A03
#define DEV_SENSOR_BF3A03 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_BF3703
#define DEV_SENSOR_BF3703 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC0311
#define DEV_SENSOR_GC0311 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC0329
#define DEV_SENSOR_GC0329 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC0312
#define DEV_SENSOR_GC0312 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_SP0718
#define DEV_SENSOR_SP0718 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_SP0A19
#define DEV_SENSOR_SP0A19 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_BF3720
#define DEV_SENSOR_BF3720 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_GC032A
#define DEV_SENSOR_GC032A (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_OV2640
#define DEV_SENSOR_OV2640 0
#endif
#ifndef DEV_SENSOR_BF2013
#define DEV_SENSOR_BF2013 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_XC7016_H63
#define DEV_SENSOR_XC7016_H63 0
#endif
#ifndef DEV_SENSOR_XC7011_H63
#define DEV_SENSOR_XC7011_H63 0
#endif
#ifndef DEV_SENSOR_XC7011_GC1054
#define DEV_SENSOR_XC7011_GC1054 0
#endif
#ifndef DEV_SENSOR_XCG532
#define DEV_SENSOR_XCG532 0
#endif
#ifndef DEV_SENSOR_GC2145
#define DEV_SENSOR_GC2145 0
#endif
#ifndef DEV_SENSOR_BF3A01
#define DEV_SENSOR_BF3A01 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_BF30A2
#define DEV_SENSOR_BF30A2 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_H62
#define DEV_SENSOR_H62 0
#endif
#ifndef DEV_SENSOR_H63P
#define DEV_SENSOR_H63P 0
#endif
#ifndef DEV_SENSOR_SC1346
#define DEV_SENSOR_SC1346 0
#endif
#ifndef DEV_SENSOR_GC1084
#define DEV_SENSOR_GC1084 0
#endif
#ifndef DEV_SENSOR_GC2083
#define DEV_SENSOR_GC2083 0
#endif
#ifndef DEV_SENSOR_GC2053
#define DEV_SENSOR_GC2053 0
#endif
#ifndef DEV_SENSOR_SC2336P
#define DEV_SENSOR_SC2336P 0
#endif
#ifndef DEV_SENSOR_SC233AP
#define DEV_SENSOR_SC233AP 0
#endif
#ifndef DEV_SENSOR_SC2331
#define DEV_SENSOR_SC2331 0
#endif
#ifndef DEV_SENSOR_F38P
#define DEV_SENSOR_F38P 0
#endif
#ifndef DEV_SENSOR_F37P
#define DEV_SENSOR_F37P 0
#endif
#if DEV_SENSOR_OV7725
extern const _Sensor_Ident_ ov7725_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ ov7725_cmd;
#endif
#if DEV_SENSOR_OV7670
extern const _Sensor_Ident_ ov7670_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ ov7670_cmd;
#endif
#if DEV_SENSOR_GC0308
extern const _Sensor_Ident_ gc0308_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc0308_cmd;
#endif
#if DEV_SENSOR_BF20A6
extern const _Sensor_Ident_ bf20a6_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf20a6_cmd;
extern const _Sensor_Ident_ bf20a6_spi_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf20a6_spi_cmd;
#endif
#if DEV_SENSOR_GC0309
extern const _Sensor_Ident_ gc0309_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc0309_cmd;
#endif
#if DEV_SENSOR_GC0328
extern const _Sensor_Ident_ gc0328_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc0328_cmd;
#endif
#if DEV_SENSOR_GC0311
extern const _Sensor_Ident_ gc0311_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc0311_cmd;
#endif
#if DEV_SENSOR_GC0329
extern const _Sensor_Ident_ gc0329_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc0329_cmd;
#endif
#if DEV_SENSOR_GC0312
extern const _Sensor_Ident_ gc0312_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc0312_cmd;
#endif
#if DEV_SENSOR_BF3A03
extern const _Sensor_Ident_ bf3a03_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf3a03_cmd;
#endif
#if DEV_SENSOR_BF3703
extern const _Sensor_Ident_ bf3703_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf3703_cmd;
#endif
#if DEV_SENSOR_BF2013
extern const _Sensor_Ident_ bf2013_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf2013_cmd;
#endif
#if DEV_SENSOR_OV2640
extern const _Sensor_Ident_ ov2640_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ ov2640_cmd;
#endif
#if DEV_SENSOR_XC7016_H63
extern const _Sensor_Ident_ xc7016_h63_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ xc7016_h63_cmd;
#endif
#if DEV_SENSOR_XC7011_H63
extern const _Sensor_Ident_ xc7011_h63_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ xc7011_h63_cmd;
#endif
#if DEV_SENSOR_XC7011_GC1054
extern const _Sensor_Ident_ xc7011_gc1054_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ xc7011_gc1054_cmd;
#endif
#if DEV_SENSOR_XCG532
extern const _Sensor_Ident_ xcg532_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ xcg532_cmd;
#endif
#if DEV_SENSOR_GC2145
extern const _Sensor_Ident_ gc2145_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc2145_cmd;
#endif
#if DEV_SENSOR_SP0718
extern const _Sensor_Ident_ sp0718_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sp0718_cmd;
#endif
#if DEV_SENSOR_SP0A19
extern const _Sensor_Ident_ sp0a19_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sp0a19_cmd;
#endif
#if DEV_SENSOR_BF3720
extern const _Sensor_Ident_ bf3720_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf3720_cmd;
#endif
#if DEV_SENSOR_GC032A
extern const _Sensor_Ident_ gc032a_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc032a_cmd;
#endif
#if DEV_SENSOR_BF3A01
extern const _Sensor_Ident_ bf3a01_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf3a01_cmd;
#endif
#if DEV_SENSOR_BF30A2
extern const _Sensor_Ident_ bf30a2_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf30a2_cmd;
#endif
#if DEV_SENSOR_H62
extern const _Sensor_Ident_ h62_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ h62_cmd;
#endif
#if DEV_SENSOR_H63P
extern const _Sensor_Ident_ h63p_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ h63p_cmd;
#endif
#if DEV_SENSOR_H66
extern const _Sensor_Ident_ h66_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ h66_cmd;
#endif
#if DEV_SENSOR_SC1336
extern const _Sensor_Ident_ sc1336_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sc1336_cmd;
#endif
#if DEV_SENSOR_SC1346
extern const _Sensor_Ident_ sc1346_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sc1346_cmd;
#endif
#if DEV_SENSOR_GC1084
extern const _Sensor_Ident_ gc1084_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc1084_cmd;
extern const _Sensor_Ident_ gc1084_init2;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc1084_cmd2;
#endif
#if DEV_SENSOR_GC1054
extern const _Sensor_Ident_ gc1054_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc1054_cmd;
#endif
#if DEV_SENSOR_GC2083
extern const _Sensor_Ident_ gc2083_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc2083_cmd;
#endif
#if DEV_SENSOR_GC2053
extern const _Sensor_Ident_ gc2053_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc2053_cmd;
#endif
#if DEV_SENSOR_SC2336P
extern const _Sensor_Ident_ sc2336p_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sc2336p_cmd;
#endif
#if DEV_SENSOR_SC233AP
extern const _Sensor_Ident_ sc233ap_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sc233ap_cmd;
#endif
#if DEV_SENSOR_SC2331
extern const _Sensor_Ident_ sc2331_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sc2331_cmd;
#endif
#if DEV_SENSOR_F38P
extern const _Sensor_Ident_ f38p_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ f38p_cmd;
#endif
#if DEV_SENSOR_F37P
extern const _Sensor_Ident_ f37p_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ f37p_cmd;
#endif
#if DEV_SENSOR_OV9734
extern const _Sensor_Ident_ ov9734_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ ov9734_cmd;
#endif
#if DEV_SENSOR_GC20C3
extern const _Sensor_Ident_ gc20C3_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ gc20C3_cmd;
#endif
#if DEV_SENSOR_IMX912
extern const _Sensor_Ident_ imx219_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ imx219_cmd;
#endif
#if DEV_SENSOR_CV2008
extern const _Sensor_Ident_ cv2008_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ cv2008_cmd;
#endif
#if DEV_SENSOR_CV2005
extern const _Sensor_Ident_ cv2005_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ cv2005_cmd;
#endif
#endif

View File

@@ -0,0 +1,5 @@
#ifndef _CSIV2_MODE_DEFINE_
#define _CSIV2_MODE_DEFINE_
#include "hal/vpp.h"
void set_time_watermark(struct vpp_device *vpp_dev,uint16 year,uint16 month,uint16 day,uint16 hour,uint16 min,uint16 sec);
#endif

View File

@@ -0,0 +1,104 @@
#ifndef _JPG_MODE_DEFINE_
#define _JPG_MODE_DEFINE_
#define DQT_DEF 5
#define DQT_MAX_INDEX 11
#ifndef TARGET_JPG_LEN
#define TARGET_JPG_LEN 50000
#endif
#define QUALITY_CTRL_P 40
#define QUALITY_CTRL_I 1
#define QUALITY_CTRL_D 0
#define LIMITING(x,x1,x2) (x>x1)?x1:(x<x2?x2:x)
typedef struct
{
struct list_head list; //jpeg_frame的节点头
uint32 frame_len; //帧长度
uint8 usable; //判断是否可用 0:空闲
// 1:节点补充中或正在使用中
// 2:可用
uint8 jpg_num;
}jpeg_frame;
typedef struct
{
struct list_head list;
uint8* buf_addr;
}mjpeg_node;
enum JPG_ID
{
JPGID0,
JPGID1,
};
//通过定义宏去设置jpg的lock的值,只要有复用,就需要添加一个,防止与其他冲突
enum JPG_LOCK_VALUE
{
JPG_LOCK_NONE,
JPG_LOCK_ENCODE,
JPG_LOCK_SCALE1_ENCODE,
JPG_LOCK_DECODE,
JPG_LOCK_GEN420_ENCODE,
JPG_LOCK_GEN420_RECODE,
JPG_LOCK_GEN420_THUBM_ENCODE,
JPG_LOCK_GEN420_THUBM_ENCODE_USB,
JPG_LOCK_GEN420_THUBM_ENCODE_OVER_DPI,
JPG_LOCK_NORMAL_ENCODE,
JPG_LOCK_MAX = 0xff,
};
enum JPG_SRC_FROM {
VPP_DATA0,
VPP_DATA1,
PRC_DATA,
SCALER_DATA,
GEN420_DATA,
SOFT_DATA,
};
void jpg_start(uint8 jpgid);
void jpeg_user();
//void jpg_open(struct hgjpg_hw *p_jpg,uint8 mode);
//void hgjpg_attach(uint32 dev_id, struct hgjpg *jpg);
#ifdef TXW81X
void jpg_cfg(uint8 jpgid,enum JPG_SRC_FROM src_from);
#endif
#ifdef TXW80X
void jpg_cfg();
#endif
//bool put_node(volatile struct list_head *head,volatile struct list_head *del);
void del_frame(uint8 jpg_num,volatile struct list_head* frame_list);
struct list_head* get_frame(uint8 jpgid);
void mjpeg_sema_init();
void mjpeg_sema_down(int32 tmo_ms);
void mjpeg_sema_up();
void mjpeg_avi_thread(void *d);
extern const uint16 htable[384];
extern const uint8 dhtable[412];
extern char quality_tab[6][128];
#if SCEN_EN
#define IMAGE_W_J IMAGE_W/2
#define IMAGE_H_J IMAGE_H/2
#else
#define IMAGE_W_J IMAGE_W
#define IMAGE_H_J IMAGE_H
#endif
#endif

View File

@@ -0,0 +1,8 @@
#ifndef __JPG_COMMON_H
#define __JPG_COMMON_H
#include "lib/video/dvp/jpeg/jpg.h"
int32 jpg_mutex_init();
int32_t jpg_mutex_lock(uint32_t jpgid,uint8_t value,uint8_t *last_value);
int32_t jpg_mutex_unlock(uint32_t jpgid,int32_t value);
int32_t jpg_mutex_unlock_check(uint32_t jpgid,int32_t value);
#endif

View File

@@ -0,0 +1,7 @@
#ifndef GEN420_DEV_H
#define GEN420_DEV_H
void gen420_dev_init(uint32_t width,uint32_t high);
#endif

View File

@@ -0,0 +1,8 @@
#ifndef GEN422_DEV_H
#define GEN422_DEV_H
void gen422_init(uint32_t w,uint32_t h,uint8_t sigle_frm);
void gen422_set_frame(uint32_t psram0,uint32_t psram1,uint32_t w,uint32_t h);
void gen422_run();
#endif

View File

@@ -0,0 +1,210 @@
#ifndef _H264_MODE_DEFINE_
#define _H264_MODE_DEFINE_
#include "dev/h264/hg264.h"
struct h264_cfg_t {
uint8_t enc_mode ; //0:dec, 1:enc
uint8_t enc_bs_buf_size;//0:1KB; 1:2KB; 2:4KB; 3:8KB; 4:16KB
uint16_t frm_width ;
uint16_t frm_height ;
uint16_t wrap_width;
uint16_t wrap_height;
uint16_t enc_bps ; //Kbit pre second
uint16_t still_enc_bps ;
uint16_t move_enc_bps ;
uint16_t stilltomove ; //enc frame mb precent
uint16_t frm_rate ; //fps
uint16_t frm_gop ; //IPPPP frame number of a gop
uint8_t rc_en ; //enc rate control enable
uint8_t rc_grp ; //mb line number when RC change qp
uint8_t cc_corect ; //0:off; 1:on
uint8_t rc_effort ; //0:low; 1: high; 2:relax;
uint8_t frm_ip_rate ; //initial (Intra MB line)/(Inter MB line) target bit rate times; not critical parameter.
uint8_t frm_ip_rate_max;
uint8_t frm_ip_rate_min;
uint8_t flt3d_en ; //3D filter enable
uint8_t flt3d_en_last ;
uint8_t flt_noise_lev ; //0: very low nosie; 1: low; 2: medium; 3: high; 4: very high; naomal usage is: 2
uint8_t flt_noise_lev_last;
uint8_t ini_qp ; //initial QP for this sequence, not critical
uint8_t roi_qp ; //QP used in ROI windows
uint8_t src_from ;
uint8_t count ;
uint32_t r3dnr ;
uint8_t gop_rst_3dnr ;
uint8_t run_gop_3dnr ;
uint8_t auto_ctl_3dnr ; //need open vpp det
uint32_t last_vpp_md;
uint32_t md_3dnr_en;
uint8_t md_3dnr_timer;
uint8_t md_set_3dnr;
uint8_t enc_runing;
uint8_t move_keep_gop; //still to move,keep x gop for mov_enc_bps
uint8_t move_remain_gop;
volatile uint8_t timeLapse_en:1,timeLapse_ready_kick:1,rev:6; //分别是缩时录影的使能和是否可以kick(不能随便使用,除非知道流程)
};
struct h264_ctl_t {
uint8_t enc_mode ; //0:dec, 1:enc
uint8_t bs_buf_id ; //0:use buf0; 1:use buf1
uint32_t bs_base0 ; //bitream buffer base addr, 1KB aligned
uint32_t bs_base1 ; //bitream buffer base addr, 1KB aligned
uint32_t ref_lu_base ; //ref luma buffer base address, 4KB aligned
uint32_t ref_lu_end ; //ref luma buffer end address, 4KB aligned
uint32_t ref_ch_base ; //ref chroma buffer base address, 4KB aligned
uint32_t ref_ch_end ; //ref chroma buffer end address, 4KB aligned
uint8_t frm_type ; //0:P frame; 2:I frame
uint8_t frm_qp ; //qp for this frame
uint16_t frm_width ;
uint16_t frm_height ;
uint16_t frm_cnt ; //encoded frame numebr cnt
uint8_t gop_frm_cnt ; //0~N cnt within a gop
uint8_t idrid ;
uint32_t target_gop ; //target bs byte of a gop
uint32_t frm_target ; //rc target byte of this frame
uint32_t last_lpf_lu_base; //last frame lpf luma write base
uint32_t last_lpf_ch_base; //last frame lpf chroma write base
uint16_t frm_mblines ; //frm_height/16
uint32_t frm_luma_size ; //frm_width*frm_height
uint32_t timeout_limit ; //timeout cycle for a frame
uint32_t bs_byte_limit ; //max enc bitstream length
uint8_t enc_first_frm ; //1: first frame; 0: not first frame
uint32_t enc_end_flags ; //flags after end enc a frame
uint32_t enc_bs_byte ; //enc bitstream byte length of a frame
uint8_t hw_cal_qp ; //when RC enable, HW cal qp for next frame
uint32_t base_bs ;
};
struct h264_rc_ctl_t {
uint8_t i_qp ; //start QP for I frame
uint8_t p_qp ; //start QP for p frame
uint16_t p_qp_acc ; //accumulate QP for last 4 P frames of a gop
uint16_t p_acc_num ; //frame number of QP accumulate
uint16_t gop_remain_frame; //remian frame number with in a GOP
int32_t gop_remain_byte ; //remain bitstream byte size for frames in this GOP
uint32_t i_byte ; //target bitstream byte size for I frame
uint32_t i_frm_max ; //max target byte for I frame
uint32_t i_frm_min ; //min target byte for I frame
uint32_t p_avg ; //P frame average byte target in a GOP
uint32_t p_frm_max ; //max target byte for P frame
uint32_t p_frm_min ; //min target byte for P frame
uint32_t frm_rdcost ; //frame rdcost
};
//--- decoder related ---//
enum nal_type {
pic_data= 1,
pic_idr = 5,
sps = 7,
pps = 8
};
struct str_info{
uint8_t* ptr ;
uint32_t stream ; //after each h264_read_bs(), valid bit>=25
uint8_t bit_len ;
uint32_t used_bits ;
};
struct h264_header {
uint8_t idr_flag ;
uint16_t sps_log2_max_fnum_minus4;
uint16_t sps_log2_max_poc_lsb_minus4;
uint16_t sps_pic_width ;
uint16_t sps_pic_height;
uint8_t pps_qp_ini ;
uint8_t pps_cavlc_mode;
int8_t pps_chrom_qp_offset;
uint8_t pic_slice_type;
uint8_t pic_qp ;
};
typedef struct
{
struct list_head list; //h264_frame的节点头
uint32 frame_len; //帧长度
uint8 usable; //判断是否可用 0:空闲
// 1:节点补充中或正在使用中
// 2:可用
uint8 h264_num; //2~255
//uint8 h264_type; //1:I frame 2:P frame
uint8 h264_type: 2, which: 3,srcID: 3; //h264_type暂时是I帧 P帧(兼容旧版本),which是指源头之类(可能从vpp0编码,可能从gen420编码,或者是vpp0的第二个摄像头,都有可能,暂时给3bit,可以代表7种)
uint8 h264_dev_id;
uint32_t timestamp;
uint16_t w,h;
}h264_frame;
typedef struct
{
struct list_head list;
uint8* buf_addr;
}h264_node;
struct stream_h264_data_s
{
struct stream_h264_data_s *next;
void *data;
int ref;
};
#define IMAGE_W_H264 1280//1920//
#define IMAGE_H_H264 720//1088//
#define H264_BS_SIZE 512*1024 //512K
#define H264_NODE_LEN 16*1024 //不要改
#define H264_NODE_NUM 32
#define H264_FRAME_NUM 4
#define H264_DEV_0_ID 0
#define H264_DEV_1_ID 1
void h264_drv_init();
int h264_enc(uint32_t drv1_from,uint32_t drv1_w,uint32_t drv1_h,uint32_t drv2_from,uint32_t drv2_w,uint32_t drv2_h);
uint32 get_h264_len(void *d);
void del_h264_frame(void *d);
uint32 get_h264_node_len_new(void *get_f);
void *get_h264_first_buf(void *d);
int del_h264_first_node(void *d);
void *get_h264_node_buf(void *d);
void del_h264_node(void *d);
uint8 get_h264_type(void *d);
uint8 get_h264_loop_num(void *d);
void h264_dec_src_264(uint8 *src_file,uint32 file_size,uint32 w,uint32 h,uint32_t devid);
void h264_dec_room_init(uint8_t devnum,uint16_t drv2_w,uint16_t drv2_h);
void get_h264_stream_w_h(uint16_t* w,uint16_t* h,uint8_t *h264data);
struct list_head* get_h264_frame();
uint32 get_h264_timestamp(void *d);
int h264_mem_init(uint8_t init,uint32_t drv1_w,uint32_t drv1_h,uint32_t drv2_w,uint32_t drv2_h);
uint32 get_h264_which(void *d);
void h264_recfg_bsp(uint8_t dev_num,uint16_t mbps,uint16_t sbps);
void h264_recfg_rate(uint8_t dev_num,uint16_t rate);
void h264_recfg_frm_gop(uint8_t dev_num,uint16_t gop);
void h264_recfg_ini_qp(uint8_t dev_num,uint8_t qp);
void h264_reflash_new_gop(uint8_t dev_num,uint8_t en);
void h264wq_queue_init(uint16_t w,uint16_t h);
uint8_t h264msg_queue_done(uint32 list);
int put_h264msg_to_queue(uint8_t type,uint32_t w,uint32_t h,uint32 data,uint32 len);
void h264_dec_intr_status(struct h264_device *p_h264,struct h264_ctl_t *dec_ctl);
void h264_clr_intr(struct h264_device *p_h264);
void sps_setting(struct str_info *str, struct h264_header *head, uint32_t w, uint32_t h);
void cfg_setting(struct h264_device *p_h264, struct h264_header *head, struct h264_cfg_t *cfg, struct h264_ctl_t *ctl);
void h264_dec_refbuf_set(struct h264_device *p_h264,uint32_t buf_base, struct h264_cfg_t *dec_cfg, struct h264_ctl_t *dec_ctl);
void pps_setting(struct str_info *str, struct h264_header *head, uint8_t *pps, uint8_t len);
void h264_rom_memcpy(uint8_t *rom_ptr, uint8_t *data, uint32_t len);
void h264_decode_I_P_setting(struct str_info *str, struct h264_header *head, uint8_t *rom_ptr);
void h264_dec_a_frame(struct h264_device *p_h264,uint32_t nal_length, struct h264_ctl_t *dec_ctl, struct h264_header *head, struct str_info *str,uint32 dataroom) ;
void h264_dec_flag_chk(uint32_t flags);
void h264_dec_src_room_set(struct h264_device *p_h264,uint32_t buf_base, struct h264_cfg_t *dec_cfg,struct h264_ctl_t *dec_ctl);
int h264_enc_with_timeLapse(uint32_t drv1_from,uint32_t drv1_w,uint32_t drv1_h,uint32_t timer);
#endif

View File

@@ -0,0 +1,18 @@
#ifndef _ISP_DEV_H_
#define _ISP_DEV_H_
#include "hal/isp.h"
typedef struct sensor_isp_info {
struct list_head list;
uint16 sensor_src;
uint16 sensor_type;
uint16 sensor_dev_id;
uint16 sensor_opt_cmd;
uint32 sensor_config;
} SENSOR_BASIC_INFO;
void isp_cfg_dev();
void sensor_info_init();
void sensor_info_destory();
void sensor_info_add(enum sensor_type type, enum isp_input_dat_src sensor_src, uint32 sensor_config, uint32 iic_id, uint32 opt_cmd);
#endif

View File

@@ -0,0 +1,92 @@
#ifndef _ISP_IRCUT_H_
#define _ISP_IRCUT_H_
#include "hal/isp.h"
#include "osal/work.h"
#define IR_ABS(x) ((x) < 0 ? -(x) : (x))
typedef struct {
float curr_bv;
uint16_t r_mean, g_mean, b_mean;
uint16_t r_gain, b_gain;
uint16_t saturation;
} ISP_IRCUT_STAT;
typedef struct ircut_info{
uint8 ircut_opt_status;
uint8 whiteled_status; // whiteled status flag( on : open whiteled)
uint8 irled_status; // irled status flag( on : open irled)
uint8 ircut_status; // ircut status flag( on : open ircut)
uint8 irdet_status; // ircut status flag( on : open ircut)
uint8 irled_detect_mode; // irled detece select
uint8 sw_state;
uint8 isp_mode;
uint8 frame_cnt;
uint8 frame_to_switch;
uint8 ircut_en; // ircut_hardware config gpio
uint8 action_status;
uint8 action_type;
uint8 ircut_gpio_en, irled_gpio_en, irdet_gpio_en, whiteled_gpio_en;
uint8 switch_cnt, switch_max;
uint16 last_r_gain,last_b_gain;
uint16 to_day_sat,to_day_diff_rb_gain,to_day_diff_b_gain;
float to_day_bv,to_day_bv_max, to_night_bv;
struct os_work ircut_action_work;
struct isp_device *dev;
}IRCUT_INFO;
enum {
IRLED_OFF = 0,
IRLED_ON,
};
enum {
IRDET_OFF = 0,
IRDET_ON,
};
enum {
WHITELED_OFF = 0,
WHITELED_ON,
};
enum {
IRCUT_OPT_STATE_IDLE,
IRCUT_OPT_STATE_SW_ON,
IRCUT_OPT_STATE_SW_OFF,
IRCUT_OPT_STATE_ON,
IRCUT_OPT_STATE_OFF,
};
enum {
IRCUT_OFF,
IRCUT_ON,
};
enum {
IRCUT_ACTION_STOP,
IRCUT_ACTION_START,
};
enum {
IRCUT_DET_MODE_SW,
IRCUT_DET_MODE_HW,
IRCUT_DET_MODE_MANUAL,
};
enum {
ISP_MODE_DAY_COLOR = 0,
ISP_MODE_NIGHT_COLOR = 1,
ISP_MODE_NIGHT_MONO = 2,
};
enum {
IRCUT_STAT_DAY_TO_NIGHT,
IRCUT_STAT_WB_REC,
IRCUT_STAT_NIGHT_TO_DAY,
};
void ircut_init();
#endif

View File

@@ -0,0 +1,32 @@
#ifndef _MIPI_CSI_H_
#define _MIPI_CSI_H_
#include "sys_config.h"
#include "typesdef.h"
#define RAW8 1
#define RAW10 2
#define RAW12 3
#define YUV422 5
#ifndef INPUT_MODE
#define INPUT_MODE RAW10
#endif
#ifndef DOUBLE_CSI
#define DOUBLE_CSI 1 //主机
#endif
#ifndef DOUBLE_LANE
#define DOUBLE_LANE 0
#endif
struct mipi_csi_debug {
uint8 debug_enable;
uint8 debug_io0 , debug_io1 , debug_io2 , debug_io3 , debug_io4 , debug_io5 ;
uint8 debug_type0, debug_type1, debug_type2, debug_type3, debug_type4, debug_type5;
};
#endif

View File

@@ -0,0 +1,19 @@
#ifndef _PARA_IN_DEV_H_
#define _PARA_IN_DEV_H_
#include "basic_include.h"
#include "hal/para_in.h"
#define TP9950_HDA_720P_25FPS
#if DEV_SENSOR_TP9950
#ifdef TP9950_HDA_720P_25FPS
extern const _Sensor_Para_in_Init tp9950_HDA_720P_25FPS_para_in_init;
#endif
#endif
void para_in_hareware_init();
#endif

View File

@@ -0,0 +1,73 @@
#ifndef RTT_UVC_HOST_H
#define RTT_UVC_HOST_H
#include "basic_include.h"
#include "hal/usb_device.h"
#include "usbh_video.h"
#include "dev/usb/uvc_host.h"
#define UVC_DEFAULT_FRAME_NUM 2
#define UVC_DEFAULT_BLANK_NUM 8
#define UVC_DEFAULT_BLANK_LEN 16 * 1024
#define MAX_DEVICES 4 // 最大支持设备数
enum uvc_device_frame_state {
UVC_DEVICE_FRAME_STATE_IDLE = 0,
UVC_DEVICE_FRAME_STATE_BUSY,
UVC_DEVICE_FRAME_STATE_AVAILABLE,
UVC_DEVICE_FRAME_STATE_USING,
};
enum uvc_device_frame_end {
UVC_DEIVCE_FRAME_NOT_END = 0,
UVC_DEIVCE_FRAME_END,
UVC_DEVICE_FRAME_ERROR,
};
enum uvc_device_register_state {
UVC_DEVICE_REGISTER_IDLE = 0,
UVC_DEVICE_REGISTER_AVAILABLE,
UVC_DEVICE_REGISTER_BUSY,
};
enum uvc_device_blank_state {
UVC_DEVICE_BLANK_STATE_IDLE = 0,
UVC_DEVICE_BLANK_STATE_BUSY,
UVC_DEVICE_BLANK_STATE_AVAILABLE,
};
// UVC设备实例结构体
typedef struct {
uint8_t dev_num; // 关联的设备号
uint8_t is_register;
uint8_t blank_num;
uint32_t blank_len;
struct list_head free_uvc_tab; //空闲节点链表
uint32_t frame_counter;
uint32_t filter_count;
uint8_t last_fid;
uint32_t expected_fid;
uint8_t initial_fid_detected;
UVC_BLANK *blank_buffer;
UVC_MANAGE uvc_msg_frame[UVC_DEFAULT_FRAME_NUM];
UVC_MANAGE *current_frame;
UVC_BLANK *current_blank;
uint32_t dwPresentationTime;
struct usb_device *p_dev;
} UVC_Device;
bool uvc_device_pool_init();
void uvc_device_pool_deinit();
void* register_uvc_device(uint8_t dev_num, uint8_t blank_num, uint32_t blank_len, void* p_dev);
bool unregister_uvc_device(void* device);
struct list_head *uvc_device_user_get_frame(void* device);
void uvc_device_user_free_blank_node(void* device, struct list_head *del);
void uvc_device_user_del_frame(void* device, void *get_f);
void process_uvc_payload(uint8_t dev_num, uint8_t ep_type, uint8_t video_format, uint8_t *payload, uint32_t payload_len, bool drop);
#endif

View File

@@ -0,0 +1,120 @@
#ifndef _VPP_DEV_H_
#define _VPP_DEV_H_
#include "hal/vpp.h"
#define VPP_INPUT_FORMAT 0 //0:YUV422
//1:RGB888/RAW
#define IN_DVP0 0
#define IN_DVP1 1
#define IN_MIPI_CSI0 2
#define IN_MIPI_CSI1 3
#define IN_ISP 4
#define IN_GEN422 5
#define IN_PARA_IN 6
#ifndef VPP_INPUT_FROM
#define VPP_INPUT_FROM IN_ISP
#endif
enum
{
ISP_VIDEO_0,
ISP_VIDEO_1,
ISP_VIDEO_2,
};
typedef enum {
SCALER3_DONE = 0,
JPG0_DONE,
JPG1_DONE,
SCALE1_JPG_ENCODE,
VPP_IFP_EN_CTRL,
VPP_FUNC_DONE_NUM,
}VPP_FUNC_DONE;
typedef int32_t (*scale3_kick_fn)();
//ret :0 --->keep running 1 --->run one time
typedef int32_t (*func_done_fn)(uint32 irq_data);
struct video_cfg_t {
uint8_t video_num;
uint8_t video_type_cur; //cur frame is ISP_VIDEO_0/1/2
uint8_t video_type_last; //last frame is ISP_VIDEO_0/1/2
uint8_t video_type_vpp; //vpp runing which frame ,app maybe use
uint8_t resv;
uint16_t dvp_iw;
uint16_t dvp_ih;
uint16_t dvp_ow;
uint16_t dvp_oh;
uint16_t dvp_type; //0:no device 1:master 2:slave0 3:slave1
uint16_t csi0_iw;
uint16_t csi0_ih;
uint16_t csi0_ow;
uint16_t csi0_oh;
uint16_t csi0_type; //0:master 1:slave0 2:slave1
uint16_t csi1_iw;
uint16_t csi1_ih;
uint16_t csi1_ow;
uint16_t csi1_oh;
uint16_t csi1_type; //0:master 1:slave0 2:slave1
};
struct mdt_coord_msg {
uint16_t x0,x1;
uint16_t y0,y1;
uint16_t x,y;
uint8_t blkmv_cnt;
};
enum
{
VPP_MODE_2N_ADD_16 = 0, //[16,32] 2N+16
VPP_MODE_2N, //[0,16] 2N
};
#ifndef SCALE1_FROM_VPPBF
#define SCALE1_FROM_VPPBF 0//0:VPP BUF0 1:VPP BUF1
#endif
#ifndef SCALE3_FROM_VPPBF
#define SCALE3_FROM_VPPBF 0//0:VPP BUF0 1:VPP BUF1
#endif
#ifndef VPP_BUF0_MODE
#define VPP_BUF0_MODE VPP_MODE_2N_ADD_16
#endif
#ifndef VPP_BUF1_MODE
#define VPP_BUF1_MODE VPP_MODE_2N_ADD_16
#endif
//注意这里配置的N,所以实际根据MODE决定申请空间
#ifndef VPP_BUF0_LINEBUF_NUM
#define VPP_BUF0_LINEBUF_NUM 8
#endif
#ifndef VPP_BUF1_LINEBUF_NUM
#define VPP_BUF1_LINEBUF_NUM 6
#endif
extern struct video_cfg_t video_msg;
bool vpp_cfg(uint32_t w,uint32_t h,uint8_t input_from);
void vpp_itp_save_only(struct vpp_device *p_vpp,uint16_t w,uint16_t h,uint32_t psram_adr);
uint8_t vpp_video_type_map(uint8_t stype);
int32 vppdone_func_register(uint8_t id,func_done_fn func,uint32 arg);
int32 vppdone_func_unregister(uint8_t id);
uint8_t get_vpp_w_h(uint16_t *w, uint16_t *h);
void set_vpp_scale_w_h(uint8_t en, uint16_t w, uint16_t h);
uint8_t get_vpp1_w_h(uint16_t *w, uint16_t *h);
void *get_vpp_buf(uint8_t which);
int8_t vpp_dev_open();
int32 vpp_is_closed(struct vpp_device *p_vpp);
#endif