pure sdk for main

This commit is contained in:
divadiow
2025-08-27 09:51:58 +01:00
parent f0d033f1c9
commit 0571416e7c
3283 changed files with 1577720 additions and 1 deletions
+438
View File
@@ -0,0 +1,438 @@
#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"
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 {
uint8 w_cmd,r_cmd,id,addr_num,data_num;
uint16 id_reg;//id ¼Ä´æÆ÷µØÖ·
uint8 * init;
uint8 * preset;
uint16 typ; //0: raw 1:yuv 2:mipi
uint32 mclk;
uint32 pclk_fir_en;
uint16 pixelw;
uint16 pixelh;
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_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;
Vpp_stream photo_msg;
void Delay_nopCnt(uint32 cnt);
int sensorCheckId(struct i2c_device *p_iic,const _Sensor_Ident_ *p_sensor_ident,const _Sensor_Adpt_ *p_sensor_adpt);
//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);
void vpp_put_psram(uint32 yuvbuf_addr,uint32 s_w,uint32 s_h);
//////////////////////////////////////////COMMON//////////////////////////////////////////////////////////////////////
#define IMAGE_W 640
#define IMAGE_H 480
#define IMAGE_FORMAT 0 //0:YUV
//1:RGB565
//2:JPEG
#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 //0:YUYV
//1:YVYU
//2:UYVY
//3:VYUY
#define ONLY_Y 0
////////////////////////////////////////////////////////JPEG//////////////////////////////////////////////////////////////////
#define JPEG_LEN 2*1024
#ifdef TXW81X
#define SCALE_TO_JPG 0
#define SCALE_WIDTH_TO_JPEG 1280
#define SCALE_HIGH_TO_JPEG 720
#define IPF_EN 0
#define DET_EN 0
#if BBM_DEMO
#define VPP_BUF1_EN 1
#else
#define VPP_BUF1_EN 0
#endif
#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_OV7660
#define DEV_SENSOR_OV7660 (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_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_NT99230
#define DEV_SENSOR_NT99230 0
#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_BF30A2
#define DEV_SENSOR_BF30A2 (0||CMOS_AUTO_LOAD)
#endif
#ifndef DEV_SENSOR_IOT101
#define DEV_SENSOR_IOT101 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_OV7660
extern const _Sensor_Ident_ ov7660_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ ov7660_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_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_BF30A2
extern const _Sensor_Ident_ bf30a2_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ bf30a2_cmd;
#endif
#if DEV_SENSOR_NT99230
extern const _Sensor_Ident_ nt99230_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ nt99230_cmd;
#endif
#if DEV_SENSOR_IOT101
extern const _Sensor_Ident_ sc101iot_init;
extern SENSOR_OP_SECTION const _Sensor_Adpt_ sc101iot_cmd;
#endif
#endif
@@ -0,0 +1,4 @@
#ifndef _CSIV2_MODE_DEFINE_
#define _CSIV2_MODE_DEFINE_
void set_time_watermark(uint16 year,uint16 month,uint16 day,uint16 hour,uint16 min,uint16 sec);
#endif
+77
View File
@@ -0,0 +1,77 @@
#ifndef _JPG_MODE_DEFINE_
#define _JPG_MODE_DEFINE_
#define DQT_DEF 6
#define DQT_MAX_INDEX 11
#define TARGET_JPG_LEN 15000
#define QUALITY_CTRL_P 131
#define QUALITY_CTRL_I 8
#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_SRC_FROM {
VPP_DATA0,
VPP_DATA1,
PRC_DATA,
SCALER_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
+45
View File
@@ -0,0 +1,45 @@
#ifndef _HG_USB_DEVICE_H
#define _HG_USB_DEVICE_H
#define USB_TEST_WIFI 0
#define USB_TEST_AUDIO 0
#define USB_TEST_MASS 1
#define RX_BUFF_SIZE 1024
struct hg_usb_device_test {
#if USB_TEST_WIFI
//正常host不需要使用
#if USB_HOST_EN
int8 rx_buf[4]; /* usb rx buffer reserved 4byte for no overflow control */
int8 tx_buf[4];
#else
int8 rx_buf[512*16+4]; /* usb rx buffer reserved 4byte for no overflow control */
int8 tx_buf[512*16];
#endif
#endif
#if USB_TEST_AUDIO
int8 rx_buf[512*4+4];
int8 tx_buf[512*4];
#endif
#if USB_TEST_MASS
int8 rx_buf[RX_BUFF_SIZE]; /* usb rx buffer reserved 4byte for no overflow control */
int8 tx_buf[RX_BUFF_SIZE];
#else
int8 rx_buf[512]; /* usb rx buffer reserved 4byte for no overflow control */
int8 tx_buf[512];
#endif
int32 ready;
uint32 total_tx_len;
uint32 total_rx_len;
struct os_mutex rx_lock;
struct os_mutex tx_lock;
struct os_semaphore sem;
struct usb_device *dev;
struct os_task scsi_task;
struct os_task sd_task;
};
#endif