This commit is contained in:
huxi
2025-12-03 11:12:34 +08:00
parent c23ae4f24c
commit bc195654bf
8163 changed files with 3799544 additions and 92 deletions
+24
View File
@@ -0,0 +1,24 @@
#ifndef FONT_ASCII_H
#define FONT_ASCII_H
#include "typedef.h"
void font_ascii_get_width_and_height(char code, int *height, int *width);
int font_ascii_get_pix(char code, u8 *pixbuf, int buflen, int *height, int *width);
int font_ascii_width_check(const char *str);
#endif
+156
View File
@@ -0,0 +1,156 @@
#ifndef _JPEG_DECODER_H_
#define _JPEG_DECODER_H_
#include "typedef.h"
#include "system/task.h"
#include "generic/rect.h"
extern u16 QT_TBL[0x80];
extern u16 STD_HUFFMAN_TBL[258];
#define QTAB_ADDR ((s16 *)(QT_TBL))
#define HTAB_DC0_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL)) // 0x30
#define HTAB_AC0_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL + 0x30)) // 0xd2
#define HTAB_DC1_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL + 0x30 + 0xd2)) // 0x30
#define HTAB_AC1_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL + 0x30 + 0xd2 + 0x30)) // 0xd2
#define JPG_SAMP_FMT_INVALID 0x0
#define JPG_SAMP_FMT_YUV444 0x1
#define JPG_SAMP_FMT_YUV422 0x2
#define JPG_SAMP_FMT_YUV420 0x3
#define jpg_be16_to_cpu(x) (((x)[0] << 8) | (x)[1])
#define SINGLE_BUFFER_MODE 0x0
#define DOUBLE_BUFFER_MODE 0x1
enum {
RGB888,
RGB565,
};
struct jpeg_yuv {
u8 *y;
u8 *u;
u8 *v;
};
struct jpeg_data {
u8 *buf;
u32 len;
};
struct jpeg_codec_handle {
JL_JPG_TypeDef *reg;
struct jpeg_decoder_fd *decoder_fd;
OS_SEM sem;
};
enum std_markers {
DQT = 0xDB,
SOF = 0xC0,
DHT = 0xC4,
SOI = 0xD8,
SOS = 0xDA,
RST = 0xD0,
RST7 = 0xD7,
EOI = 0xD9,
DRI = 0xDD,
APP0 = 0xE0,
};
struct decoder_info {
u16 x;
u16 y;
u16 x_mcu_num;
u16 y_mcu_num;
u16 x_mcu_cnt;
u16 y_mcu_cnt;
u8 mcu_h;
u8 samp_Y;
u8 htab_Y;
u8 htab_Cr;
u8 htab_Cb;
u8 qtab_Y;
u8 qtab_Cr;
u8 qtab_Cb;
u8 y_cnt;
};
typedef u8 *(*jpg_stream_input)(void *__fat_info, u32 *len, u32 offset_4k);
struct jpeg_decoder_fd {
void *parent;
struct decoder_info info;
struct jpeg_yuv yuv;
struct jpeg_yuv yuv0;
struct jpeg_yuv yuv1;
struct jpeg_data data;
u32 mcu_num;
u32 head_len;
u8 *stream;
//u8 *stream_end;
u8 *cur_stream;
u32 bits_cnt;
u32 cur_bits_cnt;
u8 yuv_type;
u8 last_rst_marker_seen;
u8 DRI_enable;
u8 next_rst;
u8 rst_flag;
u8 mcupnd_flag;
u32 next_rst_bits_cnt;
u32 restart_interval;
u32 rst_mcu_cnt;
u16 row_mcu_num;
u8 rgb_format;
u16 seg_idx;
u16 seg_num;
// u16 lcd_width;
// u16 lcd_height;
u16 need_dec_mcu_num;
u8 data_out_mode;
u8 buf_flag;
u8 *fb;
u8 *fb0;
u8 *fb1;
u8 *hbuf;
u8 fend;
u8 stop_flag;
u8 head_buf[512];
u8 fd_free_enable;
void *fat_info;
jpg_stream_input jpg_ginfo_cb;
u32 fb_size;
u8 *jpg_obuf;
struct rect cur_draw;
struct rect draw_rect;
struct rect jpeg_rect;
};
int jpeg_dec_init(void *fat_info, u8 lcd_format, jpg_stream_input jpg_ginfo_cb);
int jpeg_dec_start(struct rect *cur_draw, struct rect *draw_rect, struct rect *jpeg_rect, void *dec_out_buf);
struct jpeg_decoder_fd *jpeg_dec_get_fd();
void jpeg_dec_stop();
void jpeg_dec_uninit();
int jpeg_decoder_open(struct jpeg_decoder_fd *fd);
int _jpeg_parse_header(struct jpeg_decoder_fd *fd, u8 *buf, int len);
int jpeg_decode_area(struct jpeg_decoder_fd *decoder_fd);
int jpeg_decoder_start(void *_fd);
int jpeg_decoder_init(struct jpeg_decoder_fd *fd);
int decoder_bits_pnd_handler(struct jpeg_decoder_fd *fd);
int decoder_mcu_pnd_handler(struct jpeg_decoder_fd *fd);
int jpeg_decoder_manual_start(void *_fd);
int jpeg_decoder_close(void *fd);
int jpeg_codec_init(void);
extern u8 *jpg_ginfo(void *__fat_info, u32 *len, u32 offset_4k);
int ui_jpeg_decoder_init();
int ui_jpeg_decoder_uninit();
#endif
+38
View File
@@ -0,0 +1,38 @@
#ifndef MEM_VAR_H
#define MEM_VAR_H
#include "typedef.h"
#include "generic/list.h"
struct mem_var_element {
u16 crc;
u16 checksum;
u16 len;
u8 buf[0];
};
struct mem_var {
struct list_head head;
struct mem_var_element var;
};
struct mem_var_head {
struct list_head head;
int total_mem_size;
int items;
int use_mem_size;
int hits;
u8 debug;
};
extern struct mem_var_head var_list;
void mem_var_init(u32 size, u8 debug);
int mem_var_add(u32 index, u32 type, u32 id, u32 page, u32 prj, u8 *buf, u16 len);
void mem_var_free();
int mem_var_del(struct mem_var *var);
void mem_var_get(struct mem_var *var, u8 *buf, u16 len);
struct mem_var *mem_var_search(u32 index, u32 type, u32 id, u32 page, u32 prj);
void mem_var_stat();
#endif
+227
View File
@@ -0,0 +1,227 @@
#ifndef RESFILE_H
#define RESFILE_H
#include "typedef.h"
#include "fs/fs.h"
#include "fs/sdfile.h"
// resfile共用文件句柄
#if (defined(CONFIG_CPU_BR23) && defined(CONFIG_APP_WATCH))
#define RESFILE_COMMON_HDL_EN 0
#else
#define RESFILE_COMMON_HDL_EN 0
#endif
#define FILE_TYPE_JPEG 5
#ifndef AT_UI_RAM
#define AT_UI_RAM //AT(.ui_ram)
#endif
//文本数据格式
enum {
TEXT_1BPP,
TEXT_2BPP,
TEXT_4BPP,
TEXT_8BPP,
};
//图像数据格式
enum {
PIXEL_FMT_ARGB8888,
PIXEL_FMT_ARGB8565,
PIXEL_FMT_ARGB1555,
PIXEL_FMT_ARGB4444,
PIXEL_FMT_RGB888,
PIXEL_FMT_RGB565,
PIXEL_FMT_AL88,
PIXEL_FMT_AL44,
PIXEL_FMT_AL22,
PIXEL_FMT_L8,
PIXEL_FMT_L4,
PIXEL_FMT_L2,
PIXEL_FMT_L1,
PIXEL_FMT_A8,
PIXEL_FMT_A4,
PIXEL_FMT_A2,
PIXEL_FMT_A1,
PIXEL_FMT_JPEG,
PIXEL_FMT_GIF,
};
struct image_file {
u8 format;
u8 clut_format;
u8 compress;
u8 has_clut;
u8 strpic_mode;
u16 data_crc;
u16 width;
u16 height;
u32 offset;
u32 len;
u32 unzipOffset;
u32 unzipLen;
};
struct file_cache {
struct list_head entry;
u32 addr;
u32 len;
u8 *buf;
u16 crc;
};
typedef struct ui_resfile {
FILE *file;
int offset;
u32 ver;
char fname[64];
struct list_head root;
#if RESFILE_COMMON_HDL_EN
struct list_head entry;
u32 offset;
u32 size;
#endif
u32 in_addr;
u32 in_len;
} UI_RESFILE;
struct flashheader {
u16 crc16;
u16 crcfileheaddata;
u8 info[8];
u32 filenum;
u32 version;
u32 version1;
u8 chiptype[8];
};
struct flashfilehead {
u8 filetype;
u8 reserv;
u16 crc16;
u32 addr;
u32 len;
u32 version;
u8 name[64];
};
struct myfile {
SDFILE *file;
FILE *_file;
u8 name[64];
u32 addr;
u32 len;
};
struct flash_file_info {
u32 *tab;
u16 tab_size;
u32 offset;
u32 last_tab_data_len;
};
#define PHY_JL_EXTERN_FLASH 0 //杰理外挂fat 文件系统方案
#define PHY_JL_INSERT_FLASH 1 //杰理内置flash 文件系统方案
#define PHY_JL_NAND_FLASH 2 //nandflash文件系统方案
//针对内封flash 场景 ui 硬件模块需要获取知道当前路径是挂靠在内置flash 还是 外挂flash
struct ui_load_info {
u8 pj_id;
u8 mmu_tab;
u8 phy_dev;
//针对内封flash 场景 ui 硬件模块需要获取知道当前路径是挂靠在内置flash 还是 外挂flash
u32 phy_addr;
//针对内封flash 场景 设备的物理地址不是从0开始的,需要告诉硬件模块偏移
const char *path;
UI_RESFILE *file;
UI_RESFILE *res;
UI_RESFILE *str;
struct flash_file_info image_file_info;
struct flash_file_info str_file_info;
};
int open_resfile(const char *name);
void close_resfile();
int open_str_file(const char *name);
void close_str_file();
int open_style_file(const char *name);
int res_file_version_compare(int res_ver);
int str_file_version_compare(int str_ver);
int sty_file_check(UI_RESFILE *file);
int font_ascii_init(const char *name);
int load_pallet_table(int id, u32 *data);
int ui_language_set(int language);
int ui_language_get();
UI_RESFILE *res_fopen(const char *path, const char *mode);
int res_fread(UI_RESFILE *_file, void *buf, u32 len);
int res_fseek(UI_RESFILE *_file, int offset, int fromwhere);
int res_cache(UI_RESFILE *_file, int addr, u32 len);
int res_nocache(UI_RESFILE *_file, int addr, u32 len);
int res_flen(UI_RESFILE *file);
int res_fclose(UI_RESFILE *file);
int _norflash_read_watch(u8 *buf, u32 addr, u32 len, u8 wait);//加速读
int ui_prj_info_table_init(
struct ui_load_info *info,
void *(*malloc)(int size, u32 ram_type, u32 module_type),
void (*free)(void *p, u32 ram_type, u32 module_type));
int ui_prj_info_table_release();
void *ui_load_res_by_pj_id(int pj_id);
void *ui_load_str_by_pj_id(int pj_id);
void *ui_load_sty_by_pj_id(int pj_id);
void *ui_get_image_file_info_by_pj_id(int pj_id);
void *ui_get_str_file_info_by_pj_id(int pj_id);
int ui_unload_file_info_not_contain_prj_id(u8 pj_id);
int ui_res_flash_info_get(struct flash_file_info *file_info, char *path, char *str, int mmu_tab);
void ui_res_flash_info_free(struct flash_file_info *file_info, char *str);
int ui_res_get_image_flash_info(struct flash_file_info *image_info, struct flash_file_info *prj_info, struct image_file *img_file);
int ui_res_get_flash_tab_info(struct flash_file_info *file_info, u32 file_base_addr, u32 filelen);
int ui_set_sty_path_by_pj_id(int pj_id, const u8 *path);
int __ui_res_flash_info_get(struct flash_file_info *file_info, char *path, char *str, u8 phy_dev, u32 phy_addr, int mmu_tab);
int ui_res_file_open(struct ui_load_info *info, const u8 *path, const char *mode);
int ui_unload_file_info();
void select_resfile(u8 index);
void select_strfile(u8 index);
int open_image_by_id(int prj, UI_RESFILE *specfile, struct image_file *f, int id, int page);
int open_image_by_addr_id(struct image_file *f, u32 res_addr, int id, int page_num);
int read_image_data(int prj, UI_RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
int br23_read_image_data(int prj, UI_RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
int br25_read_image_data(UI_RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
u32 image_decode(const void *pSour, void *pDest, u32 SourLen, u32 DestLen, u8 compress);
int open_string_pic(int prj, struct image_file *file, int id);
int open_string_by_id(int prj, UI_RESFILE *specfile, struct image_file *f, int id);
int read_str_data(struct image_file *f, u8 *data, int len);
int br23_read_str_data(struct image_file *f, u8 *data, int len, int offset);
int br25_read_str_data(struct image_file *f, u8 *data, int len, int offset);
int read_string_type(int prj, int id);
int open_string_pic2(int prj, struct image_file *file, int id);
int ui_res_cache_head(UI_RESFILE *file);
int ui_res_cache(UI_RESFILE *file, int page_num);
int ui_res_nocache(UI_RESFILE *file, int page_num);
int ui_str_cache(UI_RESFILE *file, int language_index);
int ui_str_nocache(UI_RESFILE *file, int language_index);
int ui_sty_cache(UI_RESFILE *file, int page);
int ui_sty_nocache(UI_RESFILE *file, int page);
int ui_sty_cache_head(UI_RESFILE *file);
int res_get_image_stride(int gpu_format, struct image_file *image, u8 *adr_mode, u8 *compress_mode, int *compress_size);
int res_get_image_len(u32 gpu_format, int height, u32 adr_mode, u32 compress_mode, u32 compress_size, u32 stride);
#endif
+7
View File
@@ -0,0 +1,7 @@
#ifndef _ZZ_H_
#define _ZZ_H_
int text_decompress(void *dst, int dst_len, void *src, int src_len);
#endif